Go to the documentation of this file.
25 #ifndef OPENVDB_TOOLS_VELOCITY_FIELDS_HAS_BEEN_INCLUDED
26 #define OPENVDB_TOOLS_VELOCITY_FIELDS_HAS_BEEN_INCLUDED
28 #include <tbb/parallel_reduce.h>
33 #include <boost/math/constants/constants.hpp>
42 template <
typename VelGr
idT,
typename Interpolator = BoxSampler>
51 : mAccessor(vel.tree())
52 , mTransform(&vel.transform())
58 : mAccessor(other.mAccessor.tree())
59 , mTransform(other.mTransform)
74 return Interpolator::sample(mAccessor, mTransform->worldToIndex(xyz));
83 return mAccessor.getValue(ijk);
87 const typename VelGridT::ConstAccessor mAccessor;
100 template <
typename ScalarT =
float>
122 return (*
this)(ijk.
asVec3d(), time);
126 template <
typename ScalarT>
130 const ScalarT pi = boost::math::constants::pi<ScalarT>();
131 const ScalarT phase = pi / ScalarT(3);
132 const ScalarT Px = pi * ScalarT(xyz[0]), Py = pi * ScalarT(xyz[1]), Pz = pi * ScalarT(xyz[2]);
133 const ScalarT tr =
math::Cos(ScalarT(time) * phase);
134 const ScalarT a =
math::Sin(ScalarT(2)*Py);
135 const ScalarT b = -
math::Sin(ScalarT(2)*Px);
136 const ScalarT c =
math::Sin(ScalarT(2)*Pz);
150 bool Staggered =
false,
161 mAcc(grid.getAccessor())
167 mAcc(mGrid->getAccessor())
177 template <
typename LocationType>
180 const Vec3R xyz = mGrid->worldToIndex(
Vec3R(world[0], world[1], world[2]));
190 template <
typename LocationType>
193 const Vec3R xyz = mGrid->worldToIndex(
Vec3R(world[0], world[1], world[2]));
212 bool Staggered =
false,
213 size_t SampleOrder = 1>
228 template<
size_t OrderRK,
typename LocationType>
231 BOOST_STATIC_ASSERT(OrderRK <= 4);
238 }
else if (OrderRK == 1) {
240 mVelSampler.sample(P, V0);
242 }
else if (OrderRK == 2) {
244 mVelSampler.sample(P, V0);
245 mVelSampler.sample(P +
ElementType(0.5) * dt * V0, V1);
247 }
else if (OrderRK == 3) {
249 mVelSampler.sample(P, V0);
250 mVelSampler.sample(P +
ElementType(0.5) * dt * V0, V1);
251 mVelSampler.sample(P + dt * (
ElementType(2.0) * V1 - V0), V2);
253 }
else if (OrderRK == 4) {
255 mVelSampler.sample(P, V0);
256 mVelSampler.sample(P +
ElementType(0.5) * dt * V0, V1);
257 mVelSampler.sample(P +
ElementType(0.5) * dt * V1, V2);
258 mVelSampler.sample(P + dt * V2, V3);
261 typedef typename LocationType::ValueType OutType;
262 world += LocationType(
static_cast<OutType
>(P[0]),
263 static_cast<OutType
>(P[1]),
264 static_cast<OutType
>(P[2]));
275 #endif // OPENVDB_TOOLS_VELOCITY_FIELDS_HAS_BEEN_INCLUDED
Vec3SGrid Vec3fGrid
Definition: openvdb.h:56
math::Vec3< Real > Vec3R
Definition: Types.h:49
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
float Cos(const float &x)
Return cos x.
Definition: Math.h:672
Vec3< double > Vec3d
Definition: Vec3.h:662
Type Pow2(Type x)
Return x2.
Definition: Math.h:495
float Sin(const float &x)
Return sin x.
Definition: Math.h:663
Vec3d asVec3d() const
Definition: Coord.h:144
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
Definition: Exceptions.h:13