OpenVDB: LevelSetAdvect.h Source File

OpenVDB 3.2.0

LevelSetAdvect.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2016 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 //
32 //
38
39 #ifndef OPENVDB_TOOLS_LEVEL_SET_ADVECT_HAS_BEEN_INCLUDED
40 #define OPENVDB_TOOLS_LEVEL_SET_ADVECT_HAS_BEEN_INCLUDED
41
42 #include <tbb/parallel_for.h>
43 #include <tbb/parallel_reduce.h>
44 #include <openvdb/Platform.h>
45 #include "LevelSetTracker.h"
46 #include "VelocityFields.h" // for EnrightField
47 #include <openvdb/math/FiniteDifference.h>
48 #include <boost/math/constants/constants.hpp>
49 #include <openvdb/util/CpuTimer.h>
50
51 namespace openvdb {
52 OPENVDB_USE_VERSION_NAMESPACE
53 namespace OPENVDB_VERSION_NAME {
54 namespace tools {
55
97
98 template<typename GridT,
99 typename FieldT = EnrightField<typename GridT::ValueType>,
100 typename InterruptT = util::NullInterrupter>
101 class LevelSetAdvection
102 {
103 public:
104 typedef GridT GridType;
105 typedef LevelSetTracker<GridT, InterruptT> TrackerT;
106 typedef typename TrackerT::LeafRange LeafRange;
107 typedef typename TrackerT::LeafType LeafType;
108 typedef typename TrackerT::BufferType BufferType;
109 typedef typename TrackerT::ValueType ValueType;
110 typedef typename FieldT::VectorType VectorType;
111
113 LevelSetAdvection(GridT& grid, const FieldT& field, InterruptT* interrupt = NULL):
114 mTracker(grid, interrupt), mField(field),
115 mSpatialScheme(math::HJWENO5_BIAS),
116 mTemporalScheme(math::TVD_RK2) {}
117
118 virtual ~LevelSetAdvection() {}
119
121 math::BiasedGradientScheme getSpatialScheme() const { return mSpatialScheme; }
123 void setSpatialScheme(math::BiasedGradientScheme scheme) { mSpatialScheme = scheme; }
124
126 math::TemporalIntegrationScheme getTemporalScheme() const { return mTemporalScheme; }
128 void setTemporalScheme(math::TemporalIntegrationScheme scheme) { mTemporalScheme = scheme; }
129
131 math::BiasedGradientScheme getTrackerSpatialScheme() const { return mTracker.getSpatialScheme(); }
133 void setTrackerSpatialScheme(math::BiasedGradientScheme scheme) { mTracker.setSpatialScheme(scheme); }
134
136 math::TemporalIntegrationScheme getTrackerTemporalScheme() const { return mTracker.getTemporalScheme(); }
138 void setTrackerTemporalScheme(math::TemporalIntegrationScheme scheme) { mTracker.setTemporalScheme(scheme); }
139
142 int getNormCount() const { return mTracker.getNormCount(); }
145 void setNormCount(int n) { mTracker.setNormCount(n); }
146
148 int getGrainSize() const { return mTracker.getGrainSize(); }
151 void setGrainSize(int grainsize) { mTracker.setGrainSize(grainsize); }
152
157 size_t advect(ValueType time0, ValueType time1);
158
159 private:
160
161 // disallow copy construction and copy by assinment!
162 LevelSetAdvection(const LevelSetAdvection&);// not implemented
163 LevelSetAdvection& operator=(const LevelSetAdvection&);// not implemented
164
165 // This templated private struct implements all the level set magic.
166 template<typename MapT, math::BiasedGradientScheme SpatialScheme,
167 math::TemporalIntegrationScheme TemporalScheme>
168 struct Advect
169 {
171 Advect(LevelSetAdvection& parent);
173 Advect(const Advect& other);
175 virtual ~Advect() { if (mIsMaster) this->clearField(); }
178 size_t advect(ValueType time0, ValueType time1);
180 void operator()(const LeafRange& r) const
181 {
182 if (mTask) mTask(const_cast<Advect*>(this), r);
183 else OPENVDB_THROW(ValueError, "task is undefined - don\'t call this method directly");
184 }
186 void cook(const char* msg, size_t swapBuffer = 0);
188 typename GridT::ValueType sampleField(ValueType time0, ValueType time1);
189 template <bool Aligned> void sample(const LeafRange& r, ValueType t0, ValueType t1);
190 inline void sampleXformed(const LeafRange& r, ValueType t0, ValueType t1)
191 {
192 this->sample<false>(r, t0, t1);
193 }
194 inline void sampleAligned(const LeafRange& r, ValueType t0, ValueType t1)
195 {
196 this->sample<true>(r, t0, t1);
197 }
198 void clearField();
199 // Convex combination of Phi and a forward Euler advection steps:
200 // Phi(result) = alpha * Phi(phi) + (1-alpha) * (Phi(0) - dt * Speed(speed)*|Grad[Phi(0)]|);
201 template <int Nominator, int Denominator>
202 void euler(const LeafRange&, ValueType, Index, Index);
203 inline void euler01(const LeafRange& r, ValueType t) {this->euler<0,1>(r, t, 0, 1);}
204 inline void euler12(const LeafRange& r, ValueType t) {this->euler<1,2>(r, t, 1, 1);}
205 inline void euler34(const LeafRange& r, ValueType t) {this->euler<3,4>(r, t, 1, 2);}
206 inline void euler13(const LeafRange& r, ValueType t) {this->euler<1,3>(r, t, 1, 2);}
207
208 LevelSetAdvection& mParent;
209 VectorType* mVelocity;
210 size_t* mOffsets;
211 const MapT* mMap;
212 typename boost::function<void (Advect*, const LeafRange&)> mTask;
213 const bool mIsMaster;
214 }; // end of private Advect struct
215
216 template<math::BiasedGradientScheme SpatialScheme>
217 size_t advect1(ValueType time0, ValueType time1);
218
219 template<math::BiasedGradientScheme SpatialScheme,
220 math::TemporalIntegrationScheme TemporalScheme>
221 size_t advect2(ValueType time0, ValueType time1);
222
223 template<math::BiasedGradientScheme SpatialScheme,
224 math::TemporalIntegrationScheme TemporalScheme,
225 typename MapType>
226 size_t advect3(ValueType time0, ValueType time1);
227
228 TrackerT mTracker;
229 //each thread needs a deep copy of the field since it might contain a ValueAccessor
230 const FieldT mField;
231 math::BiasedGradientScheme mSpatialScheme;
232 math::TemporalIntegrationScheme mTemporalScheme;
233
234 };//end of LevelSetAdvection
235
236 template<typename GridT, typename FieldT, typename InterruptT>
237 inline size_t
238 LevelSetAdvection<GridT, FieldT, InterruptT>::advect(ValueType time0, ValueType time1)
239 {
240 switch (mSpatialScheme) {
241 case math::FIRST_BIAS:
242 return this->advect1<math::FIRST_BIAS >(time0, time1);
243 case math::SECOND_BIAS:
244 return this->advect1<math::SECOND_BIAS >(time0, time1);
245 case math::THIRD_BIAS:
246 return this->advect1<math::THIRD_BIAS >(time0, time1);
247 case math::WENO5_BIAS:
248 return this->advect1<math::WENO5_BIAS >(time0, time1);
249 case math::HJWENO5_BIAS:
250 return this->advect1<math::HJWENO5_BIAS>(time0, time1);
251 default:
252 OPENVDB_THROW(ValueError, "Spatial difference scheme not supported!");
253 }
254 return 0;
255 }
256
257 template<typename GridT, typename FieldT, typename InterruptT>
258 template<math::BiasedGradientScheme SpatialScheme>
259 inline size_t
260 LevelSetAdvection<GridT, FieldT, InterruptT>::advect1(ValueType time0, ValueType time1)
261 {
262 switch (mTemporalScheme) {
263 case math::TVD_RK1:
264 return this->advect2<SpatialScheme, math::TVD_RK1>(time0, time1);
265 case math::TVD_RK2:
266 return this->advect2<SpatialScheme, math::TVD_RK2>(time0, time1);
267 case math::TVD_RK3:
268 return this->advect2<SpatialScheme, math::TVD_RK3>(time0, time1);
269 default:
270 OPENVDB_THROW(ValueError, "Temporal integration scheme not supported!");
271 }
272 return 0;
273 }
274
275 template<typename GridT, typename FieldT, typename InterruptT>
276 template<math::BiasedGradientScheme SpatialScheme,
277 math::TemporalIntegrationScheme TemporalScheme>
278 inline size_t
279 LevelSetAdvection<GridT, FieldT, InterruptT>::advect2(ValueType time0, ValueType time1)
280 {
281 const math::Transform& trans = mTracker.grid().transform();
282 if (trans.mapType() == math::UniformScaleMap::mapType()) {
283 return this->advect3<SpatialScheme, TemporalScheme, math::UniformScaleMap>(time0, time1);
284 } else if (trans.mapType() == math::UniformScaleTranslateMap::mapType()) {
285 return this->advect3<SpatialScheme, TemporalScheme, math::UniformScaleTranslateMap>(time0, time1);
286 } else if (trans.mapType() == math::UnitaryMap::mapType()) {
287 return this->advect3<SpatialScheme, TemporalScheme, math::UnitaryMap >(time0, time1);
288 } else if (trans.mapType() == math::TranslationMap::mapType()) {
289 return this->advect3<SpatialScheme, TemporalScheme, math::TranslationMap>(time0, time1);
290 } else {
291 OPENVDB_THROW(ValueError, "MapType not supported!");
292 }
293 return 0;
294 }
295
296 template<typename GridT, typename FieldT, typename InterruptT>
297 template<math::BiasedGradientScheme SpatialScheme,
298 math::TemporalIntegrationScheme TemporalScheme,
299 typename MapT>
300 inline size_t
301 LevelSetAdvection<GridT, FieldT, InterruptT>::advect3(ValueType time0, ValueType time1)
302 {
303 Advect<MapT, SpatialScheme, TemporalScheme> tmp(*this);
304 return tmp.advect(time0, time1);
305 }
306
307
309
310
311 template<typename GridT, typename FieldT, typename InterruptT>
312 template <typename MapT, math::BiasedGradientScheme SpatialScheme,
313 math::TemporalIntegrationScheme TemporalScheme>
314 inline
315 LevelSetAdvection<GridT, FieldT, InterruptT>::
316 Advect<MapT, SpatialScheme, TemporalScheme>::
317 Advect(LevelSetAdvection& parent)
318 : mParent(parent)
319 , mVelocity(NULL)
320 , mOffsets(NULL)
321 , mMap(parent.mTracker.grid().transform().template constMap<MapT>().get())
322 , mTask(0)
323 , mIsMaster(true)
324 {
325 }
326
327 template<typename GridT, typename FieldT, typename InterruptT>
328 template <typename MapT, math::BiasedGradientScheme SpatialScheme,
329 math::TemporalIntegrationScheme TemporalScheme>
330 inline
331 LevelSetAdvection<GridT, FieldT, InterruptT>::
332 Advect<MapT, SpatialScheme, TemporalScheme>::
333 Advect(const Advect& other)
334 : mParent(other.mParent)
335 , mVelocity(other.mVelocity)
336 , mOffsets(other.mOffsets)
337 , mMap(other.mMap)
338 , mTask(other.mTask)
339 , mIsMaster(false)
340 {
341 }
342
343 template<typename GridT, typename FieldT, typename InterruptT>
344 template <typename MapT, math::BiasedGradientScheme SpatialScheme,
345 math::TemporalIntegrationScheme TemporalScheme>
346 inline size_t
347 LevelSetAdvection<GridT, FieldT, InterruptT>::
348 Advect<MapT, SpatialScheme, TemporalScheme>::
349 advect(ValueType time0, ValueType time1)
350 {
351 //util::CpuTimer timer;
352 size_t countCFL = 0;
353 if ( math::isZero(time0 - time1) ) return countCFL;
354 const bool isForward = time0 < time1;
355 while ((isForward ? time0<time1 : time0>time1) && mParent.mTracker.checkInterrupter()) {
357 //timer.start( "\nallocate buffers" );
358 mParent.mTracker.leafs().rebuildAuxBuffers(TemporalScheme == math::TVD_RK3 ? 2 : 1);
359 //timer.stop();
360
361 const ValueType dt = this->sampleField(time0, time1);
362 if ( math::isZero(dt) ) break;//V is essentially zero so terminate
363
364 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN //switch is resolved at compile-time
365 switch(TemporalScheme) {
366 case math::TVD_RK1:
367 // Perform one explicit Euler step: t1 = t0 + dt
368 // Phi_t1(1) = Phi_t0(0) - dt * VdotG_t0(0)
369 mTask = boost::bind(&Advect::euler01, _1, _2, dt);
370
371 // Cook and swap buffer 0 and 1 such that Phi_t1(0) and Phi_t0(1)
372 this->cook("Advecting level set using TVD_RK1", 1);
373 break;
374 case math::TVD_RK2:
375 // Perform one explicit Euler step: t1 = t0 + dt
376 // Phi_t1(1) = Phi_t0(0) - dt * VdotG_t0(0)
377 mTask = boost::bind(&Advect::euler01, _1, _2, dt);
378
379 // Cook and swap buffer 0 and 1 such that Phi_t1(0) and Phi_t0(1)
380 this->cook("Advecting level set using TVD_RK1 (step 1 of 2)", 1);
381
382 // Convex combine explict Euler step: t2 = t0 + dt
383 // Phi_t2(1) = 1/2 * Phi_t0(1) + 1/2 * (Phi_t1(0) - dt * V.Grad_t1(0))
384 mTask = boost::bind(&Advect::euler12, _1, _2, dt);
385
386 // Cook and swap buffer 0 and 1 such that Phi_t2(0) and Phi_t1(1)
387 this->cook("Advecting level set using TVD_RK1 (step 2 of 2)", 1);
388 break;
389 case math::TVD_RK3:
390 // Perform one explicit Euler step: t1 = t0 + dt
391 // Phi_t1(1) = Phi_t0(0) - dt * VdotG_t0(0)
392 mTask = boost::bind(&Advect::euler01, _1, _2, dt);
393
394 // Cook and swap buffer 0 and 1 such that Phi_t1(0) and Phi_t0(1)
395 this->cook("Advecting level set using TVD_RK3 (step 1 of 3)", 1);
396
397 // Convex combine explict Euler step: t2 = t0 + dt/2
398 // Phi_t2(2) = 3/4 * Phi_t0(1) + 1/4 * (Phi_t1(0) - dt * V.Grad_t1(0))
399 mTask = boost::bind(&Advect::euler34, _1, _2, dt);
400
401 // Cook and swap buffer 0 and 2 such that Phi_t2(0) and Phi_t1(2)
402 this->cook("Advecting level set using TVD_RK3 (step 2 of 3)", 2);
403
404 // Convex combine explict Euler step: t3 = t0 + dt
405 // Phi_t3(2) = 1/3 * Phi_t0(1) + 2/3 * (Phi_t2(0) - dt * V.Grad_t2(0)
406 mTask = boost::bind(&Advect::euler13, _1, _2, dt);
407
408 // Cook and swap buffer 0 and 2 such that Phi_t3(0) and Phi_t2(2)
409 this->cook("Advecting level set using TVD_RK3 (step 3 of 3)", 2);
410 break;
411 default:
412 OPENVDB_THROW(ValueError, "Temporal integration scheme not supported!");
413 }//end of compile-time resolved switch
414 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
415
416 time0 += isForward ? dt : -dt;
417 ++countCFL;
418 mParent.mTracker.leafs().removeAuxBuffers();
419 this->clearField();
421 mParent.mTracker.track();
422 }//end wile-loop over time
423 return countCFL;//number of CLF propagation steps
424 }
425
426 template<typename GridT, typename FieldT, typename InterruptT>
427 template<typename MapT, math::BiasedGradientScheme SpatialScheme,
428 math::TemporalIntegrationScheme TemporalScheme>
429 inline typename GridT::ValueType
430 LevelSetAdvection<GridT, FieldT, InterruptT>::
431 Advect<MapT, SpatialScheme, TemporalScheme>::
432 sampleField(ValueType time0, ValueType time1)
433 {
434 const int grainSize = mParent.mTracker.getGrainSize();
435 const size_t leafCount = mParent.mTracker.leafs().leafCount();
436 if (leafCount==0) return ValueType(0.0);
437
438 // Compute the pre-fix sum of offsets to active voxels
439 size_t size=0, voxelCount=mParent.mTracker.leafs().getPreFixSum(mOffsets, size, grainSize);
440
441 // Sample the velocity field
442 if (mParent.mField.transform() == mParent.mTracker.grid().transform()) {
443 mTask = boost::bind(&Advect::sampleAligned, _1, _2, time0, time1);
444 } else {
445 mTask = boost::bind(&Advect::sampleXformed, _1, _2, time0, time1);
446 }
447 assert(voxelCount == mParent.mTracker.grid().activeVoxelCount());
448 mVelocity = new VectorType[ voxelCount ];
449 this->cook("Sampling advection field");
450
451 // Find the extrema of the magnitude of the velocities
452 ValueType maxAbsV = 0;
453 VectorType* v = mVelocity;
454 for (size_t i=0; i<voxelCount; ++i, ++v) maxAbsV = math::Max(maxAbsV, ValueType(v->lengthSqr()));
455
456 // Compute the CFL number
457 if (math::isApproxZero(maxAbsV, math::Delta<ValueType>::value())) return ValueType(0);
458 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics
459 static
460 #endif
461 const ValueType CFL = (TemporalScheme == math::TVD_RK1 ? ValueType(0.3) :
462 TemporalScheme == math::TVD_RK2 ? ValueType(0.9) :
463 ValueType(1.0))/math::Sqrt(ValueType(3.0));
464 const ValueType dt = math::Abs(time1 - time0), dx = mParent.mTracker.voxelSize();
465 return math::Min(dt, ValueType(CFL*dx/math::Sqrt(maxAbsV)));
466 }
467
468 template<typename GridT, typename FieldT, typename InterruptT>
469 template <typename MapT, math::BiasedGradientScheme SpatialScheme,
470 math::TemporalIntegrationScheme TemporalScheme>
471 template <bool Aligned>
472 inline void
473 LevelSetAdvection<GridT, FieldT, InterruptT>::
474 Advect<MapT, SpatialScheme, TemporalScheme>::
475 sample(const LeafRange& range, ValueType time0, ValueType time1)
476 {
477 const bool isForward = time0 < time1;
478 typedef typename LeafType::ValueOnCIter VoxelIterT;
479 const MapT& map = *mMap;
480 const FieldT field( mParent.mField );
481 mParent.mTracker.checkInterrupter();
482 for (typename LeafRange::Iterator leafIter = range.begin(); leafIter; ++leafIter) {
483 VectorType* vel = mVelocity + mOffsets[ leafIter.pos() ];
484 for (VoxelIterT iter = leafIter->cbeginValueOn(); iter; ++iter, ++vel) {
485 const VectorType v = Aligned ? field(iter.getCoord(), time0) ://resolved at compile time
486 field(map.applyMap(iter.getCoord().asVec3d()), time0);
487 *vel = isForward ? v : -v;
488 }
489 }
490 }
491
492 template<typename GridT, typename FieldT, typename InterruptT>
493 template <typename MapT, math::BiasedGradientScheme SpatialScheme,
494 math::TemporalIntegrationScheme TemporalScheme>
495 inline void
496 LevelSetAdvection<GridT, FieldT, InterruptT>::
497 Advect<MapT, SpatialScheme, TemporalScheme>::
498 clearField()
499 {
500 delete [] mOffsets;
501 delete [] mVelocity;
502 mOffsets = NULL;
503 mVelocity = NULL;
504 }
505
506 template<typename GridT, typename FieldT, typename InterruptT>
507 template <typename MapT, math::BiasedGradientScheme SpatialScheme,
508 math::TemporalIntegrationScheme TemporalScheme>
509 inline void
510 LevelSetAdvection<GridT, FieldT, InterruptT>::
511 Advect<MapT, SpatialScheme, TemporalScheme>::
512 cook(const char* msg, size_t swapBuffer)
513 {
514 mParent.mTracker.startInterrupter( msg );
515
516 const int grainSize = mParent.mTracker.getGrainSize();
517 const LeafRange range = mParent.mTracker.leafs().leafRange(grainSize);
518
519 grainSize == 0 ? (*this)(range) : tbb::parallel_for(range, *this);
520
521 mParent.mTracker.leafs().swapLeafBuffer(swapBuffer, grainSize == 0);
522
523 mParent.mTracker.endInterrupter();
524 }
525
526 // Convex combination of Phi and a forward Euler advection steps:
527 // Phi(result) = alpha * Phi(phi) + (1-alpha) * (Phi(0) - dt * V.Grad(0));
528 template<typename GridT, typename FieldT, typename InterruptT>
529 template<typename MapT, math::BiasedGradientScheme SpatialScheme,
530 math::TemporalIntegrationScheme TemporalScheme>
531 template <int Nominator, int Denominator>
532 inline void
533 LevelSetAdvection<GridT, FieldT, InterruptT>::
534 Advect<MapT, SpatialScheme, TemporalScheme>::
535 euler(const LeafRange& range, ValueType dt, Index phiBuffer, Index resultBuffer)
536 {
537 typedef math::BIAS_SCHEME<SpatialScheme> SchemeT;
538 typedef typename SchemeT::template ISStencil<GridType>::StencilType StencilT;
539 typedef typename LeafType::ValueOnCIter VoxelIterT;
540 typedef math::GradientBiased<MapT, SpatialScheme> GradT;
541
542 static const ValueType Alpha = ValueType(Nominator)/ValueType(Denominator);
543 static const ValueType Beta = ValueType(1) - Alpha;
544
545 mParent.mTracker.checkInterrupter();
546 const MapT& map = *mMap;
547 StencilT stencil(mParent.mTracker.grid());
548 for (typename LeafRange::Iterator leafIter = range.begin(); leafIter; ++leafIter) {
549 const VectorType* vel = mVelocity + mOffsets[ leafIter.pos() ];
550 const ValueType* phi = leafIter.buffer(phiBuffer).data();
551 ValueType* result = leafIter.buffer(resultBuffer).data();
552 for (VoxelIterT voxelIter = leafIter->cbeginValueOn(); voxelIter; ++voxelIter, ++vel) {
553 const Index i = voxelIter.pos();
554 stencil.moveTo(voxelIter);
555 const ValueType a = stencil.getValue() - dt * vel->dot(GradT::result(map, stencil, *vel));
556 result[i] = Nominator ? Alpha * phi[i] + Beta * a : a;
557 }//loop over active voxels in the leaf of the mask
558 }//loop over leafs of the level set
559 }
560
561 } // namespace tools
562 } // namespace OPENVDB_VERSION_NAME
563 } // namespace openvdb
564
565 #endif // OPENVDB_TOOLS_LEVEL_SET_ADVECT_HAS_BEEN_INCLUDED
566
567 // Copyright (c) 2012-2016 DreamWorks Animation LLC
568 // All rights reserved. This software is distributed under the
569 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_2_0::tools::LevelSetAdvection::BufferType
TrackerT::BufferType BufferType
Definition: LevelSetAdvect.h:108
FiniteDifference.h
openvdb::v3_2_0::math::Abs
Coord Abs(const Coord &xyz)
Definition: Coord.h:247
openvdb::v3_2_0::tools::LevelSetAdvection::getSpatialScheme
math::BiasedGradientScheme getSpatialScheme() const
Definition: LevelSetAdvect.h:121
LevelSetTracker.h
Performs multi-threaded interface tracking of narrow band level sets. This is the building-block for ...
openvdb::v3_2_0::tree::LeafManager::LeafRange
Definition: LeafManager.h:132
VelocityFields.h
Defines two simple wrapper classes for advection velocity fields as well as VelocitySampler and Veloc...
openvdb::v3_2_0::tree::LeafManager::rebuildAuxBuffers
void rebuildAuxBuffers(size_t auxBuffersPerLeaf, bool serial=false)
Change the number of auxiliary buffers.
Definition: LeafManager.h:314
openvdb::v3_2_0::math::Delta
Delta for small floating-point offsets.
Definition: Math.h:132
openvdb::v3_2_0::math::Sqrt
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: Math.h:727
openvdb::v3_2_0::math::SECOND_BIAS
Definition: FiniteDifference.h:195
openvdb::v3_2_0::math::TemporalIntegrationScheme
TemporalIntegrationScheme
Temporal integration schemes.
Definition: FiniteDifference.h:261
openvdb::v3_2_0::math::Min
const Type & Min(const Type &a, const Type &b)
Return the minimum of two values.
Definition: Math.h:622
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
openvdb::v3_2_0::math::FIRST_BIAS
Definition: FiniteDifference.h:194
openvdb::v3_2_0::math::TVD_RK1
Definition: FiniteDifference.h:263
openvdb::v3_2_0::tools::LevelSetAdvection::setTrackerSpatialScheme
void setTrackerSpatialScheme(math::BiasedGradientScheme scheme)
Set the spatial finite difference scheme.
Definition: LevelSetAdvect.h:133
openvdb::v3_2_0::tools::LevelSetTracker::ValueType
TreeType::ValueType ValueType
Definition: LevelSetTracker.h:73
openvdb::v3_2_0::tools::LevelSetAdvection::LevelSetAdvection
LevelSetAdvection(GridT &grid, const FieldT &field, InterruptT *interrupt=NULL)
Main constructor.
Definition: LevelSetAdvect.h:113
openvdb::v3_2_0::math::isZero
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
openvdb::v3_2_0::math::HJWENO5_BIAS
Definition: FiniteDifference.h:198
openvdb::v3_2_0::math::BIAS_SCHEME
Definition: Operators.h:152
openvdb::v3_2_0::tools::LevelSetAdvection::TrackerT
LevelSetTracker< GridT, InterruptT > TrackerT
Definition: LevelSetAdvect.h:105
openvdb::v3_2_0::tools::LevelSetAdvection::setTemporalScheme
void setTemporalScheme(math::TemporalIntegrationScheme scheme)
Set the spatial finite difference scheme.
Definition: LevelSetAdvect.h:128
openvdb::v3_2_0::math::WENO5_BIAS
Definition: FiniteDifference.h:197
openvdb::v3_2_0::tools::LevelSetAdvection::ValueType
TrackerT::ValueType ValueType
Definition: LevelSetAdvect.h:109
openvdb::v3_2_0::tools::LevelSetAdvection::setSpatialScheme
void setSpatialScheme(math::BiasedGradientScheme scheme)
Set the spatial finite difference scheme.
Definition: LevelSetAdvect.h:123
openvdb::v3_2_0::Index
Index32 Index
Definition: Types.h:58
openvdb::v3_2_0::tools::LevelSetAdvection::setNormCount
void setNormCount(int n)
Set the number of normalizations performed per track or normalize call.
Definition: LevelSetAdvect.h:145
openvdb::v3_2_0::tools::LevelSetAdvection::getTrackerSpatialScheme
math::BiasedGradientScheme getTrackerSpatialScheme() const
Definition: LevelSetAdvect.h:131
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_2_0::tools::LevelSetAdvection::setTrackerTemporalScheme
void setTrackerTemporalScheme(math::TemporalIntegrationScheme scheme)
Set the spatial finite difference scheme.
Definition: LevelSetAdvect.h:138
openvdb::v3_2_0::tools::LevelSetAdvection::LeafRange
TrackerT::LeafRange LeafRange
Definition: LevelSetAdvect.h:106
openvdb::v3_2_0::math::Transform
Calculate an axis-aligned bounding box in index space from a bounding sphere in world space...
Definition: Transform.h:66
openvdb::v3_2_0::tools::LevelSetAdvection::getNormCount
int getNormCount() const
Definition: LevelSetAdvect.h:142
openvdb::v3_2_0::math::GradientBiased
Biased gradient operators, defined with respect to the range-space of the map.
Definition: Operators.h:827
openvdb::v3_2_0::tools::LevelSetTracker::leafs
LeafManagerType & leafs()
Definition: LevelSetTracker.h:185
openvdb
Definition: Exceptions.h:39
openvdb::v3_2_0::math::BiasedGradientScheme
BiasedGradientScheme
Biased Gradients are limited to non-centered differences.
Definition: FiniteDifference.h:192
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
openvdb::v3_2_0::tools::LevelSetAdvection::~LevelSetAdvection
virtual ~LevelSetAdvection()
Definition: LevelSetAdvect.h:118
openvdb::v3_2_0::tools::LevelSetTracker::getGrainSize
int getGrainSize() const
Definition: LevelSetTracker.h:168
openvdb::v3_2_0::math::TVD_RK3
Definition: FiniteDifference.h:265
openvdb::v3_2_0::tools::LevelSetAdvection
Hyperbolic advection of narrow-band level sets in an external velocity field.
Definition: LevelSetAdvect.h:101
openvdb::v3_2_0::tools::LevelSetTracker::startInterrupter
void startInterrupter(const char *msg)
Definition: LevelSetTracker.h:358
openvdb::v3_2_0::tools::LevelSetAdvection::GridType
GridT GridType
Definition: LevelSetAdvect.h:104
openvdb::v3_2_0::tree::LeafManager::LeafRange::begin
Iterator begin() const
Definition: LeafManager.h:188
openvdb::v3_2_0::tools::LevelSetAdvection::getTemporalScheme
math::TemporalIntegrationScheme getTemporalScheme() const
Definition: LevelSetAdvect.h:126
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
openvdb::v3_2_0::tools::LevelSetAdvection::getTrackerTemporalScheme
math::TemporalIntegrationScheme getTrackerTemporalScheme() const
Definition: LevelSetAdvect.h:136
openvdb::v3_2_0::tools::LevelSetTracker::grid
const GridType & grid() const
Definition: LevelSetTracker.h:183
openvdb::v3_2_0::tree::LeafManager::LeafRange::Iterator
Definition: LeafManager.h:135
openvdb::v3_2_0::ValueError
Definition: Exceptions.h:88
openvdb::v3_2_0::math::Max
const Type & Max(const Type &a, const Type &b)
Return the maximum of two values.
Definition: Math.h:561
openvdb::v3_2_0::tools::LevelSetTracker::BufferType
LeafManagerType::BufferType BufferType
Definition: LevelSetTracker.h:76
openvdb::v3_2_0::math::isApproxZero
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance...
Definition: Math.h:336
openvdb::v3_2_0::tools::LevelSetAdvection::getGrainSize
int getGrainSize() const
Definition: LevelSetAdvect.h:148
openvdb::v3_2_0::tools::LevelSetAdvection::VectorType
FieldT::VectorType VectorType
Definition: LevelSetAdvect.h:110
openvdb::v3_2_0::tools::LevelSetAdvection::setGrainSize
void setGrainSize(int grainsize)
Set the grain-size used for multi-threading.
Definition: LevelSetAdvect.h:151
CpuTimer.h
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_2_0::math::THIRD_BIAS
Definition: FiniteDifference.h:196
openvdb::v3_2_0::tools::LevelSetTracker
Performs multi-threaded interface tracking of narrow band level sets.
Definition: LevelSetTracker.h:67
openvdb::v3_2_0::math::TVD_RK2
Definition: FiniteDifference.h:264
openvdb::v3_2_0::tools::LevelSetTracker::LeafType
TreeType::LeafNodeType LeafType
Definition: LevelSetTracker.h:72
openvdb::v3_2_0::tools::LevelSetAdvection::LeafType
TrackerT::LeafType LeafType
Definition: LevelSetAdvect.h:107
openvdb::v3_2_0::math::Transform::mapType
Name mapType() const
Return the transformation map&#39;s type-name.
Definition: Transform.h:93
Platform.h