[Bf-blender-cvs] [adf1db39699] fluid-mantaflow: added missing manta omp files

Sebastián Barschkis noreply at git.blender.org
Fri Jul 21 20:46:47 CEST 2017


Commit: adf1db396990d55cc3311f46c0997d74f8cfe775
Author: Sebastián Barschkis
Date:   Fri Jul 21 20:46:32 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBadf1db396990d55cc3311f46c0997d74f8cfe775

added missing manta omp files

correspond to previous manta files update

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

M	intern/mantaflow/intern/manta_pp/omp/grid.cpp
M	intern/mantaflow/intern/manta_pp/omp/grid.h
M	intern/mantaflow/intern/manta_pp/omp/particle.h
M	intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp

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

diff --git a/intern/mantaflow/intern/manta_pp/omp/grid.cpp b/intern/mantaflow/intern/manta_pp/omp/grid.cpp
index 0e757841c97..05d0dd1ffb9 100644
--- a/intern/mantaflow/intern/manta_pp/omp/grid.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/grid.cpp
@@ -854,7 +854,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];
@@ -863,8 +863,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/omp/grid.h b/intern/mantaflow/intern/manta_pp/omp/grid.h
index f42b769a26d..574c4df46fc 100644
--- a/intern/mantaflow/intern/manta_pp/omp/grid.h
+++ b/intern/mantaflow/intern/manta_pp/omp/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/omp/particle.h b/intern/mantaflow/intern/manta_pp/omp/particle.h
index c057cd87377..9041782305d 100644
--- a/intern/mantaflow/intern/manta_pp/omp/particle.h
+++ b/intern/mantaflow/intern/manta_pp/omp/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/omp/plugin/flip.cpp b/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
index 5b0d19831c1..8d2c22df684 100644
--- a/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
@@ -719,8 +719,7 @@ 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, int minParticles, int maxParticles, Vec3 gravity, Real radiusFactor=1., bool drops=true, bool floats=false, bool tracers=false, bool bubbles=true) {
-	bool is3D = flags.is3D();
+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) {
 	Real dt = flags.getParent()->getDt();
 	Vec3 grav = gravity * flags.getParent()->getDt() / flags.getDx();
 	Grid<int> tmp( vel.getParent() );
@@ -743,7 +742,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 );
@@ -753,33 +752,18 @@ void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, L
 					parts.setPos(idx, parts.getPos(idx) + direction * phiv * grad );
 				}
 			}
-			
-			// Convert drop to bubble
-			if (bubbles && (partType[idx] & ParticleBase::PDROPLET) && phiv < -FLOAT_THRESH)
-			{
-				// Throttle drop particle, is inside fluid now
-				partVel[idx] = partVel[idx] * 0.5;
-
-				// TODO (sebbas): Convert to bubble when particle is slow enough or when it is deep enough in fluid?
-				// Convert drop particle to bubble when partvel falls below damping factor
-//				Vec3 dmpFac = damping * grav;
-//				if ( (partVel[idx].x < dmpFac.x) && (partVel[idx].y < dmpFac.y) && (partVel[idx].z < dmpFac.z) ) {
-				if (phiv < BUBBLE_THRESH) {
-					partType[idx] = ParticleBase::PBUBBLE;
-				}
-			}
 
 			// TODO (sebbas): Currently unreliable. Drop particles might get converted into floats to early
 //			// Convert bubble to float
 //			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; }
 
@@ -861,21 +845,32 @@ void sampleSndParts(BasicParticleSystem& parts, FlagGrid& flags, MACGrid& vel, L
 	}
 
 	if (bubbles) {
-		// Update forces: gravity
+		// Generate bubble particles (converted from drops). Then update forces: gravity and particle velocity
 		for (IndexInt idx=0; idx<(int)parts.size(); idx++) {
 			if (parts.isActive(idx)) {
+				Real phiv = phi.getInterpolated( parts.getPos(idx) );
 
+				// Throttle drop particle, is inside fluid now. Is candidate for bubble
+				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 );
+					partType[idx] = ParticleBase::PBUBBLE;
+				}
+
+				// Let bubbles rise up
 				if (partType[idx] & ParticleBase::PBUBBLE) {
-					// Let bubbles rise up
-//					partVel[idx] = vel.getInterpolated( parts[idx].pos );
-					partVel[idx] -= bubbleRise * grav;
+					partVel[idx] += bubbleRise * grav * (-1);
 				}
 			}
 		}
 	}
 
 	if (floats) {
-		// Generate new float particlesd
+		// Generate new float particles
 		FOR_IJK_BND(phi, 0) {
 			if ( flags.isObstacle(i,j,k) ) continue;
 
@@ -907,11 +902,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 );
 				}
 			}
@@ -922,12 +917,17 @@ void sampleSndParts(BasicParticleSystem& parts, FlagG

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list