25#ifndef OPENVDB_TOOLS_VELOCITY_FIELDS_HAS_BEEN_INCLUDED
26#define OPENVDB_TOOLS_VELOCITY_FIELDS_HAS_BEEN_INCLUDED
28#include <boost/static_assert.hpp>
29#include <tbb/parallel_reduce.h>
42template <
typename VelGr
idT,
typename Interpolator = BoxSampler>
48 static_assert(std::is_floating_point<ValueType>::value,
49 "DiscreteField requires a floating point grid.");
52 : mAccessor(vel.tree())
53 , mTransform(&vel.transform())
59 : mAccessor(other.mAccessor.tree())
60 , mTransform(other.mTransform)
75 return Interpolator::sample(mAccessor, mTransform->worldToIndex(xyz));
84 return mAccessor.getValue(ijk);
88 const typename VelGridT::ConstAccessor mAccessor;
101template <
typename ScalarT =
float>
107 static_assert(std::is_floating_point<ScalarT>::value,
108 "EnrightField requires a floating point grid.");
124 return (*
this)(ijk.
asVec3d(), time);
128template <
typename ScalarT>
132 const ScalarT pi = math::pi<ScalarT>();
133 const ScalarT phase = pi / ScalarT(3);
134 const ScalarT Px = pi * ScalarT(xyz[0]), Py = pi * ScalarT(xyz[1]), Pz = pi * ScalarT(xyz[2]);
135 const ScalarT tr = math::Cos(ScalarT(time) * phase);
136 const ScalarT a = math::Sin(ScalarT(2)*Py);
137 const ScalarT b = -math::Sin(ScalarT(2)*Px);
138 const ScalarT c = math::Sin(ScalarT(2)*Pz);
140 tr * ( ScalarT(2) * math::Pow2(math::Sin(Px)) * a * c ),
141 tr * ( b * math::Pow2(math::Sin(Py)) * c ),
142 tr * ( b * a * math::Pow2(math::Sin(Pz)) ));
152 bool Staggered =
false,
163 mAcc(grid.getAccessor())
169 mAcc(mGrid->getAccessor())
179 template <
typename LocationType>
182 const Vec3R xyz = mGrid->worldToIndex(
Vec3R(world[0], world[1], world[2]));
192 template <
typename LocationType>
195 const Vec3R xyz = mGrid->worldToIndex(
Vec3R(world[0], world[1], world[2]));
214 bool Staggered =
false,
215 size_t SampleOrder = 1>
230 template<
size_t OrderRK,
typename LocationType>
233 BOOST_STATIC_ASSERT(OrderRK <= 4);
240 }
else if (OrderRK == 1) {
242 mVelSampler.sample(P, V0);
244 }
else if (OrderRK == 2) {
246 mVelSampler.sample(P, V0);
247 mVelSampler.sample(P +
ElementType(0.5) * dt * V0, V1);
249 }
else if (OrderRK == 3) {
251 mVelSampler.sample(P, V0);
252 mVelSampler.sample(P +
ElementType(0.5) * dt * V0, V1);
253 mVelSampler.sample(P + dt * (
ElementType(2.0) * V1 - V0), V2);
255 }
else if (OrderRK == 4) {
257 mVelSampler.sample(P, V0);
258 mVelSampler.sample(P +
ElementType(0.5) * dt * V0, V1);
259 mVelSampler.sample(P +
ElementType(0.5) * dt * V1, V2);
260 mVelSampler.sample(P + dt * V2, V3);
263 typedef typename LocationType::ValueType OutType;
264 world += LocationType(
static_cast<OutType
>(P[0]),
265 static_cast<OutType
>(P[1]),
266 static_cast<OutType
>(P[2]));
Container class that associates a tree with a transform and metadata.
Definition Grid.h:571
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:25
Vec3d asVec3d() const
Definition Coord.h:143
Definition Exceptions.h:13
#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:212