FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

pEqn.H

Go to the documentation of this file.
00001 {
00002     rho = thermo.rho();
00003     rho = max(rho, rhoMin[i]);
00004     rho = min(rho, rhoMax[i]);
00005     rho.relax();
00006 
00007     volScalarField rUA = 1.0/UEqn().A();
00008     surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA));
00009 
00010     U = rUA*UEqn().H();
00011     UEqn.clear();
00012 
00013     phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
00014     bool closedVolume = adjustPhi(phi, U, p_rgh);
00015     dimensionedScalar compressibility = fvc::domainIntegrate(psi);
00016     bool compressible = (compressibility.value() > SMALL);
00017 
00018     surfaceScalarField buoyancyPhi = rhorUAf*ghf*fvc::snGrad(rho)*mesh.magSf();
00019     phi -= buoyancyPhi;
00020 
00021     // Solve pressure
00022     for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00023     {
00024         fvScalarMatrix p_rghEqn
00025         (
00026             fvm::laplacian(rhorUAf, p_rgh) == fvc::div(phi)
00027         );
00028 
00029         p_rghEqn.setReference
00030         (
00031             pRefCell,
00032             compressible ? getRefCellValue(p_rgh, pRefCell) : pRefValue
00033         );
00034 
00035         eqnResidual = p_rghEqn.solve().initialResidual();
00036 
00037         // Retain the residual from the first iteration
00038         if (nonOrth == 0)
00039         {
00040             maxResidual = max(eqnResidual, maxResidual);
00041         }
00042 
00043         if (nonOrth == nNonOrthCorr)
00044         {
00045             // Calculate the conservative fluxes
00046             phi -= p_rghEqn.flux();
00047 
00048             // Explicitly relax pressure for momentum corrector
00049             p_rgh.relax();
00050 
00051             // Correct the momentum source with the pressure gradient flux
00052             // calculated from the relaxed pressure
00053             U -= rUA*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rhorUAf);
00054             U.correctBoundaryConditions();
00055         }
00056     }
00057 
00058     p = p_rgh + rho*gh;
00059 
00060     #include <finiteVolume/continuityErrs.H>
00061 
00062     // For closed-volume cases adjust the pressure level
00063     // to obey overall mass continuity
00064     if (closedVolume && compressible)
00065     {
00066         p += (initialMass - fvc::domainIntegrate(thermo.rho()))
00067             /compressibility;
00068         p_rgh = p - rho*gh;
00069     }
00070 
00071     rho = thermo.rho();
00072     rho = max(rho, rhoMin[i]);
00073     rho = min(rho, rhoMax[i]);
00074     rho.relax();
00075 
00076     Info<< "Min/max rho:" << min(rho).value() << ' '
00077         << max(rho).value() << endl;
00078 
00079     // Update thermal conductivity
00080     K = thermo.Cp()*turb.alphaEff();
00081 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines