Initial commit of NavalHydro package from Wikki to the ShipHydroSIG
[ShipHydroSIG.git] / src / navalFoamVariant2 / pdEqn.H
blob0fee7443cf4ef619667406d85d0b2ad8c3f56bd2
2     if (nOuterCorr != 1)
3     {
4         pd.storePrevIter();
5     }
7     rAU = 1.0/UEqn.A();
8     surfaceScalarField rAUf = fvc::interpolate(rAU/rho);
10     U = rAU*UEqn.H();
11     U.correctBoundaryConditions();
13     surfaceScalarField phiU
14     (
15         "phiU",
16         (fvc::interpolate(U) & mesh.Sf())
17         // Restart accuracy lost with ddtCorr.  Removed, HJ, 16/Nov/2010
18 //       + fvc::ddtPhiCorr(rAU, U, phi)
19     );
21     phi = phiU +
22         (
23             fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)
24           - ghf*fvc::snGrad(rho)
25         )*rAUf*mesh.magSf();
27     if (!mesh.moving())
28     {
29         adjustPhi(phi, U, pd);
30     }
32     for(int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
33     {
34         fvScalarMatrix pdEqn
35         (
36             fvm::laplacian(rAUf, pd) == fvc::div(phi)
37         );
39         pdEqn.setReference(pRefCell, pRefValue);
41         // Solve pressure equation to a tight tolerance in the last corrector
42         if
43         (
44             oCorr == nOuterCorr - 1
45          && corr == nCorr - 1
46          && nonOrth == nNonOrthCorr
47         )
48         {
49             pdEqn.solve(mesh.solver("pdFinal"));
50         }
51         else
52         {
53             pdEqn.solve();
54         }
56         if (nonOrth == nNonOrthCorr)
57         {
58             phi -= pdEqn.flux();
59         }
60     }
62     // Explicitly relax pressure except for last corrector
63     if (oCorr != nOuterCorr - 1)
64     {
65         pd.relax();
66     }
68     U += rAU/rho*fvc::reconstruct((phi - phiU)/rAUf);
69     U.correctBoundaryConditions();