[Bf-blender-cvs] [e5ebf2e] fluid-mantaflow: new mantaflow functions which should replace some of the calls from smoke.c

Sebastián Barschkis noreply at git.blender.org
Thu Dec 1 13:37:59 CET 2016


Commit: e5ebf2e4feccc9221c232f428ef9516b7e97645a
Author: Sebastián Barschkis
Date:   Fri Nov 11 13:54:19 2016 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBe5ebf2e4feccc9221c232f428ef9516b7e97645a

new mantaflow functions which should replace some of the calls from smoke.c

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

M	intern/mantaflow/intern/manta_pp/grid.cpp
M	intern/mantaflow/intern/manta_pp/plugin/initplugins.cpp
M	intern/mantaflow/intern/manta_pp/registration.cpp

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

diff --git a/intern/mantaflow/intern/manta_pp/grid.cpp b/intern/mantaflow/intern/manta_pp/grid.cpp
index 39ae4ec..3b96791 100644
--- a/intern/mantaflow/intern/manta_pp/grid.cpp
+++ b/intern/mantaflow/intern/manta_pp/grid.cpp
@@ -853,7 +853,7 @@ void FlagGrid::initBoundaries(const int &boundaryWidth, const int *types) {
 
 void FlagGrid::updateFromLevelset(LevelsetGrid& levelset) {
 	FOR_IDX(*this) {
-		if (!isObstacle(idx)) {
+		if (!isObstacle(idx) && !isOutflow(idx)) {
 			const Real phi = levelset[idx];
 			if (phi <= levelset.invalidTimeValue()) continue;
 			
diff --git a/intern/mantaflow/intern/manta_pp/plugin/initplugins.cpp b/intern/mantaflow/intern/manta_pp/plugin/initplugins.cpp
index d70a649..ea51d46 100644
--- a/intern/mantaflow/intern/manta_pp/plugin/initplugins.cpp
+++ b/intern/mantaflow/intern/manta_pp/plugin/initplugins.cpp
@@ -503,7 +503,7 @@ void updateFractions(FlagGrid& flags, Grid<Real>& phiObs, MACGrid& fractions, co
 } static PyObject* _W_16 (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, "updateFractions" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); Grid<Real>& phiObs = *_args.getPtr<Grid<Real> >("phiObs",1,&_lock); MACGrid& fractions = *_args.getPtr<MACGrid >( [...]
 
 
- struct KnUpdateFlags : public KernelBase { KnUpdateFlags(FlagGrid& flags, MACGrid& fractions, Grid<Real>& phiObs) :  KernelBase(&flags,1) ,flags(flags),fractions(fractions),phiObs(phiObs)   { runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& flags, MACGrid& fractions, Grid<Real>& phiObs )  {
+ struct KnUpdateFlags : public KernelBase { KnUpdateFlags(FlagGrid& flags, MACGrid& fractions, Grid<Real>& phiObs, Grid<Real>* phiOut) :  KernelBase(&flags,1) ,flags(flags),fractions(fractions),phiObs(phiObs),phiOut(phiOut)   { runMessage(); run(); }  inline void op(int i, int j, int k, FlagGrid& flags, MACGrid& fractions, Grid<Real>& phiObs, Grid<Real>* phiOut )  {
 
 	Real test = 0.;
 	test += fractions.get(i  ,j,k).x;
@@ -514,24 +514,79 @@ void updateFractions(FlagGrid& flags, Grid<Real>& phiObs, MACGrid& fractions, co
 	test += fractions.get(i,j,k  ).z;
 	test += fractions.get(i,j,k+1).z; }
 
-	if(test==0. && phiObs(i,j,k) < 0.) flags(i,j,k) = FlagGrid::TypeObstacle; 
-	else flags(i,j,k) = FlagGrid::TypeEmpty; 
-}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline MACGrid& getArg1() { return fractions; } typedef MACGrid type1;inline Grid<Real>& getArg2() { return phiObs; } typedef Grid<Real> type2; void runMessage() { debMsg("Executing kernel KnUpdateFlags ", 2); debMsg("Kernel range" << " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 3); }; void run() {  const int _maxX = maxX; const int _maxY = maxY; if (maxZ > 1) { 
+	if(test==0. && phiObs(i,j,k) < 0.) flags(i,j,k) = FlagGrid::TypeObstacle;
+	else if (phiOut && (*phiOut)(i,j,k) < 0.) flags(i,j,k) = (FlagGrid::TypeEmpty | FlagGrid::TypeOutflow);
+	else flags(i,j,k) = FlagGrid::TypeEmpty;
+}   inline FlagGrid& getArg0() { return flags; } typedef FlagGrid type0;inline MACGrid& getArg1() { return fractions; } typedef MACGrid type1;inline Grid<Real>& getArg2() { return phiObs; } typedef Grid<Real> type2;inline Grid<Real>* getArg3() { return phiOut; } typedef Grid<Real> type3; void runMessage() { debMsg("Executing kernel KnUpdateFlags ", 2); debMsg("Kernel range" << " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 3); }; void run() {  const int _maxX = [...]
 #pragma omp parallel 
  {  
 #pragma omp for 
-  for (int k=minZ; k < maxZ; k++) for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) op(i,j,k,flags,fractions,phiObs);  } } else { const int k=0; 
+  for (int k=minZ; k < maxZ; k++) for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) op(i,j,k,flags,fractions,phiObs,phiOut);  } } else { const int k=0; 
 #pragma omp parallel 
  {  
 #pragma omp for 
-  for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) op(i,j,k,flags,fractions,phiObs);  } }  } FlagGrid& flags; MACGrid& fractions; Grid<Real>& phiObs;   };
+  for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) op(i,j,k,flags,fractions,phiObs,phiOut);  } }  } FlagGrid& flags; MACGrid& fractions; Grid<Real>& phiObs; Grid<Real>* phiOut;   };
 #line 414 "plugin/initplugins.cpp"
 
 
 
