OLD: pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); pEqn.solve(mesh.solver("Yi")); NEW: pEqn.solve(p.select(piso.finalInnerIter())); pEqn.solve("Yi");
146 lines
4.0 KiB
C
146 lines
4.0 KiB
C
{
|
|
volScalarField rAU("rAU", 1.0/UEqn.A());
|
|
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
|
|
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
|
|
surfaceScalarField phiHbyA
|
|
(
|
|
"phiHbyA",
|
|
fvc::flux(HbyA)
|
|
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf))
|
|
);
|
|
MRF.makeRelative(phiHbyA);
|
|
|
|
surfaceScalarField phig
|
|
(
|
|
(
|
|
mixture.surfaceTensionForce()
|
|
- ghf*fvc::snGrad(rho)
|
|
)*rAUf*mesh.magSf()
|
|
);
|
|
|
|
phiHbyA += phig;
|
|
|
|
// Update the pressure BCs to ensure flux consistency
|
|
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
|
|
|
|
// Make the fluxes relative to the mesh motion
|
|
fvc::makeRelative(phiHbyA, U);
|
|
|
|
tmp<fvScalarMatrix> p_rghEqnComp1;
|
|
tmp<fvScalarMatrix> p_rghEqnComp2;
|
|
|
|
if (pimple.transonic())
|
|
{
|
|
#include "rhofs.H"
|
|
|
|
surfaceScalarField phid1("phid1", fvc::interpolate(psi1)*phi);
|
|
surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi);
|
|
|
|
p_rghEqnComp1 =
|
|
pos(alpha1)
|
|
*(
|
|
(
|
|
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
|
|
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
|
|
)/rho1
|
|
- fvc::ddt(alpha1) - fvc::div(alphaPhi1)
|
|
+ (alpha1/rho1)
|
|
*correction
|
|
(
|
|
psi1*fvm::ddt(p_rgh)
|
|
+ fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
|
|
)
|
|
);
|
|
p_rghEqnComp1.ref().relax();
|
|
|
|
p_rghEqnComp2 =
|
|
pos(alpha2)
|
|
*(
|
|
(
|
|
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
|
|
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
|
|
)/rho2
|
|
- fvc::ddt(alpha2) - fvc::div(alphaPhi2)
|
|
+ (alpha2/rho2)
|
|
*correction
|
|
(
|
|
psi2*fvm::ddt(p_rgh)
|
|
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
|
|
)
|
|
);
|
|
p_rghEqnComp2.ref().relax();
|
|
}
|
|
else
|
|
{
|
|
p_rghEqnComp1 =
|
|
fvc::ddt(rho1) + psi1*correction(fvm::ddt(p_rgh))
|
|
+ fvc::div(phi, rho1) - fvc::Sp(fvc::div(phi), rho1);
|
|
|
|
p_rghEqnComp2 =
|
|
fvc::ddt(rho2) + psi2*correction(fvm::ddt(p_rgh))
|
|
+ fvc::div(phi, rho2) - fvc::Sp(fvc::div(phi), rho2);
|
|
}
|
|
|
|
// Cache p_rgh prior to solve for density update
|
|
volScalarField p_rgh_0(p_rgh);
|
|
|
|
while (pimple.correctNonOrthogonal())
|
|
{
|
|
fvScalarMatrix p_rghEqnIncomp
|
|
(
|
|
fvc::div(phiHbyA)
|
|
- fvm::laplacian(rAUf, p_rgh)
|
|
);
|
|
|
|
solve
|
|
(
|
|
(
|
|
(max(alpha1, scalar(0))/rho1)*p_rghEqnComp1()
|
|
+ (max(alpha2, scalar(0))/rho2)*p_rghEqnComp2()
|
|
)
|
|
+ p_rghEqnIncomp,
|
|
p_rgh.select(pimple.finalInnerIter())
|
|
);
|
|
|
|
if (pimple.finalNonOrthogonalIter())
|
|
{
|
|
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
|
|
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh;
|
|
|
|
dgdt =
|
|
(
|
|
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
|
|
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
|
|
);
|
|
|
|
phi = phiHbyA + p_rghEqnIncomp.flux();
|
|
|
|
U = HbyA
|
|
+ rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf);
|
|
U.correctBoundaryConditions();
|
|
fvOptions.correct(U);
|
|
}
|
|
}
|
|
|
|
{
|
|
Uf = fvc::interpolate(U);
|
|
surfaceVectorField n(mesh.Sf()/mesh.magSf());
|
|
Uf += n*(fvc::absolute(phi, U)/mesh.magSf() - (n & Uf));
|
|
}
|
|
|
|
// Update densities from change in p_rgh
|
|
mixture.thermo1().correctRho(psi1*(p_rgh - p_rgh_0));
|
|
mixture.thermo2().correctRho(psi2*(p_rgh - p_rgh_0));
|
|
|
|
rho = alpha1*rho1 + alpha2*rho2;
|
|
|
|
// Correct p_rgh for consistency with p and the updated densities
|
|
p = max(p_rgh + rho*gh, pMin);
|
|
p_rgh = p - rho*gh;
|
|
p_rgh.correctBoundaryConditions();
|
|
|
|
|
|
|
|
K = 0.5*magSqr(U);
|
|
}
|