Revision: 15459
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15459
Author:   genscher
Date:     2008-07-06 23:55:03 +0200 (Sun, 06 Jul 2008)

Log Message:
-----------
Added 4 gui elements to structs, another 2-3 will follow; Unsolved problems: 
simulation and control time desync

Modified Paths:
--------------
    branches/fluidcontrol/intern/elbeem/extern/elbeem.h
    branches/fluidcontrol/intern/elbeem/intern/controlparticles.cpp
    branches/fluidcontrol/intern/elbeem/intern/elbeem.cpp
    branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.cpp
    branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.h
    branches/fluidcontrol/intern/elbeem/intern/solver_control.cpp
    branches/fluidcontrol/source/blender/src/fluidsim.c

Modified: branches/fluidcontrol/intern/elbeem/extern/elbeem.h
===================================================================
--- branches/fluidcontrol/intern/elbeem/extern/elbeem.h 2008-07-06 19:53:32 UTC 
(rev 15458)
+++ branches/fluidcontrol/intern/elbeem/extern/elbeem.h 2008-07-06 21:55:03 UTC 
(rev 15459)
@@ -116,7 +116,7 @@
 
 // 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 @@
 
        /* 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

Modified: branches/fluidcontrol/intern/elbeem/intern/controlparticles.cpp
===================================================================
--- branches/fluidcontrol/intern/elbeem/intern/controlparticles.cpp     
2008-07-06 19:53:32 UTC (rev 15458)
+++ branches/fluidcontrol/intern/elbeem/intern/controlparticles.cpp     
2008-07-06 21:55:03 UTC (rev 15459)
@@ -68,10 +68,15 @@
        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 @@
        // 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 @@
        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 @@
                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 @@
 
        // 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 @@
                        }
                }
        }
-
-       // applyTrafos();
        
        model->setGeoInitType(FGI_CONTROL);
        

Modified: branches/fluidcontrol/intern/elbeem/intern/elbeem.cpp
===================================================================
--- branches/fluidcontrol/intern/elbeem/intern/elbeem.cpp       2008-07-06 
19:53:32 UTC (rev 15458)
+++ branches/fluidcontrol/intern/elbeem/intern/elbeem.cpp       2008-07-06 
21:55:03 UTC (rev 15459)
@@ -159,6 +159,12 @@
 
        /* 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 @@
        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]) );

Modified: branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.cpp
===================================================================
--- branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.cpp   
2008-07-06 19:53:32 UTC (rev 15458)
+++ branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.cpp   
2008-07-06 21:55:03 UTC (rev 15459)
@@ -346,6 +346,7 @@
        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()<<

Modified: branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.h
===================================================================
--- branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.h     
2008-07-06 19:53:32 UTC (rev 15458)
+++ branches/fluidcontrol/intern/elbeem/intern/ntl_geometryobject.h     
2008-07-06 21:55:03 UTC (rev 15459)
@@ -97,7 +97,28 @@
                /*! 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 @@
 
                /*! 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:
 

Modified: branches/fluidcontrol/intern/elbeem/intern/solver_control.cpp
===================================================================
--- branches/fluidcontrol/intern/elbeem/intern/solver_control.cpp       
2008-07-06 19:53:32 UTC (rev 15458)
+++ branches/fluidcontrol/intern/elbeem/intern/solver_control.cpp       
2008-07-06 21:55:03 UTC (rev 15459)
@@ -218,33 +218,32 @@
        // 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);
                }
        }
        

Modified: branches/fluidcontrol/source/blender/src/fluidsim.c
===================================================================
--- branches/fluidcontrol/source/blender/src/fluidsim.c 2008-07-06 19:53:32 UTC 
(rev 15458)
+++ branches/fluidcontrol/source/blender/src/fluidsim.c 2008-07-06 21:55:03 UTC 
(rev 15459)
@@ -994,7 +994,7 @@
                                // todo - use blenderInitElbeemMesh
                                elbeemMesh fsmesh;
                                elbeemResetMesh( &fsmesh );
-                               fsmesh.type = obit->fluidsimSettings->type;;
+                               fsmesh.type = obit->fluidsimSettings->type;
                                // get name of object for debugging solver
                                fsmesh.name = obit->id.name; 
 
@@ -1015,8 +1015,7 @@
                                fsmesh.channelScale            = 
channelObjMove[o][2];
                                fsmesh.channelActive           = 
channelObjActive[o];
                                if( (fsmesh.type == OB_FLUIDSIM_FLUID) ||
-                               (fsmesh.type == OB_FLUIDSIM_INFLOW) ||
-                               (fsmesh.type == OB_FLUIDSIM_CONTROL)) {
+                               (fsmesh.type == OB_FLUIDSIM_INFLOW)) {
                                        fsmesh.channelInitialVel       = 
channelObjInivel[o];
                                  fsmesh.localInivelCoords = 
((obit->fluidsimSettings->typeFlags&OB_FSINFLOW_LOCALCOORD)?1:0);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to