[Bf-blender-cvs] [25170baeab5] fluid-mantaflow: updated manta pp files

Sebastián Barschkis noreply at git.blender.org
Fri Jul 21 16:17:43 CEST 2017


Commit: 25170baeab5b2fc6d8de76cdaa4497eebf86bfa7
Author: Sebastián Barschkis
Date:   Fri Jul 21 16:16:37 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB25170baeab5b2fc6d8de76cdaa4497eebf86bfa7

updated manta pp files

fix for outflow flag at outermost cell: now overriding with obstacle is possible, PFLOAT name change in mantaflow

===================================================================

M	intern/mantaflow/intern/manta_pp/tbb/grid.cpp
M	intern/mantaflow/intern/manta_pp/tbb/grid.h
M	intern/mantaflow/intern/manta_pp/tbb/particle.h
M	intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
M	intern/mantaflow/intern/strings/liquid_script.h

===================================================================

diff --git a/intern/mantaflow/intern/manta_pp/tbb/grid.cpp b/intern/mantaflow/intern/manta_pp/tbb/grid.cpp
index 448f3564416..ef2fe4a972c 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/grid.cpp
+++ b/intern/mantaflow/intern/manta_pp/tbb/grid.cpp
@@ -685,7 +685,7 @@ void FlagGrid::initBoundaries(const int &boundaryWidth, const int *types) {
 	}
 }
 
