2014-05-26 09:13:56 +00:00
|
|
|
{
|
|
|
|
volScalarField rUA = 1.0/UEqn.A();
|
|
|
|
|
2015-11-11 13:17:46 +00:00
|
|
|
surfaceScalarField psisf = fvc::interpolate(psis);
|
|
|
|
surfaceScalarField rhof = fvc::interpolate(rho);
|
|
|
|
|
2016-02-05 17:48:36 +00:00
|
|
|
// Needs to be outside of loop since p is changing, but psi and rho are not
|
2015-11-11 13:17:46 +00:00
|
|
|
surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p);
|
|
|
|
|
2016-02-05 17:48:36 +00:00
|
|
|
// --- PISO loop
|
2014-05-26 09:13:56 +00:00
|
|
|
for (int corr = 0; corr < nCorr; corr++)
|
|
|
|
{
|
|
|
|
U = rUA*UEqn.H();
|
|
|
|
|
2015-11-11 15:14:33 +00:00
|
|
|
// Calculate phi for boundary conditions
|
|
|
|
phi = rhof*fvc::interpolate(U) & mesh.Sf();
|
2014-05-26 09:13:56 +00:00
|
|
|
|
2015-11-11 15:14:33 +00:00
|
|
|
surfaceScalarField phid2 = rhoReff/rhof*phi;
|
|
|
|
|
|
|
|
surfaceScalarField phid("phid", psisf/rhof*phi);
|
2014-05-26 09:13:56 +00:00
|
|
|
|
2015-11-11 13:17:46 +00:00
|
|
|
// Make fluxes relative within the MRF zone
|
|
|
|
mrfZones.relativeFlux(rhoReff, phi);
|
2015-11-11 15:14:33 +00:00
|
|
|
mrfZones.relativeFlux(psisf, phid);
|
|
|
|
mrfZones.relativeFlux(rhoReff, phid2);
|
2014-05-26 09:13:56 +00:00
|
|
|
|
|
|
|
p.storePrevIter();
|
|
|
|
|
2016-01-14 13:44:23 +00:00
|
|
|
volScalarField divPhid
|
|
|
|
(
|
|
|
|
"divPhid",
|
|
|
|
fvc::div(phid)
|
|
|
|
);
|
|
|
|
|
2014-05-26 09:13:56 +00:00
|
|
|
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
|
|
|
|
{
|
|
|
|
fvScalarMatrix pEqn
|
|
|
|
(
|
2015-11-11 13:17:46 +00:00
|
|
|
fvm::ddt(psis, p)
|
2014-05-26 09:13:56 +00:00
|
|
|
+ fvm::div(phid, p)
|
2016-01-14 13:44:23 +00:00
|
|
|
// Convective flux relaxation terms
|
|
|
|
+ fvm::SuSp(-divPhid, p)
|
|
|
|
+ divPhid*p
|
2015-11-11 15:14:33 +00:00
|
|
|
+ fvc::div(phid2)
|
2014-05-26 09:13:56 +00:00
|
|
|
- fvm::laplacian(rho*rUA, p)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Retain the residual from the first pressure solution
|
|
|
|
eqnResidual = pEqn.solve().initialResidual();
|
|
|
|
|
|
|
|
if (corr == 0 && nonOrth == 0)
|
|
|
|
{
|
|
|
|
maxResidual = max(eqnResidual, maxResidual);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the flux
|
|
|
|
if (nonOrth == nNonOrthCorr)
|
|
|
|
{
|
2015-11-11 15:14:33 +00:00
|
|
|
phi = phid2 + pEqn.flux();
|
2014-05-26 09:13:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# include "compressibleContinuityErrs.H"
|
|
|
|
|
2015-11-11 15:14:33 +00:00
|
|
|
// Relax the pressure
|
2014-05-26 09:13:56 +00:00
|
|
|
p.relax();
|
|
|
|
|
|
|
|
U -= rUA*fvc::grad(p);
|
|
|
|
U.correctBoundaryConditions();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bound the pressure
|
|
|
|
if (min(p) < pMin || max(p) > pMax)
|
|
|
|
{
|
|
|
|
p.max(pMin);
|
|
|
|
p.min(pMax);
|
|
|
|
p.correctBoundaryConditions();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bound the velocity
|
|
|
|
volScalarField magU = mag(U);
|
|
|
|
|
|
|
|
if (max(magU) > UMax)
|
|
|
|
{
|
|
|
|
volScalarField Ulimiter = pos(magU - UMax)*UMax/(magU + smallU)
|
|
|
|
+ neg(magU - UMax);
|
|
|
|
Ulimiter.max(scalar(0));
|
|
|
|
Ulimiter.min(scalar(1));
|
|
|
|
|
|
|
|
U *= Ulimiter;
|
|
|
|
U.correctBoundaryConditions();
|
|
|
|
}
|
|
|
|
}
|