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 00013 #include <sstream> 00014 #include "parametrizer.h" 00015 00016 // debug output flag, has to be off for win32 for some reason... 00017 #define DEBUG_PARAMCHANNELS 0 00018 00020 const char *ParamStrings[] = { 00021 "RelaxTime", 00022 "Reynolds", 00023 "Viscosity", 00024 "SoundSpeed", 00025 "DomainSize", 00026 "GravityForce", 00027 "TimeLength", 00028 "Timestep", 00029 "Size", 00030 "TimeFactor", 00031 "AniFrames", 00032 "AniFrameTime", 00033 "AniStart", 00034 "SurfaceTension", 00035 "Density", 00036 "CellSize", 00037 "GStar", 00038 "MaxSpeed", 00039 "SimMaxSpeed", 00040 "FluidVolHeight", 00041 "NormalizedGStar", 00042 "PSERR", "PSERR", "PSERR", "PSERR" 00043 }; 00044 00045 00046 00047 /****************************************************************************** 00048 * Default constructor 00049 *****************************************************************************/ 00050 Parametrizer::Parametrizer( void ) : 00051 mcViscosity( 8.94e-7 ), 00052 mSoundSpeed( 1500 ), 00053 mDomainSize( 0.1 ), mCellSize( 0.01 ), 00054 mcGravity( ParamVec(0.0) ), 00055 mTimestep(0.0001), mDesiredTimestep(-1.0), 00056 mMaxTimestep(-1.0), 00057 mMinTimestep(-1.0), 00058 mSizex(50), mSizey(50), mSizez(50), 00059 mTimeFactor( 1.0 ), 00060 mcAniFrameTime(0.0001), 00061 mTimeStepScale(1.0), 00062 mAniStart(0.0), 00063 //mExtent(1.0, 1.0, 1.0), //mSurfaceTension( 0.0 ), 00064 mDensity(1000.0), mGStar(0.0001), mFluidVolumeHeight(0.0), 00065 mSimulationMaxSpeed(0.0), 00066 mTadapMaxOmega(2.0), mTadapMaxSpeed(0.1), mTadapLevels(1), 00067 mFrameNum(0), 00068 mSeenValues( 0 ), mCalculatedValues( 0 ) 00069 { 00070 } 00071 00072 00073 /****************************************************************************** 00074 * Destructor 00075 *****************************************************************************/ 00076 Parametrizer::~Parametrizer() 00077 { 00078 /* not much to do... */ 00079 } 00080 00081 /****************************************************************************** 00082 * Init from attr list 00083 *****************************************************************************/ 00084 void Parametrizer::parseAttrList() 00085 { 00086 if(!mpAttrs) { 00087 errFatal("Parametrizer::parseAttrList", "mpAttrs pointer not initialized!", SIMWORLD_INITERROR); 00088 return; 00089 } 00090 00091 // unused 00092 string mSetupType = ""; 00093 mSetupType = mpAttrs->readString("p_setup",mSetupType, "Parametrizer","mSetupType", false); 00094 00095 // real params 00096 if(getAttributeList()->exists("p_viscosity")) { 00097 mcViscosity = mpAttrs->readChannelFloat("p_viscosity"); seenThis( PARAM_VISCOSITY ); } 00098 00099 mSoundSpeed = mpAttrs->readFloat("p_soundspeed",mSoundSpeed, "Parametrizer","mSoundSpeed", false); 00100 if(getAttributeList()->exists("p_soundspeed")) seenThis( PARAM_SOUNDSPEED ); 00101 00102 mDomainSize = mpAttrs->readFloat("p_domainsize",mDomainSize, "Parametrizer","mDomainSize", false); 00103 if(getAttributeList()->exists("p_domainsize")) seenThis( PARAM_DOMAINSIZE ); 00104 if(mDomainSize<=0.0) { 00105 errMsg("Parametrizer::parseAttrList","Invalid real world domain size:"<<mDomainSize<<", resetting to 0.1"); 00106 mDomainSize = 0.1; 00107 } 00108 00109 if(getAttributeList()->exists("p_gravity")) { // || (!mcGravity.isInited()) ) { 00110 mcGravity = mpAttrs->readChannelVec3d("p_gravity"); seenThis( PARAM_GRAVITY ); 00111 } 00112 00113 mTimestep = mpAttrs->readFloat("p_steptime",mTimestep, "Parametrizer","mTimestep", false); 00114 if(getAttributeList()->exists("p_steptime")) seenThis( PARAM_STEPTIME ); 00115 00116 mTimeFactor = mpAttrs->readFloat("p_timefactor",mTimeFactor, "Parametrizer","mTimeFactor", false); 00117 if(getAttributeList()->exists("p_timefactor")) seenThis( PARAM_TIMEFACTOR ); 00118 00119 if(getAttributeList()->exists("p_aniframetime")) { //|| (!mcAniFrameTime.isInited()) ) { 00120 mcAniFrameTime = mpAttrs->readChannelFloat("p_aniframetime");seenThis( PARAM_ANIFRAMETIME ); 00121 } 00122 mTimeStepScale = mpAttrs->readFloat("p_timestepscale",mTimeStepScale, "Parametrizer","mTimeStepScale", false); 00123 00124 mAniStart = mpAttrs->readFloat("p_anistart",mAniStart, "Parametrizer","mAniStart", false); 00125 if(getAttributeList()->exists("p_anistart")) seenThis( PARAM_ANISTART ); 00126 if(mAniStart<0.0) { 00127 errMsg("Parametrizer::parseAttrList","Invalid start time:"<<mAniStart<<", resetting to 0.0"); 00128 mAniStart = 0.0; 00129 } 00130 00131 //mSurfaceTension = mpAttrs->readFloat("p_surfacetension",mSurfaceTension, "Parametrizer","mSurfaceTension", false); 00132 //if(getAttributeList()->exists("p_surfacetension")) seenThis( PARAM_SURFACETENSION ); 00133 00134 mDensity = mpAttrs->readFloat("p_density",mDensity, "Parametrizer","mDensity", false); 00135 if(getAttributeList()->exists("p_density")) seenThis( PARAM_DENSITY ); 00136 00137 ParamFloat cellSize = 0.0; // unused, deprecated 00138 cellSize = mpAttrs->readFloat("p_cellsize",cellSize, "Parametrizer","cellSize", false); 00139 00140 mGStar = mpAttrs->readFloat("p_gstar",mGStar, "Parametrizer","mGStar", false); 00141 if(getAttributeList()->exists("p_gstar")) seenThis( PARAM_GSTAR ); 00142 00143 mNormalizedGStar = mpAttrs->readFloat("p_normgstar",mNormalizedGStar, "Parametrizer","mNormalizedGStar", false); 00144 if(getAttributeList()->exists("p_normgstar")) seenThis( PARAM_NORMALIZEDGSTAR ); 00145 00146 mTadapMaxOmega = mpAttrs->readFloat("p_tadapmaxomega",mTadapMaxOmega, "Parametrizer","mTadapMaxOmega", false); 00147 mTadapMaxSpeed = mpAttrs->readFloat("p_tadapmaxspeed",mTadapMaxSpeed, "Parametrizer","mTadapMaxSpeed", false); 00148 } 00149 00150 /****************************************************************************** 00151 *! advance to next render/output frame 00152 *****************************************************************************/ 00153 void Parametrizer::setFrameNum(int frame) { 00154 mFrameNum = frame; 00155 #if DEBUG_PARAMCHANNELS>0 00156 errMsg("DEBUG_PARAMCHANNELS","setFrameNum frame-num="<<mFrameNum); 00157 #endif // DEBUG_PARAMCHANNELS>0 00158 } 00160 // also used by: mpParam->getCurrentAniFrameTime() , e.g. for velocity dump 00161 ParamFloat Parametrizer::getAniFrameTime( int frame ) { 00162 double frametime = (double)frame; 00163 ParamFloat anift = mcAniFrameTime.get(frametime); 00164 if(anift<0.0) { 00165 ParamFloat resetv = 0.; 00166 errMsg("Parametrizer::setFrameNum","Invalid frame time:"<<anift<<" at frame "<<frame<<", resetting to "<<resetv); 00167 anift = resetv; 00168 } 00169 #if DEBUG_PARAMCHANNELS>0 00170 if((0)|| (DEBUG_PARAMCHANNELS)) errMsg("DEBUG_PARAMCHANNELS","getAniFrameTime frame="<<frame<<", frametime="<<anift<<" "); 00171 #endif // DEBUG_PARAMCHANNELS>0 00172 return anift; 00173 } 00174 00175 /****************************************************************************** 00176 * scale a given speed vector in m/s to lattice values 00177 *****************************************************************************/ 00178 ParamVec Parametrizer::calculateAddForce(ParamVec vec, string usage) 00179 { 00180 ParamVec ret = vec * (mTimestep*mTimestep) /mCellSize; 00181 debMsgStd("Parametrizer::calculateVector", DM_MSG, "scaled vector = "<<ret<<" for '"<<usage<<"', org = "<<vec<<" dt="<<mTimestep ,10); 00182 return ret; 00183 } 00184 00185 00186 /****************************************************************************** 00187 * calculate size of a single cell 00188 *****************************************************************************/ 00189 ParamFloat Parametrizer::calculateCellSize(void) 00190 { 00191 int maxsize = mSizex; // get max size 00192 if(mSizey>maxsize) maxsize = mSizey; 00193 if(mSizez>maxsize) maxsize = mSizez; 00194 maxsize = mSizez; // take along gravity dir for now! 00195 ParamFloat cellSize = 1.0 / (ParamFloat)maxsize; 00196 return cellSize; 00197 } 00198 00199 00200 /*****************************************************************************/ 00201 /* simple calulation functions */ 00202 /*****************************************************************************/ 00203 00205 ParamFloat Parametrizer::calculateOmega( double time ) { 00206 ParamFloat viscStar = calculateLatticeViscosity(time); 00207 ParamFloat relaxTime = (6.0 * viscStar + 1) * 0.5; 00208 #if DEBUG_PARAMCHANNELS>0 00209 errMsg("DEBUG_PARAMCHANNELS","calculateOmega viscStar="<<viscStar<<" relaxtime="<<relaxTime); 00210 #endif // DEBUG_PARAMCHANNELS>0 00211 return (1.0/relaxTime); 00212 } 00213 00215 ParamVec Parametrizer::calculateGravity( double time ) { 00216 ParamVec grav = mcGravity.get(time); 00217 ParamFloat forceFactor = (mTimestep *mTimestep)/mCellSize; 00218 ParamVec latticeGravity = grav * forceFactor; 00219 #if DEBUG_PARAMCHANNELS>0 00220 errMsg("DEBUG_PARAMCHANNELS","calculateGravity grav="<<grav<<" ff"<<forceFactor<<" lattGrav="<<latticeGravity); 00221 #endif // DEBUG_PARAMCHANNELS>0 00222 return latticeGravity; 00223 } 00224 00226 ParamFloat Parametrizer::calculateLatticeViscosity( double time ) { 00227 // check seen values 00228 int reqValues = PARAM_VISCOSITY | PARAM_STEPTIME; 00229 if(!checkSeenValues( reqValues ) ){ 00230 errMsg("Parametrizer::calculateLatticeViscosity"," Missing arguments!"); 00231 } 00232 ParamFloat viscStar = mcViscosity.get(time) * mTimestep / (mCellSize*mCellSize); 00233 #if DEBUG_PARAMCHANNELS>0 00234 errMsg("DEBUG_PARAMCHANNELS","calculateLatticeViscosity viscStar="<<viscStar); 00235 #endif // DEBUG_PARAMCHANNELS>0 00236 return viscStar; 00237 } 00238 00240 int Parametrizer::calculateStepsForSecs( ParamFloat s ) { 00241 return (int)(s/mTimestep); 00242 } 00243 00245 int Parametrizer::calculateAniStart( void ) { 00246 return (int)(mAniStart/mTimestep); 00247 } 00248 00250 int Parametrizer::calculateAniStepsPerFrame(int frame) { 00251 if(!checkSeenValues(PARAM_ANIFRAMETIME)) { 00252 errFatal("Parametrizer::calculateAniStepsPerFrame", "Missing ani frame time argument!", SIMWORLD_INITERROR); 00253 return 1; 00254 } 00255 int value = (int)(getAniFrameTime(frame)/mTimestep); 00256 if((value<0) || (value>1000000)) { 00257 errFatal("Parametrizer::calculateAniStepsPerFrame", "Invalid step-time (="<<value<<") <> ani-frame-time ("<<mTimestep<<") settings, aborting...", SIMWORLD_INITERROR); 00258 return 1; 00259 } 00260 return value; 00261 } 00262 00264 int Parametrizer::calculateNoOfSteps( ParamFloat timelen ) { 00265 return (int)(timelen/mTimestep); 00266 } 00267 00269 //ParamVec Parametrizer::calculateExtent( void ) { 00270 //return mExtent; 00271 //} 00272 00274 //ParamFloat Parametrizer::calculateSurfaceTension( void ) { return mSurfaceTension; } 00275 00277 // explicity scaled by time factor for refinement 00278 ParamFloat Parametrizer::getTimestep( void ) { 00279 return mTimestep; 00280 } 00281 00283 ParamVec Parametrizer::calculateLattVelocityFromRw( ParamVec ivel ) { 00284 ParamVec velvec = ivel; 00285 velvec /= mCellSize; 00286 velvec *= mTimestep; 00287 return velvec; 00288 } 00290 ParamVec Parametrizer::calculateRwVelocityFromLatt( ParamVec ivel ) { 00291 ParamVec velvec = ivel; 00292 velvec *= mCellSize; 00293 velvec /= mTimestep; 00294 return velvec; 00295 } 00296 00297 00299 ParamFloat Parametrizer::getCurrentGStar( void ) { 00300 ParamFloat gStar = mGStar; // check? TODO get from mNormalizedGStar? 00301 if(mFluidVolumeHeight>0.0) { gStar = mGStar/mFluidVolumeHeight; } 00302 return gStar; 00303 } 00304 00305 /****************************************************************************** 00306 * function that tries to calculate all the missing values from the given ones 00307 * prints errors and returns false if thats not possible 00308 *****************************************************************************/ 00309 bool Parametrizer::calculateAllMissingValues( double time, bool silent ) 00310 { 00311 bool init = false; // did we init correctly? 00312 int valuesChecked = 0; 00313 int reqValues; 00314 00315 // we always need the sizes 00316 reqValues = PARAM_SIZE; 00317 valuesChecked |= reqValues; 00318 if(!checkSeenValues(reqValues)) { 00319 errMsg("Parametrizer::calculateAllMissingValues"," Missing size argument!"); 00320 return false; 00321 } 00322 00323 if(!checkSeenValues(PARAM_DOMAINSIZE)) { 00324 errMsg("Parametrizer::calculateAllMissingValues"," Missing domain size argument!"); 00325 return false; 00326 } 00327 int maxsize = mSizex; // get max size 00328 if(mSizey>maxsize) maxsize = mSizey; 00329 if(mSizez>maxsize) maxsize = mSizez; 00330 maxsize = mSizez; // take along gravity dir for now! 00331 mCellSize = ( mDomainSize * calculateCellSize() ); // sets mCellSize 00332 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," max domain resolution="<<(maxsize)<<" cells , cellsize="<<mCellSize ,10); 00333 00334 00335 /* Carolin init , see DA for details */ 00336 ParamFloat maxDeltaT = 0.0; 00337 00338 /* normalized gstar init */ 00339 reqValues = PARAM_NORMALIZEDGSTAR; 00340 valuesChecked |= reqValues; 00341 if(checkSeenValues( reqValues ) ){ 00342 //if(checkSeenValues( PARAM_GSTAR ) ){ if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_WARNING," g star value override by normalizedGStar!",1); } 00343 const ParamFloat normgstarReset = 0.005; 00344 if(mNormalizedGStar<=1e-6) { 00345 errMsg("Parametrizer::calculateAllMissingValues","Invalid NormGstar: "<<mNormalizedGStar<<"... resetting to "<<normgstarReset); 00346 mNormalizedGStar = normgstarReset; 00347 } 00348 00349 mGStar = mNormalizedGStar/maxsize; 00350 00351 // TODO FIXME add use testdata check! 00352 mGStar = mNormalizedGStar/mSizez; 00353 errMsg("Warning","Used z-dir for gstar!"); 00354 00355 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," g star set to "<<mGStar<<" from normalizedGStar="<<mNormalizedGStar ,1); 00356 seenThis(PARAM_GSTAR); 00357 } 00358 00359 reqValues = PARAM_GSTAR | PARAM_VISCOSITY; 00360 if((checkSeenValues(PARAM_SURFACETENSION))) reqValues |= PARAM_DENSITY; // surface tension optional now... 00361 valuesChecked |= reqValues; 00362 if(checkSeenValues( reqValues ) ){ 00363 const ParamFloat gstarReset = 0.0005; 00364 if(getCurrentGStar()<=1e-6) { 00365 errMsg("Parametrizer::calculateAllMissingValues","Invalid Gstar: "<<getCurrentGStar()<<" (set to "<<mGStar<<") ... resetting to "<<gstarReset); 00366 mGStar = gstarReset; 00367 } 00368 00369 ParamFloat gStar = getCurrentGStar(); // mGStar 00370 if(mFluidVolumeHeight>0.0) { 00371 debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," height"<<mFluidVolumeHeight<<" resGStar = "<<gStar, 10); 00372 } 00373 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," g star = "<<gStar, 10); 00374 00375 ParamFloat forceStrength = 0.0; 00376 //if(checkSeenValues(PARAM_GRAVITY)) { forceStrength = norm( calculateGravity(time) ); } 00377 if(checkSeenValues(PARAM_GRAVITY)) { forceStrength = norm( mcGravity.get(time) ); } 00378 00379 // determine max. delta density per timestep trough gravity force 00380 if(forceStrength>0.0) { 00381 maxDeltaT = sqrt( gStar*mCellSize *mTimeStepScale /forceStrength ); 00382 } else { 00383 // use 1 lbm setp = 1 anim step as max 00384 maxDeltaT = getAniFrameTime(0); 00385 } 00386 00387 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," targeted step time = "<<maxDeltaT, 10); 00388 00389 //ParamFloat viscStarFac = mViscosity/(mCellSize*mCellSize); 00390 //if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," viscStarFac = "<<viscStarFac<<" viscosity:"<<mViscosity, 10); 00391 00392 // time step adaptivty, only for caro with max sim speed 00393 ParamFloat setDeltaT = maxDeltaT; 00394 if(mDesiredTimestep>0.0) { 00395 // explicitly set step time according to max velocity in sim 00396 setDeltaT = mDesiredTimestep; 00397 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," desired step time = "<<setDeltaT, 10); 00398 mDesiredTimestep = -1.0; 00399 } else { 00400 // just use max delta t as current 00401 } 00402 00403 // and once for init determine minimal delta t by omega max. 00404 if((mMinTimestep<0.0) || (mMaxTimestep<0.0)) { 00405 ParamFloat minDeltaT; 00406 ParamFloat maxOmega = mTadapMaxOmega; 00407 ParamFloat minRelaxTime = 1.0/maxOmega; 00408 for(int lev=1; lev<mTadapLevels; lev++) { 00409 // make minRelaxTime larger for each level that exists... 00410 minRelaxTime = 2.0 * (minRelaxTime-0.5) + 0.5; 00411 } 00412 maxOmega = 1.0/minRelaxTime; 00413 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," maxOmega="<<maxOmega<<" minRelaxTime="<<minRelaxTime<<" levels="<<mTadapLevels, 1); 00414 // visc-star for min relax time to calculate min delta ta 00415 if(mcViscosity.get(time)>0.0) { 00416 minDeltaT = ((2.0*minRelaxTime-1.0)/6.0) * mCellSize * mCellSize / mcViscosity.get(time); 00417 } else { 00418 // visc=0, this is not physical, but might happen 00419 minDeltaT = 0.0; 00420 } 00421 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," min delta t = "<<minDeltaT<<" , range = " << (maxDeltaT/minDeltaT) ,1); 00422 00423 // sim speed + accel shouldnt exceed 0.1? 00424 mMaxTimestep = maxDeltaT; 00425 mMinTimestep = minDeltaT; 00426 // only use once... 00427 } 00428 00429 setTimestep( setDeltaT ); // set mTimestep to new value 00430 init = true; 00431 } 00432 00433 // finish init 00434 if(init) { 00435 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," omega = "<<calculateOmega(0.0)<<", delt="<<mTimestep,1); 00436 00437 if(checkSeenValues(PARAM_GRAVITY)) { 00438 ParamFloat forceFactor = (mTimestep *mTimestep)/mCellSize; // only used for printing... 00439 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," gravity force = "<<PRINT_NTLVEC(mcGravity.get(time))<<", scaled with "<<forceFactor<<" to "<<calculateGravity(time),1); 00440 } 00441 00442 //mExtent = ParamVec( mCellSize*mSizex, mCellSize*mSizey, mCellSize*mSizez ); 00443 //if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," domain extent = "<<PRINT_NTLVEC(mExtent)<<"m , gs:"<<PRINT_VEC(mSizex,mSizey,mSizez)<<" cs:"<<mCellSize,1); 00444 00445 if(!checkSeenValues(PARAM_ANIFRAMETIME)) { 00446 errFatal("Parametrizer::calculateAllMissingValues"," Warning no ani frame time given!", SIMWORLD_INITERROR); 00447 setAniFrameTimeChannel( mTimestep ); 00448 } 00449 00450 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," ani frame steps = "<<calculateAniStepsPerFrame(mFrameNum)<<" for frame "<<mFrameNum, 1); 00451 00452 if((checkSeenValues(PARAM_ANISTART))&&(calculateAniStart()>0)) { 00453 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," ani start steps = "<<calculateAniStart()<<" ",1); 00454 } 00455 00456 if(! isSimworldOk() ) return false; 00457 // everything ok 00458 return true; 00459 } 00460 00461 // init failed ... failure: 00462 errMsg("Parametrizer::calculateAllMissingValues "," invalid configuration!"); 00463 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues ",DM_WARNING, " values seen:", 1); 00464 for(int i=0;i<PARAM_NUMIDS;i++) { 00465 if(checkSeenValues( 1<<i )) { 00466 if(!silent) debMsgStd(" ",DM_NOTIFY, ParamStrings[i], 1); 00467 } 00468 } 00469 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues ",DM_WARNING, "values checked but missing:", 1); 00470 for(int i=0;i<PARAM_NUMIDS;i++) { 00471 if((!checkSeenValues( 1<<i ))&& 00472 ( (valuesChecked&(1<<i))==(1<<i)) ) { 00473 debMsgStd(" ",DM_IMPORTANT, ParamStrings[i], 1); 00474 } 00475 } 00476 00477 // print values? 00478 return false; 00479 } 00480 00481 00482 /****************************************************************************** 00483 * init debug functions 00484 *****************************************************************************/ 00485 00486 00488 void Parametrizer::setViscosity(ParamFloat set) { 00489 mcViscosity = AnimChannel<ParamFloat>(set); 00490 seenThis( PARAM_VISCOSITY ); 00491 #if DEBUG_PARAMCHANNELS>0 00492 { errMsg("DebugChannels","Parametrizer::mcViscosity set = "<< mcViscosity.printChannel() ); } 00493 #endif // DEBUG_PARAMCHANNELS>0 00494 } 00495 void Parametrizer::initViscosityChannel(vector<ParamFloat> val, vector<double> time) { 00496 mcViscosity = AnimChannel<ParamFloat>(val,time); 00497 seenThis( PARAM_VISCOSITY ); 00498 #if DEBUG_PARAMCHANNELS>0 00499 { errMsg("DebugChannels","Parametrizer::mcViscosity initc = "<< mcViscosity.printChannel() ); } 00500 #endif // DEBUG_PARAMCHANNELS>0 00501 } 00502 00504 void Parametrizer::setGravity(ParamFloat setx, ParamFloat sety, ParamFloat setz) { 00505 mcGravity = AnimChannel<ParamVec>(ParamVec(setx,sety,setz)); 00506 seenThis( PARAM_GRAVITY ); 00507 #if DEBUG_PARAMCHANNELS>0 00508 { errMsg("DebugChannels","Parametrizer::mcGravity set = "<< mcGravity.printChannel() ); } 00509 #endif // DEBUG_PARAMCHANNELS>0 00510 } 00511 void Parametrizer::setGravity(ParamVec set) { 00512 mcGravity = AnimChannel<ParamVec>(set); 00513 seenThis( PARAM_GRAVITY ); 00514 #if DEBUG_PARAMCHANNELS>0 00515 { errMsg("DebugChannels","Parametrizer::mcGravity set = "<< mcGravity.printChannel() ); } 00516 #endif // DEBUG_PARAMCHANNELS>0 00517 } 00518 void Parametrizer::initGravityChannel(vector<ParamVec> val, vector<double> time) { 00519 mcGravity = AnimChannel<ParamVec>(val,time); 00520 seenThis( PARAM_GRAVITY ); 00521 #if DEBUG_PARAMCHANNELS>0 00522 { errMsg("DebugChannels","Parametrizer::mcGravity initc = "<< mcGravity.printChannel() ); } 00523 #endif // DEBUG_PARAMCHANNELS>0 00524 } 00525 00527 void Parametrizer::setAniFrameTimeChannel(ParamFloat set) { 00528 mcAniFrameTime = AnimChannel<ParamFloat>(set); 00529 seenThis( PARAM_ANIFRAMETIME ); 00530 #if DEBUG_PARAMCHANNELS>0 00531 { errMsg("DebugChannels","Parametrizer::mcAniFrameTime set = "<< mcAniFrameTime.printChannel() ); } 00532 #endif // DEBUG_PARAMCHANNELS>0 00533 } 00534 void Parametrizer::initAniFrameTimeChannel(vector<ParamFloat> val, vector<double> time) { 00535 mcAniFrameTime = AnimChannel<ParamFloat>(val,time); 00536 seenThis( PARAM_ANIFRAMETIME ); 00537 #if DEBUG_PARAMCHANNELS>0 00538 { errMsg("DebugChannels","Parametrizer::mcAniFrameTime initc = "<< mcAniFrameTime.printChannel() ); } 00539 #endif // DEBUG_PARAMCHANNELS>0 00540 } 00541 00542 // OLD interface stuff 00543 // reactivate at some point? 00544 00546 //ParamFloat mSurfaceTension; 00548 //void setSurfaceTension(ParamFloat set) { mSurfaceTension = set; seenThis( PARAM_SURFACETENSION ); } 00550 //ParamFloat getSurfaceTension( void ) { return mSurfaceTension; } 00551 /*if((checkSeenValues(PARAM_SURFACETENSION))&&(mSurfaceTension>0.0)) { 00552 ParamFloat massDelta = 1.0; 00553 ParamFloat densityStar = 1.0; 00554 massDelta = mDensity / densityStar *mCellSize*mCellSize*mCellSize; 00555 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," massDelta = "<<massDelta, 10); 00556 00557 mSurfaceTension = mSurfaceTension*mTimestep*mTimestep/massDelta; 00558 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," surface tension = "<<mSurfaceTension<<" ",1); 00559 } // */ 00560 00561 // probably just delete: 00562 00564 //ParamFloat mReynolds; 00565 00567 //void setRelaxTime(ParamFloat set) { mRelaxTime = set; seenThis( PARAM_RELAXTIME ); } 00569 //ParamFloat getRelaxTime( void ) { return mRelaxTime; } 00571 //void setReynolds(ParamFloat set) { mReynolds = set; seenThis( PARAM_REYNOLDS ); } 00573 //ParamFloat getReynolds( void ) { return mReynolds; } 00574 00575 // calculate reynolds number 00576 /*if(mViscosity>0.0) { 00577 ParamFloat maxSpeed = 1.0/6.0; // for rough reynolds approx 00578 ParamFloat reynoldsApprox = -1.0; 00579 ParamFloat gridSpeed = (maxSpeed*mCellSize/mTimestep); 00580 reynoldsApprox = (mDomainSize*gridSpeed) / mViscosity; 00581 if(!silent) debMsgStd("Parametrizer::calculateAllMissingValues",DM_MSG," reynolds number (D="<<mDomainSize<<", assuming V="<<gridSpeed<<")= "<<reynoldsApprox<<" ", 1); 00582 } // */ 00583 00584 //? mRelaxTime = mpAttrs->readFloat("p_relaxtime",mRelaxTime, "Parametrizer","mRelaxTime", false); 00585 //if(getAttributeList()->exists("p_relaxtime")) seenThis( PARAM_RELAXTIME ); 00586 //? mReynolds = mpAttrs->readFloat("p_reynolds",mReynolds, "Parametrizer","mReynolds", false); 00587 //if(getAttributeList()->exists("p_reynolds")) seenThis( PARAM_REYNOLDS ); 00588 00589 //mViscosity = mpAttrs->readFloat("p_viscosity",mViscosity, "Parametrizer","mViscosity", false); 00590 //if(getAttributeList()->exists("p_viscosity") || (!mcViscosity.isInited()) ) { } 00591 //if(getAttributeList()->exists("p_viscosity")) 00592 00593 00594 //ParamFloat viscStar = calculateLatticeViscosity(time); 00595 //RelaxTime = (6.0 * viscStar + 1) * 0.5; 00596 00597