00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GAS_SPH__
00022 #define __GAS_SPH__
00023
00024 #include "GAS_API.h"
00025
00026 #include <GEO/GEO_AttributeHandle.h>
00027
00028 #include <UT/UT_FloatArray.h>
00029 #include <UT/UT_IntArray.h>
00030 #include <UT/UT_PtrArray.h>
00031 #include <UT/UT_RefArray.h>
00032 #include <UT/UT_Vector3Array.h>
00033
00034 class GAS_SubSolver;
00035 class GU_Detail;
00036 class GB_PointGroup;
00037 class GEO_Point;
00038 class GEO_PointTree;
00039 class SIM_Engine;
00040 class UT_HashTable;
00041 class UT_FloatArray;
00042 class UT_String;
00043
00044 class GAS_API GAS_SPH
00045 {
00046 public:
00047 GAS_SPH();
00048 ~GAS_SPH();
00049
00050 enum sphWeight
00051 {
00052 POLY6,
00053 SPIKY,
00054 VISCOSITY,
00055 SPIKY2,
00056 SPIKY5,
00057 POLY6_UNSCALED,
00058 SPIKY_UNSCALED
00059 };
00060
00061
00062
00063 static void missingAttribWarning(SIM_Engine &engine, GAS_SubSolver *solver,
00064 const UT_String &objName,
00065 const UT_String &geometryName,
00066 const UT_String &attribName);
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 bool initialize(const GU_Detail *gdp, bool fullinit = true,
00077 const GB_PointGroup *excludegroup = NULL,
00078 fpreal radiusScale = 1.0, bool needVolume = true);
00079
00080
00081
00082
00083
00084
00085
00086 fpreal sampleF(const UT_Vector3 &p,
00087 GEO_AttributeHandle gah,
00088 sphWeight wfunc,
00089 fpreal *color = 0,
00090 bool normalize = false,
00091 bool volumeScale = true);
00092 fpreal sampleF(const UT_Vector3 &p,
00093 UT_FloatArray &floats,
00094 sphWeight wfunc,
00095 bool volumescale = true,
00096 bool normalize = false);
00097 UT_Vector3 sampleV3(const UT_Vector3 &p,
00098 GEO_AttributeHandle gah,
00099 sphWeight wfunc,
00100 fpreal *color = 0,
00101 bool normalize = false);
00102
00103
00104
00105
00106
00107
00108 UT_Vector3 sampleVelocity(const UT_Vector3 &p,
00109 sphWeight wfunc,
00110 int excludePoint = -1);
00111
00112
00113
00114
00115 UT_Vector3 xsphVelocity(int ptnum, sphWeight wfunc,
00116 const UT_Vector3Array &velocities,
00117 fpreal xsph_constant);
00118
00119
00120
00121
00122 fpreal sampleDensity(const UT_Vector3 &p,
00123 sphWeight wfunc,
00124 const bool massScale = true);
00125
00126
00127
00128
00129 void sampleDoubleDensity(const UT_Vector3 &p,
00130 sphWeight wfunc1, sphWeight wfunc2,
00131 fpreal &density1, fpreal &density2,
00132 UT_PtrArray<GEO_Point *> &ptlist,
00133 const bool massScale = true);
00134
00135
00136
00137
00138 fpreal sampleSurfaceDensity(const UT_Vector3 &p,
00139 GEO_AttributeHandle &distance_gah);
00140
00141
00142
00143
00144
00145 fpreal sampleSurfaceDensity(const UT_Vector3 &p,
00146 fpreal surfaceDistance,
00147 const bool distanceModifier = false);
00148
00149
00150
00151 UT_Vector3 sampleSurfaceDensityGrad(const UT_Vector3 &p,
00152 GEO_AttributeHandle &distance_gah);
00153
00154
00155
00156
00157 UT_Vector3 sampleSurfaceDensityGrad(const UT_Vector3 &p);
00158
00159
00160
00161
00162 fpreal sampleColor(const UT_Vector3 &p,
00163 sphWeight wfunc);
00164
00165
00166
00167
00168 UT_Vector3 colorGradient(const UT_Vector3 &p,
00169 sphWeight wfunc);
00170
00171
00172
00173 UT_Vector3 colorGradientUnscaled(const UT_Vector3 &p,
00174 bool scale = false);
00175
00176 fpreal colorLaplacian(const UT_Vector3 &p,
00177 sphWeight wfunc,
00178 GEO_AttributeHandle *scale_gah = NULL,
00179 fpreal point_scale = 1.0);
00180
00181 UT_Vector3 gradient(const UT_Vector3 &p,
00182 GEO_AttributeHandle gah,
00183 sphWeight wfunc,
00184 UT_Vector3 *color = 0,
00185 bool debugprint = false,
00186 GEO_AttributeHandle *scale_gah = NULL,
00187 fpreal point_scale = 1.0);
00188
00189
00190
00191 UT_Vector3 gradient(const UT_Vector3 &p,
00192 GEO_AttributeHandle gah,
00193 sphWeight wfunc,
00194 int axis, UT_Vector3 *color = 0,
00195 bool normalize = false);
00196
00197
00198 fpreal laplacian(const UT_Vector3 &p,
00199 GEO_AttributeHandle gah,
00200 sphWeight wfunc,
00201 fpreal *color = 0);
00202
00203
00204
00205 UT_FloatArray laplacianF(const UT_Vector3 &p,
00206 GEO_AttributeHandle gah,
00207 sphWeight wfunc, int size,
00208 fpreal *color = 0);
00209
00210 UT_Vector3 laplacianV3(const UT_Vector3 &p,
00211 GEO_AttributeHandle gah,
00212 sphWeight wfunc,
00213 fpreal *color = 0,
00214 GEO_AttributeHandle *scale_gah = NULL,
00215 fpreal point_scale = 1.0);
00216
00217
00218 void findClosePoints(const UT_Vector3 &p,
00219 UT_PtrArray<GEO_Point *> &ptlist);
00220
00221
00222 int getMaxElements() const { return myMaxElements; }
00223
00224
00225
00226
00227
00228
00229
00230
00231 bool initVelocityData(bool initKD = false);
00232
00233
00234 fpreal getCellWidth() { return myCellWidth; }
00235
00236
00237
00238
00239
00240 const UT_RefArray<bool> &
00241 excludeLonePoints(bool exclude, int numNeighbours = 2);
00242
00243 protected:
00244
00245 class gas_SPHGridCell {
00246 public:
00247 gas_SPHGridCell() {}
00248 gas_SPHGridCell(int i, int j, int k, int index)
00249 : myIndices(15), myXindex(i), myYindex(j),
00250 myZindex(k), myIndex(index), myNumEntries(0)
00251 {
00252 }
00253 virtual ~gas_SPHGridCell()
00254 {
00255 }
00256
00257 UT_IntArray myIndices;
00258
00259 int myXindex;
00260 int myYindex;
00261 int myZindex;
00262
00263 int myIndex;
00264
00265 int myNumEntries;
00266 };
00267
00268 typedef UT_RefArray<gas_SPHGridCell> gas_CellArray;
00269
00270
00271
00272
00273 fpreal64 weight(fpreal64 r2, fpreal64 h, sphWeight wfunc);
00274 fpreal64 dweight(fpreal64 r, fpreal64 h, sphWeight wfunc);
00275 fpreal64 d2weight(fpreal64 r, fpreal64 h, sphWeight wfunc);
00276 fpreal64 scaleddweight(fpreal64 r, fpreal64 h, sphWeight wfunc);
00277
00278
00279 void assignPoint(const GEO_Point *ppt);
00280
00281
00282
00283 gas_SPHGridCell * getCell(const UT_Vector3 &p, bool create = false);
00284 gas_SPHGridCell * getCell(int i, int j, int k, bool create = false);
00285
00286
00287
00288 int myMaxCells;
00289 int myMaxCells2;
00290 fpreal myXmin, myYmin, myZmin;
00291 fpreal myCellWidth;
00292 fpreal myCellWidth2;
00293
00294
00295 int myMaxElements;
00296
00297 const GU_Detail *myGdp;
00298
00299 UT_HashTable *myGridSet;
00300 gas_CellArray myCellArray;
00301
00302 bool myFullInit;
00303
00304 GEO_AttributeHandle myRadGah, myMassGah, myDensityGah;
00305
00306
00307
00308
00309 UT_FloatArray myMasses;
00310 UT_FloatArray myDensities;
00311 UT_FloatArray myRadii;
00312 UT_Vector3Array myVelocities;
00313
00314
00315
00316
00317 GEO_PointTree *myPointTree;
00318
00319
00320 fpreal myRadiusScale;
00321
00322
00323
00324 UT_RefArray<bool> myExcludePoint;
00325 };
00326
00327 #endif
00328