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/steadyCompressibleSRFFoam/pEqn.H

82 lines
2 KiB
C
Raw Normal View History

{
volScalarField rUrelA = 1.0/UrelEqn.A();
for (int corr = 0; corr < nCorr; corr++)
{
Urel = rUrelA*UrelEqn.H();
// Execute ddtPhiCorr before recalculating flux
// HJ, 27/Apr/2010
surfaceScalarField phid
(
"phid",
fvc::interpolate(thermo.psi())*
(
(fvc::interpolate(Urel) & mesh.Sf())
+ fvc::ddtPhiCorr(rUrelA, rho, Urel, phi)
)
);
// Calculate phi for boundary conditions
phi = fvc::interpolate(rho*Urel) & mesh.Sf();
p.storePrevIter();
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::ddt(psi, p)
+ fvm::div(phid, p)
- fvm::laplacian(rho*rUrelA, 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)
{
phi = pEqn.flux();
}
}
# include "compressibleContinuityErrs.H"
// Explicitly relax the pressure for momentum corrector
p.relax();
Urel -= rUrelA*fvc::grad(p);
Urel.correctBoundaryConditions();
}
// Bound the pressure
if (min(p) < pMin || max(p) > pMax)
{
p.max(pMin);
p.min(pMax);
p.correctBoundaryConditions();
}
// Bound the velocity
volScalarField magUrel = mag(Urel);
if (max(magUrel) > UrelMax)
{
volScalarField Urellimiter =
pos(magUrel - UrelMax)*UrelMax/(magUrel + smallUrel)
+ neg(magUrel - UrelMax);
Urellimiter.max(scalar(0));
Urellimiter.min(scalar(1));
Urel *= Urellimiter;
Urel.correctBoundaryConditions();
}
}