[Bf-blender-cvs] [3656c02] fluid-mantaflow: improved inflow, outflow and implemented initial support for moving objects
Sebastián Barschkis
noreply at git.blender.org
Thu Dec 1 13:38:08 CET 2016
Commit: 3656c02c928b19d410fe00de1d1d14fa0ee81ae6
Author: Sebastián Barschkis
Date: Thu Dec 1 13:19:53 2016 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB3656c02c928b19d410fe00de1d1d14fa0ee81ae6
improved inflow, outflow and implemented initial support for moving objects
- outflow objects may move now
- inflow routine in mantaflow script now inside adaptive time stepping
- flag grid is generated from phiobs. no more "hacks" that write bit
masks by hand
TODO:
- object velocities need to be set at borders
===================================================================
M intern/mantaflow/extern/manta_fluid_API.h
M intern/mantaflow/intern/FLUID.cpp
M intern/mantaflow/intern/FLUID.h
M intern/mantaflow/intern/manta_fluid_API.cpp
M intern/mantaflow/intern/strings/liquid_script.h
M intern/mantaflow/intern/strings/smoke_script.h
M source/blender/blenkernel/intern/smoke.c
===================================================================
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 6b5e4de..a2ab4d5 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -91,10 +91,9 @@ float *smoke_get_inflow_grid(struct FLUID *smoke);
float *smoke_get_fuel_inflow(struct FLUID *smoke);
int *smoke_turbulence_get_obstacle(struct FLUID *smoke);
-float *liquid_get_phi(struct FLUID *liquid);
-float *liquid_get_phiinit(struct FLUID *liquid);
-float *liquid_get_phiobsinit(struct FLUID *liquid);
-float *liquid_turbulence_get_phi(struct FLUID *liquid);
+float *liquid_get_phiin(struct FLUID *liquid);
+float *liquid_get_phiobs(struct FLUID *liquid);
+float *liquid_get_phiout(struct FLUID *liquid);
void liquid_ensure_init(struct FLUID *liquid, struct SmokeModifierData *smd);
void liquid_save_mesh(struct FLUID *liquid, char *filename);
void liquid_save_data(struct FLUID *liquid, char *pathname);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 2a1cde8..8b0dce2 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -112,12 +112,9 @@ FLUID::FLUID(int *res, SmokeModifierData *smd)
mTextureW2 = NULL;
// Liquid low res grids
- mPhi = NULL;
- mPhiInit = NULL;
- mPhiObsInit = NULL;
-
- // Liquid high res grids
- mPhiHigh = NULL;
+ mPhiIn = NULL;
+ mPhiObs = NULL;
+ mPhiOut = NULL;
mNumVertices = 0;
mNumNormals = 0;
@@ -315,7 +312,7 @@ void FLUID::initColorsHigh(SmokeModifierData *smd)
void FLUID::initLiquid(SmokeModifierData *smd)
{
- if (!mPhi) {
+ if (!mPhiIn) {
std::string tmpString = liquid_alloc_low
+ liquid_variables_low
+ liquid_bounds_low
@@ -450,10 +447,9 @@ FLUID::~FLUID()
mTextureW2 = NULL;
// Liquid
- mPhi = NULL;
- mPhiInit = NULL;
- mPhiObsInit = NULL;
- mPhiHigh = NULL;
+ mPhiIn = NULL;
+ mPhiObs = NULL;
+ mPhiOut = NULL;
// Reset flags
mUsingHeat = false;
@@ -910,11 +906,12 @@ void FLUID::updatePointers(SmokeModifierData *smd)
mForceY = (float*) getGridPointer("y_force", "s");
mForceZ = (float*) getGridPointer("z_force", "s");
+ mPhiObs = (float*) getGridPointer("phiObsIn", "s");
+
// Liquid
if (mUsingLiquid) {
- mPhi = (float*) getGridPointer("phi", "s");
- mPhiInit = (float*) getGridPointer("phiInit", "s");
- mPhiObsInit = (float*) getGridPointer("phiObsInit", "s");
+ mPhiIn = (float*) getGridPointer("phiIn", "s");
+ mPhiOut = (float*) getGridPointer("phiOut", "s");
}
// Smoke
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index 23174d9..5051fd8 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -123,11 +123,10 @@ public:
inline float* getTextureW2() { return mTextureW2; }
inline int* getObstacleHigh() { return mObstacleHigh; }
- inline float* getPhi() { return mPhi; }
- inline float* getPhiInit() { return mPhiInit; }
- inline float* getPhiObsInit() { return mPhiObsInit; }
- inline float* getPhiHigh() { return NULL; } // Not yet implemented
-
+ inline float* getPhiIn() { return mPhiIn; }
+ inline float* getPhiObs() { return mPhiObs; }
+ inline float* getPhiOut() { return mPhiOut; }
+
static bool mantaInitialized;
// Liquid getters
@@ -214,10 +213,9 @@ private:
int* mObstacleHigh;
// Liquids
- float* mPhi;
- float* mPhiInit;
- float* mPhiObsInit;
- float* mPhiHigh;
+ float* mPhiIn;
+ float* mPhiObs;
+ float* mPhiOut;
// Mesh fields for liquid surface
int mNumVertices;
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index d1f0732..b5c2a3b 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -501,19 +501,19 @@ extern "C" float *smoke_get_fuel_inflow(FLUID *smoke)
return smoke->getFuelInflow();
}
-extern "C" float *liquid_get_phi(FLUID *liquid)
+extern "C" float *liquid_get_phiin(FLUID *liquid)
{
- return liquid->getPhi();
+ return liquid->getPhiIn();
}
-extern "C" float *liquid_get_phiinit(FLUID *liquid)
+extern "C" float *liquid_get_phiobs(FLUID *liquid)
{
- return liquid->getPhiInit();
+ return liquid->getPhiObs();
}
-extern "C" float *liquid_get_phiobsinit(FLUID *liquid)
+extern "C" float *liquid_get_phiout(FLUID *liquid)
{
- return liquid->getPhiObsInit();
+ return liquid->getPhiOut();
}
extern "C" void liquid_save_mesh(FLUID *liquid, char *filename)
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index dc6f12d..b07fe7a 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -76,11 +76,12 @@ flags = s.create(FlagGrid)\n\
numObs = s.create(IntGrid)\n\
phiParts = s.create(LevelsetGrid)\n\
phi = s.create(LevelsetGrid)\n\
-phiInit = s.create(LevelsetGrid)\n\
+phiIn = s.create(LevelsetGrid)\n\
+phiOut = s.create(LevelsetGrid)\n\
pressure = s.create(RealGrid)\n\
\n\
phiObs = s.create(LevelsetGrid)\n\
-phiObsInit = s.create(LevelsetGrid)\n\
+phiObsIn = s.create(LevelsetGrid)\n\
fractions = s.create(MACGrid)\n\
\n\
vel = s.create(MACGrid)\n\
@@ -122,7 +123,7 @@ xl_gpi = xl.create(IntGrid)\n";
const std::string liquid_init_phi = "\n\
phi.initFromFlags(flags)\n\
-phiInit.initFromFlags(flags)\n";
+phiIn.initFromFlags(flags)\n";
//////////////////////////////////////////////////////////////////////
// PRE / POST STEP
@@ -167,20 +168,24 @@ def manta_step(start_frame):\n\
liquid_pre_step_low()\n\
if using_highres:\n\
liquid_pre_step_high()\n\
- if start_frame == 1:\n\
- phi.join(phiInit)\n\
- phiObs.join(phiObsInit)\n\
+ \n\
+ while s.frame == last_frame:\n\
\n\
- flags.updateFromLevelset(phi)\n\
- phi.subtract(phiObs)\n\
+ flags.initDomain(boundaryWidth=boundaryWidth, phiWalls=phiObs)\n\
+ if doOpen:\n\
+ setOpenBound(flags=flags, bWidth=boundaryWidth, openBound=boundConditions, type=FlagOutflow|FlagEmpty)\n\
\n\
- sampleLevelsetWithParticles(phi=phi, flags=flags, parts=pp, discretization=particleNumber, randomness=randomness)\n\
+ phiObs.join(phiObsIn)\n\
+ #phi.subtract(phiObs)\n\
+ phiIn.subtract(phiObs)\n\
+ phi.join(phiIn)\n\
\n\
updateFractions(flags=flags, phiObs=phiObs, fractions=fractions, boundaryWidth=boundaryWidth)\n\
- setObstacleFlags(flags=flags, phiObs=phiObs, fractions=fractions)\n\
- \n\
- while s.frame == last_frame:\n\
- sampleLevelsetWithParticles(phi=phiInit, flags=flags, parts=pp, discretization=particleNumber, randomness=randomness, refillEmpty=True)\n\
+ setObstacleFlags(flags=flags, phiObs=phiObs, fractions=fractions, phiOut=phiOut)\n\
+ \n\
+ sampleLevelsetWithParticles(phi=phiIn, flags=flags, parts=pp, discretization=particleNumber, randomness=randomness, refillEmpty=True)\n\
+ flags.updateFromLevelset(phi)\n\
+ pushOutofObs(parts=pp, flags=flags, phiObs=phiObs)\n\
\n\
mantaMsg('Adapt timestep')\n\
maxvel = vel.getMaxValue()\n\
@@ -223,8 +228,8 @@ def liquid_step():\n\
extrapolateLsSimple(phi=phi, distance=narrowBandWidth+2, inside=True)\n\
extrapolateLsSimple(phi=phi, distance=3)\n\
phi.setBoundNeumann(boundaryWidth) # make sure no particles are placed at outer boundary\n\
- if doOpen:\n\
- resetOutflow(flags=flags, phi=phi, parts=pp, index=gpi, indexSys=pindex) # open boundaries\n\
+ #if doOpen:\n\
+ resetOutflow(flags=flags, phi=phi, parts=pp, index=gpi, indexSys=pindex) # open boundaries\n\
flags.updateFromLevelset(phi)\n\
\n\
# combine particles velocities with advected grid velocities\n\
@@ -237,6 +242,9 @@ def liquid_step():\n\
addGravity(flags=flags, vel=vel, gravity=gravity)\n\
copyRealToVec3(sourceX=x_force, sourceY=y_force, sourceZ=z_force, target=forces)\n\
addForceField(flags=flags, vel=vel, force=forces)\n\
+ # TODO (sebbas): need to extrapolate obvels - currently only on mesh border\n\
+ #extrapolateMACSimple(flags=flags, vel=obvel, distance=res/2, intoObs=True)\n\
+ addForceField(flags=flags, vel=vel, force=obvel)\n\
forces.clear()\n\
\n\
extrapolateMACSimple(flags=flags, vel=vel, distance=2, intoObs=True)\n\
@@ -247,7 +255,6 @@ def liquid_step():\n\
extrapolateMACSimple(flags=flags, vel=vel, distance=4, intoObs=True)\n\
setWallBcs(flags=flags, vel=vel, fractions=fractions, phiObs=phiObs)\n\
\n\
- # TODO (sebbas): Clearing should not be needed once obvel are added correctly\n\
clearInObstacle(flags=flags, grid=phi)\n\
clearInObstacle(flags=flags, grid=phiParts)\n\
pushOutofObs(parts=pp, flags=flags, phiObs=phiObs)\n\
@@ -293,9 +300,10 @@ def load_liquid_data_low(path):\n\
\n\
phiParts.load(os.path.join(path, 'phiParts.uni'))\n\
phi.load(os.path.join(path, 'phi.uni'))\n\
- phiInit.load(os.path.join(path, 'phiInit.uni'))\n\
+ phiIn.load(os.path.join(path, 'phiIn.uni'))\n\
phiObs.load(os.path.join(path, 'phiObs.uni'))\n\
- phiObsInit.load(os.path.join(path, 'phiObsInit.uni'))\n\
+ phiObsIn.load(os.path.join(path, 'phiObsIn.uni'))\n\
+ phiOut.load(os.path.join(path, 'phiOut.uni'))\n\
fractions.load(os.path.join(path, 'fractions.uni'))\n\
pressure.load(os.path.join(path, 'pressure.uni'))\n\
\n\
@@ -331,9 +339,10 @@ def save_liquid_data_low(path):\n\
\n\
phiParts.save(os.path.join(path, 'phiParts.uni'))\n\
phi.save(os.path.join(path, 'phi.uni'))\n\
- phiInit.save(os.path.join(path, 'phiInit.uni'))\n\
+ phiIn.save(os.path.join(path, 'phiIn.uni'))\n\
phiObs.save(os.path.join(path, 'phiObs.uni'))\n\
- phiObsInit.save(os.path.join(path, 'phiObsInit.uni'))\n\
+ phiObsIn.save(os.path.join(path, 'phiObsIn.uni'))\n\
+ phiOut.save(os.path.join(path, 'phiOut.uni'))\n\
fractions.save(os.path.join(path, 'fractions.uni'))\n\
pressure.save(os.path.join(path, 'p
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list