[Bf-blender-cvs] [3b60dd8c46d] fluid-mantaflow: fixed and cleaned up inflow grid
Sebastián Barschkis
noreply at git.blender.org
Sun Mar 26 20:41:25 CEST 2017
Commit: 3b60dd8c46d0aa2f6f75ecf9b7cf8d3beca2e3f9
Author: Sebastián Barschkis
Date: Sat Mar 18 19:10:37 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB3b60dd8c46d0aa2f6f75ecf9b7cf8d3beca2e3f9
fixed and cleaned up inflow grid
inflow grid is necessary when running manta script in mantaflow standalone mode
===================================================================
M intern/mantaflow/extern/manta_fluid_API.h
M intern/mantaflow/intern/FLUID.cpp
M intern/mantaflow/intern/FLUID.h
M intern/mantaflow/intern/manta_fluid_API.cpp
M intern/mantaflow/intern/strings/smoke_script.h
M source/blender/blenkernel/intern/smoke.c
===================================================================
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 667360e9aaf..89cc73789c9 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -86,8 +86,6 @@ int smoke_turbulence_has_colors(struct FLUID *smoke);
void smoke_ensure_heat(struct FLUID *smoke, struct SmokeModifierData *smd);
void smoke_ensure_fire(struct FLUID *smoke, struct SmokeModifierData *smd);
void smoke_ensure_colors(struct FLUID *smoke, struct SmokeModifierData *smd);
-float *smoke_get_inflow_grid(struct FLUID *smoke);
-float *smoke_get_fuel_inflow(struct FLUID *smoke);
float *liquid_get_phiin(struct FLUID *liquid);
float *liquid_get_phiobs(struct FLUID *liquid);
@@ -115,6 +113,7 @@ void liquid_load_data_high(struct FLUID *liquid, char *pathname);
void liquid_manta_export(struct FLUID* smoke, struct SmokeModifierData *smd);
int *fluid_get_num_obstacle(struct FLUID *fluid);
+float *fluid_get_inflow(struct FLUID *fluid);
#ifdef __cplusplus
}
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 8a5c0dfe201..4aa70609754 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -94,8 +94,6 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
mColorR = NULL;
mColorG = NULL;
mColorB = NULL;
- mDensityInflow = NULL;
- mFuelInflow = NULL;
mObstacle = NULL;
// Smoke high res grids
@@ -438,8 +436,6 @@ FLUID::~FLUID()
mColorR = NULL;
mColorG = NULL;
mColorB = NULL;
- mDensityInflow = NULL;
- mFuelInflow = NULL;
mObstacle = NULL;
mDensityHigh = NULL;
@@ -943,9 +939,8 @@ void FLUID::updatePointers()
// Smoke
if (mUsingSmoke) {
- mDensity = (float*) getGridPointer("density", "s");
- mDensityInflow = (float*) getGridPointer("inflow_grid", "s");
- mFuelInflow = (float*) getGridPointer("fuel_inflow", "s");
+ mDensity = (float*) getGridPointer("density", "s");
+ mInflow = (float*) getGridPointer("inflow", "s");
if (mUsingHeat) {
mHeat = (float*) getGridPointer("heat", "s");
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index 76452fa11c2..25a4a61487a 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -104,8 +104,7 @@ public:
inline float* getColorR() { return mColorR; }
inline float* getColorG() { return mColorG; }
inline float* getColorB() { return mColorB; }
- inline float* getDensityInflow() { return mDensityInflow; }
- inline float* getFuelInflow() { return mFuelInflow; }
+ inline float* getInflow() { return mInflow; }
inline float* getDensityHigh() { return mDensityHigh; }
inline float* getFlameHigh() { return mFlameHigh; }
@@ -147,9 +146,6 @@ public:
void updateMeshData(const char* filename);
- // Helper for standalone Mantaflow
- float* getInflow() { return mInflow; }
-
private:
// simulation constants
size_t mTotalCells;
@@ -177,7 +173,7 @@ private:
float mConstantScaling;
std::vector<std::string> mCommands;
- // Smoke grids low res
+ // Smoke grids
float* mDensity;
float* mHeat;
float* mVelocityX;
@@ -197,10 +193,7 @@ private:
float *mColorR;
float *mColorG;
float *mColorB;
- float* mDensityInflow;
- float* mFuelInflow;
-
- // Smoke grids high res
+ float *mInflow;
float* mDensityHigh;
float* mFlameHigh;
float* mFuelHigh;
@@ -214,7 +207,7 @@ private:
float* mTextureU2;
float* mTextureV2;
float* mTextureW2;
-
+
// Liquids
float* mPhiIn;
float* mPhiObs;
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 8bab7f6ef4d..2acac08b911 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -478,16 +478,6 @@ extern "C" void liquid_ensure_init(FLUID *smoke, struct SmokeModifierData *smd)
}
}
-extern "C" float *smoke_get_inflow_grid(FLUID *smoke)
-{
- return smoke->getDensityInflow();
-}
-
-extern "C" float *smoke_get_fuel_inflow(FLUID *smoke)
-{
- return smoke->getFuelInflow();
-}
-
extern "C" float *liquid_get_phiin(FLUID *liquid)
{
return liquid->getPhiIn();
@@ -616,3 +606,8 @@ extern "C" void liquid_manta_export(FLUID* liquid, SmokeModifierData *smd)
liquid->exportLiquidScript(smd);
liquid->exportLiquidData(smd);
}
+
+extern "C" float *fluid_get_inflow(FLUID* fluid)
+{
+ return fluid->getInflow();
+}
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index e7f32830e6b..81f6ff8d5b0 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -108,8 +108,7 @@ forces = s.create(Vec3Grid)\n\
x_force = s.create(RealGrid)\n\
y_force = s.create(RealGrid)\n\
z_force = s.create(RealGrid)\n\
-inflow_grid = s.create(RealGrid)\n\
-fuel_inflow = s.create(RealGrid)\n";
+inflow = s.create(RealGrid)\n";
const std::string smoke_alloc_high = "\n\
# prepare grids high\n\
@@ -426,8 +425,7 @@ def load_smoke_data_low(path):\n\
x_force.load(os.path.join(path, 'x_force.uni'))\n\
y_force.load(os.path.join(path, 'y_force.uni'))\n\
z_force.load(os.path.join(path, 'z_force.uni'))\n\
- inflow_grid.load(os.path.join(path, 'inflow_low.uni'))\n\
- fuel_inflow.load(os.path.join(path, 'fuel_inflow.uni'))\n\
+ inflow.load(os.path.join(path, 'inflow_low.uni'))\n\
x_vel.load(os.path.join(path, 'x_vel.uni'))\n\
y_vel.load(os.path.join(path, 'y_vel.uni'))\n\
z_vel.load(os.path.join(path, 'z_vel.uni'))\n\
@@ -481,8 +479,7 @@ def save_smoke_data_low(path):\n\
x_force.save(os.path.join(path, 'x_force.uni'))\n\
y_force.save(os.path.join(path, 'y_force.uni'))\n\
z_force.save(os.path.join(path, 'z_force.uni'))\n\
- inflow_grid.save(os.path.join(path, 'inflow_low.uni'))\n\
- fuel_inflow.save(os.path.join(path, 'fuel_inflow.uni'))\n\
+ inflow.save(os.path.join(path, 'inflow_low.uni'))\n\
x_vel.save(os.path.join(path, 'x_vel.uni'))\n\
y_vel.save(os.path.join(path, 'y_vel.uni'))\n\
z_vel.save(os.path.join(path, 'z_vel.uni'))\n\
@@ -578,8 +575,7 @@ if 'forces' in globals() : del forces\n\
if 'x_force' in globals() : del x_force\n\
if 'y_force' in globals() : del y_force\n\
if 'z_force' in globals() : del z_force\n\
-if 'inflow_grid' in globals() : del inflow_grid\n\
-if 'fuel_inflow' in globals() : del fuel_inflow\n";
+if 'inflow' in globals() : del inflow\n";
const std::string smoke_delete_grids_high = "\n\
mantaMsg('Deleting base grids high')\n\
@@ -654,9 +650,9 @@ def apply_inflow():\n\
mantaMsg('Applying inflow')\n\
#inflow_grid.multConst(0.1)\n\
#fuel_inflow.multConst(0.1)\n\
- density.add(inflow_grid)\n\
- if using_fire:\n\
- fuel.add(fuel_inflow)\n";
+ #density.add(inflow_grid)\n\
+ #if using_fire:\n\
+ #fuel.add(fuel_inflow)\n";
const std::string smoke_inflow_high = "\n\
# TODO\n";
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 7aa96bbcbe2..4a588e81296 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -2327,14 +2327,19 @@ BLI_INLINE void apply_outflow_fields(int index, float inflow_value, float *densi
}
}
-BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value, float inflow_value, int index, float *density, float *heat, float *fuel, float *react, float *color_r, float *color_g, float *color_b, float *phi)
+BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value, float inflow_value, int index, float *density, float *heat, float *fuel, float *react, float *color_r, float *color_g, float *color_b, float *phi, float *manta_inflow)
{
/* add liquid inflow */
if (phi) {
phi[index] = inflow_value;
return;
}
-
+
+ /* save inflow value for mantaflow standalone */
+ if (manta_inflow) {
+ manta_inflow[index] = emission_value;
+ }
+
/* add smoke inflow */
int absolute_flow = (sfs->flags & MOD_SMOKE_FLOW_ABSOLUTE);
float dens_old = density[index];
@@ -2651,6 +2656,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
float *velocity_z = smoke_get_velocity_z(sds->fluid);
float *phiin = liquid_get_phiin(sds->fluid);
float *phiout = liquid_get_phiout(sds->fluid);
+ float *manta_inflow = fluid_get_inflow(sds->fluid); // Copy of emission map for inflow modeling in Mantaflow standalone
int bigres[3];
float *velocity_map = em->velocity;
@@ -2685,12 +2691,12 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
apply_outflow_fields(d_index, inflow_map[e_index], density, heat, fuel, react, color_r, color_g, color_b, phiout);
}
else if (sfs->behavior == MOD_SMOKE_FLOW_BEHAVIOR_GEOMETRY && smd2->time > 2) {
- apply_inflow_fields(sfs, 0.0f, 0.5f, d_index, density, heat, fuel, react, color_r, color_g, color_b, phiin);
+ apply_inflow_fields(sfs, 0.0f, 0.5f, d_index, density, heat, fuel, react, color_r, color_g, color_b, phiin, manta_inflow);
}
else if (sfs->behavior == MOD_SMOKE_FLOW_BEHAVIOR_INFLOW || sfs->behavior == MOD_SMOKE_FLOW_BEHAVIOR_GEOMETRY) { // inflow
/* only apply inflow if enabled */
if (sfs->flags & MOD_SMOKE_FLOW_USE_INFLOW) {
- apply_inflow_fields(sfs, emission_map[e_index], inflow_map[e_index], d_index, density, heat, fuel, react, color_r, color_g, color_b, phiin);
+ apply_inflow_fields(sfs, emission_map[e_index], inflow_map[e_index], d_index, density, heat, fuel, react, color_r, color_g, color_b, phiin, manta_inflow);
/* initial velocity */
if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
@@ -2783,11 +2789,11 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
}
}
else if (sfs->behavior == MOD_SMOKE_FLOW_BEHAVIOR_GEOMETRY && smd2->time > 2) {
- apply_inflow_fields(sfs, 0.0f, 0.5f,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list