initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / solvers / compressible / rhoPorousSimpleFoam / UEqn.H
blob4150cd7503f41d781ce066ae50ee9acfd915e00c
1     // Construct the Momentum equation
3     tmp<fvVectorMatrix> UEqn
4     (
5         fvm::div(phi, U)
6       - fvm::Sp(fvc::div(phi), U)
7       + turbulence->divDevRhoReff(U)
8     );
10     UEqn().relax();
12     // Include the porous media resistance and solve the momentum equation
13     // either implicit in the tensorial resistance or transport using by
14     // including the spherical part of the resistance in the momentum diagonal
16     tmp<volScalarField> trAU;
17     tmp<volTensorField> trTU;
19     if (pressureImplicitPorosity)
20     {
21         tmp<volTensorField> tTU = tensor(I)*UEqn().A();
22         pZones.addResistance(UEqn(), tTU());
23         trTU = inv(tTU());
24         trTU().rename("rAU");
26         volVectorField gradp = fvc::grad(p);
28         for (int UCorr=0; UCorr<nUCorr; UCorr++)
29         {
30             U = trTU() & (UEqn().H() - gradp);
31         }
32         U.correctBoundaryConditions();
33     }
34     else
35     {
36         pZones.addResistance(UEqn());
38         eqnResidual = solve
39         (
40             UEqn() == -fvc::grad(p)
41         ). initialResidual();
43         maxResidual = max(eqnResidual, maxResidual);
45         trAU = 1.0/UEqn().A();
46         trAU().rename("rAU");
47     }