40 #ifndef OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED 41 #define OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED 45 #include <openvdb/math/Math.h> 46 #include <openvdb/Types.h> 47 #include <openvdb/math/Coord.h> 48 #include <openvdb/math/FiniteDifference.h> 49 #include <openvdb/tree/ValueAccessor.h> 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);
111 template<
typename RealType>
115 if (ijk != mCenter) this->moveTo(ijk);
123 inline const ValueType&
getValue(
unsigned int pos = 0)
const 125 assert(pos < mStencil.size());
126 return mStencil[pos];
130 template<
int i,
int j,
int k>
133 return mStencil[
static_cast<const DerivedType&
>(*this).template pos<i,j,k>()];
137 template<
int i,
int j,
int k>
140 mStencil[
static_cast<const DerivedType&
>(*this).template pos<i,j,k>()] = value;
144 inline int size() {
return mStencil.size(); }
149 BufferType tmp(mStencil);
150 assert(!tmp.empty());
151 size_t midpoint = (tmp.size() - 1) >> 1;
153 std::nth_element(tmp.begin(), tmp.begin() + midpoint, tmp.end());
154 return tmp[midpoint];
161 for (
int n = 0, s =
int(mStencil.size()); n < s; ++n) sum += mStencil[n];
162 return sum / mStencil.size();
166 inline ValueType
min()
const 168 IterType iter = std::min_element(mStencil.begin(), mStencil.end());
173 inline ValueType
max()
const 175 IterType iter = std::max_element(mStencil.begin(), mStencil.end());
187 inline bool intersects(
const ValueType &isoValue = zeroVal<ValueType>())
const 189 const bool less = this->getValue< 0, 0, 0>() < isoValue;
190 return (less ^ (this->getValue<-1, 0, 0>() < isoValue)) ||
191 (less ^ (this->getValue< 1, 0, 0>() < isoValue)) ||
192 (less ^ (this->getValue< 0,-1, 0>() < isoValue)) ||
193 (less ^ (this->getValue< 0, 1, 0>() < isoValue)) ||
194 (less ^ (this->getValue< 0, 0,-1>() < isoValue)) ||
195 (less ^ (this->getValue< 0, 0, 1>() < isoValue)) ;
200 inline const GridType&
grid()
const {
return *mGrid; }
204 inline const AccessorType&
accessor()
const {
return mCache; }
210 , mCache(grid.tree())
230 template<
int i,
int j,
int k>
struct SevenPt {};
231 template<>
struct SevenPt< 0, 0, 0> {
enum { idx = 0 }; };
232 template<>
struct SevenPt< 1, 0, 0> {
enum { idx = 1 }; };
233 template<>
struct SevenPt< 0, 1, 0> {
enum { idx = 2 }; };
234 template<>
struct SevenPt< 0, 0, 1> {
enum { idx = 3 }; };
235 template<>
struct SevenPt<-1, 0, 0> {
enum { idx = 4 }; };
236 template<>
struct SevenPt< 0,-1, 0> {
enum { idx = 5 }; };
237 template<>
struct SevenPt< 0, 0,-1> {
enum { idx = 6 }; };
242 template<
typename Gr
idT,
bool IsSafe = true>
252 static const int SIZE = 7;
257 template<
int i,
int j,
int k>
258 unsigned int pos()
const {
return SevenPt<i,j,k>::idx; }
261 inline void init(
const Coord& ijk)
263 BaseType::template setValue<-1, 0, 0>(mCache.getValue(ijk.
offsetBy(-1, 0, 0)));
264 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
266 BaseType::template setValue< 0,-1, 0>(mCache.getValue(ijk.
offsetBy( 0,-1, 0)));
267 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
269 BaseType::template setValue< 0, 0,-1>(mCache.getValue(ijk.
offsetBy( 0, 0,-1)));
270 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
274 using BaseType::mCache;
275 using BaseType::mStencil;
285 template<
int i,
int j,
int k>
struct BoxPt {};
286 template<>
struct BoxPt< 0, 0, 0> {
enum { idx = 0 }; };
287 template<>
struct BoxPt< 0, 0, 1> {
enum { idx = 1 }; };
288 template<>
struct BoxPt< 0, 1, 1> {
enum { idx = 2 }; };
289 template<>
struct BoxPt< 0, 1, 0> {
enum { idx = 3 }; };
290 template<>
struct BoxPt< 1, 0, 0> {
enum { idx = 4 }; };
291 template<>
struct BoxPt< 1, 0, 1> {
enum { idx = 5 }; };
292 template<>
struct BoxPt< 1, 1, 1> {
enum { idx = 6 }; };
293 template<>
struct BoxPt< 1, 1, 0> {
enum { idx = 7 }; };
296 template<
typename Gr
idT,
bool IsSafe = true>
306 static const int SIZE = 8;
311 template<
int i,
int j,
int k>
312 unsigned int pos()
const {
return BoxPt<i,j,k>::idx; }
316 inline bool intersects(
const ValueType &isoValue = zeroVal<ValueType>())
const 318 const bool less = mStencil[0] < isoValue;
319 return (less ^ (mStencil[1] < isoValue)) ||
320 (less ^ (mStencil[2] < isoValue)) ||
321 (less ^ (mStencil[3] < isoValue)) ||
322 (less ^ (mStencil[4] < isoValue)) ||
323 (less ^ (mStencil[5] < isoValue)) ||
324 (less ^ (mStencil[6] < isoValue)) ||
325 (less ^ (mStencil[7] < isoValue)) ;
337 const ValueType u = xyz[0] - BaseType::mCenter[0]; assert(u>=0 && u<=1);
338 const ValueType v = xyz[1] - BaseType::mCenter[1]; assert(v>=0 && v<=1);
339 const ValueType w = xyz[2] - BaseType::mCenter[2]; assert(w>=0 && w<=1);
341 ValueType V = BaseType::template getValue<0,0,0>();
342 ValueType A =
static_cast<ValueType
>(V + (BaseType::template getValue<0,0,1>() - V) * w);
343 V = BaseType::template getValue< 0, 1, 0>();
344 ValueType B =
static_cast<ValueType
>(V + (BaseType::template getValue<0,1,1>() - V) * w);
345 ValueType C =
static_cast<ValueType
>(A + (B - A) * v);
347 V = BaseType::template getValue<1,0,0>();
348 A =
static_cast<ValueType
>(V + (BaseType::template getValue<1,0,1>() - V) * w);
349 V = BaseType::template getValue<1,1,0>();
350 B =
static_cast<ValueType
>(V + (BaseType::template getValue<1,1,1>() - V) * w);
351 ValueType D =
static_cast<ValueType
>(A + (B - A) * v);
353 return static_cast<ValueType
>(C + (D - C) * u);
365 const ValueType u = xyz[0] - BaseType::mCenter[0]; assert(u>=0 && u<=1);
366 const ValueType v = xyz[1] - BaseType::mCenter[1]; assert(v>=0 && v<=1);
367 const ValueType w = xyz[2] - BaseType::mCenter[2]; assert(w>=0 && w<=1);
369 ValueType D[4]={BaseType::template getValue<0,0,1>()-BaseType::template getValue<0,0,0>(),
370 BaseType::template getValue<0,1,1>()-BaseType::template getValue<0,1,0>(),
371 BaseType::template getValue<1,0,1>()-BaseType::template getValue<1,0,0>(),
372 BaseType::template getValue<1,1,1>()-BaseType::template getValue<1,1,0>()};
375 ValueType A =
static_cast<ValueType
>(D[0] + (D[1]- D[0]) * v);
376 ValueType B =
static_cast<ValueType
>(D[2] + (D[3]- D[2]) * v);
378 zeroVal<ValueType>(),
379 static_cast<ValueType>(A + (B - A) * u));
381 D[0] =
static_cast<ValueType
>(BaseType::template getValue<0,0,0>() + D[0] * w);
382 D[1] =
static_cast<ValueType
>(BaseType::template getValue<0,1,0>() + D[1] * w);
383 D[2] =
static_cast<ValueType
>(BaseType::template getValue<1,0,0>() + D[2] * w);
384 D[3] =
static_cast<ValueType
>(BaseType::template getValue<1,1,0>() + D[3] * w);
387 A =
static_cast<ValueType
>(D[0] + (D[1] - D[0]) * v);
388 B =
static_cast<ValueType
>(D[2] + (D[3] - D[2]) * v);
396 grad[1] =
static_cast<ValueType
>(A + (B - A) * u);
398 return BaseType::mGrid->transform().baseMap()->applyIJT(grad, xyz);
402 inline void init(
const Coord& ijk)
404 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
405 BaseType::template setValue< 0, 1, 1>(mCache.getValue(ijk.
offsetBy( 0, 1, 1)));
406 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
407 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
408 BaseType::template setValue< 1, 0, 1>(mCache.getValue(ijk.
offsetBy( 1, 0, 1)));
409 BaseType::template setValue< 1, 1, 1>(mCache.getValue(ijk.
offsetBy( 1, 1, 1)));
410 BaseType::template setValue< 1, 1, 0>(mCache.getValue(ijk.
offsetBy( 1, 1, 0)));
414 using BaseType::mCache;
415 using BaseType::mStencil;
425 template<
int i,
int j,
int k>
struct DensePt {};
426 template<>
struct DensePt< 0, 0, 0> {
enum { idx = 0 }; };
428 template<>
struct DensePt< 1, 0, 0> {
enum { idx = 1 }; };
429 template<>
struct DensePt< 0, 1, 0> {
enum { idx = 2 }; };
430 template<>
struct DensePt< 0, 0, 1> {
enum { idx = 3 }; };
432 template<>
struct DensePt<-1, 0, 0> {
enum { idx = 4 }; };
433 template<>
struct DensePt< 0,-1, 0> {
enum { idx = 5 }; };
434 template<>
struct DensePt< 0, 0,-1> {
enum { idx = 6 }; };
436 template<>
struct DensePt<-1,-1, 0> {
enum { idx = 7 }; };
437 template<>
struct DensePt< 0,-1,-1> {
enum { idx = 8 }; };
438 template<>
struct DensePt<-1, 0,-1> {
enum { idx = 9 }; };
440 template<>
struct DensePt< 1,-1, 0> {
enum { idx = 10 }; };
441 template<>
struct DensePt< 0, 1,-1> {
enum { idx = 11 }; };
442 template<>
struct DensePt<-1, 0, 1> {
enum { idx = 12 }; };
444 template<>
struct DensePt<-1, 1, 0> {
enum { idx = 13 }; };
445 template<>
struct DensePt< 0,-1, 1> {
enum { idx = 14 }; };
446 template<>
struct DensePt< 1, 0,-1> {
enum { idx = 15 }; };
448 template<>
struct DensePt< 1, 1, 0> {
enum { idx = 16 }; };
449 template<>
struct DensePt< 0, 1, 1> {
enum { idx = 17 }; };
450 template<>
struct DensePt< 1, 0, 1> {
enum { idx = 18 }; };
455 template<
typename Gr
idT,
bool IsSafe = true>
457 :
public BaseStencil<SecondOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe >
466 static const int SIZE = 19;
471 template<
int i,
int j,
int k>
472 unsigned int pos()
const {
return DensePt<i,j,k>::idx; }
475 inline void init(
const Coord& ijk)
477 mStencil[DensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
478 mStencil[DensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
479 mStencil[DensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
481 mStencil[DensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
482 mStencil[DensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
483 mStencil[DensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
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));
488 mStencil[DensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
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));
493 mStencil[DensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 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));
498 mStencil[DensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
502 using BaseType::mCache;
503 using BaseType::mStencil;
513 template<
int i,
int j,
int k>
struct ThirteenPt {};
514 template<>
struct ThirteenPt< 0, 0, 0> {
enum { idx = 0 }; };
516 template<>
struct ThirteenPt< 1, 0, 0> {
enum { idx = 1 }; };
517 template<>
struct ThirteenPt< 0, 1, 0> {
enum { idx = 2 }; };
518 template<>
struct ThirteenPt< 0, 0, 1> {
enum { idx = 3 }; };
520 template<>
struct ThirteenPt<-1, 0, 0> {
enum { idx = 4 }; };
521 template<>
struct ThirteenPt< 0,-1, 0> {
enum { idx = 5 }; };
522 template<>
struct ThirteenPt< 0, 0,-1> {
enum { idx = 6 }; };
524 template<>
struct ThirteenPt< 2, 0, 0> {
enum { idx = 7 }; };
525 template<>
struct ThirteenPt< 0, 2, 0> {
enum { idx = 8 }; };
526 template<>
struct ThirteenPt< 0, 0, 2> {
enum { idx = 9 }; };
528 template<>
struct ThirteenPt<-2, 0, 0> {
enum { idx = 10 }; };
529 template<>
struct ThirteenPt< 0,-2, 0> {
enum { idx = 11 }; };
530 template<>
struct ThirteenPt< 0, 0,-2> {
enum { idx = 12 }; };
535 template<
typename Gr
idT,
bool IsSafe = true>
537 :
public BaseStencil<ThirteenPointStencil<GridT, IsSafe>, GridT, IsSafe>
546 static const int SIZE = 13;
551 template<
int i,
int j,
int k>
552 unsigned int pos()
const {
return ThirteenPt<i,j,k>::idx; }
555 inline void init(
const Coord& ijk)
557 mStencil[ThirteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
558 mStencil[ThirteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
559 mStencil[ThirteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
560 mStencil[ThirteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
562 mStencil[ThirteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
563 mStencil[ThirteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
564 mStencil[ThirteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
565 mStencil[ThirteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
567 mStencil[ThirteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
568 mStencil[ThirteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
569 mStencil[ThirteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
570 mStencil[ThirteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
574 using BaseType::mCache;
575 using BaseType::mStencil;
585 template<
int i,
int j,
int k>
struct FourthDensePt {};
586 template<>
struct FourthDensePt< 0, 0, 0> {
enum { idx = 0 }; };
588 template<>
struct FourthDensePt<-2, 2, 0> {
enum { idx = 1 }; };
589 template<>
struct FourthDensePt<-1, 2, 0> {
enum { idx = 2 }; };
590 template<>
struct FourthDensePt< 0, 2, 0> {
enum { idx = 3 }; };
591 template<>
struct FourthDensePt< 1, 2, 0> {
enum { idx = 4 }; };
592 template<>
struct FourthDensePt< 2, 2, 0> {
enum { idx = 5 }; };
594 template<>
struct FourthDensePt<-2, 1, 0> {
enum { idx = 6 }; };
595 template<>
struct FourthDensePt<-1, 1, 0> {
enum { idx = 7 }; };
596 template<>
struct FourthDensePt< 0, 1, 0> {
enum { idx = 8 }; };
597 template<>
struct FourthDensePt< 1, 1, 0> {
enum { idx = 9 }; };
598 template<>
struct FourthDensePt< 2, 1, 0> {
enum { idx = 10 }; };
600 template<>
struct FourthDensePt<-2, 0, 0> {
enum { idx = 11 }; };
601 template<>
struct FourthDensePt<-1, 0, 0> {
enum { idx = 12 }; };
602 template<>
struct FourthDensePt< 1, 0, 0> {
enum { idx = 13 }; };
603 template<>
struct FourthDensePt< 2, 0, 0> {
enum { idx = 14 }; };
605 template<>
struct FourthDensePt<-2,-1, 0> {
enum { idx = 15 }; };
606 template<>
struct FourthDensePt<-1,-1, 0> {
enum { idx = 16 }; };
607 template<>
struct FourthDensePt< 0,-1, 0> {
enum { idx = 17 }; };
608 template<>
struct FourthDensePt< 1,-1, 0> {
enum { idx = 18 }; };
609 template<>
struct FourthDensePt< 2,-1, 0> {
enum { idx = 19 }; };
611 template<>
struct FourthDensePt<-2,-2, 0> {
enum { idx = 20 }; };
612 template<>
struct FourthDensePt<-1,-2, 0> {
enum { idx = 21 }; };
613 template<>
struct FourthDensePt< 0,-2, 0> {
enum { idx = 22 }; };
614 template<>
struct FourthDensePt< 1,-2, 0> {
enum { idx = 23 }; };
615 template<>
struct FourthDensePt< 2,-2, 0> {
enum { idx = 24 }; };
618 template<>
struct FourthDensePt<-2, 0, 2> {
enum { idx = 25 }; };
619 template<>
struct FourthDensePt<-1, 0, 2> {
enum { idx = 26 }; };
620 template<>
struct FourthDensePt< 0, 0, 2> {
enum { idx = 27 }; };
621 template<>
struct FourthDensePt< 1, 0, 2> {
enum { idx = 28 }; };
622 template<>
struct FourthDensePt< 2, 0, 2> {
enum { idx = 29 }; };
624 template<>
struct FourthDensePt<-2, 0, 1> {
enum { idx = 30 }; };
625 template<>
struct FourthDensePt<-1, 0, 1> {
enum { idx = 31 }; };
626 template<>
struct FourthDensePt< 0, 0, 1> {
enum { idx = 32 }; };
627 template<>
struct FourthDensePt< 1, 0, 1> {
enum { idx = 33 }; };
628 template<>
struct FourthDensePt< 2, 0, 1> {
enum { idx = 34 }; };
630 template<>
struct FourthDensePt<-2, 0,-1> {
enum { idx = 35 }; };
631 template<>
struct FourthDensePt<-1, 0,-1> {
enum { idx = 36 }; };
632 template<>
struct FourthDensePt< 0, 0,-1> {
enum { idx = 37 }; };
633 template<>
struct FourthDensePt< 1, 0,-1> {
enum { idx = 38 }; };
634 template<>
struct FourthDensePt< 2, 0,-1> {
enum { idx = 39 }; };
636 template<>
struct FourthDensePt<-2, 0,-2> {
enum { idx = 40 }; };
637 template<>
struct FourthDensePt<-1, 0,-2> {
enum { idx = 41 }; };
638 template<>
struct FourthDensePt< 0, 0,-2> {
enum { idx = 42 }; };
639 template<>
struct FourthDensePt< 1, 0,-2> {
enum { idx = 43 }; };
640 template<>
struct FourthDensePt< 2, 0,-2> {
enum { idx = 44 }; };
643 template<>
struct FourthDensePt< 0,-2, 2> {
enum { idx = 45 }; };
644 template<>
struct FourthDensePt< 0,-1, 2> {
enum { idx = 46 }; };
645 template<>
struct FourthDensePt< 0, 1, 2> {
enum { idx = 47 }; };
646 template<>
struct FourthDensePt< 0, 2, 2> {
enum { idx = 48 }; };
648 template<>
struct FourthDensePt< 0,-2, 1> {
enum { idx = 49 }; };
649 template<>
struct FourthDensePt< 0,-1, 1> {
enum { idx = 50 }; };
650 template<>
struct FourthDensePt< 0, 1, 1> {
enum { idx = 51 }; };
651 template<>
struct FourthDensePt< 0, 2, 1> {
enum { idx = 52 }; };
653 template<>
struct FourthDensePt< 0,-2,-1> {
enum { idx = 53 }; };
654 template<>
struct FourthDensePt< 0,-1,-1> {
enum { idx = 54 }; };
655 template<>
struct FourthDensePt< 0, 1,-1> {
enum { idx = 55 }; };
656 template<>
struct FourthDensePt< 0, 2,-1> {
enum { idx = 56 }; };
658 template<>
struct FourthDensePt< 0,-2,-2> {
enum { idx = 57 }; };
659 template<>
struct FourthDensePt< 0,-1,-2> {
enum { idx = 58 }; };
660 template<>
struct FourthDensePt< 0, 1,-2> {
enum { idx = 59 }; };
661 template<>
struct FourthDensePt< 0, 2,-2> {
enum { idx = 60 }; };
666 template<
typename Gr
idT,
bool IsSafe = true>
668 :
public BaseStencil<FourthOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe>
677 static const int SIZE = 61;
682 template<
int i,
int j,
int k>
683 unsigned int pos()
const {
return FourthDensePt<i,j,k>::idx; }
686 inline void init(
const Coord& ijk)
688 mStencil[FourthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 2, 0));
689 mStencil[FourthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 2, 0));
690 mStencil[FourthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
691 mStencil[FourthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 2, 0));
692 mStencil[FourthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 2, 0));
694 mStencil[FourthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 1, 0));
695 mStencil[FourthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
696 mStencil[FourthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
697 mStencil[FourthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
698 mStencil[FourthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 1, 0));
700 mStencil[FourthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
701 mStencil[FourthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
702 mStencil[FourthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
703 mStencil[FourthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
705 mStencil[FourthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-1, 0));
706 mStencil[FourthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-1, 0));
707 mStencil[FourthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 0));
708 mStencil[FourthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-1, 0));
709 mStencil[FourthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-1, 0));
711 mStencil[FourthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-2, 0));
712 mStencil[FourthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-2, 0));
713 mStencil[FourthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 0));
714 mStencil[FourthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-2, 0));
715 mStencil[FourthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-2, 0));
717 mStencil[FourthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 2));
718 mStencil[FourthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 2));
719 mStencil[FourthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
720 mStencil[FourthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 2));
721 mStencil[FourthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 2));
723 mStencil[FourthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 1));
724 mStencil[FourthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
725 mStencil[FourthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
726 mStencil[FourthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
727 mStencil[FourthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 1));
729 mStencil[FourthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-1));
730 mStencil[FourthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-1));
731 mStencil[FourthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-1));
732 mStencil[FourthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-1));
733 mStencil[FourthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-1));
735 mStencil[FourthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-2));
736 mStencil[FourthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-2));
737 mStencil[FourthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-2));
738 mStencil[FourthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-2));
739 mStencil[FourthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-2));
742 mStencil[FourthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 2));
743 mStencil[FourthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 2));
744 mStencil[FourthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 2));
745 mStencil[FourthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 2));
747 mStencil[FourthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 1));
748 mStencil[FourthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 1));
749 mStencil[FourthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
750 mStencil[FourthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 1));
752 mStencil[FourthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-1));
753 mStencil[FourthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-1));
754 mStencil[FourthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-1));
755 mStencil[FourthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-1));
757 mStencil[FourthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-2));
758 mStencil[FourthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-2));
759 mStencil[FourthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-2));
760 mStencil[FourthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-2));
764 using BaseType::mCache;
765 using BaseType::mStencil;
775 template<
int i,
int j,
int k>
struct NineteenPt {};
776 template<>
struct NineteenPt< 0, 0, 0> {
enum { idx = 0 }; };
778 template<>
struct NineteenPt< 1, 0, 0> {
enum { idx = 1 }; };
779 template<>
struct NineteenPt< 0, 1, 0> {
enum { idx = 2 }; };
780 template<>
struct NineteenPt< 0, 0, 1> {
enum { idx = 3 }; };
782 template<>
struct NineteenPt<-1, 0, 0> {
enum { idx = 4 }; };
783 template<>
struct NineteenPt< 0,-1, 0> {
enum { idx = 5 }; };
784 template<>
struct NineteenPt< 0, 0,-1> {
enum { idx = 6 }; };
786 template<>
struct NineteenPt< 2, 0, 0> {
enum { idx = 7 }; };
787 template<>
struct NineteenPt< 0, 2, 0> {
enum { idx = 8 }; };
788 template<>
struct NineteenPt< 0, 0, 2> {
enum { idx = 9 }; };
790 template<>
struct NineteenPt<-2, 0, 0> {
enum { idx = 10 }; };
791 template<>
struct NineteenPt< 0,-2, 0> {
enum { idx = 11 }; };
792 template<>
struct NineteenPt< 0, 0,-2> {
enum { idx = 12 }; };
794 template<>
struct NineteenPt< 3, 0, 0> {
enum { idx = 13 }; };
795 template<>
struct NineteenPt< 0, 3, 0> {
enum { idx = 14 }; };
796 template<>
struct NineteenPt< 0, 0, 3> {
enum { idx = 15 }; };
798 template<>
struct NineteenPt<-3, 0, 0> {
enum { idx = 16 }; };
799 template<>
struct NineteenPt< 0,-3, 0> {
enum { idx = 17 }; };
800 template<>
struct NineteenPt< 0, 0,-3> {
enum { idx = 18 }; };
805 template<
typename Gr
idT,
bool IsSafe = true>
807 :
public BaseStencil<NineteenPointStencil<GridT, IsSafe>, GridT, IsSafe>
816 static const int SIZE = 19;
821 template<
int i,
int j,
int k>
822 unsigned int pos()
const {
return NineteenPt<i,j,k>::idx; }
825 inline void init(
const Coord& ijk)
827 mStencil[NineteenPt< 3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
828 mStencil[NineteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
829 mStencil[NineteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
830 mStencil[NineteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
831 mStencil[NineteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
832 mStencil[NineteenPt<-3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
834 mStencil[NineteenPt< 0, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
835 mStencil[NineteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
836 mStencil[NineteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
837 mStencil[NineteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
838 mStencil[NineteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
839 mStencil[NineteenPt< 0,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, -3, 0));
841 mStencil[NineteenPt< 0, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
842 mStencil[NineteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
843 mStencil[NineteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
844 mStencil[NineteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
845 mStencil[NineteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
846 mStencil[NineteenPt< 0, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, -3));
850 using BaseType::mCache;
851 using BaseType::mStencil;
861 template<
int i,
int j,
int k>
struct SixthDensePt { };
862 template<>
struct SixthDensePt< 0, 0, 0> {
enum { idx = 0 }; };
864 template<>
struct SixthDensePt<-3, 3, 0> {
enum { idx = 1 }; };
865 template<>
struct SixthDensePt<-2, 3, 0> {
enum { idx = 2 }; };
866 template<>
struct SixthDensePt<-1, 3, 0> {
enum { idx = 3 }; };
867 template<>
struct SixthDensePt< 0, 3, 0> {
enum { idx = 4 }; };
868 template<>
struct SixthDensePt< 1, 3, 0> {
enum { idx = 5 }; };
869 template<>
struct SixthDensePt< 2, 3, 0> {
enum { idx = 6 }; };
870 template<>
struct SixthDensePt< 3, 3, 0> {
enum { idx = 7 }; };
872 template<>
struct SixthDensePt<-3, 2, 0> {
enum { idx = 8 }; };
873 template<>
struct SixthDensePt<-2, 2, 0> {
enum { idx = 9 }; };
874 template<>
struct SixthDensePt<-1, 2, 0> {
enum { idx = 10 }; };
875 template<>
struct SixthDensePt< 0, 2, 0> {
enum { idx = 11 }; };
876 template<>
struct SixthDensePt< 1, 2, 0> {
enum { idx = 12 }; };
877 template<>
struct SixthDensePt< 2, 2, 0> {
enum { idx = 13 }; };
878 template<>
struct SixthDensePt< 3, 2, 0> {
enum { idx = 14 }; };
880 template<>
struct SixthDensePt<-3, 1, 0> {
enum { idx = 15 }; };
881 template<>
struct SixthDensePt<-2, 1, 0> {
enum { idx = 16 }; };
882 template<>
struct SixthDensePt<-1, 1, 0> {
enum { idx = 17 }; };
883 template<>
struct SixthDensePt< 0, 1, 0> {
enum { idx = 18 }; };
884 template<>
struct SixthDensePt< 1, 1, 0> {
enum { idx = 19 }; };
885 template<>
struct SixthDensePt< 2, 1, 0> {
enum { idx = 20 }; };
886 template<>
struct SixthDensePt< 3, 1, 0> {
enum { idx = 21 }; };
888 template<>
struct SixthDensePt<-3, 0, 0> {
enum { idx = 22 }; };
889 template<>
struct SixthDensePt<-2, 0, 0> {
enum { idx = 23 }; };
890 template<>
struct SixthDensePt<-1, 0, 0> {
enum { idx = 24 }; };
891 template<>
struct SixthDensePt< 1, 0, 0> {
enum { idx = 25 }; };
892 template<>
struct SixthDensePt< 2, 0, 0> {
enum { idx = 26 }; };
893 template<>
struct SixthDensePt< 3, 0, 0> {
enum { idx = 27 }; };
896 template<>
struct SixthDensePt<-3,-1, 0> {
enum { idx = 28 }; };
897 template<>
struct SixthDensePt<-2,-1, 0> {
enum { idx = 29 }; };
898 template<>
struct SixthDensePt<-1,-1, 0> {
enum { idx = 30 }; };
899 template<>
struct SixthDensePt< 0,-1, 0> {
enum { idx = 31 }; };
900 template<>
struct SixthDensePt< 1,-1, 0> {
enum { idx = 32 }; };
901 template<>
struct SixthDensePt< 2,-1, 0> {
enum { idx = 33 }; };
902 template<>
struct SixthDensePt< 3,-1, 0> {
enum { idx = 34 }; };
905 template<>
struct SixthDensePt<-3,-2, 0> {
enum { idx = 35 }; };
906 template<>
struct SixthDensePt<-2,-2, 0> {
enum { idx = 36 }; };
907 template<>
struct SixthDensePt<-1,-2, 0> {
enum { idx = 37 }; };
908 template<>
struct SixthDensePt< 0,-2, 0> {
enum { idx = 38 }; };
909 template<>
struct SixthDensePt< 1,-2, 0> {
enum { idx = 39 }; };
910 template<>
struct SixthDensePt< 2,-2, 0> {
enum { idx = 40 }; };
911 template<>
struct SixthDensePt< 3,-2, 0> {
enum { idx = 41 }; };
914 template<>
struct SixthDensePt<-3,-3, 0> {
enum { idx = 42 }; };
915 template<>
struct SixthDensePt<-2,-3, 0> {
enum { idx = 43 }; };
916 template<>
struct SixthDensePt<-1,-3, 0> {
enum { idx = 44 }; };
917 template<>
struct SixthDensePt< 0,-3, 0> {
enum { idx = 45 }; };
918 template<>
struct SixthDensePt< 1,-3, 0> {
enum { idx = 46 }; };
919 template<>
struct SixthDensePt< 2,-3, 0> {
enum { idx = 47 }; };
920 template<>
struct SixthDensePt< 3,-3, 0> {
enum { idx = 48 }; };
923 template<>
struct SixthDensePt<-3, 0, 3> {
enum { idx = 49 }; };
924 template<>
struct SixthDensePt<-2, 0, 3> {
enum { idx = 50 }; };
925 template<>
struct SixthDensePt<-1, 0, 3> {
enum { idx = 51 }; };
926 template<>
struct SixthDensePt< 0, 0, 3> {
enum { idx = 52 }; };
927 template<>
struct SixthDensePt< 1, 0, 3> {
enum { idx = 53 }; };
928 template<>
struct SixthDensePt< 2, 0, 3> {
enum { idx = 54 }; };
929 template<>
struct SixthDensePt< 3, 0, 3> {
enum { idx = 55 }; };
932 template<>
struct SixthDensePt<-3, 0, 2> {
enum { idx = 56 }; };
933 template<>
struct SixthDensePt<-2, 0, 2> {
enum { idx = 57 }; };
934 template<>
struct SixthDensePt<-1, 0, 2> {
enum { idx = 58 }; };
935 template<>
struct SixthDensePt< 0, 0, 2> {
enum { idx = 59 }; };
936 template<>
struct SixthDensePt< 1, 0, 2> {
enum { idx = 60 }; };
937 template<>
struct SixthDensePt< 2, 0, 2> {
enum { idx = 61 }; };
938 template<>
struct SixthDensePt< 3, 0, 2> {
enum { idx = 62 }; };
940 template<>
struct SixthDensePt<-3, 0, 1> {
enum { idx = 63 }; };
941 template<>
struct SixthDensePt<-2, 0, 1> {
enum { idx = 64 }; };
942 template<>
struct SixthDensePt<-1, 0, 1> {
enum { idx = 65 }; };
943 template<>
struct SixthDensePt< 0, 0, 1> {
enum { idx = 66 }; };
944 template<>
struct SixthDensePt< 1, 0, 1> {
enum { idx = 67 }; };
945 template<>
struct SixthDensePt< 2, 0, 1> {
enum { idx = 68 }; };
946 template<>
struct SixthDensePt< 3, 0, 1> {
enum { idx = 69 }; };
949 template<>
struct SixthDensePt<-3, 0,-1> {
enum { idx = 70 }; };
950 template<>
struct SixthDensePt<-2, 0,-1> {
enum { idx = 71 }; };
951 template<>
struct SixthDensePt<-1, 0,-1> {
enum { idx = 72 }; };
952 template<>
struct SixthDensePt< 0, 0,-1> {
enum { idx = 73 }; };
953 template<>
struct SixthDensePt< 1, 0,-1> {
enum { idx = 74 }; };
954 template<>
struct SixthDensePt< 2, 0,-1> {
enum { idx = 75 }; };
955 template<>
struct SixthDensePt< 3, 0,-1> {
enum { idx = 76 }; };
958 template<>
struct SixthDensePt<-3, 0,-2> {
enum { idx = 77 }; };
959 template<>
struct SixthDensePt<-2, 0,-2> {
enum { idx = 78 }; };
960 template<>
struct SixthDensePt<-1, 0,-2> {
enum { idx = 79 }; };
961 template<>
struct SixthDensePt< 0, 0,-2> {
enum { idx = 80 }; };
962 template<>
struct SixthDensePt< 1, 0,-2> {
enum { idx = 81 }; };
963 template<>
struct SixthDensePt< 2, 0,-2> {
enum { idx = 82 }; };
964 template<>
struct SixthDensePt< 3, 0,-2> {
enum { idx = 83 }; };
967 template<>
struct SixthDensePt<-3, 0,-3> {
enum { idx = 84 }; };
968 template<>
struct SixthDensePt<-2, 0,-3> {
enum { idx = 85 }; };
969 template<>
struct SixthDensePt<-1, 0,-3> {
enum { idx = 86 }; };
970 template<>
struct SixthDensePt< 0, 0,-3> {
enum { idx = 87 }; };
971 template<>
struct SixthDensePt< 1, 0,-3> {
enum { idx = 88 }; };
972 template<>
struct SixthDensePt< 2, 0,-3> {
enum { idx = 89 }; };
973 template<>
struct SixthDensePt< 3, 0,-3> {
enum { idx = 90 }; };
976 template<>
struct SixthDensePt< 0,-3, 3> {
enum { idx = 91 }; };
977 template<>
struct SixthDensePt< 0,-2, 3> {
enum { idx = 92 }; };
978 template<>
struct SixthDensePt< 0,-1, 3> {
enum { idx = 93 }; };
979 template<>
struct SixthDensePt< 0, 1, 3> {
enum { idx = 94 }; };
980 template<>
struct SixthDensePt< 0, 2, 3> {
enum { idx = 95 }; };
981 template<>
struct SixthDensePt< 0, 3, 3> {
enum { idx = 96 }; };
983 template<>
struct SixthDensePt< 0,-3, 2> {
enum { idx = 97 }; };
984 template<>
struct SixthDensePt< 0,-2, 2> {
enum { idx = 98 }; };
985 template<>
struct SixthDensePt< 0,-1, 2> {
enum { idx = 99 }; };
986 template<>
struct SixthDensePt< 0, 1, 2> {
enum { idx = 100 }; };
987 template<>
struct SixthDensePt< 0, 2, 2> {
enum { idx = 101 }; };
988 template<>
struct SixthDensePt< 0, 3, 2> {
enum { idx = 102 }; };
990 template<>
struct SixthDensePt< 0,-3, 1> {
enum { idx = 103 }; };
991 template<>
struct SixthDensePt< 0,-2, 1> {
enum { idx = 104 }; };
992 template<>
struct SixthDensePt< 0,-1, 1> {
enum { idx = 105 }; };
993 template<>
struct SixthDensePt< 0, 1, 1> {
enum { idx = 106 }; };
994 template<>
struct SixthDensePt< 0, 2, 1> {
enum { idx = 107 }; };
995 template<>
struct SixthDensePt< 0, 3, 1> {
enum { idx = 108 }; };
997 template<>
struct SixthDensePt< 0,-3,-1> {
enum { idx = 109 }; };
998 template<>
struct SixthDensePt< 0,-2,-1> {
enum { idx = 110 }; };
999 template<>
struct SixthDensePt< 0,-1,-1> {
enum { idx = 111 }; };
1000 template<>
struct SixthDensePt< 0, 1,-1> {
enum { idx = 112 }; };
1001 template<>
struct SixthDensePt< 0, 2,-1> {
enum { idx = 113 }; };
1002 template<>
struct SixthDensePt< 0, 3,-1> {
enum { idx = 114 }; };
1004 template<>
struct SixthDensePt< 0,-3,-2> {
enum { idx = 115 }; };
1005 template<>
struct SixthDensePt< 0,-2,-2> {
enum { idx = 116 }; };
1006 template<>
struct SixthDensePt< 0,-1,-2> {
enum { idx = 117 }; };
1007 template<>
struct SixthDensePt< 0, 1,-2> {
enum { idx = 118 }; };
1008 template<>
struct SixthDensePt< 0, 2,-2> {
enum { idx = 119 }; };
1009 template<>
struct SixthDensePt< 0, 3,-2> {
enum { idx = 120 }; };
1011 template<>
struct SixthDensePt< 0,-3,-3> {
enum { idx = 121 }; };
1012 template<>
struct SixthDensePt< 0,-2,-3> {
enum { idx = 122 }; };
1013 template<>
struct SixthDensePt< 0,-1,-3> {
enum { idx = 123 }; };
1014 template<>
struct SixthDensePt< 0, 1,-3> {
enum { idx = 124 }; };
1015 template<>
struct SixthDensePt< 0, 2,-3> {
enum { idx = 125 }; };
1016 template<>
struct SixthDensePt< 0, 3,-3> {
enum { idx = 126 }; };
1021 template<
typename Gr
idT,
bool IsSafe = true>
1023 :
public BaseStencil<SixthOrderDenseStencil<GridT, IsSafe>, GridT, IsSafe>
1032 static const int SIZE = 127;
1037 template<
int i,
int j,
int k>
1038 unsigned int pos()
const {
return SixthDensePt<i,j,k>::idx; }
1041 inline void init(
const Coord& ijk)
1043 mStencil[SixthDensePt<-3, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 3, 0));
1044 mStencil[SixthDensePt<-2, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 3, 0));
1045 mStencil[SixthDensePt<-1, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 3, 0));
1046 mStencil[SixthDensePt< 0, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
1047 mStencil[SixthDensePt< 1, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 3, 0));
1048 mStencil[SixthDensePt< 2, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 3, 0));
1049 mStencil[SixthDensePt< 3, 3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 3, 0));
1051 mStencil[SixthDensePt<-3, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 2, 0));
1052 mStencil[SixthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 2, 0));
1053 mStencil[SixthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 2, 0));
1054 mStencil[SixthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
1055 mStencil[SixthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 2, 0));
1056 mStencil[SixthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 2, 0));
1057 mStencil[SixthDensePt< 3, 2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 2, 0));
1059 mStencil[SixthDensePt<-3, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 1, 0));
1060 mStencil[SixthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 1, 0));
1061 mStencil[SixthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
1062 mStencil[SixthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1063 mStencil[SixthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
1064 mStencil[SixthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 1, 0));
1065 mStencil[SixthDensePt< 3, 1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 1, 0));
1067 mStencil[SixthDensePt<-3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
1068 mStencil[SixthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
1069 mStencil[SixthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1070 mStencil[SixthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1071 mStencil[SixthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
1072 mStencil[SixthDensePt< 3, 0, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
1074 mStencil[SixthDensePt<-3,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-1, 0));
1075 mStencil[SixthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-1, 0));
1076 mStencil[SixthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-1, 0));
1077 mStencil[SixthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 0));
1078 mStencil[SixthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-1, 0));
1079 mStencil[SixthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-1, 0));
1080 mStencil[SixthDensePt< 3,-1, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-1, 0));
1082 mStencil[SixthDensePt<-3,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-2, 0));
1083 mStencil[SixthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-2, 0));
1084 mStencil[SixthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-2, 0));
1085 mStencil[SixthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 0));
1086 mStencil[SixthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-2, 0));
1087 mStencil[SixthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-2, 0));
1088 mStencil[SixthDensePt< 3,-2, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-2, 0));
1090 mStencil[SixthDensePt<-3,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-3,-3, 0));
1091 mStencil[SixthDensePt<-2,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-2,-3, 0));
1092 mStencil[SixthDensePt<-1,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy(-1,-3, 0));
1093 mStencil[SixthDensePt< 0,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 0));
1094 mStencil[SixthDensePt< 1,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 1,-3, 0));
1095 mStencil[SixthDensePt< 2,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 2,-3, 0));
1096 mStencil[SixthDensePt< 3,-3, 0>::idx] = mCache.getValue(ijk.
offsetBy( 3,-3, 0));
1098 mStencil[SixthDensePt<-3, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 3));
1099 mStencil[SixthDensePt<-2, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 3));
1100 mStencil[SixthDensePt<-1, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 3));
1101 mStencil[SixthDensePt< 0, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
1102 mStencil[SixthDensePt< 1, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 3));
1103 mStencil[SixthDensePt< 2, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 3));
1104 mStencil[SixthDensePt< 3, 0, 3>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 3));
1106 mStencil[SixthDensePt<-3, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 2));
1107 mStencil[SixthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 2));
1108 mStencil[SixthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 2));
1109 mStencil[SixthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
1110 mStencil[SixthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 2));
1111 mStencil[SixthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 2));
1112 mStencil[SixthDensePt< 3, 0, 2>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 2));
1114 mStencil[SixthDensePt<-3, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0, 1));
1115 mStencil[SixthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0, 1));
1116 mStencil[SixthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
1117 mStencil[SixthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1118 mStencil[SixthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
1119 mStencil[SixthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0, 1));
1120 mStencil[SixthDensePt< 3, 0, 1>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0, 1));
1122 mStencil[SixthDensePt<-3, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-1));
1123 mStencil[SixthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-1));
1124 mStencil[SixthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-1));
1125 mStencil[SixthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-1));
1126 mStencil[SixthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-1));
1127 mStencil[SixthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-1));
1128 mStencil[SixthDensePt< 3, 0,-1>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-1));
1130 mStencil[SixthDensePt<-3, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-2));
1131 mStencil[SixthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-2));
1132 mStencil[SixthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-2));
1133 mStencil[SixthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-2));
1134 mStencil[SixthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-2));
1135 mStencil[SixthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-2));
1136 mStencil[SixthDensePt< 3, 0,-2>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-2));
1138 mStencil[SixthDensePt<-3, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-3, 0,-3));
1139 mStencil[SixthDensePt<-2, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-2, 0,-3));
1140 mStencil[SixthDensePt<-1, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy(-1, 0,-3));
1141 mStencil[SixthDensePt< 0, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 0,-3));
1142 mStencil[SixthDensePt< 1, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 1, 0,-3));
1143 mStencil[SixthDensePt< 2, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 2, 0,-3));
1144 mStencil[SixthDensePt< 3, 0,-3>::idx] = mCache.getValue(ijk.
offsetBy( 3, 0,-3));
1146 mStencil[SixthDensePt< 0,-3, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 3));
1147 mStencil[SixthDensePt< 0,-2, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 3));
1148 mStencil[SixthDensePt< 0,-1, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 3));
1149 mStencil[SixthDensePt< 0, 1, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 3));
1150 mStencil[SixthDensePt< 0, 2, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 3));
1151 mStencil[SixthDensePt< 0, 3, 3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 3));
1153 mStencil[SixthDensePt< 0,-3, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 2));
1154 mStencil[SixthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 2));
1155 mStencil[SixthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 2));
1156 mStencil[SixthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 2));
1157 mStencil[SixthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 2));
1158 mStencil[SixthDensePt< 0, 3, 2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 2));
1160 mStencil[SixthDensePt< 0,-3, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3, 1));
1161 mStencil[SixthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2, 1));
1162 mStencil[SixthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1, 1));
1163 mStencil[SixthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
1164 mStencil[SixthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2, 1));
1165 mStencil[SixthDensePt< 0, 3, 1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3, 1));
1167 mStencil[SixthDensePt< 0,-3,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-1));
1168 mStencil[SixthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-1));
1169 mStencil[SixthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-1));
1170 mStencil[SixthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-1));
1171 mStencil[SixthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-1));
1172 mStencil[SixthDensePt< 0, 3,-1>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-1));
1174 mStencil[SixthDensePt< 0,-3,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-2));
1175 mStencil[SixthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-2));
1176 mStencil[SixthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-2));
1177 mStencil[SixthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-2));
1178 mStencil[SixthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-2));
1179 mStencil[SixthDensePt< 0, 3,-2>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-2));
1181 mStencil[SixthDensePt< 0,-3,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-3,-3));
1182 mStencil[SixthDensePt< 0,-2,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-2,-3));
1183 mStencil[SixthDensePt< 0,-1,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0,-1,-3));
1184 mStencil[SixthDensePt< 0, 1,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 1,-3));
1185 mStencil[SixthDensePt< 0, 2,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 2,-3));
1186 mStencil[SixthDensePt< 0, 3,-3>::idx] = mCache.getValue(ijk.
offsetBy( 0, 3,-3));
1190 using BaseType::mCache;
1191 using BaseType::mStencil;
1200 template<
int i,
int j,
int k>
struct GradPt {};
1201 template<>
struct GradPt< 0, 0, 0> {
enum { idx = 0 }; };
1202 template<>
struct GradPt< 1, 0, 0> {
enum { idx = 2 }; };
1203 template<>
struct GradPt< 0, 1, 0> {
enum { idx = 4 }; };
1204 template<>
struct GradPt< 0, 0, 1> {
enum { idx = 6 }; };
1205 template<>
struct GradPt<-1, 0, 0> {
enum { idx = 1 }; };
1206 template<>
struct GradPt< 0,-1, 0> {
enum { idx = 3 }; };
1207 template<>
struct GradPt< 0, 0,-1> {
enum { idx = 5 }; };
1216 template<
typename Gr
idT,
bool IsSafe = true>
1226 static const int SIZE = 7;
1229 : BaseType(grid, SIZE)
1230 , mInv2Dx(ValueType(0.5 / grid.voxelSize()[0]))
1231 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1236 : BaseType(grid, SIZE)
1237 , mInv2Dx(ValueType(0.5 / dx))
1238 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1250 mStencil[0] - mStencil[1],
1251 mStencil[2] - mStencil[0],
1252 mStencil[0] - mStencil[3],
1253 mStencil[4] - mStencil[0],
1254 mStencil[0] - mStencil[5],
1255 mStencil[6] - mStencil[0]);
1266 mStencil[4] - mStencil[3],
1267 mStencil[6] - mStencil[5])*mInv2Dx;
1276 V[0]>0 ? mStencil[0] - mStencil[1] : mStencil[2] - mStencil[0],
1277 V[1]>0 ? mStencil[0] - mStencil[3] : mStencil[4] - mStencil[0],
1278 V[2]>0 ? mStencil[0] - mStencil[5] : mStencil[6] - mStencil[0])*2*mInv2Dx;
1285 return mInvDx2 * (mStencil[1] + mStencil[2] +
1286 mStencil[3] + mStencil[4] +
1287 mStencil[5] + mStencil[6] - 6*mStencil[0]);
1295 return (v[0]>0 ? (v[1]<0 || v[2]<0 || v[3]<0 || v[4]<0 || v[5]<0 || v[6]<0)
1296 : (v[1]>0 || v[2]>0 || v[3]>0 || v[4]>0 || v[5]>0 || v[6]>0));
1308 const Coord& ijk = BaseType::getCenterCoord();
1309 const ValueType d = ValueType(mStencil[0] * 0.5 * mInvDx2);
1311 ijk[1] - d*(mStencil[4] - mStencil[3]),
1312 ijk[2] - d*(mStencil[6] - mStencil[5]));
1316 template<
int i,
int j,
int k>
1317 unsigned int pos()
const {
return GradPt<i,j,k>::idx; }
1321 inline void init(
const Coord& ijk)
1323 BaseType::template setValue<-1, 0, 0>(mCache.getValue(ijk.
offsetBy(-1, 0, 0)));
1324 BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.
offsetBy( 1, 0, 0)));
1326 BaseType::template setValue< 0,-1, 0>(mCache.getValue(ijk.
offsetBy( 0,-1, 0)));
1327 BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.
offsetBy( 0, 1, 0)));
1329 BaseType::template setValue< 0, 0,-1>(mCache.getValue(ijk.
offsetBy( 0, 0,-1)));
1330 BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.
offsetBy( 0, 0, 1)));
1334 using BaseType::mCache;
1335 using BaseType::mStencil;
1336 const ValueType mInv2Dx, mInvDx2;
1347 template<
typename Gr
idT,
bool IsSafe = true>
1357 static const int SIZE = 19;
1360 : BaseType(grid, SIZE)
1361 , mDx2(ValueType(math::
Pow2(grid.voxelSize()[0])))
1362 , mInv2Dx(ValueType(0.5 / grid.voxelSize()[0]))
1363 , mInvDx2(ValueType(1.0 / mDx2))
1368 : BaseType(grid, SIZE)
1369 , mDx2(ValueType(dx * dx))
1370 , mInv2Dx(ValueType(0.5 / dx))
1371 , mInvDx2(ValueType(1.0 / mDx2))
1380 inline ValueType
normSqGrad(
const ValueType &isoValue = zeroVal<ValueType>())
const 1386 v1(v[2]-v[1], v[ 8]-v[ 7], v[14]-v[13], 0),
1387 v2(v[3]-v[2], v[ 9]-v[ 8], v[15]-v[14], 0),
1388 v3(v[0]-v[3], v[ 0]-v[ 9], v[ 0]-v[15], 0),
1389 v4(v[4]-v[0], v[10]-v[ 0], v[16]-v[ 0], 0),
1390 v5(v[5]-v[4], v[11]-v[10], v[17]-v[16], 0),
1391 v6(v[6]-v[5], v[12]-v[11], v[18]-v[17], 0),
1398 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),
1399 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),
1400 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),
1401 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),
1402 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),
1403 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);
1404 return static_cast<ValueType
>(
1418 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)
1419 :
math::WENO5(v[ 6]-v[ 5],v[ 5]-v[ 4],v[ 4]-v[ 0], v[ 0]-v[ 3],v[ 3]-v[ 2],mDx2),
1420 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)
1421 :
math::WENO5(v[12]-v[11],v[11]-v[10],v[10]-v[ 0], v[ 0]-v[ 9],v[ 9]-v[ 8],mDx2),
1422 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)
1423 :
math::WENO5(v[18]-v[17],v[17]-v[16],v[16]-v[ 0], v[ 0]-v[15],v[15]-v[14],mDx2));
1433 mStencil[10] - mStencil[ 9],
1434 mStencil[16] - mStencil[15]);
1445 mStencil[ 3] + mStencil[ 4] +
1446 mStencil[ 9] + mStencil[10] +
1447 mStencil[15] + mStencil[16] - 6*mStencil[0]);
1455 return (v[ 0]>0 ? (v[ 3]<0 || v[ 4]<0 || v[ 9]<0 || v[10]<0 || v[15]<0 || v[16]<0)
1456 : (v[ 3]>0 || v[ 4]>0 || v[ 9]>0 || v[10]>0 || v[15]>0 || v[16]>0));
1460 inline void init(
const Coord& ijk)
1462 mStencil[ 1] = mCache.getValue(ijk.
offsetBy(-3, 0, 0));
1463 mStencil[ 2] = mCache.getValue(ijk.
offsetBy(-2, 0, 0));
1464 mStencil[ 3] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1465 mStencil[ 4] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1466 mStencil[ 5] = mCache.getValue(ijk.
offsetBy( 2, 0, 0));
1467 mStencil[ 6] = mCache.getValue(ijk.
offsetBy( 3, 0, 0));
1469 mStencil[ 7] = mCache.getValue(ijk.
offsetBy( 0, -3, 0));
1470 mStencil[ 8] = mCache.getValue(ijk.
offsetBy( 0, -2, 0));
1471 mStencil[ 9] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1472 mStencil[10] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1473 mStencil[11] = mCache.getValue(ijk.
offsetBy( 0, 2, 0));
1474 mStencil[12] = mCache.getValue(ijk.
offsetBy( 0, 3, 0));
1476 mStencil[13] = mCache.getValue(ijk.
offsetBy( 0, 0, -3));
1477 mStencil[14] = mCache.getValue(ijk.
offsetBy( 0, 0, -2));
1478 mStencil[15] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1479 mStencil[16] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1480 mStencil[17] = mCache.getValue(ijk.
offsetBy( 0, 0, 2));
1481 mStencil[18] = mCache.getValue(ijk.
offsetBy( 0, 0, 3));
1485 using BaseType::mCache;
1486 using BaseType::mStencil;
1487 const ValueType mDx2, mInv2Dx, mInvDx2;
1494 template<
typename Gr
idT,
bool IsSafe = true>
1504 static const int SIZE = 19;
1507 : BaseType(grid, SIZE)
1508 , mInv2Dx(ValueType(0.5 / grid.voxelSize()[0]))
1509 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1514 : BaseType(grid, SIZE)
1515 , mInv2Dx(ValueType(0.5 / dx))
1516 , mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1550 mStencil[1] + mStencil[2] +
1551 mStencil[3] + mStencil[4] +
1552 mStencil[5] + mStencil[6] - 6*mStencil[0]);
1563 mStencil[2] - mStencil[1],
1564 mStencil[4] - mStencil[3],
1565 mStencil[6] - mStencil[5])*mInv2Dx;
1569 inline void init(
const Coord &ijk)
1571 mStencil[ 1] = mCache.getValue(ijk.
offsetBy(-1, 0, 0));
1572 mStencil[ 2] = mCache.getValue(ijk.
offsetBy( 1, 0, 0));
1574 mStencil[ 3] = mCache.getValue(ijk.
offsetBy( 0, -1, 0));
1575 mStencil[ 4] = mCache.getValue(ijk.
offsetBy( 0, 1, 0));
1577 mStencil[ 5] = mCache.getValue(ijk.
offsetBy( 0, 0, -1));
1578 mStencil[ 6] = mCache.getValue(ijk.
offsetBy( 0, 0, 1));
1580 mStencil[ 7] = mCache.getValue(ijk.
offsetBy(-1, -1, 0));
1581 mStencil[ 8] = mCache.getValue(ijk.
offsetBy( 1, -1, 0));
1582 mStencil[ 9] = mCache.getValue(ijk.
offsetBy(-1, 1, 0));
1583 mStencil[10] = mCache.getValue(ijk.
offsetBy( 1, 1, 0));
1585 mStencil[11] = mCache.getValue(ijk.
offsetBy(-1, 0, -1));
1586 mStencil[12] = mCache.getValue(ijk.
offsetBy( 1, 0, -1));
1587 mStencil[13] = mCache.getValue(ijk.
offsetBy(-1, 0, 1));
1588 mStencil[14] = mCache.getValue(ijk.
offsetBy( 1, 0, 1));
1590 mStencil[15] = mCache.getValue(ijk.
offsetBy( 0, -1, -1));
1591 mStencil[16] = mCache.getValue(ijk.
offsetBy( 0, 1, -1));
1592 mStencil[17] = mCache.getValue(ijk.
offsetBy( 0, -1, 1));
1593 mStencil[18] = mCache.getValue(ijk.
offsetBy( 0, 1, 1));
1600 Half(0.5), Quarter(0.25),
1601 Dx = Half * (mStencil[2] - mStencil[1]), Dx2 = Dx * Dx,
1602 Dy = Half * (mStencil[4] - mStencil[3]), Dy2 = Dy * Dy,
1603 Dz = Half * (mStencil[6] - mStencil[5]), Dz2 = Dz * Dz,
1604 normGrad = Dx2 + Dy2 + Dz2;
1610 Dxx = mStencil[2] - 2 * mStencil[0] + mStencil[1],
1611 Dyy = mStencil[4] - 2 * mStencil[0] + mStencil[3],
1612 Dzz = mStencil[6] - 2 * mStencil[0] + mStencil[5],
1613 Dxy = Quarter * (mStencil[10] - mStencil[ 8] + mStencil[7] - mStencil[ 9]),
1614 Dxz = Quarter * (mStencil[14] - mStencil[12] + mStencil[11] - mStencil[13]),
1615 Dyz = Quarter * (mStencil[18] - mStencil[16] + mStencil[15] - mStencil[17]);
1616 alpha = (Dx2*(Dyy+Dzz)+Dy2*(Dxx+Dzz)+Dz2*(Dxx+Dyy)-2*(Dx*(Dy*Dxy+Dz*Dxz)+Dy*Dz*Dyz));
1617 beta = std::sqrt(normGrad);
1622 using BaseType::mCache;
1623 using BaseType::mStencil;
1624 const ValueType mInv2Dx, mInvDx2;
1632 template<
typename Gr
idT,
bool IsSafe = true>
1643 : BaseType(grid, math::
Pow3(2 * halfWidth + 1))
1644 , mHalfWidth(halfWidth)
1646 assert(halfWidth>0);
1649 inline const ValueType&
getCenterValue()
const {
return mStencil[(mStencil.size()-1)>>1]; }
1655 BaseType::mCenter = ijk;
1660 template<
typename IterType>
1663 BaseType::mCenter = iter.getCoord();
1664 this->init(BaseType::mCenter);
1670 inline void init(
const Coord& ijk)
1674 for (p[1] = ijk[1]-mHalfWidth; p[1] <= q[1]; ++p[1]) {
1675 for (p[2] = ijk[2]-mHalfWidth; p[2] <= q[2]; ++p[2]) {
1676 mStencil[n++] = mCache.getValue(p);
1683 using BaseType::mCache;
1684 using BaseType::mStencil;
1685 const int mHalfWidth;
1693 #endif // OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED math::Vec3< ValueType > gradient(const math::Vec3< ValueType > &V) const
Definition: Stencils.h:1414
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:1317
GridType::ValueType ValueType
Definition: Stencils.h:1355
const ValueType & getCenterValue() const
Return the value at the center of the stencil.
Definition: Stencils.h:183
ValueType interpolation(const math::Vec3< ValueType > &xyz) const
Return the trilinear interpolation at the normalized position.
Definition: Stencils.h:335
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:1348
double Real
Definition: Types.h:67
math::Vec3< ValueType > gradient() const
Return the gradient computed at the previously buffered location by second order central differencing...
Definition: Stencils.h:1263
Definition: Stencils.h:1022
BufferType::iterator IterType
Definition: Stencils.h:68
tree::ValueAccessor< const TreeType, IsSafe > AccessorType
Definition: Stencils.h:66
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
math::Vec3< ValueType > gradient() const
Definition: Stencils.h:1430
ValueType median() const
Return the median value of the current stencil.
Definition: Stencils.h:147
CurvatureStencil(const GridType &grid)
Definition: Stencils.h:1506
void setValue(const ValueType &value)
Set the value at the specified location relative to the center of the stencil.
Definition: Stencils.h:138
GridT GridType
Definition: Stencils.h:462
WenoStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1367
int size()
Return the size of the stencil buffer.
Definition: Stencils.h:144
SecondOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:468
ValueType normSqGrad(const ValueType &isoValue=zeroVal< ValueType >()) const
Return the norm-square of the WENO upwind gradient (computed via WENO upwinding and Godunov's scheme)...
Definition: Stencils.h:1380
Definition: Stencils.h:536
void moveTo(const Coord &ijk)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:1653
Definition: Stencils.h:456
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
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
bool zeroCrossing() const
Definition: Stencils.h:1292
GridT::TreeType TreeType
Definition: Stencils.h:1029
GridType::ValueType ValueType
Definition: Stencils.h:675
void moveTo(const IterType &iter)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:1661
const Coord & getCenterCoord() const
Return the coordinates of the center point of the stencil.
Definition: Stencils.h:180
ThirteenPointStencil(const GridType &grid)
Definition: Stencils.h:548
GridT GridType
Definition: Stencils.h:1638
GridT::TreeType TreeType
Definition: Stencils.h:1354
FourthOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:679
GridT::TreeType TreeType
Definition: Stencils.h:463
static Coord floor(const Vec3< T > &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion)...
Definition: Coord.h:83
AccessorType mCache
Definition: Stencils.h:217
bool zeroCrossing() const
Definition: Stencils.h:1452
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:683
Definition: Stencils.h:297
GridT GridType
Definition: Stencils.h:1353
GradStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1235
GridT GridType
Definition: Stencils.h:248
const ValueType & getCenterValue() const
Definition: Stencils.h:1649
Tolerance for floating-point comparison.
Definition: Math.h:117
CurvatureStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1513
GridT GridType
Definition: Stencils.h:1222
const ValueType & getValue() const
Return the value at the specified location relative to the center of the stencil. ...
Definition: Stencils.h:131
NineteenPointStencil(const GridType &grid)
Definition: Stencils.h:818
const ValueType & getValue(unsigned int pos=0) const
Return the value from the stencil buffer with linear offset pos.
Definition: Stencils.h:123
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:822
GridT GridType
Definition: Stencils.h:302
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
BufferType mStencil
Definition: Stencils.h:218
GridType::ValueType ValueType
Definition: Stencils.h:814
GridT::ValueType ValueType
Definition: Stencils.h:65
GridT::ValueType ValueType
Definition: Stencils.h:250
GridT GridType
Definition: Stencils.h:63
GridT GridType
Definition: Stencils.h:673
GridT::TreeType TreeType
Definition: Stencils.h:543
ValueType max() const
Return the largest value in the stencil buffer.
Definition: Stencils.h:173
Definition: Stencils.h:60
Definition: Exceptions.h:40
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:552
GridT::TreeType TreeType
Definition: Stencils.h:303
GridT::TreeType TreeType
Definition: Stencils.h:1639
ValueType meanCurvature()
Return the mean curvature at the previously buffered location.
Definition: Stencils.h:1524
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:118
BaseStencil(const GridType &grid, int size)
Definition: Stencils.h:208
void moveTo(const Vec3< RealType > &xyz)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:112
void moveTo(const IterType &iter)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:98
Definition: Stencils.h:243
ValueType meanCurvatureNormGrad()
Definition: Stencils.h:1536
GridT::TreeType TreeType
Definition: Stencils.h:249
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:187
SevenPointStencil(const GridT &grid)
Definition: Stencils.h:254
const AccessorType & accessor() const
Return a const reference to the ValueAccessor associated with this Stencil.
Definition: Stencils.h:204
ValueType laplacian() const
Definition: Stencils.h:1442
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:258
GridT GridType
Definition: Stencils.h:1028
ValueType laplacian() const
Definition: Stencils.h:1547
const GridType & grid() const
Return a const reference to the grid from which this stencil was constructed.
Definition: Stencils.h:200
SixthOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:1034
GridT GridType
Definition: Stencils.h:542
math::Vec3< ValueType > gradient(const math::Vec3< ValueType > &xyz) const
Return the gradient in world space of the trilinear interpolation kernel.
Definition: Stencils.h:363
const GridType * mGrid
Definition: Stencils.h:216
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:472
math::Vec3< ValueType > gradient()
Definition: Stencils.h:1560
GridT::TreeType TreeType
Definition: Stencils.h:1501
GridT::ValueType ValueType
Definition: Stencils.h:304
GridT::TreeType TreeType
Definition: Stencils.h:1223
Type Pow3(Type x)
Return x3.
Definition: Math.h:506
void moveTo(const Coord &ijk)
Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors.
Definition: Stencils.h:73
ValueType min() const
Return the smallest value in the stencil buffer.
Definition: Stencils.h:166
Type Pow2(Type x)
Return x2.
Definition: Math.h:502
GridType::ValueType ValueType
Definition: Stencils.h:544
math::Vec3< ValueType > cpt()
Compute the closest-point transform to a level set.
Definition: Stencils.h:1306
std::vector< ValueType > BufferType
Definition: Stencils.h:67
bool intersects(const ValueType &isoValue=zeroVal< ValueType >()) const
Return true if the center of the stencil intersects the.
Definition: Stencils.h:316
GridType::ValueType ValueType
Definition: Stencils.h:464
Definition: Stencils.h:806
GridT GridType
Definition: Stencils.h:812
GridT::TreeType TreeType
Definition: Stencils.h:813
WenoStencil(const GridType &grid)
Definition: Stencils.h:1359
DenseStencil(const GridType &grid, int halfWidth)
Definition: Stencils.h:1642
ValueType laplacian() const
Definition: Stencils.h:1283
Coord mCenter
Definition: Stencils.h:219
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
Definition: Stencils.h:1495
GridT::ValueType ValueType
Definition: Stencils.h:1502
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:1038
Real GodunovsNormSqrd(bool isOutside, Real dP_xm, Real dP_xp, Real dP_ym, Real dP_yp, Real dP_zm, Real dP_zp)
Definition: FiniteDifference.h:353
Dense stencil of a given width.
Definition: Stencils.h:1633
GridType::ValueType ValueType
Definition: Stencils.h:1224
GridT::TreeType TreeType
Definition: Stencils.h:64
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:312
Definition: Stencils.h:667
GradStencil(const GridType &grid)
Definition: Stencils.h:1228
ValueType normSqGrad() const
Return the norm square of the single-sided upwind gradient (computed via Godunov's scheme) at the pre...
Definition: Stencils.h:1247
math::Vec3< ValueType > gradient(const math::Vec3< ValueType > &V) const
Return the first-order upwind gradient corresponding to the direction V.
Definition: Stencils.h:1273
Definition: Stencils.h:1217
GridT GridType
Definition: Stencils.h:1500
GridType::ValueType ValueType
Definition: Stencils.h:1030
BoxStencil(const GridType &grid)
Definition: Stencils.h:308
ValueType mean() const
Return the mean value of the current stencil.
Definition: Stencils.h:158
GridT::TreeType TreeType
Definition: Stencils.h:674
GridType::ValueType ValueType
Definition: Stencils.h:1640