[Bf-blender-cvs] [e486b84b33d] fluid-mantaflow: cleanup for smoke preconditioner (multi-grid)

Sebastián Barschkis noreply at git.blender.org
Sat Aug 26 22:41:39 CEST 2017


Commit: e486b84b33db5056fb40b0a871e73dce72a9c0ec
Author: Sebastián Barschkis
Date:   Sat Aug 26 22:35:39 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBe486b84b33db5056fb40b0a871e73dce72a9c0ec

cleanup for smoke preconditioner (multi-grid)

better way to set preconditioner flag in dynamic scenes (scenes with moving obstacle)

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

M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/strings/smoke_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

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

diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index d1294a4b649..653710eb353 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -730,11 +730,6 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 		char parent_dir[1024];
 		BLI_split_dir_part(smd->domain->manta_filepath, parent_dir, sizeof(parent_dir));
 		ss << parent_dir;
-	} else if (varName == "PRECONDITIONER") {
-		if (smd->domain->preconditioner == MOD_SMOKE_PC_NONE) ss << "PcNone";
-		else if (smd->domain->preconditioner == MOD_SMOKE_PC_MIC) ss << "PcMIC";
-		else if (smd->domain->preconditioner == MOD_SMOKE_PC_MG_DYNAMIC) ss << "PcMGDynamic";
-		else if (smd->domain->preconditioner == MOD_SMOKE_PC_MG_STATIC) ss << "PcMGStatic";
 	} else if (varName == "ID")
 		ss << mCurrentID;
 	else if (varName == "USING_ADAPTIVETIME")
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index bcd9bea9405..10409aec8bf 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -55,6 +55,7 @@ if doOpen_s$ID$:\n\
 
 const std::string smoke_variables_low = "\n\
 mantaMsg('Smoke variables low')\n\
+preconditioner_s$ID$  = PcMGStatic\n\
 using_colors_s$ID$    = $USING_COLORS$\n\
 using_heat_s$ID$      = $USING_HEAT$\n\
 using_fire_s$ID$      = $USING_FIRE$\n\
@@ -204,7 +205,15 @@ def smoke_pre_step_low_$ID$():\n\
     copyRealToVec3(sourceX=x_vel_s$ID$, sourceY=y_vel_s$ID$, sourceZ=z_vel_s$ID$, target=vel_s$ID$)\n\
     copyRealToVec3(sourceX=x_obvel_s$ID$, sourceY=y_obvel_s$ID$, sourceZ=z_obvel_s$ID$, target=obvelC_s$ID$)\n\
     copyRealToVec3(sourceX=x_invel_s$ID$, sourceY=y_invel_s$ID$, sourceZ=z_invel_s$ID$, target=invel_s$ID$)\n\
-    copyRealToVec3(sourceX=x_force_s$ID$, sourceY=y_force_s$ID$, sourceZ=z_force_s$ID$, target=forces_s$ID$)\n";
+    copyRealToVec3(sourceX=x_force_s$ID$, sourceY=y_force_s$ID$, sourceZ=z_force_s$ID$, target=forces_s$ID$)\n\
+    \n\
+    # If obstacle has velocity, i.e. is moving switch to dynamic preconditioner\n\
+    if obvelC_s$ID$.getMaxValue() > 0:\n\
+        mantaMsg('Using dynamic preconditioner')\n\
+        preconditioner_s$ID$ = PcMGDynamic\n\
+    else:\n\
+        mantaMsg('Using static preconditioner')\n\
+        preconditioner_s$ID$ = PcMGStatic\n";
 
 const std::string smoke_pre_step_high = "\n\
 def smoke_pre_step_high_$ID$():\n\
@@ -343,10 +352,10 @@ def step_low_$ID$():\n\
         mantaMsg('Guiding and pressure')\n\
         weightGuide_s$ID$.multConst(0)\n\
         weightGuide_s$ID$.addConst(alpha_s$ID$)\n\
-        PD_fluid_guiding(vel=vel_s$ID$, velT=guidevel_s$ID$, flags=flags_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_s$ID$, pressure=pressure_s$ID$, tau=tau_s$ID$, sigma=sigma_s$ID$, theta=theta_s$ID$, preconditioner=$PRECONDITIONER$, zeroPressureFixing=not doOpen_s$ID$)\n\
+        PD_fluid_guiding(vel=vel_s$ID$, velT=guidevel_s$ID$, flags=flags_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_s$ID$, pressure=pressure_s$ID$, tau=tau_s$ID$, sigma=sigma_s$ID$, theta=theta_s$ID$, preconditioner=preconditioner_s$ID$, zeroPressureFixing=not doOpen_s$ID$)\n\
     else:\n\
         mantaMsg('Pressure')\n\
-        solvePressure(flags=flags_s$ID$, vel=vel_s$ID$, pressure=pressure_s$ID$, preconditioner=$PRECONDITIONER$, zeroPressureFixing=not doOpen_s$ID$) # closed domains require pressure fixing\n\
+        solvePressure(flags=flags_s$ID$, vel=vel_s$ID$, pressure=pressure_s$ID$, preconditioner=preconditioner_s$ID$, zeroPressureFixing=not doOpen_s$ID$) # closed domains require pressure fixing\n\
 \n\
 def process_burn_low_$ID$():\n\
     mantaMsg('Process burn low')\n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 8adafe04eff..5a9df8e9e49 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -404,7 +404,7 @@ class PHYSICS_PT_smoke_guiding(PhysicButtonsPanel, Panel):
 
         col = split.column()
         col.enabled = not domain.point_cache.is_baked
