[Bf-blender-cvs] [4a6f96a] fluid-mantaflow: moved some script snippets to separate shared file (now there is only one solver string, one adaptive time stepping string, etc)
Sebastián Barschkis
noreply at git.blender.org
Mon May 23 23:45:51 CEST 2016
Commit: 4a6f96a6d306572d82a15a6d81d0c90b91dd98f4
Author: Sebastián Barschkis
Date: Thu May 12 13:01:39 2016 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB4a6f96a6d306572d82a15a6d81d0c90b91dd98f4
moved some script snippets to separate shared file (now there is only one solver string, one adaptive time stepping string, etc)
===================================================================
M intern/mantaflow/intern/LIQUID.cpp
M intern/mantaflow/intern/SMOKE.cpp
M intern/mantaflow/intern/strings/liquid_script.h
M intern/mantaflow/intern/strings/shared_script.h
M intern/mantaflow/intern/strings/smoke_script.h
===================================================================
diff --git a/intern/mantaflow/intern/LIQUID.cpp b/intern/mantaflow/intern/LIQUID.cpp
index 1d1d7b9..9177ecb 100644
--- a/intern/mantaflow/intern/LIQUID.cpp
+++ b/intern/mantaflow/intern/LIQUID.cpp
@@ -51,15 +51,15 @@ LIQUID::LIQUID()
void LIQUID::initSetup()
{
- std::string tmpString =
- manta_import +
- liquid_flags +
- liquid_solver_setup +
- alloc_liquid +
- prep_domain +
- mesh_loading +
- manta_step +
- liquid_step;
+ std::string tmpString = manta_import
+ + solver_low
+ + adaptive_time_stepping
+ + alloc_liquid
+ + liquid_variables
+ + prep_domain
+ + mesh_loading
+ + manta_step
+ + liquid_step;
// std::string finalString = parseScript(tmpString, smd);
mCommands.clear();
mCommands.push_back(tmpString);
diff --git a/intern/mantaflow/intern/SMOKE.cpp b/intern/mantaflow/intern/SMOKE.cpp
index 07d4cca..9d836ff 100644
--- a/intern/mantaflow/intern/SMOKE.cpp
+++ b/intern/mantaflow/intern/SMOKE.cpp
@@ -142,14 +142,14 @@ SMOKE::SMOKE(int *res, SmokeModifierData *smd)
void SMOKE::initSetup(SmokeModifierData *smd)
{
- std::string tmpString =
- manta_import +
- solver_setup_low +
- alloc_base_grids_low +
- prep_domain_low +
- flags +
- manta_step +
- smoke_step_low;
+ std::string tmpString = manta_import
+ + solver_low
+ + adaptive_time_stepping
+ + alloc_base_grids_low
+ + smoke_variables
+ + prep_domain_low
+ + manta_step
+ + smoke_step_low;
std::string finalString = parseScript(tmpString, smd);
mCommands.clear();
mCommands.push_back(finalString);
@@ -494,7 +494,7 @@ void SMOKE::exportScript(SmokeModifierData *smd)
// Setup low
std::string manta_script =
manta_import +
- solver_setup_low +
+ solver_low +
alloc_base_grids_low;
// Add heat grid low if needed
@@ -513,7 +513,7 @@ void SMOKE::exportScript(SmokeModifierData *smd)
}
// Rest of low res setup
- manta_script += prep_domain_low + flags;
+ manta_script += prep_domain_low + smoke_variables;
// Setup high
if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 1c637b9..6376d23 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -33,38 +33,17 @@
// GENERAL SETUP
//////////////////////////////////////////////////////////////////////
-const std::string liquid_flags = "\n\
-narrowBand = False\n";
-
-const std::string liquid_solver_setup = "\n\
-dim = 3\n\
-particleNumber = 2\n\
-res = 64\n\
-gs = vec3(res,res,res)\n\
-if (dim==2):\n\
- gs.z=1\n\
-s = Solver(name='main', gridSize = gs, dim=dim)\n\
-dt_default = 0.1\n\
-dt_factor = 1.0\n\
-fps = 24\n\
-dt0 = dt_default * (25.0 / fps) * dt_factor\n\
-s.frameLength = dt0\n\
-s.timestepMin = dt0 / 10\n\
-s.timestepMax = dt0\n\
-s.cfl = 4.0\n\
-s.timestep = dt0\n\
-#s.frameLength = 1.0\n\
-#s.timestep = 1.0\n\
-#s.timestepMin = 0.5\n\
-#s.timestepMax = 1.0\n\
-#s.cfl = 5.0\n\
+const std::string liquid_variables = "\n\
+narrowBand = False\n\
narrowBandWidth = 3\n\
combineBandWidth = narrowBandWidth - 1\n\
-# using special gravity for blender\n\
+\n\
+minParticles = pow(2,dim)\n\
+particleNumber = 2\n\
+\n\
gravity = (0,0,-1)\n\
-minParticles = pow(2,dim)\n\
-step = -1\n\
-maxVel = 0\n";
+step = -1\n\
+maxVel = 0\n";
//////////////////////////////////////////////////////////////////////
// GRIDS & MESHES
@@ -82,13 +61,13 @@ velOld = s.create(MACGrid)\n\
velParts = s.create(MACGrid)\n\
mapWeights = s.create(MACGrid)\n\
\n\
-pp = s.create(BasicParticleSystem)\n\
-pVel = pp.create(PdataVec3)\n\
-mesh = s.create(Mesh)\n\
+pp = s.create(BasicParticleSystem)\n\
+pVel = pp.create(PdataVec3)\n\
+mesh = s.create(Mesh)\n\
\n\
# Acceleration data for particle nbs\n\
-pindex = s.create(ParticleIndexSystem)\n\
-gpi = s.create(IntGrid)\n";
+pindex = s.create(ParticleIndexSystem)\n\
+gpi = s.create(IntGrid)\n";
const std::string prep_domain = "\n\
flags.initDomain(boundaryWidth=0)\n\
diff --git a/intern/mantaflow/intern/strings/shared_script.h b/intern/mantaflow/intern/strings/shared_script.h
index 2ac8aa6..a72802c 100644
--- a/intern/mantaflow/intern/strings/shared_script.h
+++ b/intern/mantaflow/intern/strings/shared_script.h
@@ -31,4 +31,26 @@
const std::string manta_import = "\
from manta import *\n\
-import os, shutil, math, sys, gc\n";
\ No newline at end of file
+import os, shutil, math, sys, gc\n";
+
+const std::string solver_low = "\n\
+# solver low params\n\
+dim = $SOLVER_DIM$\n\
+res = $RES$\n\
+gs = vec3($RESX$,$RESY$,$RESZ$)\n\
+if dim == 2: gs.z = 1\n\
+s = Solver(name='main', gridSize=gs, dim=dim)\n";
+
+const std::string adaptive_time_stepping = "\n\
+# adaptive time stepping\n\
+dt_default = 0.1\n\
+dt_factor = $DT_FACTOR$\n\
+fps = $FPS$\n\
+dt0 = dt_default * (25.0 / fps) * dt_factor\n\
+s.frameLength = dt0\n\
+s.timestepMin = dt0 / 10\n\
+s.timestepMax = dt0\n\
+s.cfl = 4.0\n\
+s.timestep = dt0\n";
+
+
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index 484af7d..ec24c54 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -33,11 +33,15 @@
// GENERAL SETUP
//////////////////////////////////////////////////////////////////////
-const std::string flags = "\n\
-using_colors = $USING_COLORS$\n\
-using_heat = $USING_HEAT$\n\
-using_fire = $USING_FIRE$\n\
-using_wavelets = $USE_WAVELETS$\n";
+const std::string smoke_variables = "\n\
+using_colors = $USING_COLORS$\n\
+using_heat = $USING_HEAT$\n\
+using_fire = $USING_FIRE$\n\
+using_wavelets = $USE_WAVELETS$\n\
+vorticity = $VORTICITY$\n\
+doOpen = $DO_OPEN$\n\
+boundConditions = '$BOUNDCONDITIONS$'\n\
+boundaryWidth = 1\n";
const std::string uv_setup = "\n\
# create the array of uv grids\n\
@@ -47,6 +51,7 @@ for i in range(uvs):\n\
uvGrid = s.create(VecGrid)\n\
uv.append(uvGrid)\n\
resetUvGrid(uv[i])\n\
+\n\
# Need to initialize helper grids for uvw as well\n\
copyVec3ToReal(source=uv[0], targetX=texture_u, targetY=texture_v, targetZ=texture_w)\n\
copyVec3ToReal(source=uv[1], targetX=texture_u2, targetY=texture_v2, targetZ=texture_w2)\n";
@@ -55,28 +60,6 @@ copyVec3ToReal(source=uv[1], targetX=texture_u2, targetY=texture_v2, targetZ=tex
// LOW RESOLUTION SETUP
//////////////////////////////////////////////////////////////////////
-const std::string solver_setup_low = "\n\
-# solver low params\n\
-dim = $SOLVER_DIM$\n\
-doOpen = $DO_OPEN$\n\
-boundConditions = '$BOUNDCONDITIONS$'\n\
-res = $RES$\n\
-gs = vec3($RESX$,$RESY$,$RESZ$)\n\
-if dim == 2:\n\
- gs.z = 1\n\
-s = Solver(name='main', gridSize=gs, dim=dim)\n\
-dt_default = 0.1\n\
-dt_factor = $DT_FACTOR$\n\
-fps = $FPS$\n\
-dt0 = dt_default * (25.0 / fps) * dt_factor\n\
-s.frameLength = dt0\n\
-s.timestepMin = dt0 / 10\n\
-s.timestepMax = dt0\n\
-s.cfl = 4.0\n\
-s.timestep = dt0\n\
-vorticity = $VORTICITY$\n\
-boundaryWidth = 1\n";
-
const std::string alloc_base_grids_low = "\n\
# prepare grids low\n\
flags = s.create(FlagGrid)\n\
@@ -112,14 +95,13 @@ const std::string solver_setup_high = "\n\
# solver high params\n\
upres = $UPRES$\n\
xl_gs = vec3($HRESX$, $HRESY$, $HRESZ$)\n\
-if dim == 2:\n\
- xl_gs.z = 1\n\
+if dim == 2: xl_gs.z = 1\n\
xl = Solver(name = 'larger', gridSize = xl_gs)\n\
xl.frameLength = s.frameLength\n\
xl.timestepMin = s.timestepMin / 10\n\
xl.timestepMax = s.timestepMax\n\
-xl.cfl = s.cfl\n\
-wltStrength = $WLT_STR$\n\
+xl.cfl = s.cfl\n\
+wltStrength = $WLT_STR$\n\
octaves = 0\n\
uvs = 2\n\
if upres == 1:\n\
More information about the Bf-blender-cvs
mailing list