[Bf-blender-cvs] [83797251717] fluid-mantaflow: fix for liquid domain boundaries

Sebastián Barschkis noreply at git.blender.org
Tue Jul 11 19:15:36 CEST 2017


Commit: 837972517176d541b57e5b7de687e516ba01c688
Author: Sebastián Barschkis
Date:   Tue Jul 11 18:21:28 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB837972517176d541b57e5b7de687e516ba01c688

fix for liquid domain boundaries

cells next to domain walls are used for fractions. if outflow is enabled these should get set to outflow cells and not fluid cells (were set to fluid and liquid didnt leave domain)

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

M	intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
M	intern/mantaflow/intern/strings/liquid_script.h

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

diff --git a/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp b/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
index 48b2e5ffcba..40909008cee 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
+++ b/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
@@ -128,7 +128,7 @@ inline void convertDescToVec(const string& desc, Vector3D<bool>& lo, Vector3D<bo
 }
 
 //! add empty and outflow flag to cells of open boundaries 
-void setOpenBound(FlagGrid& flags, int bWidth, string openBound = "", int type = FlagGrid::TypeOutflow | FlagGrid::TypeEmpty){
+void setOpenBound(FlagGrid& flags, int bWidth, string openBound = "", int type = FlagGrid::TypeOutflow | FlagGrid::TypeEmpty, Grid<Real>* phiOut=NULL){
 	if (openBound == "") return;
 	Vector3D<bool> lo, up;
 	convertDescToVec(openBound, lo, up);
@@ -152,8 +152,10 @@ void setOpenBound(FlagGrid& flags, int bWidth, string openBound = "", int type =
 				if ((loX || upX || innerI) && (loY || upY || innerJ) && (loZ || upZ || innerK) && flags.isObstacle(i, j, k)) flags(i, j, k) = type;
 			}
 		}
+		// update levelset outflow grid too
+		if (phiOut && flags.isOutflow(i,j,k)) (*phiOut)(i,j,k) = -0.5;
 	}
