This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/applications/solvers/compressible/steadyCompressibleMRFFoam/pEqn.H

82 lines
2 KiB
C
Raw Normal View History

{
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
while (pimple.correct())
{
U = rUA*UEqn.H();
2017-01-11 11:57:48 +00:00
// Update boundary velocity for consistency with the flux
mrfZones.correctBoundaryVelocity(U);
// Calculate phi for boundary conditions
phi = rhof*(fvc::interpolate(U) & mesh.Sf());
surfaceScalarField phid2 = rhoReff/rhof*phi;
surfaceScalarField phid("phid", psisf/rhof*phi);
2015-11-11 13:17:46 +00:00
// Make fluxes relative within the MRF zone
mrfZones.relativeFlux(rhoReff, phi);
mrfZones.relativeFlux(psisf, phid);
mrfZones.relativeFlux(rhoReff, phid2);
p.storePrevIter();
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn
(
fvm::div(phid, p)
+ fvc::div(phid2)
- fvm::laplacian(rho*rUA, p)
);
pEqn.solve();
// Calculate the flux
if (pimple.finalNonOrthogonalIter())
{
phi = phid2 + pEqn.flux();
}
}
// Use incompressible continuity error check: div(rho U) = 0
# include "continuityErrs.H"
// Relax the pressure
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();
}
}