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

pEqn.H

Go to the documentation of this file.
00001 {
00002     surfaceScalarField alphaf = fvc::interpolate(alpha);
00003     surfaceScalarField betaf = scalar(1) - alphaf;
00004 
00005     volScalarField rUaA = 1.0/UaEqn.A();
00006     volScalarField rUbA = 1.0/UbEqn.A();
00007 
00008     rUaAf = fvc::interpolate(rUaA);
00009     surfaceScalarField rUbAf = fvc::interpolate(rUbA);
00010 
00011     Ua = rUaA*UaEqn.H();
00012     Ub = rUbA*UbEqn.H();
00013 
00014     surfaceScalarField phiDraga =
00015         fvc::interpolate(beta/rhoa*K*rUaA)*phib + rUaAf*(g & mesh.Sf());
00016 
00017     if (g0.value() > 0.0)
00018     {
00019         phiDraga -= ppMagf*fvc::snGrad(alpha)*mesh.magSf();
00020     }
00021 
00022     if (kineticTheory.on())
00023     {
00024         phiDraga -= rUaAf*fvc::snGrad(kineticTheory.pa()/rhoa)*mesh.magSf();
00025     }
00026 
00027     surfaceScalarField phiDragb =
00028         fvc::interpolate(alpha/rhob*K*rUbA)*phia + rUbAf*(g & mesh.Sf());
00029 
00030     // Fix for gravity on outlet boundary.
00031     forAll(p.boundaryField(), patchi)
00032     {
00033         if (isA<zeroGradientFvPatchScalarField>(p.boundaryField()[patchi]))
00034         {
00035             phiDraga.boundaryField()[patchi] = 0.0;
00036             phiDragb.boundaryField()[patchi] = 0.0;
00037         }
00038     }
00039 
00040     phia = (fvc::interpolate(Ua) & mesh.Sf()) + fvc::ddtPhiCorr(rUaA, Ua, phia)
00041          + phiDraga;
00042 
00043     phib = (fvc::interpolate(Ub) & mesh.Sf()) + fvc::ddtPhiCorr(rUbA, Ub, phib)
00044          + phiDragb;
00045     
00046     phi = alphaf*phia + betaf*phib;
00047 
00048     surfaceScalarField Dp("(rho*(1|A(U)))", alphaf*rUaAf/rhoa + betaf*rUbAf/rhob);
00049 
00050     for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00051     {
00052         fvScalarMatrix pEqn
00053         (
00054             fvm::laplacian(Dp, p) == fvc::div(phi)
00055         );
00056 
00057         pEqn.setReference(pRefCell, pRefValue);
00058         pEqn.solve();
00059 
00060         if (nonOrth == nNonOrthCorr)
00061         {
00062             surfaceScalarField SfGradp = pEqn.flux()/Dp;
00063 
00064             phia -= rUaAf*SfGradp/rhoa;
00065             phib -= rUbAf*SfGradp/rhob;
00066             phi = alphaf*phia + betaf*phib;
00067 
00068             p.relax();
00069             SfGradp = pEqn.flux()/Dp;
00070 
00071             Ua += fvc::reconstruct(phiDraga - rUaAf*SfGradp/rhoa);
00072             Ua.correctBoundaryConditions();
00073 
00074             Ub += fvc::reconstruct(phiDragb - rUbAf*SfGradp/rhob);
00075             Ub.correctBoundaryConditions();
00076 
00077             U = alpha*Ua + beta*Ub;
00078         }
00079     }
00080 }
00081 
00082 #include "continuityErrs.H"
Copyright © 2000-2009 OpenCFD Ltd