-} static PyObject* _W_2 (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, "setOpenBound" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); int bWidth = _args.get<int >("bWidth",1,&_lock); string openBound = _args.getOpt<string >("openBound",2,"",&_lock); i [...]
+} static PyObject* _W_2 (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, "setOpenBound" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); int bWidth = _args.get<int >("bWidth",1,&_lock); string openBound = _args.getOpt<string >("openBound",2,"",&_lock); i [...]
 
 //! delete fluid and ensure empty flag in outflow cells, delete particles and density and set phi to 0.5
 void resetOutflow(FlagGrid& flags, Grid<Real>* phi = 0, BasicParticleSystem* parts = 0, Grid<Real>* real = 0, Grid<int>* index = 0, ParticleIndexSystem* indexSys = 0){
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index ce7309dc21d..15f1b40db44 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -38,7 +38,7 @@ const std::string liquid_bounds_low = "\n\
 mantaMsg('Liquid domain low')\n\
 flags_s$ID$.initDomain(boundaryWidth=boundaryWidth_s$ID$, phiWalls=phiObs_s$ID$)\n\
 if doOpen_s$ID$:\n\
-    setOpenBound(flags=flags_s$ID$, bWidth=boundaryWidth_s$ID$, openBound=boundConditions_s$ID$, type=FlagOutflow|FlagEmpty)\n";
+    setOpenBound(flags=flags_s$ID$, bWidth=boundaryWidth_s$ID$, openBound=boundConditions_s$ID$, type=FlagOutflow|FlagEmpty, phiOut=phiOut_s$ID$)\n";
 
 const std::string liquid_bounds_high = "\n\
 # prepare domain high\n\
@@ -77,6 +77,7 @@ phiParts_s$ID$   = s$ID$.create(LevelsetGrid)\n\
 phi_s$ID$        = s$ID$.create(LevelsetGrid)\n\
 phiIn_s$ID$      = s$ID$.create(LevelsetGrid)\n\
 phiOut_s$ID$     = s$ID$.create(LevelsetGrid)\n\
+phiOutIn_s$ID$   = s$ID$.create(LevelsetGrid)\n\
 pressure_s$ID$   = s$ID$.create(RealGrid)\n\
 \n\
 phiObs_s$ID$     = s$ID$.create(LevelsetGrid)\n\
@@ -149,6 +150,7 @@ def liquid_post_step_low_$ID$():\n\
     \n\
     phiIn_s$ID$.setConst(9999)\n\
     phiObs_s$ID$.setConst(9999)\n\
+    phiOut_s$ID$.setConst(9999)\n\
     \n\
     copyVec3ToReal(source=vel_s$ID$, targetX=x_vel_s$ID$, targetY=y_vel_s$ID$, targetZ=z_vel_s$ID$)\n";
 
@@ -167,16 +169,17 @@ def manta_step_$ID$(framenr):\n\
     while s$ID$.frame == last_frame_s$ID$:\n\
         \n\
         flags_s$ID$.initDomain(boundaryWidth=boundaryWidth_s$ID$, phiWalls=phiObs_s$ID$)\n\
+        if doOpen_s$ID$:\n\
+            setOpenBound(flags=flags_s$ID$, bWidth=boundaryWidth_s$ID$, openBound=boundConditions_s$ID$, type=FlagOutflow|FlagEmpty, phiOut=phiOut_s$ID$)\n\
         \n\
-        #phiObs_s$ID$.addConst(1.) # TODO (sebbas): temp trick: while fractions disabled make border phi wall one cell thinner\n\
         phiObs_s$ID$.join(phiObsIn_s$ID$)\n\
         phi_s$ID$.join(phiIn_s$ID$)\n\
         phi_s$ID$.subtract(phiObsIn_s$ID$)\n\
         \n\
+        phiOut_s$ID$.join(phiOutIn_s$ID$)\n\
+        \n\
         updateFractions(flags=flags_s$ID$, phiObs=phiObs_s$ID$, fractions=fractions_s$ID$, boundaryWidth=boundaryWidth_s$ID$)\n\
         setObstacleFlags(flags=flags_s$ID$, phiObs=phiObs_s$ID$, phiOut=phiOut_s$ID$, fractions=fractions_s$ID$)\n\
-        if doOpen_s$ID$:\n\
-            setOpenBound(flags=flags_s$ID$, bWidth=boundaryWidth_s$ID$, openBound=boundConditions_s$ID$, type=FlagOutflow|FlagEmpty)\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\
@@ -307,6 +310,7 @@ def load_liquid_data_low_$ID$(path):\n\
     phiObs_s$ID$.load(path + '_phiObs.uni')\n\
     phiObsIn_s$ID$.load(path + '_phiObsIn.uni')\n\
     phiOut_s$ID$.load(path + '_phiOut.uni')\n\
+    phiOutIn_s$ID$.load(path + '_phiOutIn.uni')\n\
     fractions_s$ID$.load(path + '_fractions.uni')\n\
     pressure_s$ID$.load(path + '_pressure.uni')\n\
     \n\
@@ -347,6 +351,7 @@ def save_liquid_data_low_$ID$(path):\n\
     phiObs_s$ID$.save(path + '_phiObs.uni')\n\
     phiObsIn_s$ID$.save(path + '_phiObsIn.uni')\n\
     phiOut_s$ID$.save(path + '_phiOut.uni')\n\
+    phiOutIn_s$ID$.save(path + '_phiOutIn.uni')\n\
     fractions_s$ID$.save(path + '_fractions.uni')\n\
     pressure_s$ID$.save(path + '_pressure.uni')\n\
     \n\
@@ -389,6 +394,7 @@ if 'phiParts_s$ID$'   in globals() : del phiParts_s$ID$\n\
 if 'phi_s$ID$'        in globals() : del phi_s$ID$\n\
 if 'phiIn_s$ID$'      in globals() : del phiIn_s$ID$\n\
 if 'phiOut_s$ID$'     in globals() : del phiOut_s$ID$\n\
+if 'phiOutIn_s$ID$'   in globals() : del phiOutIn_s$ID$\n\
 if 'pressure_s$ID$'   in globals() : del pressure_s$ID$\n\
 if 'vel_s$ID$'        in globals() : del vel_s$ID$\n\
 if 'x_vel_s$ID$'      in globals() : del x_vel_s$ID$\n\




More information about the Bf-blender-cvs mailing list