diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2020-10-30 02:09:03 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2020-10-30 11:52:05 +0300 |
commit | 8bdf191461a6a09c71258e69246d13fa3034e357 (patch) | |
tree | fb760a106c1d371914f69a3866f8d0da3be7c682 /intern/mantaflow | |
parent | e3e5d595f61251372eea1f6ffa262734d68f3181 (diff) |
Fluid: Added APIC simulation method
Basic support for velocity updates with the APIC method.
This commit adds APIC to the already existing dropdown menu for the simulation method. The APIC plugin within Mantaflow has been updated to the latest version.
Diffstat (limited to 'intern/mantaflow')
-rw-r--r-- | intern/mantaflow/intern/MANTA_main.cpp | 8 | ||||
-rw-r--r-- | intern/mantaflow/intern/strings/liquid_script.h | 25 |
2 files changed, 22 insertions, 11 deletions
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index e15fe809b2d..729cb151a39 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -697,12 +697,6 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd) if ((fds->border_collisions & FLUID_DOMAIN_BORDER_TOP) == 0) borderCollisions += "Z"; - string simulationMethod = ""; - if (fds->simulation_method & FLUID_DOMAIN_METHOD_FLIP) - simulationMethod += "'FLIP'"; - else if (fds->simulation_method & FLUID_DOMAIN_METHOD_APIC) - simulationMethod += "'APIC'"; - string particleTypesStr = ""; if (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) particleTypesStr += "PtypeSpray"; @@ -837,7 +831,7 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd) mRNAMap["CACHE_MESH_FORMAT"] = getCacheFileEnding(fds->cache_mesh_format); mRNAMap["CACHE_NOISE_FORMAT"] = getCacheFileEnding(fds->cache_noise_format); mRNAMap["CACHE_PARTICLE_FORMAT"] = getCacheFileEnding(fds->cache_particle_format); - mRNAMap["SIMULATION_METHOD"] = simulationMethod; + mRNAMap["USING_APIC"] = getBooleanString(fds->simulation_method == FLUID_DOMAIN_METHOD_APIC); mRNAMap["FLIP_RATIO"] = to_string(fds->flip_ratio); mRNAMap["PARTICLE_RANDOMNESS"] = to_string(fds->particle_randomness); mRNAMap["PARTICLE_NUMBER"] = to_string(fds->particle_number); diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h index 7622fc5a602..8e0d113d680 100644 --- a/intern/mantaflow/intern/strings/liquid_script.h +++ b/intern/mantaflow/intern/strings/liquid_script.h @@ -50,7 +50,8 @@ smoothenPos_s$ID$ = $MESH_SMOOTHEN_POS$\n\ smoothenNeg_s$ID$ = $MESH_SMOOTHEN_NEG$\n\ randomness_s$ID$ = $PARTICLE_RANDOMNESS$\n\ surfaceTension_s$ID$ = $LIQUID_SURFACE_TENSION$\n\ -maxSysParticles_s$ID$ = $PP_PARTICLE_MAXIMUM$\n"; +maxSysParticles_s$ID$ = $PP_PARTICLE_MAXIMUM$\n\ +using_apic_s$ID$ = $USING_APIC$\n"; const std::string liquid_variables_particles = "\n\ @@ -91,6 +92,14 @@ curvature_s$ID$ = None\n\ pp_s$ID$ = s$ID$.create(BasicParticleSystem, name='$NAME_PARTS$')\n\ pVel_pp$ID$ = pp_s$ID$.create(PdataVec3, name='$NAME_PARTSVELOCITY$')\n\ \n\ +pCx_pp$ID$ = None\n\ +pCy_pp$ID$ = None\n\ +pCz_pp$ID$ = None\n\ +if using_apic_s$ID$:\n\ + pCx_pp$ID$ = pp_s$ID$.create(PdataVec3)\n\ + pCy_pp$ID$ = pp_s$ID$.create(PdataVec3)\n\ + pCz_pp$ID$ = pp_s$ID$.create(PdataVec3)\n\ +\n\ # Acceleration data for particle nbs\n\ pindex_s$ID$ = s$ID$.create(ParticleIndexSystem, name='$NAME_PINDEX$')\n\ gpi_s$ID$ = s$ID$.create(IntGrid, name='$NAME_GPI$')\n\ @@ -275,8 +284,12 @@ def liquid_step_$ID$():\n\ resetOutflow(flags=flags_s$ID$, phi=phi_s$ID$, parts=pp_s$ID$, index=gpi_s$ID$, indexSys=pindex_s$ID$)\n\ flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\ \n\ - # combine particles velocities with advected grid velocities\n\ - mapPartsToMAC(vel=velParts_s$ID$, flags=flags_s$ID$, velOld=velOld_s$ID$, parts=pp_s$ID$, partVel=pVel_pp$ID$, weight=mapWeights_s$ID$)\n\ + # combine particle velocities with advected grid velocities\n\ + if using_apic_s$ID$:\n\ + apicMapPartsToMAC(flags=flags_s$ID$, vel=vel_s$ID$, parts=pp_s$ID$, partVel=pVel_pp$ID$, cpx=pCx_pp$ID$, cpy=pCy_pp$ID$, cpz=pCz_pp$ID$)\n\ + else:\n\ + mapPartsToMAC(vel=velParts_s$ID$, flags=flags_s$ID$, velOld=velOld_s$ID$, parts=pp_s$ID$, partVel=pVel_pp$ID$, weight=mapWeights_s$ID$)\n\ + \n\ extrapolateMACFromWeight(vel=velParts_s$ID$, distance=2, weight=mapWeights_s$ID$)\n\ combineGridVel(vel=velParts_s$ID$, weight=mapWeights_s$ID$, combineVel=vel_s$ID$, phi=phi_s$ID$, narrowBand=combineBandWidth_s$ID$, thresh=0)\n\ velOld_s$ID$.copyFrom(vel_s$ID$)\n\ @@ -319,7 +332,11 @@ def liquid_step_$ID$():\n\ # set source grids for resampling, used in adjustNumber!\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"; + \n\ + if using_apic_s$ID$:\n\ + apicMapMACGridToParts(partVel=pVel_pp$ID$, cpx=pCx_pp$ID$, cpy=pCy_pp$ID$, cpz=pCz_pp$ID$, parts=pp_s$ID$, vel=vel_s$ID$, flags=flags_s$ID$)\n\ + else:\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"; const std::string liquid_step_mesh = "\n\ |