[Bf-blender-cvs] [02b271947e5] fluid-mantaflow: added settings for fluid diffusion (i.e. viscosity and surface tension)
Sebastián Barschkis
noreply at git.blender.org
Wed Nov 29 19:12:39 CET 2017
Commit: 02b271947e5bf0db62ee6b86f8d83920715b7a13
Author: Sebastián Barschkis
Date: Wed Nov 29 16:28:37 2017 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB02b271947e5bf0db62ee6b86f8d83920715b7a13
added settings for fluid diffusion (i.e. viscosity and surface tension)
===================================================================
M intern/mantaflow/intern/FLUID.cpp
M intern/mantaflow/intern/strings/liquid_script.h
M intern/mantaflow/intern/strings/shared_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 74e3b75c5c7..824785223e2 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -815,8 +815,10 @@ std::string FLUID::getRealValue(const std::string& varName, SmokeModifierData *
ss << smd->domain->particle_tracer_max;
else if (varName == "LIQUID_SURFACE_TENSION")
ss << smd->domain->surface_tension;
- else if (varName == "LIQUID_VISCOSITY")
+ else if (varName == "FLUID_VISCOSITY")
ss << smd->domain->viscosity;
+ else if (varName == "FLUID_DOMAIN_SIZE")
+ ss << smd->domain->domain_size;
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 d26dffbe4c2..deea39f8272 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -45,7 +45,6 @@ maxParticles_s$ID$ = $PARTICLE_MAXIMUM$\n\
radiusFactor_s$ID$ = $PARTICLE_RADIUS$\n\
randomness_s$ID$ = $PARTICLE_RANDOMNESS$\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\
@@ -221,10 +220,10 @@ def liquid_step_$ID$():\n\
mantaMsg('Sampling snd particles')\n\
sampleSndParts(phi=phi_s$ID$, phiIn=phiIn_s$ID$, flags=flags_s$ID$, vel=vel_s$ID$, parts=ppSnd_s$ID$, type=$SNDPARTICLE_TYPES$, amountDroplet=$SNDPARTICLE_DROPLET_AMOUNT$, amountFloater=$SNDPARTICLE_FLOATER_AMOUNT$, amountTracer=$SNDPARTICLE_TRACER_AMOUNT$, thresholdDroplet=$SNDPARTICLE_DROPLET_THRESH$)\n\
mantaMsg('Updating snd particle data (velocity, life count)')\n\
- updateSndParts(phi=phi_s$ID$, flags=flags_s$ID$, vel=vel_s$ID$, gravity=gravity_s$ID$, parts=ppSnd_s$ID$, partVel=pVelSnd_pp$ID$, partLife=pLifeSnd_pp$ID$, riseBubble=$SNDPARTICLE_BUBBLE_RISE$)\n\
+ updateSndParts(phi=phi_s$ID$, flags=flags_s$ID$, vel=vel_s$ID$, gravity=gravity_s$ID$, parts=ppSnd_s$ID$, partVel=pVelSnd_pp$ID$, partLife=pLifeSnd_pp$ID$, riseBubble=$SNDPARTICLE_BUBBLE_RISE$, lifeDroplet=$SNDPARTICLE_DROPLET_LIFE$, lifeBubble=$SNDPARTICLE_BUBBLE_LIFE$, lifeFloater=$SNDPARTICLE_FLOATER_LIFE$, lifeTracer=$SNDPARTICLE_TRACER_LIFE$)\n\
mantaMsg('Adjusting snd particles')\n\
pushOutofObs(parts=ppSnd_s$ID$, flags=flags_s$ID$, phiObs=phiObs_s$ID$, shift=1.0)\n\
- adjustSndParts(parts=ppSnd_s$ID$, flags=flags_s$ID$, phi=phi_s$ID$, partVel=pVelSnd_pp$ID$, partLife=pLifeSnd_pp$ID$, lifeDroplet=$SNDPARTICLE_DROPLET_LIFE$, lifeBubble=$SNDPARTICLE_BUBBLE_LIFE$, lifeFloater=$SNDPARTICLE_FLOATER_LIFE$, lifeTracer=$SNDPARTICLE_TRACER_LIFE$, maxDroplet=$SNDPARTICLE_DROPLET_MAX$, maxBubble=$SNDPARTICLE_BUBBLE_MAX$, maxFloater=$SNDPARTICLE_FLOATER_MAX$, maxTracer=$SNDPARTICLE_TRACER_MAX$)\n\
+ adjustSndParts(parts=ppSnd_s$ID$, flags=flags_s$ID$, phi=phi_s$ID$, partVel=pVelSnd_pp$ID$, partLife=pLifeSnd_pp$ID$, maxDroplet=$SNDPARTICLE_DROPLET_MAX$, maxBubble=$SNDPARTICLE_BUBBLE_MAX$, maxFloater=$SNDPARTICLE_FLOATER_MAX$, maxTracer=$SNDPARTICLE_TRACER_MAX$)\n\
\n\
# create level set of particles\n\
gridParticleIndex(parts=pp_s$ID$, flags=flags_s$ID$, indexSys=pindex_s$ID$, index=gpi_s$ID$)\n\
diff --git a/intern/mantaflow/intern/strings/shared_script.h b/intern/mantaflow/intern/strings/shared_script.h
index dfbfab060bb..f547296ae08 100644
--- a/intern/mantaflow/intern/strings/shared_script.h
+++ b/intern/mantaflow/intern/strings/shared_script.h
@@ -87,7 +87,12 @@ alpha_s$ID$ = $GUIDING_ALPHA$\n\
beta_s$ID$ = $GUIDING_BETA$\n\
tau_s$ID$ = 1.0\n\
sigma_s$ID$ = 0.99/tau_s$ID$\n\
-theta_s$ID$ = 1.0\n";
+theta_s$ID$ = 1.0\n\
+\n\
+# fluid diffusion / viscosity\n\
+domainSize_s$ID$ = $FLUID_DOMAIN_SIZE$ # longest domain side in cm\n\
+if domainSize_s$ID$ == 0: domainSize_s$ID$ = 100 # TODO (sebbas): just for versioning, remove with proper 2.8 versioning\n\
+viscosity_s$ID$ = $FLUID_VISCOSITY$ / (domainSize_s$ID$ / res_s$ID$) * (30.0 / $FPS$) # assuming 30fps\n";
const std::string fluid_variables_high= "\n\
upres_xl$ID$ = $UPRES$\n\
@@ -178,7 +183,7 @@ const std::string fluid_alloc_sndparts_low = "\n\
mantaMsg('Allocating snd parts low')\n\
ppSnd_s$ID$ = s$ID$.create(BasicParticleSystem)\n\
pVelSnd_pp$ID$ = ppSnd_s$ID$.create(PdataVec3)\n\
-pLifeSnd_pp$ID$ = ppSnd_s$ID$.create(PdataInt)\n";
+pLifeSnd_pp$ID$ = ppSnd_s$ID$.create(PdataReal)\n";
//////////////////////////////////////////////////////////////////////
// DESTRUCTION
@@ -202,6 +207,8 @@ if 'beta_s$ID$' in globals() : del beta_s$ID$\n\
if 'tau_s$ID$' in globals() : del tau_s$ID$\n\
if 'sigma_s$ID$' in globals() : del sigma_s$ID$\n\
if 'theta_s$ID$' in globals() : del theta_s$ID$\n\
+if 'domainSize_s$ID$' in globals() : del domainSize_s$ID$\n\
+if 'viscosity_s$ID$' in globals() : del viscosity_s$ID$\n\
if 'using_obstacle_s$ID$' in globals() : del using_obstacle_s$ID$\n\
if 'using_guiding_s$ID$' in globals() : del using_guiding_s$ID$\n\
if 'using_invel_s$ID$' in globals() : del using_invel_s$ID$\n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index a8d94108e06..a4d3209e7a4 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -438,10 +438,11 @@ class PHYSICS_PT_smoke_diffusion(PhysicButtonsPanel, Panel):
col = split.column()
col.enabled = not domain.point_cache.is_baked
col.prop(domain, "viscosity", text="Viscosity")
+ col.prop(domain, "domain_size", text="Size")
col = split.column()
col.enabled = not domain.point_cache.is_baked
- col.prop(domain, "surface_tension", text="Surface tension")
+ col.prop(domain, "surface_tension", text="Tension")
class PHYSICS_PT_smoke_guiding(PhysicButtonsPanel, Panel):
bl_label = "Fluid Guiding"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index c9e0c11880d..b5f6c5c19fe 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -546,23 +546,24 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->particle_droplet_threshold = 2.0f;
smd->domain->particle_droplet_amount = 2.5f;
- smd->domain->particle_droplet_life = 0;
+ smd->domain->particle_droplet_life = 250.0f;
smd->domain->particle_droplet_max = 4;
smd->domain->particle_bubble_rise = 0.5f;
- smd->domain->particle_bubble_life = 0;
+ smd->domain->particle_bubble_life = 250.0f;
smd->domain->particle_bubble_max = 2;
smd->domain->particle_floater_amount = 0.5f;
- smd->domain->particle_floater_life = 0;
+ smd->domain->particle_floater_life = 250.0f;
smd->domain->particle_floater_max = 2;
smd->domain->particle_tracer_amount = 0.5f;
- smd->domain->particle_tracer_life = 0;
+ smd->domain->particle_tracer_life = 250.0f;
smd->domain->particle_tracer_max = 2;
smd->domain->surface_tension = 0.0f;
smd->domain->viscosity = 0.0f;
+ smd->domain->domain_size = 100.0f;
/* guiding */
smd->domain->guiding_alpha = 2.0f;
@@ -708,6 +709,7 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
tsmd->domain->surface_tension = smd->domain->surface_tension;
tsmd->domain->viscosity = smd->domain->viscosity;
+ tsmd->domain->domain_size = smd->domain->domain_size;
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 6cc1bfd8c3a..c56fb541646 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -264,6 +264,8 @@ typedef struct SmokeDomainSettings {
int particle_type;
float surface_tension;
float viscosity;
+ float domain_size;
+ char pad2[4];
/* 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 b0cb6d60b1f..033d0595d56 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -1352,8 +1352,8 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "particle_droplet_life", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(prop, "Life", "Maximum drop particle life in frames (Life 0: live infinitely)");
+ RNA_def_property_range(prop, 0, 10000);
+ RNA_def_property_ui_text(prop, "Life", "Life span of drop particles");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
@@ -1369,8 +1369,8 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "particle_bubble_life", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(prop, "Life", "Maximum bubble particle life in frames (Life 0: live infinitely)");
+ RNA_def_property_range(prop, 0, 10000);
+ RNA_def_property_ui_text(prop, "Life", "Life span of bubble particles");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
@@ -1386,8 +1386,8 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
prop = RNA_def_property(srna, "particle_floater_life", PROP_INT, PROP_NONE);
- RNA_def_property_range(prop, 0, 1000);
- RNA_def_property_ui_text(pr
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list