[Bf-committers] Missing functions in
bullet/LinearMath/SimdVector3.h
Stealth Apprentice
stealthapprentice at yahoo.com
Fri Jan 13 17:13:19 CET 2006
I never submitted this patch to the patch server
because I feel it is quite sloppy. (elbeempath.txt is
attached).
I am hoping that once people see what the problem is,
a more elegant solution can be derived.
Thanks for looking!
--- Nils Thuerey <nils at thuerey.de> wrote:
> Hello,
>
> that sounds interesting! Could you send the patch to
> the list or me?
>
> Thanks,
> -> Nils
>
>
> Stealth Apprentice wrote:
> > BTW, I should mention that the only other thing
> that
> > prevents a clean build from CVS on VC8 is elbeem.
> THe
> > problem in elbeem is that some of the templates
> need
> > to be explicitly instantiated.
> >
> > THis is probably the same issue alluded to in
> elbeem's
> > comments, where it says that there are problems on
> the
> > Intel compiler.
> >
> > The fix is tedious but easy. I can supply it if
> anyone
> > wants to test it.
> >
> > --- Stealth Apprentice
> <stealthapprentice at yahoo.com>
> > wrote:
> >
> >
> >>It seems something like the below is missing from
> >>bullet/LinearMath/SimdVector3.h, line 184
> >>
> >>Could someone patch this in? This is one reason
> some
> >>people can't build with a fresh get from CVS right
> >>now.
> >>
> >>
> >> SIMD_FORCE_INLINE void setMin(SimdVector3& v)
> >> {
> >> m_x = v.m_x < m_x ? v.m_x : m_x;
> >> m_y = v.m_y < m_y ? v.m_y : m_y;
> >> m_z = v.m_z < m_z ? v.m_z : m_z;
> >> }
> >>
> >> SIMD_FORCE_INLINE void setMax(SimdVector3& v)
> >> {
> >> m_x = v.m_x > m_x ? v.m_x : m_x;
> >> m_y = v.m_y > m_y ? v.m_y : m_y;
> >> m_z = v.m_z > m_z ? v.m_z : m_z;
> >> }
> >>
> >>
> >>__________________________________________________
> >>Do You Yahoo!?
> >>Tired of spam? Yahoo! Mail has the best spam
> >>protection around
> >>http://mail.yahoo.com
> >>_______________________________________________
> >>Bf-committers mailing list
> >>Bf-committers at projects.blender.org
> >>
> >
> >
>
http://projects.blender.org/mailman/listinfo/bf-committers
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at projects.blender.org
> >
>
http://projects.blender.org/mailman/listinfo/bf-committers
> >
>
>
> --
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> . . . . . . . . . .
> .
> .
> . Nils Thuerey
> .
> . LSS, Inf10 - University of Erlangen
> Nuremberg .
> . http://www.ntoken.com
> .
> .
> http://www10.informatik.uni-erlangen.de/~sinithue/
> .
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> . . . . . . . . . .
>
> > _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
>
http://projects.blender.org/mailman/listinfo/bf-committers
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
Index: intern/elbeem/intern/solver_init.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/elbeem/intern/solver_init.cpp,v
retrieving revision 1.5
diff -u -r1.5 solver_init.cpp
--- intern/elbeem/intern/solver_init.cpp 23 Nov 2005 12:51:07 -0000 1.5
+++ intern/elbeem/intern/solver_init.cpp 19 Dec 2005 07:04:10 -0000
@@ -1452,7 +1452,11 @@
#define LBM_INSTANTIATE LbmBGK3D
#endif // LBMDIM==3
+#if _MSC_VER < 1400
template class LbmFsgrSolver< LBM_INSTANTIATE >;
+#else
+class LbmFsgrSolver< LBM_INSTANTIATE > foo; // force instantiation for lib
+#endif
#endif // __APPLE_CC__ __INTEL_COMPILER
Index: intern/elbeem/intern/solver_main.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/elbeem/intern/solver_main.cpp,v
retrieving revision 1.5
diff -u -r1.5 solver_main.cpp
--- intern/elbeem/intern/solver_main.cpp 23 Nov 2005 12:51:07 -0000 1.5
+++ intern/elbeem/intern/solver_main.cpp 19 Dec 2005 07:13:52 -0000
@@ -2680,7 +2680,27 @@
#endif // LBMDIM==3
#endif // LBM_INSTANTIATE
+
+#if _MSC_VER < 1400
template class LbmFsgrSolver< LBM_INSTANTIATE >;
+#else
+template<>
+int LbmFsgrSolver<LBM_INSTANTIATE>::getDimension() { return LBM_INSTANTIATE::cDimension; }
+
+template<>
+string LbmFsgrSolver<LBM_INSTANTIATE>::getIdString() {
+ return string("FsgrSolver[") + LBM_INSTANTIATE::getIdString();
+}
+
+template<>
+void LbmFsgrSolver<LBM_INSTANTIATE>::step() {
+ initLevelOmegas();
+ stepMain();
+}
+
+
+#endif
+
// the intel compiler is too smart - so the virtual functions called from other cpp
// files have to be instantiated explcitly (otherwise this will cause undefined
// references to "non virtual thunks") ... still not working, though
Index: intern/elbeem/intern/solver_util.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/elbeem/intern/solver_util.cpp,v
retrieving revision 1.4
diff -u -r1.4 solver_util.cpp
--- intern/elbeem/intern/solver_util.cpp 23 Nov 2005 12:51:07 -0000 1.4
+++ intern/elbeem/intern/solver_util.cpp 19 Dec 2005 07:24:50 -0000
@@ -1071,7 +1071,723 @@
#define LBM_INSTANTIATE LbmBGK3D
#endif // LBMDIM==3
+#if _MSC_VER < 1400
template class LbmFsgrSolver< LBM_INSTANTIATE >;
+#else
+
+
+/*! init particle positions */
+template<>
+int LbmFsgrSolver<LBM_INSTANTIATE>::initParticles(ParticleTracer *partt) {
+#if ELBEEM_PLUGIN==1
+ partt = NULL; // remove warning
+#else // ELBEEM_PLUGIN
+ int workSet = mLevel[mMaxRefine].setCurr;
+ int tries = 0;
+ int num = 0;
+ mpParticles=partt;
+
+ //partt->setSimEnd ( ntlVec3Gfx(LBM_INSTANTIATE::mSizex-1, LBM_INSTANTIATE::mSizey-1, getForZMax1()) );
+ partt->setSimEnd ( ntlVec3Gfx(LBM_INSTANTIATE::mSizex, LBM_INSTANTIATE::mSizey, getForZMaxBnd(mMaxRefine)) );
+ partt->setSimStart( ntlVec3Gfx(0.0) );
+
+ while( (num<partt->getNumParticles()) && (tries<100*partt->getNumParticles()) ) {
+ double x,y,z;
+ x = 0.0+(( (float)(LBM_INSTANTIATE::mSizex-1) ) * (rand()/(RAND_MAX+1.0)) );
+ y = 0.0+(( (float)(LBM_INSTANTIATE::mSizey-1) ) * (rand()/(RAND_MAX+1.0)) );
+ z = 0.0+(( (float) getForZMax1(mMaxRefine) )* (rand()/(RAND_MAX+1.0)) );
+ int i = (int)(x-0.5);
+ int j = (int)(y-0.5);
+ int k = (int)(z-0.5);
+ if(LBM_INSTANTIATE::cDimension==2) {
+ k = 0;
+ z = 0.5; // place in the middle of domain
+ }
+
+ if( TESTFLAG( RFLAG(mMaxRefine, i,j,k, workSet), CFFluid ) ||
+ TESTFLAG( RFLAG(mMaxRefine, i,j,k, workSet), CFFluid ) ) { // only fluid cells?
+ // in fluid...
+ partt->addParticle(x,y,z);
+ num++;
+ }
+ tries++;
+ }
+ debMsgStd("LbmFsgrSolver::initParticles",DM_MSG,"Added "<<num<<" particles ", 10);
+ if(num != partt->getNumParticles()) return 1;
+#endif // ELBEEM_PLUGIN
+
+ return 0;
+}
+
+template<>
+void LbmFsgrSolver<LBM_INSTANTIATE>::advanceParticles(ParticleTracer *partt) {
+#if ELBEEM_PLUGIN==1
+ partt = NULL; // remove warning
+#else // ELBEEM_PLUGIN
+ int workSet = mLevel[mMaxRefine].setCurr;
+ LbmFloat vx=0.0,vy=0.0,vz=0.0;
+ LbmFloat rho, df[27]; //feq[27];
+ if(mpParticles!=partt) { errMsg("LbmFsgrSolver<LBM_INSTANTIATE>::advanceParticles","Invalid ParticleTracer..."); }
+
+ // TODO use timestep size
+ for(vector<ParticleObject>::iterator pit= partt->getParticlesBegin();
+ pit!= partt->getParticlesEnd(); pit++) {
+ //errorOut(" pit "<< (*pit).getPos() );
+ if( (*pit).getActive()==false ) continue;
+ int i,j,k;
+ ParticleObject *p = &(*pit);
+
+ // nearest neighbor, particle positions don't include empty bounds
+ ntlVec3Gfx pos = p->getPos();
+ i= (int)(pos[0]+0.5);
+ j= (int)(pos[1]+0.5);
+ k= (int)(pos[2]+0.5);
+ if(LBM_INSTANTIATE::cDimension==2) {
+ k = 0;
+ }
+
+ if( (i<0)||(i>LBM_INSTANTIATE::mSizex-1)||
+ (j<0)||(j>LBM_INSTANTIATE::mSizey-1)||
+ (k<0)||(k>LBM_INSTANTIATE::mSizez-1) ) {
+ p->setActive( false );
+ continue;
+ }
+
+ if(p->getStatus()==0) {
+ // no interpol
+ rho = vx = vy = vz = 0.0;
+ FORDF0{
+ LbmFloat cdf = QCELL(mMaxRefine, i,j,k, workSet, l);
+ df[l] = cdf;
+ rho += cdf;
+ vx += (LBM_INSTANTIATE::dfDvecX[l]*cdf);
+ vy += (LBM_INSTANTIATE::dfDvecY[l]*cdf);
+ vz += (LBM_INSTANTIATE::dfDvecZ[l]*cdf);
+ }
+
+ // remove gravity influence
+ //FORDF0{ feq[l] = LBM_INSTANTIATE::getCollideEq(l, rho,vx,vy,vz); }
+ //const LbmFloat Qo = LBM_INSTANTIATE::getLesNoneqTensorCoeff(df,feq);
+ //const LbmFloat lesomega = LBM_INSTANTIATE::getLesOmega(mLevel[mMaxRefine].omega,mLevel[mMaxRefine].lcsmago,Qo);
+ const LbmFloat lesomega = mLevel[mMaxRefine].omega; // no les
+ vx -= mLevel[mMaxRefine].gravity[0] * lesomega*0.5;
+ vy -= mLevel[mMaxRefine].gravity[1] * lesomega*0.5;
+ vz -= mLevel[mMaxRefine].gravity[2] * lesomega*0.5;
+
+ if( TESTFLAG( RFLAG(mMaxRefine, i,j,k, workSet), CFFluid ) ||
+ TESTFLAG( RFLAG(mMaxRefine, i,j,k, workSet), CFInter ) ) {
+ // still ok
+ } else {
+ // out of bounds, deactivate...
+ // FIXME make fsgr treatment
+ p->setActive( false );
+ continue;
+ LBM_INSTANTIATE::mNumParticlesLost++;
+ }
+
+ p->advance( vx,vy,vz );
+ // fluid particle
+ } else {
+ p->setVel( p->getVel() * 0.999 ); // dampen...
+ p->addToVel( vec2G(mLevel[mMaxRefine].gravity) );
+ p->advanceVel();
+ //errMsg("NNNPART"," at "<<p->getPos()<<" u="<<p->getVel() );
+ if( TESTFLAG( RFLAG(mMaxRefine, i,j,k, workSet), CFEmpty ) ||
+ TESTFLAG( RFLAG(mMaxRefine, i,j,k, workSet), CFInter ) ) {
+ // still ok
+ } else {
+ // out of bounds, deactivate...
+ // FIXME make fsgr treatment
+ p->setActive( false );
+ continue;
+ LBM_INSTANTIATE::mNumParticlesLost++;
+ }
+ } // air particle
+ }
+#endif // ELBEEM_PLUGIN
+}
+
+
+/*****************************************************************************/
+/*! internal quick print function (for debugging) */
+/*****************************************************************************/
+template<>
+void
+LbmFsgrSolver<LBM_INSTANTIATE>::printLbmCell(int level, int i, int j, int k, int set) {
+ stdCellId *newcid = new stdCellId;
+ newcid->level = level;
+ newcid->x = i;
+ newcid->y = j;
+ newcid->z = k;
+
+ // this function is not called upon clicking, then its from setMouseClick
+ debugPrintNodeInfo( newcid, set );
+ delete newcid;
+}
+
+template<>
+void
+LbmFsgrSolver<LBM_INSTANTIATE>::debugMarkCellCall(int level, int vi,int vj,int vk) {
+ stdCellId *newcid = new stdCellId;
+ newcid->level = level;
+ newcid->x = vi;
+ newcid->y = vj;
+ newcid->z = vk;
+ addCellToMarkedList( newcid );
+}
+
+
+/*! calculate speeds of fluid objects (or inflow) */
+template<>
+void LbmFsgrSolver<LBM_INSTANTIATE>::recalculateObjectSpeeds() {
+ int numobjs = (int)(LBM_INSTANTIATE::mpGiObjects->size());
+ // note - (numobjs + 1) is entry for domain settings
+ if(numobjs>255-1) {
+ errFatal("LbmFsgrSolver::recalculateObjectSpeeds","More than 256 objects currently not supported...",SIMWORLD_INITERROR);
+ return;
+ }
+ mObjectSpeeds.resize(numobjs+1);
+ for(int i=0; i<(int)(numobjs+0); i++) {
+ mObjectSpeeds[i] = vec2L(LBM_INSTANTIATE::mpParam->calculateLattVelocityFromRw( vec2P( (*LBM_INSTANTIATE::mpGiObjects)[i]->getInitialVelocity() )));
+ //errMsg("recalculateObjectSpeeds","id"<<i<<" set to "<< mObjectSpeeds[i]<<", unscaled:"<< (*LBM_INSTANTIATE::mpGiObjects)[i]->getInitialVelocity() );
+ }
+
+ // also reinit part slip values here
+ mObjectPartslips.resize(numobjs+1);
+ for(int i=0; i<(int)(numobjs+0); i++) {
+ mObjectPartslips[i] = (LbmFloat)(*LBM_INSTANTIATE::mpGiObjects)[i]->getGeoPartSlipValue();
+ }
+ //errMsg("GEOIN"," dm set "<<mDomainPartSlipValue);
+ mObjectPartslips[numobjs] = mDomainPartSlipValue;
+}
+
+
+
+//! for raytracing
+template<>
+void LbmFsgrSolver<LBM_INSTANTIATE>::prepareVisualization( void ) {
+ int lev = mMaxRefine;
+ int workSet = mLevel[lev].setCurr;
+
+ //make same prepareVisualization and getIsoSurface...
+#if LBMDIM==2
+ // 2d, place in the middle of isofield slice (k=2)
+# define ZKD1 0
+ // 2d z offset = 2, lbmGetData adds 1, so use one here
+# define ZKOFF 1
+ // reset all values...
+ for(int k= 0; k< 5; ++k)
+ for(int j=0;j<mLevel[lev].lSizey-0;j++)
+ for(int i=0;i<mLevel[lev].lSizex-0;i++) {
+ *LBM_INSTANTIATE::mpIso->lbmGetData(i,j,ZKOFF)=0.0;
+ }
+#else // LBMDIM==2
+ // 3d, use normal bounds
+# define ZKD1 1
+# define ZKOFF k
+ // reset all values...
+ for(int k= getForZMinBnd(); k< getForZMaxBnd(lev); ++k)
+ for(int j=0;j<mLevel[lev].lSizey-0;j++)
+ for(int i=0;i<mLevel[lev].lSizex-0;i++) {
+ *LBM_INSTANTIATE::mpIso->lbmGetData(i,j,ZKOFF)=0.0;
+ }
+#endif // LBMDIM==2
+
+
+
+ // add up...
+ float val = 0.0;
+ for(int k= getForZMin1(); k< getForZMax1(lev); ++k)
+ for(int j=1;j<mLevel[lev].lSizey-1;j++)
+ for(int i=1;i<mLevel[lev].lSizex-1;i++) {
+
+ //continue; // OFF DEBUG
+ if(RFLAG(lev, i,j,k,workSet)&(CFBnd|CFEmpty)) {
+ continue;
+ } else
+ if( (RFLAG(lev, i,j,k,workSet)&CFInter) && (!(RFLAG(lev, i,j,k,workSet)&CFNoNbEmpty)) ){
+ // no empty nb interface cells are treated as full
+ val = (QCELL(lev, i,j,k,workSet, dFfrac));
+ /* // flicker-test-fix: no real difference
+ if( (!(RFLAG(lev, i,j,k,workSet)&CFNoBndFluid)) &&
+ (RFLAG(lev, i,j,k,workSet)&CFNoNbFluid) &&
+ (val<LBM_INSTANTIATE::mIsoValue) ){
+ val = LBM_INSTANTIATE::mIsoValue*1.1; }
+ // */
+ } else {
+ // fluid?
+ val = 1.0; ///27.0;
+ } // */
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j-1 ,ZKOFF-ZKD1) += ( val * mIsoWeight[0] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j-1 ,ZKOFF-ZKD1) += ( val * mIsoWeight[1] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j-1 ,ZKOFF-ZKD1) += ( val * mIsoWeight[2] );
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j ,ZKOFF-ZKD1) += ( val * mIsoWeight[3] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j ,ZKOFF-ZKD1) += ( val * mIsoWeight[4] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j ,ZKOFF-ZKD1) += ( val * mIsoWeight[5] );
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j+1 ,ZKOFF-ZKD1) += ( val * mIsoWeight[6] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j+1 ,ZKOFF-ZKD1) += ( val * mIsoWeight[7] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j+1 ,ZKOFF-ZKD1) += ( val * mIsoWeight[8] );
+
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j-1 ,ZKOFF ) += ( val * mIsoWeight[9] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j-1 ,ZKOFF ) += ( val * mIsoWeight[10] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j-1 ,ZKOFF ) += ( val * mIsoWeight[11] );
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j ,ZKOFF ) += ( val * mIsoWeight[12] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j ,ZKOFF ) += ( val * mIsoWeight[13] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j ,ZKOFF ) += ( val * mIsoWeight[14] );
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j+1 ,ZKOFF ) += ( val * mIsoWeight[15] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j+1 ,ZKOFF ) += ( val * mIsoWeight[16] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j+1 ,ZKOFF ) += ( val * mIsoWeight[17] );
+
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j-1 ,ZKOFF+ZKD1) += ( val * mIsoWeight[18] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j-1 ,ZKOFF+ZKD1) += ( val * mIsoWeight[19] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j-1 ,ZKOFF+ZKD1) += ( val * mIsoWeight[20] );
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j ,ZKOFF+ZKD1) += ( val * mIsoWeight[21] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j ,ZKOFF+ZKD1)+= ( val * mIsoWeight[22] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j ,ZKOFF+ZKD1) += ( val * mIsoWeight[23] );
+
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i-1 , j+1 ,ZKOFF+ZKD1) += ( val * mIsoWeight[24] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i , j+1 ,ZKOFF+ZKD1) += ( val * mIsoWeight[25] );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i+1 , j+1 ,ZKOFF+ZKD1) += ( val * mIsoWeight[26] );
+ }
+
+
+#if ELBEEM_PLUGIN!=1
+ if(mUseTestdata) {
+ int border = 1;
+ for(int k=0;k<mLevel[mMaxRefine].lSizez-1;k++)
+ for(int j=0;j<mLevel[mMaxRefine].lSizey-1;j++) {
+ for(int l=0; l<=border; l++) {
+ *LBM_INSTANTIATE::mpIso->lbmGetData( l-1, j,ZKOFF) = *LBM_INSTANTIATE::mpIso->lbmGetData( border+1, j,ZKOFF);
+ *LBM_INSTANTIATE::mpIso->lbmGetData( mLevel[mMaxRefine].lSizex-l, j,ZKOFF) = *LBM_INSTANTIATE::mpIso->lbmGetData( mLevel[mMaxRefine].lSizex-border-1, j,ZKOFF);
+ }
+ }
+
+ for(int k=0;k<mLevel[mMaxRefine].lSizez-1;k++)
+ for(int i=-1;i<mLevel[mMaxRefine].lSizex+1;i++) {
+ for(int l=0; l<=border; l++) {
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i, l-1, ZKOFF) = *LBM_INSTANTIATE::mpIso->lbmGetData( i, border+1, ZKOFF);
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i, mLevel[mMaxRefine].lSizey-l, ZKOFF) = *LBM_INSTANTIATE::mpIso->lbmGetData( i, mLevel[mMaxRefine].lSizey-border-1, ZKOFF);
+ }
+ }
+
+ if(LBM_INSTANTIATE::cDimension == 3) {
+ // only for 3D
+ for(int j=-1;j<mLevel[mMaxRefine].lSizey+1;j++)
+ for(int i=-1;i<mLevel[mMaxRefine].lSizex+1;i++) {
+ for(int l=0; l<=border; l++) {
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i,j,l-1 ) = *LBM_INSTANTIATE::mpIso->lbmGetData( i,j, border+1 );
+ *LBM_INSTANTIATE::mpIso->lbmGetData( i,j,mLevel[mMaxRefine].lSizez-l) = *LBM_INSTANTIATE::mpIso->lbmGetData( i,j,mLevel[mMaxRefine].lSizez-1-border);
+ }
+ }
+ }
+ } // testdata
+#endif // ELBEEM_PLUGIN
+ // */
+
+ // update preview, remove 2d?
+ if(LBM_INSTANTIATE::mOutputSurfacePreview) {
+ int pvsx = (int)(LBM_INSTANTIATE::mPreviewFactor*LBM_INSTANTIATE::mSizex);
+ int pvsy = (int)(LBM_INSTANTIATE::mPreviewFactor*LBM_INSTANTIATE::mSizey);
+ int pvsz = (int)(LBM_INSTANTIATE::mPreviewFactor*LBM_INSTANTIATE::mSizez);
+ //float scale = (float)LBM_INSTANTIATE::mSizex / previewSize;
+ LbmFloat scalex = (LbmFloat)LBM_INSTANTIATE::mSizex/(LbmFloat)pvsx;
+ LbmFloat scaley = (LbmFloat)LBM_INSTANTIATE::mSizey/(LbmFloat)pvsy;
+ LbmFloat scalez = (LbmFloat)LBM_INSTANTIATE::mSizez/(LbmFloat)pvsz;
+ for(int k= 0; k< ((LBM_INSTANTIATE::cDimension==3) ? (pvsz-1):1) ; ++k)
+ for(int j=0;j< pvsy;j++)
+ for(int i=0;i< pvsx;i++) {
+ *mpPreviewSurface->lbmGetData(i,j,k) = *LBM_INSTANTIATE::mpIso->lbmGetData( (int)(i*scalex), (int)(j*scaley), (int)(k*scalez) );
+ }
+ // set borders again...
+ for(int k= 0; k< ((LBM_INSTANTIATE::cDimension == 3) ? (pvsz-1):1) ; ++k) {
+ for(int j=0;j< pvsy;j++) {
+ *mpPreviewSurface->lbmGetData(0,j,k) = *LBM_INSTANTIATE::mpIso->lbmGetData( 0, (int)(j*scaley), (int)(k*scalez) );
+ *mpPreviewSurface->lbmGetData(pvsx-1,j,k) = *LBM_INSTANTIATE::mpIso->lbmGetData( LBM_INSTANTIATE::mSizex-1, (int)(j*scaley), (int)(k*scalez) );
+ }
+ for(int i=0;i< pvsx;i++) {
+ *mpPreviewSurface->lbmGetData(i,0,k) = *LBM_INSTANTIATE::mpIso->lbmGetData( (int)(i*scalex), 0, (int)(k*scalez) );
+ *mpPreviewSurface->lbmGetData(i,pvsy-1,k) = *LBM_INSTANTIATE::mpIso->lbmGetData( (int)(i*scalex), LBM_INSTANTIATE::mSizey-1, (int)(k*scalez) );
+ }
+ }
+ if(LBM_INSTANTIATE::cDimension == 3) {
+ // only for 3D
+ for(int j=0;j<pvsy;j++)
+ for(int i=0;i<pvsx;i++) {
+ *mpPreviewSurface->lbmGetData(i,j,0) = *LBM_INSTANTIATE::mpIso->lbmGetData( (int)(i*scalex), (int)(j*scaley) , 0);
+ *mpPreviewSurface->lbmGetData(i,j,pvsz-1) = *LBM_INSTANTIATE::mpIso->lbmGetData( (int)(i*scalex), (int)(j*scaley) , LBM_INSTANTIATE::mSizez-1);
+ }
+ } // borders done...
+ }
+
+#if ELBEEM_PLUGIN!=1
+ if(LBM_INSTANTIATE::mInitDone) {
+ if(mpTest->mDebugvalue3<=0.0) handleTestdata();
+ }
+#endif // ELBEEM_PLUGIN!=1
+ // correction
+ return;
+}
+
+
+
+
+/*****************************************************************************/
+/*! debug object display */
+/*****************************************************************************/
+template<>
+vector<ntlGeometryObject*> LbmFsgrSolver<LBM_INSTANTIATE>::getDebugObjects() {
+ vector<ntlGeometryObject*> debo;
+ if(LBM_INSTANTIATE::mOutputSurfacePreview) {
+ debo.push_back( mpPreviewSurface );
+ }
+#if ELBEEM_PLUGIN!=1
+ if(mUseTestdata) {
+ vector<ntlGeometryObject*> tdebo;
+ tdebo = mpTest->getDebugObjects();
+ for(size_t i=0; i<tdebo.size(); i++) debo.push_back( tdebo[i] );
+ }
+#endif // ELBEEM_PLUGIN
+ return debo;
+}
+
+
+
+template<>
+CellIdentifierInterface*
+LbmFsgrSolver<LBM_INSTANTIATE>::getFirstCell( ) {
+ int level = mMaxRefine;
+
+#if LBMDIM==3
+ if(mMaxRefine>0) { level = mMaxRefine-1; } // NO1HIGHESTLEV DEBUG
+#endif
+ level = guiRoiMaxLev;
+ if(level>mMaxRefine) level = mMaxRefine;
+
+ //errMsg("LbmFsgrSolver::getFirstCell","Celliteration started...");
+ stdCellId *cid = new stdCellId;
+ cid->level = level;
+ cid->x = CID_SX;
+ cid->y = CID_SY;
+ cid->z = CID_SZ;
+ return cid;
+}
+
+template<>
+typename LbmFsgrSolver<LBM_INSTANTIATE>::stdCellId*
+LbmFsgrSolver<LBM_INSTANTIATE>::convertBaseCidToStdCid( CellIdentifierInterface* basecid) {
+ //stdCellId *cid = dynamic_cast<stdCellId*>( basecid );
+ stdCellId *cid = (stdCellId*)( basecid );
+ return cid;
+}
+
+template<>
+void
+LbmFsgrSolver<LBM_INSTANTIATE>::advanceCell( CellIdentifierInterface* basecid) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ if(cid->getEnd()) return;
+
+ //debugOut(" ADb "<<cid->x<<","<<cid->y<<","<<cid->z<<" e"<<cid->getEnd(), 10);
+ cid->x++;
+ if(cid->x > CID_EX){ cid->x = CID_SX; cid->y++;
+ if(cid->y > CID_EY){ cid->y = CID_SY; cid->z++;
+ if(cid->z > CID_EZ){
+ cid->level--;
+ cid->x = CID_SX;
+ cid->y = CID_SY;
+ cid->z = CID_SZ;
+ if(cid->level < guiRoiMinLev) {
+ cid->level = guiRoiMaxLev;
+ cid->setEnd( true );
+ }
+ }
+ }
+ }
+ //debugOut(" ADa "<<cid->x<<","<<cid->y<<","<<cid->z<<" e"<<cid->getEnd(), 10);
+}
+
+template<>
+bool
+LbmFsgrSolver<LBM_INSTANTIATE>::noEndCell( CellIdentifierInterface* basecid) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ return (!cid->getEnd());
+}
+
+template<>
+void
+LbmFsgrSolver<LBM_INSTANTIATE>::deleteCellIterator( CellIdentifierInterface** cid ) {
+ delete *cid;
+ *cid = NULL;
+}
+
+template<>
+CellIdentifierInterface*
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellAt( ntlVec3Gfx pos ) {
+ //int cellok = false;
+ pos -= (LBM_INSTANTIATE::mvGeoStart);
+
+ LbmFloat mmaxsize = mLevel[mMaxRefine].nodeSize;
+ for(int level=mMaxRefine; level>=0; level--) { // finest first
+ //for(int level=0; level<=mMaxRefine; level++) { // coarsest first
+ LbmFloat nsize = mLevel[level].nodeSize;
+ int x,y,z;
+ //LbmFloat nsize = getCellSize(NULL)[0]*2.0;
+ x = (int)((pos[0]-0.5*mmaxsize) / nsize );
+ y = (int)((pos[1]-0.5*mmaxsize) / nsize );
+ z = (int)((pos[2]-0.5*mmaxsize) / nsize );
+ if(LBM_INSTANTIATE::cDimension==2) z = 0;
+
+ // double check...
+ //int level = mMaxRefine;
+ if(x<0) continue;
+ if(y<0) continue;
+ if(z<0) continue;
+ if(x>=mLevel[level].lSizex) continue;
+ if(y>=mLevel[level].lSizey) continue;
+ if(z>=mLevel[level].lSizez) continue;
+
+ // return fluid/if/border cells
+ if( ( (RFLAG(level, x,y,z, mLevel[level].setCurr)&(CFUnused)) ) ||
+ ( (level<mMaxRefine) && (RFLAG(level, x,y,z, mLevel[level].setCurr)&(CFUnused|CFEmpty)) ) ) {
+ continue;
+ } // */
+
+ stdCellId *newcid = new stdCellId;
+ newcid->level = level;
+ newcid->x = x;
+ newcid->y = y;
+ newcid->z = z;
+ //errMsg("cellAt",LBM_INSTANTIATE::mName<<" "<<pos<<" l"<<level<<":"<<x<<","<<y<<","<<z<<" "<<convertCellFlagType2String(RFLAG(level, x,y,z, mLevel[level].setCurr)) );
+ return newcid;
+ }
+
+ return NULL;
+}
+
+
+// INFO functions
+
+template<>
+int
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellSet ( CellIdentifierInterface* basecid) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ return mLevel[cid->level].setCurr;
+ //return mLevel[cid->level].setOther;
+}
+
+template<>
+int
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellLevel ( CellIdentifierInterface* basecid) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ return cid->level;
+}
+
+template<>
+ntlVec3Gfx
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellOrigin ( CellIdentifierInterface* basecid) {
+ ntlVec3Gfx ret;
+
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ ntlVec3Gfx cs( mLevel[cid->level].nodeSize );
+ if(LBM_INSTANTIATE::cDimension==2) { cs[2] = 0.0; }
+
+ if(LBM_INSTANTIATE::cDimension==2) {
+ ret =(LBM_INSTANTIATE::mvGeoStart -(cs*0.5) + ntlVec3Gfx( cid->x *cs[0], cid->y *cs[1], (LBM_INSTANTIATE::mvGeoEnd[2]-LBM_INSTANTIATE::mvGeoStart[2])*0.5 )
+ + ntlVec3Gfx(0.0,0.0,cs[1]*-0.25)*cid->level )
+ +getCellSize(basecid);
+ } else {
+ ret =(LBM_INSTANTIATE::mvGeoStart -(cs*0.5) + ntlVec3Gfx( cid->x *cs[0], cid->y *cs[1], cid->z *cs[2] ))
+ +getCellSize(basecid);
+ }
+ return (ret);
+}
+
+template<>
+ntlVec3Gfx
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellSize ( CellIdentifierInterface* basecid) {
+ // return half size
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ ntlVec3Gfx retvec( mLevel[cid->level].nodeSize * 0.5 );
+ // 2d display as rectangles
+ if(LBM_INSTANTIATE::cDimension==2) { retvec[2] = 0.0; }
+ return (retvec);
+}
+
+template<>
+LbmFloat
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellDensity ( CellIdentifierInterface* basecid,int set) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+
+ LbmFloat rho = 0.0;
+ //FORDF0 { rho += QCELL(cid->level, cid->x,cid->y,cid->z, set, l); } // ORG
+ //return ((rho-1.0) * mLevel[cid->level].simCellSize / mLevel[cid->level].stepsize) +1.0; // ORG
+ if(RFLAG(cid->level, cid->x,cid->y,cid->z, set)&CFInter) { // test
+ LbmFloat ux,uy,uz;
+ ux=uy=uz= 0.0;
+ int lev = cid->level;
+ LbmFloat df[27], feqOld[27];
+ FORDF0 {
+ rho += QCELL(lev, cid->x,cid->y,cid->z, set, l);
+ ux += LBM_INSTANTIATE::dfDvecX[l]* QCELL(lev, cid->x,cid->y,cid->z, set, l);
+ uy += LBM_INSTANTIATE::dfDvecY[l]* QCELL(lev, cid->x,cid->y,cid->z, set, l);
+ uz += LBM_INSTANTIATE::dfDvecZ[l]* QCELL(lev, cid->x,cid->y,cid->z, set, l);
+ df[l] = QCELL(lev, cid->x,cid->y,cid->z, set, l);
+ }
+ FORDF0 {
+ feqOld[l] = LBM_INSTANTIATE::getCollideEq(l, rho,ux,uy,uz);
+ }
+ const LbmFloat Qo = LBM_INSTANTIATE::getLesNoneqTensorCoeff(df,feqOld);
+ //const LbmFloat modOmega = LBM_INSTANTIATE::getLesOmega(mLevel[lev].omega, mLevel[lev].lcsmago,Qo);
+ //rho = (2.0-modOmega) *25.0;
+ rho = Qo*100.0;
+ //if(cid->x==24){ errMsg("MODOMT"," at "<<PRINT_VEC(cid->x,cid->y,cid->z)<<" = "<<rho<<" "<<Qo); }
+ //else{ rho=0.0; }
+ } // test
+ return rho; // test
+}
+
+template<>
+LbmVec
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellVelocity ( CellIdentifierInterface* basecid,int set) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+
+ LbmFloat ux,uy,uz;
+ ux=uy=uz= 0.0;
+ FORDF0 {
+ ux += LBM_INSTANTIATE::dfDvecX[l]* QCELL(cid->level, cid->x,cid->y,cid->z, set, l);
+ uy += LBM_INSTANTIATE::dfDvecY[l]* QCELL(cid->level, cid->x,cid->y,cid->z, set, l);
+ uz += LBM_INSTANTIATE::dfDvecZ[l]* QCELL(cid->level, cid->x,cid->y,cid->z, set, l);
+ }
+ LbmVec vel(ux,uy,uz);
+ // TODO fix...
+ return (vel * mLevel[cid->level].simCellSize / mLevel[cid->level].stepsize * LBM_INSTANTIATE::mDebugVelScale); // normal
+}
+
+template<>
+LbmFloat
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellDf( CellIdentifierInterface* basecid,int set, int dir) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ return QCELL(cid->level, cid->x,cid->y,cid->z, set, dir);
+}
+template<>
+LbmFloat
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellMass( CellIdentifierInterface* basecid,int set) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ return QCELL(cid->level, cid->x,cid->y,cid->z, set, dMass);
+}
+template<>
+LbmFloat
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellFill( CellIdentifierInterface* basecid,int set) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ if(RFLAG(cid->level, cid->x,cid->y,cid->z, set)&CFInter) return QCELL(cid->level, cid->x,cid->y,cid->z, set, dFfrac);
+ if(RFLAG(cid->level, cid->x,cid->y,cid->z, set)&CFFluid) return 1.0;
+ return 0.0;
+ //return QCELL(cid->level, cid->x,cid->y,cid->z, set, dFfrac);
+}
+template<>
+CellFlagType
+LbmFsgrSolver<LBM_INSTANTIATE>::getCellFlag( CellIdentifierInterface* basecid,int set) {
+ stdCellId *cid = convertBaseCidToStdCid(basecid);
+ return RFLAG(cid->level, cid->x,cid->y,cid->z, set);
+}
+
+template<>
+LbmFloat
+LbmFsgrSolver<LBM_INSTANTIATE>::getEquilDf( int l ) {
+ return LBM_INSTANTIATE::dfEquil[l];
+}
+
+template<>
+int
+LbmFsgrSolver<LBM_INSTANTIATE>::getDfNum( ) {
+ return LBM_INSTANTIATE::cDfNum;
+}
+
+
+
+//! display a single node
+template<>
+void LbmFsgrSolver<LBM_INSTANTIATE>::debugPrintNodeInfo(CellIdentifierInterface* cell, int forceSet) {
+ //string printInfo,
+ // force printing of one set? default = -1 = off
+ bool printDF = false;
+ bool printRho = false;
+ bool printVel = false;
+ bool printFlag = false;
+ bool printGeom = false;
+ bool printMass=false;
+ bool printBothSets = false;
+ string printInfo = this->getNodeInfoString();
+
+ for(size_t i=0; i<printInfo.length()-0; i++) {
+ char what = printInfo[i];
+ switch(what) {
+ case '+': // all on
+ printDF = true; printRho = true; printVel = true; printFlag = true; printGeom = true; printMass = true ;
+ printBothSets = true; break;
+ case '-': // all off
+ printDF = false; printRho = false; printVel = false; printFlag = false; printGeom = false; printMass = false;
+ printBothSets = false; break;
+ case 'd': printDF = true; break;
+ case 'r': printRho = true; break;
+ case 'v': printVel = true; break;
+ case 'f': printFlag = true; break;
+ case 'g': printGeom = true; break;
+ case 'm': printMass = true; break;
+ case 's': printBothSets = true; break;
+ default:
+ errFatal("debugPrintNodeInfo","Invalid node info id "<<what,SIMWORLD_GENERICERROR); return;
+ }
+ }
+
+ ntlVec3Gfx org = this->getCellOrigin( cell );
+ ntlVec3Gfx halfsize = this->getCellSize( cell );
+ int set = this->getCellSet( cell );
+ debMsgStd("debugPrintNodeInfo",DM_NOTIFY, "Printing cell info '"<<printInfo<<"' for node: "<<cell->getAsString()<<" from "<<this->getName()<<" currSet:"<<set , 1);
+ if(printGeom) debMsgStd(" ",DM_MSG, "Org:"<<org<<" Halfsize:"<<halfsize<<" ", 1);
+
+ int setmax = 2;
+ if(!printBothSets) setmax = 1;
+ if(forceSet>=0) setmax = 1;
+
+ for(int s=0; s<setmax; s++) {
+ int workset = set;
+ if(s==1){ workset = (set^1); }
+ if(forceSet>=0) workset = forceSet;
+ debMsgStd(" ",DM_MSG, "Printing set:"<<workset<<" orgSet:"<<set, 1);
+
+ if(printDF) {
+ for(int l=0; l<this->getDfNum(); l++) { // FIXME ??
+ debMsgStd(" ",DM_MSG, " Df"<<l<<": "<<this->getCellDf(cell,workset,l), 1);
+ }
+ }
+ if(printRho) {
+ debMsgStd(" ",DM_MSG, " Rho: "<<this->getCellDensity(cell,workset), 1);
+ }
+ if(printVel) {
+ debMsgStd(" ",DM_MSG, " Vel: "<<this->getCellVelocity(cell,workset), 1);
+ }
+ if(printFlag) {
+ CellFlagType flag = this->getCellFlag(cell,workset);
+ debMsgStd(" ",DM_MSG, " Flg: "<< flag<<" "<<convertFlags2String( flag ) <<" "<<convertCellFlagType2String( flag ), 1);
+ }
+ if(printMass) {
+ debMsgStd(" ",DM_MSG, " Mss: "<<this->getCellMass(cell,workset), 1);
+ }
+ }
+}
+
+
+
+
+#endif // _MSC_VER < 1400
#endif // __APPLE_CC__ __INTEL_COMPILER
More information about the Bf-committers
mailing list