[Bf-blender-cvs] [9ed7be5] soc-2014-fluid: Separate Solver creation function; 2D solver option implemented: UI + functionality
Roman Pogribnyi
noreply at git.blender.org
Sun Jun 8 13:20:52 CEST 2014
Commit: 9ed7be50aaee593f55432d90c838f33128c41176
Author: Roman Pogribnyi
Date: Fri Jun 6 23:39:00 2014 +0200
https://developer.blender.org/rB9ed7be50aaee593f55432d90c838f33128c41176
Separate Solver creation function; 2D solver option implemented: UI + functionality
===================================================================
M intern/smoke/intern/MANTA.h
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/makesdna/DNA_smoke_types.h
M source/blender/makesrna/intern/rna_smoke.c
===================================================================
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index 012e9f8..b20523f 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -7,6 +7,7 @@
#include "../../../source/blender/makesdna/DNA_smoke_types.h"
#include <sstream>
#include <fstream>
+
extern "C" bool manta_check_grid_size(struct FLUID_3D *fluid, int dimX, int dimY, int dimZ)
{
if (!(dimX == fluid->xRes() && dimY == fluid->yRes() && dimZ == fluid->zRes())) {
@@ -96,7 +97,7 @@ static void manta_gen_noise(stringstream& ss, bool clamp, int clampNeg, int clam
ss << "noise.timeAnim = " << timeAnim << " \n";
}
-static void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound)
+static void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res)
{
/*open:0 ; vertical : 1; closed:2*/
ss << " solvePressure(flags=" << flags << ", vel=" << vel << ", pressure=" << pressure << ", useResNorm=" << (useResNorms?"True":"False") << ", openBound='";
@@ -107,13 +108,17 @@ static void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char
}
else if (openBound == 0) /*open*/
{
- ss << "xXyYzZ') \n";
+ if(solver_res == 2)
+ ss << "xXyY') \n";
+ else
+ ss << "xXyYzZ') \n";
}
else /*also for closed bounds*/
{
ss << "') \n";
}
}
+
static void manta_advect_SemiLagr(stringstream& ss, char *indent, char *flags, char *vel, char *grid, int order)
{
if((order <=1) || (indent == NULL) || (flags == NULL) || (vel == NULL) || (grid == NULL))
@@ -122,6 +127,17 @@ static void manta_advect_SemiLagr(stringstream& ss, char *indent, char *flags, c
<< ", grid=" << grid << ", order=" << order << ") \n";
}
+/*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)
+{
+ if ((dim != 2) && (dim != 3))
+ { return; }
+ if (dim == 2)
+ { z_res = 1; }
+ ss << "gs = vec3(" << x_res << ", " << y_res << ", " << z_res << ")" << " \n";
+ ss << name << " = Solver(name = '" << nick << "', gridSize = " << grid_size_name << ", dim = " << dim << ") \n";
+}
+
static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
{
/*for now, simpleplume file creation
@@ -140,8 +156,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
/*Solver Resolution*/
ss << "res = " << smd->domain->maxres << " \n";
/*Z axis in Blender = Y axis in Mantaflow*/
- ss << "gs = vec3(" << fluid->xRes() << ", " << fluid->zRes() << ", " << fluid->yRes() << ")" << " \n";
- ss << "s = Solver(name = 'main', gridSize = gs) \n";
+ 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";
/*Grids setup*/
@@ -171,7 +186,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
manta_advect_SemiLagr(ss, " ", "flags", "vel", "vel", 2);
ss << " setWallBcs(flags=flags, vel=vel) \n";
ss << " addBuoyancy(density=density, vel=vel, gravity=vec3(0,-6e-4,0), flags=flags) \n";
- manta_solve_pressure(ss,"flags", "vel", "pressure",true,smd->domain->border_collisions);
+ manta_solve_pressure(ss,"flags", "vel", "pressure",true,smd->domain->border_collisions, smd->domain->manta_solver_res);
ss << " setWallBcs(flags=flags, vel=vel) \n";
/*Saving output*/
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index a706415..bebcb13 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -345,7 +345,7 @@ class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
layout.active = domain.use_manta
col = layout.split()
col.operator("manta.make_file", text="Create Manta Setup")
-
+ col.prop(domain, "manta_solver_res", text="Solver Resolution")
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index b80eb23..9384ed8 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -150,6 +150,9 @@ typedef struct SmokeDomainSettings {
float burning_rate, flame_smoke, flame_vorticity;
float flame_ignition, flame_max_temp;
float flame_smoke_color[3];
+ /* mantaflow settings */
+ int manta_solver_res; /*dimension of manta solver, 2d or 3d*/
+ int manta_mockvar;
} SmokeDomainSettings;
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index a9e49fc..137c1fc 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -317,10 +317,6 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
- prop = RNA_def_property(srna, "use_manta", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_USE_MANTA);
- RNA_def_property_ui_text(prop, "MantaFlow", "Use Mantaflow");
-
prop = RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "amplify");
RNA_def_property_range(prop, 1, 10);
@@ -548,6 +544,19 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Threshold",
"Maximum amount of fluid cell can contain before it is considered empty");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ /* mantaflow variables */
+ prop = RNA_def_property(srna, "use_manta", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_USE_MANTA);
+ RNA_def_property_ui_text(prop, "MantaFlow", "Use Mantaflow");
+
+ prop = RNA_def_property(srna, "manta_solver_res", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "manta_solver_res");
+ RNA_def_property_range(prop, 2, 3);
+ RNA_def_property_ui_range(prop, 2, 3, 1, -1);
+ RNA_def_property_ui_text(prop, "Solver Res", "Solver resolution(2D/3D)");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
}
static void rna_def_smoke_flow_settings(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list