OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

pEqn.H

Go to the documentation of this file.
00001 rho = thermo.rho();
00002 
00003 volScalarField rUA = 1.0/UEqn().A();
00004 U = rUA*UEqn().H();
00005 UEqn.clear();
00006 
00007 bool closedVolume = false;
00008 
00009 if (transonic)
00010 {
00011     surfaceScalarField phid
00012     (
00013         "phid",
00014         fvc::interpolate(psi)*(fvc::interpolate(U) & mesh.Sf())
00015     );
00016 
00017     for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00018     {
00019         fvScalarMatrix pEqn
00020         (
00021             fvm::div(phid, p)
00022           - fvm::laplacian(rho*rUA, p)
00023         );
00024 
00025         // Relax the pressure equation to ensure diagonal-dominance
00026         pEqn.relax(mesh.relaxationFactor("pEqn"));
00027 
00028         pEqn.setReference(pRefCell, pRefValue);
00029 
00030         // retain the residual from the first iteration
00031         if (nonOrth == 0)
00032         {
00033             eqnResidual = pEqn.solve().initialResidual();
00034             maxResidual = max(eqnResidual, maxResidual);
00035         }
00036         else
00037         {
00038             pEqn.solve();
00039         }
00040 
00041         if (nonOrth == nNonOrthCorr)
00042         {
00043             phi == pEqn.flux();
00044         }
00045     }
00046 }
00047 else
00048 {
00049     phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
00050     closedVolume = adjustPhi(phi, U, p);
00051 
00052     for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00053     {
00054         fvScalarMatrix pEqn
00055         (
00056             fvm::laplacian(rho*rUA, p) == fvc::div(phi)
00057         );
00058 
00059         pEqn.setReference(pRefCell, pRefValue);
00060 
00061         // Retain the residual from the first iteration
00062         if (nonOrth == 0)
00063         {
00064             eqnResidual = pEqn.solve().initialResidual();
00065             maxResidual = max(eqnResidual, maxResidual);
00066         }
00067         else
00068         {
00069             pEqn.solve();
00070         }
00071 
00072         if (nonOrth == nNonOrthCorr)
00073         {
00074             phi -= pEqn.flux();
00075         }
00076     }
00077 }
00078 
00079 
00080 #include "incompressible/continuityErrs.H"
00081 
00082 // Explicitly relax pressure for momentum corrector
00083 p.relax();
00084 
00085 rho = thermo.rho();
00086 rho.relax();
00087 Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl;
00088 
00089 U -= rUA*fvc::grad(p);
00090 U.correctBoundaryConditions();
00091 
00092 bound(p, pMin);
00093 
00094 // For closed-volume cases adjust the pressure and density levels
00095 // to obey overall mass continuity
00096 if (closedVolume)
00097 {
00098     p += (initialMass - fvc::domainIntegrate(psi*p))
00099         /fvc::domainIntegrate(psi);
00100 }
Copyright © 2000-2009 OpenCFD Ltd