Commit: 9ac37c4e0e8143bb011df3b33d8bbec9770e007e
Author: Sebastián Barschkis
Date: Sat Sep 19 16:58:03 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB9ac37c4e0e8143bb011df3b33d8bbec9770e007e
added caching for simulation with manta solver
===================================================================
M intern/smoke/intern/FLUID_3D.cpp
M intern/smoke/intern/WTURBULENCE.cpp
M intern/smoke/intern/scenarios/smoke.h
M intern/smoke/intern/smoke_API.cpp
M source/blender/blenkernel/intern/pointcache.c
M source/blender/blenkernel/intern/smoke.c
M source/blender/python/manta_pp/fluidsolver.cpp
===================================================================
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 48f7cf6..247b8dd 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -51,6 +51,7 @@
FLUID_3D::FLUID_3D(int *res, float dx, float dtdef, int init_heat, int
init_fire, int init_colors) :
_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
{
+ cout << "FLUID" << endl;
// set simulation consts
_dt = dtdef; // just in case. set in step from a RNA factor
@@ -531,6 +532,7 @@ void FLUID_3D::updateFlame(float *react, float *flame, int
total_cells)
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)
{
+ cout << "FLUID_3D" << endl;
// set simulation consts
_dt = dtdef; // just in case. set in step from a RNA factor
@@ -575,13 +577,14 @@ _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
_yForce = new float[_totalCells];
_zForce = new float[_totalCells];
/*if two-dimensional, insert manta sim into blender _density field */
- if (smd->domain->manta_solver_res == 2){
+ if (smd->domain->manta_solver_res == 2) {
_density = new float[_totalCells];
_manta_flags = new int[_totalCells];
manta_resoution = 2;
_yLocation = _yRes / 2;
}
- else{
+ else
+ {
_density = NULL;
_manta_flags = NULL;
manta_resoution = 3;
@@ -656,6 +659,7 @@ _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
smoke_script = smoke_setup_low + liquid_step_low;
else
smoke_script = smoke_setup_low + smoke_step_low;
+
smd->domain->fluid = this;
std::string final_script = Manta_API::parseScript(smoke_script, smd);
ofstream myfile;
diff --git a/intern/smoke/intern/WTURBULENCE.cpp
b/intern/smoke/intern/WTURBULENCE.cpp
index fbed3d7..29cccbd 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -60,6 +60,7 @@ static const float persistence = 0.56123f;
//////////////////////////////////////////////////////////////////////
WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int
noisetype, const char *noisefile_path, int init_fire, int init_colors)
{
+ cout << "WTURBULENCE" << endl;
// if noise magnitude is below this threshold, its contribution
// is negilgible, so stop evaluating new octaves
_cullingThreshold = 1e-3;
@@ -1210,6 +1211,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float*
xvel, float* yvel, floa
WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int
noisetype, const char *noisefile_path, int init_fire, int
init_colors,SmokeDomainSettings *sds)
{
+ cout << "WTURBULENCE" << endl;
// if noise magnitude is below this threshold, its contribution
// is negilgible, so stop evaluating new octaves
_cullingThreshold = 1e-3;
diff --git a/intern/smoke/intern/scenarios/smoke.h
b/intern/smoke/intern/scenarios/smoke.h
index eb78fc0..0588aa3 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -3,6 +3,7 @@ using namespace std;
const string smoke_clean = "";
const string smoke_setup_low ="from manta import *\n\
+print ('SMOKE SETUP LOW')\n\
import os, shutil, math, sys\n\
\n\
def transform_back(obj, gs):\n\
diff --git a/intern/smoke/intern/smoke_API.cpp
b/intern/smoke/intern/smoke_API.cpp
index 09830ba..eb7e249 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -221,6 +221,7 @@ extern "C" void smoke_dissolve_wavelet(WTURBULENCE *wt, int
speed, int log)
data_dissolve(wt->_densityBig, 0, wt->_color_rBig, wt->_color_gBig,
wt->_color_bBig, wt->_totalCellsBig, speed, log);
}
+#ifndef WITH_MANTA
extern "C" void smoke_export(FLUID_3D *fluid, float *dt, float *dx, float
**dens, float **react, float **flame, float **fuel, float **heat,
float **heatold, float
**vx, float **vy, float **vz, float **r, float **g, float **b, unsigned char
**obstacles)
{
@@ -248,6 +249,37 @@ extern "C" void smoke_export(FLUID_3D *fluid, float *dt,
float *dx, float **dens
*dt = fluid->_dt;
*dx = fluid->_dx;
}
+//////////////////////////////////////////////////////////////////////
+#else /*USING MANTAFLOW STRUCTURES*/
+//////////////////////////////////////////////////////////////////////
+extern "C" void smoke_export(FLUID_3D *fluid, float *dt, float *dx, float
**dens, float **react, float **flame, float **fuel, float **heat,
+ float **manta_inflow,
float **vx, float **vy, float **vz, float **r, float **g, float **b, unsigned
char **obstacles)
+{
+ *dens = fluid->_density;
+ if(fuel)
+ *fuel = fluid->_fuel;
+ if(react)
+ *react = fluid->_react;
+ if(flame)
+ *flame = fluid->_flame;
+ if(heat)
+ *heat = fluid->_heat;
+ if(manta_inflow)
+ *manta_inflow = fluid->_manta_inflow;
+ *vx = fluid->_xVelocity;
+ *vy = fluid->_yVelocity;
+ *vz = fluid->_zVelocity;
+ if(r)
+ *r = fluid->_color_r;
+ if(g)
+ *g = fluid->_color_g;
+ if(b)
+ *b = fluid->_color_b;
+ *obstacles = fluid->_obstacles;
+ *dt = fluid->_dt;
+ *dx = fluid->_dx;
+}
+#endif /* WITH_MANTA */
extern "C" void smoke_turbulence_export(WTURBULENCE *wt, float **dens, float
**react, float **flame, float **fuel,
float **r, float **g, float **b ,
float **tcu, float **tcv, float **tcw)
diff --git a/source/blender/blenkernel/intern/pointcache.c
b/source/blender/blenkernel/intern/pointcache.c
index b69bc2f..b80c1bb 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -600,7 +600,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void
*smoke_v)
ptcache_file_write(pf, &sds->dx, 1, sizeof(float));
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold,
*vx, *vy, *vz, *r, *g, *b;
+ float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold,
*manta_inflow, *vx, *vy, *vz, *r, *g, *b;
unsigned char *obstacles;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned char *out = (unsigned char
*)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
@@ -608,7 +608,11 @@ static int ptcache_smoke_write(PTCacheFile *pf, void
*smoke_v)
int mode=1; // light
if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy
- smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame,
&fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
+ #ifndef WITH_MANTA
+ smoke_export(sds->fluid, &dt, &dx, &dens, &react,
&flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
+ #else
+ smoke_export(sds->fluid, &dt, &dx, &dens, &react,
&flame, &fuel, &heat, &manta_inflow, &vx, &vy, &vz, &r, &g, &b, &obstacles);
+ #endif
ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow,
in_len, out, mode);
@@ -618,9 +622,15 @@ static int ptcache_smoke_write(PTCacheFile *pf, void
*smoke_v)
/* writeArrToFile("dens.txt", dens, res);
*/
+ #ifdef WITH_MANTA
+ ptcache_file_compressed_write(pf, (unsigned char
*)manta_inflow, in_len, out, mode);
+ #endif
if (fluid_fields & SM_ACTIVE_HEAT) {
ptcache_file_compressed_write(pf, (unsigned char
*)heat, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char
*)heatold, in_len, out, mode);
+
+ #ifndef WITH_MANTA
+ ptcache_file_compressed_write(pf, (unsigned
char *)heatold, in_len, out, mode);
+ #endif
}
if (fluid_fields & SM_ACTIVE_FIRE) {
ptcache_file_compressed_write(pf, (unsigned char
*)flame, in_len, out, mode);
@@ -717,7 +727,7 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void
*smoke_v)
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *heat, *heatold, *vx, *vy, *vz;
+ float dt, dx, *dens, *heat, *heatold, *manta_inflow, *vx, *vy,
*vz;
unsigned char *obstacles;
unsigned int out_len = (unsigned int)res * sizeof(float);
float *tmp_array = MEM_callocN(out_len, "Smoke old cache tmp");
@@ -729,16 +739,24 @@ static int ptcache_smoke_read_old(PTCacheFile *pf, void
*smoke_v)
sds->active_color[1] = 0.7f;
sds->active_color[2] = 0.7f;
- smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL,
&heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
+ #ifndef WITH_MANTA
+ smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL,
NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
+ #else
+ smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL,
NULL, &heat, &manta_inflow, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
+ #endif
ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow,
out_len);
ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len);
ptcache_file_compressed_read(pf, (unsigned char*)tmp_array,
out_len);
- if (fluid_fields & SM_ACTIVE_HEAT)
- {
+ #ifdef WITH_MANTA
+ ptcache_file_compressed_read(pf, (unsigned
char*)manta_inflow, out_len);
+ #endif
+ if (fluid_fields & SM_ACTIVE_HEAT) {
ptcache_file_compressed_read(pf, (unsigned char*)heat,
out_len);
- ptcache_file_compressed_read(pf, (unsigned
char*)heatold, out_len);
+ #ifndef WITH_MANTA
+ ptcache_file_compressed_read(pf, (unsigned
char*)heatold, out_len);
+ #endif
}
else
{
@@ -842,17 +860,29 @@ static int ptcache_smoke_read(PTCacheFile *pf, void
*smoke_v)
if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold,
*vx, *vy, *vz, *r, *g, *b;
+ float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold,
*manta_inflow, *vx, *vy, *vz, *r, *g, *b;
unsigned char *obstacles;
unsigned int out_len = (unsigned int)res * sizeof(float);
- smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame,
&fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
+ #ifndef WITH_MANTA
+ smoke_export(sds->fluid, &dt, &dx, &dens, &react,
&flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
+ #else
+ smoke_export(sds->fluid, &dt, &dx, &dens, &react,
&flame, &fuel, &heat, &manta_inflow, &vx, &vy, &vz, &r, &g, &b, &obstacles);
+ #endif
+
ptcache_file_compressed_read(pf, (unsigned char *)sds->sh
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs