Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / solvers / compressible / rhoSimpleFoam / pEqn.H
blob54af64c003e36af6fceb68487c0cbcc287a428f2
1 rho = thermo.rho();
2 rho = max(rho, rhoMin);
3 rho = min(rho, rhoMax);
4 rho.relax();
6 volScalarField rAU(1.0/UEqn().A());
7 U = rAU*UEqn().H();
8 UEqn.clear();
10 bool closedVolume = false;
12 if (simple.transonic())
14     surfaceScalarField phid
15     (
16         "phid",
17         fvc::interpolate(psi)*(fvc::interpolate(U) & mesh.Sf())
18     );
20     for (int nonOrth=0; nonOrth<=simple.nNonOrthCorr(); nonOrth++)
21     {
22         fvScalarMatrix pEqn
23         (
24             fvm::div(phid, p)
25           - fvm::laplacian(rho*rAU, p)
26         );
28         // Relax the pressure equation to ensure diagonal-dominance
29         pEqn.relax(mesh.relaxationFactor("pEqn"));
31         pEqn.setReference(pRefCell, pRefValue);
33         pEqn.solve();
35         if (nonOrth == simple.nNonOrthCorr())
36         {
37             phi == pEqn.flux();
38         }
39     }
41 else
43     phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
44     closedVolume = adjustPhi(phi, U, p);
46     for (int nonOrth=0; nonOrth<=simple.nNonOrthCorr(); nonOrth++)
47     {
48         fvScalarMatrix pEqn
49         (
50             fvm::laplacian(rho*rAU, p) == fvc::div(phi)
51         );
53         pEqn.setReference(pRefCell, pRefValue);
55         pEqn.solve();
57         if (nonOrth == simple.nNonOrthCorr())
58         {
59             phi -= pEqn.flux();
60         }
61     }
65 #include "incompressible/continuityErrs.H"
67 // Explicitly relax pressure for momentum corrector
68 p.relax();
70 U -= rAU*fvc::grad(p);
71 U.correctBoundaryConditions();
73 // For closed-volume cases adjust the pressure and density levels
74 // to obey overall mass continuity
75 if (closedVolume)
77     p += (initialMass - fvc::domainIntegrate(psi*p))
78         /fvc::domainIntegrate(psi);
81 rho = thermo.rho();
82 rho = max(rho, rhoMin);
83 rho = min(rho, rhoMax);
84 rho.relax();
85 Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;