-        col.prop(domain, "guiding_alpha", text="Strength")
+        col.prop(domain, "guiding_alpha", text="Weight")
 
         col = split.column()
         col.enabled = not domain.point_cache.is_baked
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index f6a6474042e..a29d69d27db 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -530,7 +530,6 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			smd->domain->viewport_display_mode = SM_VIEWPORT_PREVIEW;
 			smd->domain->render_display_mode = SM_VIEWPORT_FINAL;
 			smd->domain->type = MOD_SMOKE_DOMAIN_TYPE_GAS;
-			smd->domain->preconditioner = MOD_SMOKE_PC_MG_STATIC;
 			
 #ifdef WITH_MANTA
 			smd->domain->gravity[0] = 0.0f;
@@ -546,6 +545,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			smd->domain->particle_band_width = 3.0f;
 			smd->domain->particle_velocity_threshold = 2.0f;
 			smd->domain->particle_bubble_rise = 0.5f;
+			smd->domain->particle_float_amount = 0.5f;
+			smd->domain->particle_tracer_amount = 0.5f;
 			smd->domain->particle_type = 0;
 
 			/* guiding */
@@ -678,6 +679,8 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->particle_band_width = smd->domain->particle_band_width;
 		tsmd->domain->particle_velocity_threshold = smd->domain->particle_velocity_threshold;
 		tsmd->domain->particle_bubble_rise = smd->domain->particle_bubble_rise;
+		tsmd->domain->particle_float_amount = smd->domain->particle_float_amount;
+		tsmd->domain->particle_tracer_amount = smd->domain->particle_tracer_amount;
 
 		tsmd->domain->guiding_alpha = smd->domain->guiding_alpha;
 		tsmd->domain->guiding_beta = smd->domain->guiding_beta;
@@ -689,7 +692,6 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->viewport_display_mode = smd->domain->viewport_display_mode;
 		tsmd->domain->render_display_mode = smd->domain->render_display_mode;
 		tsmd->domain->type = smd->domain->type;
-		tsmd->domain->preconditioner = smd->domain->preconditioner;
 
 		copy_v3_v3(tsmd->domain->flame_smoke_color, smd->domain->flame_smoke_color);
 
@@ -887,9 +889,6 @@ static void obstacles_from_derivedmesh(
 				has_velocity = true;
 			}
 		}
-		
-		/* Manta CG precoditioner */
-		sds->preconditioner = (has_velocity) ? MOD_SMOKE_PC_MG_DYNAMIC : MOD_SMOKE_PC_MG_STATIC;
 
 		/*	Transform collider vertices to
 		 *   domain grid space for fast lookups */
@@ -954,22 +953,20 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds,
 		Object *collob = collobjs[collIndex];
 		SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(collob, eModifierType_Smoke);
 
