2014-05-26 09:13:56 +00:00
|
|
|
{
|
|
|
|
volScalarField rUrelA = 1.0/UrelEqn.A();
|
|
|
|
|
2015-11-11 15:14:33 +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-26 23:33:07 +00:00
|
|
|
while (pimple.correct())
|
2014-05-26 09:13:56 +00:00
|
|
|
{
|
|
|
|
Urel = rUrelA*UrelEqn.H();
|
|
|
|
|
|
|
|
// Calculate phi for boundary conditions
|
2015-11-11 15:14:33 +00:00
|
|
|
phi = rhof*fvc::interpolate(Urel) & mesh.Sf();
|
|
|
|
|
|
|
|
surfaceScalarField phid2 = rhoReff/rhof*phi;
|
|
|
|
|
|
|
|
surfaceScalarField phid("phid", psisf/rhof*phi);
|
2014-05-26 09:13:56 +00:00
|
|
|
|
|
|
|
p.storePrevIter();
|
|
|
|
|
2016-05-26 23:33:07 +00:00
|
|
|
while (pimple.correctNonOrthogonal())
|
2014-05-26 09:13:56 +00:00
|
|
|
{
|
|
|
|
fvScalarMatrix pEqn
|
|
|
|
(
|
2017-03-30 09:36:09 +00:00
|
|
|
fvm::div(phid, p)
|
|
|
|
+ fvc::div(phid2)
|
2017-04-04 09:36:16 +00:00
|
|
|
- fvm::laplacian(rho*rUrelA, p)
|
2014-05-26 09:13:56 +00:00
|
|
|
);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-04 09:36:16 +00:00
|
|
|
// Use incompressible continuity error check: div(rho U) = 0
|
|
|
|
# include "continuityErrs.H"
|
2014-05-26 09:13:56 +00:00
|
|
|
|
2015-11-11 15:14:33 +00:00
|
|
|
// Relax the pressure
|
2014-05-26 09:13:56 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|