You are on page 1of 9

alphaEqn.

H
{ word alphaScheme("div(phi,alpha)"); word alpharScheme("div(phirb,alpha)"); surfaceScalarField phic = mag(phi/mesh.magSf()); phic = min(interface.cAlpha()*phic, max(phic)); surfaceScalarField phir = phic*interface.nHatf(); for (int aCorr=0; aCorr<nAlphaCorr; aCorr++) { surfaceScalarField phiAlpha = fvc::flux ( phi, alpha1, alphaScheme ) + fvc::flux ( -fvc::flux(-phir, scalar(1) - alpha1, alpharScheme), alpha1, alpharScheme ); MULES::explicitSolve(alpha1, phi, phiAlpha, 1, 0); rhoPhi = phiAlpha*(rho1 - rho2) + phi*rho2; } Info<< "Liquid phase volume fraction = " << alpha1.weightedAverage(mesh.V()).value() << " Min(alpha1) = " << min(alpha1).value() << " Max(alpha1) = " << max(alpha1).value() << endl; }

alphaEqnSubCycle.H
label nAlphaCorr ( readLabel(piso.lookup("nAlphaCorr")) ); label nAlphaSubCycles ( readLabel(piso.lookup("nAlphaSubCycles"))

); if (nAlphaSubCycles > 1) { dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum = 0.0*rhoPhi; for ( subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles); !(++alphaSubCycle).end(); ) { # include "alphaEqn.H" rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; } rhoPhi = rhoPhiSum; } else { # include "alphaEqn.H" } interface.correct(); rho == alpha1*rho1 + (scalar(1) alpha1)*rho2;

correctPhi.H
{ #include "continuityErrs.H" wordList pcorrTypes ( p.boundaryField().size(), zeroGradientFvPatchScalarField::typeName ); for (label i=0; i<p.boundaryField().size(); i++) { if (p.boundaryField()[i].fixesValue()) { pcorrTypes[i] = fixedValueFvPatchScalarField::typeName; } } volScalarField pcorr (

IOobject ( "pcorr", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar("pcorr", p.dimensions(), 0.0), pcorrTypes ); dimensionedScalar rUAf("(1|A(U))", dimTime/rho.dimensions(), 1.0); adjustPhi(phi, U, pcorr); for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pcorrEqn ( fvm::laplacian(rUAf, pcorr) == fvc::div(phi) ); pcorrEqn.setReference(pRefCell, pRefValue); pcorrEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pcorrEqn.flux(); } } #include "continuityErrs.H" }

createFields.H
Info<< "Reading field p\n" << endl; volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh );

Info<< "Reading field alpha1\n" << endl; volScalarField alpha1 ( IOobject ( "alpha1", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Info<< "Reading field U\n" << endl; volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); # include "createPhi.H"

Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi); const dimensionedScalar& rho1 = twoPhaseProperties.rho1(); const dimensionedScalar& rho2 = twoPhaseProperties.rho2();

// Need to store rho for ddt(rho, U) volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*rho1 + (scalar(1) - alpha1)*rho2, alpha1.boundaryField().types() );

rho.oldTime();

// Mass flux // Initialisation does not matter because rhoPhi is reset after the // alpha1 solution before it is used in the U equation. surfaceScalarField rhoPhi ( IOobject ( "rho*phi", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), rho1*phi );

label pRefCell = 0; scalar pRefValue = 0.0; setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);

// Construct interface from alpha1 distribution interfaceProperties interface(alpha1, U, twoPhaseProperties);

// Construct incompressible turbulence model autoPtr<incompressible::turbulenceModel> turbulence ( incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) );

pEqn.H
{ volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf = fvc::interpolate(rUA); U = rUA*UEqn.H(); surfaceScalarField phiU ( "phiU", (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) ); adjustPhi(phiU, U, p);

phi = phiU + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) )*rUAf; for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rUAf, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { pEqn.solve(mesh.solver(p.name() + "Final")); } else { pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } U += rUA*fvc::reconstruct((phi - phiU)/rUAf); U.correctBoundaryConditions(); }

UBlendingFactor.H
surfaceScalarField alpha1f = fvc::interpolate(alpha1); surfaceScalarField UBlendingFactor ( "UBlendingFactor", sqrt(max(min(4*alpha1f*(1.0 - alpha1f), 1.0), 0.0)) );

UEqn.H
surfaceScalarField muEff

( "muEff", twoPhaseProperties.muf() + fvc::interpolate(rho*turbulence->nut()) ); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) - fvm::laplacian(muEff, U) - (fvc::grad(U) & fvc::grad(muEff)) //- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) ); UEqn.relax(); if (momentumPredictor) { solve ( UEqn == fvc::reconstruct ( fvc::interpolate(rho)*(g & mesh.Sf()) +( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - fvc::snGrad(p) ) * mesh.magSf() ) ); }

interFoam.C
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your

option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application interFoam Description Solver for 2 incompressible, isothermal immiscible fluids using a VOF (volume of fluid) phase-fraction based interface capturing approach. The momentum and other fluid properties are of the "mixture" and a single momentum equation is solved. Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. For a two-fluid approach see twoPhaseEulerFoam. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" #include "MULES.H" #include "subCycle.H" #include "interfaceProperties.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "readGravitationalAcceleration.H" #include "readPISOControls.H" #include "initContinuityErrs.H" #include "createFields.H" #include "readTimeControls.H" #include "correctPhi.H" #include "CourantNo.H" #include "setInitialDeltaT.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { #include "readPISOControls.H" #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; twoPhaseProperties.correct(); #include "alphaEqnSubCycle.H" #include "UEqn.H" // --- PISO loop for (int corr=0; corr<nCorr; corr++) { #include "pEqn.H" } #include "continuityErrs.H" turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }

// ************************************************************************* // /opt/OpenFOAM/OpenFOAM-1.6/applications/solvers/multiphase/interFoam

You might also like