pEqn.H 1.48 KB
Newer Older
1
volScalarField rAU(1.0/UEqn().A());
Henry's avatar
Henry committed
2
volVectorField HbyA("HbyA", U);
3
HbyA = rAU*UEqn().H();
henry's avatar
henry committed
4

Henry's avatar
Henry committed
5
6
7
8
surfaceScalarField phiHbyA
(
    "phiHbyA",
    (fvc::interpolate(HbyA) & mesh.Sf())
9
  + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
Henry's avatar
Henry committed
10
);
henry's avatar
henry committed
11

Henry's avatar
Henry committed
12
MRF.makeRelative(phiHbyA);
13

14
15
adjustPhi(phiHbyA, U, p);

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
tmp<volScalarField> rAtU(rAU);

if (pimple.consistent())
{
    rAtU = 1.0/max(1.0/rAU - UEqn().H1(), 0.1/rAU);
    phiHbyA +=
        fvc::interpolate(rAtU() - rAU)*fvc::snGrad(p)*mesh.magSf();
    HbyA -= (rAU - rAtU())*fvc::grad(p);
}

if (pimple.nCorrPISO() <= 1)
{
    UEqn.clear();
}

surfaceScalarField rAUf("rAUf", fvc::interpolate(rAtU()));

33
34
35
36
37
38
// Update the fixedFluxPressure BCs to ensure flux consistency
setSnGrad<fixedFluxPressureFvPatchScalarField>
(
    p.boundaryField(),
    (
        phiHbyA.boundaryField()
Henry's avatar
Henry committed
39
      - MRF.relative(mesh.Sf().boundaryField() & U.boundaryField())
40
41
42
    )/(mesh.magSf().boundaryField()*rAUf.boundaryField())
);

henry's avatar
henry committed
43
// Non-orthogonal pressure corrector loop
44
while (pimple.correctNonOrthogonal())
henry's avatar
henry committed
45
46
47
48
{
    // Pressure corrector
    fvScalarMatrix pEqn
    (
49
        fvm::laplacian(rAUf, p) == fvc::div(phiHbyA)
henry's avatar
henry committed
50
51
52
53
    );

    pEqn.setReference(pRefCell, pRefValue);

54
    pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));
henry's avatar
henry committed
55

56
    if (pimple.finalNonOrthogonalIter())
henry's avatar
henry committed
57
    {
Henry's avatar
Henry committed
58
        phi = phiHbyA - pEqn.flux();
henry's avatar
henry committed
59
60
61
62
63
    }
}

#include "continuityErrs.H"

64
65
// Explicitly relax pressure for momentum corrector
p.relax();
henry's avatar
henry committed
66

67
U = HbyA - rAtU()*fvc::grad(p);
henry's avatar
henry committed
68
U.correctBoundaryConditions();
69
fvOptions.correct(U);