11 #ifndef __SIM_RawField__
12 #define __SIM_RawField__
128 int xres,
int yres,
int zres);
131 int xres,
int yres,
int zres,
153 return field()->numTiles() > 1;
163 void makeConstant(
float cval);
186 int &numsample,
int *ix,
int *iy,
int *iz,
227 sampleval(v), samplew(w), ptpos(p) {}
257 extrapolateFromIndexInternal,
281 void moveAlongCurvature(
fpreal amount,
283 int miniter,
int maxiter);
295 const SIM_RawField &, speed,
296 const SIM_RawField &, source,
299 void moveAlongNormalPartial(const SIM_RawField &speed,
300 const SIM_RawField &source,
301 fpreal timestep, fpreal bandwidth,
306 void moveAlongNormalMidpoint(const SIM_RawField &speed,
307 const SIM_RawField &source,
308 fpreal timestep, fpreal bandwidth);
319 void reinitializeSignedDistance(
int maxiter,
336 const SIM_RawField *, other)
337 void maximumPartial(const SIM_RawField *other, const
UT_JobInfo &info);
340 const SIM_RawField *, other)
341 void minimumPartial(const SIM_RawField *other, const
UT_JobInfo &jobinfo);
346 const SIM_RawField &, other)
347 void averagePartial(const SIM_RawField &other, const
UT_JobInfo &jobinfo);
356 void sumPerComponentPartial(UT_DoubleArray &result,
357 UT_Int64Array &activevoxels,
358 const SIM_RawIndexField *comp,
363 int64 &, activevoxels,
365 const SIM_RawIndexField *, comp,
366 const SIM_RawField *, pressureboundary)
367 void sumComponentPartial(
double &result,
370 const SIM_RawIndexField *comp,
371 const SIM_RawField *pressureboundary,
377 const UT_DoubleArray &, valuelist,
378 const SIM_RawIndexField *, comp)
379 void addValuePerComponentPartial(const UT_DoubleArray &valuelist,
380 const SIM_RawIndexField *comp,
386 const SIM_RawIndexField *, comp,
387 const SIM_RawField *, pressureboundary)
388 void addValueToComponentPartial(
double value,
390 const SIM_RawIndexField *comp,
391 const SIM_RawField *pressureboundary,
397 const SIM_RawField &,
A,
399 const SIM_RawField &,
B)
400 void setScaleAddPartial(const SIM_RawField &A,
408 const SIM_RawField &, sdf,
410 void smearedSignPartial(const SIM_RawField &sdf,
417 void convertToHeavisidePartial(const
UT_JobInfo &info);
420 static fpreal toHeaviside(fpreal
val, fpreal diam);
421 static fpreal fromHeaviside(fpreal val, fpreal diam);
423 fpreal toHeaviside(fpreal val) const;
424 fpreal fromHeaviside(fpreal val) const;
444 fpreal reduceOp(REDUCE_NAMES op)
const;
452 void localReduceOp(REDUCE_NAMES op,
const UT_Vector3 &radius);
459 localReduceOp(REDUCE_AVERAGE, r);
465 fpreal reduceMaskedOp(REDUCE_NAMES op,
499 bool hasNan()
const {
return field()->hasNan(); }
503 void testForNan()
const;
517 void clearGrid()
const;
523 void updateGridFromField()
const;
526 void updateFieldFromGrid()
const;
542 { myVoxelSize = voxelsize; myVoxelDiameter = voxelsize.
length(); }
545 {
return myVoxelSize.x()
551 int64 getMemoryUsage()
const;
556 void getVoxelRes(
int &xres,
int &yres,
int &zres)
const;
575 fpreal getCellValue(
int x,
int y,
int z)
const;
579 void addToCell(
int x,
int y,
int z,
fpreal v);
584 void setCellValue(
int x,
int y,
int z,
fpreal v);
600 fpreal64 getLaplacianAtIndex(
int x,
int y,
int z)
const;
610 fpreal64 getCurvatureAtIndex(
int x,
int y,
int z)
const;
619 fpreal64 getCurvatureTimesGradAtIndex(
int x,
int y,
int z)
const;
630 int axis,
bool positivegradient)
const;
646 bool posToIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
659 bool cellIndexToPos(
int x,
int y,
int z,
UT_Vector3 &pos)
const;
660 bool posToCellIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
674 float time,
float voxelsize,
688 float time,
float voxelsize,
769 void advectSingleMinMaxPartial(const sim_advectParms &parms,
773 const SIM_RawField *, source,
774 const SIM_RawField *, velx,
775 const SIM_RawField *, vely,
776 const SIM_RawField *, velz,
778 const SIM_RawField *, collision,
781 void advectTracePartial(const SIM_RawField *source,
782 const SIM_RawField *velx,
783 const SIM_RawField *vely,
784 const SIM_RawField *velz,
786 const SIM_RawField *collision,
791 const sim_advectParms &, parms)
792 void advectTraceMinMaxPartial(const sim_advectParms &parms,
796 const SIM_RawField *, source,
797 const SIM_RawField *, velx,
798 const SIM_RawField *, vely,
799 const SIM_RawField *, velz,
801 const SIM_RawField *, collision,
805 void advectMultistepPartial(const SIM_RawField *source,
806 const SIM_RawField *velx,
807 const SIM_RawField *vely,
808 const SIM_RawField *velz,
810 const SIM_RawField *collision,
812 SIM_FieldAdvection advectmethod,
816 const sim_advectParms &, parms)
817 void advectMultistepMinMaxPartial(const sim_advectParms &parms,
822 const SIM_RawField &, source,
823 const SIM_RawField *, velx,
824 const SIM_RawField *, vely,
825 const SIM_RawField *, velz,
828 void advectHJWENOPartial(const SIM_RawField &source,
829 const SIM_RawField *velx,
830 const SIM_RawField *vely,
831 const SIM_RawField *velz,
837 const SIM_RawField &, source,
838 const SIM_RawField *, velx,
839 const SIM_RawField *, vely,
840 const SIM_RawField *, velz,
843 void advectUpwindPartial(const SIM_RawField &source,
844 const SIM_RawField *velx,
845 const SIM_RawField *vely,
846 const SIM_RawField *velz,
854 const SIM_RawField *, temperature,
858 void buoyancyPartial(const SIM_RawField *stencil,
859 const SIM_RawField *temperature,
860 fpreal up, fpreal Tamb,
895 d = SYSsafediv(d, s);
945 dstval = mixValues(parms.
calctype, dstval, srcval);
957 sim_particleToFieldParms &, parms)
958 void applyParticlesPartial(
964 void accumulateParticles(const
GU_Detail *particles,
969 const SIM_RawField *,
source,
971 float,
time,
float, voxelsize,
972 const SIM_RawField *, collision,
974 void advect2Partial(const SIM_RawField *source,
975 sim_PointVelocity getVelocity,
976 float time,
float voxelsize,
977 const SIM_RawField *collision,
983 void advectSelf(const SIM_RawField *velx,
984 const SIM_RawField *vely,
985 const SIM_RawField *velz,
987 const SIM_RawField *collision,
990 void advectSelf(sim_PointVelocity getVelocity,
991 float time,
float voxelsize,
992 const SIM_RawField *collision,
996 void advectMinMaxSelf(SIM_RawField *minfield,
997 SIM_RawField *maxfield,
998 const SIM_RawField *velx,
999 const SIM_RawField *vely,
1000 const SIM_RawField *velz,
1002 const SIM_RawField *collision,
1008 void diffuse(
fpreal diffrate,
1010 const SIM_RawField *collision=0);
1013 static
void diffuse(
float *dstdata, const
float *srcdata[3][3][3],
1014 float b,
float ivsx,
float ivsy,
float ivsz,
1016 int max_xtile,
int max_ytile,
1017 int max_xvox,
int max_yvox);
1020 void computeConnectedComponents(
UT_VoxelArray<
int64> &comp,
int &numcomponent) const;
1030 const SIM_RawField *,
surface,
1031 const SIM_RawField *,
stencil)
1032 void buildDivergenceFacePartial(const SIM_VectorField *vel,
1033 const SIM_RawField *surface,
1056 bool variational =
true,
1057 bool ghostfluid =
true,
1058 PCG_METHOD pcgmethod = PCG_MIC);
1066 gaussSeidelIteration,
1071 void gaussSeidelIterationPartial(
1082 gaussSeidelIterationFlat,
1085 fpreal32, sumweight,
1087 void gaussSeidelIterationFlatPartial(
1099 gaussSeidelIterationFlat2D,
1102 fpreal32, sumweight,
1104 void gaussSeidelIterationFlat2DPartial(
1115 const SIM_RawField *collision=0,
1116 const SIM_RawField *cvalue = 0,
1117 const SIM_RawField *boundary = 0,
1120 const SIM_RawField *collision,
1121 const SIM_RawField *cvalue = 0);
1122 void enforceSideBoundary(
int axis,
int side,
1125 const SIM_BoundaryLine &indexbline = SIM_BoundaryLine(),
1126 const SIM_RawField *boundaryfield = 0);
1129 enforceCollisionBoundaryInternal,
1131 const SIM_RawField *, collision,
1132 const SIM_RawField *, cvalue)
1133 void enforceCollisionBoundaryInternalPartial(
1134 SIM_FieldBoundary boundary,
1135 const SIM_RawField *collision,
1136 const SIM_RawField *cvalue,
1143 void enforceBoundaryFlat(fpreal32 *
values,
1146 enforceCollisionBoundaryFlat,
1150 void enforceCollisionBoundaryFlatPartial(fpreal32 *values,
1151 const SIM_RawIndexField *collision_lookup,
1153 void enforceSideBoundaryFlat(fpreal32 *values,
1155 SIM_FieldBoundary bound,
1165 void setBoundary(
int axis,
int side, SIM_FieldBoundary bound)
1166 { myBoundary[axis][side] = bound; }
1168 {
return myBoundary[axis][side]; }
1170 { myBoundaryValue[axis][side] =
v; }
1172 {
return myBoundaryValue[axis][side]; }
1184 float getBorderValue()
const;
1192 void setCompressionTolerance(
fpreal tol);
1193 fpreal getCompressionTolerance()
const;
1208 int maxpasses = -1);
1209 void waveletInverseTransform(
1212 int maxpasses = -1);
1219 void waveletExtractComponent(
const SIM_RawField *wavelet,
1248 computeSDFWeightsSampledInternal(sdf,samplesperaxis,invert,
1249 minweight, dilatedist);
1254 computeSDFWeightsSampledInternal,
1256 int, samplesperaxis,
1261 void computeSDFWeightsSampledInternalPartial(
const SIM_RawField *sdf,
1273 computeSDFWeightsFace,
1279 void computeSDFWeightsFacePartial(
const SIM_RawField *sdf,
1289 computeSDFWeightsVolumeFraction,
1294 void computeSDFWeightsVolumeFractionPartial(
const SIM_RawField *sdf,
1303 fpreal computeVoxelSDFWeightFace(
int x,
int y,
int z,
1310 setScaleDivideThreshold,
1322 void waveletRebuildFromVoxelArray(
1333 void reduceOpInternalPartial(fpreal64 *sum, REDUCE_NAMES op, const
UT_JobInfo &info) const;
1337 fpreal64 *, masktotal,
1339 const SIM_RawField *,
mask,
1341 void reduceMaskedOpInternalPartial(fpreal64 *sum, fpreal64 *masktotal, REDUCE_NAMES op, const SIM_RawField *maskfield,
bool maskissdf, const
UT_JobInfo &info) const;
1345 const SIM_RawField *maskfield,
1346 bool maskissdf) const;
1351 const SIM_RawField *, depths,
1352 const SIM_RawField *, valid,
1358 void buildExtrapListPartial(
1360 const SIM_RawField *depths,
1361 const SIM_RawField *valid,
1363 fpreal dir, fpreal maxdist,
1364 bool clamp, fpreal clampval,
1369 void localReduceByAxis(REDUCE_NAMES op,
1375 template <
int AXIS, REDUCE_NAMES OP>
1380 template <
int AXIS, REDUCE_NAMES OP>
1387 void localReduceAxisOp(REDUCE_NAMES op,
1394 field.getTileRes(1)*field.getTileRes(2) > 1,
1398 UT_VoxelArrayF &, field,
1400 void localReduceAxisXPartial(
1402 UT_VoxelArrayF &dst,
1403 UT_VoxelArrayF &field,
1406 { localReduceAxisOp<0>(op,
dst, field, radius, info); }
1409 field.getTileRes(0)*field.getTileRes(2) > 1,
1415 void localReduceAxisYPartial(
1421 { localReduceAxisOp<1>(op,
dst, field, radius, info); }
1424 field.getTileRes(0)*field.getTileRes(1) > 1,
1430 void localReduceAxisZPartial(
1436 { localReduceAxisOp<2>(op,
dst, field, radius, info); }
1452 void buildFromVDBSampledPartial(const GEO_PrimVDB *vdb,
1454 const UT_DMatrix4 &xform,
1467 mutable
bool myFieldOutOfDate;
1477 fpreal myVoxelDiameter;
1480 fpreal myBoundaryValue[3][2];
1495 myRes[0] = myRes[1] = myRes[2] = 0;
1517 return myIdx[2] >= myRes[2];
1523 if (myIdx[0] >= myRes[0])
1527 if (myIdx[1] >= myRes[1])
1531 if (myIdx[2] >= myRes[2])
1534 myIdx[2] = myRes[2];
1540 int x()
const {
return myIdx[0]; }
1541 int y()
const {
return myIdx[1]; }
1542 int z()
const {
return myIdx[2]; }
1543 int idx(
int axis)
const {
return myIdx[axis]; }
1550 return myIdx[0] == 0;
1582 #define CALL_PROBEXY(XSTEP, YSTEP, src, dst, command) \
1584 if ((dstsample ^ srcsample) & 4) \
1586 if (dstsample & 4) \
1588 UT_VoxelProbeAverage<fpreal32, XSTEP, YSTEP, -1> theprobe; \
1589 theprobe.setArray(src->field()); \
1594 UT_VoxelProbeAverage<fpreal32, XSTEP, YSTEP, 1> theprobe; \
1595 theprobe.setArray(src->field()); \
1601 UT_VoxelProbeAverage<fpreal32, XSTEP, YSTEP, 0> theprobe; \
1602 theprobe.setArray(src->field()); \
1607 #define CALL_PROBEX(XSTEP, src, dst, command) \
1609 if ((dstsample ^ srcsample) & 2) \
1611 if (dstsample & 2) \
1613 CALL_PROBEXY(XSTEP, -1, src, dst, command); \
1617 CALL_PROBEXY(XSTEP, 1, src, dst, command); \
1622 CALL_PROBEXY(XSTEP, 0, src, dst, command); \
1626 #define CALL_VOXELPROBE(src, dst, defval, command) \
1630 UT_VoxelProbeConstant<fpreal32> theprobe; \
1631 theprobe.setValue(defval); \
1636 int dstsample, srcsample; \
1637 dstsample = dst->getSample(); \
1638 srcsample = src->getSample(); \
1639 if ((dstsample ^ srcsample) & 1) \
1641 if (dstsample & 1) \
1643 CALL_PROBEX(-1, src, dst, command); \
1647 CALL_PROBEX(1, src, dst, command); \
1652 CALL_PROBEX(0, src, dst, command); \
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
#define THREADED_METHOD7(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6, PARMTYPE7, PARMNAME7)
#define THREADED_METHOD4_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4)
virtual ~SIM_RawFieldCellIterator()
GLenum const void * lists
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
void getVoxelRes(int &xres, int &yres, int &zres) const
#define THREADED_METHOD8(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6, PARMTYPE7, PARMNAME7, PARMTYPE8, PARMNAME8)
GT_API const UT_StringHolder time
const UT_Vector3 & getVoxelSize() const
#define THREADED_METHOD1(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1)
static fpreal applyParticleToFieldParms(fpreal srcval, fpreal dstval, const sim_particleToFieldParms &parms)
UT_Vector3T< float > UT_Vector3
GLdouble GLdouble GLdouble z
static fpreal mixValues(MIX_NAMES mixtype, fpreal d, fpreal s)
Performs the requires mixing.
UT_VoxelArrayF * fieldNC() const
const SIM_RawField * velz
constexpr SYS_FORCE_INLINE T length() const noexcept
**But if you need a result
GLfloat GLfloat GLfloat v2
SIM_RawFieldCellIterator()
UT_Vector3(* sim_PointVelocityCB)(const UT_Vector3 &, int, void *)
GLfloat GLfloat GLfloat GLfloat v3
bool shouldMultiThread() const
Returns true if this should be multithreaded.
#define THREADED_METHOD5_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
#define THREADED_METHOD3(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3)
__hostdev__ float getValue(uint32_t i) const
bool gridIsAuthoritative() const
Returns true if the OpenCL grid has more up-to-date data than the voxel array.
GA_API const UT_StringHolder scale
fpreal getVoxelDiameter() const
GLint GLsizei GLsizei height
void markGridAsChanged()
Mark the field as out of date, but only if we have a valid grid.
SIM_FieldSample getSample() const
sim_PointVelocity(sim_PointVelocityCB _cb, void *_data)
const UT_Vector3 & getBBoxOrig() const
IMATH_NAMESPACE::V2f float
const UT_Vector3 & getBBoxSize() const
#define THREADED_METHOD2(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2)
void computeSDFWeightsSampled(const SIM_RawField *sdf, int samplesperaxis, bool invert, fpreal minweight, fpreal dilatedist=0)
bool isStartOfTile() const
GLsizei GLsizei GLchar * source
const SIM_RawField * collision
void setBoundaryValue(int axis, int side, fpreal v)
const UT_Vector3 & getSize() const
const SIM_RawField * source
#define THREADED_METHOD5(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
fpreal average() const
Prebuilt versions.
#define THREADED_METHOD4(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4)
GLboolean GLboolean GLboolean b
void setArray(const SIM_RawField *field)
GEO_PrimVolumeXform * fieldxform
fpreal getBoundaryValue(int axis, int side) const
const UT_VoxelArrayF * field() const
Fetches the raw field.
#define THREADED_METHOD2_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2)
GLint GLint GLsizei GLint border
GLenum GLsizei GLsizei GLint * values
GA_API const UT_StringHolder up
LeafData & operator=(const LeafData &)=delete
SIM_API const UT_StringHolder position
void boxBlur(float radius)
#define THREADED_METHOD6(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6)
GLubyte GLubyte GLubyte GLubyte w
fpreal getVoxelVolume() const
bool hasNan() const
Returns true if our field has any NANs.
SIM_FieldAdvection advectmethod
GLint GLfloat GLint stencil
REDUCE_NAMES
Types of reductions supported by reduceOp.
const UT_Vector3 & getOrig() const
#define THREADED_METHOD3_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3)
ImageBuf OIIO_API resample(const ImageBuf &src, bool interpolate=true, ROI roi={}, int nthreads=0)
This class holds a three dimensional vector field.
#define THREADED_METHOD(CLASSNAME, DOMULTI, METHOD)
SIM_FieldBoundary getBoundary(int axis, int side) const
void setVoxelSize(const UT_Vector3 &voxelsize)