[Bf-blender-cvs] [06f0529] soc-2014-fluid: function bodies moved to cpp file, some sim settings tweaked
Roman Pogribnyi
noreply at git.blender.org
Fri Jul 25 22:34:18 CEST 2014
Commit: 06f05294cb92ec9125a491267b95dd1b2f492a4b
Author: Roman Pogribnyi
Date: Fri Jul 25 16:53:24 2014 +0200
Branches: soc-2014-fluid
https://developer.blender.org/rB06f05294cb92ec9125a491267b95dd1b2f492a4b
function bodies moved to cpp file, some sim settings tweaked
===================================================================
M intern/smoke/CMakeLists.txt
A intern/smoke/intern/MANTA.cpp
M intern/smoke/intern/MANTA.h
M source/blender/python/manta_pp/CMakeLists.txt
===================================================================
diff --git a/intern/smoke/CMakeLists.txt b/intern/smoke/CMakeLists.txt
index 4bb134f..783427e 100644
--- a/intern/smoke/CMakeLists.txt
+++ b/intern/smoke/CMakeLists.txt
@@ -62,6 +62,7 @@ set(SRC
intern/WAVELET_NOISE.h
intern/WTURBULENCE.h
intern/MANTA.h
+ intern/MANTA.cpp
intern/tnt/jama_eig.h
intern/tnt/jama_lu.h
intern/tnt/tnt.h
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.cpp
similarity index 81%
copy from intern/smoke/intern/MANTA.h
copy to intern/smoke/intern/MANTA.cpp
index af050c3..d1e85e6 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.cpp
@@ -1,16 +1,6 @@
-#ifndef MANTA_H
-#define MANTA_H
-#include "FLUID_3D.h"
-#include "zlib.h"
-#include "../../../source/blender/makesdna/DNA_scene_types.h"
-#include "../../../source/blender/makesdna/DNA_modifier_types.h"
-#include "../../../source/blender/makesdna/DNA_smoke_types.h"
-#include <sstream>
-#include <stdlib.h>
-#include <fstream>
-#include <pthread.h>
-#include <Python.h>
-#include <vector>
+#include "MANTA.h"
+
+//#include "../../../source/blender/blenlib/BLI_fileops.h"
//#include "../../../source/blender/python/manta_pp/pwrapper/pymain.cpp"
void runMantaScript(vector<string>& args);//defined in manta_pp/pwrapper/pymain.cpp
@@ -84,11 +74,11 @@ extern "C" void read_mantaflow_sim(struct FLUID_3D *fluid, char *name)
gzread(gzf,fluid->_density, sizeof(float)*head.dimX*head.dimY*head.dimZ);
}
gzclose(gzf);
-
+
# endif /*zlib*/
- }
+}
-static void indent_ss(stringstream& ss, int indent)
+void indent_ss(stringstream& ss, int indent)
{
/*two-spaces indent*/
if (indent < 0) return;
@@ -99,7 +89,7 @@ static void indent_ss(stringstream& ss, int indent)
ss << indentation;
}
-static void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim)
+void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim)
{
if (ss == NULL)/*should never be here*/
{
@@ -116,7 +106,7 @@ static void manta_gen_noise(stringstream& ss, char* solver, int indent, char *no
ss << noise << ".timeAnim = " << timeAnim << " \n";
}
-static void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res,float cgMaxIterFac=1.0, float cgAccuracy = 0.01)
+void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res,float cgMaxIterFac, float cgAccuracy)
{
/*open:0 ; vertical : 1; closed:2*/
ss << " solvePressure(flags=" << flags << ", vel=" << vel << ", pressure=" << pressure << ", useResNorm=" << (useResNorms?"True":"False") << ", openBound='";
@@ -132,12 +122,12 @@ static void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char
else
ss << "xXyYzZ";
}
- ss << "'"; /*empty for closed bounds*/
+ ss << "'"; /*empty for closed bounds*/
ss << ", cgMaxIterFac=" << cgMaxIterFac << ", cgAccuracy=" << cgAccuracy << ") \n";
}
-static void manta_advect_SemiLagr(stringstream& ss, int indent, char *flags, char *vel, char *grid, int order)
+void manta_advect_SemiLagr(stringstream& ss, int indent, char *flags, char *vel, char *grid, int order)
{
if((order <=1) || (flags == NULL) || (vel == NULL) || (grid == NULL)){return;}
indent_ss(ss, indent);
@@ -146,7 +136,7 @@ static void manta_advect_SemiLagr(stringstream& ss, int indent, char *flags, cha
}
/*create solver, handle 2D case*/
-static void manta_create_solver(stringstream& ss, char *name, char *nick, char *grid_size_name, int x_res, int y_res, int z_res, int dim)
+void manta_create_solver(stringstream& ss, char *name, char *nick, char *grid_size_name, int x_res, int y_res, int z_res, int dim)
{
if ((dim != 2) && (dim != 3))
{ return; }
@@ -161,32 +151,51 @@ inline bool file_exists (const std::string& name) {
}
/*blender transforms obj coords to [-1,1]. This method transforms them back*/
-static void add_mesh_transform_method(stringstream& ss)
+void add_mesh_transform_method(stringstream& ss)
{
ss << "def transform_back(obj, res):\n" <<
" obj.scale(vec3(res/2, res/2, res/2))\n" <<
" obj.offset(vec3(res/2, res/2, res/2))\n\n";
}
+void manta_cache_path(char *filepath)
+{
+ char *name="manta";
+ BLI_make_file_string("/", filepath, BLI_temporary_dir(), name);
+}
+//void BLI_dir_create_recursive(const char *filepath);
+void create_manta_folder()
+{
+ //cout<<"PR BLENDER FILES" << BLI_get_folder(BLENDER_USER_DATAFILES, NULL)<<endl;
+ char* filepath=NULL;
+ manta_cache_path(filepath);
+ cout<<"PR_filepath" <<filepath<<endl;
+ //BLI_dir_create_recursive(filepath);
+
+}
+
void *run_manta_scene(void *threadid)
{
+ //create_manta_folder();
//PyInterpreterState *st = PyThreadState_GET()->interp;
//PyThreadState *ts = Py_NewInterpreter();
-
+
vector<string> args;
args.push_back("manta_scene.py");
//args.push_back("test_1.py");
runMantaScript(args);
-
+
//system("./manta manta_scene.py");
-// pthread_exit(NULL);
+ // pthread_exit(NULL);
}
-static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
+
+
+void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
{
/*for now, simpleplume file creation
- *create python file with 2-spaces indentation*/
+ *create python file with 2-spaces indentation*/
bool wavelets = smd->domain->flags & MOD_SMOKE_HIGHRES;
bool noise_clamp = smd->domain->flags & MOD_SMOKE_NOISE_CLAMP;
@@ -208,11 +217,11 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
return;
}
add_mesh_transform_method(ss);
-/*Data Declaration*/
+ /*Data Declaration*/
/*Wavelets variables*/
int upres = smd->domain->amplify;
ss << "uvs = " << smd->domain->manta_uvs_num << "\n";
- ss << "velInflow = vec3(2, 0, 0)"<< "\n"; /*TODO:add UI*/
+ ss << "velInflow = vec3(0, 0, 1)"<< "\n"; /*TODO:add UI*/
if (wavelets) {
ss << "upres = " << upres << "\n";
ss << "wltStrength = " << smd->domain->strength << "\n";
@@ -222,27 +231,27 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
{ ss << "octaves = 0"<< "\n"; }
}
else upres = 0;
-
+
/*Solver Resolution*/
ss << "res = " << smd->domain->maxres << " \n";
- /*Z axis in Blender = Y axis in Mantaflow*/
+ /*Z axis in Blender = Y axis in Mantaflow*/
manta_create_solver(ss, "s", "main", "gs", fluid->xRes(), fluid->zRes(), fluid->yRes(), smd->domain->manta_solver_res);
ss << "s.timestep = " << smd->domain->time_scale << " \n";
-
-/*Noise Field*/
+
+ /*Noise Field*/
manta_gen_noise(ss, "s", 0, "noise", 256, true, noise_clamp, noise_clamp_neg, noise_clamp_pos, noise_val_scale, noise_val_offset, noise_time_anim);
-
-/*Inflow source - for now, using mock sphere */
+
+ /*Inflow source - for now, using mock sphere */
ss << "source = s.create(Mesh)\n";
ss << "source.load('manta_flow.obj')\n";
ss << "transform_back(source, res)\n";
ss << "sourceVel = s.create(Mesh)\n";
ss << "sourceVel.load('manta_flow.obj')\n";
ss << "transform_back(sourceVel, res)\n";
-// ss << "source = s.create(Cylinder, center=gs*vec3(0.3,0.2,0.5), radius=res*0.081, z=gs*vec3(0.081, 0, 0))\n";
-// ss << "sourceVel = s.create(Cylinder, center=gs*vec3(0.3,0.2,0.5), radius=res*0.15 , z=gs*vec3(0.15 , 0, 0))\n";
+ // ss << "source = s.create(Cylinder, center=gs*vec3(0.3,0.2,0.5), radius=res*0.081, z=gs*vec3(0.081, 0, 0))\n";
+ // ss << "sourceVel = s.create(Cylinder, center=gs*vec3(0.3,0.2,0.5), radius=res*0.15 , z=gs*vec3(0.15 , 0, 0))\n";
-/*Wavelets: larger solver*/
+ /*Wavelets: larger solver*/
if(wavelets && upres>0)
{
manta_create_solver(ss, "xl", "larger", "xl_gs", fluid->xRes() * upres, fluid->zRes()* upres, fluid->yRes() * upres, smd->domain->manta_solver_res);
@@ -253,13 +262,13 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
ss << "xl_flags = xl.create(FlagGrid) \n";
ss << "xl_flags.initDomain() \n";
ss << "xl_flags.fillGrid() \n";
-
-// ss << "xl_source = xl.create(Cylinder, center=xl_gs*vec3(0.3,0.2,0.5), radius=xl_gs.x*0.081, z=xl_gs*vec3(0.081, 0, 0)) \n";
+
+ // ss << "xl_source = xl.create(Cylinder, center=xl_gs*vec3(0.3,0.2,0.5), radius=xl_gs.x*0.081, z=xl_gs*vec3(0.081, 0, 0)) \n";
ss << "xl_source = s.create(Mesh)\n";
ss << "xl_source.load('manta_flow.obj')\n";
ss << "transform_back(xl_source, res)\n";
-// ss << "xl_source.scale(vec3("<< upres <<", " << upres <<", " << upres << "))\n";
-
+ // ss << "xl_source.scale(vec3("<< upres <<", " << upres <<", " << upres << "))\n";
+
/*Obstacle handling*/
if (file_exists("manta_coll.obj"))
{
@@ -270,7 +279,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
}
manta_gen_noise(ss, "xl", 0, "xl_noise", 256, true, noise_clamp, noise_clamp_neg, noise_clamp_pos, noise_val_scale, noise_val_offset, noise_time_anim * (float)upres);
}
-/*Flow setup*/
+ /*Flow setup*/
ss << "flags = s.create(FlagGrid) \n";/*must always be present*/
ss << "flags.initDomain() \n";
ss << "flags.fillGrid() \n";
@@ -301,7 +310,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
ss << "tempFlag = s.create(FlagGrid)\n";
ss << "sdf_flow = s.create(LevelsetGrid)\n";
ss << "source.meshSDF(source, sdf_flow, 1.1)\n";
-
+
/*Wavelets noise field*/
if (wavelets)
{
@@ -314,11 +323,12 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
ss << "xl_wltnoise.timeAnim = 0.1 \n";
}
-/*GUI for debugging purposes*/
+ /*GUI for debugging purposes*/
ss << "if (GUI):\n gui = Gui()\n gui.show() \n";
-
-/*Flow solving stepsv, main loop*/
- ss << "for t in range(" << scene->r.sfra << ", " << scene->r.efra << "): \n";
+
+ /*Flow solving stepsv, main loop*/
+ //setting 20 sim frames for now
+ ss << "for t in range(0,20): \n"; // << scene->r.sfra << ", " << scene->r.efra << "): \n";
manta_advect_SemiLagr(ss, 1, "flags", "vel", "density", 2);
manta_advect_SemiLagr(ss, 1, "flags",
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list