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

pEqn.H

Go to the documentation of this file.
00001 {
00002     bool closedVolume = p.needReference();
00003 
00004     rho = thermo.rho();
00005 
00006     // Thermodynamic density needs to be updated by psi*d(p) after the
00007     // pressure solution - done in 2 parts. Part 1:
00008     thermo.rho() -= psi*p;
00009 
00010     volScalarField rUA = 1.0/UEqn.A();
00011     surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
00012 
00013     U = rUA*UEqn.H();
00014 
00015     surfaceScalarField phiU
00016     (
00017         fvc::interpolate(rho)
00018        *(
00019             (fvc::interpolate(U) & mesh.Sf())
00020           + fvc::ddtPhiCorr(rUA, rho, U, phi)
00021         )
00022     );
00023 
00024     phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf());
00025 
00026     for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00027     {
00028         fvScalarMatrix pEqn
00029         (
00030             fvc::ddt(rho) + psi*correction(fvm::ddt(p))
00031           + fvc::div(phi)
00032           - fvm::laplacian(rhorUAf, p)
00033         );
00034 
00035         if (corr == nCorr-1 && nonOrth == nNonOrthCorr)
00036         {
00037             pEqn.solve(mesh.solver(p.name() + "Final"));
00038         }
00039         else
00040         {
00041             pEqn.solve(mesh.solver(p.name()));
00042         }
00043 
00044         if (nonOrth == nNonOrthCorr)
00045         {
00046             phi += pEqn.flux();
00047         }
00048     }
00049 
00050     // Second part of thermodynamic density update
00051     thermo.rho() += psi*p;
00052 
00053     U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf);
00054     U.correctBoundaryConditions();
00055 
00056     DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
00057 
00058     #include "rhoEqn.H"
00059     #include "compressibleContinuityErrs.H"
00060 
00061     // For closed-volume cases adjust the pressure and density levels
00062     // to obey overall mass continuity
00063     if (closedVolume)
00064     {
00065         p +=
00066             (initialMass - fvc::domainIntegrate(psi*p))
00067             /fvc::domainIntegrate(psi);
00068         thermo.rho() = psi*p;
00069         rho += (initialMass - fvc::domainIntegrate(rho))/totalVolume;
00070     }
00071 }
Copyright © 2000-2009 OpenCFD Ltd