[Bf-blender-cvs] [cd76de8] fluid-mantaflow: work on high resolution fire
Sebastián Barschkis
noreply at git.blender.org
Thu Jan 28 12:36:35 CET 2016
Commit: cd76de8410c7f0559c717dfdef981fa508a09a5d
Author: Sebastián Barschkis
Date: Tue Sep 8 00:39:02 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBcd76de8410c7f0559c717dfdef981fa508a09a5d
work on high resolution fire
===================================================================
M intern/smoke/intern/FLUID_3D.cpp
M intern/smoke/intern/MANTA.cpp
M intern/smoke/intern/WTURBULENCE.cpp
M intern/smoke/intern/WTURBULENCE.h
M intern/smoke/intern/scenarios/smoke.h
===================================================================
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index a272588..a0a6eed 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -524,11 +524,9 @@ void FLUID_3D::updateFlame(float *react, float *flame, int total_cells)
}
}
-/*===============================================================================================*/
-/*===============================================================================================*/
+//////////////////////////////////////////////////////////////////////
#else /*USING MANTAFLOW STRUCTURES*/
-/*===============================================================================================*/
-/*===============================================================================================*/
+//////////////////////////////////////////////////////////////////////
FLUID_3D::FLUID_3D(int *res, float dx, float dtdef, int init_heat, int init_fire, int init_colors, SmokeModifierData *smd) :
_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
@@ -1249,6 +1247,7 @@ void FLUID_3D::wipeBoundariesSL(int zBegin, int zEnd)
}
}
+
//////////////////////////////////////////////////////////////////////
// add forces to velocity field
//////////////////////////////////////////////////////////////////////
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index e2cffbf..8f11a51 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -642,14 +642,11 @@ void Manta_API::updatePointers(FLUID_3D *fluid, bool updateColor)
fluid->_density = (float* )pointerFromString(getGridPointer("density", "s"));
fluid->_manta_flags = (int* )pointerFromString(getGridPointer("flags", "s"));
}
-// fluid->_density = (float* )pointerFromString(getGridPointer("density", "s"));
fluid->_manta_inflow = (float* )pointerFromString(getGridPointer("inflow_grid", "s"));
if (fluid-> manta_resoution == 2){return;}
if (fluid->using_colors) {
- cout<< "POINTER FOR R_LOW" << fluid->_color_r<< endl;
fluid->_color_r = (float* )pointerFromString(getGridPointer("color_r_low", "s"));
- cout<< "POINTER FOR R_LOW" << fluid->_color_r<< endl;
fluid->_color_g = (float* )pointerFromString(getGridPointer("color_g_low", "s"));
fluid->_color_b = (float* )pointerFromString(getGridPointer("color_b_low", "s"));
}
@@ -669,11 +666,14 @@ void Manta_API::updateHighResPointers(WTURBULENCE *wt, bool updateColor)
{
wt->_densityBig = (float* )pointerFromString(getGridPointer("xl_density", "xl"));;
if (updateColor){
- cout<< "POINTER FOR R_HIGH" << wt->_color_rBig << endl;
wt->_color_rBig = (float* )pointerFromString(getGridPointer("color_r_high", "xl"));
- cout<< "POINTER FOR R_HIGH" << wt->_color_rBig << endl;
wt->_color_gBig = (float* )pointerFromString(getGridPointer("color_g_high", "xl"));
wt->_color_bBig = (float* )pointerFromString(getGridPointer("color_b_high", "xl"));
}
+ if (wt->using_fire) {
+ wt->_flameBig = (float* )pointerFromString(getGridPointer("flame_high", "xl"));
+ wt->_fuelBig = (float* )pointerFromString(getGridPointer("fuel_high", "xl"));
+ wt->_reactBig = (float* )pointerFromString(getGridPointer("react_high", "xl"));
+ }
}
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp
index 000a78e..4db2c49 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -1204,12 +1204,9 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
_totalStepsBig++;
}
-
-
-
-
-
-#else /*USING MANTAFLOW WTURBULENCE*/
+//////////////////////////////////////////////////////////////////////
+#else /*USING MANTAFLOW WTURBULENCE*/
+//////////////////////////////////////////////////////////////////////
WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, const char *noisefile_path, int init_fire, int init_colors,SmokeDomainSettings *sds)
{
@@ -1256,6 +1253,7 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int no
/* fire */
_flameBig = _fuelBig = _fuelBigOld = NULL;
_reactBig = _reactBigOld = NULL;
+ using_fire = false;
if (init_fire) {
initFire();
}
@@ -1265,7 +1263,6 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int no
_color_bBig = _color_bBigOld = NULL;
using_colors = false;
if (init_colors) {
- using_colors = true;
initColors(0.0f, 0.0f, 0.0f);
}
@@ -1297,6 +1294,7 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int no
Manta_API::generate_manta_sim_file_highRes(sds->smd);
Manta_API::updateHighResPointers(this,using_colors);
}
+
/// destructor
WTURBULENCE::~WTURBULENCE()
{
@@ -1323,10 +1321,22 @@ WTURBULENCE::~WTURBULENCE()
delete[] _noiseTile;
}
-void WTURBULENCE::initFire(){}
+void WTURBULENCE::initFire()
+{
+ if (!_flameBig) {
+ initColors(0.0f, 0.0f, 0.0f);
+
+ using_fire = true;
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString(smoke_init_fire_high.c_str());
+ PyGILState_Release(gilstate);
+ Manta_API::updateHighResPointers(this, true);
+ }
+}
+
void WTURBULENCE::initColors(float init_r, float init_g, float init_b)
{
- if (!_color_rBig){
+ if (!_color_rBig) {
using_colors = true;
PyGILState_STATE gilstate = PyGILState_Ensure();
stringstream ss;
@@ -1340,11 +1350,15 @@ void WTURBULENCE::initColors(float init_r, float init_g, float init_b)
}
}
-void WTURBULENCE::setNoise(int type, const char *noisefile_path){}
-void WTURBULENCE::initBlenderRNA(float *strength){}
+void WTURBULENCE::setNoise(int type, const char *noisefile_path)
+{}
+
+void WTURBULENCE::initBlenderRNA(float *strength)
+{}
// step more readable version -- no rotation correction
-void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles){
+void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles)
+{
PyGILState_STATE gilstate = PyGILState_Ensure();
int sim_frame = 1;
// manta_write_effectors(fluid);
@@ -1358,7 +1372,8 @@ void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, flo
// step more complete version -- include rotation correction
// and use OpenMP if available
-void WTURBULENCE::stepTurbulenceFull(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles){
+void WTURBULENCE::stepTurbulenceFull(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles)
+{
PyGILState_STATE gilstate = PyGILState_Ensure();
int sim_frame = 1;
// manta_write_effectors(fluid);
@@ -1371,14 +1386,26 @@ void WTURBULENCE::stepTurbulenceFull(float dt, float* xvel, float* yvel, float*
}
// texcoord functions
-void WTURBULENCE::advectTextureCoordinates(float dtOrg, float* xvel, float* yvel, float* zvel, float *tempBig1, float *tempBig2){}
-void WTURBULENCE::resetTextureCoordinates(float *_eigMin, float *_eigMax){}
+void WTURBULENCE::advectTextureCoordinates(float dtOrg, float* xvel, float* yvel, float* zvel, float *tempBig1, float *tempBig2)
+{}
+
+void WTURBULENCE::resetTextureCoordinates(float *_eigMin, float *_eigMax)
+{}
+
+void WTURBULENCE::computeEnergy(float *energy, float* xvel, float* yvel, float* zvel, unsigned char *obstacles)
+{}
+
+void WTURBULENCE::computeEigenvalues(float *_eigMin, float *_eigMax)
+{}
+
+void WTURBULENCE::decomposeEnergy(float *energy, float *_highFreqEnergy)
+{
+}
-void WTURBULENCE::computeEnergy(float *energy, float* xvel, float* yvel, float* zvel, unsigned char *obstacles){}
+Vec3 WTURBULENCE::WVelocity(Vec3 p)
+{return Vec3(0.);}
-void WTURBULENCE::computeEigenvalues(float *_eigMin, float *_eigMax){}
-void WTURBULENCE::decomposeEnergy(float *energy, float *_highFreqEnergy){}
-Vec3 WTURBULENCE::WVelocity(Vec3 p){return Vec3(0.);}
-Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped){return Vec3(0.);}
+Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped)
+{return Vec3(0.);}
#endif
diff --git a/intern/smoke/intern/WTURBULENCE.h b/intern/smoke/intern/WTURBULENCE.h
index 787177b..e63644d 100644
--- a/intern/smoke/intern/WTURBULENCE.h
+++ b/intern/smoke/intern/WTURBULENCE.h
@@ -121,6 +121,7 @@ struct WTURBULENCE
float* _fuelBigOld;
float* _reactBig;
float* _reactBigOld;
+ bool using_fire;
float* _color_rBig;
float* _color_rBigOld;
diff --git a/intern/smoke/intern/scenarios/smoke.h b/intern/smoke/intern/scenarios/smoke.h
index 6ff7347..ae0ec10 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -130,6 +130,12 @@ fuel_low = s.create(RealGrid)\n\
react_low = s.create(RealGrid)\n\
manta_using_fire = True\n";
+const string smoke_init_fire_high = "print(\"Initializing fire highres\")\n\
+flame_high = xl.create(RealGrid)\n\
+fuel_high = xl.create(RealGrid)\n\
+react_high = xl.create(RealGrid)\n\
+manta_using_fire = True\n";
+
const string smoke_del_colors_high = "\n\
del color_r_high \n\
del color_g_high \n\
@@ -157,7 +163,8 @@ if (GUI):\n\
gui.pause()\n\
\n\
for step in range(100):\n\
- sim_step_low(step, True)\n";
+ sim_step_low(step, True)\n\
+";
const string smoke_step_low = "def sim_step_low(t, standalone = False):\n\
#applying inflow\n\
@@ -180,13 +187,13 @@ const string smoke_step_low = "def sim_step_low(t, standalone = False):\n\
else:\n\
gravity=vec3(0,0,-0.01 * $ALPHA$) if solver_dim==3 else vec3(0,-0.01* $ALPHA$,0)\n\
addBuoyancy(density=density, vel=vel, gravity=gravity, flags=flags)\n\
- print ('Advecting colors')\n\
if manta_using_colors:\n\
+ print ('Advecting colors')\n\
advectSemiLagrange(flags=flags, vel=vel, grid=color_r_low, order=$ADVECT_ORDER$)\n\
advectSemiLagrange(flags=flags, vel=vel, grid=color_g_low, order=$ADVECT_ORDER$)\n\
advectSemiLagrange(flags=flags, vel=vel, grid=color_b_low, order=$ADVECT_ORDER$)\n\
- print ('Advecting fire grids')\n\
if manta_using_fire:\n\
+ print ('Advecting fire')\n\
advectSemiLagrange(flags=flags, vel=vel, grid=fuel_low, order=$ADVECT_ORDER$)\n\
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list