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

alphaEqns.H

Go to the documentation of this file.
00001 {
00002     word alphaScheme("div(phi,alpha)");
00003     word alpharScheme("div(phirb,alpha)");
00004 
00005     surfaceScalarField phir
00006     (
00007         IOobject
00008         (
00009             "phir",
00010             runTime.timeName(),
00011             mesh,
00012             IOobject::NO_READ,
00013             IOobject::NO_WRITE
00014         ),
00015         interface.cAlpha()*mag(phi/mesh.magSf())*interface.nHatf()
00016     );
00017 
00018     for (int gCorr=0; gCorr<nAlphaCorr; gCorr++)
00019     {
00020         // Create the limiter to be used for all phase-fractions
00021         scalarField allLambda(mesh.nFaces(), 1.0);
00022 
00023         // Split the limiter into a surfaceScalarField
00024         slicedSurfaceScalarField lambda
00025         (
00026             IOobject
00027             (
00028                 "lambda",
00029                 mesh.time().timeName(),
00030                 mesh,
00031                 IOobject::NO_READ,
00032                 IOobject::NO_WRITE,
00033                 false
00034             ),
00035             mesh,
00036             dimless,
00037             allLambda,
00038             false   // Use slices for the couples
00039         );
00040 
00041 
00042         // Create the complete convection flux for alpha1
00043         surfaceScalarField phiAlpha1 =
00044             fvc::flux
00045             (
00046                 phi,
00047                 alpha1,
00048                 alphaScheme
00049             )
00050           + fvc::flux
00051             (
00052                 -fvc::flux(-phir, alpha2, alpharScheme),
00053                 alpha1,
00054                 alpharScheme
00055             )
00056           + fvc::flux
00057             (
00058                 -fvc::flux(-phir, alpha3, alpharScheme),
00059                 alpha1,
00060                 alpharScheme
00061             );
00062 
00063         // Create the bounded (upwind) flux for alpha1
00064         surfaceScalarField phiAlpha1BD =
00065             upwind<scalar>(mesh, phi).flux(alpha1);
00066 
00067         // Calculate the flux correction for alpha1
00068         phiAlpha1 -= phiAlpha1BD;
00069 
00070         // Calculate the limiter for alpha1
00071         MULES::limiter
00072         (
00073             allLambda,
00074             geometricOneField(),
00075             alpha1,
00076             phiAlpha1BD,
00077             phiAlpha1,
00078             zeroField(),
00079             zeroField(),
00080             1,
00081             0,
00082             3
00083         );
00084 
00085         // Create the complete flux for alpha2
00086         surfaceScalarField phiAlpha2 =
00087             fvc::flux
00088             (
00089                 phi,
00090                 alpha2,
00091                 alphaScheme
00092             )
00093           + fvc::flux
00094             (
00095                 -fvc::flux(phir, alpha1, alpharScheme),
00096                 alpha2,
00097                 alpharScheme
00098             );
00099 
00100         // Create the bounded (upwind) flux for alpha2
00101         surfaceScalarField phiAlpha2BD =
00102             upwind<scalar>(mesh, phi).flux(alpha2);
00103 
00104         // Calculate the flux correction for alpha2
00105         phiAlpha2 -= phiAlpha2BD;
00106 
00107         // Further limit the limiter for alpha2
00108         MULES::limiter
00109         (
00110             allLambda,
00111             geometricOneField(),
00112             alpha2,
00113             phiAlpha2BD,
00114             phiAlpha2,
00115             zeroField(),
00116             zeroField(),
00117             1,
00118             0,
00119             3
00120         );
00121 
00122         // Construct the limited fluxes
00123         phiAlpha1 = phiAlpha1BD + lambda*phiAlpha1;
00124         phiAlpha2 = phiAlpha2BD + lambda*phiAlpha2;
00125 
00126         // Solve for alpha1
00127         solve(fvm::ddt(alpha1) + fvc::div(phiAlpha1));
00128 
00129         // Create the diffusion coefficients for alpha2<->alpha3
00130         volScalarField Dc23 = D23*max(alpha3, scalar(0))*pos(alpha2);
00131         volScalarField Dc32 = D23*max(alpha2, scalar(0))*pos(alpha3);
00132 
00133         // Add the diffusive flux for alpha3->alpha2
00134         phiAlpha2 -= fvc::interpolate(Dc32)*mesh.magSf()*fvc::snGrad(alpha1);
00135 
00136         // Solve for alpha2
00137         fvScalarMatrix alpha2Eqn
00138         (
00139             fvm::ddt(alpha2)
00140           + fvc::div(phiAlpha2)
00141           - fvm::laplacian(Dc23 + Dc32, alpha2)
00142         );
00143         alpha2Eqn.solve();
00144 
00145         // Construct the complete mass flux
00146         rhoPhi =
00147               phiAlpha1*(rho1 - rho3)
00148             + (phiAlpha2 + alpha2Eqn.flux())*(rho2 - rho3)
00149             + phi*rho3;
00150 
00151         alpha3 = 1.0 - alpha1 - alpha2;
00152     }
00153 
00154     Info<< "Air phase volume fraction = "
00155         << alpha1.weightedAverage(mesh.V()).value()
00156         << "  Min(alpha1) = " << min(alpha1).value()
00157         << "  Max(alpha1) = " << max(alpha1).value()
00158         << endl;
00159 
00160     Info<< "Liquid phase volume fraction = "
00161         << alpha2.weightedAverage(mesh.V()).value()
00162         << "  Min(alpha2) = " << min(alpha2).value()
00163         << "  Max(alpha2) = " << max(alpha2).value()
00164         << endl;
00165 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines