Fluid: Added an option to delete fluid inside obstacles
authorSebastián Barschkis <sebbas@sebbas.org>
Wed, 4 Mar 2020 16:23:09 +0000 (17:23 +0100)
committerSebastián Barschkis <sebbas@sebbas.org>
Wed, 4 Mar 2020 17:46:48 +0000 (18:46 +0100)
Simple checkbox that - if enabled - will tell the solver to clear density or liquid particles in obstacle cells.

intern/mantaflow/intern/MANTA_main.cpp
intern/mantaflow/intern/strings/fluid_script.h
intern/mantaflow/intern/strings/liquid_script.h
intern/mantaflow/intern/strings/smoke_script.h
release/scripts/startup/bl_ui/properties_physics_fluid.py
source/blender/makesdna/DNA_fluid_types.h
source/blender/makesrna/intern/rna_fluid.c

index 2566e9b45b8a2e59530b6ac9a725da4ef4b23b50..89e505fcf9725fac68e5b84f6dac10f3621ee0a9 100644 (file)
@@ -977,6 +977,8 @@ std::string MANTA::getRealValue(const std::string &varName, FluidModifierData *m
     ss << (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS ? "True" : "False");
   else if (varName == "USING_FRACTIONS")
     ss << (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS ? "True" : "False");
+  else if (varName == "DELETE_IN_OBSTACLE")
+    ss << (mmd->domain->flags & FLUID_DOMAIN_DELETE_IN_OBSTACLE ? "True" : "False");
   else
     std::cout << "ERROR: Unknown option: " << varName << std::endl;
   return ss.str();
index 6ddf97e7b3f095470520453afd8da10540735bc0..0442609a15db87de977b589df35fcae874e1a5ef 100644 (file)
@@ -96,9 +96,10 @@ gravity_s$ID$ = vec3($GRAVITY_X$, $GRAVITY_Y$, $GRAVITY_Z$)\n\
 gs_s$ID$      = vec3($RESX$, $RESY$, $RESZ$)\n\
 maxVel_s$ID$  = 0\n\
 \n\
-doOpen_s$ID$          = $DO_OPEN$\n\
-boundConditions_s$ID$ = '$BOUND_CONDITIONS$'\n\
-boundaryWidth_s$ID$   = $BOUNDARY_WIDTH$\n\
+doOpen_s$ID$           = $DO_OPEN$\n\
+boundConditions_s$ID$  = '$BOUND_CONDITIONS$'\n\
+boundaryWidth_s$ID$    = $BOUNDARY_WIDTH$\n\
+deleteInObstacle_s$ID$ = $DELETE_IN_OBSTACLE$\n\
 \n\
 using_smoke_s$ID$        = $USING_SMOKE$\n\
 using_liquid_s$ID$       = $USING_LIQUID$\n\
index d885296ec17786b88ee64b0406f704cd93cdc9d3..0d20c4cb2041f8033989f1ff9bcd87833886156e 100644 (file)
@@ -212,7 +212,7 @@ def liquid_step_$ID$():\n\
     mantaMsg('Liquid step')\n\
     \n\
     mantaMsg('Advecting particles')\n\
-    pp_s$ID$.advectInGrid(flags=flags_s$ID$, vel=vel_s$ID$, integrationMode=IntRK4, deleteInObstacle=False, stopInObstacle=False)\n\
+    pp_s$ID$.advectInGrid(flags=flags_s$ID$, vel=vel_s$ID$, integrationMode=IntRK4, deleteInObstacle=deleteInObstacle_s$ID$, stopInObstacle=False)\n\
     \n\
     mantaMsg('Pushing particles out of obstacles')\n\
     pushOutofObs(parts=pp_s$ID$, flags=flags_s$ID$, phiObs=phiObs_s$ID$)\n\
index 119f5cd0a88ce92747da83457c04f8e6ba75e124..719ebbfef3e1d0a940c3ce49f1fd70ed3d6c15c0 100644 (file)
@@ -379,7 +379,8 @@ def smoke_step_$ID$():\n\
         resampleVec3ToMac(source=obvelC_s$ID$, target=obvel_s$ID$)\n\
     \n\
     # Cells inside obstacle should not contain any density, fire, etc.\n\
-    resetInObstacle(flags=flags_s$ID$, density=density_s$ID$, vel=vel_s$ID$, heat=heat_s$ID$, fuel=fuel_s$ID$, flame=flame_s$ID$, red=color_r_s$ID$, green=color_g_s$ID$, blue=color_b_s$ID$)\n\
+    if deleteInObstacle_s$ID$:\n\
+        resetInObstacle(flags=flags_s$ID$, density=density_s$ID$, vel=vel_s$ID$, heat=heat_s$ID$, fuel=fuel_s$ID$, flame=flame_s$ID$, red=color_r_s$ID$, green=color_g_s$ID$, blue=color_b_s$ID$)\n\
     \n\
     # add initial velocity\n\
     if using_invel_s$ID$:\n\
index 4d6d3d8f607c4669f8a696032fac9e9815339bfb..04297fc725b27876ed9163636e57ccea066ea158 100644 (file)
@@ -271,10 +271,10 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 
             col.prop(effector_settings, "use_plane_init", text="Is Planar")
             col.prop(effector_settings, "surface_distance", text="Surface Thickness")
+            col.prop(effector_settings, "delete_in_obstacle", text="Delete In Obstacle")
 
             if effector_settings.effector_type == 'GUIDE':
                 col.prop(effector_settings, "velocity_factor", text="Velocity Factor")
-                col = flow.column()
                 col.prop(effector_settings, "guide_mode", text="Guide Mode")
 
 
index e12bee13ebc85748f4f5a019ee3712c3e0bed23f..783babdaa1c49255a4972f8dc596c5680ca24788 100644 (file)
@@ -41,6 +41,7 @@ enum {
   FLUID_DOMAIN_USE_SPEED_VECTORS = (1 << 11),   /* Generate mesh speed vectors. */
   FLUID_DOMAIN_EXPORT_MANTA_SCRIPT = (1 << 12), /* Export mantaflow script during bake. */
   FLUID_DOMAIN_USE_FRACTIONS = (1 << 13),       /* Use second order obstacles. */
+  FLUID_DOMAIN_DELETE_IN_OBSTACLE = (1 << 14),  /* Delete fluid inside obstacles. */
 };
 
 /* Border collisions. */
@@ -494,7 +495,7 @@ enum {
   FLUID_FLOW_USE_PART_SIZE = (1 << 4),
   /* Control when to apply inflow. */
   FLUID_FLOW_USE_INFLOW = (1 << 5),
-  /* Control when to apply inflow. */
+  /* Control how to initialize flow objects. */
   FLUID_FLOW_USE_PLANE_INIT = (1 << 6),
 };
 
index d4bc02bbf3e9a0801ca0774afb54ba712f2b8763..7edb1cfaa81e3495f2781f48377f4e386aa3bdf2 100644 (file)
@@ -2539,6 +2539,11 @@ static void rna_def_fluid_effector_settings(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Is Planar", "Treat this object as a planar, unclosed mesh");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_reset");
 
+  prop = RNA_def_property(srna, "delete_in_obstacle", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_DELETE_IN_OBSTACLE);
+  RNA_def_property_ui_text(prop, "Clear In Obstacle", "Delete fluid inside obstacles");
+  RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_reset");
+
   prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
   RNA_def_property_float_sdna(prop, NULL, "vel_multi");
   RNA_def_property_range(prop, -100.0, 100.0);