-void FlagGrid::updateFromLevelset(LevelsetGrid& levelset) {
+void FlagGrid::updateFromLevelset(LevelsetGrid& levelset, LevelsetGrid* obsLevelset) {
 	FOR_IDX(*this) {
 		if (!isObstacle(idx) && !isOutflow(idx)) {
 			const Real phi = levelset[idx];
@@ -694,8 +694,12 @@ void FlagGrid::updateFromLevelset(LevelsetGrid& levelset) {
 			mData[idx] &= ~(TypeEmpty | TypeFluid); // clear empty/fluid flags
 			mData[idx] |= (phi <= 0) ? TypeFluid : TypeEmpty; // set resepctive flag
 		}
+		if (obsLevelset && isOutflow(idx)) {
+			const Real phiObs = (*obsLevelset)[idx];
+			if (phiObs <= 0) mData[idx] = TypeObstacle; // enforce obstacle flag
+		}
 	}
-}   
+}
 
 void FlagGrid::fillGrid(int type) {
 	FOR_IDX(*this) {
diff --git a/intern/mantaflow/intern/manta_pp/tbb/grid.h b/intern/mantaflow/intern/manta_pp/tbb/grid.h
index 62c9310fe49..44993253ffb 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/grid.h
+++ b/intern/mantaflow/intern/manta_pp/tbb/grid.h
@@ -336,7 +336,7 @@ void initDomain( const int &boundaryWidth = 0 , const std::string &wall = "xXyYz
 
 	void initBoundaries( const int &boundaryWidth, const int *types );
 
-	void updateFromLevelset(LevelsetGrid& levelset); static PyObject* _W_28 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FlagGrid* pbo = dynamic_cast<FlagGrid*>(Pb::objFromPy(_self)); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(pbo->getParent(), "FlagGrid::updateFromLevelset" , !noTiming); PyObject *_retval = 0; { ArgLocker _lock; LevelsetGrid& levelset = *_args.getPtr<LevelsetGrid >("levelset",0,&_lock);  pbo->_arg [...]
+	void updateFromLevelset(LevelsetGrid& levelset, LevelsetGrid* obsLevelset=NULL); static PyObject* _W_28 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FlagGrid* pbo = dynamic_cast<FlagGrid*>(Pb::objFromPy(_self)); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(pbo->getParent(), "FlagGrid::updateFromLevelset" , !noTiming); PyObject *_retval = 0; { ArgLocker _lock; LevelsetGrid& levelset = *_args.getPtr<LevelsetGrid >( [...]
 	void fillGrid(int type=TypeFluid); static PyObject* _W_29 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FlagGrid* pbo = dynamic_cast<FlagGrid*>(Pb::objFromPy(_self)); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(pbo->getParent(), "FlagGrid::fillGrid" , !noTiming); PyObject *_retval = 0; { ArgLocker _lock; int type = _args.getOpt<int >("type",0,TypeFluid,&_lock);  pbo->_args.copy(_args);  _retval = getPyNone(); pbo [...]
 #define _C_FlagGrid
 ;
diff --git a/intern/mantaflow/intern/manta_pp/tbb/particle.h b/intern/mantaflow/intern/manta_pp/tbb/particle.h
index 9185b532983..531a7e4b5fe 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/particle.h
+++ b/intern/mantaflow/intern/manta_pp/tbb/particle.h
@@ -47,7 +47,7 @@ class ParticleBase : public PbClass {public:
 		PNEW          = (1<<1),  // particles newly created in this step
 		PDROPLET      = (1<<2),  // secondary particle types
 		PBUBBLE       = (1<<3),
-		PFLOAT        = (1<<4),
+		PFLOATER      = (1<<4),
 		PTRACER       = (1<<5),
 		PDELETE       = (1<<10), // mark as deleted, will be deleted in next compress() step
 		PINVALID      = (1<<30), // unused
diff --git a/intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp b/intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
index a93e738ab6d..2514d072669 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
+++ b/intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
@@ -601,7 +601,6 @@ void combineGridVel( MACGrid& vel, Grid<Vec3>& weight, MACGrid& combineVel, Leve
 
 
 void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, LevelsetGrid& phi, ParticleDataImpl<Vec3>& partVel, ParticleDataImpl<int>& partType, Real dropVelThresh, Real bubbleRise, Real tracerAmount, int minParticles, int maxParticles, Vec3 gravity, bool drops=true, bool floats=false, bool tracers=false, bool bubbles=true) {
-	bool is3D = flags.is3D();
 	Real dt = flags.getParent()->getDt();
 	Vec3 grav = gravity * flags.getParent()->getDt() / flags.getDx();
 	Grid<int> tmp( vel.getParent() );
@@ -624,7 +623,7 @@ void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, L
 
 			// Try to save float / tracer particle by pushing it into the valid region
 			Real phiv = phi.getInterpolated( parts.getPos(idx) );
-			if (( partType[idx] & ParticleBase::PFLOAT && (phiv > FLOAT_THRESH || phiv < -FLOAT_THRESH)) ||
+			if (( partType[idx] & ParticleBase::PFLOATER && (phiv > FLOAT_THRESH || phiv < -FLOAT_THRESH)) ||
 				( partType[idx] & ParticleBase::PTRACER && phiv > 0. ))
 			{
 				Vec3 grad = getGradient( phi, p1i.x,p1i.y,p1i.z );
@@ -640,12 +639,12 @@ void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, L
 //			if (floats && partType[idx] & ParticleBase::PBUBBLE && phiv > -FLOAT_THRESH)
 //			{
 //				partVel[idx] = vel.getInterpolated( parts[idx].pos ); // floats have fluid vel
-//				partType[idx] = ParticleBase::PFLOAT;
+//				partType[idx] = ParticleBase::PFLOATER;
 //			}
 
 			// Kill particles depending on type. Especially those that were not converted (see above) to other particle type
 			if ( partType[idx] & ParticleBase::PDROPLET && phiv < BUBBLE_THRESH ) { parts.kill(idx); continue; }
-			if ( partType[idx] & ParticleBase::PFLOAT && (phiv > 0. || phiv < -FLOAT_THRESH)) { parts.kill(idx); continue; }
+			if ( partType[idx] & ParticleBase::PFLOATER && (phiv > 0. || phiv < -FLOAT_THRESH)) { parts.kill(idx); continue; }
 			if ( partType[idx] & ParticleBase::PBUBBLE && phiv > 0. ) { parts.kill(idx); continue; }
 			if ( partType[idx] & ParticleBase::PTRACER && phiv > 0. ) { parts.kill(idx); continue; }
 
@@ -736,7 +735,7 @@ void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, L
 				if (partType[idx] & ParticleBase::PDROPLET && phiv < -FLOAT_THRESH) {
 					partVel[idx] = partVel[idx] * 0.5;
 				}
-				
+
 				// Update particle type (convert to bubble) and set initial velocity (now use fluid vel)
 				if (partType[idx] & ParticleBase::PDROPLET && phiv < BUBBLE_THRESH) {
 					partVel[idx] = vel.getInterpolated( parts[idx].pos );
@@ -784,11 +783,11 @@ void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, L
 
 				// Update particle type
 				if (parts.getStatus(idx) & ParticleBase::PNEW) {
-					partType[idx] = ParticleBase::PFLOAT;
+					partType[idx] = ParticleBase::PFLOATER;
 				}
 
 				// Float particles move with fluid flow
-				if (partType[idx] & ParticleBase::PFLOAT) {
+				if (partType[idx] & ParticleBase::PFLOATER) {
 					partVel[idx] = vel.getInterpolated( parts[idx].pos );
 				}
 			}
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 0b125d3adfb..53461aac2d4 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -170,7 +170,7 @@ def manta_step_$ID$(framenr):\n\
         setObstacleFlags(flags=flags_s$ID$, phiObs=phiObs_s$ID$, phiOut=phiOut_s$ID$, fractions=fractions_s$ID$)\n\
         \n\
         sampleLevelsetWithParticles(phi=phiIn_s$ID$, flags=flags_s$ID$, parts=pp_s$ID$, discretization=particleNumber_s$ID$, randomness=randomness_s$ID$, refillEmpty=True)\n\
-        flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\
+        flags_s$ID$.updateFromLevelset(phi_s$ID$, phiObs_s$ID$)\n\
         \n\
         if using_adaptTime_s$ID$:\n\
             mantaMsg('Adapt timestep')\n\




More information about the Bf-blender-cvs mailing list