[Bf-blender-cvs] [31ad8bda74e] master: Fix T77204: Mantaflow Initial velocity bugged?

Sebastián Barschkis noreply at git.blender.org
Thu Jun 25 18:03:15 CEST 2020


Commit: 31ad8bda74ec8228db03b5969145c499b0f5a6f3
Author: Sebastián Barschkis
Date:   Thu Jun 25 18:02:58 2020 +0200
Branches: master
https://developer.blender.org/rB31ad8bda74ec8228db03b5969145c499b0f5a6f3

Fix T77204: Mantaflow Initial velocity bugged?

Always initialize the particle velocity of newly sampled particles to 0 if there are no initial velocities. Clearing the grid source makes sure that new particles will get a 0 velocity - and not interpolated from the associated grid.

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

M	intern/mantaflow/intern/strings/liquid_script.h

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

diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index d7ba220d2c3..04505206601 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -211,10 +211,10 @@ def liquid_adaptive_step_$ID$(framenr):\n\
     if using_invel_s$ID$:\n\
         extrapolateVec3Simple(vel=invelC_s$ID$, phi=phiIn_s$ID$, distance=6, inside=True)\n\
         resampleVec3ToMac(source=invelC_s$ID$, target=invel_s$ID$)\n\
-        pVel_pp$ID$.setSource(invel_s$ID$, isMAC=True)\n\
-    # ensure that pvel has vel as source (important when resuming bake jobs)\n\
+        pVel_pp$ID$.setSource(grid=invel_s$ID$, isMAC=True)\n\
+    # reset pvel grid source before sampling new particles - ensures that new particles are initialized with 0 velocity\n\
     else:\n\
-        pVel_pp$ID$.setSource(vel_s$ID$, isMAC=True)\n\
+        pVel_pp$ID$.setSource(grid=None, isMAC=False)\n\
     \n\
     sampleLevelsetWithParticles(phi=phiIn_s$ID$, flags=flags_s$ID$, parts=pp_s$ID$, discretization=particleNumber_s$ID$, randomness=randomness_s$ID$)\n\
     flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\
@@ -310,7 +310,7 @@ def liquid_step_$ID$():\n\
         extrapolateMACSimple(flags=flags_s$ID$, vel=vel_s$ID$)\n\
     \n\
     # set source grids for resampling, used in adjustNumber!\n\
-    pVel_pp$ID$.setSource(vel_s$ID$, isMAC=True)\n\
+    pVel_pp$ID$.setSource(grid=vel_s$ID$, isMAC=True)\n\
     adjustNumber(parts=pp_s$ID$, vel=vel_s$ID$, flags=flags_s$ID$, minParticles=minParticles_s$ID$, maxParticles=maxParticles_s$ID$, phi=phi_s$ID$, exclude=phiObs_s$ID$, radiusFactor=radiusFactor_s$ID$, narrowBand=adjustedNarrowBandWidth_s$ID$)\n\
     flipVelocityUpdate(vel=vel_s$ID$, velOld=velOld_s$ID$, flags=flags_s$ID$, parts=pp_s$ID$, partVel=pVel_pp$ID$, flipRatio=flipRatio_s$ID$)\n";
 
@@ -347,7 +347,7 @@ def liquid_step_mesh_$ID$():\n\
     # Vert vel vector needs to pull data from vel grid with correct dim\n\
     if using_speedvectors_s$ID$:\n\
         interpolateMACGrid(target=vel_sm$ID$, source=vel_s$ID$)\n\
-        mVel_mesh$ID$.setSource(vel_sm$ID$, isMAC=True)\n\
+        mVel_mesh$ID$.setSource(grid=vel_sm$ID$, isMAC=True)\n\
     \n\
     # Set 0.5 boundary at walls + account for extra wall thickness in fractions mode + account for grid scaling:\n\
     # E.g. at upres=1 we expect 1 cell border (or 2 with fractions), at upres=2 we expect 2 cell border (or 4 with fractions), etc.\n\



More information about the Bf-blender-cvs mailing list