00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __GAS_SubSolver__
00020 #define __GAS_SubSolver__
00021
00022 #include "GAS_API.h"
00023
00024 #include <PRM/PRM_Name.h>
00025 #include <PRM/PRM_ChoiceList.h>
00026
00027 #include <SIM/SIM_Data.h>
00028 #include <SIM/SIM_DataUtils.h>
00029 #include <SIM/SIM_Utils.h>
00030 #include <SIM/SIM_OptionsUser.h>
00031 #include <SIM/SIM_Solver.h>
00032 #include <SIM/SIM_Time.h>
00033 #include <SIM/SIM_RawField.h>
00034
00035 class SIM_Engine;
00036 class GAS_Solver;
00037 class SIM_Object;
00038 class SIM_Geometry;
00039 class SIM_GeometryCopy;
00040 class SIM_ScalarField;
00041 class SIM_VectorField;
00042 class SIM_MatrixField;
00043 class SIM_IndexField;
00044 class SIM_RawIndexField;
00045 class GU_SDF;
00046
00047 class GAS_API GAS_SubSolver : public SIM_Solver,
00048 public SIM_OptionsUser
00049 {
00050 public:
00051
00052 virtual SIM_Result solveObjectsSubclass(SIM_Engine &engine,
00053 SIM_ObjectArray &objects,
00054 SIM_ObjectArray &newobjects,
00055 SIM_ObjectArray &feedbacktoobjects,
00056 const SIM_Time ×tep);
00057
00058
00059 virtual SIM_Result postSolveObjectsSubclass(SIM_Engine &engine,
00060 SIM_ObjectArray &objects,
00061 SIM_ObjectArray &newobjects,
00062 SIM_ObjectArray &feedbacktoobjects,
00063 const SIM_Time ×tep);
00064
00065
00066
00067 virtual bool solveGas(SIM_Engine &engine,
00068 SIM_Object *obj,
00069 SIM_Time time,
00070 SIM_Time timestep);
00071
00072
00073
00074
00075
00076
00077 SIM_Geometry *getGeometry(SIM_Object *obj, const char *name, bool silent=false);
00078 SIM_GeometryCopy *getGeometryCopy(SIM_Object *obj, const char *name, bool silent=false);
00079 SIM_ScalarField *getScalarField(SIM_Object *obj, const char *name, bool silent=false);
00080 SIM_VectorField *getVectorField(SIM_Object *obj, const char *name, bool silent=false);
00081 SIM_MatrixField *getMatrixField(SIM_Object *obj, const char *name, bool silent=false);
00082 SIM_IndexField *getIndexField(SIM_Object *obj, const char *name, bool silent=false);
00083
00084
00085 void getWorldToGeometry(UT_DMatrix4 &xform, SIM_Object *obj, const char *geopath);
00086
00087 void getGeometryToWorld(UT_DMatrix4 &xform, SIM_Object *obj, const char *geopath);
00088
00089
00090
00091
00092
00093 SIM_GeometryCopy *getOrCreateGeometry(SIM_Object *obj, const char *name);
00094 SIM_ScalarField *getOrCreateScalarField(SIM_Object *obj, const char *name);
00095 SIM_VectorField *getOrCreateVectorField(SIM_Object *obj, const char *name);
00096 SIM_MatrixField *getOrCreateMatrixField(SIM_Object *obj, const char *name);
00097 SIM_IndexField *getOrCreateIndexField(SIM_Object *obj, const char *name);
00098
00099
00100
00101 void getMatchingData(SIM_DataArray &data,
00102 SIM_Object *obj, const char *name);
00103 void getMatchingData(SIM_DataArray &data,
00104 UT_StringArray &datanames,
00105 SIM_Object *obj, const char *name);
00106
00107
00108
00109
00110 void matchField(SIM_ScalarField *field, const SIM_ScalarField *reffield);
00111 void matchField(SIM_VectorField *field, const SIM_ScalarField *reffield);
00112 void matchField(SIM_MatrixField *field, const SIM_ScalarField *reffield);
00113 void matchField(SIM_IndexField *field, const SIM_ScalarField *reffield);
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 void buildRelationshipField(
00128 SIM_ScalarField *mask,
00129 SIM_VectorField *vel,
00130 SIM_IndexField *index,
00131 SIM_Object *srcobj,
00132 bool usepoint, bool usesdf,
00133 bool allownonsdf,
00134 bool negate,
00135 fpreal particlebandwidth,
00136 fpreal bandwidth);
00137
00138 protected:
00139 explicit GAS_SubSolver(const SIM_DataFactory *factory);
00140 virtual ~GAS_SubSolver();
00141
00142
00143
00144 virtual bool solveGasSubclass(SIM_Engine &engine,
00145 SIM_Object *obj,
00146 SIM_Time time,
00147 SIM_Time timestep) = 0;
00148
00149
00150 virtual bool postSolveGasSubclass(SIM_Engine &engine,
00151 SIM_Object *obj,
00152 SIM_Time time,
00153 SIM_Time timestep){ return true; };
00154
00155
00156 fpreal getPropertyFromState(const SIM_Object &object,
00157 const SIM_Property &property) const;
00158
00159
00160 virtual fpreal getPropertyAtPositionSubclass(const SIM_Object &object,
00161 const UT_Vector3 &worldspacepos,
00162 const SIM_Property &property) const;
00163 virtual fpreal getPropertyAtPointSubclass(const SIM_Object &object,
00164 int ptnum, const SIM_Property &property) const;
00165
00166 virtual SIM_PropertyResolver *getPropertyResolverSubclass(const SIM_Object &object, const SIM_Property &property) const;
00167
00168
00169
00170 fpreal calculateTimestep(SIM_Engine &engine,
00171 SIM_VectorField *velocity,
00172 fpreal cflcond) const;
00173
00174
00175
00176
00177
00178 fpreal calculateTimestep(GU_ConstDetailHandle gdh,
00179 fpreal cflcond) const;
00180
00181 struct RelationshipParms
00182 {
00183 SIM_RawField *mask;
00184 SIM_VectorField *vel;
00185 SIM_PropertyResolver *vel_lookup;
00186 SIM_RawIndexField *index;
00187 int64 id;
00188
00189 const SIM_RawField *surface;
00190 bool isdensity;
00191 const GEO_PrimVolume *volume;
00192 UT_DMatrix4 tolocal;
00193 GEO_PointTree *pttree;
00194 const GU_Detail *gdp;
00195 const GU_SDF *sdf;
00196
00197 bool restricttorange;
00198 UT_BoundingBox activerange;
00199 bool negate;
00200 fpreal maxdist;
00201 fpreal particlebandwidth;
00202 };
00203
00204 THREADED_METHOD1(GAS_SubSolver, parms.mask->shouldMultiThread(),
00205 buildRelationshipFieldInternal,
00206 const RelationshipParms &, parms)
00207 void buildRelationshipFieldInternalPartial(
00208 const RelationshipParms &parms,
00209 const UT_JobInfo &info);
00210
00211 public:
00212 enum MIX_NAMES {
00213 MIX_COPY,
00214 MIX_ADD,
00215 MIX_SUB,
00216 MIX_MUL,
00217 MIX_DIV,
00218 MIX_MAX,
00219 MIX_MIN,
00220 MIX_AVERAGE,
00221 NUM_MIX
00222 };
00223
00224 enum TIMESCALE_NAMES
00225 {
00226 TIMESCALE_NONE,
00227 TIMESCALE_ADD,
00228 TIMESCALE_MULT,
00229 TIMESCALE_BOTH,
00230 TIMESCALE_DIVIDE,
00231 NUM_TIMESCALE
00232 };
00233
00234 enum LENGTHSCALE_NAMES
00235 {
00236 LENGTHSCALE_NONE,
00237 LENGTHSCALE_LENGTH,
00238 LENGTHSCALE_AREA,
00239 LENGTHSCALE_VOLUME,
00240 NUM_LENGTHSCALE
00241 };
00242
00243
00244 static fpreal mixValues(MIX_NAMES mixtype,
00245 fpreal dest, fpreal src);
00246
00247
00248
00249 static fpreal applyTimeScalePow(fpreal value, fpreal t) ;
00250
00251
00252
00253 static void applyTimeScale(fpreal &add, fpreal &mul,
00254 fpreal timestep, int timescale);
00255
00256
00257
00258 static fpreal applyLengthScale(fpreal val, fpreal width,
00259 int scaletype);
00260
00261 protected:
00262
00263
00264 static PRM_Name ourMixMethods[NUM_MIX+1];
00265 static PRM_ChoiceList ourMixMethodMenu;
00266
00267 static PRM_Name ourTimeScaleMethods[NUM_TIMESCALE+1];
00268 static PRM_ChoiceList ourTimeScaleMenu;
00269
00270 static PRM_Name ourLengthScaleMethods[NUM_LENGTHSCALE+1];
00271 static PRM_ChoiceList ourLengthScaleMenu;
00272
00273 private:
00274 DECLARE_STANDARD_GETCASTTOTYPE();
00275 DECLARE_CLASSNAME(GAS_SubSolver, SIM_Solver);
00276 };
00277
00278 #endif
00279