[Bf-blender-cvs] [13124fa84e1] fluid-mantaflow: Mantaflow: Added min/max timestep parameters

Sebastián Barschkis noreply at git.blender.org
Wed Nov 20 14:40:13 CET 2019


Commit: 13124fa84e10b0fc23dfe3adb8ca68eac9c0275b
Author: Sebastián Barschkis
Date:   Wed Nov 20 13:05:53 2019 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB13124fa84e10b0fc23dfe3adb8ca68eac9c0275b

Mantaflow: Added min/max timestep parameters

These parameters will allow the user to better control how long bake jobs may/should take.

===================================================================

M	intern/mantaflow/intern/MANTA_main.cpp
M	intern/mantaflow/intern/strings/fluid_script.h
M	release/scripts/startup/bl_ui/properties_physics_manta.py
M	source/blender/blenkernel/intern/manta.c
M	source/blender/makesdna/DNA_manta_types.h
M	source/blender/makesrna/intern/rna_manta.c

===================================================================

diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index 69e4b17d3bc..8e0fd3c7e1a 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -669,6 +669,10 @@ std::string MANTA::getRealValue(const std::string &varName, MantaModifierData *m
     ss << mmd->domain->cfl_condition;
   else if (varName == "DT")
     ss << mmd->domain->dt;
+  else if (varName == "TIMESTEPS_MIN")
+    ss << mmd->domain->timesteps_minimum;
+  else if (varName == "TIMESTEPS_MAX")
+    ss << mmd->domain->timesteps_maximum;
   else if (varName == "TIME_TOTAL")
     ss << mmd->domain->time_total;
   else if (varName == "TIME_PER_FRAME")
diff --git a/intern/mantaflow/intern/strings/fluid_script.h b/intern/mantaflow/intern/strings/fluid_script.h
index 55e074f2b99..e2f08956c07 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -123,6 +123,8 @@ timePerFrame_s$ID$ = $TIME_PER_FRAME$\n\
 frameLength_s$ID$  = $FRAME_LENGTH$\n\
 dt0_s$ID$          = $DT$\n\
 cflCond_s$ID$      = $CFL$\n\
+timestepsMin_s$ID$ = $TIMESTEPS_MIN$\n\
+timestepsMax_s$ID$ = $TIMESTEPS_MAX$\n\
 \n\
 # Fluid diffusion / viscosity\n\
 domainSize_s$ID$ = $FLUID_DOMAIN_SIZE$ # longest domain side in meters\n\
@@ -189,8 +191,8 @@ const std::string fluid_time_stepping =
     "\n\
 mantaMsg('Fluid adaptive time stepping')\n\
 s$ID$.frameLength  = frameLength_s$ID$\n\
-s$ID$.timestepMin  = s$ID$.frameLength / 5.\n\
-s$ID$.timestepMax  = s$ID$.frameLength\n\
+s$ID$.timestepMin  = s$ID$.frameLength / max(1, timestepsMax_s$ID$)\n\
+s$ID$.timestepMax  = s$ID$.frameLength / max(1, timestepsMin_s$ID$)\n\
 s$ID$.cfl          = cflCond_s$ID$\n\
 s$ID$.timePerFrame = timePerFrame_s$ID$\n\
 s$ID$.timestep     = dt0_s$ID$\n\
@@ -201,8 +203,8 @@ const std::string fluid_time_stepping_noise =
     "\n\
 mantaMsg('Fluid adaptive time stepping noise')\n\
 sn$ID$.frameLength = frameLength_s$ID$\n\
-sn$ID$.timestepMin = sn$ID$.frameLength / 10.\n\
-sn$ID$.timestepMax = sn$ID$.frameLength\n\
+sn$ID$.timestepMin = s$ID$.timestepMin\n\
+sn$ID$.timestepMax = s$ID$.timestepMax\n\
 sn$ID$.cfl         = cflCond_s$ID$\n\
 sn$ID$.timestep    = dt0_s$ID$\n\
 sn$ID$.timeTotal   = timeTotal_s$ID$\n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_manta.py b/release/scripts/startup/bl_ui/properties_physics_manta.py
index 5378ebf81fe..e055dc199f1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_manta.py
+++ b/release/scripts/startup/bl_ui/properties_physics_manta.py
@@ -149,10 +149,16 @@ class PHYSICS_PT_manta_fluid(PhysicButtonsPanel, Panel):
 
             col = flow.column()
             col.prop(domain, "resolution_max", text="Resolution Divisions")
-            col.prop(domain, "use_adaptive_stepping", text="Use Adaptive Stepping")
             col.prop(domain, "time_scale", text="Time Scale")
             col.prop(domain, "cfl_condition", text="CFL Number")
 
+            col = flow.column()
+            col.prop(domain, "use_adaptive_stepping", text="Use Adaptive Stepping")
+            col1 = col.column(align=True)
+            col1.enabled = domain.use_adaptive_stepping
+            col1.prop(domain, "timesteps_maximum", text="Timesteps Maximum")
+            col1.prop(domain, "timesteps_minimum", text="Minimum")
+
             col.separator()
 
             col = flow.column()
diff --git a/source/blender/blenkernel/intern/manta.c b/source/blender/blenkernel/intern/manta.c
index 180fb63df2a..bc917ee2523 100644
--- a/source/blender/blenkernel/intern/manta.c
+++ b/source/blender/blenkernel/intern/manta.c
@@ -772,6 +772,8 @@ void mantaModifier_createType(struct MantaModifierData *mmd)
       /* time options */
       mmd->domain->time_scale = 1.0;
       mmd->domain->cfl_condition = 4.0;
+      mmd->domain->timesteps_minimum = 1;
+      mmd->domain->timesteps_maximum = 4;
 
       /* display options */
       mmd->domain->slice_method = FLUID_DOMAIN_SLICE_VIEW_ALIGNED;
@@ -1006,6 +1008,8 @@ void mantaModifier_copy(const struct MantaModifierData *mmd,
     /* time options */
     tmds->time_scale = mds->time_scale;
     tmds->cfl_condition = mds->cfl_condition;
+    tmds->timesteps_minimum = mds->timesteps_minimum;
+    tmds->timesteps_maximum = mds->timesteps_maximum;
 
     /* display options */
     tmds->slice_method = mds->slice_method;
diff --git a/source/blender/makesdna/DNA_manta_types.h b/source/blender/makesdna/DNA_manta_types.h
index 075584518db..fe3f684ae26 100644
--- a/source/blender/makesdna/DNA_manta_types.h
+++ b/source/blender/makesdna/DNA_manta_types.h
@@ -364,6 +364,8 @@ typedef struct MantaDomainSettings {
   float frame_length;
   float time_scale;
   float cfl_condition;
+  int timesteps_minimum;
+  int timesteps_maximum;
 
   /* display options */
   char slice_method, axis_slice_method;
diff --git a/source/blender/makesrna/intern/rna_manta.c b/source/blender/makesrna/intern/rna_manta.c
index 78131ec4c97..b42e015f022 100644
--- a/source/blender/makesrna/intern/rna_manta.c
+++ b/source/blender/makesrna/intern/rna_manta.c
@@ -2027,6 +2027,22 @@ static void rna_def_manta_domain_settings(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Adaptive stepping", "Enable adaptive time-stepping");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Manta_resetCache");
 
+  prop = RNA_def_property(srna, "timesteps_minimum", PROP_INT, PROP_NONE);
+  RNA_def_property_range(prop, 1, 100);
+  RNA_def_property_ui_range(prop, 0, 100, 1, -1);
+  RNA_def_property_ui_text(prop,
+                           "Minimum",
+                           "Minimum number of simulation steps to perform for one frame");
+  RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Manta_reset");
+
+  prop = RNA_def_property(srna, "timesteps_maximum", PROP_INT, PROP_NONE);
+  RNA_def_property_range(prop, 1, 100);
+  RNA_def_property_ui_range(prop, 0, 100, 1, -1);
+  RNA_def_property_ui_text(prop,
+                           "Maximum",
+                           "Maximum number of simulation steps to perform for one frame");
+  RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Manta_reset");
+
   /* display settings */
 
   prop = RNA_def_property(srna, "slice_method", PROP_ENUM, PROP_NONE);



More information about the Bf-blender-cvs mailing list