-void setObstacleFlags(FlagGrid& flags, MACGrid& fractions, Grid<Real>& phiObs) {
-	KnUpdateFlags(flags,fractions, phiObs);
-} static PyObject* _W_17 (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, "setObstacleFlags" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& fractions = *_args.getPtr<MACGrid >("fractions",1,&_lock); Grid<Real>& phiObs = *_args.getPtr<Grid<Real [...]
+void setObstacleFlags(FlagGrid& flags, MACGrid& fractions, Grid<Real>& phiObs, Grid<Real>* phiOut=NULL) {
+	KnUpdateFlags(flags,fractions, phiObs, phiOut);
+} static PyObject* _W_17 (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, "setObstacleFlags" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& fractions = *_args.getPtr<MACGrid >("fractions",1,&_lock); Grid<Real>& phiObs = *_args.getPtr<Grid<Real [...]
+
+ struct KnClearInObstacle : public KernelBase { KnClearInObstacle(FlagGrid* flags, GridBase* grid) :  KernelBase(flags,0) ,flags(flags),grid(grid)   { runMessage(); run(); }   inline void op(IndexInt idx, FlagGrid* flags, GridBase* grid )  {
+
+	if ((*flags).isObstacle(idx)) {
+		if (grid->getType() & GridBase::TypeReal) {
+			(*(Grid<Real>*) grid)[idx] = 0.;
+		}
+		else if (grid->getType() & GridBase::TypeInt) {
+			(*(Grid<int>*) grid)[idx] = 0;
+		}
+		else if (grid->getType() & GridBase::TypeMAC || grid->getType() & GridBase::TypeVec3) {
+			(*(Grid<Vec3>*) grid)[idx].x = 0;
+			(*(Grid<Vec3>*) grid)[idx].y = 0;
+			(*(Grid<Vec3>*) grid)[idx].z = 0;
+		}
+		else if (grid->getType() & GridBase::TypeLevelset) {
+			(*(Grid<Real>*) grid)[idx] = 0.5;
+		}
+		else
+			errMsg("ClearInObstacle: Grid Type is not supported (only Real, Int, Vec3, MAC, Levelset)");
+	}
+}    inline FlagGrid* getArg0() { return flags; } typedef FlagGrid type0;inline GridBase* getArg1() { return grid; } typedef GridBase type1; void runMessage() { debMsg("Executing kernel KnClearInObstacle ", 2); debMsg("Kernel range" << " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 3); }; void run() {   const IndexInt _sz = size; 
+#pragma omp parallel 
+ {  
+#pragma omp for 
+  for (IndexInt i = 0; i < _sz; i++) op(i,flags,grid);  }   } FlagGrid* flags; GridBase* grid;   };
+#line 434 "plugin/initplugins.cpp"
+
+
+
+
+void clearInObstacle(FlagGrid* flags, GridBase* grid) {
+	KnClearInObstacle(flags, grid);
+} static PyObject* _W_18 (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, "clearInObstacle" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid* flags = _args.getPtr<FlagGrid >("flags",0,&_lock); GridBase* grid = _args.getPtr<GridBase >("grid",1,&_lock);   _retval = getPyNone(); clearInObstacle(flags,grid);   [...]
+
+ struct KnAveragedVel : public KernelBase { KnAveragedVel(MACGrid& vel, Grid<int>& numObs) :  KernelBase(&vel,0) ,vel(vel),numObs(numObs)   { runMessage(); run(); }   inline void op(IndexInt idx, MACGrid& vel, Grid<int>& numObs )  {
+	if (numObs[idx]) {
+		vel[idx].x /= numObs[idx];
+		vel[idx].y /= numObs[idx];
+		vel[idx].z /= numObs[idx];
+	}
+}    inline MACGrid& getArg0() { return vel; } typedef MACGrid type0;inline Grid<int>& getArg1() { return numObs; } typedef Grid<int> type1; void runMessage() { debMsg("Executing kernel KnAveragedVel ", 2); debMsg("Kernel range" << " x "<<  maxX  << " y "<<

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list