11 #ifndef __SIM_RawField__
12 #define __SIM_RawField__
126 int xres,
int yres,
int zres);
129 int xres,
int yres,
int zres,
151 return field()->numTiles() > 1;
161 void makeConstant(
float cval);
184 int &numsample,
int *ix,
int *iy,
int *iz,
225 sampleval(v), samplew(w), ptpos(p) {}
255 extrapolateFromIndexInternal,
279 void moveAlongCurvature(
fpreal amount,
281 int miniter,
int maxiter);
293 const SIM_RawField &, speed,
294 const SIM_RawField &, source,
297 void moveAlongNormalPartial(
const SIM_RawField &speed,
299 fpreal timestep, fpreal bandwidth,
304 void moveAlongNormalMidpoint(
const SIM_RawField &speed,
305 const SIM_RawField &source,
306 fpreal timestep, fpreal bandwidth);
317 void reinitializeSignedDistance(
int maxiter,
334 const SIM_RawField *, other)
338 const SIM_RawField *, other)
344 const SIM_RawField &, other)
354 void sumPerComponentPartial(UT_DoubleArray &result,
355 UT_Int64Array &activevoxels,
356 const SIM_RawIndexField *comp,
361 int64 &, activevoxels,
363 const SIM_RawIndexField *, comp,
364 const SIM_RawField *, pressureboundary)
365 void sumComponentPartial(
double &result,
368 const SIM_RawIndexField *comp,
369 const SIM_RawField *pressureboundary,
375 const UT_DoubleArray &, valuelist,
376 const SIM_RawIndexField *, comp)
377 void addValuePerComponentPartial(const UT_DoubleArray &valuelist,
378 const SIM_RawIndexField *comp,
384 const SIM_RawIndexField *, comp,
385 const SIM_RawField *, pressureboundary)
386 void addValueToComponentPartial(
double value,
388 const SIM_RawIndexField *comp,
389 const SIM_RawField *pressureboundary,
395 const SIM_RawField &, A,
397 const SIM_RawField &, B)
398 void setScaleAddPartial(const SIM_RawField &A,
400 const SIM_RawField &B, const
UT_JobInfo &jobinfo);
406 const SIM_RawField &, sdf,
408 void smearedSignPartial(const SIM_RawField &sdf,
415 void convertToHeavisidePartial(const
UT_JobInfo &info);
418 static fpreal toHeaviside(fpreal
val, fpreal diam);
419 static fpreal fromHeaviside(fpreal val, fpreal diam);
421 fpreal toHeaviside(fpreal val) const;
422 fpreal fromHeaviside(fpreal val) const;
442 fpreal reduceOp(REDUCE_NAMES op)
const;
450 void localReduceOp(REDUCE_NAMES op,
const UT_Vector3 &radius);
457 localReduceOp(REDUCE_AVERAGE, r);
463 fpreal reduceMaskedOp(REDUCE_NAMES op,
487 bool hasNan()
const {
return field()->hasNan(); }
491 void testForNan()
const;
505 void clearGrid()
const;
511 void updateGridFromField()
const;
514 void updateFieldFromGrid()
const;
530 { myVoxelSize = voxelsize; myVoxelDiameter = voxelsize.
length(); }
533 {
return myVoxelSize.x()
539 int64 getMemoryUsage()
const;
544 void getVoxelRes(
int &xres,
int &yres,
int &zres)
const;
560 fpreal getCellValue(
int x,
int y,
int z)
const;
564 void addToCell(
int x,
int y,
int z,
fpreal v);
569 void setCellValue(
int x,
int y,
int z,
fpreal v);
585 fpreal64 getLaplacianAtIndex(
int x,
int y,
int z)
const;
595 fpreal64 getCurvatureAtIndex(
int x,
int y,
int z)
const;
604 fpreal64 getCurvatureTimesGradAtIndex(
int x,
int y,
int z)
const;
615 int axis,
bool positivegradient)
const;
628 bool posToIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
640 bool cellIndexToPos(
int x,
int y,
int z,
UT_Vector3 &pos)
const;
641 bool posToCellIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
655 float time,
float voxelsize,
669 float time,
float voxelsize,
750 void advectSingleMinMaxPartial(
const sim_advectParms &parms,
754 const SIM_RawField *, source,
755 const SIM_RawField *, velx,
756 const SIM_RawField *, vely,
757 const SIM_RawField *, velz,
759 const SIM_RawField *, collision,
762 void advectTracePartial(
const SIM_RawField *source,
763 const SIM_RawField *velx,
764 const SIM_RawField *vely,
765 const SIM_RawField *velz,
767 const SIM_RawField *collision,
772 const sim_advectParms &, parms)
773 void advectTraceMinMaxPartial(
const sim_advectParms &parms,
777 const SIM_RawField *, source,
778 const SIM_RawField *, velx,
779 const SIM_RawField *, vely,
780 const SIM_RawField *, velz,
782 const SIM_RawField *, collision,
786 void advectMultistepPartial(
const SIM_RawField *source,
788 const SIM_RawField *vely,
789 const SIM_RawField *velz,
791 const SIM_RawField *collision,
793 SIM_FieldAdvection advectmethod,
797 const sim_advectParms &, parms)
798 void advectMultistepMinMaxPartial(
const sim_advectParms &parms,
803 const SIM_RawField &, source,
804 const SIM_RawField *, velx,
805 const SIM_RawField *, vely,
806 const SIM_RawField *, velz,
809 void advectHJWENOPartial(
const SIM_RawField &source,
811 const SIM_RawField *vely,
812 const SIM_RawField *velz,
818 const SIM_RawField &, source,
819 const SIM_RawField *, velx,
820 const SIM_RawField *, vely,
821 const SIM_RawField *, velz,
824 void advectUpwindPartial(
const SIM_RawField &source,
825 const SIM_RawField *velx,
826 const SIM_RawField *vely,
827 const SIM_RawField *velz,
835 const SIM_RawField *, temperature,
839 void buoyancyPartial(
const SIM_RawField *stencil,
841 fpreal up, fpreal Tamb,
876 d = SYSsafediv(d, s);
926 dstval = mixValues(parms.
calctype, dstval, srcval);
938 sim_particleToFieldParms &, parms)
939 void applyParticlesPartial(
952 float,
time,
float, voxelsize,
953 const SIM_RawField *, collision,
955 void advect2Partial(
const SIM_RawField *source,
956 sim_PointVelocity getVelocity,
957 float time,
float voxelsize,
958 const SIM_RawField *collision,
964 void advectSelf(
const SIM_RawField *velx,
965 const SIM_RawField *vely,
966 const SIM_RawField *velz,
968 const SIM_RawField *collision,
971 void advectSelf(sim_PointVelocity getVelocity,
972 float time,
float voxelsize,
973 const SIM_RawField *collision,
977 void advectMinMaxSelf(SIM_RawField *minfield,
978 SIM_RawField *maxfield,
979 const SIM_RawField *velx,
980 const SIM_RawField *vely,
981 const SIM_RawField *velz,
983 const SIM_RawField *collision,
989 void diffuse(
fpreal diffrate,
991 const SIM_RawField *collision=0);
994 static
void diffuse(
float *dstdata,
const float *srcdata[3][3][3],
995 float b,
float ivsx,
float ivsy,
float ivsz,
997 int max_xtile,
int max_ytile,
998 int max_xvox,
int max_yvox);
1011 const SIM_RawField *, surface,
1012 const SIM_RawField *,
stencil)
1013 void buildDivergenceFacePartial(const SIM_VectorField *vel,
1014 const SIM_RawField *surface,
1037 bool variational =
true,
1038 bool ghostfluid =
true,
1039 PCG_METHOD pcgmethod = PCG_MIC);
1047 gaussSeidelIteration,
1052 void gaussSeidelIterationPartial(
1063 gaussSeidelIterationFlat,
1066 fpreal32, sumweight,
1068 void gaussSeidelIterationFlatPartial(
1080 gaussSeidelIterationFlat2D,
1083 fpreal32, sumweight,
1085 void gaussSeidelIterationFlat2DPartial(
1096 const SIM_RawField *collision=0,
1097 const SIM_RawField *cvalue = 0,
1098 const SIM_RawField *boundary = 0,
1101 const SIM_RawField *collision,
1102 const SIM_RawField *cvalue = 0);
1103 void enforceSideBoundary(
int axis,
int side,
1106 const SIM_BoundaryLine &indexbline = SIM_BoundaryLine(),
1107 const SIM_RawField *boundaryfield = 0);
1110 enforceCollisionBoundaryInternal,
1112 const SIM_RawField *, collision,
1113 const SIM_RawField *, cvalue)
1114 void enforceCollisionBoundaryInternalPartial(
1115 SIM_FieldBoundary boundary,
1116 const SIM_RawField *collision,
1117 const SIM_RawField *cvalue,
1124 void enforceBoundaryFlat(fpreal32 *
values,
1127 enforceCollisionBoundaryFlat,
1131 void enforceCollisionBoundaryFlatPartial(fpreal32 *values,
1132 const SIM_RawIndexField *collision_lookup,
1134 void enforceSideBoundaryFlat(fpreal32 *values,
1136 SIM_FieldBoundary bound,
1146 void setBoundary(
int axis,
int side, SIM_FieldBoundary bound)
1147 { myBoundary[axis][side] = bound; }
1149 {
return myBoundary[axis][side]; }
1151 { myBoundaryValue[axis][side] =
v; }
1153 {
return myBoundaryValue[axis][side]; }
1165 float getBorderValue()
const;
1173 void setCompressionTolerance(
fpreal tol);
1174 fpreal getCompressionTolerance()
const;
1189 int maxpasses = -1);
1190 void waveletInverseTransform(
1193 int maxpasses = -1);
1200 void waveletExtractComponent(
const SIM_RawField *wavelet,
1229 computeSDFWeightsSampledInternal(sdf,samplesperaxis,invert,
1230 minweight, dilatedist);
1235 computeSDFWeightsSampledInternal,
1237 int, samplesperaxis,
1242 void computeSDFWeightsSampledInternalPartial(
const SIM_RawField *sdf,
1254 computeSDFWeightsFace,
1260 void computeSDFWeightsFacePartial(
const SIM_RawField *sdf,
1270 computeSDFWeightsVolumeFraction,
1275 void computeSDFWeightsVolumeFractionPartial(
const SIM_RawField *sdf,
1284 fpreal computeVoxelSDFWeightFace(
int x,
int y,
int z,
1291 setScaleDivideThreshold,
1303 void waveletRebuildFromVoxelArray(
1318 fpreal64 *, masktotal,
1320 const SIM_RawField *,
mask,
1322 void reduceMaskedOpInternalPartial(fpreal64 *sum, fpreal64 *masktotal, REDUCE_NAMES op, const SIM_RawField *maskfield,
bool maskissdf, const
UT_JobInfo &info) const;
1326 const SIM_RawField *maskfield,
1327 bool maskissdf) const;
1332 const SIM_RawField *, depths,
1333 const SIM_RawField *, valid,
1339 void buildExtrapListPartial(
1341 const SIM_RawField *depths,
1342 const SIM_RawField *valid,
1344 fpreal dir, fpreal maxdist,
1345 bool clamp, fpreal clampval,
1350 void localReduceByAxis(REDUCE_NAMES op,
1356 template <
int AXIS, REDUCE_NAMES OP>
1361 template <
int AXIS, REDUCE_NAMES OP>
1368 void localReduceAxisOp(REDUCE_NAMES op,
1375 field.getTileRes(1)*field.getTileRes(2) > 1,
1379 UT_VoxelArrayF &, field,
1381 void localReduceAxisXPartial(
1383 UT_VoxelArrayF &dst,
1384 UT_VoxelArrayF &field,
1387 { localReduceAxisOp<0>(op,
dst, field, radius, info); }
1390 field.getTileRes(0)*field.getTileRes(2) > 1,
1396 void localReduceAxisYPartial(
1402 { localReduceAxisOp<1>(op,
dst, field, radius, info); }
1405 field.getTileRes(0)*field.getTileRes(1) > 1,
1411 void localReduceAxisZPartial(
1417 { localReduceAxisOp<2>(op,
dst, field, radius, info); }
1433 void buildFromVDBSampledPartial(
const GEO_PrimVDB *vdb,
1435 const UT_DMatrix4 &xform,
1448 mutable
bool myFieldOutOfDate;
1458 fpreal myVoxelDiameter;
1461 fpreal myBoundaryValue[3][2];
1476 myRes[0] = myRes[1] = myRes[2] = 0;
1498 return myIdx[2] >= myRes[2];
1504 if (myIdx[0] >= myRes[0])
1508 if (myIdx[1] >= myRes[1])
1512 if (myIdx[2] >= myRes[2])
1515 myIdx[2] = myRes[2];
1521 int x()
const {
return myIdx[0]; }
1522 int y()
const {
return myIdx[1]; }
1523 int z()
const {
return myIdx[2]; }
1524 int idx(
int axis)
const {
return myIdx[axis]; }
1531 return myIdx[0] == 0;
1563 #define CALL_PROBEXY(XSTEP, YSTEP, src, dst, command) \
1565 if ((dstsample ^ srcsample) & 4) \
1567 if (dstsample & 4) \
1569 UT_VoxelProbeAverage<fpreal32, XSTEP, YSTEP, -1> theprobe; \
1570 theprobe.setArray(src->field()); \
1575 UT_VoxelProbeAverage<fpreal32, XSTEP, YSTEP, 1> theprobe; \
1576 theprobe.setArray(src->field()); \
1582 UT_VoxelProbeAverage<fpreal32, XSTEP, YSTEP, 0> theprobe; \
1583 theprobe.setArray(src->field()); \
1588 #define CALL_PROBEX(XSTEP, src, dst, command) \
1590 if ((dstsample ^ srcsample) & 2) \
1592 if (dstsample & 2) \
1594 CALL_PROBEXY(XSTEP, -1, src, dst, command); \
1598 CALL_PROBEXY(XSTEP, 1, src, dst, command); \
1603 CALL_PROBEXY(XSTEP, 0, src, dst, command); \
1607 #define CALL_VOXELPROBE(src, dst, defval, command) \
1611 UT_VoxelProbeConstant<fpreal32> theprobe; \
1612 theprobe.setValue(defval); \
1617 int dstsample, srcsample; \
1618 dstsample = dst->getSample(); \
1619 srcsample = src->getSample(); \
1620 if ((dstsample ^ srcsample) & 1) \
1622 if (dstsample & 1) \
1624 CALL_PROBEX(-1, src, dst, command); \
1628 CALL_PROBEX(1, src, dst, command); \
1633 CALL_PROBEX(0, src, dst, command); \
#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()
*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)
GLuint const GLfloat * val
GLuint GLuint GLfloat weight
GLenum GLenum GLenum GLenum GLenum scale
UT_Vector3T< float > UT_Vector3
GLint GLsizei const GLuint64 * values
static fpreal mixValues(MIX_NAMES mixtype, fpreal d, fpreal s)
Performs the requires mixing.
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
UT_VoxelArrayF * fieldNC() const
GLsizei GLsizei GLchar * source
const SIM_RawField * velz
GLint GLfloat GLint stencil
SIM_RawFieldCellIterator()
UT_Vector3(* sim_PointVelocityCB)(const UT_Vector3 &, int, void *)
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)
bool gridIsAuthoritative() const
Returns true if the OpenCL grid has more up-to-date data than the voxel array.
fpreal getVoxelDiameter() const
void markGridAsChanged()
Mark the field as out of date, but only if we have a valid grid.
SIM_FieldSample getSample() const
GLfloat GLfloat GLfloat v2
sim_PointVelocity(sim_PointVelocityCB _cb, void *_data)
const UT_Vector3 & getBBoxOrig() const
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLint GLsizei const void * data
const UT_Vector3 & getBBoxSize() const
GLint GLint GLsizei GLsizei GLsizei GLint border
GLubyte GLubyte GLubyte GLubyte w
#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
const SIM_RawField * collision
void setBoundaryValue(int axis, int side, fpreal v)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
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)
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)
GLdouble GLdouble GLdouble b
GA_API const UT_StringHolder up
GLdouble GLdouble GLdouble r
void boxBlur(float radius)
#define THREADED_METHOD6(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6)
fpreal getVoxelVolume() const
bool hasNan() const
Returns true if our field has any NANs.
SIM_FieldAdvection advectmethod
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)
SYS_FORCE_INLINE Storage::MathFloat length() const
ImageBuf OIIO_API resample(const ImageBuf &src, bool interpolate=true, ROI roi={}, int nthreads=0)
This class holds a three dimensional vector field.
GLsizei const GLfloat * value
GLfloat GLfloat GLfloat GLfloat v3
#define THREADED_METHOD(CLASSNAME, DOMULTI, METHOD)
SIM_FieldBoundary getBoundary(int axis, int side) const
void setVoxelSize(const UT_Vector3 &voxelsize)