[Bf-blender-cvs] [d0c9ebf] fluid-mantaflow: fuel inflow and manta script cleanup
Sebastián Barschkis
noreply at git.blender.org
Thu Jan 28 12:37:01 CET 2016
Commit: d0c9ebf9cbc4e469bb489de24307f13d28511ec3
Author: Sebastián Barschkis
Date: Sun Oct 11 23:44:51 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBd0c9ebf9cbc4e469bb489de24307f13d28511ec3
fuel inflow and manta script cleanup
===================================================================
M intern/smoke/extern/smoke_API.h
M intern/smoke/intern/FLUID_3D.cpp
M intern/smoke/intern/FLUID_3D.h
M intern/smoke/intern/MANTA.cpp
M intern/smoke/intern/scenarios/smoke.h
M intern/smoke/intern/smoke_API.cpp
M source/blender/blenkernel/intern/smoke.c
===================================================================
diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h
index 3e9be15..f0e3a4f 100644
--- a/intern/smoke/extern/smoke_API.h
+++ b/intern/smoke/extern/smoke_API.h
@@ -73,6 +73,7 @@ float *smoke_get_force_z(struct FLUID_3D *fluid);
int *smoke_get_manta_flags(struct FLUID_3D *fluid);
float *smoke_get_inflow_grid(struct FLUID_3D *fluid);
+float *smoke_get_fuel_inflow(struct FLUID_3D *fluid);
void smoke_manta_export(struct SmokeModifierData *smd);
unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid);
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 77825a6..0523aa1 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -592,6 +592,7 @@ _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
_yLocation = -1;
}
_manta_inflow = NULL;
+ _fuel_inflow = NULL;
_densityOld = new float[_totalCells];
_obstacles = new unsigned char[_totalCells]; // set 0 at end of step
diff --git a/intern/smoke/intern/FLUID_3D.h b/intern/smoke/intern/FLUID_3D.h
index 127f0bb..1246d37 100644
--- a/intern/smoke/intern/FLUID_3D.h
+++ b/intern/smoke/intern/FLUID_3D.h
@@ -118,6 +118,7 @@ struct FLUID_3D
unsigned char* _obstacles; /* only used (useful) for static obstacles like domain boundaries */
unsigned char* _obstaclesAnim;
float* _manta_inflow;
+ float* _fuel_inflow;
bool using_heat;
int manta_resoution;
int _yLocation;/*at which Y-coordinate store the information*/
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 5a27465..79e4526 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -390,7 +390,7 @@ std::string Manta_API::get_manta_smoke_script(SmokeModifierData *smd)
if (smd->domain->flags & MOD_SMOKE_MANTA_USE_LIQUID)
smoke_script = smoke_setup_low + liquid_step_low;
else
- smoke_script = smoke_setup_low + smoke_import_low + smoke_step_low ;
+ smoke_script = smoke_setup_low + smoke_import_low + smoke_inflow_low + smoke_step_low ;
}
return smoke_script;
}
@@ -671,6 +671,7 @@ void Manta_API::updatePointers(FLUID_3D *fluid)
}
fluid->_manta_inflow = (float* )pointerFromString(getGridPointer("inflow_grid", "s"));
+ fluid->_fuel_inflow = (float* )pointerFromString(getGridPointer("fuel_inflow", "s"));
if (fluid-> manta_resoution == 2) {return;}
if (fluid->using_colors) {
fluid->_color_r = (float* )pointerFromString(getGridPointer("color_r_low", "s"));
diff --git a/intern/smoke/intern/scenarios/smoke.h b/intern/smoke/intern/scenarios/smoke.h
index 05c882d..aec8331 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -31,6 +31,9 @@ heat_low = s.create(RealGrid)\n\
flame_low = s.create(RealGrid)\n\
fuel_low = s.create(RealGrid)\n\
react_low = s.create(RealGrid)\n\
+forces = s.create(MACGrid)\n\
+inflow_grid = s.create(LevelsetGrid)\n\
+fuel_inflow = s.create(LevelsetGrid)\n\
\n\
# noise field\n\
#noise = s.create(NoiseField, loadFromFile=True)\n\
@@ -42,15 +45,12 @@ react_low = s.create(RealGrid)\n\
#noise.valOffset = 0.75\n\
#noise.timeAnim = 0.2\n\
\n\
+# prepare domain\n\
flags.initDomain()\n\
flags.fillGrid()\n\
-\n\
setOpenBound(flags=flags, bWidth=1, openBound=boundConditions, type=FlagOutflow|FlagEmpty)\n\
\n\
-inflow_grid = s.create(LevelsetGrid)\n\
-source = s.create(Mesh)\n\
-forces = s.create(MACGrid)\n\
-dict_loaded = dict()\n\
+# initialization flags\n\
manta_using_colors = $USING_COLORS$\n\
manta_using_heat = $USING_HEAT$\n\
manta_using_fire = $USING_FIRE$\n\
@@ -162,7 +162,7 @@ import_grids()\n\
\n\
for step in range(1000):\n\
apply_inflow()\n\
-\n\
+ \n\
print('Step '+ str(step))\n\
if manta_using_fire:\n\
process_burn()\n\
@@ -199,20 +199,24 @@ def step_low():\n\
\n\
print('Advecting density')\n\
advectSemiLagrange(flags=flags, vel=vel, grid=density, order=$ADVECT_ORDER$)\n\
+ \n\
print('Advecting velocity')\n\
advectSemiLagrange(flags=flags, vel=vel, grid=vel, order=$ADVECT_ORDER$)\n\
\n\
print ('Walls')\n\
setWallBcs(flags=flags, vel=vel)\n\
+ \n\
print('Vorticity')\n\
if $VORTICITY$ > 0.01:\n\
- vorticityConfinement( vel=vel, flags=flags, strength=$VORTICITY$ ) \n\
- print('Forcefield')\n\
- #addForceField(flags=flags, vel=vel, force=forces)\n\
- forces.clear()\n\
+ vorticityConfinement( vel=vel, flags=flags, strength=$VORTICITY$ )\n\
+ \n\
+ # TODO: print('Forcefield')\n\
+ # TODO: addForceField(flags=flags, vel=vel, force=forces)\n\
+ # TODO: forces.clear()\n\
\n\
print('Pressure')\n\
solvePressure(flags=flags, vel=vel, pressure=pressure)\n\
+ \n\
print('Walls')\n\
setWallBcs(flags=flags, vel=vel)\n\
\n\
@@ -291,10 +295,12 @@ def sim_step_low(t):\n\
const string smoke_export_low = "\n\
import os\n\
+print('Exporting grids')\n\
density.save(os.path.join('$MANTA_EXPORT_PATH$','density_low.uni'))\n\
flags.save(os.path.join('$MANTA_EXPORT_PATH$','flags_low.uni'))\n\
forces.save(os.path.join('$MANTA_EXPORT_PATH$','forces_low.uni'))\n\
inflow_grid.save(os.path.join('$MANTA_EXPORT_PATH$','inflow_low.uni'))\n\
+fuel_inflow.save(os.path.join('$MANTA_EXPORT_PATH$','fuel_inflow.uni'))\n\
if manta_using_colors:\n\
color_r_low.save(os.path.join('$MANTA_EXPORT_PATH$','color_r_low.uni'))\n\
color_g_low.save(os.path.join('$MANTA_EXPORT_PATH$','color_g_low.uni'))\n\
@@ -305,11 +311,11 @@ if manta_using_fire:\n\
flame_low.save(os.path.join('$MANTA_EXPORT_PATH$','flame_low.uni'))\n\
fuel_low.save(os.path.join('$MANTA_EXPORT_PATH$','fuel_low.uni'))\n\
react_low.save(os.path.join('$MANTA_EXPORT_PATH$','react_low.uni'))\n\
-print('Grids exported')\n\
";
const string smoke_export_high = "\n\
import os\n\
+print('Exporting grids')\n\
xl_density.save(os.path.join('$MANTA_EXPORT_PATH$','xl_density.uni'))\n\
xl_flags.save(os.path.join('$MANTA_EXPORT_PATH$','xl_flags.uni'))\n\
if manta_using_colors:\n\
@@ -330,21 +336,20 @@ def import_grids():\n\
flags.load('$MANTA_EXPORT_PATH$flags_low.uni')\n\
forces.load('$MANTA_EXPORT_PATH$forces_low.uni')\n\
inflow_grid.load('$MANTA_EXPORT_PATH$inflow_low.uni')\n\
+ fuel_inflow.load('$MANTA_EXPORT_PATH$fuel_inflow.uni')\n\
+ \n\
if manta_using_colors:\n\
color_r_low.load('$MANTA_EXPORT_PATH$color_r_low.uni')\n\
color_g_low.load('$MANTA_EXPORT_PATH$color_g_low.uni')\n\
color_b_low.load('$MANTA_EXPORT_PATH$color_b_low.uni')\n\
+ \n\
if manta_using_heat:\n\
heat_low.load('$MANTA_EXPORT_PATH$heat.uni')\n\
+ \n\
if manta_using_fire:\n\
flame_low.load('$MANTA_EXPORT_PATH$flame_low.uni')\n\
fuel_low.load('$MANTA_EXPORT_PATH$fuel_low.uni')\n\
react_low.load('$MANTA_EXPORT_PATH$react_low.uni')\n\
-\n\
-def apply_inflow():\n\
- print('Applying inflow')\n\
- #inflow_grid.multConst(0.1)\n\
- density.add(inflow_grid)\n\
";
const string smoke_import_high = "\n\
@@ -363,3 +368,15 @@ def import_grids():\n\
react_high.load('$MANTA_EXPORT_PATH$react_high.uni')\n\
";
+const string smoke_inflow_low = "\n\
+def apply_inflow():\n\
+ print('Applying inflow')\n\
+ #inflow_grid.multConst(0.1)\n\
+ #fuel_inflow.multConst(0.1)\n\
+ density.add(inflow_grid)\n\
+ fuel_low.add(fuel_inflow)\n\
+";
+
+const string smoke_inflow_high = "\n\
+ # TODO\n\
+";
diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp
index 82879f9..3904fd9 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -681,3 +681,8 @@ extern "C" float *smoke_get_inflow_grid(FLUID_3D *fluid)
{
return fluid->_manta_inflow;
}
+
+extern "C" float *smoke_get_fuel_inflow(FLUID_3D *fluid)
+{
+ return fluid->_fuel_inflow;
+}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 8a66313..51945a5 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -2290,6 +2290,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
EmissionMap *em = &emaps[flowIndex];
float *density = smoke_get_density(sds->fluid);
float *inflow_grid = smoke_get_inflow_grid(sds->fluid);
+ float *fuel_inflow = smoke_get_fuel_inflow(sds->fluid);
float *color_r = smoke_get_color_r(sds->fluid);
float *color_g = smoke_get_color_g(sds->fluid);
float *color_b = smoke_get_color_b(sds->fluid);
@@ -2345,7 +2346,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
else { // inflow
apply_inflow_fields(sfs, emission_map[e_index], d_index, density, heat, fuel, react, color_r, color_g, color_b);
if((sfs->flags & MOD_SMOKE_USE_MANTA) && (sds->manta_solver_res == 3)) {
- apply_inflow_fields(sfs, emission_map[e_index], d_index, inflow_grid, heat, fuel, react, color_r, color_g, color_b);
+ apply_inflow_fields(sfs, emission_map[e_index], d_index, inflow_grid, heat, fuel_inflow, react, color_r, color_g, color_b);
}
/* initial velocity */
if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
More information about the Bf-blender-cvs
mailing list