OpenVDB 12.0.0
 
Loading...
Searching...
No Matches
LevelSetAdvect.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4/// @author Ken Museth
5///
6/// @file tools/LevelSetAdvect.h
7///
8/// @brief Hyperbolic advection of narrow-band level sets
9
10#ifndef OPENVDB_TOOLS_LEVEL_SET_ADVECT_HAS_BEEN_INCLUDED
11#define OPENVDB_TOOLS_LEVEL_SET_ADVECT_HAS_BEEN_INCLUDED
12
13#include <tbb/parallel_for.h>
14#include <tbb/parallel_reduce.h>
15#include "LevelSetTracker.h"
16#include "VelocityFields.h" // for EnrightField
17#include <openvdb/Platform.h>
19#include <openvdb/util/Assert.h>
20//#include <openvdb/util/CpuTimer.h>
21#include <functional>
22
23
24namespace openvdb {
26namespace OPENVDB_VERSION_NAME {
27namespace tools {
28
29/// @brief Hyperbolic advection of narrow-band level sets in an
30/// external velocity field
31///
32/// The @c FieldType template argument below refers to any functor
33/// with the following interface (see tools/VelocityFields.h
34/// for examples):
35///
36/// @code
37/// class VelocityField {
38/// ...
39/// public:
40/// openvdb::VectorType operator() (const openvdb::Coord& xyz, ValueType time) const;
41/// ...
42/// };
43/// @endcode
44///
45/// @note The functor method returns the velocity field at coordinate
46/// position xyz of the advection grid, and for the specified
47/// time. Note that since the velocity is returned in the local
48/// coordinate space of the grid that is being advected, the functor
49/// typically depends on the transformation of that grid. This design
50/// is chosen for performance reasons. Finally we will assume that the
51/// functor method is NOT threadsafe (typically uses a ValueAccessor)
52/// and that its lightweight enough that we can copy it per thread.
53///
54/// The @c InterruptType template argument below refers to any class
55/// with the following interface:
56/// @code
57/// class Interrupter {
58/// ...
59/// public:
60/// void start(const char* name = nullptr) // called when computations begin
61/// void end() // called when computations end
62/// bool wasInterrupted(int percent=-1) // return true to break computation
63///};
64/// @endcode
65///
66/// @note If no template argument is provided for this InterruptType
67/// the util::NullInterrupter is used which implies that all
68/// interrupter calls are no-ops (i.e. incurs no computational overhead).
69///
70
71template<typename GridT,
72 typename FieldT = EnrightField<typename GridT::ValueType>,
73 typename InterruptT = util::NullInterrupter>
75{
76public:
77 using GridType = GridT;
80 using LeafType = typename TrackerT::LeafType;
83 using VectorType = typename FieldT::VectorType;
84
85 /// Main constructor
86 LevelSetAdvection(GridT& grid, const FieldT& field, InterruptT* interrupt = nullptr):
87 mTracker(grid, interrupt), mField(field),
88 mSpatialScheme(math::HJWENO5_BIAS),
89 mTemporalScheme(math::TVD_RK2) {}
90
91 virtual ~LevelSetAdvection() {}
92
93 /// @brief Return the spatial finite difference scheme
94 math::BiasedGradientScheme getSpatialScheme() const { return mSpatialScheme; }
95 /// @brief Set the spatial finite difference scheme
96 void setSpatialScheme(math::BiasedGradientScheme scheme) { mSpatialScheme = scheme; }
97
98 /// @brief Return the temporal integration scheme
99 math::TemporalIntegrationScheme getTemporalScheme() const { return mTemporalScheme; }
100 /// @brief Set the spatial finite difference scheme
101 void setTemporalScheme(math::TemporalIntegrationScheme scheme) { mTemporalScheme = scheme; }
102
103 /// @brief Return the spatial finite difference scheme
105 return mTracker.getSpatialScheme();
106 }
107 /// @brief Set the spatial finite difference scheme
109 mTracker.setSpatialScheme(scheme);
110 }
111 /// @brief Return the temporal integration scheme
113 return mTracker.getTemporalScheme();
114 }
115 /// @brief Set the spatial finite difference scheme
117 mTracker.setTemporalScheme(scheme);
118 }
119
120 /// @brief Return The number of normalizations performed per track or
121 /// normalize call.
122 int getNormCount() const { return mTracker.getNormCount(); }
123 /// @brief Set the number of normalizations performed per track or
124 /// normalize call.
125 void setNormCount(int n) { mTracker.setNormCount(n); }
126
127 /// @brief Return the grain-size used for multi-threading
128 int getGrainSize() const { return mTracker.getGrainSize(); }
129 /// @brief Set the grain-size used for multi-threading.
130 /// @note A grain size of 0 or less disables multi-threading!
131 void setGrainSize(int grainsize) { mTracker.setGrainSize(grainsize); }
132
133 /// Advect the level set from its current time, time0, to its
134 /// final time, time1. If time0>time1 backward advection is performed.
135 ///
136 /// @return number of CFL iterations used to advect from time0 to time1
137 size_t advect(ValueType time0, ValueType time1);
138
139private:
140 // disallow copy construction and copy by assignment!
141 LevelSetAdvection(const LevelSetAdvection&);// not implemented
142 LevelSetAdvection& operator=(const LevelSetAdvection&);// not implemented
143
144 // This templated private struct implements all the level set magic.
145 template<typename MapT, math::BiasedGradientScheme SpatialScheme,
146 math::TemporalIntegrationScheme TemporalScheme>
147 struct Advect
148 {
149 /// Main constructor
150 Advect(LevelSetAdvection& parent);
151 /// Shallow copy constructor called by tbb::parallel_for() threads
152 Advect(const Advect& other);
153 /// Destructor
154 virtual ~Advect() { if (mIsMaster) this->clearField(); }
155 /// Advect the level set from its current time, time0, to its final time, time1.
156 /// @return number of CFL iterations
157 size_t advect(ValueType time0, ValueType time1);
158 /// Used internally by tbb::parallel_for()
159 void operator()(const LeafRange& r) const
160 {
161 if (mTask) mTask(const_cast<Advect*>(this), r);
162 else OPENVDB_THROW(ValueError, "task is undefined - don\'t call this method directly");
163 }
164 /// method calling tbb
165 void cook(const char* msg, size_t swapBuffer = 0);
166 /// Sample field and return the CFL time step
167 typename GridT::ValueType sampleField(ValueType time0, ValueType time1);
168 template <bool Aligned> void sample(const LeafRange& r, ValueType t0, ValueType t1);
169 inline void sampleXformed(const LeafRange& r, ValueType t0, ValueType t1)
170 {
171 this->sample<false>(r, t0, t1);
172 }
173 inline void sampleAligned(const LeafRange& r, ValueType t0, ValueType t1)
174 {
175 this->sample<true>(r, t0, t1);
176 }
177 void clearField();
178 // Convex combination of Phi and a forward Euler advection steps:
179 // Phi(result) = alpha * Phi(phi) + (1-alpha) * (Phi(0) - dt * Speed(speed)*|Grad[Phi(0)]|);
180 template <int Nominator, int Denominator>
181 void euler(const LeafRange&, ValueType, Index, Index);
182 inline void euler01(const LeafRange& r, ValueType t) {this->euler<0,1>(r, t, 0, 1);}
183 inline void euler12(const LeafRange& r, ValueType t) {this->euler<1,2>(r, t, 1, 1);}
184 inline void euler34(const LeafRange& r, ValueType t) {this->euler<3,4>(r, t, 1, 2);}
185 inline void euler13(const LeafRange& r, ValueType t) {this->euler<1,3>(r, t, 1, 2);}
186
187 LevelSetAdvection& mParent;
188 VectorType* mVelocity;
189 size_t* mOffsets;
190 const MapT* mMap;
191 typename std::function<void (Advect*, const LeafRange&)> mTask;
192 const bool mIsMaster;
193 }; // end of private Advect struct
194
195 template<math::BiasedGradientScheme SpatialScheme>
196 size_t advect1(ValueType time0, ValueType time1);
197
198 template<math::BiasedGradientScheme SpatialScheme,
199 math::TemporalIntegrationScheme TemporalScheme>
200 size_t advect2(ValueType time0, ValueType time1);
201
202 template<math::BiasedGradientScheme SpatialScheme,
203 math::TemporalIntegrationScheme TemporalScheme,
204 typename MapType>
205 size_t advect3(ValueType time0, ValueType time1);
206
207 TrackerT mTracker;
208 //each thread needs a deep copy of the field since it might contain a ValueAccessor
209 const FieldT mField;
210 math::BiasedGradientScheme mSpatialScheme;
211 math::TemporalIntegrationScheme mTemporalScheme;
212
213};//end of LevelSetAdvection
214
215
216template<typename GridT, typename FieldT, typename InterruptT>
217size_t
219{
220 switch (mSpatialScheme) {
221 case math::FIRST_BIAS:
222 return this->advect1<math::FIRST_BIAS >(time0, time1);
224 return this->advect1<math::SECOND_BIAS >(time0, time1);
225 case math::THIRD_BIAS:
226 return this->advect1<math::THIRD_BIAS >(time0, time1);
227 case math::WENO5_BIAS:
228 return this->advect1<math::WENO5_BIAS >(time0, time1);
230 return this->advect1<math::HJWENO5_BIAS>(time0, time1);
231 default:
232 OPENVDB_THROW(ValueError, "Spatial difference scheme not supported!");
233 }
234 return 0;
235}
236
237
238template<typename GridT, typename FieldT, typename InterruptT>
239template<math::BiasedGradientScheme SpatialScheme>
240size_t
241LevelSetAdvection<GridT, FieldT, InterruptT>::advect1(ValueType time0, ValueType time1)
242{
243 switch (mTemporalScheme) {
244 case math::TVD_RK1:
245 return this->advect2<SpatialScheme, math::TVD_RK1>(time0, time1);
246 case math::TVD_RK2:
247 return this->advect2<SpatialScheme, math::TVD_RK2>(time0, time1);
248 case math::TVD_RK3:
249 return this->advect2<SpatialScheme, math::TVD_RK3>(time0, time1);
250 default:
251 OPENVDB_THROW(ValueError, "Temporal integration scheme not supported!");
252 }
253 return 0;
254}
255
256
257template<typename GridT, typename FieldT, typename InterruptT>
258template<math::BiasedGradientScheme SpatialScheme, math::TemporalIntegrationScheme TemporalScheme>
259size_t
260LevelSetAdvection<GridT, FieldT, InterruptT>::advect2(ValueType time0, ValueType time1)
261{
262 const math::Transform& trans = mTracker.grid().transform();
263 if (trans.mapType() == math::UniformScaleMap::mapType()) {
264 return this->advect3<SpatialScheme, TemporalScheme, math::UniformScaleMap>(time0, time1);
265 } else if (trans.mapType() == math::UniformScaleTranslateMap::mapType()) {
266 return this->advect3<SpatialScheme, TemporalScheme, math::UniformScaleTranslateMap>(
267 time0, time1);
268 } else if (trans.mapType() == math::UnitaryMap::mapType()) {
269 return this->advect3<SpatialScheme, TemporalScheme, math::UnitaryMap >(time0, time1);
270 } else if (trans.mapType() == math::TranslationMap::mapType()) {
271 return this->advect3<SpatialScheme, TemporalScheme, math::TranslationMap>(time0, time1);
272 } else {
273 OPENVDB_THROW(ValueError, "MapType not supported!");
274 }
275 return 0;
276}
277
278
279template<typename GridT, typename FieldT, typename InterruptT>
280template<
281 math::BiasedGradientScheme SpatialScheme,
282 math::TemporalIntegrationScheme TemporalScheme,
283 typename MapT>
284size_t
285LevelSetAdvection<GridT, FieldT, InterruptT>::advect3(ValueType time0, ValueType time1)
286{
287 Advect<MapT, SpatialScheme, TemporalScheme> tmp(*this);
288 return tmp.advect(time0, time1);
289}
290
291
292///////////////////////////////////////////////////////////////////////
293
294
295template<typename GridT, typename FieldT, typename InterruptT>
296template<
297 typename MapT,
298 math::BiasedGradientScheme SpatialScheme,
299 math::TemporalIntegrationScheme TemporalScheme>
300inline
301LevelSetAdvection<GridT, FieldT, InterruptT>::
302Advect<MapT, SpatialScheme, TemporalScheme>::
303Advect(LevelSetAdvection& parent)
304 : mParent(parent)
305 , mVelocity(nullptr)
306 , mOffsets(nullptr)
307 , mMap(parent.mTracker.grid().transform().template constMap<MapT>().get())
308 , mTask(0)
309 , mIsMaster(true)
310{
311}
312
313
314template<typename GridT, typename FieldT, typename InterruptT>
315template<
316 typename MapT,
317 math::BiasedGradientScheme SpatialScheme,
318 math::TemporalIntegrationScheme TemporalScheme>
319inline
322Advect(const Advect& other)
323 : mParent(other.mParent)
324 , mVelocity(other.mVelocity)
325 , mOffsets(other.mOffsets)
326 , mMap(other.mMap)
327 , mTask(other.mTask)
328 , mIsMaster(false)
329{
330}
331
332
333template<typename GridT, typename FieldT, typename InterruptT>
334template<
335 typename MapT,
336 math::BiasedGradientScheme SpatialScheme,
337 math::TemporalIntegrationScheme TemporalScheme>
338inline size_t
341advect(ValueType time0, ValueType time1)
342{
343 namespace ph = std::placeholders;
344
345 //util::CpuTimer timer;
346 size_t countCFL = 0;
347 if ( math::isZero(time0 - time1) ) return countCFL;
348 const bool isForward = time0 < time1;
349 while ((isForward ? time0<time1 : time0>time1) && mParent.mTracker.checkInterrupter()) {
350 /// Make sure we have enough temporal auxiliary buffers
351 //timer.start( "\nallocate buffers" );
352 mParent.mTracker.leafs().rebuildAuxBuffers(TemporalScheme == math::TVD_RK3 ? 2 : 1);
353 //timer.stop();
354
355 const ValueType dt = this->sampleField(time0, time1);
356 if ( math::isZero(dt) ) break;//V is essentially zero so terminate
357
358 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN //switch is resolved at compile-time
359 switch(TemporalScheme) {
360 case math::TVD_RK1:
361 // Perform one explicit Euler step: t1 = t0 + dt
362 // Phi_t1(1) = Phi_t0(0) - dt * VdotG_t0(0)
363 mTask = std::bind(&Advect::euler01, ph::_1, ph::_2, dt);
364
365 // Cook and swap buffer 0 and 1 such that Phi_t1(0) and Phi_t0(1)
366 this->cook("Advecting level set using TVD_RK1", 1);
367 break;
368 case math::TVD_RK2:
369 // Perform one explicit Euler step: t1 = t0 + dt
370 // Phi_t1(1) = Phi_t0(0) - dt * VdotG_t0(0)
371 mTask = std::bind(&Advect::euler01, ph::_1, ph::_2, dt);
372
373 // Cook and swap buffer 0 and 1 such that Phi_t1(0) and Phi_t0(1)
374 this->cook("Advecting level set using TVD_RK1 (step 1 of 2)", 1);
375
376 // Convex combine explict Euler step: t2 = t0 + dt
377 // Phi_t2(1) = 1/2 * Phi_t0(1) + 1/2 * (Phi_t1(0) - dt * V.Grad_t1(0))
378 mTask = std::bind(&Advect::euler12, ph::_1, ph::_2, dt);
379
380 // Cook and swap buffer 0 and 1 such that Phi_t2(0) and Phi_t1(1)
381 this->cook("Advecting level set using TVD_RK1 (step 2 of 2)", 1);
382 break;
383 case math::TVD_RK3:
384 // Perform one explicit Euler step: t1 = t0 + dt
385 // Phi_t1(1) = Phi_t0(0) - dt * VdotG_t0(0)
386 mTask = std::bind(&Advect::euler01, ph::_1, ph::_2, dt);
387
388 // Cook and swap buffer 0 and 1 such that Phi_t1(0) and Phi_t0(1)
389 this->cook("Advecting level set using TVD_RK3 (step 1 of 3)", 1);
390
391 // Convex combine explict Euler step: t2 = t0 + dt/2
392 // Phi_t2(2) = 3/4 * Phi_t0(1) + 1/4 * (Phi_t1(0) - dt * V.Grad_t1(0))
393 mTask = std::bind(&Advect::euler34, ph::_1, ph::_2, dt);
394
395 // Cook and swap buffer 0 and 2 such that Phi_t2(0) and Phi_t1(2)
396 this->cook("Advecting level set using TVD_RK3 (step 2 of 3)", 2);
397
398 // Convex combine explict Euler step: t3 = t0 + dt
399 // Phi_t3(2) = 1/3 * Phi_t0(1) + 2/3 * (Phi_t2(0) - dt * V.Grad_t2(0)
400 mTask = std::bind(&Advect::euler13, ph::_1, ph::_2, dt);
401
402 // Cook and swap buffer 0 and 2 such that Phi_t3(0) and Phi_t2(2)
403 this->cook("Advecting level set using TVD_RK3 (step 3 of 3)", 2);
404 break;
405 default:
406 OPENVDB_THROW(ValueError, "Temporal integration scheme not supported!");
407 }//end of compile-time resolved switch
409
410 time0 += isForward ? dt : -dt;
411 ++countCFL;
412 mParent.mTracker.leafs().removeAuxBuffers();
413 this->clearField();
414 /// Track the narrow band
415 mParent.mTracker.track();
416 }//end wile-loop over time
417 return countCFL;//number of CLF propagation steps
418}
419
420
421template<typename GridT, typename FieldT, typename InterruptT>
422template<
423 typename MapT,
424 math::BiasedGradientScheme SpatialScheme,
425 math::TemporalIntegrationScheme TemporalScheme>
426inline typename GridT::ValueType
429sampleField(ValueType time0, ValueType time1)
430{
431 namespace ph = std::placeholders;
432
433 const int grainSize = mParent.mTracker.getGrainSize();
434 const size_t leafCount = mParent.mTracker.leafs().leafCount();
435 if (leafCount==0) return ValueType(0.0);
436
437 // Compute the prefix sum of offsets to active voxels
438 size_t size=0, voxelCount=mParent.mTracker.leafs().getPrefixSum(mOffsets, size, grainSize);
439
440 // Sample the velocity field
441 if (mParent.mField.transform() == mParent.mTracker.grid().transform()) {
442 mTask = std::bind(&Advect::sampleAligned, ph::_1, ph::_2, time0, time1);
443 } else {
444 mTask = std::bind(&Advect::sampleXformed, ph::_1, ph::_2, time0, time1);
445 }
446 OPENVDB_ASSERT(voxelCount == mParent.mTracker.grid().activeVoxelCount());
447 mVelocity = new VectorType[ voxelCount ];
448 this->cook("Sampling advection field");
449
450 // Find the extrema of the magnitude of the velocities
451 ValueType maxAbsV = 0;
452 VectorType* v = mVelocity;
453 for (size_t i = 0; i < voxelCount; ++i, ++v) {
454 maxAbsV = math::Max(maxAbsV, ValueType(v->lengthSqr()));
455 }
456
457 // Compute the CFL number
458 if (math::isApproxZero(maxAbsV, math::Delta<ValueType>::value())) return ValueType(0);
459 static const ValueType CFL = (TemporalScheme == math::TVD_RK1 ? ValueType(0.3) :
460 TemporalScheme == math::TVD_RK2 ? ValueType(0.9) :
461 ValueType(1.0))/math::Sqrt(ValueType(3.0));
462 const ValueType dt = math::Abs(time1 - time0), dx = mParent.mTracker.voxelSize();
463 return math::Min(dt, ValueType(CFL*dx/math::Sqrt(maxAbsV)));
464}
465
466
467template<typename GridT, typename FieldT, typename InterruptT>
468template<
469 typename MapT,
470 math::BiasedGradientScheme SpatialScheme,
471 math::TemporalIntegrationScheme TemporalScheme>
472template<bool Aligned>
473inline void
476sample(const LeafRange& range, ValueType time0, ValueType time1)
477{
478 const bool isForward = time0 < time1;
479 using VoxelIterT = typename LeafType::ValueOnCIter;
480 const MapT& map = *mMap;
481 const FieldT field( mParent.mField );
482 mParent.mTracker.checkInterrupter();
483 for (typename LeafRange::Iterator leafIter = range.begin(); leafIter; ++leafIter) {
484 VectorType* vel = mVelocity + mOffsets[ leafIter.pos() ];
485 for (VoxelIterT iter = leafIter->cbeginValueOn(); iter; ++iter, ++vel) {
487 const VectorType v = Aligned ? field(iter.getCoord(), time0) ://resolved at compile time
488 field(map.applyMap(iter.getCoord().asVec3d()), time0);
489 *vel = isForward ? v : -v;
491 }
492 }
493}
494
495
496template<typename GridT, typename FieldT, typename InterruptT>
497template<
498 typename MapT,
499 math::BiasedGradientScheme SpatialScheme,
500 math::TemporalIntegrationScheme TemporalScheme>
501inline void
505{
506 delete [] mOffsets;
507 delete [] mVelocity;
508 mOffsets = nullptr;
509 mVelocity = nullptr;
510}
511
512
513template<typename GridT, typename FieldT, typename InterruptT>
514template<
515 typename MapT,
516 math::BiasedGradientScheme SpatialScheme,
517 math::TemporalIntegrationScheme TemporalScheme>
518inline void
521cook(const char* msg, size_t swapBuffer)
522{
523 mParent.mTracker.startInterrupter( msg );
524
525 const int grainSize = mParent.mTracker.getGrainSize();
526 const LeafRange range = mParent.mTracker.leafs().leafRange(grainSize);
527
528 grainSize == 0 ? (*this)(range) : tbb::parallel_for(range, *this);
529
530 mParent.mTracker.leafs().swapLeafBuffer(swapBuffer, grainSize == 0);
531
532 mParent.mTracker.endInterrupter();
533}
534
535
536// Convex combination of Phi and a forward Euler advection steps:
537// Phi(result) = alpha * Phi(phi) + (1-alpha) * (Phi(0) - dt * V.Grad(0));
538template<typename GridT, typename FieldT, typename InterruptT>
539template<
540 typename MapT,
541 math::BiasedGradientScheme SpatialScheme,
542 math::TemporalIntegrationScheme TemporalScheme>
543template <int Nominator, int Denominator>
544inline void
547euler(const LeafRange& range, ValueType dt, Index phiBuffer, Index resultBuffer)
548{
549 using SchemeT = math::BIAS_SCHEME<SpatialScheme>;
550 using StencilT = typename SchemeT::template ISStencil<GridType>::StencilType;
551 using VoxelIterT = typename LeafType::ValueOnCIter;
552 using GradT = math::GradientBiased<MapT, SpatialScheme>;
553
554 static const ValueType Alpha = ValueType(Nominator)/ValueType(Denominator);
555 static const ValueType Beta = ValueType(1) - Alpha;
556
557 mParent.mTracker.checkInterrupter();
558 const MapT& map = *mMap;
559 StencilT stencil(mParent.mTracker.grid());
560 for (typename LeafRange::Iterator leafIter = range.begin(); leafIter; ++leafIter) {
561 const VectorType* vel = mVelocity + mOffsets[ leafIter.pos() ];
562 const ValueType* phi = leafIter.buffer(phiBuffer).data();
563 ValueType* result = leafIter.buffer(resultBuffer).data();
564 for (VoxelIterT voxelIter = leafIter->cbeginValueOn(); voxelIter; ++voxelIter, ++vel) {
565 const Index i = voxelIter.pos();
566 stencil.moveTo(voxelIter);
567 const ValueType a =
568 stencil.getValue() - dt * vel->dot(GradT::result(map, stencil, *vel));
569 result[i] = Nominator ? Alpha * phi[i] + Beta * a : a;
570 }//loop over active voxels in the leaf of the mask
571 }//loop over leafs of the level set
572}
573
574
575////////////////////////////////////////
576
577
578// Explicit Template Instantiation
579
580#ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
581
582#ifdef OPENVDB_INSTANTIATE_LEVELSETADVECT
584#endif
585
588
589#endif // OPENVDB_USE_EXPLICIT_INSTANTIATION
590
591
592} // namespace tools
593} // namespace OPENVDB_VERSION_NAME
594} // namespace openvdb
595
596#endif // OPENVDB_TOOLS_LEVEL_SET_ADVECT_HAS_BEEN_INCLUDED
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
Performs multi-threaded interface tracking of narrow band level sets. This is the building-block for ...
#define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
Bracket code with OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN/_END, to inhibit warnings about type conve...
Definition Platform.h:221
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition Platform.h:141
#define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
Definition Platform.h:222
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition Platform.h:140
Defines two simple wrapper classes for advection velocity fields as well as VelocitySampler and Veloc...
Definition Exceptions.h:65
Definition Transform.h:40
Name mapType() const
Return the transformation map's type-name.
Definition Transform.h:66
static Name mapType()
Definition Maps.h:936
Hyperbolic advection of narrow-band level sets in an external velocity field.
Definition LevelSetAdvect.h:75
typename TrackerT::LeafRange LeafRange
Definition LevelSetAdvect.h:79
void setTrackerSpatialScheme(math::BiasedGradientScheme scheme)
Set the spatial finite difference scheme.
Definition LevelSetAdvect.h:108
math::BiasedGradientScheme getTrackerSpatialScheme() const
Return the spatial finite difference scheme.
Definition LevelSetAdvect.h:104
void setTrackerTemporalScheme(math::TemporalIntegrationScheme scheme)
Set the spatial finite difference scheme.
Definition LevelSetAdvect.h:116
typename TrackerT::ValueType ValueType
Definition LevelSetAdvect.h:82
math::TemporalIntegrationScheme getTemporalScheme() const
Return the temporal integration scheme.
Definition LevelSetAdvect.h:99
typename TrackerT::BufferType BufferType
Definition LevelSetAdvect.h:81
void setTemporalScheme(math::TemporalIntegrationScheme scheme)
Set the spatial finite difference scheme.
Definition LevelSetAdvect.h:101
void setSpatialScheme(math::BiasedGradientScheme scheme)
Set the spatial finite difference scheme.
Definition LevelSetAdvect.h:96
math::BiasedGradientScheme getSpatialScheme() const
Return the spatial finite difference scheme.
Definition LevelSetAdvect.h:94
void setGrainSize(int grainsize)
Set the grain-size used for multi-threading.
Definition LevelSetAdvect.h:131
LevelSetAdvection(GridT &grid, const FieldT &field, InterruptT *interrupt=nullptr)
Main constructor.
Definition LevelSetAdvect.h:86
typename FieldT::VectorType VectorType
Definition LevelSetAdvect.h:83
int getGrainSize() const
Return the grain-size used for multi-threading.
Definition LevelSetAdvect.h:128
void setNormCount(int n)
Set the number of normalizations performed per track or normalize call.
Definition LevelSetAdvect.h:125
typename TrackerT::LeafType LeafType
Definition LevelSetAdvect.h:80
LevelSetTracker< GridT, InterruptT > TrackerT
Definition LevelSetAdvect.h:78
math::TemporalIntegrationScheme getTrackerTemporalScheme() const
Return the temporal integration scheme.
Definition LevelSetAdvect.h:112
virtual ~LevelSetAdvection()
Definition LevelSetAdvect.h:91
size_t advect(ValueType time0, ValueType time1)
Definition LevelSetAdvect.h:218
GridT GridType
Definition LevelSetAdvect.h:77
int getNormCount() const
Return The number of normalizations performed per track or normalize call.
Definition LevelSetAdvect.h:122
Performs multi-threaded interface tracking of narrow band level sets.
Definition LevelSetTracker.h:58
typename TreeType::ValueType ValueType
Definition LevelSetTracker.h:65
int getGrainSize() const
Definition LevelSetTracker.h:164
void startInterrupter(const char *msg)
Definition LevelSetTracker.h:369
typename LeafManagerType::LeafRange LeafRange
Definition LevelSetTracker.h:67
typename LeafManagerType::BufferType BufferType
Definition LevelSetTracker.h:68
typename TreeType::LeafNodeType LeafType
Definition LevelSetTracker.h:64
Definition Types.h:28
TemporalIntegrationScheme
Temporal integration schemes.
Definition FiniteDifference.h:233
@ TVD_RK1
Definition FiniteDifference.h:235
@ TVD_RK2
Definition FiniteDifference.h:236
@ TVD_RK3
Definition FiniteDifference.h:237
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance.
Definition Math.h:349
float Sqrt(float x)
Return the square root of a floating-point value.
Definition Math.h:761
const Type & Max(const Type &a, const Type &b)
Return the maximum of two values.
Definition Math.h:595
BiasedGradientScheme
Biased Gradients are limited to non-centered differences.
Definition FiniteDifference.h:164
@ FIRST_BIAS
Definition FiniteDifference.h:166
@ THIRD_BIAS
Definition FiniteDifference.h:168
@ WENO5_BIAS
Definition FiniteDifference.h:169
@ SECOND_BIAS
Definition FiniteDifference.h:167
@ HJWENO5_BIAS
Definition FiniteDifference.h:170
const Type & Min(const Type &a, const Type &b)
Return the minimum of two values.
Definition Math.h:656
Coord Abs(const Coord &xyz)
Definition Coord.h:518
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition Math.h:337
Index32 Index
Definition Types.h:54
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
static T value()
Definition Math.h:155
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218
#define OPENVDB_INSTANTIATE_CLASS
Definition version.h.in:158