-		if ((smd2->type & MOD_SMOKE_TYPE_EFFEC) && smd2->effec)
-		{
+		if ((smd2->type & MOD_SMOKE_TYPE_EFFEC) && smd2->effec) {
 			SmokeCollSettings *scs = smd2->effec;
-			if (scs && (scs->type == SM_EFFECTOR_COLLISION))
-			{
+			if (scs && (scs->type == SM_EFFECTOR_COLLISION)) {
 				active_fields |= SM_ACTIVE_OBSTACLE;
 				// TODO (sebbas): ensure obstacles function
 //				fluid_ensure_obstacle(sds->fluid, sds->smd);
 			}
-			if (scs && (scs->type == SM_EFFECTOR_GUIDE))
-			{
+			if (scs && (scs->type == SM_EFFECTOR_GUIDE)) {
 				active_fields |= SM_ACTIVE_GUIDING;
 				fluid_ensure_guiding(sds->fluid, sds->smd);
 			}
 		}
 	}
+	sds->active_fields = active_fields;
 
 	float *velx = smoke_get_ob_velocity_x(sds->fluid);
 	float *vely = smoke_get_ob_velocity_y(sds->fluid);
@@ -1025,20 +1022,16 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds,
 
 		// DG TODO: check if modifier is active?
 
-		if ((smd2->type & MOD_SMOKE_TYPE_EFFEC) && smd2->effec)
-		{
+		if ((smd2->type & MOD_SMOKE_TYPE_EFFEC) && smd2->effec) {
 			SmokeCollSettings *scs = smd2->effec;
-			if (scs && (scs->type == SM_EFFECTOR_COLLISION))
-			{
+			if (scs && (scs->type == SM_EFFECTOR_COLLISION)) {
 				obstacles_from_derivedmesh(collob, sds, scs, phiObsIn, velx, vely, velz, num_obstacles, dt);
 			}
-			if (scs && (scs->type == SM_EFFECTOR_GUIDE))
-			{
+			if (scs && (scs->type == SM_EFFECTOR_GUIDE)) {
 				obstacles_from_derivedmesh(collob, sds, scs, phiGuideIn, velxGuide, velyGuide, velzGuide, num_guides, dt);
 			}
 		}
 	}
-	sds->active_fields = active_fields;
 
 	if (collobjs)
 		MEM_freeN(collobjs);
@@ -1734,7 +1727,7 @@ static void update_mesh_distances(int index, float *mesh_distances, BVHTreeFromM
 	inside |= (BLI_bvhtree_find_nearest(treeData->tree, ray_start, &nearest, treeData->nearest_callback, treeData) != -1);
 
 	/* Levelset is negative inside mesh */
-	if (inside) mesh_distances[index] = fabs(mesh_distances[index]) * (-1.0f);
+	if (inside) mesh_distances[index] = fabsf(mesh_distances[index]) * (-1.0f);
 }
 
 static void sample_derivedmesh(
@@ -2565,18 +2558,18 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
 			if (em->total_cells && sfs->behavior != MOD_SMOKE_FLOW_BEHAVIOR_OUTFLOW) {
 				/* activate liquid field. cannot be combined with anything else */
 				if (sfs->type == MOD_SMOKE_FLOW_TYPE_LIQUID) {
-					active_fields &= SM_ACTIVE_LIQUID;
+					active_fields |= SM_ACTIVE_LIQUID;
 				}
 				/* activate heat field if flow produces any heat */
-				if (sfs->temp && sfs->type != MOD_SMOKE_FLOW_TYPE_LIQUID) {
+				if (sfs->temp && (sfs->type == MOD_SMOKE_FLOW_TYPE_SMOKE || sfs->type == MOD_SMOKE_FLOW_TYPE_FIRE || sfs->type == MOD_SMOKE_FLOW_TYPE_SMOKEFIRE)) {
 					active_fields |= SM_ACTIVE_HEAT;
 				}
 				/* activate fuel field if flow adds any fuel */
-				if (sfs->type != MOD_SMOKE_FLOW_TYPE_SMOKE && sfs->type != MOD_SMOKE_FLOW_TYPE_LIQUID && sfs->fuel_amount) {
+				if (sfs->fuel_amount && (sfs->type == MOD_SMOKE_FLOW_TYPE_FIRE || sfs->type == MOD_SMOKE_FLOW_TYPE_SMOKEFIRE)) {
 					active_fields |= SM_ACTIVE_FIRE;
 				}
 				/* activate color field if flows add smoke with varying colors */
-				if (sfs->ty

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list