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/steadyCompressibleFoam/pEqn.H
Hrvoje Jasak 9daa8e28f4 Updated enthalpy equation
Conflicts:
	applications/solvers/compressible/steadyCompressibleFoam/pEqn.H
2016-01-05 14:51:40 +00:00

88 lines
2.2 KiB
C

{
volScalarField rUA = 1.0/UEqn.A();
<<<<<<< HEAD
=======
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);
>>>>>>> 07efd81... Updated enthalpy equation
for (int corr = 0; corr < nCorr; corr++)
{
U = rUA*UEqn.H();
// Execute ddtPhiCorr before recalculating flux
// HJ, 27/Apr/2010
surfaceScalarField phid
(
"phid",
fvc::interpolate(psi)*
(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
)
);
// Calculate phi for boundary conditions
phi = fvc::interpolate(rho*U) & mesh.Sf();
p.storePrevIter();
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::ddt(psi, p)
+ fvm::div(phid, p)
- 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)
{
phi = pEqn.flux();
}
}
# include "compressibleContinuityErrs.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();
}
}