40 #ifndef OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
41 #define OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
59 template<
typename DerivedType,
typename Gr
idT,
bool IsSafe>
68 typedef typename BufferType::iterator
IterType;
76 mStencil[0] = mCache.getValue(ijk);
77 static_cast<DerivedType&
>(*this).init(mCenter);
85 inline void moveTo(
const Coord& ijk,
const ValueType& centerValue)
88 mStencil[0] = centerValue;
89 static_cast<DerivedType&
>(*this).init(mCenter);
97 template<
typename IterType>
98 inline void moveTo(
const IterType& iter)
100 mCenter = iter.getCoord();
102 static_cast<DerivedType&
>(*this).init(mCenter);
113 Coord ijk = openvdb::Coord::floor(xyz);
114 if (ijk != mCenter) this->moveTo(ijk);
122 inline const ValueType&
getValue(
unsigned int pos = 0)
const
124 assert(pos < mStencil.size());
125 return mStencil[pos];
129 template<
int i,
int j,
int k>
132 return mStencil[
static_cast<const DerivedType&
>(*this).template pos<i,j,k>()];
136 template<
int i,
int j,
int k>
139 mStencil[
static_cast<const DerivedType&
>(*this).template pos<i,j,k>()] = value;
143 inline int size() {
return mStencil.size(); }
148 BufferType tmp(mStencil);
149 assert(!tmp.empty());
150 size_t midpoint = (tmp.size() - 1) >> 1;
152 std::nth_element(tmp.begin(), tmp.begin() + midpoint, tmp.end());
153 return tmp[midpoint];
160 for (
int n = 0, s =
int(mStencil.size()); n < s; ++n) sum += mStencil[n];
161 return sum / mStencil.size();
165 inline ValueType
min()
const
167 IterType iter = std::min_element(mStencil.begin(), mStencil.end());
172 inline ValueType
max()
const
174 IterType iter = std::max_element(mStencil.begin(), mStencil.end());
186 inline bool intersects(
const ValueType &isoValue = zeroVal<ValueType>())
const
188 const bool less = this->getValue< 0, 0, 0>() < isoValue;
189 return (less ^ (this->getValue<-1, 0, 0>() < isoValue)) ||
190 (less ^ (this->getValue< 1, 0, 0>() < isoValue)) ||
191 (less ^ (this->getValue< 0,-1, 0>() < isoValue)) ||
192 (less ^ (this->getValue< 0, 1, 0>() < isoValue)) ||
193 (less ^ (this->getValue< 0, 0,-1>() < isoValue)) ||
194 (less ^ (this->getValue< 0, 0, 1>() < isoValue)) ;
199 inline const GridType&
grid()
const {
return *mGrid; }
203 inline const AccessorType&
accessor()
const {
return mCache; }
209 , mCache(grid.tree())
229 template<
int i,
int j,
int k>
struct SevenPt {};
230 template<>
struct SevenPt< 0, 0, 0> {
enum { idx = 0 }; };
231 template<>
struct SevenPt< 1, 0, 0> {
enum { idx = 1 }; };
232 template<>
struct SevenPt< 0, 1, 0> {
enum { idx = 2 }; };
233 template<>
struct SevenPt< 0, 0, 1> {
enum { idx = 3 }; };
234 template<>
struct SevenPt<-1, 0, 0> {
enum { idx = 4 }; };
235 template<>
struct SevenPt< 0,-1, 0> {
enum { idx = 5 }; };
236 template<>
struct SevenPt< 0, 0,-1> {
enum { idx = 6 }; };
241 template<
typename Gr
idT,
bool IsSafe = true>
251 static const int SIZE = 7;
256 template<
int i,
int j,
int k>
257 unsigned int pos()
const {
return SevenPt<i,j,k>::idx; }
260 inline void init(
const Coord& ijk)
262 BaseType::template setValue<-1, 0, 0>(mCache.getValue(ijk.
offsetBy(-1, 0, 0)));
263 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
265 BaseType::template setValue< 0,-1, 0>(mCache.getValue(ijk.
offsetBy( 0,-1, 0)));
266 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
268 BaseType::template setValue< 0, 0,-1>(mCache.getValue(ijk.
offsetBy( 0, 0,-1)));
269 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
273 using BaseType::mCache;
274 using BaseType::mStencil;
284 template<
int i,
int j,
int k>
struct BoxPt {};
285 template<>
struct BoxPt< 0, 0, 0> {
enum { idx = 0 }; };
286 template<>
struct BoxPt< 0, 0, 1> {
enum { idx = 1 }; };
287 template<>
struct BoxPt< 0, 1, 1> {
enum { idx = 2 }; };
288 template<>
struct BoxPt< 0, 1, 0> {
enum { idx = 3 }; };
289 template<>
struct BoxPt< 1, 0, 0> {
enum { idx = 4 }; };
290 template<>
struct BoxPt< 1, 0, 1> {
enum { idx = 5 }; };
291 template<>
struct BoxPt< 1, 1, 1> {
enum { idx = 6 }; };
292 template<>
struct BoxPt< 1, 1, 0> {
enum { idx = 7 }; };
295 template<
typename Gr
idT,
bool IsSafe = true>
305 static const int SIZE = 8;
310 template<
int i,
int j,
int k>
311 unsigned int pos()
const {
return BoxPt<i,j,k>::idx; }
315 inline bool intersects(
const ValueType &isoValue = zeroVal<ValueType>())
const
317 const bool less = mStencil[0] < isoValue;
318 return (less ^ (mStencil[1] < isoValue)) ||
319 (less ^ (mStencil[2] < isoValue)) ||
320 (less ^ (mStencil[3] < isoValue)) ||
321 (less ^ (mStencil[4] < isoValue)) ||
322 (less ^ (mStencil[5] < isoValue)) ||
323 (less ^ (mStencil[6] < isoValue)) ||
324 (less ^ (mStencil[7] < isoValue)) ;
336 const Real u = xyz[0] - BaseType::mCenter[0]; assert(u>=0 && u<=1);
337 const Real v = xyz[1] - BaseType::mCenter[1]; assert(v>=0 && v<=1);
338 const Real w = xyz[2] - BaseType::mCenter[2]; assert(w>=0 && w<=1);
340 ValueType V = BaseType::template getValue<0,0,0>();
341 ValueType A =
static_cast<ValueType
>(V + (BaseType::template getValue<0,0,1>() - V) * w);
342 V = BaseType::template getValue< 0, 1, 0>();
343 ValueType B =
static_cast<ValueType
>(V + (BaseType::template getValue<0,1,1>() - V) * w);
344 ValueType C =
static_cast<ValueType
>(A + (B - A) * v);
346 V = BaseType::template getValue<1,0,0>();
347 A =
static_cast<ValueType
>(V + (BaseType::template getValue<1,0,1>() - V) * w);
348 V = BaseType::template getValue<1,1,0>();
349 B =
static_cast<ValueType
>(V + (BaseType::template getValue<1,1,1>() - V) * w);
350 ValueType D =
static_cast<ValueType
>(A + (B - A) * v);
352 return static_cast<ValueType
>(C + (D - C) * u);
364 const Real u = xyz[0] - BaseType::mCenter[0]; assert(u>=0 && u<=1);
365 const Real v = xyz[1] - BaseType::mCenter[1]; assert(v>=0 && v<=1);
366 const Real w = xyz[2] - BaseType::mCenter[2]; assert(w>=0 && w<=1);
368 ValueType D[4]={BaseType::template getValue<0,0,1>()-BaseType::template getValue<0,0,0>(),
369 BaseType::template getValue<0,1,1>()-BaseType::template getValue<0,1,0>(),
370 BaseType::template getValue<1,0,1>()-BaseType::template getValue<1,0,0>(),
371 BaseType::template getValue<1,1,1>()-BaseType::template getValue<1,1,0>()};
374 ValueType A =
static_cast<ValueType
>(D[0] + (D[1]- D[0]) * v);
375 ValueType B =
static_cast<ValueType
>(D[2] + (D[3]- D[2]) * v);
377 zeroVal<ValueType>(),
378 static_cast<ValueType>(A + (B - A) * u));
380 D[0] =
static_cast<ValueType
>(BaseType::template getValue<0,0,0>() + D[0] * w);
381 D[1] =
static_cast<ValueType
>(BaseType::template getValue<0,1,0>() + D[1] * w);
382 D[2] =
static_cast<ValueType
>(BaseType::template getValue<1,0,0>() + D[2] * w);
383 D[3] =
static_cast<ValueType
>(BaseType::template getValue<1,1,0>() + D[3] * w);
386 A =
static_cast<ValueType
>(D[0] + (D[1] - D[0]) * v);
387 B =
static_cast<ValueType
>(D[2] + (D[3] - D[2]) * v);
395 grad[1] =
static_cast<ValueType
>(A + (B - A) * u);
397 return BaseType::mGrid->transform().baseMap()->applyIJT(grad, xyz);
401 inline void init(
const Coord& ijk)
403 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
404 BaseType::template setValue< 0, 1, 1>(mCache.getValue(ijk.
offsetBy( 0, 1, 1)));
405 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
406 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
407 BaseType::template setValue< 1, 0, 1>(mCache.getValue(ijk.
offsetBy( 1, 0, 1)));
408 BaseType::template setValue< 1, 1, 1>(mCache.getValue(ijk.
offsetBy( 1, 1, 1)));
409 BaseType::template setValue< 1, 1, 0>(mCache.getValue(ijk.
offsetBy( 1, 1, 0)));
413 using BaseType::mCache;
414 using BaseType::mStencil;
424 template<
int i,
int j,
int k>
struct DensePt {};
425 template<>
struct DensePt< 0, 0, 0> {
enum { idx = 0 }; };
427 template<>
struct DensePt< 1, 0, 0> {
enum { idx = 1 }; };
428 template<>
struct DensePt< 0, 1, 0> {
enum { idx = 2 }; };
429 template<>
struct DensePt< 0, 0, 1> {
enum { idx = 3 }; };
431 template<>
struct DensePt<-1, 0, 0> {
enum { idx = 4 }; };
432 template<>
struct DensePt< 0,-1, 0> {
enum { idx = 5 }; };
433 template<>
struct DensePt< 0, 0,-1> {
enum { idx = 6 }; };
435 template<>
struct DensePt<-1,-1, 0> {
enum { idx = 7 }; };
436 template<>
struct DensePt< 0,-1,-1> {
enum { idx = 8 }; };
437 template<>
struct DensePt<-1, 0,-1> {
enum { idx = 9 }; };
439 template<>
struct DensePt< 1,-1, 0> {
enum { idx = 10 }; };
440 template<>
struct DensePt< 0, 1,-1> {
enum { idx = 11 }; };
441 template<>
struct DensePt<-1, 0, 1> {
enum { idx = 12 }; };
443 template<>
struct DensePt<-1, 1, 0> {
enum { idx = 13 }; };
444 template<>
struct DensePt< 0,-1, 1> {
enum { idx = 14 }; };
445 template<>
struct DensePt< 1, 0,-1> {
enum { idx = 15 }; };
447 template<>
struct DensePt< 1, 1, 0> {
enum { idx = 16 }; };
448 template<>
struct DensePt< 0, 1, 1> {
enum { idx = 17 }; };
449 template<>
struct DensePt< 1, 0, 1> {
enum { idx = 18 }; };
454 template<
typename Gr
idT,
bool IsSafe = true>
456 :
public BaseStencil<SecondOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe >
465 static const int SIZE = 19;
470 template<
int i,
int j,
int k>
471 unsigned int pos()
const {
return DensePt<i,j,k>::idx; }
474 inline void init(
const Coord& ijk)
476 mStencil[DensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
477 mStencil[DensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
478 mStencil[DensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
480 mStencil[DensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
481 mStencil[DensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
482 mStencil[DensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
484 mStencil[DensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, -1, 0));
485 mStencil[DensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, -1, 0));
486 mStencil[DensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
487 mStencil[DensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
489 mStencil[DensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, -1));
490 mStencil[DensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, -1));
491 mStencil[DensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
492 mStencil[DensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
494 mStencil[DensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, -1));
495 mStencil[DensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, -1));
496 mStencil[DensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 1));
497 mStencil[DensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
501 using BaseType::mCache;
502 using BaseType::mStencil;
512 template<
int i,
int j,
int k>
struct ThirteenPt {};
513 template<>
struct ThirteenPt< 0, 0, 0> {
enum { idx = 0 }; };
515 template<>
struct ThirteenPt< 1, 0, 0> {
enum { idx = 1 }; };
516 template<>
struct ThirteenPt< 0, 1, 0> {
enum { idx = 2 }; };
517 template<>
struct ThirteenPt< 0, 0, 1> {
enum { idx = 3 }; };
519 template<>
struct ThirteenPt<-1, 0, 0> {
enum { idx = 4 }; };
520 template<>
struct ThirteenPt< 0,-1, 0> {
enum { idx = 5 }; };
521 template<>
struct ThirteenPt< 0, 0,-1> {
enum { idx = 6 }; };
523 template<>
struct ThirteenPt< 2, 0, 0> {
enum { idx = 7 }; };
524 template<>
struct ThirteenPt< 0, 2, 0> {
enum { idx = 8 }; };
525 template<>
struct ThirteenPt< 0, 0, 2> {
enum { idx = 9 }; };
527 template<>
struct ThirteenPt<-2, 0, 0> {
enum { idx = 10 }; };
528 template<>
struct ThirteenPt< 0,-2, 0> {
enum { idx = 11 }; };
529 template<>
struct ThirteenPt< 0, 0,-2> {
enum { idx = 12 }; };
534 template<
typename Gr
idT,
bool IsSafe = true>
536 :
public BaseStencil<ThirteenPointStencil<GridT, IsSafe>, GridT, IsSafe>
545 static const int SIZE = 13;
550 template<
int i,
int j,
int k>
551 unsigned int pos()
const {
return ThirteenPt<i,j,k>::idx; }
554 inline void init(
const Coord& ijk)
556 mStencil[ThirteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
557 mStencil[ThirteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
558 mStencil[ThirteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
559 mStencil[ThirteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
561 mStencil[ThirteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
562 mStencil[ThirteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
563 mStencil[ThirteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
564 mStencil[ThirteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
566 mStencil[ThirteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
567 mStencil[ThirteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
568 mStencil[ThirteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
569 mStencil[ThirteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
573 using BaseType::mCache;
574 using BaseType::mStencil;
584 template<
int i,
int j,
int k>
struct FourthDensePt {};
585 template<>
struct FourthDensePt< 0, 0, 0> {
enum { idx = 0 }; };
587 template<>
struct FourthDensePt<-2, 2, 0> {
enum { idx = 1 }; };
588 template<>
struct FourthDensePt<-1, 2, 0> {
enum { idx = 2 }; };
589 template<>
struct FourthDensePt< 0, 2, 0> {
enum { idx = 3 }; };
590 template<>
struct FourthDensePt< 1, 2, 0> {
enum { idx = 4 }; };
591 template<>
struct FourthDensePt< 2, 2, 0> {
enum { idx = 5 }; };
593 template<>
struct FourthDensePt<-2, 1, 0> {
enum { idx = 6 }; };
594 template<>
struct FourthDensePt<-1, 1, 0> {
enum { idx = 7 }; };
595 template<>
struct FourthDensePt< 0, 1, 0> {
enum { idx = 8 }; };
596 template<>
struct FourthDensePt< 1, 1, 0> {
enum { idx = 9 }; };
597 template<>
struct FourthDensePt< 2, 1, 0> {
enum { idx = 10 }; };
599 template<>
struct FourthDensePt<-2, 0, 0> {
enum { idx = 11 }; };
600 template<>
struct FourthDensePt<-1, 0, 0> {
enum { idx = 12 }; };
601 template<>
struct FourthDensePt< 1, 0, 0> {
enum { idx = 13 }; };
602 template<>
struct FourthDensePt< 2, 0, 0> {
enum { idx = 14 }; };
604 template<>
struct FourthDensePt<-2,-1, 0> {
enum { idx = 15 }; };
605 template<>
struct FourthDensePt<-1,-1, 0> {
enum { idx = 16 }; };
606 template<>
struct FourthDensePt< 0,-1, 0> {
enum { idx = 17 }; };
607 template<>
struct FourthDensePt< 1,-1, 0> {
enum { idx = 18 }; };
608 template<>
struct FourthDensePt< 2,-1, 0> {
enum { idx = 19 }; };
610 template<>
struct FourthDensePt<-2,-2, 0> {
enum { idx = 20 }; };
611 template<>
struct FourthDensePt<-1,-2, 0> {
enum { idx = 21 }; };
612 template<>
struct FourthDensePt< 0,-2, 0> {
enum { idx = 22 }; };
613 template<>
struct FourthDensePt< 1,-2, 0> {
enum { idx = 23 }; };
614 template<>
struct FourthDensePt< 2,-2, 0> {
enum { idx = 24 }; };
617 template<>
struct FourthDensePt<-2, 0, 2> {
enum { idx = 25 }; };
618 template<>
struct FourthDensePt<-1, 0, 2> {
enum { idx = 26 }; };
619 template<>
struct FourthDensePt< 0, 0, 2> {
enum { idx = 27 }; };
620 template<>
struct FourthDensePt< 1, 0, 2> {
enum { idx = 28 }; };
621 template<>
struct FourthDensePt< 2, 0, 2> {
enum { idx = 29 }; };
623 template<>
struct FourthDensePt<-2, 0, 1> {
enum { idx = 30 }; };
624 template<>
struct FourthDensePt<-1, 0, 1> {
enum { idx = 31 }; };
625 template<>
struct FourthDensePt< 0, 0, 1> {
enum { idx = 32 }; };
626 template<>
struct FourthDensePt< 1, 0, 1> {
enum { idx = 33 }; };
627 template<>
struct FourthDensePt< 2, 0, 1> {
enum { idx = 34 }; };
629 template<>
struct FourthDensePt<-2, 0,-1> {
enum { idx = 35 }; };
630 template<>
struct FourthDensePt<-1, 0,-1> {
enum { idx = 36 }; };
631 template<>
struct FourthDensePt< 0, 0,-1> {
enum { idx = 37 }; };
632 template<>
struct FourthDensePt< 1, 0,-1> {
enum { idx = 38 }; };
633 template<>
struct FourthDensePt< 2, 0,-1> {
enum { idx = 39 }; };
635 template<>
struct FourthDensePt<-2, 0,-2> {
enum { idx = 40 }; };
636 template<>
struct FourthDensePt<-1, 0,-2> {
enum { idx = 41 }; };
637 template<>
struct FourthDensePt< 0, 0,-2> {
enum { idx = 42 }; };
638 template<>
struct FourthDensePt< 1, 0,-2> {
enum { idx = 43 }; };
639 template<>
struct FourthDensePt< 2, 0,-2> {
enum { idx = 44 }; };
642 template<>
struct FourthDensePt< 0,-2, 2> {
enum { idx = 45 }; };
643 template<>
struct FourthDensePt< 0,-1, 2> {
enum { idx = 46 }; };
644 template<>
struct FourthDensePt< 0, 1, 2> {
enum { idx = 47 }; };
645 template<>
struct FourthDensePt< 0, 2, 2> {
enum { idx = 48 }; };
647 template<>
struct FourthDensePt< 0,-2, 1> {
enum { idx = 49 }; };
648 template<>
struct FourthDensePt< 0,-1, 1> {
enum { idx = 50 }; };
649 template<>
struct FourthDensePt< 0, 1, 1> {
enum { idx = 51 }; };
650 template<>
struct FourthDensePt< 0, 2, 1> {
enum { idx = 52 }; };
652 template<>
struct FourthDensePt< 0,-2,-1> {
enum { idx = 53 }; };
653 template<>
struct FourthDensePt< 0,-1,-1> {
enum { idx = 54 }; };
654 template<>
struct FourthDensePt< 0, 1,-1> {
enum { idx = 55 }; };
655 template<>
struct FourthDensePt< 0, 2,-1> {
enum { idx = 56 }; };
657 template<>
struct FourthDensePt< 0,-2,-2> {
enum { idx = 57 }; };
658 template<>
struct FourthDensePt< 0,-1,-2> {
enum { idx = 58 }; };
659 template<>
struct FourthDensePt< 0, 1,-2> {
enum { idx = 59 }; };
660 template<>
struct FourthDensePt< 0, 2,-2> {
enum { idx = 60 }; };
665 template<
typename Gr
idT,
bool IsSafe = true>
667 :
public BaseStencil<FourthOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe>
676 static const int SIZE = 61;
681 template<
int i,
int j,
int k>
682 unsigned int pos()
const {
return FourthDensePt<i,j,k>::idx; }
685 inline void init(
const Coord& ijk)
687 mStencil[FourthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 2, 0));
688 mStencil[FourthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 2, 0));
689 mStencil[FourthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
690 mStencil[FourthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 2, 0));
691 mStencil[FourthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 2, 0));
693 mStencil[FourthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 1, 0));
694 mStencil[FourthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
695 mStencil[FourthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
696 mStencil[FourthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
697 mStencil[FourthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 1, 0));
699 mStencil[FourthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
700 mStencil[FourthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
701 mStencil[FourthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
702 mStencil[FourthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
704 mStencil[FourthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-1, 0));
705 mStencil[FourthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-1, 0));
706 mStencil[FourthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 0));
707 mStencil[FourthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-1, 0));
708 mStencil[FourthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-1, 0));
710 mStencil[FourthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-2, 0));
711 mStencil[FourthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-2, 0));
712 mStencil[FourthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 0));
713 mStencil[FourthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-2, 0));
714 mStencil[FourthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-2, 0));
716 mStencil[FourthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 2));
717 mStencil[FourthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 2));
718 mStencil[FourthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
719 mStencil[FourthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 2));
720 mStencil[FourthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 2));
722 mStencil[FourthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 1));
723 mStencil[FourthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
724 mStencil[FourthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
725 mStencil[FourthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
726 mStencil[FourthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 1));
728 mStencil[FourthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-1));
729 mStencil[FourthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-1));
730 mStencil[FourthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-1));
731 mStencil[FourthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-1));
732 mStencil[FourthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-1));
734 mStencil[FourthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-2));
735 mStencil[FourthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-2));
736 mStencil[FourthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-2));
737 mStencil[FourthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-2));
738 mStencil[FourthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-2));
741 mStencil[FourthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 2));
742 mStencil[FourthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 2));
743 mStencil[FourthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 2));
744 mStencil[FourthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 2));
746 mStencil[FourthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 1));
747 mStencil[FourthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 1));
748 mStencil[FourthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
749 mStencil[FourthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 1));
751 mStencil[FourthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-1));
752 mStencil[FourthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-1));
753 mStencil[FourthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-1));
754 mStencil[FourthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-1));
756 mStencil[FourthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-2));
757 mStencil[FourthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-2));
758 mStencil[FourthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-2));
759 mStencil[FourthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-2));
763 using BaseType::mCache;
764 using BaseType::mStencil;
774 template<
int i,
int j,
int k>
struct NineteenPt {};
775 template<>
struct NineteenPt< 0, 0, 0> {
enum { idx = 0 }; };
777 template<>
struct NineteenPt< 1, 0, 0> {
enum { idx = 1 }; };
778 template<>
struct NineteenPt< 0, 1, 0> {
enum { idx = 2 }; };
779 template<>
struct NineteenPt< 0, 0, 1> {
enum { idx = 3 }; };
781 template<>
struct NineteenPt<-1, 0, 0> {
enum { idx = 4 }; };
782 template<>
struct NineteenPt< 0,-1, 0> {
enum { idx = 5 }; };
783 template<>
struct NineteenPt< 0, 0,-1> {
enum { idx = 6 }; };
785 template<>
struct NineteenPt< 2, 0, 0> {
enum { idx = 7 }; };
786 template<>
struct NineteenPt< 0, 2, 0> {
enum { idx = 8 }; };
787 template<>
struct NineteenPt< 0, 0, 2> {
enum { idx = 9 }; };
789 template<>
struct NineteenPt<-2, 0, 0> {
enum { idx = 10 }; };
790 template<>
struct NineteenPt< 0,-2, 0> {
enum { idx = 11 }; };
791 template<>
struct NineteenPt< 0, 0,-2> {
enum { idx = 12 }; };
793 template<>
struct NineteenPt< 3, 0, 0> {
enum { idx = 13 }; };
794 template<>
struct NineteenPt< 0, 3, 0> {
enum { idx = 14 }; };
795 template<>
struct NineteenPt< 0, 0, 3> {
enum { idx = 15 }; };
797 template<>
struct NineteenPt<-3, 0, 0> {
enum { idx = 16 }; };
798 template<>
struct NineteenPt< 0,-3, 0> {
enum { idx = 17 }; };
799 template<>
struct NineteenPt< 0, 0,-3> {
enum { idx = 18 }; };
804 template<
typename Gr
idT,
bool IsSafe = true>
806 :
public BaseStencil<NineteenPointStencil<GridT, IsSafe>, GridT, IsSafe>
815 static const int SIZE = 19;
820 template<
int i,
int j,
int k>
821 unsigned int pos()
const {
return NineteenPt<i,j,k>::idx; }
824 inline void init(
const Coord& ijk)
826 mStencil[NineteenPt< 3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
827 mStencil[NineteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
828 mStencil[NineteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
829 mStencil[NineteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
830 mStencil[NineteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
831 mStencil[NineteenPt<-3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
833 mStencil[NineteenPt< 0, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
834 mStencil[NineteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
835 mStencil[NineteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
836 mStencil[NineteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
837 mStencil[NineteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
838 mStencil[NineteenPt< 0,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -3, 0));
840 mStencil[NineteenPt< 0, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
841 mStencil[NineteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
842 mStencil[NineteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
843 mStencil[NineteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
844 mStencil[NineteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
845 mStencil[NineteenPt< 0, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -3));
849 using BaseType::mCache;
850 using BaseType::mStencil;
860 template<
int i,
int j,
int k>
struct SixthDensePt { };
861 template<>
struct SixthDensePt< 0, 0, 0> {
enum { idx = 0 }; };
863 template<>
struct SixthDensePt<-3, 3, 0> {
enum { idx = 1 }; };
864 template<>
struct SixthDensePt<-2, 3, 0> {
enum { idx = 2 }; };
865 template<>
struct SixthDensePt<-1, 3, 0> {
enum { idx = 3 }; };
866 template<>
struct SixthDensePt< 0, 3, 0> {
enum { idx = 4 }; };
867 template<>
struct SixthDensePt< 1, 3, 0> {
enum { idx = 5 }; };
868 template<>
struct SixthDensePt< 2, 3, 0> {
enum { idx = 6 }; };
869 template<>
struct SixthDensePt< 3, 3, 0> {
enum { idx = 7 }; };
871 template<>
struct SixthDensePt<-3, 2, 0> {
enum { idx = 8 }; };
872 template<>
struct SixthDensePt<-2, 2, 0> {
enum { idx = 9 }; };
873 template<>
struct SixthDensePt<-1, 2, 0> {
enum { idx = 10 }; };
874 template<>
struct SixthDensePt< 0, 2, 0> {
enum { idx = 11 }; };
875 template<>
struct SixthDensePt< 1, 2, 0> {
enum { idx = 12 }; };
876 template<>
struct SixthDensePt< 2, 2, 0> {
enum { idx = 13 }; };
877 template<>
struct SixthDensePt< 3, 2, 0> {
enum { idx = 14 }; };
879 template<>
struct SixthDensePt<-3, 1, 0> {
enum { idx = 15 }; };
880 template<>
struct SixthDensePt<-2, 1, 0> {
enum { idx = 16 }; };
881 template<>
struct SixthDensePt<-1, 1, 0> {
enum { idx = 17 }; };
882 template<>
struct SixthDensePt< 0, 1, 0> {
enum { idx = 18 }; };
883 template<>
struct SixthDensePt< 1, 1, 0> {
enum { idx = 19 }; };
884 template<>
struct SixthDensePt< 2, 1, 0> {
enum { idx = 20 }; };
885 template<>
struct SixthDensePt< 3, 1, 0> {
enum { idx = 21 }; };
887 template<>
struct SixthDensePt<-3, 0, 0> {
enum { idx = 22 }; };
888 template<>
struct SixthDensePt<-2, 0, 0> {
enum { idx = 23 }; };
889 template<>
struct SixthDensePt<-1, 0, 0> {
enum { idx = 24 }; };
890 template<>
struct SixthDensePt< 1, 0, 0> {
enum { idx = 25 }; };
891 template<>
struct SixthDensePt< 2, 0, 0> {
enum { idx = 26 }; };
892 template<>
struct SixthDensePt< 3, 0, 0> {
enum { idx = 27 }; };
895 template<>
struct SixthDensePt<-3,-1, 0> {
enum { idx = 28 }; };
896 template<>
struct SixthDensePt<-2,-1, 0> {
enum { idx = 29 }; };
897 template<>
struct SixthDensePt<-1,-1, 0> {
enum { idx = 30 }; };
898 template<>
struct SixthDensePt< 0,-1, 0> {
enum { idx = 31 }; };
899 template<>
struct SixthDensePt< 1,-1, 0> {
enum { idx = 32 }; };
900 template<>
struct SixthDensePt< 2,-1, 0> {
enum { idx = 33 }; };
901 template<>
struct SixthDensePt< 3,-1, 0> {
enum { idx = 34 }; };
904 template<>
struct SixthDensePt<-3,-2, 0> {
enum { idx = 35 }; };
905 template<>
struct SixthDensePt<-2,-2, 0> {
enum { idx = 36 }; };
906 template<>
struct SixthDensePt<-1,-2, 0> {
enum { idx = 37 }; };
907 template<>
struct SixthDensePt< 0,-2, 0> {
enum { idx = 38 }; };
908 template<>
struct SixthDensePt< 1,-2, 0> {
enum { idx = 39 }; };
909 template<>
struct SixthDensePt< 2,-2, 0> {
enum { idx = 40 }; };
910 template<>
struct SixthDensePt< 3,-2, 0> {
enum { idx = 41 }; };
913 template<>
struct SixthDensePt<-3,-3, 0> {
enum { idx = 42 }; };
914 template<>
struct SixthDensePt<-2,-3, 0> {
enum { idx = 43 }; };
915 template<>
struct SixthDensePt<-1,-3, 0> {
enum { idx = 44 }; };
916 template<>
struct SixthDensePt< 0,-3, 0> {
enum { idx = 45 }; };
917 template<>
struct SixthDensePt< 1,-3, 0> {
enum { idx = 46 }; };
918 template<>
struct SixthDensePt< 2,-3, 0> {
enum { idx = 47 }; };
919 template<>
struct SixthDensePt< 3,-3, 0> {
enum { idx = 48 }; };
922 template<>
struct SixthDensePt<-3, 0, 3> {
enum { idx = 49 }; };
923 template<>
struct SixthDensePt<-2, 0, 3> {
enum { idx = 50 }; };
924 template<>
struct SixthDensePt<-1, 0, 3> {
enum { idx = 51 }; };
925 template<>
struct SixthDensePt< 0, 0, 3> {
enum { idx = 52 }; };
926 template<>
struct SixthDensePt< 1, 0, 3> {
enum { idx = 53 }; };
927 template<>
struct SixthDensePt< 2, 0, 3> {
enum { idx = 54 }; };
928 template<>
struct SixthDensePt< 3, 0, 3> {
enum { idx = 55 }; };
931 template<>
struct SixthDensePt<-3, 0, 2> {
enum { idx = 56 }; };
932 template<>
struct SixthDensePt<-2, 0, 2> {
enum { idx = 57 }; };
933 template<>
struct SixthDensePt<-1, 0, 2> {
enum { idx = 58 }; };
934 template<>
struct SixthDensePt< 0, 0, 2> {
enum { idx = 59 }; };
935 template<>
struct SixthDensePt< 1, 0, 2> {
enum { idx = 60 }; };
936 template<>
struct SixthDensePt< 2, 0, 2> {
enum { idx = 61 }; };
937 template<>
struct SixthDensePt< 3, 0, 2> {
enum { idx = 62 }; };
939 template<>
struct SixthDensePt<-3, 0, 1> {
enum { idx = 63 }; };
940 template<>
struct SixthDensePt<-2, 0, 1> {
enum { idx = 64 }; };
941 template<>
struct SixthDensePt<-1, 0, 1> {
enum { idx = 65 }; };
942 template<>
struct SixthDensePt< 0, 0, 1> {
enum { idx = 66 }; };
943 template<>
struct SixthDensePt< 1, 0, 1> {
enum { idx = 67 }; };
944 template<>
struct SixthDensePt< 2, 0, 1> {
enum { idx = 68 }; };
945 template<>
struct SixthDensePt< 3, 0, 1> {
enum { idx = 69 }; };
948 template<>
struct SixthDensePt<-3, 0,-1> {
enum { idx = 70 }; };
949 template<>
struct SixthDensePt<-2, 0,-1> {
enum { idx = 71 }; };
950 template<>
struct SixthDensePt<-1, 0,-1> {
enum { idx = 72 }; };
951 template<>
struct SixthDensePt< 0, 0,-1> {
enum { idx = 73 }; };
952 template<>
struct SixthDensePt< 1, 0,-1> {
enum { idx = 74 }; };
953 template<>
struct SixthDensePt< 2, 0,-1> {
enum { idx = 75 }; };
954 template<>
struct SixthDensePt< 3, 0,-1> {
enum { idx = 76 }; };
957 template<>
struct SixthDensePt<-3, 0,-2> {
enum { idx = 77 }; };
958 template<>
struct SixthDensePt<-2, 0,-2> {
enum { idx = 78 }; };
959 template<>
struct SixthDensePt<-1, 0,-2> {
enum { idx = 79 }; };
960 template<>
struct SixthDensePt< 0, 0,-2> {
enum { idx = 80 }; };
961 template<>
struct SixthDensePt< 1, 0,-2> {
enum { idx = 81 }; };
962 template<>
struct SixthDensePt< 2, 0,-2> {
enum { idx = 82 }; };
963 template<>
struct SixthDensePt< 3, 0,-2> {
enum { idx = 83 }; };
966 template<>
struct SixthDensePt<-3, 0,-3> {
enum { idx = 84 }; };
967 template<>
struct SixthDensePt<-2, 0,-3> {
enum { idx = 85 }; };
968 template<>
struct SixthDensePt<-1, 0,-3> {
enum { idx = 86 }; };
969 template<>
struct SixthDensePt< 0, 0,-3> {
enum { idx = 87 }; };
970 template<>
struct SixthDensePt< 1, 0,-3> {
enum { idx = 88 }; };
971 template<>
struct SixthDensePt< 2, 0,-3> {
enum { idx = 89 }; };
972 template<>
struct SixthDensePt< 3, 0,-3> {
enum { idx = 90 }; };
975 template<>
struct SixthDensePt< 0,-3, 3> {
enum { idx = 91 }; };
976 template<>
struct SixthDensePt< 0,-2, 3> {
enum { idx = 92 }; };
977 template<>
struct SixthDensePt< 0,-1, 3> {
enum { idx = 93 }; };
978 template<>
struct SixthDensePt< 0, 1, 3> {
enum { idx = 94 }; };
979 template<>
struct SixthDensePt< 0, 2, 3> {
enum { idx = 95 }; };
980 template<>
struct SixthDensePt< 0, 3, 3> {
enum { idx = 96 }; };
982 template<>
struct SixthDensePt< 0,-3, 2> {
enum { idx = 97 }; };
983 template<>
struct SixthDensePt< 0,-2, 2> {
enum { idx = 98 }; };
984 template<>
struct SixthDensePt< 0,-1, 2> {
enum { idx = 99 }; };
985 template<>
struct SixthDensePt< 0, 1, 2> {
enum { idx = 100 }; };
986 template<>
struct SixthDensePt< 0, 2, 2> {
enum { idx = 101 }; };
987 template<>
struct SixthDensePt< 0, 3, 2> {
enum { idx = 102 }; };
989 template<>
struct SixthDensePt< 0,-3, 1> {
enum { idx = 103 }; };
990 template<>
struct SixthDensePt< 0,-2, 1> {
enum { idx = 104 }; };
991 template<>
struct SixthDensePt< 0,-1, 1> {
enum { idx = 105 }; };
992 template<>
struct SixthDensePt< 0, 1, 1> {
enum { idx = 106 }; };
993 template<>
struct SixthDensePt< 0, 2, 1> {
enum { idx = 107 }; };
994 template<>
struct SixthDensePt< 0, 3, 1> {
enum { idx = 108 }; };
996 template<>
struct SixthDensePt< 0,-3,-1> {
enum { idx = 109 }; };
997 template<>
struct SixthDensePt< 0,-2,-1> {
enum { idx = 110 }; };
998 template<>
struct SixthDensePt< 0,-1,-1> {
enum { idx = 111 }; };
999 template<>
struct SixthDensePt< 0, 1,-1> {
enum { idx = 112 }; };
1000 template<>
struct SixthDensePt< 0, 2,-1> {
enum { idx = 113 }; };
1001 template<>
struct SixthDensePt< 0, 3,-1> {
enum { idx = 114 }; };
1003 template<>
struct SixthDensePt< 0,-3,-2> {
enum { idx = 115 }; };
1004 template<>
struct SixthDensePt< 0,-2,-2> {
enum { idx = 116 }; };
1005 template<>
struct SixthDensePt< 0,-1,-2> {
enum { idx = 117 }; };
1006 template<>
struct SixthDensePt< 0, 1,-2> {
enum { idx = 118 }; };
1007 template<>
struct SixthDensePt< 0, 2,-2> {
enum { idx = 119 }; };
1008 template<>
struct SixthDensePt< 0, 3,-2> {
enum { idx = 120 }; };
1010 template<>
struct SixthDensePt< 0,-3,-3> {
enum { idx = 121 }; };
1011 template<>
struct SixthDensePt< 0,-2,-3> {
enum { idx = 122 }; };
1012 template<>
struct SixthDensePt< 0,-1,-3> {
enum { idx = 123 }; };
1013 template<>
struct SixthDensePt< 0, 1,-3> {
enum { idx = 124 }; };
1014 template<>
struct SixthDensePt< 0, 2,-3> {
enum { idx = 125 }; };
1015 template<>
struct SixthDensePt< 0, 3,-3> {
enum { idx = 126 }; };
1020 template<
typename Gr
idT,
bool IsSafe = true>
1022 :
public BaseStencil<SixthOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe>
1031 static const int SIZE = 127;
1036 template<
int i,
int j,
int k>
1037 unsigned int pos()
const {
return SixthDensePt<i,j,k>::idx; }
1040 inline void init(
const Coord& ijk)
1042 mStencil[SixthDensePt<-3, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 3, 0));
1043 mStencil[SixthDensePt<-2, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 3, 0));
1044 mStencil[SixthDensePt<-1, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 3, 0));
1045 mStencil[SixthDensePt< 0, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
1046 mStencil[SixthDensePt< 1, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 3, 0));
1047 mStencil[SixthDensePt< 2, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 3, 0));
1048 mStencil[SixthDensePt< 3, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 3, 0));
1050 mStencil[SixthDensePt<-3, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 2, 0));
1051 mStencil[SixthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 2, 0));
1052 mStencil[SixthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 2, 0));
1053 mStencil[SixthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
1054 mStencil[SixthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 2, 0));
1055 mStencil[SixthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 2, 0));
1056 mStencil[SixthDensePt< 3, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 2, 0));
1058 mStencil[SixthDensePt<-3, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 1, 0));
1059 mStencil[SixthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 1, 0));
1060 mStencil[SixthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
1061 mStencil[SixthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1062 mStencil[SixthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
1063 mStencil[SixthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 1, 0));
1064 mStencil[SixthDensePt< 3, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 1, 0));
1066 mStencil[SixthDensePt<-3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
1067 mStencil[SixthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
1068 mStencil[SixthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1069 mStencil[SixthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1070 mStencil[SixthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
1071 mStencil[SixthDensePt< 3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
1073 mStencil[SixthDensePt<-3,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-1, 0));
1074 mStencil[SixthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-1, 0));
1075 mStencil[SixthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-1, 0));
1076 mStencil[SixthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 0));
1077 mStencil[SixthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-1, 0));
1078 mStencil[SixthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-1, 0));
1079 mStencil[SixthDensePt< 3,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-1, 0));
1081 mStencil[SixthDensePt<-3,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-2, 0));
1082 mStencil[SixthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-2, 0));
1083 mStencil[SixthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-2, 0));
1084 mStencil[SixthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 0));
1085 mStencil[SixthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-2, 0));
1086 mStencil[SixthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-2, 0));
1087 mStencil[SixthDensePt< 3,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-2, 0));
1089 mStencil[SixthDensePt<-3,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-3, 0));
1090 mStencil[SixthDensePt<-2,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-3, 0));
1091 mStencil[SixthDensePt<-1,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-3, 0));
1092 mStencil[SixthDensePt< 0,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 0));
1093 mStencil[SixthDensePt< 1,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-3, 0));
1094 mStencil[SixthDensePt< 2,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-3, 0));
1095 mStencil[SixthDensePt< 3,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-3, 0));
1097 mStencil[SixthDensePt<-3, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 3));
1098 mStencil[SixthDensePt<-2, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 3));
1099 mStencil[SixthDensePt<-1, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 3));
1100 mStencil[SixthDensePt< 0, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
1101 mStencil[SixthDensePt< 1, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 3));
1102 mStencil[SixthDensePt< 2, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 3));
1103 mStencil[SixthDensePt< 3, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 3));
1105 mStencil[SixthDensePt<-3, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 2));
1106 mStencil[SixthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 2));
1107 mStencil[SixthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 2));
1108 mStencil[SixthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
1109 mStencil[SixthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 2));
1110 mStencil[SixthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 2));
1111 mStencil[SixthDensePt< 3, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 2));
1113 mStencil[SixthDensePt<-3, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 1));
1114 mStencil[SixthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 1));
1115 mStencil[SixthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
1116 mStencil[SixthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1117 mStencil[SixthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
1118 mStencil[SixthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 1));
1119 mStencil[SixthDensePt< 3, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 1));
1121 mStencil[SixthDensePt<-3, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-1));
1122 mStencil[SixthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-1));
1123 mStencil[SixthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-1));
1124 mStencil[SixthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-1));
1125 mStencil[SixthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-1));
1126 mStencil[SixthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-1));
1127 mStencil[SixthDensePt< 3, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-1));
1129 mStencil[SixthDensePt<-3, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-2));
1130 mStencil[SixthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-2));
1131 mStencil[SixthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-2));
1132 mStencil[SixthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-2));
1133 mStencil[SixthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-2));
1134 mStencil[SixthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-2));
1135 mStencil[SixthDensePt< 3, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-2));
1137 mStencil[SixthDensePt<-3, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-3));
1138 mStencil[SixthDensePt<-2, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-3));
1139 mStencil[SixthDensePt<-1, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-3));
1140 mStencil[SixthDensePt< 0, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-3));
1141 mStencil[SixthDensePt< 1, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-3));
1142 mStencil[SixthDensePt< 2, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-3));
1143 mStencil[SixthDensePt< 3, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-3));
1145 mStencil[SixthDensePt< 0,-3, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 3));
1146 mStencil[SixthDensePt< 0,-2, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 3));
1147 mStencil[SixthDensePt< 0,-1, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 3));
1148 mStencil[SixthDensePt< 0, 1, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 3));
1149 mStencil[SixthDensePt< 0, 2, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 3));
1150 mStencil[SixthDensePt< 0, 3, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 3));
1152 mStencil[SixthDensePt< 0,-3, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 2));
1153 mStencil[SixthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 2));
1154 mStencil[SixthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 2));
1155 mStencil[SixthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 2));
1156 mStencil[SixthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 2));
1157 mStencil[SixthDensePt< 0, 3, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 2));
1159 mStencil[SixthDensePt< 0,-3, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 1));
1160 mStencil[SixthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 1));
1161 mStencil[SixthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 1));
1162 mStencil[SixthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
1163 mStencil[SixthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 1));
1164 mStencil[SixthDensePt< 0, 3, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 1));
1166 mStencil[SixthDensePt< 0,-3,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-1));
1167 mStencil[SixthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-1));
1168 mStencil[SixthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-1));
1169 mStencil[SixthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-1));
1170 mStencil[SixthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-1));
1171 mStencil[SixthDensePt< 0, 3,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-1));
1173 mStencil[SixthDensePt< 0,-3,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-2));
1174 mStencil[SixthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-2));
1175 mStencil[SixthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-2));
1176 mStencil[SixthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-2));
1177 mStencil[SixthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-2));
1178 mStencil[SixthDensePt< 0, 3,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-2));
1180 mStencil[SixthDensePt< 0,-3,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-3));
1181 mStencil[SixthDensePt< 0,-2,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-3));
1182 mStencil[SixthDensePt< 0,-1,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-3));
1183 mStencil[SixthDensePt< 0, 1,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-3));
1184 mStencil[SixthDensePt< 0, 2,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-3));
1185 mStencil[SixthDensePt< 0, 3,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-3));
1189 using BaseType::mCache;
1190 using BaseType::mStencil;
1203 template<
typename Gr
idT,
bool IsSafe = true>
1213 static const int SIZE = 7;
1216 : BaseType(grid, SIZE)
1217 , mInv2Dx(ValueType(0.5 / grid.voxelSize()[0]))
1218 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1223 : BaseType(grid, SIZE)
1224 , mInv2Dx(ValueType(0.5 / dx))
1225 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1237 mStencil[0] - mStencil[1],
1238 mStencil[2] - mStencil[0],
1239 mStencil[0] - mStencil[3],
1240 mStencil[4] - mStencil[0],
1241 mStencil[0] - mStencil[5],
1242 mStencil[6] - mStencil[0]);
1253 mStencil[4] - mStencil[3],
1254 mStencil[6] - mStencil[5])*mInv2Dx;
1263 V[0]>0 ? mStencil[0] - mStencil[1] : mStencil[2] - mStencil[0],
1264 V[1]>0 ? mStencil[0] - mStencil[3] : mStencil[4] - mStencil[0],
1265 V[2]>0 ? mStencil[0] - mStencil[5] : mStencil[6] - mStencil[0])*2*mInv2Dx;
1272 return mInvDx2 * (mStencil[1] + mStencil[2] +
1273 mStencil[3] + mStencil[4] +
1274 mStencil[5] + mStencil[6] - 6*mStencil[0]);
1282 return (v[0]>0 ? (v[1]<0 || v[2]<0 || v[3]<0 || v[4]<0 || v[5]<0 || v[6]<0)
1283 : (v[1]>0 || v[2]>0 || v[3]>0 || v[4]>0 || v[5]>0 || v[6]>0));
1295 const Coord& ijk = BaseType::getCenterCoord();
1296 const ValueType d = ValueType(mStencil[0] * 0.5 * mInvDx2);
1298 ijk[1] - d*(mStencil[4] - mStencil[3]),
1299 ijk[2] - d*(mStencil[6] - mStencil[5]));
1304 inline void init(
const Coord& ijk)
1306 mStencil[1] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1307 mStencil[2] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1309 mStencil[3] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1310 mStencil[4] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1312 mStencil[5] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1313 mStencil[6] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1317 using BaseType::mCache;
1318 using BaseType::mStencil;
1319 const ValueType mInv2Dx, mInvDx2;
1330 template<
typename Gr
idT,
bool IsSafe = true>
1340 static const int SIZE = 19;
1343 : BaseType(grid, SIZE)
1344 , mDx2(ValueType(math::
Pow2(grid.voxelSize()[0])))
1345 , mInv2Dx(ValueType(0.5 / grid.voxelSize()[0]))
1346 , mInvDx2(ValueType(1.0 / mDx2))
1351 : BaseType(grid, SIZE)
1352 , mDx2(ValueType(dx * dx))
1353 , mInv2Dx(ValueType(0.5 / dx))
1354 , mInvDx2(ValueType(1.0 / mDx2))
1369 v1(v[2]-v[1], v[ 8]-v[ 7], v[14]-v[13], 0),
1370 v2(v[3]-v[2], v[ 9]-v[ 8], v[15]-v[14], 0),
1371 v3(v[0]-v[3], v[ 0]-v[ 9], v[ 0]-v[15], 0),
1372 v4(v[4]-v[0], v[10]-v[ 0], v[16]-v[ 0], 0),
1373 v5(v[5]-v[4], v[11]-v[10], v[17]-v[16], 0),
1374 v6(v[6]-v[5], v[12]-v[11], v[18]-v[17], 0),
1381 dP_xm =
math::WENO5(v[ 2]-v[ 1],v[ 3]-v[ 2],v[ 0]-v[ 3],v[ 4]-v[ 0],v[ 5]-v[ 4],mDx2),
1382 dP_xp =
math::WENO5(v[ 6]-v[ 5],v[ 5]-v[ 4],v[ 4]-v[ 0],v[ 0]-v[ 3],v[ 3]-v[ 2],mDx2),
1383 dP_ym =
math::WENO5(v[ 8]-v[ 7],v[ 9]-v[ 8],v[ 0]-v[ 9],v[10]-v[ 0],v[11]-v[10],mDx2),
1384 dP_yp =
math::WENO5(v[12]-v[11],v[11]-v[10],v[10]-v[ 0],v[ 0]-v[ 9],v[ 9]-v[ 8],mDx2),
1385 dP_zm =
math::WENO5(v[14]-v[13],v[15]-v[14],v[ 0]-v[15],v[16]-v[ 0],v[17]-v[16],mDx2),
1386 dP_zp =
math::WENO5(v[18]-v[17],v[17]-v[16],v[16]-v[ 0],v[ 0]-v[15],v[15]-v[14],mDx2);
1387 return static_cast<ValueType
>(
1401 V[0]>0 ?
math::WENO5(v[ 2]-v[ 1],v[ 3]-v[ 2],v[ 0]-v[ 3], v[ 4]-v[ 0],v[ 5]-v[ 4],mDx2)
1402 :
math::WENO5(v[ 6]-v[ 5],v[ 5]-v[ 4],v[ 4]-v[ 0], v[ 0]-v[ 3],v[ 3]-v[ 2],mDx2),
1403 V[1]>0 ?
math::WENO5(v[ 8]-v[ 7],v[ 9]-v[ 8],v[ 0]-v[ 9], v[10]-v[ 0],v[11]-v[10],mDx2)
1404 :
math::WENO5(v[12]-v[11],v[11]-v[10],v[10]-v[ 0], v[ 0]-v[ 9],v[ 9]-v[ 8],mDx2),
1405 V[2]>0 ?
math::WENO5(v[14]-v[13],v[15]-v[14],v[ 0]-v[15], v[16]-v[ 0],v[17]-v[16],mDx2)
1406 :
math::WENO5(v[18]-v[17],v[17]-v[16],v[16]-v[ 0], v[ 0]-v[15],v[15]-v[14],mDx2));
1416 mStencil[10] - mStencil[ 9],
1417 mStencil[16] - mStencil[15]);
1428 mStencil[ 3] + mStencil[ 4] +
1429 mStencil[ 9] + mStencil[10] +
1430 mStencil[15] + mStencil[16] - 6*mStencil[0]);
1438 return (v[ 0]>0 ? (v[ 3]<0 || v[ 4]<0 || v[ 9]<0 || v[10]<0 || v[15]<0 || v[16]<0)
1439 : (v[ 3]>0 || v[ 4]>0 || v[ 9]>0 || v[10]>0 || v[15]>0 || v[16]>0));
1443 inline void init(
const Coord& ijk)
1445 mStencil[ 1] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
1446 mStencil[ 2] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
1447 mStencil[ 3] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1448 mStencil[ 4] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1449 mStencil[ 5] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
1450 mStencil[ 6] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
1452 mStencil[ 7] = mCache.getValue(ijk.
offsetBy( 0, -3, 0));
1453 mStencil[ 8] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
1454 mStencil[ 9] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1455 mStencil[10] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1456 mStencil[11] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
1457 mStencil[12] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
1459 mStencil[13] = mCache.getValue(ijk.
offsetBy( 0, 0, -3));
1460 mStencil[14] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
1461 mStencil[15] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1462 mStencil[16] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1463 mStencil[17] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
1464 mStencil[18] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
1468 using BaseType::mCache;
1469 using BaseType::mStencil;
1470 const ValueType mDx2, mInv2Dx, mInvDx2;
1477 template<
typename Gr
idT,
bool IsSafe = true>
1487 static const int SIZE = 19;
1490 : BaseType(grid, SIZE)
1491 , mInv2Dx(ValueType(0.5 / grid.voxelSize()[0]))
1492 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1497 : BaseType(grid, SIZE)
1498 , mInv2Dx(ValueType(0.5 / dx))
1499 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1533 mStencil[1] + mStencil[2] +
1534 mStencil[3] + mStencil[4] +
1535 mStencil[5] + mStencil[6] - 6*mStencil[0]);
1546 mStencil[2] - mStencil[1],
1547 mStencil[4] - mStencil[3],
1548 mStencil[6] - mStencil[5])*mInv2Dx;
1552 inline void init(
const Coord &ijk)
1554 mStencil[ 1] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1555 mStencil[ 2] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1557 mStencil[ 3] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1558 mStencil[ 4] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1560 mStencil[ 5] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1561 mStencil[ 6] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1563 mStencil[ 7] = mCache.getValue(ijk.
offsetBy(-1, -1, 0));
1564 mStencil[ 8] = mCache.getValue(ijk.
offsetBy( 1, -1, 0));
1565 mStencil[ 9] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
1566 mStencil[10] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
1568 mStencil[11] = mCache.getValue(ijk.
offsetBy(-1, 0, -1));
1569 mStencil[12] = mCache.getValue(ijk.
offsetBy( 1, 0, -1));
1570 mStencil[13] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
1571 mStencil[14] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
1573 mStencil[15] = mCache.getValue(ijk.
offsetBy( 0, -1, -1));
1574 mStencil[16] = mCache.getValue(ijk.
offsetBy( 0, 1, -1));
1575 mStencil[17] = mCache.getValue(ijk.
offsetBy( 0, -1, 1));
1576 mStencil[18] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
1583 Half(0.5), Quarter(0.25),
1584 Dx = Half * (mStencil[2] - mStencil[1]), Dx2 = Dx * Dx,
1585 Dy = Half * (mStencil[4] - mStencil[3]), Dy2 = Dy * Dy,
1586 Dz = Half * (mStencil[6] - mStencil[5]), Dz2 = Dz * Dz,
1587 normGrad = Dx2 + Dy2 + Dz2;
1593 Dxx = mStencil[2] - 2 * mStencil[0] + mStencil[1],
1594 Dyy = mStencil[4] - 2 * mStencil[0] + mStencil[3],
1595 Dzz = mStencil[6] - 2 * mStencil[0] + mStencil[5],
1596 Dxy = Quarter * (mStencil[10] - mStencil[ 8] + mStencil[7] - mStencil[ 9]),
1597 Dxz = Quarter * (mStencil[14] - mStencil[12] + mStencil[11] - mStencil[13]),
1598 Dyz = Quarter * (mStencil[18] - mStencil[16] + mStencil[15] - mStencil[17]);
1599 alpha = (Dx2*(Dyy+Dzz)+Dy2*(Dxx+Dzz)+Dz2*(Dxx+Dyy)-2*(Dx*(Dy*Dxy+Dz*Dxz)+Dy*Dz*Dyz));
1600 beta = std::sqrt(normGrad);
1605 using BaseType::mCache;
1606 using BaseType::mStencil;
1607 const ValueType mInv2Dx, mInvDx2;
1615 template<
typename Gr
idT,
bool IsSafe = true>
1626 : BaseType(grid, math::
Pow3(2 * halfWidth + 1))
1627 , mHalfWidth(halfWidth)
1629 assert(halfWidth>0);
1632 inline const ValueType&
getCenterValue()
const {
return mStencil[(mStencil.size()-1)>>1]; }
1638 BaseType::mCenter = ijk;
1643 template<
typename IterType>
1646 BaseType::mCenter = iter.getCoord();
1647 this->init(BaseType::mCenter);
1653 inline void init(
const Coord& ijk)
1657 for (p[1] = ijk[1]-mHalfWidth; p[1] <= q[1]; ++p[1]) {
1658 for (p[2] = ijk[2]-mHalfWidth; p[2] <= q[2]; ++p[2]) {
1659 mStencil[n++] = mCache.getValue(p);
1666 using BaseType::mCache;
1667 using BaseType::mStencil;
1668 const int mHalfWidth;
1676 #endif // OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
math::Vec3< ValueType > gradient(const math::Vec3< ValueType > &V) const
Return the first-order upwind gradient corresponding to the direction V.
Definition: Stencils.h:1260
GridT::TreeType TreeType
Definition: Stencils.h:1484
BoxStencil(const GridType &grid)
Definition: Stencils.h:307
ValueType laplacian() const
Definition: Stencils.h:1425
Definition: Stencils.h:60
bool intersects(const ValueType &isoValue=zeroVal< ValueType >()) const
Return true if the center of the stencil intersects the iso-contour specified by the isoValue...
Definition: Stencils.h:186
GridT::TreeType TreeType
Definition: Stencils.h:302
void moveTo(const Coord &ijk)
Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors.
Definition: Stencils.h:73
Coord mCenter
Definition: Stencils.h:218
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:311
GridT GridType
Definition: Stencils.h:811
GridT GridType
Definition: Stencils.h:461
const ValueType & getValue(unsigned int pos=0) const
Return the value from the stencil buffer with linear offset pos.
Definition: Stencils.h:122
ValueType normSqGrad() const
Return the norm square of the single-sided upwind gradient (computed via Gudonov's scheme) at the pre...
Definition: Stencils.h:1234
GridType::ValueType ValueType
Definition: Stencils.h:1338
bool zeroCrossing() const
Definition: Stencils.h:1279
void moveTo(const IterType &iter)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:1644
DenseStencil(const GridType &grid, int halfWidth)
Definition: Stencils.h:1625
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Definition: Stencils.h:1204
This is a special 19-point stencil that supports optimal fifth-order WENO upwinding, second-order central differencing, Laplacian, and zero-crossing test.
Definition: Stencils.h:1331
bool zeroCrossing() const
Definition: Stencils.h:1435
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:471
ValueType laplacian() const
Definition: Stencils.h:1530
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:111
const ValueType & getCenterValue() const
Return the value at the center of the stencil.
Definition: Stencils.h:182
Definition: Stencils.h:1478
GridT::TreeType TreeType
Definition: Stencils.h:812
GridType::ValueType ValueType
Definition: Stencils.h:813
GridT::TreeType TreeType
Definition: Stencils.h:1210
GridT::TreeType TreeType
Definition: Stencils.h:673
AccessorType mCache
Definition: Stencils.h:216
void moveTo(const IterType &iter)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:98
const ValueType & getCenterValue() const
Definition: Stencils.h:1632
const AccessorType & accessor() const
Return a const reference to the ValueAccessor associated with this Stencil.
Definition: Stencils.h:203
ValueType min() const
Return the smallest value in the stencil buffer.
Definition: Stencils.h:165
math::Vec3< ValueType > gradient()
Definition: Stencils.h:1543
ValueType max() const
Return the largest value in the stencil buffer.
Definition: Stencils.h:172
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
math::Vec3< ValueType > gradient() const
Definition: Stencils.h:1413
void moveTo(const Coord &ijk)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:1636
WenoStencil(const GridType &grid)
Definition: Stencils.h:1342
ValueType mean() const
Return the mean value of the current stencil.
Definition: Stencils.h:157
Definition: Stencils.h:242
void moveTo(const Coord &ijk, const ValueType ¢erValue)
Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors. The method also takes a value of the center element of the stencil, assuming it is already known.
Definition: Stencils.h:85
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:1037
GradStencil(const GridType &grid)
Definition: Stencils.h:1215
ThirteenPointStencil(const GridType &grid)
Definition: Stencils.h:547
BufferType mStencil
Definition: Stencils.h:217
const ValueType & getValue() const
Return the value at the specified location relative to the center of the stencil. ...
Definition: Stencils.h:130
ValueType meanCurvatureNormGrad()
Definition: Stencils.h:1519
GridT::ValueType ValueType
Definition: Stencils.h:1485
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:682
math::Vec3< ValueType > cpt()
Compute the closest-point transform to a level set.
Definition: Stencils.h:1293
GridType::ValueType ValueType
Definition: Stencils.h:674
GridT GridType
Definition: Stencils.h:1027
NineteenPointStencil(const GridType &grid)
Definition: Stencils.h:817
Definition: Stencils.h:455
GridT::ValueType ValueType
Definition: Stencils.h:249
Real GudonovsNormSqrd(bool isOutside, Real dP_xm, Real dP_xp, Real dP_ym, Real dP_yp, Real dP_zm, Real dP_zp)
Definition: FiniteDifference.h:353
WenoStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1350
#define OPENVDB_VERSION_NAME
Definition: version.h:43
math::Vec3< ValueType > gradient() const
Return the gradient computed at the previously buffered location by second order central differencing...
Definition: Stencils.h:1250
Definition: Stencils.h:805
const Coord & getCenterCoord() const
Return the coordinates of the center point of the stencil.
Definition: Stencils.h:179
GridT GridType
Definition: Stencils.h:63
ValueType normSqGrad() const
Return the norm-square of the WENO upwind gradient (computed via WENO upwinding and Gudonov's scheme)...
Definition: Stencils.h:1363
SixthOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:1033
const GridType & grid() const
Return a const reference to the grid from which this stencil was constructed.
Definition: Stencils.h:199
Definition: Stencils.h:296
GridT GridType
Definition: Stencils.h:301
tree::ValueAccessor< const TreeType, IsSafe > AccessorType
Definition: Stencils.h:66
ValueType laplacian() const
Definition: Stencils.h:1270
Definition: Exceptions.h:39
GridType::ValueType ValueType
Definition: Stencils.h:1623
GridT::TreeType TreeType
Definition: Stencils.h:64
BufferType::iterator IterType
Definition: Stencils.h:68
GridType::ValueType ValueType
Definition: Stencils.h:463
BaseStencil(const GridType &grid, int size)
Definition: Stencils.h:207
CurvatureStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1496
SevenPointStencil(const GridT &grid)
Definition: Stencils.h:253
math::Vec3< ValueType > gradient(const math::Vec3< ValueType > &V) const
Definition: Stencils.h:1397
Type Pow2(Type x)
Return .
Definition: Math.h:514
GridT GridType
Definition: Stencils.h:541
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:551
ValueType interpolation(const math::Vec3< ValueType > &xyz) const
Return the trilinear interpolation at the normalized position.
Definition: Stencils.h:334
void moveTo(const Vec3R &xyz)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:111
Definition: Stencils.h:1021
void setValue(const ValueType &value)
Set the value at the specified location relative to the center of the stencil.
Definition: Stencils.h:137
double Real
Definition: Types.h:64
GridT GridType
Definition: Stencils.h:1483
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:821
SecondOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:467
GridT::TreeType TreeType
Definition: Stencils.h:1337
Tolerance for floating-point comparison.
Definition: Math.h:125
GridT::TreeType TreeType
Definition: Stencils.h:542
ValueType median() const
Return the median value of the current stencil.
Definition: Stencils.h:146
GridT GridType
Definition: Stencils.h:1336
Type Pow3(Type x)
Return .
Definition: Math.h:518
GridT::ValueType ValueType
Definition: Stencils.h:65
Definition: Stencils.h:666
GridT GridType
Definition: Stencils.h:1621
ValueType meanCurvature()
Return the mean curvature at the previously buffered location.
Definition: Stencils.h:1507
CurvatureStencil(const GridType &grid)
Definition: Stencils.h:1489
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
GridT GridType
Definition: Stencils.h:672
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:257
GridT::TreeType TreeType
Definition: Stencils.h:1028
Dense stencil of a given width.
Definition: Stencils.h:1616
std::vector< ValueType > BufferType
Definition: Stencils.h:67
GridT::TreeType TreeType
Definition: Stencils.h:248
GridT GridType
Definition: Stencils.h:1209
GridT::TreeType TreeType
Definition: Stencils.h:1622
GridType::ValueType ValueType
Definition: Stencils.h:1029
GridT GridType
Definition: Stencils.h:247
int size()
Return the size of the stencil buffer.
Definition: Stencils.h:143
GradStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1222
GridT::ValueType ValueType
Definition: Stencils.h:303
math::Vec3< ValueType > gradient(const math::Vec3< ValueType > &xyz) const
Return the gradient in world space of the trilinear interpolation kernel.
Definition: Stencils.h:362
GridType::ValueType ValueType
Definition: Stencils.h:1211
GridType::ValueType ValueType
Definition: Stencils.h:543
GridT::TreeType TreeType
Definition: Stencils.h:462
const GridType * mGrid
Definition: Stencils.h:215
Definition: Stencils.h:535
FourthOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:678
bool intersects(const ValueType &isoValue=zeroVal< ValueType >()) const
Return true if the center of the stencil intersects the.
Definition: Stencils.h:315
ValueType WENO5(const ValueType &v1, const ValueType &v2, const ValueType &v3, const ValueType &v4, const ValueType &v5, float scale2=0.01f)
Implementation of nominally fifth-order finite-difference WENO.
Definition: FiniteDifference.h:331