[Bf-blender-cvs] [5c1c489e5dc] fluid-mantaflow: updated manta pp files and adapted obstacle velocity setter in smoke/liquid script

Sebastián Barschkis noreply at git.blender.org
Sun Mar 26 20:41:42 CEST 2017


Commit: 5c1c489e5dc2987c0abf400f03b6bc6831a2674d
Author: Sebastián Barschkis
Date:   Sun Mar 26 20:40:17 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB5c1c489e5dc2987c0abf400f03b6bc6831a2674d

updated manta pp files and adapted obstacle velocity setter in smoke/liquid script

important: boundaryWidth for liquids is 2 instead of default 1

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

M	intern/mantaflow/intern/manta_pp/omp/fastmarch.cpp
M	intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
M	intern/mantaflow/intern/manta_pp/omp/plugin/initplugins.cpp
M	intern/mantaflow/intern/manta_pp/omp/registration.cpp
M	intern/mantaflow/intern/manta_pp/tbb/fastmarch.cpp
M	intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
M	intern/mantaflow/intern/manta_pp/tbb/plugin/initplugins.cpp
M	intern/mantaflow/intern/manta_pp/tbb/registration.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	intern/mantaflow/intern/strings/smoke_script.h

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

diff --git a/intern/mantaflow/intern/manta_pp/omp/fastmarch.cpp b/intern/mantaflow/intern/manta_pp/omp/fastmarch.cpp
index f772956ac52..b679555b098 100644
--- a/intern/mantaflow/intern/manta_pp/omp/fastmarch.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/fastmarch.cpp
@@ -577,7 +577,7 @@ void extrapolateVec3Simple(Grid<Vec3>& vel, Grid<Real>& phi, int distance = 4, b
 	Grid<int> tmp( vel.getParent() );
 	tmp.clear();
 	const int dim = (vel.is3D() ? 3:2);
-	
+
 	// by default, march outside
 	if(!inside) {
 		// mark all inside
@@ -598,11 +598,11 @@ void extrapolateVec3Simple(Grid<Vec3>& vel, Grid<Real>& phi, int distance = 4, b
 				tmp(i,j,k) = 2; n=2*dim;
 			}
 		}
-	}
-	
+	} 
+
 	for(int d=2; d<1+distance; ++d) {
 		knExtrapolateLsSimple<Vec3>(vel, distance, tmp, d, Vec3(0.) );
-	}
+	} 
 	knSetRemaining<Vec3>(vel, tmp, Vec3(0.) );
 } static PyObject* _W_3 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(parent, "extrapolateVec3Simple" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; Grid<Vec3>& vel = *_args.getPtr<Grid<Vec3> >("vel",0,&_lock); Grid<Real>& phi = *_args.getPtr<Grid<Real> >("phi",1,&_lock); int distance = _args.getOpt<int >("distance",2 [...]
 
diff --git a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
index e9fc78f398d..b50d6a413a7 100644
--- a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
@@ -370,21 +370,22 @@ void setWallBcs(FlagGrid& flags, MACGrid& vel, MACGrid* fractions = 0, Grid<Real
 	}
 } static PyObject* _W_5 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(parent, "setWallBcs" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); MACGrid* fractions = _args.getPtrOpt<MACGrid >("fractions",2,0, [...]
 
-//! add obvel between obs/obs and obs/fl cells
+//! add obvel between obs/obs, obs/fl and/or obs,em cells. expects centered obvels, sets staggered vels
 
- struct KnSetObstacleVelocity : public KernelBase { KnSetObstacleVelocity(FlagGrid& flags, MACGrid& vel, Grid<Vec3>& obvel, int borderWidth) :  KernelBase(&flags,0) ,flags(flags),vel(vel),obvel(obvel),borderWidth(borderWidth)   { runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& flags, MACGrid& vel, Grid<Vec3>& obvel, int borderWidth )  {
+ struct KnSetObstacleVelocity : public KernelBase { KnSetObstacleVelocity(FlagGrid& flags, MACGrid& vel, Grid<Vec3>& obvel, int boundaryWidth, int borderWidth) :  KernelBase(&flags,boundaryWidth) ,flags(flags),vel(vel),obvel(obvel),boundaryWidth(boundaryWidth),borderWidth(borderWidth)   { runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& flags, MACGrid& vel, Grid<Vec3>& obvel, int boundaryWidth, int borderWidth )  {
 	bool curFluid = flags.isFluid(i,j,k);
 	bool curObs   = flags.isObstacle(i,j,k);
 	if (!curFluid && !curObs) return;
-	
-	// Set vel for obstacles only - staggered obvels end exactly at fl/obs or em/obs border
+
+	// Set vel for obstacles: getting centered vels and setting staggered
+	// Affects all cells inside obstacle. Obvels end exactly at obs/fl or obs/em border
 	if (flags.isObstacle(i-1,j,k) || (curObs && flags.isFluid(i-1,j,k)) || (curObs && flags.isEmpty(i-1,j,k)))
 		vel(i,j,k).x = 0.5*(obvel(i-1,j,k).x + obvel(i,j,k).x);
 	if (flags.isObstacle(i,j-1,k) || (curObs && flags.isFluid(i,j-1,k)) || (curObs && flags.isEmpty(i,j-1,k)))
 		vel(i,j,k).y = 0.5*(obvel(i,j-1,k).y + obvel(i,j,k).y);
 	if (vel.is3D() && (flags.isObstacle(i,j,k-1) || (curObs && flags.isFluid(i,j,k-1)) || (curObs && flags.isEmpty(i,j,k-1))))
-		vel(i,j,k).z = 0.5*(obvel(i,j,k-1).z + obvel(i,j,k-1).z);
-	
+		vel(i,j,k).z = 0.5*(obvel(i,j,k-1).z + obvel(i,j,k).z);
+
 	// Optional border velocities outside of obstacle
 	if (!borderWidth) return;
 	for (int d=1; d<1+borderWidth; ++d)
@@ -395,29 +396,40 @@ void setWallBcs(FlagGrid& flags, MACGrid& vel, MACGrid* fractions = 0, Grid<Real
 		bool dObs = flags.isObstacle(i,j-d,k); // down
 		bool tObs = flags.isObstacle(i,j,k+d); // top
 		bool bObs = flags.isObstacle(i,j,k-d); // bottom
-		
-		if (rObs || lObs || uObs || dObs || tObs || bObs) {
+
+		bool rupObs = flags.isObstacle(i+d,j+d,k+d); // corner right up top
+		bool rdtObs = flags.isObstacle(i+d,j-d,k+d); // corner right down top
+		bool lupObs = flags.isObstacle(i-d,j+d,k+d); // corner left up top
+		bool ldtObs = flags.isObstacle(i-d,j-d,k+d); // corner left down top
+
+		bool rubObs = flags.isObstacle(i+d,j+d,k-d); // corner right up bottom
+		bool rdbObs = flags.isObstacle(i+d,j-d,k-d); // corner right down bottom
+		bool lubObs = flags.isObstacle(i-d,j+d,k-d); // corner left up bottom
+		bool ldbObs = flags.isObstacle(i-d,j-d,k-d); // corner left down bottom
+
+		if (rObs || lObs || uObs || dObs || tObs || bObs
+			|| rupObs || rdtObs || lupObs || ldtObs || rubObs || rdbObs || lubObs || ldbObs) {
 			vel(i,j,k).x = 0.5*(obvel(i-1,j,k).x + obvel(i,j,k).x);
 			vel(i,j,k).y = 0.5*(obvel(i,j-1,k).y + obvel(i,j,k).y);
 			if (vel.is3D()) vel(i,j,k).z = 0.5*(obvel(i,j,k-1).z + obvel(i,j,k).z);
 		}
 	}
-}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline Grid<Vec3>& getArg2() { return obvel; } typedef Grid<Vec3> type2;inline int& getArg3() { return borderWidth; } typedef int type3; void runMessage() { debMsg("Executing kernel KnSetObstacleVelocity ", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; void run() {  const int _maxX = maxX;  [...]
+}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline MACGrid& getArg1() { return vel; } typedef MACGrid type1;inline Grid<Vec3>& getArg2() { return obvel; } typedef Grid<Vec3> type2;inline int& getArg3() { return boundaryWidth; } typedef int type3;inline int& getArg4() { return borderWidth; } typedef int type4; void runMessage() { debMsg("Executing kernel KnSetObstacleVelocity ", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" -  [...]
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int k=minZ; k < maxZ; k++) for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) op(i,j,k,flags,vel,obvel,borderWidth);  } } else { const int k=0; 
+  for (int k=minZ; k < maxZ; k++) for (int j=boundaryWidth; j < _maxY; j++) for (int i=boundaryWidth; i < _maxX; i++) op(i,j,k,flags,vel,obvel,boundaryWidth,borderWidth);  } } else { const int k=0; 
 #pragma omp parallel 
  {  
 #pragma omp for  
-  for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) op(i,j,k,flags,vel,obvel,borderWidth);  } }  } FlagGrid& flags; MACGrid& vel; Grid<Vec3>& obvel; int borderWidth;   };
+  for (int j=boundaryWidth; j < _maxY; j++) for (int i=boundaryWidth; i < _maxX; i++) op(i,j,k,flags,vel,obvel,boundaryWidth,borderWidth);  } }  } FlagGrid& flags; MACGrid& vel; Grid<Vec3>& obvel; int boundaryWidth; int borderWidth;   };
 #line 297 "plugin/extforces.cpp"
 
 
 
-void setObstacleVelocity(FlagGrid& flags, MACGrid& vel, Grid<Vec3>& obvel, int borderWidth=0) {
-	KnSetObstacleVelocity(flags, vel, obvel, borderWidth);
-} static PyObject* _W_6 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(parent, "setObstacleVelocity" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); Grid<Vec3>& obvel = *_args.getPtr<Grid<Vec3> >("obvel" [...]
+void setObstacleVelocity(FlagGrid& flags, MACGrid& vel, Grid<Vec3>& obvel, int boundaryWidth=1, int borderWidth=0) {
+	KnSetObstacleVelocity(flags, vel, obvel, boundaryWidth, borderWidth);
+} static PyObject* _W_6 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) { try { PbArgs _args(_linargs, _kwds); FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(parent, "setObstacleVelocity"

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list