diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-07-07 01:55:03 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-07-07 01:55:03 +0400 |
commit | 7bbf88d602368733e66cf00b4f70947ef83b3b64 (patch) | |
tree | 2b7b04b1b7f1f6da0c5a398d5438f6b5cc650fb1 /intern | |
parent | b3303c98b1143a20794189eb60007f659d96c7eb (diff) |
Added 4 gui elements to structs, another 2-3 will follow; Unsolved problems: simulation and control time desync
Diffstat (limited to 'intern')
-rw-r--r-- | intern/elbeem/extern/elbeem.h | 9 | ||||
-rw-r--r-- | intern/elbeem/intern/controlparticles.cpp | 17 | ||||
-rw-r--r-- | intern/elbeem/intern/elbeem.cpp | 13 | ||||
-rw-r--r-- | intern/elbeem/intern/ntl_geometryobject.cpp | 1 | ||||
-rw-r--r-- | intern/elbeem/intern/ntl_geometryobject.h | 30 | ||||
-rw-r--r-- | intern/elbeem/intern/solver_control.cpp | 41 |
6 files changed, 84 insertions, 27 deletions
diff --git a/intern/elbeem/extern/elbeem.h b/intern/elbeem/extern/elbeem.h index 2599432e8b8..5c1fc644827 100644 --- a/intern/elbeem/extern/elbeem.h +++ b/intern/elbeem/extern/elbeem.h @@ -116,7 +116,7 @@ typedef struct elbeemSimulationSettings { // a single mesh object typedef struct elbeemMesh { - /* obstacle,fluid or inflow... */ + /* obstacle,fluid or inflow or control ... */ short type; /* id of simulation domain it belongs to */ short parentDomainId; @@ -158,6 +158,13 @@ typedef struct elbeemMesh { /* name of the mesh, mostly for debugging */ const char *name; + + /* fluid control settings */ + // TODO dg: change to channels + float attractforceStrength; + float attractforceRadius; + float velocityforceStrength; + float velocityforceRadius; } elbeemMesh; // API functions diff --git a/intern/elbeem/intern/controlparticles.cpp b/intern/elbeem/intern/controlparticles.cpp index d1f11f3835c..70a94bb2d1a 100644 --- a/intern/elbeem/intern/controlparticles.cpp +++ b/intern/elbeem/intern/controlparticles.cpp @@ -68,10 +68,15 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) { model->setLoaded(true); model->setGeoInitId(gid); + + + printf("a animated? %d\n", model->getIsAnimated()); + printf("b animated? %d\n", model->getMeshAnimated()); */ model->setGeoInitType(FGI_FLUID); model->getTriangles(mCPSTimeStart, &triangles, &vertices, &normals, 1 ); + // model->applyTransformation(mCPSTimeStart, &vertices, &normals, 0, vertices.size(), true); // valid mesh? if(triangles.size() <= 0) { @@ -92,11 +97,11 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) { // TODO? use params ntlVec3Gfx start,end; model->getExtends(start,end); - + /* printf("start - x: %f, y: %f, z: %f\n", start[0], start[1], start[2]); printf("end - x: %f, y: %f, z: %f\n", end[0], end[1], end[2]); printf("mCPSWidth: %f\n"); - +*/ LbmFloat width = mCPSWidth; if(width<=LBM_EPSILON) { errMsg("ControlParticles::initFromMVMCMesh","Invalid mCPSWidth! "<<mCPSWidth); width=mCPSWidth=0.1; } ntlVec3Gfx org = start+ntlVec3Gfx(width*0.5); @@ -104,6 +109,8 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) { vector<ntlVec3Gfx> inspos; int approxmax = (int)( ((end[0]-start[0])/width)*((end[1]-start[1])/width)*((end[2]-start[2])/width) ); + // printf("distance: %f, width: %f\n", distance, width); + while(org[2]<end[2]) { while(org[1]<end[1]) { while(org[0]<end[0]) { @@ -119,6 +126,8 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) { org[2] += width; org[1] = start[1]; } + + // printf("inspos.size(): %d\n", inspos.size()); MeanValueMeshCoords mvm; mvm.calculateMVMCs(vertices,triangles, inspos, mCPSWeightFac); @@ -144,6 +153,8 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) { // init further sets, temporal mesh sampling double tsampling = mCPSTimestep; + // printf("tsampling: %f, ninspos.size(): %d, mCPSTimeEnd: %f\n", tsampling, ninspos.size(), mCPSTimeEnd); + int totcnt = (int)( (mCPSTimeEnd-mCPSTimeStart)/tsampling ), tcnt=0; for(double t=mCPSTimeStart+tsampling; ((t<mCPSTimeEnd) && (ninspos.size()>0.)); t+=tsampling) { ControlParticleSet nextcps; //T @@ -164,8 +175,6 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) { } } } - - // applyTrafos(); model->setGeoInitType(FGI_CONTROL); diff --git a/intern/elbeem/intern/elbeem.cpp b/intern/elbeem/intern/elbeem.cpp index 0a48a7a9826..1d8f92b0744 100644 --- a/intern/elbeem/intern/elbeem.cpp +++ b/intern/elbeem/intern/elbeem.cpp @@ -159,6 +159,12 @@ void elbeemResetMesh(elbeemMesh *mesh) { /* name of the mesh, mostly for debugging */ mesh->name = "[unnamed]"; + + /* fluid control settings */ + mesh->attractforceStrength = 0; + mesh->attractforceRadius = 0; + mesh->velocityforceStrength = 0; + mesh->velocityforceRadius = 0; } int globalMeshCounter = 1; @@ -198,6 +204,13 @@ int elbeemAddMesh(elbeemMesh *mesh) { obj->setGeoInitType(initType); obj->setGeoPartSlipValue(mesh->obstaclePartslip); obj->setGeoImpactFactor(mesh->obstacleImpactFactor); + + /* fluid control features */ + obj->setAttractForceStrength(mesh->attractforceStrength); + obj->setAttractForceRadius(mesh->attractforceRadius); + obj->setVelocityForceStrength(mesh->velocityforceStrength); + obj->setVelocityForceRadius(mesh->velocityforceRadius); + if((mesh->volumeInitType<VOLUMEINIT_VOLUME)||(mesh->volumeInitType>VOLUMEINIT_BOTH)) mesh->volumeInitType = VOLUMEINIT_VOLUME; obj->setVolumeInit(mesh->volumeInitType); // use channel instead, obj->setInitialVelocity( ntlVec3Gfx(mesh->iniVelocity[0], mesh->iniVelocity[1], mesh->iniVelocity[2]) ); diff --git a/intern/elbeem/intern/ntl_geometryobject.cpp b/intern/elbeem/intern/ntl_geometryobject.cpp index 9861ce8edc9..68735acaec1 100644 --- a/intern/elbeem/intern/ntl_geometryobject.cpp +++ b/intern/elbeem/intern/ntl_geometryobject.cpp @@ -346,6 +346,7 @@ void ntlGeometryObject::initChannels( if((ivel)&&(nIvel>0)) { ADD_CHANNEL_VEC(mcInitialVelocity, nIvel, ivel); } checkIsAnimated(); + if(debugInitc) { debMsgStd("ntlGeometryObject::initChannels",DM_MSG,getName()<< " nt:"<<mcTrans.accessValues().size()<<" nr:"<<mcRot.accessValues().size()<< diff --git a/intern/elbeem/intern/ntl_geometryobject.h b/intern/elbeem/intern/ntl_geometryobject.h index a5afd6b2207..fd7455a4787 100644 --- a/intern/elbeem/intern/ntl_geometryobject.h +++ b/intern/elbeem/intern/ntl_geometryobject.h @@ -97,7 +97,28 @@ class ntlGeometryObject : public ntlGeometryClass /*! Set/get the local inivel coords flag */ inline bool getLocalCoordInivel() const { return mLocalCoordInivel; } inline void setLocalCoordInivel(bool set) { mLocalCoordInivel=set; } - + + /****************************************/ + /* fluid control features */ + /****************************************/ + /*! Set/get the particle control set attract force strength */ + inline float getAttractForceStrength() const { return mAttractforceStrength; } + inline void setAttractForceStrength(float set) { mAttractforceStrength=set; } + + /*! Set/get the particle control set attract force radius */ + inline float getAttractForceRadius() const { return mAttractforceRadius; } + inline void setAttractForceRadius(float set) { mAttractforceRadius=set; } + + /*! Set/get the particle control set velocity force strength */ + inline float getVelocityForceStrength() const { return mVelocityforceStrength; } + inline void setVelocityForceStrength(float set) { mVelocityforceStrength=set; } + + /*! Set/get the particle control set velocity force radius */ + inline float getVelocityForceRadius() const { return mVelocityforceRadius; } + inline void setVelocityForceRadius(float set) { mVelocityforceRadius=set; } + + /****************************************/ + /*! Init channels from float arrays (for elbeem API) */ void initChannels( int nTrans, float *trans, int nRot, float *rot, int nScale, float *scale, @@ -202,6 +223,13 @@ class ntlGeometryObject : public ntlGeometryClass /*! animated channels for in/outflow on/off */ AnimChannel<float> mcGeoActive; + + /* fluid control settings */ + // TODO dg: change to channels + float mAttractforceStrength; + float mAttractforceRadius; + float mVelocityforceStrength; + float mVelocityforceRadius; public: diff --git a/intern/elbeem/intern/solver_control.cpp b/intern/elbeem/intern/solver_control.cpp index c556cbf9a51..e4c5158b615 100644 --- a/intern/elbeem/intern/solver_control.cpp +++ b/intern/elbeem/intern/solver_control.cpp @@ -218,33 +218,32 @@ LbmFsgrSolver::initCpdata() // manually switch on! if this is zero, nothing is done... mpControl->mSetForceStrength = this->mTForceStrength = 1.; mpControl->mCons.clear(); - - // add new set - LbmControlSet *cset; - - cset = new LbmControlSet(); - cset->initCparts(); - - // dont load any file - cset->mContrPartFile = string(""); - - cset->mcForceAtt = AnimChannel<float>(0.2); - cset->mcRadiusAtt = AnimChannel<float>(0.75); - cset->mcForceVel = AnimChannel<float>(0.2); - cset->mcRadiusVel = AnimChannel<float>(0.75); - - // this value can be left at 0.5: - cset->mCparts->setCPSMvmWeightFac(0.5); - - mpControl->mCons.push_back( cset ); // init all control fluid objects int numobjs = (int)(mpGiObjects->size()); for(int o=0; o<numobjs; o++) { ntlGeometryObjModel *obj = (ntlGeometryObjModel *)(*mpGiObjects)[o]; if(obj->getGeoInitType() & FGI_CONTROL) { - printf("added control object\n"); - mpControl->mCons[0]->mCparts->initFromObject(obj); + // add new control set per object + LbmControlSet *cset; + + cset = new LbmControlSet(); + cset->initCparts(); + + // dont load any file + cset->mContrPartFile = string(""); + + // TODO dg: switch to channels later + cset->mcForceAtt = AnimChannel<float>(obj->getAttractForceStrength()); + cset->mcRadiusAtt = AnimChannel<float>(obj->getAttractForceRadius()); + cset->mcForceVel = AnimChannel<float>(obj->getVelocityForceStrength()); + cset->mcRadiusVel = AnimChannel<float>(obj->getVelocityForceRadius()); + + // this value can be left at 0.5: + cset->mCparts->setCPSMvmWeightFac(0.5); + + mpControl->mCons.push_back( cset ); + mpControl->mCons[mpControl->mCons.size()-1]->mCparts->initFromObject(obj); } } |