[Bf-blender-cvs] [a769db448c0] fluid-mantaflow: activated viscosity and surface tension settings for liquids

Sebastián Barschkis noreply at git.blender.org
Wed Nov 29 19:12:31 CET 2017


Commit: a769db448c0ce49f715fa898ee0f1885eecce93f
Author: Sebastián Barschkis
Date:   Tue Nov 28 12:49:22 2017 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBa769db448c0ce49f715fa898ee0f1885eecce93f

activated viscosity and surface tension settings for liquids

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

M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

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

diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index f371f4c1727..1706107bc22 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -813,6 +813,10 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 		ss << smd->domain->particle_tracer_life;
 	else if (varName == "SNDPARTICLE_TRACER_MAX")
 		ss << smd->domain->particle_tracer_max;
+	else if (varName == "LIQUID_SURFACE_TENSION")
+		ss << smd->domain->surface_tension;
+	else if (varName == "LIQUID_VISCOSITY")
+		ss << smd->domain->viscosity;
 	else if (varName == "SNDPARTICLE_TYPES") {
 		if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_DROP) {
 			ss << "PtypeDroplet";
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 8dadfa34644..d26dffbe4c2 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -44,8 +44,8 @@ minParticles_s$ID$   = $PARTICLE_MINIMUM$\n\
 maxParticles_s$ID$   = $PARTICLE_MAXIMUM$\n\
 radiusFactor_s$ID$   = $PARTICLE_RADIUS$\n\
 randomness_s$ID$     = $PARTICLE_RANDOMNESS$\n\
-surfaceTension_s$ID$ = 0.0\n\
-viscosity_s$ID$      = 0.0\n\
+surfaceTension_s$ID$ = $LIQUID_SURFACE_TENSION$\n\
+viscosity_s$ID$      = $LIQUID_VISCOSITY$\n\
 maxVel_s$ID$         = 1 # just declared here, do not set\n";
 
 const std::string liquid_variables_high = "\n\
@@ -64,7 +64,7 @@ phiIn_s$ID$      = s$ID$.create(LevelsetGrid)\n\
 phiOut_s$ID$     = s$ID$.create(LevelsetGrid)\n\
 phiOutIn_s$ID$   = s$ID$.create(LevelsetGrid)\n\
 pressure_s$ID$   = s$ID$.create(RealGrid)\n\
-curvature_s$ID$  = 0 #s$ID$.create(RealGrid)\n\
+curvature_s$ID$  = s$ID$.create(RealGrid)\n\
 \n\
 phiObs_s$ID$     = s$ID$.create(LevelsetGrid)\n\
 fractions_s$ID$  = 0 # s$ID$.create(MACGrid) # TODO (sebbas): disabling fractions for now - not fracwallbcs not supporting obvels yet\n\
@@ -279,8 +279,8 @@ def liquid_step_$ID$():\n\
     \n\
     setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=obvel_s$ID$ if using_obstacle_s$ID$ else 0, phiObs=phiObs_s$ID$, fractions=fractions_s$ID$)\n\
     \n\
-#    mantaMsg('Calculating curvature')\n\
-#    getLaplacian(laplacian=curvature_s$ID$, grid=phi_s$ID$)\n\
+    mantaMsg('Calculating curvature')\n\
+    getLaplacian(laplacian=curvature_s$ID$, grid=phi_s$ID$)\n\
     \n\
     if using_guiding_s$ID$:\n\
         mantaMsg('Guiding and pressure')\n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 637df208159..a8d94108e06 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -418,6 +418,31 @@ class PHYSICS_PT_smoke_particles(PhysicButtonsPanel, Panel):
         sub3 = col.column()
         sub3.prop(domain, "use_flip_particles", text="FLIP")
 
+class PHYSICS_PT_smoke_diffusion(PhysicButtonsPanel, Panel):
+    bl_label = "Fluid Diffusion"
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+    @classmethod
+    def poll(cls, context):
+        md = context.smoke
+        rd = context.scene.render
+        # Fluid diffusion only enabled for liquids (surface tension and viscosity not relevant for smoke)
+        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES) and (md.domain_settings.smoke_domain_type in {'LIQUID'}) 
+
+    def draw(self, context):
+        layout = self.layout
+        domain = context.smoke.domain_settings
+
+        split = layout.split()
+
+        col = split.column()
+        col.enabled = not domain.point_cache.is_baked
+        col.prop(domain, "viscosity", text="Viscosity")
+
+        col = split.column()
+        col.enabled = not domain.point_cache.is_baked
+        col.prop(domain, "surface_tension", text="Surface tension")
+
 class PHYSICS_PT_smoke_guiding(PhysicButtonsPanel, Panel):
     bl_label = "Fluid Guiding"
     COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -628,6 +653,7 @@ classes = (
     PHYSICS_PT_smoke_adaptive_domain,
     PHYSICS_PT_smoke_quality,
     PHYSICS_PT_smoke_particles,
+    PHYSICS_PT_smoke_diffusion,
     PHYSICS_PT_smoke_guiding,
     PHYSICS_PT_smoke_groups,
     PHYSICS_PT_smoke_cache,
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index a33f8202441..c9e0c11880d 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -561,6 +561,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			smd->domain->particle_tracer_life = 0;
 			smd->domain->particle_tracer_max = 2;
 
+			smd->domain->surface_tension = 0.0f;
+			smd->domain->viscosity = 0.0f;
+
 			/* guiding */
 			smd->domain->guiding_alpha = 2.0f;
 			smd->domain->guiding_beta = 5;
@@ -703,6 +706,9 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->particle_tracer_life = smd->domain->particle_tracer_life;
 		tsmd->domain->particle_tracer_max = smd->domain->particle_tracer_max;
 
+		tsmd->domain->surface_tension = smd->domain->surface_tension;
+		tsmd->domain->viscosity = smd->domain->viscosity;
+
 		tsmd->domain->guiding_alpha = smd->domain->guiding_alpha;
 		tsmd->domain->guiding_beta = smd->domain->guiding_beta;
 
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index d591cac5905..6cc1bfd8c3a 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -262,6 +262,8 @@ typedef struct SmokeDomainSettings {
 	int particle_tracer_life;
 	int particle_tracer_max;
 	int particle_type;
+	float surface_tension;
+	float viscosity;
 
 	/* fluid guiding parameters */
 	float guiding_alpha; /* guiding weight scalar (determines strength) */
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 5adb838ca8e..b0cb6d60b1f 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -1414,6 +1414,16 @@ 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, "surface_tension", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_range(prop, 0.0, 100.0);
+	RNA_def_property_ui_text(prop, "Tension", "Surface tension of liquid (higher value results in greater hydrophobic behaviour)");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
+	prop = RNA_def_property(srna, "viscosity", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_range(prop, 0.0, 100.0);
+	RNA_def_property_ui_text(prop, "Viscosity", "Viscosity of liquid (higher value results in more viscous liquid)");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+
 	prop = RNA_def_property(srna, "guiding_alpha", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "guiding_alpha");
 	RNA_def_property_range(prop, 1.0, 100.0);



More information about the Bf-blender-cvs mailing list