Blender V2.61 - r43446
|
00001 00004 /****************************************************************************** 00005 * 00006 * El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method 00007 * Copyright 2003-2006 Nils Thuerey 00008 * 00009 * Parameter calculator for the LBM Solver class 00010 * 00011 *****************************************************************************/ 00012 #ifndef MFFSLBM_PARAMETRIZER 00013 #define MFFSLBM_PARAMETRIZER 00014 00015 00016 /* LBM Files */ 00017 #include "utilities.h" 00018 #include "attributes.h" 00019 00020 /* parametrizer accuracy */ 00021 typedef double ParamFloat; 00022 typedef ntlVec3d ParamVec; 00023 00025 #define PARAM_RELAXTIME (1<< 0) 00026 #define PARAM_REYNOLDS (1<< 1) 00027 #define PARAM_VISCOSITY (1<< 2) 00028 #define PARAM_SOUNDSPEED (1<< 3) 00029 #define PARAM_DOMAINSIZE (1<< 4) 00030 #define PARAM_GRAVITY (1<< 5) 00031 #define PARAM_STEPTIME (1<< 7) 00032 #define PARAM_SIZE (1<< 8) 00033 #define PARAM_TIMEFACTOR (1<< 9) 00034 #define PARAM_ANIFRAMETIME (1<<11) 00035 #define PARAM_ANISTART (1<<12) 00036 #define PARAM_SURFACETENSION (1<<13) 00037 #define PARAM_DENSITY (1<<14) 00038 #define PARAM_GSTAR (1<<16) 00039 #define PARAM_SIMMAXSPEED (1<<18) 00040 #define PARAM_FLUIDVOLHEIGHT (1<<19) 00041 #define PARAM_NORMALIZEDGSTAR (1<<20) 00042 #define PARAM_NUMIDS 21 00043 00045 //#define PARAM_DEBUG 1 00046 00047 00048 00050 class Parametrizer { 00051 00052 public: 00054 Parametrizer(); 00055 00057 ~Parametrizer(); 00058 00060 void parseAttrList( void ); 00061 00065 bool calculateAllMissingValues( double time, bool silent ); 00067 bool isUsed() { return true; } 00068 00070 void seenThis(int seen) { mSeenValues = (mSeenValues | seen); 00071 #ifdef PARAM_DEBUG 00072 errorOut(" seen "<<seen<<endl); 00073 #endif 00074 } 00075 00077 void setSeenValues(int set) { mSeenValues = set; } 00079 bool checkSeenValues(int check) { /*errorOut( " b"<<((mSeenValues&check)==check) );*/ return ((mSeenValues&check)==check); } 00080 00082 void calculatedThis(int cac) { mCalculatedValues = (mCalculatedValues | cac); /*errorOut(" a "<<seen);*/ } 00084 void setCalculatedValues(int set) { mCalculatedValues = set; } 00086 bool checkCalculatedValues(int check) { /*errorOut( " b"<<((mSeenValues&check)==check) );*/ return ((mCalculatedValues&check)==check); } 00088 void setFrameNum(int frame); 00089 ParamFloat getAniFrameTime(int frame); 00090 ParamFloat getCurrentAniFrameTime(){ return getAniFrameTime(mFrameNum); }; 00091 00094 ParamVec calculateAddForce(ParamVec vec, string usage); 00095 00096 /* simple calulation functions */ 00098 ParamFloat calculateOmega( double time ); 00100 int calculateNoOfSteps( ParamFloat timelen ); 00102 ParamVec calculateGravity( double time ); 00104 int calculateStepsForSecs( ParamFloat s ); 00106 int calculateAniStepsPerFrame(int frame); 00108 int calculateAniStart( void ); 00110 //ParamVec calculateExtent( void ); 00112 ParamFloat calculateSurfaceTension( void ); 00114 // unused ParamFloat calculateTimestep( void ); 00116 ParamFloat calculateCellSize(void); 00118 ParamFloat calculateLatticeViscosity( double time ); 00119 00121 ParamVec calculateLattVelocityFromRw( ParamVec ivel ); 00123 ParamVec calculateRwVelocityFromLatt( ParamVec ivel ); 00124 00126 void setSoundSpeed(ParamFloat set) { mSoundSpeed = set; seenThis( PARAM_SOUNDSPEED ); } 00128 ParamFloat getSoundSpeed( void ) { return mSoundSpeed; } 00129 00131 void setViscosity(ParamFloat set); 00132 void initViscosityChannel(vector<ParamFloat> val, vector<double> time); 00133 00135 void setGravity(ParamFloat setx, ParamFloat sety, ParamFloat setz); 00136 void setGravity(ParamVec set); 00137 void initGravityChannel(vector<ParamVec> val, vector<double> time); 00138 ParamVec getGravity(double time) { return mcGravity.get( time ); } 00139 00141 void setAniFrameTimeChannel(ParamFloat set); 00142 void initAniFrameTimeChannel(vector<ParamFloat> val, vector<double> time); 00143 00145 void setTimestep(ParamFloat set) { mTimestep = set; seenThis( PARAM_STEPTIME ); } 00147 ParamFloat getTimestep( void); 00149 void setDesiredTimestep(ParamFloat set) { mDesiredTimestep = set; } 00151 ParamFloat getMaxTimestep( void ) { return mMaxTimestep; } 00153 ParamFloat getMinTimestep( void ) { return mMinTimestep; } 00154 00156 void setTimeFactor(ParamFloat set) { mTimeFactor = set; seenThis( PARAM_TIMEFACTOR ); } 00158 ParamFloat getTimeFactor( void ) { return mTimeFactor; } 00159 00161 void setSize(int ijk) { mSizex = ijk; mSizey = ijk; mSizez = ijk; seenThis( PARAM_SIZE ); } 00162 void setSize(int i,int j, int k) { mSizex = i; mSizey = j; mSizez = k; seenThis( PARAM_SIZE ); } 00163 00165 void setAniStart(ParamFloat set) { mAniStart = set; seenThis( PARAM_ANISTART ); } 00167 ParamFloat getAniStart( void ) { return mAniStart; } 00168 00170 void setDensity(ParamFloat set) { mDensity = set; seenThis( PARAM_DENSITY ); } 00172 ParamFloat getDensity( void ) { return mDensity; } 00173 00175 void setGStar(ParamFloat set) { mGStar = set; seenThis( PARAM_GSTAR ); } 00177 ParamFloat getGStar( void ) { return mGStar; } 00179 ParamFloat getCurrentGStar( void ); 00181 void setNormalizedGStar(ParamFloat set) { mNormalizedGStar = set; seenThis( PARAM_NORMALIZEDGSTAR ); } 00183 ParamFloat getNormalizedGStar( void ) { return mNormalizedGStar; } 00184 00186 void setFluidVolumeHeight(ParamFloat set) { mFluidVolumeHeight = set; seenThis( PARAM_FLUIDVOLHEIGHT ); } 00188 ParamFloat getFluidVolumeHeight( void ) { return mFluidVolumeHeight; } 00189 00191 void setDomainSize(ParamFloat set) { mDomainSize = set; seenThis( PARAM_DOMAINSIZE ); } 00193 ParamFloat getDomainSize( void ) { return mDomainSize; } 00194 00196 void setCellSize(ParamFloat set) { mCellSize = set; } 00198 ParamFloat getCellSize( void ) { return mCellSize; } 00199 00201 //void setActive(bool set) { mActive = set; } 00202 00204 void setAttrList(AttributeList *set) { mpAttrs = set; } 00206 inline AttributeList *getAttributeList() { return mpAttrs; } 00207 00209 void setSimulationMaxSpeed(ParamFloat set) { mSimulationMaxSpeed = set; seenThis( PARAM_SIMMAXSPEED ); } 00211 ParamFloat getSimulationMaxSpeed( void ) { return mSimulationMaxSpeed; } 00212 00214 void setTadapMaxOmega(ParamFloat set) { mTadapMaxOmega = set; } 00216 ParamFloat getTadapMaxOmega( void ) { return mTadapMaxOmega; } 00217 00219 void setTadapMaxSpeed(ParamFloat set) { mTadapMaxSpeed = set; } 00221 ParamFloat getTadapMaxSpeed( void ) { return mTadapMaxSpeed; } 00222 00224 void setTadapLevels(int set) { mTadapLevels = set; } 00226 int getTadapLevels( void ) { return mTadapLevels; } 00227 00229 // void set(ParamFloat set) { m = set; seenThis( PARAM_ ); } 00231 // ParamFloat get( void ) { return m; } 00232 00233 00234 00235 private: 00236 00238 AnimChannel<ParamFloat> mcViscosity; 00239 00241 ParamFloat mSoundSpeed; 00242 00244 ParamFloat mDomainSize; 00245 00247 ParamFloat mCellSize; 00248 00250 ParamFloat mTimeStep; 00251 00253 AnimChannel<ParamVec> mcGravity; 00254 00256 ParamFloat mTimestep; 00258 ParamFloat mDesiredTimestep; 00260 ParamFloat mMaxTimestep, mMinTimestep; 00261 00263 int mSizex, mSizey, mSizez; 00264 00266 ParamFloat mTimeFactor; 00267 00269 AnimChannel<ParamFloat> mcAniFrameTime; 00271 ParamFloat mTimeStepScale; 00272 00274 ParamFloat mAniStart; 00275 00277 //ParamVec mExtent; 00278 00280 ParamFloat mDensity; 00281 00283 ParamFloat mGStar; 00285 ParamFloat mNormalizedGStar; 00287 ParamFloat mFluidVolumeHeight; 00288 00290 ParamFloat mSimulationMaxSpeed; 00292 ParamFloat mTadapMaxOmega; 00294 ParamFloat mTadapMaxSpeed; 00296 int mTadapLevels; 00297 00299 int mFrameNum; 00300 00302 int mSeenValues; 00303 00305 int mCalculatedValues; 00306 00308 AttributeList *mpAttrs; 00309 }; 00310 00311 00312 #endif 00313