Blender V2.61 - r43446

solver_control.h

Go to the documentation of this file.
00001 
00004 /******************************************************************************
00005  *
00006  * El'Beem - the visual lattice boltzmann freesurface simulator
00007  * All code distributed as part of El'Beem is covered by the version 2 of the 
00008  * GNU General Public License. See the file COPYING for details.
00009  * Copyright 2003-2006 Nils Thuerey
00010  *
00011  * testing extensions
00012  *
00013  *****************************************************************************/
00014 
00015 
00016 #ifndef LBM_TESTCLASS_H
00017 #define LBM_TESTCLASS_H
00018 
00019 //class IsoSurface;
00020 class ParticleObject;
00021 class ControlParticles;
00022 class ControlForces;
00023 
00024 //#define NUMGRIDS 2
00025 //#define MAXNUMSWS 10
00026 
00027 // farfield modes
00028 #define FARF_3DONLY -1
00029 #define FARF_BOTH    0
00030 #define FARF_SWEONLY 1
00031 // dont reuse 3d vars/init
00032 #define FARF_SEPSWE  2
00033 
00034 // relaxation macros for solver_relax.h
00035 
00036 // WARNING has to match controlparts.h
00037 #define CPF_ENTRIES     12
00038 #define CPF_FORCE       0
00039 #define CPF_VELWEIGHT   3
00040 #define CPF_VELOCITY    4
00041 #define CPF_FORCEWEIGHT 7
00042 #define CPF_MINCPDIST   8
00043 #define CPF_MINCPDIR    9
00044 
00045 #include "controlparticles.h"
00046 
00047 #include "ntl_geometrymodel.h"
00048              
00049 // get force entry, set=0 is unused anyway
00050 #define LBMGET_FORCE(lev, i,j,k)  mpControl->mCpForces[lev][ (LBMGI(lev,i,j,k,0)) ]
00051 
00052 // debug mods off...
00053 // same as in src/solver_relax.h!
00054 #define __PRECOLLIDE_MODS(rho,ux,uy,uz, grav) \
00055     ux += (grav)[0]; \
00056     uy += (grav)[1]; \
00057     uz += (grav)[2]; 
00058 
00059 //void testMaxdmod(int i, int j,int k, LbmFloat &ux,LbmFloat &uy,LbmFloat &uz,ControlForces &ff);
00060 #if LBMDIM==3
00061 #define MAXDGRAV \
00062             if(myforce->forceMaxd[0]*ux+myforce->forceMaxd[1]*uy<LBM_EPSILON) { \
00063                 ux = v2w*myforce->forceVel[0]+ v2wi*ux;  \
00064                 uy = v2w*myforce->forceVel[1]+ v2wi*uy; }  \
00065             /* movement inverse to g? */ \
00066             if((uz>LBM_EPSILON)&&(uz>myforce->forceVel[2])) { \
00067                 uz = v2w*myforce->forceVel[2]+ v2wi*uz; } 
00068 #else // LBMDIM==3
00069 #define MAXDGRAV \
00070             if(myforce->forceMaxd[0]*ux<LBM_EPSILON) { \
00071                 ux = v2w*myforce->forceVel[0]+ v2wi*ux; } \
00072             /* movement inverse to g? */ \
00073             if((uy>LBM_EPSILON)&&(uy>myforce->forceVel[1])) { \
00074                 uy = v2w*myforce->forceVel[1]+ v2wi*uy; } 
00075 #endif // LBMDIM==3
00076 
00077 // debug modifications of collide vars (testing)
00078 // requires: lev,i,j,k
00079 #define PRECOLLIDE_MODS(rho,ux,uy,uz, grav) \
00080     LbmFloat attforce = 1.; \
00081     if(this->mTForceStrength>0.) { \
00082         ControlForces* myforce = &LBMGET_FORCE(lev,i,j,k); \
00083         const LbmFloat vf = myforce->weightAtt;\
00084         const LbmFloat vw = myforce->weightVel;\
00085         if(vf!=0.) { attforce = MAX(0., 1.-vf);  /* TODO FIXME? use ABS(vf) for repulsion force? */ \
00086             ux += myforce->forceAtt[0]; \
00087             uy += myforce->forceAtt[1]; \
00088             uz += myforce->forceAtt[2]; \
00089             \
00090         } else if(( myforce->maxDistance>0.) && ( myforce->maxDistance<CPF_MAXDINIT)) {\
00091             const LbmFloat v2w = mpControl->mCons[0]->mCparts->getInfluenceMaxdist() * \
00092                 (myforce->maxDistance-mpControl->mCons[0]->mCparts->getRadiusMinMaxd()) / (mpControl->mCons[0]->mCparts->getRadiusMaxd()-mpControl->mCons[0]->mCparts->getRadiusMinMaxd()); \
00093             const LbmFloat v2wi = 1.-v2w; \
00094             if(v2w>0.){ MAXDGRAV; \
00095                 /* errMsg("ERRMDTT","at "<<PRINT_IJK<<" maxd="<<myforce->maxDistance<<", newu"<<PRINT_VEC(ux,uy,uz)<<", org"<<PRINT_VEC(oux,ouy,ouz)<<", fv"<<myforce->forceVel<<" " );  */ \
00096             }\
00097         } \
00098         if(vw>0.) { \
00099             const LbmFloat vwi = 1.-vw;\
00100             const LbmFloat vwd = mpControl->mDiffVelCon;\
00101             ux += vw*(myforce->forceVel[0]-myforce->compAv[0] + vwd*(myforce->compAv[0]-ux) ); \
00102             uy += vw*(myforce->forceVel[1]-myforce->compAv[1] + vwd*(myforce->compAv[1]-uy) ); \
00103             uz += vw*(myforce->forceVel[2]-myforce->compAv[2] + vwd*(myforce->compAv[2]-uz) ); \
00104             /*  TODO test!? modify smooth vel by influence of force for each lbm step, to account for force update only each N steps */ \
00105             myforce->compAv = (myforce->forceVel*vw+ myforce->compAv*vwi); \
00106         } \
00107     } \
00108     ux += (grav)[0]*attforce; \
00109     uy += (grav)[1]*attforce; \
00110     uz += (grav)[2]*attforce; \
00111     /* end PRECOLLIDE_MODS */
00112 
00113 #define TEST_IF_CHECK \
00114         if((!iffilled)&&(LBMGET_FORCE(lev,i,j,k).weightAtt!=0.)) { \
00115             errMsg("TESTIFFILL"," at "<<PRINT_IJK<<" "<<mass<<" "<<rho); \
00116             iffilled = true; \
00117             if(mass<rho*1.0) mass = rho*1.0; myfrac = 1.0; \
00118         }
00119 
00120 
00121 // a single set of control particles and params
00122 class LbmControlSet {
00123     public:
00124         LbmControlSet();
00125         ~LbmControlSet();
00126         void initCparts();
00127 
00128         // control particles
00129         ControlParticles *mCparts; 
00130         // control particle overall motion (for easier manual generation)
00131         ControlParticles *mCpmotion;
00132         // cp data file
00133         string mContrPartFile;
00134         string mCpmotionFile;
00135         // cp debug displau
00136         LbmFloat mDebugCpscale, mDebugVelScale, mDebugCompavScale, mDebugAttScale, mDebugMaxdScale, mDebugAvgVelScale;
00137 
00138         // params
00139         AnimChannel<float> mcForceAtt;
00140         AnimChannel<float> mcForceVel;
00141         AnimChannel<float> mcForceMaxd;
00142 
00143         AnimChannel<float> mcRadiusAtt;
00144         AnimChannel<float> mcRadiusVel;
00145         AnimChannel<float> mcRadiusMind;
00146         AnimChannel<float> mcRadiusMaxd;
00147 
00148         AnimChannel<ntlVec3f> mcCpScale;
00149         AnimChannel<ntlVec3f> mcCpOffset;
00150 };
00151         
00152 
00153 
00154 // main control data storage
00155 class LbmControlData 
00156 {
00157     public:
00158         LbmControlData();
00159         virtual ~LbmControlData();
00160 
00161         // control data
00162 
00163         // contorl params
00164         void parseControldataAttrList(AttributeList *attr);
00165 
00166         // control strength, set for solver interface
00167         LbmFloat mSetForceStrength;
00168         // cp vars
00169         std::vector<LbmControlSet*> mCons;
00170         // update interval
00171         int mCpUpdateInterval;
00172         // output
00173         string mCpOutfile;
00174         // control particle precomputed influence
00175         std::vector< std::vector<ControlForces> > mCpForces;
00176         std::vector<ControlForces> mCpKernel;
00177         std::vector<ControlForces> mMdKernel;
00178         // activate differential velcon
00179         LbmFloat mDiffVelCon;
00180 
00181         // cp debug displau
00182         LbmFloat mDebugCpscale, mDebugVelScale, mDebugCompavScale, mDebugAttScale, mDebugMaxdScale, mDebugAvgVelScale;
00183 };
00184 
00185 #endif // LBM_TESTCLASS_H