diff options
-rw-r--r-- | intern/mantaflow/intern/MANTA_main.cpp | 15 | ||||
-rw-r--r-- | intern/mantaflow/intern/MANTA_main.h | 2 | ||||
-rw-r--r-- | intern/mantaflow/intern/strings/liquid_script.h | 14 |
3 files changed, 27 insertions, 4 deletions
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index 35d4629d195..e6da083f3e5 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -71,6 +71,7 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID) mUsingNoise = (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke; mUsingFractions = (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS) && mUsingLiquid; mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid; + mUsingDiffusion = (mmd->domain->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid; mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid; mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE); mUsingDrops = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && mUsingLiquid; @@ -219,6 +220,10 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID) initLiquidMesh(mmd); } + if (mUsingDiffusion) { + initCurvature(mmd); + } + if (mUsingGuiding) { mResGuiding = (mmd->domain->guide_parent) ? mmd->domain->guide_res : mmd->domain->res; initGuiding(mmd); @@ -427,6 +432,16 @@ void MANTA::initLiquidMesh(FluidModifierData *mmd) mUsingMesh = true; } +void MANTA::initCurvature(FluidModifierData *mmd) +{ + std::vector<std::string> pythonCommands; + std::string finalString = parseScript(liquid_alloc_curvature, mmd); + pythonCommands.push_back(finalString); + + runPythonString(pythonCommands); + mUsingDiffusion = true; +} + void MANTA::initObstacle(FluidModifierData *mmd) { if (!mPhiObsIn) { diff --git a/intern/mantaflow/intern/MANTA_main.h b/intern/mantaflow/intern/MANTA_main.h index 21946431f28..5c40fdf7dd8 100644 --- a/intern/mantaflow/intern/MANTA_main.h +++ b/intern/mantaflow/intern/MANTA_main.h @@ -66,6 +66,7 @@ struct MANTA { void initLiquid(FluidModifierData *mmd); void initLiquidMesh(FluidModifierData *mmd); void initObstacle(FluidModifierData *mmd); + void initCurvature(FluidModifierData *mmd); void initGuiding(FluidModifierData *mmd); void initFractions(FluidModifierData *mmd); void initInVelocity(FluidModifierData *mmd); @@ -753,6 +754,7 @@ struct MANTA { bool mUsingOutflow; bool mUsingNoise; bool mUsingMesh; + bool mUsingDiffusion; bool mUsingMVel; bool mUsingLiquid; bool mUsingSmoke; diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h index f20b218427c..9d1f1024ddb 100644 --- a/intern/mantaflow/intern/strings/liquid_script.h +++ b/intern/mantaflow/intern/strings/liquid_script.h @@ -80,11 +80,11 @@ mantaMsg('Liquid alloc')\n\ phiParts_s$ID$ = s$ID$.create(LevelsetGrid)\n\ phi_s$ID$ = s$ID$.create(LevelsetGrid)\n\ phiTmp_s$ID$ = s$ID$.create(LevelsetGrid)\n\ -curvature_s$ID$ = s$ID$.create(RealGrid)\n\ velOld_s$ID$ = s$ID$.create(MACGrid)\n\ velParts_s$ID$ = s$ID$.create(MACGrid)\n\ mapWeights_s$ID$ = s$ID$.create(MACGrid)\n\ fractions_s$ID$ = None # allocated dynamically\n\ +curvature_s$ID$ = None\n\ \n\ pp_s$ID$ = s$ID$.create(BasicParticleSystem)\n\ pVel_pp$ID$ = pp_s$ID$.create(PdataVec3)\n\ @@ -124,6 +124,11 @@ liquid_mesh_dict_s$ID$ = dict(lMesh=mesh_sm$ID$)\n\ if using_speedvectors_s$ID$:\n\ liquid_meshvel_dict_s$ID$ = dict(lVelMesh=mVel_mesh$ID$)\n"; +const std::string liquid_alloc_curvature = + "\n\ +mantaMsg('Liquid alloc curvature')\n\ +curvature_s$ID$ = s$ID$.create(RealGrid)\n"; + const std::string liquid_alloc_particles = "\n\ ppSnd_sp$ID$ = sp$ID$.create(BasicParticleSystem)\n\ @@ -284,12 +289,13 @@ def liquid_step_$ID$():\n\ alphaV = viscosity_s$ID$ * s$ID$.timestep * float(res_s$ID$*res_s$ID$)\n\ setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=None if using_fractions_s$ID$ else obvel_s$ID$, phiObs=phiObs_s$ID$, fractions=fractions_s$ID$)\n\ cgSolveDiffusion(flags_s$ID$, vel_s$ID$, alphaV)\n\ + \n\ + mantaMsg('Curvature')\n\ + getLaplacian(laplacian=curvature_s$ID$, grid=phi_s$ID$)\n\ + curvature_s$ID$.clamp(-1.0, 1.0)\n\ \n\ setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=None if using_fractions_s$ID$ else obvel_s$ID$, phiObs=phiObs_s$ID$, fractions=fractions_s$ID$)\n\ \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\ PD_fluid_guiding(vel=vel_s$ID$, velT=velT_s$ID$, flags=flags_s$ID$, phi=phi_s$ID$, curv=curvature_s$ID$, surfTens=surfaceTension_s$ID$, fractions=fractions_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_sg$ID$, pressure=pressure_s$ID$, tau=tau_sg$ID$, sigma=sigma_sg$ID$, theta=theta_sg$ID$, zeroPressureFixing=not doOpen_s$ID$)\n\ |