Fluid: Refactor for initial velocities
Removed invel MAC grid since it is sufficient to use the cell centered vec3 representation. When setting initial velocities these will be interpolated by the setter functions.
This commit is contained in:
parent
b17cca6966
commit
97ec16d68f
|
@ -907,7 +907,6 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd)
|
|||
mRNAMap["NAME_OBVEL_Z"] = FLUID_NAME_OBVEL_Z;
|
||||
mRNAMap["NAME_FRACTIONS"] = FLUID_NAME_FRACTIONS;
|
||||
mRNAMap["NAME_INVELC"] = FLUID_NAME_INVELC;
|
||||
mRNAMap["NAME_INVEL"] = FLUID_NAME_INVEL;
|
||||
mRNAMap["NAME_INVEL_X"] = FLUID_NAME_INVEL_X;
|
||||
mRNAMap["NAME_INVEL_Y"] = FLUID_NAME_INVEL_Y;
|
||||
mRNAMap["NAME_INVEL_Z"] = FLUID_NAME_INVEL_Z;
|
||||
|
|
|
@ -343,7 +343,6 @@ const std::string fluid_alloc_invel =
|
|||
"\n\
|
||||
mantaMsg('Allocating initial velocity data')\n\
|
||||
invelC_s$ID$ = s$ID$.create(VecGrid, name='$NAME_INVELC$')\n\
|
||||
invel_s$ID$ = s$ID$.create(MACGrid, name='$NAME_INVEL$')\n\
|
||||
x_invel_s$ID$ = s$ID$.create(RealGrid, name='$NAME_INVEL_X$')\n\
|
||||
y_invel_s$ID$ = s$ID$.create(RealGrid, name='$NAME_INVEL_Y$')\n\
|
||||
z_invel_s$ID$ = s$ID$.create(RealGrid, name='$NAME_INVEL_Z$')\n";
|
||||
|
|
|
@ -177,6 +177,13 @@ def liquid_adaptive_step_$ID$(framenr):\n\
|
|||
flags_s$ID$.initDomain(boundaryWidth=1 if using_fractions_s$ID$ else 0, phiWalls=phiObs_s$ID$, outflow=boundConditions_s$ID$)\n\
|
||||
\n\
|
||||
if using_obstacle_s$ID$:\n\
|
||||
mantaMsg('Extrapolating object velocity')\n\
|
||||
# ensure velocities inside of obs object, slightly add obvels outside of obs object\n\
|
||||
# extrapolate with phiObsIn before joining (static) phiObsSIn grid to prevent flows into static obs\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
|
||||
resampleVec3ToMac(source=obvelC_s$ID$, target=obvel_s$ID$)\n\
|
||||
\n\
|
||||
mantaMsg('Initializing obstacle levelset')\n\
|
||||
phiObsIn_s$ID$.join(phiObsSIn_s$ID$) # Join static obstacle map\n\
|
||||
phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
|
||||
|
@ -211,8 +218,8 @@ def liquid_adaptive_step_$ID$(framenr):\n\
|
|||
# add initial velocity: set invel as source grid to ensure const vels in inflow region, sampling makes use of this\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(grid=invel_s$ID$, isMAC=True)\n\
|
||||
# Using cell centered invels, a false isMAC flag ensures correct interpolation\n\
|
||||
pVel_pp$ID$.setSource(grid=invelC_s$ID$, isMAC=False)\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(grid=None, isMAC=False)\n\
|
||||
|
@ -275,13 +282,6 @@ def liquid_step_$ID$():\n\
|
|||
mantaMsg('Adding external forces')\n\
|
||||
addForceField(flags=flags_s$ID$, vel=vel_s$ID$, force=forces_s$ID$)\n\
|
||||
\n\
|
||||
if using_obstacle_s$ID$:\n\
|
||||
mantaMsg('Extrapolating object velocity')\n\
|
||||
# ensure velocities inside of obs object, slightly add obvels outside of obs object\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
|
||||
resampleVec3ToMac(source=obvelC_s$ID$, target=obvel_s$ID$)\n\
|
||||
\n\
|
||||
extrapolateMACSimple(flags=flags_s$ID$, vel=vel_s$ID$, distance=2, intoObs=True if using_fractions_s$ID$ else False)\n\
|
||||
\n\
|
||||
# vel diffusion / viscosity!\n\
|
||||
|
|
|
@ -280,6 +280,13 @@ def smoke_adaptive_step_$ID$(framenr):\n\
|
|||
flags_s$ID$.initDomain(boundaryWidth=0, phiWalls=phiObs_s$ID$, outflow=boundConditions_s$ID$)\n\
|
||||
\n\
|
||||
if using_obstacle_s$ID$:\n\
|
||||
mantaMsg('Extrapolating object velocity')\n\
|
||||
# ensure velocities inside of obs object, slightly add obvels outside of obs object\n\
|
||||
# extrapolate with phiObsIn before joining (static) phiObsSIn grid to prevent flows into static obs\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
|
||||
resampleVec3ToMac(source=obvelC_s$ID$, target=obvel_s$ID$)\n\
|
||||
\n\
|
||||
mantaMsg('Initializing obstacle levelset')\n\
|
||||
phiObsIn_s$ID$.join(phiObsSIn_s$ID$) # Join static obstacle map\n\
|
||||
phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
|
||||
|
@ -386,21 +393,14 @@ def smoke_step_$ID$():\n\
|
|||
mantaMsg('Adding forces')\n\
|
||||
addForceField(flags=flags_s$ID$, vel=vel_s$ID$, force=forces_s$ID$)\n\
|
||||
\n\
|
||||
if using_obstacle_s$ID$:\n\
|
||||
mantaMsg('Extrapolating object velocity')\n\
|
||||
# ensure velocities inside of obs object, slightly add obvels outside of obs object\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
|
||||
extrapolateVec3Simple(vel=obvelC_s$ID$, phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
|
||||
resampleVec3ToMac(source=obvelC_s$ID$, target=obvel_s$ID$)\n\
|
||||
\n\
|
||||
# Cells inside obstacle should not contain any density, fire, etc.\n\
|
||||
if deleteInObstacle_s$ID$:\n\
|
||||
resetInObstacle(flags=flags_s$ID$, density=density_s$ID$, vel=vel_s$ID$, heat=heat_s$ID$, fuel=fuel_s$ID$, flame=flame_s$ID$, red=color_r_s$ID$, green=color_g_s$ID$, blue=color_b_s$ID$)\n\
|
||||
\n\
|
||||
# add initial velocity\n\
|
||||
if using_invel_s$ID$:\n\
|
||||
resampleVec3ToMac(source=invelC_s$ID$, target=invel_s$ID$)\n\
|
||||
setInitialVelocity(flags=flags_s$ID$, vel=vel_s$ID$, invel=invel_s$ID$)\n\
|
||||
# Using cell centered invels, will be converted to MAC within the function\n\
|
||||
setInitialVelocity(flags=flags_s$ID$, vel=vel_s$ID$, invel=invelC_s$ID$)\n\
|
||||
\n\
|
||||
mantaMsg('Walls')\n\
|
||||
setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=obvel_s$ID$ if using_obstacle_s$ID$ else None)\n\
|
||||
|
|
|
@ -311,7 +311,6 @@ enum {
|
|||
#define FLUID_NAME_OBVEL_Z "z_obvel"
|
||||
#define FLUID_NAME_FRACTIONS "fractions"
|
||||
#define FLUID_NAME_INVELC "invelC"
|
||||
#define FLUID_NAME_INVEL "invel"
|
||||
#define FLUID_NAME_INVEL_X "x_invel"
|
||||
#define FLUID_NAME_INVEL_Y "y_invel"
|
||||
#define FLUID_NAME_INVEL_Z "z_invel"
|
||||
|
|
Loading…
Reference in New Issue