OpenVDB  2.1.0
Stencils.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2013 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 //
33 
34 #ifndef OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
35 #define OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
36 
37 #include <algorithm>
38 #include <vector>
39 #include <openvdb/math/Math.h> // for Pow2, needed by WENO and Gudonov
40 #include <openvdb/Types.h> // for Real
41 #include <openvdb/math/Coord.h> // for Coord
42 #include <openvdb/math/FiniteDifference.h> // for WENO5 and GudonovsNormSqrd
43 
44 namespace openvdb {
46 namespace OPENVDB_VERSION_NAME {
47 namespace math {
48 
49 
51 
52 
53 template<typename _GridType, typename StencilType>
55 {
56 public:
57  typedef _GridType GridType;
58  typedef typename GridType::TreeType TreeType;
59  typedef typename GridType::ValueType ValueType;
60  typedef std::vector<ValueType> BufferType;
61  typedef typename BufferType::iterator IterType;
62  typedef typename GridType::ConstAccessor AccessorType;
63 
67  inline void moveTo(const Coord& ijk)
68  {
69  mCenter = ijk;
70  mStencil[0] = mCache.getValue(ijk);
71  static_cast<StencilType&>(*this).init(mCenter);
72  }
73 
79  inline void moveTo(const Coord& ijk, const ValueType& centerValue)
80  {
81  mCenter = ijk;
82  mStencil[0] = centerValue;
83  static_cast<StencilType&>(*this).init(mCenter);
84  }
85 
91  template<typename IterType>
92  inline void moveTo(const IterType& iter)
93  {
94  mCenter = iter.getCoord();
95  mStencil[0] = *iter;
96  static_cast<StencilType&>(*this).init(mCenter);
97  }
98 
105  inline void moveTo(const Vec3R& xyz)
106  {
107  Coord ijk = openvdb::Coord::floor(xyz);
108  if (ijk != mCenter) this->moveTo(ijk);
109  }
110 
116  inline const ValueType& getValue(unsigned int pos = 0) const
117  {
118  assert(pos < mStencil.size());
119  return mStencil[pos];
120  }
121 
123  template<int i, int j, int k>
124  inline const ValueType& getValue() const
125  {
126  return mStencil[static_cast<const StencilType&>(*this).template pos<i,j,k>()];
127  }
128 
130  template<int i, int j, int k>
131  inline void setValue(const ValueType& value)
132  {
133  mStencil[static_cast<const StencilType&>(*this).template pos<i,j,k>()] = value;
134  }
135 
137  inline int size() { return mStencil.size(); }
138 
140  inline ValueType median() const
141  {
142  std::vector<ValueType> tmp(mStencil);//local copy
143  assert(!tmp.empty());
144  size_t midpoint = (tmp.size() - 1) >> 1;
145  // Partially sort the vector until the median value is at the midpoint.
146  std::nth_element(tmp.begin(), tmp.begin() + midpoint, tmp.end());
147  return tmp[midpoint];
148  }
149 
151  inline ValueType mean() const
152  {
153  ValueType sum = 0.0;
154  for (int n=0, s=mStencil.size(); n<s; ++n) sum += mStencil[n];
155  return sum / mStencil.size();
156  }
157 
159  inline ValueType min() const
160  {
161  IterType iter = std::min_element(mStencil.begin(), mStencil.end());
162  return *iter;
163  }
164 
166  inline ValueType max() const
167  {
168  IterType iter = std::max_element(mStencil.begin(), mStencil.end());
169  return *iter;
170  }
171 
173  inline const Coord& getCenterCoord() const { return mCenter; }
174 
176  inline const ValueType& getCenterValue() const { return mStencil[0]; }
177 
180  inline bool intersects(const ValueType &isoValue = zeroVal<ValueType>()) const
181  {
182  const bool less = this->getValue< 0, 0, 0>() < isoValue;
183  return (less ^ (this->getValue<-1, 0, 0>() < isoValue)) ||
184  (less ^ (this->getValue< 1, 0, 0>() < isoValue)) ||
185  (less ^ (this->getValue< 0,-1, 0>() < isoValue)) ||
186  (less ^ (this->getValue< 0, 1, 0>() < isoValue)) ||
187  (less ^ (this->getValue< 0, 0,-1>() < isoValue)) ||
188  (less ^ (this->getValue< 0, 0, 1>() < isoValue)) ;
189  }
190 
193  inline const GridType& grid() const { return *mGrid; }
194 
197  inline const AccessorType& accessor() const { return mCache; }
198 
199 protected:
200  // Constructor is protected to prevent direct instantiation.
201  BaseStencil(const GridType& grid, int size):
202  mGrid(&grid), mCache(grid.getConstAccessor()),
203  mStencil(size), mCenter(Coord::max())
204  {
205  }
206 
207  const GridType* mGrid;
211 
212 }; // class BaseStencil
213 
214 
216 
217 
218 namespace { // anonymous namespace for stencil-layout map
219 
220  // the seven point stencil
221  template<int i, int j, int k> struct SevenPt {};
222  template<> struct SevenPt< 0, 0, 0> { enum { idx = 0 }; };
223  template<> struct SevenPt< 1, 0, 0> { enum { idx = 1 }; };
224  template<> struct SevenPt< 0, 1, 0> { enum { idx = 2 }; };
225  template<> struct SevenPt< 0, 0, 1> { enum { idx = 3 }; };
226  template<> struct SevenPt<-1, 0, 0> { enum { idx = 4 }; };
227  template<> struct SevenPt< 0,-1, 0> { enum { idx = 5 }; };
228  template<> struct SevenPt< 0, 0,-1> { enum { idx = 6 }; };
229 
230 }
231 
232 
233 template<typename GridType>
234 class SevenPointStencil: public BaseStencil<GridType, SevenPointStencil<GridType> >
235 {
236 public:
239  typedef typename GridType::ValueType ValueType;
241  static const int SIZE = 7;
242 
243  SevenPointStencil(const GridType& grid): BaseType(grid, SIZE) {}
244 
246  template<int i, int j, int k>
247  unsigned int pos() const { return SevenPt<i,j,k>::idx; }
248 
249 private:
250  inline void init(const Coord& ijk)
251  {
252  BaseType::template setValue<-1, 0, 0>(mCache.getValue(ijk.offsetBy(-1, 0, 0)));
253  BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.offsetBy( 1, 0, 0)));
254 
255  BaseType::template setValue< 0,-1, 0>(mCache.getValue(ijk.offsetBy( 0,-1, 0)));
256  BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.offsetBy( 0, 1, 0)));
257 
258  BaseType::template setValue< 0, 0,-1>(mCache.getValue(ijk.offsetBy( 0, 0,-1)));
259  BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.offsetBy( 0, 0, 1)));
260  }
261 
262  template<typename, typename> friend class BaseStencil; // allow base class to call init()
263  using BaseType::mCache;
264  using BaseType::mStencil;
265 };
266 
267 
269 
270 
271 namespace { // anonymous namespace for stencil-layout map
272 
273  // the eight point box stencil
274  template<int i, int j, int k> struct BoxPt {};
275  template<> struct BoxPt< 0, 0, 0> { enum { idx = 0 }; };
276  template<> struct BoxPt< 0, 0, 1> { enum { idx = 1 }; };
277  template<> struct BoxPt< 0, 1, 1> { enum { idx = 2 }; };
278  template<> struct BoxPt< 0, 1, 0> { enum { idx = 3 }; };
279  template<> struct BoxPt< 1, 0, 0> { enum { idx = 4 }; };
280  template<> struct BoxPt< 1, 0, 1> { enum { idx = 5 }; };
281  template<> struct BoxPt< 1, 1, 1> { enum { idx = 6 }; };
282  template<> struct BoxPt< 1, 1, 0> { enum { idx = 7 }; };
283 }
284 
285 template<typename GridType>
286 class BoxStencil: public BaseStencil<GridType, BoxStencil<GridType> >
287 {
288 public:
291  typedef typename GridType::ValueType ValueType;
293  static const int SIZE = 8;
294 
295  BoxStencil(const GridType& grid): BaseType(grid, SIZE) {}
296 
298  template<int i, int j, int k>
299  unsigned int pos() const { return BoxPt<i,j,k>::idx; }
300 
303  inline bool intersects(const ValueType &isoValue = zeroVal<ValueType>()) const
304  {
305  const bool less = mStencil[0] < isoValue;
306  return (less ^ (mStencil[1] < isoValue)) ||
307  (less ^ (mStencil[2] < isoValue)) ||
308  (less ^ (mStencil[3] < isoValue)) ||
309  (less ^ (mStencil[4] < isoValue)) ||
310  (less ^ (mStencil[5] < isoValue)) ||
311  (less ^ (mStencil[6] < isoValue)) ||
312  (less ^ (mStencil[7] < isoValue)) ;
313  }
314 
322  inline ValueType interpolation(const Vec3Type& xyz) const
323  {
324  const Real u = xyz[0] - BaseType::mCenter[0]; assert(u>=0 && u<=1);
325  const Real v = xyz[1] - BaseType::mCenter[1]; assert(v>=0 && v<=1);
326  const Real w = xyz[2] - BaseType::mCenter[2]; assert(w>=0 && w<=1);
327 
328  ValueType V = BaseType::template getValue<0,0,0>();
329  ValueType A = V + (BaseType::template getValue<0,0,1>() - V) * w;
330  V = BaseType::template getValue< 0, 1, 0>();
331  ValueType B = V + (BaseType::template getValue<0,1,1>() - V) * w;
332  ValueType C = A + (B - A) * v;
333 
334  V = BaseType::template getValue<1,0,0>();
335  A = V + (BaseType::template getValue<1,0,1>() - V) * w;
336  V = BaseType::template getValue<1,1,0>();
337  B = V + (BaseType::template getValue<1,1,1>() - V) * w;
338  ValueType D = A + (B - A) * v;
339 
340  return C + (D - C) * u;
341  }
342 
350  inline Vec3Type gradient(const Vec3Type& xyz) const
351  {
352  const Real u = xyz[0] - BaseType::mCenter[0]; assert(u>=0 && u<=1);
353  const Real v = xyz[1] - BaseType::mCenter[1]; assert(v>=0 && v<=1);
354  const Real w = xyz[2] - BaseType::mCenter[2]; assert(w>=0 && w<=1);
355 
356  ValueType D[4]={BaseType::template getValue<0,0,1>()-BaseType::template getValue<0,0,0>(),
357  BaseType::template getValue<0,1,1>()-BaseType::template getValue<0,1,0>(),
358  BaseType::template getValue<1,0,1>()-BaseType::template getValue<1,0,0>(),
359  BaseType::template getValue<1,1,1>()-BaseType::template getValue<1,1,0>()};
360 
361  // Z component
362  ValueType A = D[0] + (D[1]- D[0]) * v;
363  ValueType B = D[2] + (D[3]- D[2]) * v;
364  Vec3Type grad(zeroVal<ValueType>(), zeroVal<ValueType>(), A + (B - A) * u);
365 
366  D[0] = BaseType::template getValue<0,0,0>() + D[0] * w;
367  D[1] = BaseType::template getValue<0,1,0>() + D[1] * w;
368  D[2] = BaseType::template getValue<1,0,0>() + D[2] * w;
369  D[3] = BaseType::template getValue<1,1,0>() + D[3] * w;
370 
371  // X component
372  A = D[0] + (D[1] - D[0]) * v;
373  B = D[2] + (D[3] - D[2]) * v;
374 
375  grad[0] = B - A;
376 
377  // Y component
378  A = D[1] - D[0];
379  B = D[3] - D[2];
380 
381  grad[1] = A + (B - A) * u;
382 
383  return BaseType::mGrid->transform().baseMap()->applyIJT(grad, xyz);
384  }
385 
386 private:
387  inline void init(const Coord& ijk)
388  {
389  BaseType::template setValue< 0, 0, 1>(mCache.getValue(ijk.offsetBy( 0, 0, 1)));
390  BaseType::template setValue< 0, 1, 1>(mCache.getValue(ijk.offsetBy( 0, 1, 1)));
391  BaseType::template setValue< 0, 1, 0>(mCache.getValue(ijk.offsetBy( 0, 1, 0)));
392  BaseType::template setValue< 1, 0, 0>(mCache.getValue(ijk.offsetBy( 1, 0, 0)));
393  BaseType::template setValue< 1, 0, 1>(mCache.getValue(ijk.offsetBy( 1, 0, 1)));
394  BaseType::template setValue< 1, 1, 1>(mCache.getValue(ijk.offsetBy( 1, 1, 1)));
395  BaseType::template setValue< 1, 1, 0>(mCache.getValue(ijk.offsetBy( 1, 1, 0)));
396  }
397 
398  template<typename, typename> friend class BaseStencil; // allow base class to call init()
399  using BaseType::mCache;
400  using BaseType::mStencil;
401 };
402 
403 
405 
406 
407 namespace { // anonymous namespace for stencil-layout map
408 
409  // the dense point stencil
410  template<int i, int j, int k> struct DensePt {};
411  template<> struct DensePt< 0, 0, 0> { enum { idx = 0 }; };
412 
413  template<> struct DensePt< 1, 0, 0> { enum { idx = 1 }; };
414  template<> struct DensePt< 0, 1, 0> { enum { idx = 2 }; };
415  template<> struct DensePt< 0, 0, 1> { enum { idx = 3 }; };
416 
417  template<> struct DensePt<-1, 0, 0> { enum { idx = 4 }; };
418  template<> struct DensePt< 0,-1, 0> { enum { idx = 5 }; };
419  template<> struct DensePt< 0, 0,-1> { enum { idx = 6 }; };
420 
421  template<> struct DensePt<-1,-1, 0> { enum { idx = 7 }; };
422  template<> struct DensePt< 0,-1,-1> { enum { idx = 8 }; };
423  template<> struct DensePt<-1, 0,-1> { enum { idx = 9 }; };
424 
425  template<> struct DensePt< 1,-1, 0> { enum { idx = 10 }; };
426  template<> struct DensePt< 0, 1,-1> { enum { idx = 11 }; };
427  template<> struct DensePt<-1, 0, 1> { enum { idx = 12 }; };
428 
429  template<> struct DensePt<-1, 1, 0> { enum { idx = 13 }; };
430  template<> struct DensePt< 0,-1, 1> { enum { idx = 14 }; };
431  template<> struct DensePt< 1, 0,-1> { enum { idx = 15 }; };
432 
433  template<> struct DensePt< 1, 1, 0> { enum { idx = 16 }; };
434  template<> struct DensePt< 0, 1, 1> { enum { idx = 17 }; };
435  template<> struct DensePt< 1, 0, 1> { enum { idx = 18 }; };
436 
437 }
438 
439 
440 template<typename GridType>
441 class SecondOrderDenseStencil: public BaseStencil<GridType, SecondOrderDenseStencil<GridType> >
442 {
443 public:
446  typedef typename GridType::ValueType ValueType;
448 
449  static const int SIZE = 19;
450 
451  SecondOrderDenseStencil(const GridType& grid): BaseType(grid, SIZE) {}
452 
454  template<int i, int j, int k>
455  unsigned int pos() const { return DensePt<i,j,k>::idx; }
456 
457 private:
458  inline void init(const Coord& ijk)
459  {
460  mStencil[DensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
461  mStencil[DensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
462  mStencil[DensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
463 
464  mStencil[DensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
465  mStencil[DensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, -1, 0));
466  mStencil[DensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, -1));
467 
468  mStencil[DensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, -1, 0));
469  mStencil[DensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, -1, 0));
470  mStencil[DensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 1, 0));
471  mStencil[DensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 1, 0));
472 
473  mStencil[DensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, -1));
474  mStencil[DensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, -1));
475  mStencil[DensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 1));
476  mStencil[DensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 1));
477 
478  mStencil[DensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, -1, -1));
479  mStencil[DensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, -1));
480  mStencil[DensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, -1, 1));
481  mStencil[DensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 1));
482  }
483 
484  template<typename, typename> friend class BaseStencil; // allow base class to call init()
485  using BaseType::mCache;
486  using BaseType::mStencil;
487 };
488 
489 
491 
492 
493 namespace { // anonymous namespace for stencil-layout map
494 
495  // the dense point stencil
496  template<int i, int j, int k> struct ThirteenPt {};
497  template<> struct ThirteenPt< 0, 0, 0> { enum { idx = 0 }; };
498 
499  template<> struct ThirteenPt< 1, 0, 0> { enum { idx = 1 }; };
500  template<> struct ThirteenPt< 0, 1, 0> { enum { idx = 2 }; };
501  template<> struct ThirteenPt< 0, 0, 1> { enum { idx = 3 }; };
502 
503  template<> struct ThirteenPt<-1, 0, 0> { enum { idx = 4 }; };
504  template<> struct ThirteenPt< 0,-1, 0> { enum { idx = 5 }; };
505  template<> struct ThirteenPt< 0, 0,-1> { enum { idx = 6 }; };
506 
507  template<> struct ThirteenPt< 2, 0, 0> { enum { idx = 7 }; };
508  template<> struct ThirteenPt< 0, 2, 0> { enum { idx = 8 }; };
509  template<> struct ThirteenPt< 0, 0, 2> { enum { idx = 9 }; };
510 
511  template<> struct ThirteenPt<-2, 0, 0> { enum { idx = 10 }; };
512  template<> struct ThirteenPt< 0,-2, 0> { enum { idx = 11 }; };
513  template<> struct ThirteenPt< 0, 0,-2> { enum { idx = 12 }; };
514 
515 }
516 
517 
518 template<typename GridType>
519 class ThirteenPointStencil: public BaseStencil<GridType, ThirteenPointStencil<GridType> >
520 {
521 public:
524  typedef typename GridType::ValueType ValueType;
526 
527  static const int SIZE = 13;
528 
529  ThirteenPointStencil(const GridType& grid): BaseType(grid, SIZE) {}
530 
532  template<int i, int j, int k>
533  unsigned int pos() const { return ThirteenPt<i,j,k>::idx; }
534 
535 private:
536  inline void init(const Coord& ijk)
537  {
538  mStencil[ThirteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 0));
539  mStencil[ThirteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
540  mStencil[ThirteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
541  mStencil[ThirteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 0));
542 
543  mStencil[ThirteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 0));
544  mStencil[ThirteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
545  mStencil[ThirteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, -1, 0));
546  mStencil[ThirteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, -2, 0));
547 
548  mStencil[ThirteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 2));
549  mStencil[ThirteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
550  mStencil[ThirteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, -1));
551  mStencil[ThirteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, -2));
552  }
553 
554  template<typename, typename> friend class BaseStencil; // allow base class to call init()
555  using BaseType::mCache;
556  using BaseType::mStencil;
557 };
558 
559 
561 
562 
563 namespace { // anonymous namespace for stencil-layout map
564 
565  // the 4th-order dense point stencil
566  template<int i, int j, int k> struct FourthDensePt {};
567  template<> struct FourthDensePt< 0, 0, 0> { enum { idx = 0 }; };
568 
569  template<> struct FourthDensePt<-2, 2, 0> { enum { idx = 1 }; };
570  template<> struct FourthDensePt<-1, 2, 0> { enum { idx = 2 }; };
571  template<> struct FourthDensePt< 0, 2, 0> { enum { idx = 3 }; };
572  template<> struct FourthDensePt< 1, 2, 0> { enum { idx = 4 }; };
573  template<> struct FourthDensePt< 2, 2, 0> { enum { idx = 5 }; };
574 
575  template<> struct FourthDensePt<-2, 1, 0> { enum { idx = 6 }; };
576  template<> struct FourthDensePt<-1, 1, 0> { enum { idx = 7 }; };
577  template<> struct FourthDensePt< 0, 1, 0> { enum { idx = 8 }; };
578  template<> struct FourthDensePt< 1, 1, 0> { enum { idx = 9 }; };
579  template<> struct FourthDensePt< 2, 1, 0> { enum { idx = 10 }; };
580 
581  template<> struct FourthDensePt<-2, 0, 0> { enum { idx = 11 }; };
582  template<> struct FourthDensePt<-1, 0, 0> { enum { idx = 12 }; };
583  template<> struct FourthDensePt< 1, 0, 0> { enum { idx = 13 }; };
584  template<> struct FourthDensePt< 2, 0, 0> { enum { idx = 14 }; };
585 
586  template<> struct FourthDensePt<-2,-1, 0> { enum { idx = 15 }; };
587  template<> struct FourthDensePt<-1,-1, 0> { enum { idx = 16 }; };
588  template<> struct FourthDensePt< 0,-1, 0> { enum { idx = 17 }; };
589  template<> struct FourthDensePt< 1,-1, 0> { enum { idx = 18 }; };
590  template<> struct FourthDensePt< 2,-1, 0> { enum { idx = 19 }; };
591 
592  template<> struct FourthDensePt<-2,-2, 0> { enum { idx = 20 }; };
593  template<> struct FourthDensePt<-1,-2, 0> { enum { idx = 21 }; };
594  template<> struct FourthDensePt< 0,-2, 0> { enum { idx = 22 }; };
595  template<> struct FourthDensePt< 1,-2, 0> { enum { idx = 23 }; };
596  template<> struct FourthDensePt< 2,-2, 0> { enum { idx = 24 }; };
597 
598 
599  template<> struct FourthDensePt<-2, 0, 2> { enum { idx = 25 }; };
600  template<> struct FourthDensePt<-1, 0, 2> { enum { idx = 26 }; };
601  template<> struct FourthDensePt< 0, 0, 2> { enum { idx = 27 }; };
602  template<> struct FourthDensePt< 1, 0, 2> { enum { idx = 28 }; };
603  template<> struct FourthDensePt< 2, 0, 2> { enum { idx = 29 }; };
604 
605  template<> struct FourthDensePt<-2, 0, 1> { enum { idx = 30 }; };
606  template<> struct FourthDensePt<-1, 0, 1> { enum { idx = 31 }; };
607  template<> struct FourthDensePt< 0, 0, 1> { enum { idx = 32 }; };
608  template<> struct FourthDensePt< 1, 0, 1> { enum { idx = 33 }; };
609  template<> struct FourthDensePt< 2, 0, 1> { enum { idx = 34 }; };
610 
611  template<> struct FourthDensePt<-2, 0,-1> { enum { idx = 35 }; };
612  template<> struct FourthDensePt<-1, 0,-1> { enum { idx = 36 }; };
613  template<> struct FourthDensePt< 0, 0,-1> { enum { idx = 37 }; };
614  template<> struct FourthDensePt< 1, 0,-1> { enum { idx = 38 }; };
615  template<> struct FourthDensePt< 2, 0,-1> { enum { idx = 39 }; };
616 
617  template<> struct FourthDensePt<-2, 0,-2> { enum { idx = 40 }; };
618  template<> struct FourthDensePt<-1, 0,-2> { enum { idx = 41 }; };
619  template<> struct FourthDensePt< 0, 0,-2> { enum { idx = 42 }; };
620  template<> struct FourthDensePt< 1, 0,-2> { enum { idx = 43 }; };
621  template<> struct FourthDensePt< 2, 0,-2> { enum { idx = 44 }; };
622 
623 
624  template<> struct FourthDensePt< 0,-2, 2> { enum { idx = 45 }; };
625  template<> struct FourthDensePt< 0,-1, 2> { enum { idx = 46 }; };
626  template<> struct FourthDensePt< 0, 1, 2> { enum { idx = 47 }; };
627  template<> struct FourthDensePt< 0, 2, 2> { enum { idx = 48 }; };
628 
629  template<> struct FourthDensePt< 0,-2, 1> { enum { idx = 49 }; };
630  template<> struct FourthDensePt< 0,-1, 1> { enum { idx = 50 }; };
631  template<> struct FourthDensePt< 0, 1, 1> { enum { idx = 51 }; };
632  template<> struct FourthDensePt< 0, 2, 1> { enum { idx = 52 }; };
633 
634  template<> struct FourthDensePt< 0,-2,-1> { enum { idx = 53 }; };
635  template<> struct FourthDensePt< 0,-1,-1> { enum { idx = 54 }; };
636  template<> struct FourthDensePt< 0, 1,-1> { enum { idx = 55 }; };
637  template<> struct FourthDensePt< 0, 2,-1> { enum { idx = 56 }; };
638 
639  template<> struct FourthDensePt< 0,-2,-2> { enum { idx = 57 }; };
640  template<> struct FourthDensePt< 0,-1,-2> { enum { idx = 58 }; };
641  template<> struct FourthDensePt< 0, 1,-2> { enum { idx = 59 }; };
642  template<> struct FourthDensePt< 0, 2,-2> { enum { idx = 60 }; };
643 
644 }
645 
646 
647 template<typename GridType>
648 class FourthOrderDenseStencil: public BaseStencil<GridType, FourthOrderDenseStencil<GridType> >
649 {
650 public:
653  typedef typename GridType::ValueType ValueType;
655 
656  static const int SIZE = 61;
657 
658  FourthOrderDenseStencil(const GridType& grid): BaseType(grid, SIZE) {}
659 
661  template<int i, int j, int k>
662  unsigned int pos() const { return FourthDensePt<i,j,k>::idx; }
663 
664 private:
665  inline void init(const Coord& ijk)
666  {
667  mStencil[FourthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 2, 0));
668  mStencil[FourthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 2, 0));
669  mStencil[FourthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 0));
670  mStencil[FourthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 2, 0));
671  mStencil[FourthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 2, 0));
672 
673  mStencil[FourthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 1, 0));
674  mStencil[FourthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 1, 0));
675  mStencil[FourthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
676  mStencil[FourthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 1, 0));
677  mStencil[FourthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 1, 0));
678 
679  mStencil[FourthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 0));
680  mStencil[FourthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
681  mStencil[FourthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
682  mStencil[FourthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 0));
683 
684  mStencil[FourthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.offsetBy(-2,-1, 0));
685  mStencil[FourthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.offsetBy(-1,-1, 0));
686  mStencil[FourthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 0));
687  mStencil[FourthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 1,-1, 0));
688  mStencil[FourthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 2,-1, 0));
689 
690  mStencil[FourthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.offsetBy(-2,-2, 0));
691  mStencil[FourthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.offsetBy(-1,-2, 0));
692  mStencil[FourthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 0));
693  mStencil[FourthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 1,-2, 0));
694  mStencil[FourthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 2,-2, 0));
695 
696  mStencil[FourthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 2));
697  mStencil[FourthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 2));
698  mStencil[FourthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 2));
699  mStencil[FourthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 2));
700  mStencil[FourthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 2));
701 
702  mStencil[FourthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 1));
703  mStencil[FourthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 1));
704  mStencil[FourthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
705  mStencil[FourthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 1));
706  mStencil[FourthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 1));
707 
708  mStencil[FourthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.offsetBy(-2, 0,-1));
709  mStencil[FourthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.offsetBy(-1, 0,-1));
710  mStencil[FourthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0,-1));
711  mStencil[FourthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 1, 0,-1));
712  mStencil[FourthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 2, 0,-1));
713 
714  mStencil[FourthDensePt<-2, 0,-2>::idx] = mCache.getValue(ijk.offsetBy(-2, 0,-2));
715  mStencil[FourthDensePt<-1, 0,-2>::idx] = mCache.getValue(ijk.offsetBy(-1, 0,-2));
716  mStencil[FourthDensePt< 0, 0,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0,-2));
717  mStencil[FourthDensePt< 1, 0,-2>::idx] = mCache.getValue(ijk.offsetBy( 1, 0,-2));
718  mStencil[FourthDensePt< 2, 0,-2>::idx] = mCache.getValue(ijk.offsetBy( 2, 0,-2));
719 
720 
721  mStencil[FourthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 2));
722  mStencil[FourthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 2));
723  mStencil[FourthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 2));
724  mStencil[FourthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 2));
725 
726  mStencil[FourthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 1));
727  mStencil[FourthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 1));
728  mStencil[FourthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 1));
729  mStencil[FourthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 1));
730 
731  mStencil[FourthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.offsetBy( 0,-2,-1));
732  mStencil[FourthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.offsetBy( 0,-1,-1));
733  mStencil[FourthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 1,-1));
734  mStencil[FourthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 2,-1));
735 
736  mStencil[FourthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.offsetBy( 0,-2,-2));
737  mStencil[FourthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.offsetBy( 0,-1,-2));
738  mStencil[FourthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 1,-2));
739  mStencil[FourthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 2,-2));
740  }
741 
742  template<typename, typename> friend class BaseStencil; // allow base class to call init()
743  using BaseType::mCache;
744  using BaseType::mStencil;
745 };
746 
747 
749 
750 
751 namespace { // anonymous namespace for stencil-layout map
752 
753  // the dense point stencil
754  template<int i, int j, int k> struct NineteenPt {};
755  template<> struct NineteenPt< 0, 0, 0> { enum { idx = 0 }; };
756 
757  template<> struct NineteenPt< 1, 0, 0> { enum { idx = 1 }; };
758  template<> struct NineteenPt< 0, 1, 0> { enum { idx = 2 }; };
759  template<> struct NineteenPt< 0, 0, 1> { enum { idx = 3 }; };
760 
761  template<> struct NineteenPt<-1, 0, 0> { enum { idx = 4 }; };
762  template<> struct NineteenPt< 0,-1, 0> { enum { idx = 5 }; };
763  template<> struct NineteenPt< 0, 0,-1> { enum { idx = 6 }; };
764 
765  template<> struct NineteenPt< 2, 0, 0> { enum { idx = 7 }; };
766  template<> struct NineteenPt< 0, 2, 0> { enum { idx = 8 }; };
767  template<> struct NineteenPt< 0, 0, 2> { enum { idx = 9 }; };
768 
769  template<> struct NineteenPt<-2, 0, 0> { enum { idx = 10 }; };
770  template<> struct NineteenPt< 0,-2, 0> { enum { idx = 11 }; };
771  template<> struct NineteenPt< 0, 0,-2> { enum { idx = 12 }; };
772 
773  template<> struct NineteenPt< 3, 0, 0> { enum { idx = 13 }; };
774  template<> struct NineteenPt< 0, 3, 0> { enum { idx = 14 }; };
775  template<> struct NineteenPt< 0, 0, 3> { enum { idx = 15 }; };
776 
777  template<> struct NineteenPt<-3, 0, 0> { enum { idx = 16 }; };
778  template<> struct NineteenPt< 0,-3, 0> { enum { idx = 17 }; };
779  template<> struct NineteenPt< 0, 0,-3> { enum { idx = 18 }; };
780 
781 }
782 
783 
784 template<typename GridType>
785 class NineteenPointStencil: public BaseStencil<GridType, NineteenPointStencil<GridType> >
786 {
787 public:
790  typedef typename GridType::ValueType ValueType;
792 
793  static const int SIZE = 19;
794 
795  NineteenPointStencil(const GridType& grid): BaseType(grid, SIZE) {}
796 
798  template<int i, int j, int k>
799  unsigned int pos() const { return NineteenPt<i,j,k>::idx; }
800 
801 private:
802  inline void init(const Coord& ijk)
803  {
804  mStencil[NineteenPt< 3, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 3, 0, 0));
805  mStencil[NineteenPt< 2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 0));
806  mStencil[NineteenPt< 1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
807  mStencil[NineteenPt<-1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
808  mStencil[NineteenPt<-2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 0));
809  mStencil[NineteenPt<-3, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-3, 0, 0));
810 
811  mStencil[NineteenPt< 0, 3, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 3, 0));
812  mStencil[NineteenPt< 0, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 0));
813  mStencil[NineteenPt< 0, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
814  mStencil[NineteenPt< 0,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, -1, 0));
815  mStencil[NineteenPt< 0,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, -2, 0));
816  mStencil[NineteenPt< 0,-3, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, -3, 0));
817 
818  mStencil[NineteenPt< 0, 0, 3>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 3));
819  mStencil[NineteenPt< 0, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 2));
820  mStencil[NineteenPt< 0, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
821  mStencil[NineteenPt< 0, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, -1));
822  mStencil[NineteenPt< 0, 0,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, -2));
823  mStencil[NineteenPt< 0, 0,-3>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, -3));
824  }
825 
826  template<typename, typename> friend class BaseStencil; // allow base class to call init()
827  using BaseType::mCache;
828  using BaseType::mStencil;
829 };
830 
831 
833 
834 
835 namespace { // anonymous namespace for stencil-layout map
836 
837  // the 4th-order dense point stencil
838  template<int i, int j, int k> struct SixthDensePt { };
839  template<> struct SixthDensePt< 0, 0, 0> { enum { idx = 0 }; };
840 
841  template<> struct SixthDensePt<-3, 3, 0> { enum { idx = 1 }; };
842  template<> struct SixthDensePt<-2, 3, 0> { enum { idx = 2 }; };
843  template<> struct SixthDensePt<-1, 3, 0> { enum { idx = 3 }; };
844  template<> struct SixthDensePt< 0, 3, 0> { enum { idx = 4 }; };
845  template<> struct SixthDensePt< 1, 3, 0> { enum { idx = 5 }; };
846  template<> struct SixthDensePt< 2, 3, 0> { enum { idx = 6 }; };
847  template<> struct SixthDensePt< 3, 3, 0> { enum { idx = 7 }; };
848 
849  template<> struct SixthDensePt<-3, 2, 0> { enum { idx = 8 }; };
850  template<> struct SixthDensePt<-2, 2, 0> { enum { idx = 9 }; };
851  template<> struct SixthDensePt<-1, 2, 0> { enum { idx = 10 }; };
852  template<> struct SixthDensePt< 0, 2, 0> { enum { idx = 11 }; };
853  template<> struct SixthDensePt< 1, 2, 0> { enum { idx = 12 }; };
854  template<> struct SixthDensePt< 2, 2, 0> { enum { idx = 13 }; };
855  template<> struct SixthDensePt< 3, 2, 0> { enum { idx = 14 }; };
856 
857  template<> struct SixthDensePt<-3, 1, 0> { enum { idx = 15 }; };
858  template<> struct SixthDensePt<-2, 1, 0> { enum { idx = 16 }; };
859  template<> struct SixthDensePt<-1, 1, 0> { enum { idx = 17 }; };
860  template<> struct SixthDensePt< 0, 1, 0> { enum { idx = 18 }; };
861  template<> struct SixthDensePt< 1, 1, 0> { enum { idx = 19 }; };
862  template<> struct SixthDensePt< 2, 1, 0> { enum { idx = 20 }; };
863  template<> struct SixthDensePt< 3, 1, 0> { enum { idx = 21 }; };
864 
865  template<> struct SixthDensePt<-3, 0, 0> { enum { idx = 22 }; };
866  template<> struct SixthDensePt<-2, 0, 0> { enum { idx = 23 }; };
867  template<> struct SixthDensePt<-1, 0, 0> { enum { idx = 24 }; };
868  template<> struct SixthDensePt< 1, 0, 0> { enum { idx = 25 }; };
869  template<> struct SixthDensePt< 2, 0, 0> { enum { idx = 26 }; };
870  template<> struct SixthDensePt< 3, 0, 0> { enum { idx = 27 }; };
871 
872 
873  template<> struct SixthDensePt<-3,-1, 0> { enum { idx = 28 }; };
874  template<> struct SixthDensePt<-2,-1, 0> { enum { idx = 29 }; };
875  template<> struct SixthDensePt<-1,-1, 0> { enum { idx = 30 }; };
876  template<> struct SixthDensePt< 0,-1, 0> { enum { idx = 31 }; };
877  template<> struct SixthDensePt< 1,-1, 0> { enum { idx = 32 }; };
878  template<> struct SixthDensePt< 2,-1, 0> { enum { idx = 33 }; };
879  template<> struct SixthDensePt< 3,-1, 0> { enum { idx = 34 }; };
880 
881 
882  template<> struct SixthDensePt<-3,-2, 0> { enum { idx = 35 }; };
883  template<> struct SixthDensePt<-2,-2, 0> { enum { idx = 36 }; };
884  template<> struct SixthDensePt<-1,-2, 0> { enum { idx = 37 }; };
885  template<> struct SixthDensePt< 0,-2, 0> { enum { idx = 38 }; };
886  template<> struct SixthDensePt< 1,-2, 0> { enum { idx = 39 }; };
887  template<> struct SixthDensePt< 2,-2, 0> { enum { idx = 40 }; };
888  template<> struct SixthDensePt< 3,-2, 0> { enum { idx = 41 }; };
889 
890 
891  template<> struct SixthDensePt<-3,-3, 0> { enum { idx = 42 }; };
892  template<> struct SixthDensePt<-2,-3, 0> { enum { idx = 43 }; };
893  template<> struct SixthDensePt<-1,-3, 0> { enum { idx = 44 }; };
894  template<> struct SixthDensePt< 0,-3, 0> { enum { idx = 45 }; };
895  template<> struct SixthDensePt< 1,-3, 0> { enum { idx = 46 }; };
896  template<> struct SixthDensePt< 2,-3, 0> { enum { idx = 47 }; };
897  template<> struct SixthDensePt< 3,-3, 0> { enum { idx = 48 }; };
898 
899 
900  template<> struct SixthDensePt<-3, 0, 3> { enum { idx = 49 }; };
901  template<> struct SixthDensePt<-2, 0, 3> { enum { idx = 50 }; };
902  template<> struct SixthDensePt<-1, 0, 3> { enum { idx = 51 }; };
903  template<> struct SixthDensePt< 0, 0, 3> { enum { idx = 52 }; };
904  template<> struct SixthDensePt< 1, 0, 3> { enum { idx = 53 }; };
905  template<> struct SixthDensePt< 2, 0, 3> { enum { idx = 54 }; };
906  template<> struct SixthDensePt< 3, 0, 3> { enum { idx = 55 }; };
907 
908 
909  template<> struct SixthDensePt<-3, 0, 2> { enum { idx = 56 }; };
910  template<> struct SixthDensePt<-2, 0, 2> { enum { idx = 57 }; };
911  template<> struct SixthDensePt<-1, 0, 2> { enum { idx = 58 }; };
912  template<> struct SixthDensePt< 0, 0, 2> { enum { idx = 59 }; };
913  template<> struct SixthDensePt< 1, 0, 2> { enum { idx = 60 }; };
914  template<> struct SixthDensePt< 2, 0, 2> { enum { idx = 61 }; };
915  template<> struct SixthDensePt< 3, 0, 2> { enum { idx = 62 }; };
916 
917  template<> struct SixthDensePt<-3, 0, 1> { enum { idx = 63 }; };
918  template<> struct SixthDensePt<-2, 0, 1> { enum { idx = 64 }; };
919  template<> struct SixthDensePt<-1, 0, 1> { enum { idx = 65 }; };
920  template<> struct SixthDensePt< 0, 0, 1> { enum { idx = 66 }; };
921  template<> struct SixthDensePt< 1, 0, 1> { enum { idx = 67 }; };
922  template<> struct SixthDensePt< 2, 0, 1> { enum { idx = 68 }; };
923  template<> struct SixthDensePt< 3, 0, 1> { enum { idx = 69 }; };
924 
925 
926  template<> struct SixthDensePt<-3, 0,-1> { enum { idx = 70 }; };
927  template<> struct SixthDensePt<-2, 0,-1> { enum { idx = 71 }; };
928  template<> struct SixthDensePt<-1, 0,-1> { enum { idx = 72 }; };
929  template<> struct SixthDensePt< 0, 0,-1> { enum { idx = 73 }; };
930  template<> struct SixthDensePt< 1, 0,-1> { enum { idx = 74 }; };
931  template<> struct SixthDensePt< 2, 0,-1> { enum { idx = 75 }; };
932  template<> struct SixthDensePt< 3, 0,-1> { enum { idx = 76 }; };
933 
934 
935  template<> struct SixthDensePt<-3, 0,-2> { enum { idx = 77 }; };
936  template<> struct SixthDensePt<-2, 0,-2> { enum { idx = 78 }; };
937  template<> struct SixthDensePt<-1, 0,-2> { enum { idx = 79 }; };
938  template<> struct SixthDensePt< 0, 0,-2> { enum { idx = 80 }; };
939  template<> struct SixthDensePt< 1, 0,-2> { enum { idx = 81 }; };
940  template<> struct SixthDensePt< 2, 0,-2> { enum { idx = 82 }; };
941  template<> struct SixthDensePt< 3, 0,-2> { enum { idx = 83 }; };
942 
943 
944  template<> struct SixthDensePt<-3, 0,-3> { enum { idx = 84 }; };
945  template<> struct SixthDensePt<-2, 0,-3> { enum { idx = 85 }; };
946  template<> struct SixthDensePt<-1, 0,-3> { enum { idx = 86 }; };
947  template<> struct SixthDensePt< 0, 0,-3> { enum { idx = 87 }; };
948  template<> struct SixthDensePt< 1, 0,-3> { enum { idx = 88 }; };
949  template<> struct SixthDensePt< 2, 0,-3> { enum { idx = 89 }; };
950  template<> struct SixthDensePt< 3, 0,-3> { enum { idx = 90 }; };
951 
952 
953  template<> struct SixthDensePt< 0,-3, 3> { enum { idx = 91 }; };
954  template<> struct SixthDensePt< 0,-2, 3> { enum { idx = 92 }; };
955  template<> struct SixthDensePt< 0,-1, 3> { enum { idx = 93 }; };
956  template<> struct SixthDensePt< 0, 1, 3> { enum { idx = 94 }; };
957  template<> struct SixthDensePt< 0, 2, 3> { enum { idx = 95 }; };
958  template<> struct SixthDensePt< 0, 3, 3> { enum { idx = 96 }; };
959 
960  template<> struct SixthDensePt< 0,-3, 2> { enum { idx = 97 }; };
961  template<> struct SixthDensePt< 0,-2, 2> { enum { idx = 98 }; };
962  template<> struct SixthDensePt< 0,-1, 2> { enum { idx = 99 }; };
963  template<> struct SixthDensePt< 0, 1, 2> { enum { idx = 100 }; };
964  template<> struct SixthDensePt< 0, 2, 2> { enum { idx = 101 }; };
965  template<> struct SixthDensePt< 0, 3, 2> { enum { idx = 102 }; };
966 
967  template<> struct SixthDensePt< 0,-3, 1> { enum { idx = 103 }; };
968  template<> struct SixthDensePt< 0,-2, 1> { enum { idx = 104 }; };
969  template<> struct SixthDensePt< 0,-1, 1> { enum { idx = 105 }; };
970  template<> struct SixthDensePt< 0, 1, 1> { enum { idx = 106 }; };
971  template<> struct SixthDensePt< 0, 2, 1> { enum { idx = 107 }; };
972  template<> struct SixthDensePt< 0, 3, 1> { enum { idx = 108 }; };
973 
974  template<> struct SixthDensePt< 0,-3,-1> { enum { idx = 109 }; };
975  template<> struct SixthDensePt< 0,-2,-1> { enum { idx = 110 }; };
976  template<> struct SixthDensePt< 0,-1,-1> { enum { idx = 111 }; };
977  template<> struct SixthDensePt< 0, 1,-1> { enum { idx = 112 }; };
978  template<> struct SixthDensePt< 0, 2,-1> { enum { idx = 113 }; };
979  template<> struct SixthDensePt< 0, 3,-1> { enum { idx = 114 }; };
980 
981  template<> struct SixthDensePt< 0,-3,-2> { enum { idx = 115 }; };
982  template<> struct SixthDensePt< 0,-2,-2> { enum { idx = 116 }; };
983  template<> struct SixthDensePt< 0,-1,-2> { enum { idx = 117 }; };
984  template<> struct SixthDensePt< 0, 1,-2> { enum { idx = 118 }; };
985  template<> struct SixthDensePt< 0, 2,-2> { enum { idx = 119 }; };
986  template<> struct SixthDensePt< 0, 3,-2> { enum { idx = 120 }; };
987 
988  template<> struct SixthDensePt< 0,-3,-3> { enum { idx = 121 }; };
989  template<> struct SixthDensePt< 0,-2,-3> { enum { idx = 122 }; };
990  template<> struct SixthDensePt< 0,-1,-3> { enum { idx = 123 }; };
991  template<> struct SixthDensePt< 0, 1,-3> { enum { idx = 124 }; };
992  template<> struct SixthDensePt< 0, 2,-3> { enum { idx = 125 }; };
993  template<> struct SixthDensePt< 0, 3,-3> { enum { idx = 126 }; };
994 
995 }
996 
997 
998 template<typename GridType>
999 class SixthOrderDenseStencil: public BaseStencil<GridType, SixthOrderDenseStencil<GridType> >
1000 {
1001 public:
1004  typedef typename GridType::ValueType ValueType;
1006 
1007  static const int SIZE = 127;
1008 
1009  SixthOrderDenseStencil(const GridType& grid): BaseType(grid, SIZE) {}
1010 
1012  template<int i, int j, int k>
1013  unsigned int pos() const { return SixthDensePt<i,j,k>::idx; }
1014 
1015 private:
1016  inline void init(const Coord& ijk)
1017  {
1018  mStencil[SixthDensePt<-3, 3, 0>::idx] = mCache.getValue(ijk.offsetBy(-3, 3, 0));
1019  mStencil[SixthDensePt<-2, 3, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 3, 0));
1020  mStencil[SixthDensePt<-1, 3, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 3, 0));
1021  mStencil[SixthDensePt< 0, 3, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 3, 0));
1022  mStencil[SixthDensePt< 1, 3, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 3, 0));
1023  mStencil[SixthDensePt< 2, 3, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 3, 0));
1024  mStencil[SixthDensePt< 3, 3, 0>::idx] = mCache.getValue(ijk.offsetBy( 3, 3, 0));
1025 
1026  mStencil[SixthDensePt<-3, 2, 0>::idx] = mCache.getValue(ijk.offsetBy(-3, 2, 0));
1027  mStencil[SixthDensePt<-2, 2, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 2, 0));
1028  mStencil[SixthDensePt<-1, 2, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 2, 0));
1029  mStencil[SixthDensePt< 0, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 0));
1030  mStencil[SixthDensePt< 1, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 2, 0));
1031  mStencil[SixthDensePt< 2, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 2, 0));
1032  mStencil[SixthDensePt< 3, 2, 0>::idx] = mCache.getValue(ijk.offsetBy( 3, 2, 0));
1033 
1034  mStencil[SixthDensePt<-3, 1, 0>::idx] = mCache.getValue(ijk.offsetBy(-3, 1, 0));
1035  mStencil[SixthDensePt<-2, 1, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 1, 0));
1036  mStencil[SixthDensePt<-1, 1, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 1, 0));
1037  mStencil[SixthDensePt< 0, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
1038  mStencil[SixthDensePt< 1, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 1, 0));
1039  mStencil[SixthDensePt< 2, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 1, 0));
1040  mStencil[SixthDensePt< 3, 1, 0>::idx] = mCache.getValue(ijk.offsetBy( 3, 1, 0));
1041 
1042  mStencil[SixthDensePt<-3, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-3, 0, 0));
1043  mStencil[SixthDensePt<-2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 0));
1044  mStencil[SixthDensePt<-1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
1045  mStencil[SixthDensePt< 1, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
1046  mStencil[SixthDensePt< 2, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 0));
1047  mStencil[SixthDensePt< 3, 0, 0>::idx] = mCache.getValue(ijk.offsetBy( 3, 0, 0));
1048 
1049  mStencil[SixthDensePt<-3,-1, 0>::idx] = mCache.getValue(ijk.offsetBy(-3,-1, 0));
1050  mStencil[SixthDensePt<-2,-1, 0>::idx] = mCache.getValue(ijk.offsetBy(-2,-1, 0));
1051  mStencil[SixthDensePt<-1,-1, 0>::idx] = mCache.getValue(ijk.offsetBy(-1,-1, 0));
1052  mStencil[SixthDensePt< 0,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 0));
1053  mStencil[SixthDensePt< 1,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 1,-1, 0));
1054  mStencil[SixthDensePt< 2,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 2,-1, 0));
1055  mStencil[SixthDensePt< 3,-1, 0>::idx] = mCache.getValue(ijk.offsetBy( 3,-1, 0));
1056 
1057  mStencil[SixthDensePt<-3,-2, 0>::idx] = mCache.getValue(ijk.offsetBy(-3,-2, 0));
1058  mStencil[SixthDensePt<-2,-2, 0>::idx] = mCache.getValue(ijk.offsetBy(-2,-2, 0));
1059  mStencil[SixthDensePt<-1,-2, 0>::idx] = mCache.getValue(ijk.offsetBy(-1,-2, 0));
1060  mStencil[SixthDensePt< 0,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 0));
1061  mStencil[SixthDensePt< 1,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 1,-2, 0));
1062  mStencil[SixthDensePt< 2,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 2,-2, 0));
1063  mStencil[SixthDensePt< 3,-2, 0>::idx] = mCache.getValue(ijk.offsetBy( 3,-2, 0));
1064 
1065  mStencil[SixthDensePt<-3,-3, 0>::idx] = mCache.getValue(ijk.offsetBy(-3,-3, 0));
1066  mStencil[SixthDensePt<-2,-3, 0>::idx] = mCache.getValue(ijk.offsetBy(-2,-3, 0));
1067  mStencil[SixthDensePt<-1,-3, 0>::idx] = mCache.getValue(ijk.offsetBy(-1,-3, 0));
1068  mStencil[SixthDensePt< 0,-3, 0>::idx] = mCache.getValue(ijk.offsetBy( 0,-3, 0));
1069  mStencil[SixthDensePt< 1,-3, 0>::idx] = mCache.getValue(ijk.offsetBy( 1,-3, 0));
1070  mStencil[SixthDensePt< 2,-3, 0>::idx] = mCache.getValue(ijk.offsetBy( 2,-3, 0));
1071  mStencil[SixthDensePt< 3,-3, 0>::idx] = mCache.getValue(ijk.offsetBy( 3,-3, 0));
1072 
1073  mStencil[SixthDensePt<-3, 0, 3>::idx] = mCache.getValue(ijk.offsetBy(-3, 0, 3));
1074  mStencil[SixthDensePt<-2, 0, 3>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 3));
1075  mStencil[SixthDensePt<-1, 0, 3>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 3));
1076  mStencil[SixthDensePt< 0, 0, 3>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 3));
1077  mStencil[SixthDensePt< 1, 0, 3>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 3));
1078  mStencil[SixthDensePt< 2, 0, 3>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 3));
1079  mStencil[SixthDensePt< 3, 0, 3>::idx] = mCache.getValue(ijk.offsetBy( 3, 0, 3));
1080 
1081  mStencil[SixthDensePt<-3, 0, 2>::idx] = mCache.getValue(ijk.offsetBy(-3, 0, 2));
1082  mStencil[SixthDensePt<-2, 0, 2>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 2));
1083  mStencil[SixthDensePt<-1, 0, 2>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 2));
1084  mStencil[SixthDensePt< 0, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 2));
1085  mStencil[SixthDensePt< 1, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 2));
1086  mStencil[SixthDensePt< 2, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 2));
1087  mStencil[SixthDensePt< 3, 0, 2>::idx] = mCache.getValue(ijk.offsetBy( 3, 0, 2));
1088 
1089  mStencil[SixthDensePt<-3, 0, 1>::idx] = mCache.getValue(ijk.offsetBy(-3, 0, 1));
1090  mStencil[SixthDensePt<-2, 0, 1>::idx] = mCache.getValue(ijk.offsetBy(-2, 0, 1));
1091  mStencil[SixthDensePt<-1, 0, 1>::idx] = mCache.getValue(ijk.offsetBy(-1, 0, 1));
1092  mStencil[SixthDensePt< 0, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
1093  mStencil[SixthDensePt< 1, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 1, 0, 1));
1094  mStencil[SixthDensePt< 2, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 2, 0, 1));
1095  mStencil[SixthDensePt< 3, 0, 1>::idx] = mCache.getValue(ijk.offsetBy( 3, 0, 1));
1096 
1097  mStencil[SixthDensePt<-3, 0,-1>::idx] = mCache.getValue(ijk.offsetBy(-3, 0,-1));
1098  mStencil[SixthDensePt<-2, 0,-1>::idx] = mCache.getValue(ijk.offsetBy(-2, 0,-1));
1099  mStencil[SixthDensePt<-1, 0,-1>::idx] = mCache.getValue(ijk.offsetBy(-1, 0,-1));
1100  mStencil[SixthDensePt< 0, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 0,-1));
1101  mStencil[SixthDensePt< 1, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 1, 0,-1));
1102  mStencil[SixthDensePt< 2, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 2, 0,-1));
1103  mStencil[SixthDensePt< 3, 0,-1>::idx] = mCache.getValue(ijk.offsetBy( 3, 0,-1));
1104 
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));
1112 
1113  mStencil[SixthDensePt<-3, 0,-3>::idx] = mCache.getValue(ijk.offsetBy(-3, 0,-3));
1114  mStencil[SixthDensePt<-2, 0,-3>::idx] = mCache.getValue(ijk.offsetBy(-2, 0,-3));
1115  mStencil[SixthDensePt<-1, 0,-3>::idx] = mCache.getValue(ijk.offsetBy(-1, 0,-3));
1116  mStencil[SixthDensePt< 0, 0,-3>::idx] = mCache.getValue(ijk.offsetBy( 0, 0,-3));
1117  mStencil[SixthDensePt< 1, 0,-3>::idx] = mCache.getValue(ijk.offsetBy( 1, 0,-3));
1118  mStencil[SixthDensePt< 2, 0,-3>::idx] = mCache.getValue(ijk.offsetBy( 2, 0,-3));
1119  mStencil[SixthDensePt< 3, 0,-3>::idx] = mCache.getValue(ijk.offsetBy( 3, 0,-3));
1120 
1121  mStencil[SixthDensePt< 0,-3, 3>::idx] = mCache.getValue(ijk.offsetBy( 0,-3, 3));
1122  mStencil[SixthDensePt< 0,-2, 3>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 3));
1123  mStencil[SixthDensePt< 0,-1, 3>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 3));
1124  mStencil[SixthDensePt< 0, 1, 3>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 3));
1125  mStencil[SixthDensePt< 0, 2, 3>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 3));
1126  mStencil[SixthDensePt< 0, 3, 3>::idx] = mCache.getValue(ijk.offsetBy( 0, 3, 3));
1127 
1128  mStencil[SixthDensePt< 0,-3, 2>::idx] = mCache.getValue(ijk.offsetBy( 0,-3, 2));
1129  mStencil[SixthDensePt< 0,-2, 2>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 2));
1130  mStencil[SixthDensePt< 0,-1, 2>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 2));
1131  mStencil[SixthDensePt< 0, 1, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 2));
1132  mStencil[SixthDensePt< 0, 2, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 2));
1133  mStencil[SixthDensePt< 0, 3, 2>::idx] = mCache.getValue(ijk.offsetBy( 0, 3, 2));
1134 
1135  mStencil[SixthDensePt< 0,-3, 1>::idx] = mCache.getValue(ijk.offsetBy( 0,-3, 1));
1136  mStencil[SixthDensePt< 0,-2, 1>::idx] = mCache.getValue(ijk.offsetBy( 0,-2, 1));
1137  mStencil[SixthDensePt< 0,-1, 1>::idx] = mCache.getValue(ijk.offsetBy( 0,-1, 1));
1138  mStencil[SixthDensePt< 0, 1, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 1, 1));
1139  mStencil[SixthDensePt< 0, 2, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 2, 1));
1140  mStencil[SixthDensePt< 0, 3, 1>::idx] = mCache.getValue(ijk.offsetBy( 0, 3, 1));
1141 
1142  mStencil[SixthDensePt< 0,-3,-1>::idx] = mCache.getValue(ijk.offsetBy( 0,-3,-1));
1143  mStencil[SixthDensePt< 0,-2,-1>::idx] = mCache.getValue(ijk.offsetBy( 0,-2,-1));
1144  mStencil[SixthDensePt< 0,-1,-1>::idx] = mCache.getValue(ijk.offsetBy( 0,-1,-1));
1145  mStencil[SixthDensePt< 0, 1,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 1,-1));
1146  mStencil[SixthDensePt< 0, 2,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 2,-1));
1147  mStencil[SixthDensePt< 0, 3,-1>::idx] = mCache.getValue(ijk.offsetBy( 0, 3,-1));
1148 
1149  mStencil[SixthDensePt< 0,-3,-2>::idx] = mCache.getValue(ijk.offsetBy( 0,-3,-2));
1150  mStencil[SixthDensePt< 0,-2,-2>::idx] = mCache.getValue(ijk.offsetBy( 0,-2,-2));
1151  mStencil[SixthDensePt< 0,-1,-2>::idx] = mCache.getValue(ijk.offsetBy( 0,-1,-2));
1152  mStencil[SixthDensePt< 0, 1,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 1,-2));
1153  mStencil[SixthDensePt< 0, 2,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 2,-2));
1154  mStencil[SixthDensePt< 0, 3,-2>::idx] = mCache.getValue(ijk.offsetBy( 0, 3,-2));
1155 
1156  mStencil[SixthDensePt< 0,-3,-3>::idx] = mCache.getValue(ijk.offsetBy( 0,-3,-3));
1157  mStencil[SixthDensePt< 0,-2,-3>::idx] = mCache.getValue(ijk.offsetBy( 0,-2,-3));
1158  mStencil[SixthDensePt< 0,-1,-3>::idx] = mCache.getValue(ijk.offsetBy( 0,-1,-3));
1159  mStencil[SixthDensePt< 0, 1,-3>::idx] = mCache.getValue(ijk.offsetBy( 0, 1,-3));
1160  mStencil[SixthDensePt< 0, 2,-3>::idx] = mCache.getValue(ijk.offsetBy( 0, 2,-3));
1161  mStencil[SixthDensePt< 0, 3,-3>::idx] = mCache.getValue(ijk.offsetBy( 0, 3,-3));
1162  }
1163 
1164  template<typename, typename> friend class BaseStencil; // allow base class to call init()
1165  using BaseType::mCache;
1166  using BaseType::mStencil;
1167 };
1168 
1169 
1171 
1172 
1179 template<typename GridType>
1180 class GradStencil: public BaseStencil<GridType, GradStencil<GridType> >
1181 {
1182 public:
1185  typedef typename GridType::ValueType ValueType;
1187 
1188  static const int SIZE = 7;
1189 
1190  GradStencil(const GridType& grid):
1191  BaseType(grid, SIZE),
1192  mInv2Dx(ValueType(0.5 / grid.voxelSize()[0])),
1193  mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1194  {
1195  }
1196 
1197  GradStencil(const GridType& grid, Real dx):
1198  BaseType(grid, SIZE),
1199  mInv2Dx(ValueType(0.5 / dx)),
1200  mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1201  {
1202  }
1203 
1209  inline ValueType normSqGrad() const
1210  {
1211  return mInvDx2 * math::GudonovsNormSqrd(mStencil[0] > 0,
1212  mStencil[0] - mStencil[1],
1213  mStencil[2] - mStencil[0],
1214  mStencil[0] - mStencil[3],
1215  mStencil[4] - mStencil[0],
1216  mStencil[0] - mStencil[5],
1217  mStencil[6] - mStencil[0]);
1218  }
1219 
1225  inline Vec3Type gradient() const
1226  {
1227  return Vec3Type(mStencil[2] - mStencil[1],
1228  mStencil[4] - mStencil[3],
1229  mStencil[6] - mStencil[5])*mInv2Dx;
1230  }
1235  inline Vec3Type gradient(const Vec3Type& V) const
1236  {
1237  return Vec3Type(V[0]>0 ? mStencil[0] - mStencil[1] : mStencil[2] - mStencil[0],
1238  V[1]>0 ? mStencil[0] - mStencil[3] : mStencil[4] - mStencil[0],
1239  V[2]>0 ? mStencil[0] - mStencil[5] : mStencil[6] - mStencil[0])*2*mInv2Dx;
1240  }
1241 
1244  inline ValueType laplacian() const
1245  {
1246  return mInvDx2 * (mStencil[1] + mStencil[2] +
1247  mStencil[3] + mStencil[4] +
1248  mStencil[5] + mStencil[6] - 6*mStencil[0]);
1249  }
1250 
1253  inline bool zeroCrossing() const
1254  {
1255  const BufferType& v = mStencil;
1256  return (v[0]>0 ? (v[1]<0 || v[2]<0 || v[3]<0 || v[4]<0 || v[5]<0 || v[6]<0)
1257  : (v[1]>0 || v[2]>0 || v[3]>0 || v[4]>0 || v[5]>0 || v[6]>0));
1258  }
1259 
1267  inline Vec3Type cpt()
1268  {
1269  const Coord& ijk = BaseType::getCenterCoord();
1270  const ValueType d = ValueType(mStencil[0] * 0.5 * mInvDx2); // distance in voxels / (2dx^2)
1271  return Vec3Type(ijk[0] - d*(mStencil[2] - mStencil[1]),
1272  ijk[1] - d*(mStencil[4] - mStencil[3]),
1273  ijk[2] - d*(mStencil[6] - mStencil[5]));
1274  }
1275 
1276 private:
1277 
1278  inline void init(const Coord& ijk)
1279  {
1280  mStencil[1] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
1281  mStencil[2] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
1282 
1283  mStencil[3] = mCache.getValue(ijk.offsetBy( 0, -1, 0));
1284  mStencil[4] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
1285 
1286  mStencil[5] = mCache.getValue(ijk.offsetBy( 0, 0, -1));
1287  mStencil[6] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
1288  }
1289 
1290  template<typename, typename> friend class BaseStencil; // allow base class to call init()
1291  using BaseType::mCache;
1292  using BaseType::mStencil;
1293  const ValueType mInv2Dx, mInvDx2;
1294 }; // class GradStencil
1295 
1296 
1298 
1299 
1305 template<typename GridType>
1306 class WenoStencil: public BaseStencil<GridType, WenoStencil<GridType> >
1307 {
1308 public:
1311  typedef typename GridType::ValueType ValueType;
1313 
1314  static const int SIZE = 19;
1315 
1316  WenoStencil(const GridType& grid):
1317  BaseType(grid, SIZE),
1318  mDx2(ValueType(math::Pow2(grid.voxelSize()[0]))),
1319  mInv2Dx(ValueType(0.5 / grid.voxelSize()[0])),
1320  mInvDx2(ValueType(1.0 / mDx2))
1321  {
1322  }
1323 
1324  WenoStencil(const GridType& grid, Real dx):
1325  BaseType(grid, SIZE),
1326  mDx2(ValueType(dx * dx)),
1327  mInv2Dx(ValueType(0.5 / dx)),
1328  mInvDx2(ValueType(1.0 / mDx2))
1329  {
1330  }
1331 
1337  inline ValueType normSqGrad() const
1338  {
1339  const BufferType& v = mStencil;
1340 #ifdef DWA_OPENVDB
1341  // SSE optimized
1342  const simd::Float4
1343  v1(v[2]-v[1], v[ 8]-v[ 7], v[14]-v[13], 0),
1344  v2(v[3]-v[2], v[ 9]-v[ 8], v[15]-v[14], 0),
1345  v3(v[0]-v[3], v[ 0]-v[ 9], v[ 0]-v[15], 0),
1346  v4(v[4]-v[0], v[10]-v[ 0], v[16]-v[ 0], 0),
1347  v5(v[5]-v[4], v[11]-v[10], v[17]-v[16], 0),
1348  v6(v[6]-v[5], v[12]-v[11], v[18]-v[17], 0),
1349  dP_m = math::WENO5(v1, v2, v3, v4, v5, mDx2),
1350  dP_p = math::WENO5(v6, v5, v4, v3, v2, mDx2);
1351 
1352  return mInvDx2 * math::GudonovsNormSqrd(mStencil[0] > 0, dP_m, dP_p);
1353 #else
1354  const Real
1355  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),
1356  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),
1357  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),
1358  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),
1359  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),
1360  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);
1361  return mInvDx2*math::GudonovsNormSqrd(v[0]>0,dP_xm,dP_xp,dP_ym,dP_yp,dP_zm,dP_zp);
1362 #endif
1363  }
1364 
1370  inline Vec3Type gradient(const Vec3Type& V) const
1371  {
1372  const BufferType& v = mStencil;
1373  return 2*mInv2Dx * Vec3Type(
1374  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)
1375  : math::WENO5(v[ 6]-v[ 5],v[ 5]-v[ 4],v[ 4]-v[ 0], v[ 0]-v[ 3],v[ 3]-v[ 2],mDx2),
1376  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)
1377  : math::WENO5(v[12]-v[11],v[11]-v[10],v[10]-v[ 0], v[ 0]-v[ 9],v[ 9]-v[ 8],mDx2),
1378  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)
1379  : math::WENO5(v[18]-v[17],v[17]-v[16],v[16]-v[ 0], v[ 0]-v[15],v[15]-v[14],mDx2));
1380  }
1386  inline Vec3Type gradient() const
1387  {
1388  return mInv2Dx * Vec3Type(
1389  mStencil[ 4] - mStencil[ 3],
1390  mStencil[10] - mStencil[ 9],
1391  mStencil[16] - mStencil[15]);
1392  }
1393 
1399  inline ValueType laplacian() const
1400  {
1401  return mInvDx2 * (
1402  mStencil[ 3] + mStencil[ 4] +
1403  mStencil[ 9] + mStencil[10] +
1404  mStencil[15] + mStencil[16] - 6*mStencil[0]);
1405  }
1406 
1409  inline bool zeroCrossing() const
1410  {
1411  const BufferType& v = mStencil;
1412  return (v[ 0]>0 ? (v[ 3]<0 || v[ 4]<0 || v[ 9]<0 || v[10]<0 || v[15]<0 || v[16]<0)
1413  : (v[ 3]>0 || v[ 4]>0 || v[ 9]>0 || v[10]>0 || v[15]>0 || v[16]>0));
1414  }
1415 
1416 private:
1417  inline void init(const Coord& ijk)
1418  {
1419  mStencil[ 1] = mCache.getValue(ijk.offsetBy(-3, 0, 0));
1420  mStencil[ 2] = mCache.getValue(ijk.offsetBy(-2, 0, 0));
1421  mStencil[ 3] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
1422  mStencil[ 4] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
1423  mStencil[ 5] = mCache.getValue(ijk.offsetBy( 2, 0, 0));
1424  mStencil[ 6] = mCache.getValue(ijk.offsetBy( 3, 0, 0));
1425 
1426  mStencil[ 7] = mCache.getValue(ijk.offsetBy( 0, -3, 0));
1427  mStencil[ 8] = mCache.getValue(ijk.offsetBy( 0, -2, 0));
1428  mStencil[ 9] = mCache.getValue(ijk.offsetBy( 0, -1, 0));
1429  mStencil[10] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
1430  mStencil[11] = mCache.getValue(ijk.offsetBy( 0, 2, 0));
1431  mStencil[12] = mCache.getValue(ijk.offsetBy( 0, 3, 0));
1432 
1433  mStencil[13] = mCache.getValue(ijk.offsetBy( 0, 0, -3));
1434  mStencil[14] = mCache.getValue(ijk.offsetBy( 0, 0, -2));
1435  mStencil[15] = mCache.getValue(ijk.offsetBy( 0, 0, -1));
1436  mStencil[16] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
1437  mStencil[17] = mCache.getValue(ijk.offsetBy( 0, 0, 2));
1438  mStencil[18] = mCache.getValue(ijk.offsetBy( 0, 0, 3));
1439  }
1440 
1441  template<typename, typename> friend class BaseStencil; // allow base class to call init()
1442  using BaseType::mCache;
1443  using BaseType::mStencil;
1444  const ValueType mDx2, mInv2Dx, mInvDx2;
1445 }; // class WenoStencil
1446 
1447 
1449 
1450 
1451 template<typename GridType>
1452 class CurvatureStencil: public BaseStencil<GridType, CurvatureStencil<GridType> >
1453 {
1454 public:
1456  typedef typename GridType::ValueType ValueType;
1457 
1458  static const int SIZE = 19;
1459 
1461  BaseType(grid, SIZE),
1462  mInv2Dx(ValueType(0.5 / grid.voxelSize()[0])),
1463  mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1464  {
1465  }
1466 
1467  CurvatureStencil(const GridType& grid, Real dx):
1468  BaseType(grid, SIZE),
1469  mInv2Dx(ValueType(0.5 / dx)),
1470  mInvDx2(ValueType(4.0 * mInv2Dx * mInv2Dx))
1471  {
1472  }
1473 
1479  {
1480  Real alpha, beta;
1481  this->meanCurvature(alpha, beta);
1482  return ValueType(alpha*mInv2Dx/math::Pow3(beta));
1483  }
1484 
1492  {
1493  Real alpha, beta;
1494  this->meanCurvature(alpha, beta);
1495  return ValueType(alpha*mInvDx2/(2*math::Pow2(beta)));
1496  }
1497 
1503  inline ValueType laplacian() const
1504  {
1505  return mInvDx2 * (
1506  mStencil[1] + mStencil[2] +
1507  mStencil[3] + mStencil[4] +
1508  mStencil[5] + mStencil[6] - 6*mStencil[0]);
1509  }
1510 
1517  {
1518  return math::Vec3<ValueType>(
1519  mStencil[2] - mStencil[1],
1520  mStencil[4] - mStencil[3],
1521  mStencil[6] - mStencil[5])*mInv2Dx;
1522  }
1523 
1524 private:
1525  inline void init(const Coord &ijk)
1526  {
1527  mStencil[ 1] = mCache.getValue(ijk.offsetBy(-1, 0, 0));
1528  mStencil[ 2] = mCache.getValue(ijk.offsetBy( 1, 0, 0));
1529 
1530  mStencil[ 3] = mCache.getValue(ijk.offsetBy( 0, -1, 0));
1531  mStencil[ 4] = mCache.getValue(ijk.offsetBy( 0, 1, 0));
1532 
1533  mStencil[ 5] = mCache.getValue(ijk.offsetBy( 0, 0, -1));
1534  mStencil[ 6] = mCache.getValue(ijk.offsetBy( 0, 0, 1));
1535 
1536  mStencil[ 7] = mCache.getValue(ijk.offsetBy(-1, -1, 0));
1537  mStencil[ 8] = mCache.getValue(ijk.offsetBy( 1, -1, 0));
1538  mStencil[ 9] = mCache.getValue(ijk.offsetBy(-1, 1, 0));
1539  mStencil[10] = mCache.getValue(ijk.offsetBy( 1, 1, 0));
1540 
1541  mStencil[11] = mCache.getValue(ijk.offsetBy(-1, 0, -1));
1542  mStencil[12] = mCache.getValue(ijk.offsetBy( 1, 0, -1));
1543  mStencil[13] = mCache.getValue(ijk.offsetBy(-1, 0, 1));
1544  mStencil[14] = mCache.getValue(ijk.offsetBy( 1, 0, 1));
1545 
1546  mStencil[15] = mCache.getValue(ijk.offsetBy( 0, -1, -1));
1547  mStencil[16] = mCache.getValue(ijk.offsetBy( 0, 1, -1));
1548  mStencil[17] = mCache.getValue(ijk.offsetBy( 0, -1, 1));
1549  mStencil[18] = mCache.getValue(ijk.offsetBy( 0, 1, 1));
1550  }
1551 
1552  inline void meanCurvature(Real& alpha, Real& beta) const
1553  {
1554  // For performance all finite differences are unscaled wrt dx
1555  const Real
1556  Half(0.5), Quarter(0.25),
1557  Dx = Half * (mStencil[2] - mStencil[1]), Dx2 = Dx * Dx, // * 1/dx
1558  Dy = Half * (mStencil[4] - mStencil[3]), Dy2 = Dy * Dy, // * 1/dx
1559  Dz = Half * (mStencil[6] - mStencil[5]), Dz2 = Dz * Dz, // * 1/dx
1560  Dxx = mStencil[2] - 2 * mStencil[0] + mStencil[1], // * 1/dx2
1561  Dyy = mStencil[4] - 2 * mStencil[0] + mStencil[3], // * 1/dx2
1562  Dzz = mStencil[6] - 2 * mStencil[0] + mStencil[5], // * 1/dx2
1563  Dxy = Quarter * (mStencil[10] - mStencil[ 8] + mStencil[7] - mStencil[ 9]), // * 1/dx2
1564  Dxz = Quarter * (mStencil[14] - mStencil[12] + mStencil[11] - mStencil[13]), // * 1/dx2
1565  Dyz = Quarter * (mStencil[18] - mStencil[16] + mStencil[15] - mStencil[17]); // * 1/dx2
1566  alpha = (Dx2*(Dyy+Dzz)+Dy2*(Dxx+Dzz)+Dz2*(Dxx+Dyy)-2*(Dx*(Dy*Dxy+Dz*Dxz)+Dy*Dz*Dyz));
1567  beta = std::sqrt(Dx2 + Dy2 + Dz2); // * 1/dx
1568  }
1569 
1570  template<typename, typename> friend class BaseStencil; // allow base class to call init()
1571  using BaseType::mCache;
1572  using BaseType::mStencil;
1573  const ValueType mInv2Dx, mInvDx2;
1574 }; // class CurvatureStencil
1575 
1576 
1578 
1579 
1581 template<typename GridType>
1582 class DenseStencil: public BaseStencil<GridType, DenseStencil<GridType> >
1583 {
1584 public:
1586  typedef typename GridType::ValueType ValueType;
1587 
1588  DenseStencil(const GridType& grid, int halfWidth) :
1589  BaseType(grid, /*size=*/math::Pow3(2 * halfWidth + 1)),
1590  mHalfWidth(halfWidth)
1591  {
1592  assert(halfWidth>0);
1593  }
1594 
1595  inline const ValueType& getCenterValue() const { return mStencil[(mStencil.size()-1)>>1]; }
1596 
1599  inline void moveTo(const Coord& ijk)
1600  {
1601  BaseType::mCenter = ijk;
1602  this->init(ijk);
1603  }
1606  template<typename IterType>
1607  inline void moveTo(const IterType& iter)
1608  {
1609  BaseType::mCenter = iter.getCoord();
1610  this->init(BaseType::mCenter);
1611  }
1612 
1613 private:
1616  inline void init(const Coord& ijk)
1617  {
1618  int n = 0;
1619  for (Coord p=ijk.offsetBy(-mHalfWidth), q=ijk.offsetBy(mHalfWidth); p[0] <= q[0]; ++p[0]) {
1620  for (p[1] = ijk[1]-mHalfWidth; p[1] <= q[1]; ++p[1]) {
1621  for (p[2] = ijk[2]-mHalfWidth; p[2] <= q[2]; ++p[2]) {
1622  mStencil[n++] = mCache.getValue(p);
1623  }
1624  }
1625  }
1626  }
1627 
1628  template<typename, typename> friend class BaseStencil; // allow base class to call init()
1629  using BaseType::mCache;
1630  using BaseType::mStencil;
1631  const int mHalfWidth;
1632 };
1633 
1634 
1635 } // end math namespace
1636 } // namespace OPENVDB_VERSION_NAME
1637 } // end openvdb namespace
1638 
1639 #endif // OPENVDB_MATH_STENCILS_HAS_BEEN_INCLUDED
1640 
1641 // Copyright (c) 2012-2013 DreamWorks Animation LLC
1642 // All rights reserved. This software is distributed under the
1643 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
Vec3Type cpt()
Compute the closest-point transform to a level set.
Definition: Stencils.h:1267
Vec3Type gradient() const
Definition: Stencils.h:1386
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:351
BaseStencil< GridType, WenoStencil< GridType > > BaseType
Definition: Stencils.h:1309
BaseType::BufferType BufferType
Definition: Stencils.h:445
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:662
BaseType::BufferType BufferType
Definition: Stencils.h:238
void setValue(const ValueType &value)
Set the value at the specified location relative to the center of the stencil.
Definition: Stencils.h:131
GridType::ValueType ValueType
Definition: Stencils.h:239
BaseStencil< GridType, DenseStencil< GridType > > BaseType
Definition: Stencils.h:1585
ValueType laplacian() const
Definition: Stencils.h:1244
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:299
BaseStencil< GridType, SecondOrderDenseStencil< GridType > > BaseType
Definition: Stencils.h:444
GridType::ValueType ValueType
Definition: Stencils.h:59
Definition: Stencils.h:54
ValueType normSqGrad() const
Return the norm-square of the WENO upwind gradient (computed via WENO upwinding and Gudonov&#39;s scheme)...
Definition: Stencils.h:1337
BufferType::iterator IterType
Definition: Stencils.h:61
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:240
GridType::TreeType TreeType
Definition: Stencils.h:58
_GridType GridType
Definition: Stencils.h:57
ValueType median() const
Return the median value of the current stencil.
Definition: Stencils.h:140
math::Vec3< ValueType > gradient()
Definition: Stencils.h:1516
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:455
ValueType laplacian() const
Definition: Stencils.h:1503
SevenPointStencil(const GridType &grid)
Definition: Stencils.h:243
BaseType::BufferType BufferType
Definition: Stencils.h:1184
BaseStencil< GridType, FourthOrderDenseStencil< GridType > > BaseType
Definition: Stencils.h:651
BaseStencil(const GridType &grid, int size)
Definition: Stencils.h:201
Definition: Stencils.h:1180
BaseStencil< GridType, NineteenPointStencil< GridType > > BaseType
Definition: Stencils.h:788
ValueType interpolation(const Vec3Type &xyz) const
Return the trilinear interpolation at the normalized position.
Definition: Stencils.h:322
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:533
Type Pow2(Type x)
Return .
Definition: Math.h:467
DenseStencil(const GridType &grid, int halfWidth)
Definition: Stencils.h:1588
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:1013
void moveTo(const Vec3R &xyz)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:105
GridType::ValueType ValueType
Definition: Stencils.h:446
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:247
const GridType * mGrid
Definition: Stencils.h:207
Definition: Stencils.h:286
GridType::ConstAccessor AccessorType
Definition: Stencils.h:62
const ValueType & getCenterValue() const
Definition: Stencils.h:1595
GridType::ValueType ValueType
Definition: Stencils.h:1586
GridType::ValueType ValueType
Definition: Stencils.h:1456
Vec3Type gradient() const
Return the gradient computed at the previously buffered location by second order central differencing...
Definition: Stencils.h:1225
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:654
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:447
Vec3Type gradient(const Vec3Type &V) const
Definition: Stencils.h:1370
BaseStencil< GridType, ThirteenPointStencil< GridType > > BaseType
Definition: Stencils.h:522
ValueType meanCurvatureNormGrad()
Definition: Stencils.h:1491
GridType::ValueType ValueType
Definition: Stencils.h:524
BaseStencil< GridType, CurvatureStencil< GridType > > BaseType
Definition: Stencils.h:1455
GridType::ValueType ValueType
Definition: Stencils.h:790
BaseType::BufferType BufferType
Definition: Stencils.h:652
GridType::ValueType ValueType
Definition: Stencils.h:1311
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:292
GridType::ValueType ValueType
Definition: Stencils.h:1185
#define OPENVDB_VERSION_NAME
Definition: version.h:45
int size()
Return the size of the stencil buffer.
Definition: Stencils.h:137
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
ThirteenPointStencil(const GridType &grid)
Definition: Stencils.h:529
const ValueType & getValue(unsigned int pos=0) const
Return the value from the stencil buffer with linear offset pos.
Definition: Stencils.h:116
Definition: Stencils.h:1452
SixthOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:1009
Coord mCenter
Definition: Stencils.h:210
GradStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1197
BaseType::BufferType BufferType
Definition: Stencils.h:523
FourthOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:658
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:1306
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:525
std::vector< ValueType > BufferType
Definition: Stencils.h:60
GridType::Ptr meanCurvature(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the mean curvature of the given grid.
Definition: GridOperators.h:932
ValueType normSqGrad() const
Return the norm square of the single-sided upwind gradient (computed via Gudonov&#39;s scheme) at the pre...
Definition: Stencils.h:1209
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:1312
bool zeroCrossing() const
Definition: Stencils.h:1253
OPENVDB_API Hermite max(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
GridType::ValueType ValueType
Definition: Stencils.h:291
ValueType max() const
Return the largest value in the stencil buffer.
Definition: Stencils.h:166
ValueType laplacian() const
Definition: Stencils.h:1399
void moveTo(const Coord &ijk)
Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors.
Definition: Stencils.h:67
Dense stencil of a given width.
Definition: Stencils.h:1582
double Real
Definition: Types.h:62
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:180
BaseType::BufferType BufferType
Definition: Stencils.h:789
NineteenPointStencil(const GridType &grid)
Definition: Stencils.h:795
CurvatureStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1467
const ValueType & getCenterValue() const
Return the value at the center of the stencil.
Definition: Stencils.h:176
void moveTo(const IterType &iter)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:92
const AccessorType & accessor() const
Return a const reference to the ValueAccessor associated with this Stencil.
Definition: Stencils.h:197
Vec3Type gradient(const Vec3Type &V) const
Return the first-order upwind gradient corresponding to the direction V.
Definition: Stencils.h:1235
ValueType min() const
Return the smallest value in the stencil buffer.
Definition: Stencils.h:159
BaseStencil< GridType, SixthOrderDenseStencil< GridType > > BaseType
Definition: Stencils.h:1002
AccessorType mCache
Definition: Stencils.h:208
ValueType WENO5(const ValueType &v1, const ValueType &v2, const ValueType &v3, const ValueType &v4, const ValueType &v5, float scale2=0.01)
implimentation of nonimally fith-order finite-difference WENO. This function returns the numerical fl...
Definition: FiniteDifference.h:331
GridType::ValueType ValueType
Definition: Stencils.h:653
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:791
bool zeroCrossing() const
Definition: Stencils.h:1409
void moveTo(const Coord &ijk)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:1599
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:1005
void moveTo(const Coord &ijk, const ValueType &centerValue)
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:79
Type Pow3(Type x)
Return .
Definition: Math.h:471
BaseStencil< GridType, SevenPointStencil< GridType > > BaseType
Definition: Stencils.h:237
BaseType::BufferType BufferType
Definition: Stencils.h:1310
WenoStencil(const GridType &grid, Real dx)
Definition: Stencils.h:1324
ValueType meanCurvature()
Return the mean curvature at the previously buffered location.
Definition: Stencils.h:1478
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:102
ValueType mean() const
Return the mean value of the current stencil.
Definition: Stencils.h:151
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
CurvatureStencil(const GridType &grid)
Definition: Stencils.h:1460
GridType::ValueType ValueType
Definition: Stencils.h:1004
GradStencil(const GridType &grid)
Definition: Stencils.h:1190
BaseType::BufferType BufferType
Definition: Stencils.h:290
math::Vec3< ValueType > Vec3Type
Definition: Stencils.h:1186
const GridType & grid() const
Return a const reference to the grid from which this stencil was constructed.
Definition: Stencils.h:193
SecondOrderDenseStencil(const GridType &grid)
Definition: Stencils.h:451
unsigned int pos() const
Return linear offset for the specified stencil point relative to its center.
Definition: Stencils.h:799
void moveTo(const IterType &iter)
Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.
Definition: Stencils.h:1607
BaseType::BufferType BufferType
Definition: Stencils.h:1003
BoxStencil(const GridType &grid)
Definition: Stencils.h:295
Vec3Type gradient(const Vec3Type &xyz) const
Return the gradient in world space of the trilinear interpolation kernel.
Definition: Stencils.h:350
BaseStencil< GridType, BoxStencil< GridType > > BaseType
Definition: Stencils.h:289
BufferType mStencil
Definition: Stencils.h:209
WenoStencil(const GridType &grid)
Definition: Stencils.h:1316
BaseStencil< GridType, GradStencil< GridType > > BaseType
Definition: Stencils.h:1183
const ValueType & getValue() const
Return the value at the specified location relative to the center of the stencil. ...
Definition: Stencils.h:124
bool intersects(const ValueType &isoValue=zeroVal< ValueType >()) const
Return true if the center of the stencil intersects the.
Definition: Stencils.h:303
const Coord & getCenterCoord() const
Return the coordinates of the center point of the stencil.
Definition: Stencils.h:173