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);
|
|
|
|
|
|
|
|
// Needs to be outside of loop since p is changing, but psi and rho are not.
|
|
|
|
surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p);
|
|
|
|
|
2016-05-30 08:40:08 +00:00
|
|
|
// --- PISO loop
|
2016-05-26 23:33:07 +00:00
|
|
|
while (pimple.correct())
|
2014-05-26 09:13:56 +00:00
|
|
|
{
|
|
|
|
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-05-30 08:40:08 +00:00
|
|
|
volScalarField divPhid
|
|
|
|
(
|
|
|
|
"divPhid",
|
|
|
|
fvc::div(phid)
|
|
|
|
);
|
|
|
|
|
2016-05-26 23:33:07 +00:00
|
|
|
while (pimple.correctNonOrthogonal())
|
2014-05-26 09:13:56 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
);
|
|
|
|
|
2016-05-26 23:33:07 +00:00
|
|
|
pEqn.solve();
|
2014-05-26 09:13:56 +00:00
|
|
|
|
|
|
|
// Calculate the flux
|
2016-05-26 23:33:07 +00:00
|
|
|
if (pimple.finalNonOrthogonalIter())
|
2014-05-26 09:13:56 +00:00
|
|
|
{
|
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();
|
|
|
|
}
|
|
|
|
}
|