solvers::incompressibleMultiphaseVoF: New solver module for multiphase VoF simulations

executed with foamRun for single region simulations of foamMultiRun for
multi-region simulations.  Replaces multiphaseInterFoam and all the
corresponding tutorials have been updated and moved to
tutorials/modules/incompressibleMultiphaseVoF.

incompressibleMultiphaseVoF is derived from the multiphaseVoFSolver which adds
multiphase capability to the VoFSolver base-class used as the basis of all
two-phase and multiphase VoF solvers.

Class
    Foam::solvers::incompressibleMultiphaseVoF

Description
    Solver module for the solution of multiple incompressible, isothermal
    immiscible fluids using a VOF (volume of fluid) phase-fraction based
    interface capturing approach, with optional mesh motion and mesh topology
    changes including adaptive re-meshing.

    The momentum and other fluid properties are of the "mixture" and a single
    momentum equation is solved.

    A mixture approach for momentum transport is provided in which a single
    laminar, RAS or LES model is selected to model the momentum stress.

    Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
    pseudo-transient and steady simulations.

SourceFiles
    incompressibleMultiphaseVoF.C

See also
    Foam::solvers::VoFSolver
    Foam::solvers::multiphaseVoFSolver
This commit is contained in:
Henry Weller
2023-01-10 10:12:43 +00:00
parent 7f1fb2fb11
commit ffdb211bdc
127 changed files with 2116 additions and 1284 deletions

View File

@ -14,6 +14,8 @@ wmake $targetType VoFSolver
wmake $targetType twoPhaseVoFSolver
incompressibleVoF/Allwmake $targetType $*
compressibleVoF/Allwmake $targetType $*
wmake $targetType multiphaseVoFSolver
wmake $targetType incompressibleMultiphaseVoF
multiphaseEuler/Allwmake $targetType $*
wmake $targetType solid
solidDisplacement/Allwmake $targetType $*

View File

@ -25,18 +25,14 @@ Class
Foam::solvers::VoFSolver
Description
Solver module base-class for for 2 immiscible fluids using a VOF (volume
of fluid) phase-fraction based interface capturing approach, with optional
mesh motion and mesh topology changes including adaptive re-meshing.
Base solver module base-class for the solution of immiscible fluids using
a VOF (volume of fluid) phase-fraction based interface capturing approach,
with optional mesh motion and mesh topology changes including adaptive
re-meshing.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
Either mixture or two-phase transport modelling may be selected. In the
mixture approach a single laminar, RAS or LES model is selected to model the
momentum stress. In the Euler-Euler two-phase approach separate laminar,
RAS or LES selected models are selected for each of the phases.
Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
pseudo-transient and steady simulations.

View File

@ -0,0 +1,7 @@
incompressibleMultiphaseVoFMixture/incompressibleVoFphase/incompressibleVoFphase.C
incompressibleMultiphaseVoFMixture/incompressibleMultiphaseVoFMixture.C
alphaPredictor.C
pressureCorrector.C
incompressibleMultiphaseVoF.C
LIB = $(FOAM_LIBBIN)/libincompressibleMultiphaseVoF

View File

@ -1,24 +1,26 @@
EXE_INC = \
-IincompressibleMultiphaseMixture/lnInclude \
-I$(FOAM_SOLVERS)/modules/multiphaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/VoF \
-I$(LIB_SRC)/twoPhaseModels/interfaceCompression/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/multiphaseModels/multiphaseProperties/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/phaseIncompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lincompressibleMultiphaseMixture \
LIB_LIBS = \
-lmultiphaseVoFSolver \
-lphysicalProperties \
-lmultiphaseProperties \
-linterfaceCompression \
-linterfaceProperties \
-lmomentumTransportModels \
-lincompressibleMomentumTransportModels \
-lphaseIncompressibleMomentumTransportModels \
-lfiniteVolume \
-lmeshTools \
-lfvModels \
-lfvConstraints \
-lmeshTools \
-lsampling

View File

@ -0,0 +1,212 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "incompressibleMultiphaseVoF.H"
#include "subCycle.H"
#include "CMULES.H"
#include "fvcFlux.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::incompressibleMultiphaseVoF::alphaSolve
(
const dictionary& alphaControls
)
{
const scalar cAlpha(alphaControls.lookup<scalar>("cAlpha"));
const word alphaScheme("div(phi,alpha)");
const word alpharScheme("div(phirb,alpha)");
surfaceScalarField phic(mag(phi/mesh.magSf()));
phic = min(cAlpha*phic, max(phic));
UPtrList<const volScalarField> alphas(phases.size());
PtrList<surfaceScalarField> alphaPhis(phases.size());
forAll(phases, phasei)
{
const incompressibleVoFphase& alpha = phases[phasei];
alphas.set(phasei, &alpha);
alphaPhis.set
(
phasei,
new surfaceScalarField
(
"phi" + alpha.name() + "Corr",
fvc::flux
(
phi,
alpha,
alphaScheme
)
)
);
surfaceScalarField& alphaPhi = alphaPhis[phasei];
forAll(phases, phasej)
{
incompressibleVoFphase& alpha2 = phases[phasej];
if (&alpha2 == &alpha) continue;
surfaceScalarField phir(phic*mixture.nHatf(alpha, alpha2));
alphaPhi += fvc::flux
(
-fvc::flux(-phir, alpha2, alpharScheme),
alpha,
alpharScheme
);
}
// Limit alphaPhi for each phase
MULES::limit
(
1.0/mesh.time().deltaT().value(),
geometricOneField(),
alpha,
phi,
alphaPhi,
zeroField(),
zeroField(),
oneField(),
zeroField(),
false
);
}
MULES::limitSum(alphas, alphaPhis, phi);
rhoPhi = Zero;
volScalarField sumAlpha
(
IOobject
(
"sumAlpha",
mesh.time().name(),
mesh
),
mesh,
dimensionedScalar(dimless, 0)
);
forAll(phases, phasei)
{
incompressibleVoFphase& alpha = phases[phasei];
surfaceScalarField& alphaPhi = alphaPhis[phasei];
MULES::explicitSolve
(
geometricOneField(),
alpha,
alphaPhi
);
rhoPhi += alphaPhi*alpha.rho();
Info<< alpha.name() << " volume fraction, min, max = "
<< alpha.weightedAverage(mesh.V()).value()
<< ' ' << min(alpha).value()
<< ' ' << max(alpha).value()
<< endl;
sumAlpha += alpha;
}
Info<< "Phase-sum volume fraction, min, max = "
<< sumAlpha.weightedAverage(mesh.V()).value()
<< ' ' << min(sumAlpha).value()
<< ' ' << max(sumAlpha).value()
<< endl;
// Correct the sum of the phase-fractions to avoid 'drift'
volScalarField sumCorr(1.0 - sumAlpha);
forAll(phases, phasei)
{
incompressibleVoFphase& alpha = phases[phasei];
alpha += alpha*sumCorr;
}
}
void Foam::solvers::incompressibleMultiphaseVoF::alphaPredictor()
{
const dictionary& alphaControls = mesh.solution().solverDict("alpha");
const label nAlphaSubCycles(alphaControls.lookup<label>("nAlphaSubCycles"));
if (nAlphaSubCycles > 1)
{
surfaceScalarField rhoPhiSum
(
IOobject
(
"rhoPhiSum",
runTime.name(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), 0)
);
const dimensionedScalar totalDeltaT = runTime.deltaT();
List<volScalarField*> alphaPtrs(phases.size());
forAll(phases, phasei)
{
alphaPtrs[phasei] = &phases[phasei];
}
for
(
subCycle<volScalarField, subCycleFields> alphaSubCycle
(
alphaPtrs,
nAlphaSubCycles
);
!(++alphaSubCycle).end();
)
{
alphaSolve(alphaControls);
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi;
}
rhoPhi = rhoPhiSum;
}
else
{
alphaSolve(alphaControls);
}
mixture.correct();
}
// ************************************************************************* //

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "incompressibleMultiphaseVoF.H"
#include "CorrectPhi.H"
#include "geometricZeroField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
defineTypeNameAndDebug(incompressibleMultiphaseVoF, 0);
addToRunTimeSelectionTable(solver, incompressibleMultiphaseVoF, fvMesh);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF
(
fvMesh& mesh
)
:
multiphaseVoFSolver
(
mesh,
autoPtr<multiphaseVoFMixture>
(
new incompressibleMultiphaseVoFMixture(mesh)
)
),
mixture
(
refCast<incompressibleMultiphaseVoFMixture>
(
multiphaseVoFSolver::mixture
)
),
phases(mixture.phases()),
p
(
IOobject
(
"p",
runTime.name(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh + rho*buoyancy.gh
),
pressureReference_
(
p,
p_rgh,
pimple.dict(),
false
),
momentumTransport_
(
incompressible::momentumTransportModel::New
(
U,
phi,
mixture
)
),
momentumTransport(momentumTransport_())
{
// Read the controls
read();
if (!runTime.restart() || !divergent())
{
if (correctPhi)
{
rAU = new volScalarField
(
IOobject
(
"rAU",
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimTime/dimDensity, 1)
);
correctUphiBCs(U, phi, true);
CorrectPhi
(
phi,
U,
p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(),
pressureReference(),
pimple
);
}
else
{
correctUphiBCs(U, phi, true);
CorrectPhi
(
phi,
U,
p_rgh,
dimensionedScalar(dimTime/rho.dimensions(), 1),
geometricZeroField(),
pressureReference(),
pimple
);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solvers::incompressibleMultiphaseVoF::~incompressibleMultiphaseVoF()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::incompressibleMultiphaseVoF::prePredictor()
{
multiphaseVoFSolver::prePredictor();
if (pimple.predictTransport())
{
momentumTransport.predict();
}
}
void Foam::solvers::incompressibleMultiphaseVoF::thermophysicalPredictor()
{}
void Foam::solvers::incompressibleMultiphaseVoF::postCorrector()
{
if (pimple.correctTransport())
{
momentumTransport.correct();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::solvers::incompressibleMultiphaseVoF
Description
Solver module for the solution of multiple incompressible, isothermal
immiscible fluids using a VOF (volume of fluid) phase-fraction based
interface capturing approach, with optional mesh motion and mesh topology
changes including adaptive re-meshing.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
A mixture approach for momentum transport is provided in which a single
laminar, RAS or LES model is selected to model the momentum stress.
Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
pseudo-transient and steady simulations.
SourceFiles
incompressibleMultiphaseVoF.C
See also
Foam::solvers::VoFSolver
Foam::solvers::multiphaseVoFSolver
\*---------------------------------------------------------------------------*/
#ifndef incompressibleMultiphaseVoF_H
#define incompressibleMultiphaseVoF_H
#include "multiphaseVoFSolver.H"
#include "incompressibleMultiphaseVoFMixture.H"
#include "incompressibleMomentumTransportModels.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
/*---------------------------------------------------------------------------*\
Class incompressibleMultiphaseVoF Declaration
\*---------------------------------------------------------------------------*/
class incompressibleMultiphaseVoF
:
public multiphaseVoFSolver
{
protected:
// Phase properties
//- The compressible two-phase mixture
incompressibleMultiphaseVoFMixture& mixture;
//- Reference to the phases
UPtrListDictionary<incompressibleVoFphase>& phases;
// Thermophysical properties
//- Static pressure field
volScalarField p;
// Pressure reference
//- Pressure reference
Foam::pressureReference pressureReference_;
// Momentum transport
//- Momentum transport model pointer
autoPtr<incompressible::momentumTransportModel> momentumTransport_;
//- Momentum transport model
incompressible::momentumTransportModel& momentumTransport;
// Protected Member Functions
//- Return the pressure reference
virtual const Foam::pressureReference& pressureReference() const
{
return pressureReference_;
}
//- Is the flow divergent?
// i.e. includes phase-fraction sources
virtual bool divergent()
{
return false;
}
//- Return the momentum equation stress term
virtual tmp<fvVectorMatrix> divDevTau(volVectorField& U)
{
return momentumTransport.divDevTau(rho, U);
}
//- Solve for the phase-fractions
virtual void alphaPredictor();
private:
// Private Member Functions
//- Solve for the phase-fractions
void alphaSolve(const dictionary& alphaControls);
public:
//- Runtime type information
TypeName("incompressibleMultiphaseVoF");
// Constructors
//- Construct from region mesh
incompressibleMultiphaseVoF(fvMesh& mesh);
//- Disallow default bitwise copy construction
incompressibleMultiphaseVoF
(
const incompressibleMultiphaseVoF&
) = delete;
//- Destructor
virtual ~incompressibleMultiphaseVoF();
// Member Functions
//- Called at the start of the PIMPLE loop
virtual void prePredictor();
//- Construct and solve the energy equation,
// convert to temperature
// and update thermophysical and transport properties
virtual void thermophysicalPredictor();
//- Construct and solve the pressure equation in the PISO loop
virtual void pressureCorrector();
//- Correct the momentum and thermophysical transport modelling
virtual void postCorrector();
// Member Operators
//- Disallow default bitwise assignment
void operator=(const incompressibleMultiphaseVoF&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solvers
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "incompressibleMultiphaseVoFMixture.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(incompressibleMultiphaseVoFMixture, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::incompressibleMultiphaseVoFMixture::incompressibleMultiphaseVoFMixture
(
const fvMesh& mesh
)
:
multiphaseVoFMixture(mesh, incompressibleVoFphase::iNew(mesh)),
phases_(multiphaseVoFMixture::phases().convert<incompressibleVoFphase>()),
rho_
(
IOobject
(
"rho",
mesh.time().name(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("rho", dimDensity, 0)
),
nu_
(
IOobject
(
"nu",
mesh.time().name(),
mesh
),
mesh,
dimensionedScalar(dimViscosity, 0),
calculatedFvPatchScalarField::typeName
)
{
correct();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::incompressibleMultiphaseVoFMixture::mu() const
{
tmp<volScalarField> tmu
(
phases_[0]*phases_[0].rho()*phases_[0].nu()
);
volScalarField& mu = tmu.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
mu += phases_[phasei]*phases_[phasei].rho()*phases_[phasei].nu();
}
return tmu;
}
Foam::tmp<Foam::scalarField>
Foam::incompressibleMultiphaseVoFMixture::mu(const label patchi) const
{
tmp<scalarField> tmu
(
phases_[0].boundaryField()[patchi]
*phases_[0].rho().value()
*phases_[0].nu(patchi)
);
scalarField& mu = tmu.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
mu +=
phases_[phasei].boundaryField()[patchi]
*phases_[phasei].rho().value()
*phases_[phasei].nu(patchi);
}
return tmu;
}
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleMultiphaseVoFMixture::muf() const
{
tmp<surfaceScalarField> tmuf
(
fvc::interpolate(phases_[0])
*phases_[0].rho()*fvc::interpolate(phases_[0].nu())
);
surfaceScalarField& muf = tmuf.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
muf +=
fvc::interpolate(phases_[phasei])
*phases_[phasei].rho()*fvc::interpolate(phases_[phasei].nu());
}
return tmuf;
}
Foam::tmp<Foam::volScalarField>
Foam::incompressibleMultiphaseVoFMixture::nu() const
{
return nu_;
}
Foam::tmp<Foam::scalarField>
Foam::incompressibleMultiphaseVoFMixture::nu(const label patchi) const
{
return nu_.boundaryField()[patchi];
}
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleMultiphaseVoFMixture::nuf() const
{
return muf()/fvc::interpolate(rho());
}
void Foam::incompressibleMultiphaseVoFMixture::correct()
{
forAll(phases_, phasei)
{
phases_[phasei].correct();
}
rho_ = phases_[0]*phases_[0].rho();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
rho_ += phases_[phasei]*phases_[phasei].rho();
}
// Update the mixture kinematic viscosity
nu_ = mu()/rho();
calcAlphas();
}
bool Foam::incompressibleMultiphaseVoFMixture::read()
{
if (regIOobject::read())
{
lookup("sigmas") >> sigmas_;
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressibleMultiphaseVoFMixture
Description
Incompressible multiphase mixture for interface-capturing simulations.
Derived from viscosity so that it can be used in conjunction with the
incompressible turbulence models.
Surface tension and contact-angle is handled for the interface between each
phase-pair.
SourceFiles
incompressibleMultiphaseVoFMixture.C
See also
Foam::multiphaseVoFMixture
Foam::incompressibleVoFphase
\*---------------------------------------------------------------------------*/
#ifndef incompressibleMultiphaseVoFMixture_H
#define incompressibleMultiphaseVoFMixture_H
#include "multiphaseVoFMixture.H"
#include "viscosity.H"
#include "UPtrListDictionary.H"
#include "incompressibleVoFphase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class incompressibleMultiphaseVoFMixture Declaration
\*---------------------------------------------------------------------------*/
class incompressibleMultiphaseVoFMixture
:
public multiphaseVoFMixture,
public viscosity
{
// Private Data
//- Dictionary of phases
UPtrListDictionary<incompressibleVoFphase> phases_;
//- Mixture density
volScalarField rho_;
//- Mixture viscosity
volScalarField nu_;
public:
TypeName("incompressibleMultiphaseVoFMixture");
// Constructors
//- Construct from components
incompressibleMultiphaseVoFMixture(const fvMesh& mesh);
//- Destructor
virtual ~incompressibleMultiphaseVoFMixture()
{}
// Member Functions
//- Return the phases
UPtrListDictionary<incompressibleVoFphase>& phases()
{
return phases_;
}
//- Return the mixture density
virtual const volScalarField& rho() const
{
return rho_;
}
//- Return the dynamic laminar viscosity
tmp<volScalarField> mu() const;
//- Return the dynamic laminar viscosity for patch
tmp<scalarField> mu(const label patchi) const;
//- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> muf() const;
//- Return the kinematic laminar viscosity
virtual tmp<volScalarField> nu() const;
//- Return the laminar viscosity for patch
virtual tmp<scalarField> nu(const label patchi) const;
//- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> nuf() const;
//- Correct the mixture properties
virtual void correct();
//- Read base phaseProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,17 +23,17 @@ License
\*---------------------------------------------------------------------------*/
#include "incompressiblePhase.H"
#include "incompressibleVoFphase.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::incompressiblePhase::incompressiblePhase
Foam::incompressibleVoFphase::incompressibleVoFphase
(
const word& name,
const fvMesh& mesh
)
:
phase(name, mesh),
VoFphase(name, mesh),
nuModel_(viscosityModel::New(mesh, name)),
rho_("rho", dimDensity, nuModel_())
{}
@ -41,21 +41,20 @@ Foam::incompressiblePhase::incompressiblePhase
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::incompressiblePhase>
Foam::incompressiblePhase::clone() const
Foam::autoPtr<Foam::VoFphase> Foam::incompressibleVoFphase::clone() const
{
NotImplemented;
return autoPtr<incompressiblePhase>(nullptr);
return autoPtr<VoFphase>(nullptr);
}
void Foam::incompressiblePhase::correct()
void Foam::incompressibleVoFphase::correct()
{
nuModel_->correct();
}
bool Foam::incompressiblePhase::read(const dictionary& dict)
bool Foam::incompressibleVoFphase::read(const dictionary& dict)
{
dict.lookup("rho") >> rho_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,24 +22,27 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressiblePhase
Foam::incompressibleVoFphase
Description
Single incompressible phase derived from the phase.
Single incompressible phase derived from the VoFphase.
Used as part of the multiphaseMixture for interface-capturing
multiphase simulations.
Used in incompressibleMultiphaseVoFMixture for multiphase
interface-capturing simulations.
SourceFiles
incompressiblePhase.C
incompressibleVoFphase.C
See also
Foam::VoFphase
Foam::incompressibleMultiphaseVoFMixture
\*---------------------------------------------------------------------------*/
#ifndef incompressiblePhase_H
#define incompressiblePhase_H
#ifndef incompressibleVoFphase_H
#define incompressibleVoFphase_H
#include "phase.H"
#include "dictionaryEntry.H"
#include "VoFphase.H"
#include "viscosityModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,16 +51,19 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class incompressiblePhase Declaration
Class incompressibleVoFphase Declaration
\*---------------------------------------------------------------------------*/
class incompressiblePhase
class incompressibleVoFphase
:
public phase
public VoFphase
{
// Private Data
//- Phase viscosity model
autoPtr<viscosityModel> nuModel_;
//- Phase density
dimensionedScalar rho_;
@ -66,35 +72,35 @@ public:
// Constructors
//- Construct from components
incompressiblePhase
incompressibleVoFphase
(
const word& name,
const fvMesh& mesh
);
//- Return clone
autoPtr<incompressiblePhase> clone() const;
virtual autoPtr<VoFphase> clone() const;
//- Return a pointer to a new incompressiblePhase created on freestore
// from Istream
//- Return a pointer to a new incompressibleVoFphase
// created on freestore from Istream
class iNew
:
public VoFphase::iNew
{
const fvMesh& mesh_;
public:
iNew(const fvMesh& mesh)
:
mesh_(mesh)
VoFphase::iNew(mesh)
{}
autoPtr<incompressiblePhase> operator()(Istream& is) const
virtual autoPtr<VoFphase> operator()(Istream& is) const
{
const word name(is);
return autoPtr<incompressiblePhase>
return autoPtr<VoFphase>
(
new incompressiblePhase(name, mesh_)
new incompressibleVoFphase(name, mesh_)
);
}
};
@ -102,7 +108,7 @@ public:
// Member Functions
//- Return const-access to incompressiblePhase1 viscosityModel
//- Return const-access to incompressibleVoFphase1 viscosityModel
const viscosityModel& nuModel() const
{
return nuModel_();
@ -120,20 +126,17 @@ public:
return nuModel_->nu(patchi);
}
//- Return const-access to incompressiblePhase1 density
//- Return const-access to incompressibleVoFphase1 density
const dimensionedScalar& rho() const
{
return rho_;
}
//- Correct the incompressiblePhase properties
//- Correct the incompressibleVoFphase properties
void correct();
//- Inherit read from phase
using phase::read;
//- Read base incompressiblePhaseProperties dictionary
bool read(const dictionary& incompressiblePhaseDict);
//- Read base incompressibleVoFphaseProperties dictionary
bool read(const dictionary& incompressibleVoFphaseDict);
};

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "incompressibleMultiphaseVoF.H"
#include "constrainHbyA.H"
#include "constrainPressure.H"
#include "adjustPhi.H"
#include "findRefCell.H"
#include "fvcMeshPhi.H"
#include "fvcFlux.H"
#include "fvcDdt.H"
#include "fvcSnGrad.H"
#include "fvcReconstruct.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::incompressibleMultiphaseVoF::pressureCorrector()
{
fvVectorMatrix& UEqn = tUEqn.ref();
if (rAU.valid())
{
rAU.ref() = 1.0/UEqn.A();
}
else
{
rAU = 1.0/UEqn.A();
}
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU()));
while (pimple.correct())
{
volVectorField HbyA(constrainHbyA(rAU()*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU())*fvc::ddtCorr(U, phi, Uf))
);
MRF.makeRelative(phiHbyA);
if (p_rgh.needReference())
{
fvc::makeRelative(phiHbyA, U);
adjustPhi(phiHbyA, U, p_rgh);
fvc::makeAbsolute(phiHbyA, U);
}
surfaceScalarField phig
(
(
mixture.surfaceTensionForce(U)
- buoyancy.ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Cache the phase change pressure source
fvScalarMatrix Sp_rgh
(
fvModels().source
(
volScalarField::New
(
"1",
mesh,
dimensionedScalar(dimless/dimPressure, 1)
),
p_rgh
)
);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
== Sp_rgh
);
p_rghEqn.setReference
(
pressureReference().refCell(),
getRefCellValue(p_rgh, pressureReference().refCell())
);
p_rghEqn.solve();
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA + p_rghEqn.flux();
p_rgh.relax();
U = HbyA
+ rAU()*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
fvConstraints().constrain(U);
}
}
continuityErrors();
// Correct Uf if the mesh is moving
fvc::correctUf(Uf, U, phi, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
p == p_rgh + rho*buoyancy.gh;
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pressureReference().refValue()
- getRefCellValue(p, pressureReference().refCell())
);
p_rgh = p - rho*buoyancy.gh;
}
}
if (!correctPhi)
{
rAU.clear();
}
tUEqn.clear();
}
// ************************************************************************* //

View File

@ -0,0 +1,7 @@
multiphaseVoFMixture/VoFphase/VoFphase.C
multiphaseVoFMixture/multiphaseVoFMixture.C
setInterfaceRDeltaT.C
#alphaPredictor.C
multiphaseVoFSolver.C
LIB = $(FOAM_LIBBIN)/libmultiphaseVoFSolver

View File

@ -0,0 +1,20 @@
EXE_INC = \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/multiphaseModels/multiphaseProperties/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lVoFSolver \
-lfluidSolver \
-lphysicalProperties \
-lmultiphaseProperties \
-linterfaceCompression \
-lfiniteVolume \
-lmeshTools \
-lfvModels \
-lfvConstraints \
-lsampling

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VoFphase.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::VoFphase::VoFphase(const word& phaseName, const fvMesh& mesh)
:
volScalarField
(
IOobject
(
IOobject::groupName("alpha", phaseName),
mesh.time().name(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
),
name_(phaseName)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::VoFphase> Foam::VoFphase::clone() const
{
NotImplemented;
return autoPtr<VoFphase>(nullptr);
}
// ************************************************************************* //

View File

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::VoFphase
Description
Single incompressible VoFphase derived from the phase-fraction.
Used as part of the multiPhaseMixture for interface-capturing multi-VoFphase
simulations.
SourceFiles
VoFphase.C
\*---------------------------------------------------------------------------*/
#ifndef VoFphase_H
#define VoFphase_H
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class VoFphase Declaration
\*---------------------------------------------------------------------------*/
class VoFphase
:
public volScalarField
{
// Private Data
word name_;
public:
// Constructors
//- Construct from components
VoFphase
(
const word& name,
const fvMesh& mesh
);
//- Return clone
virtual autoPtr<VoFphase> clone() const;
//- Return a pointer to a new VoFphase
// created on freestore
// from Istream
class iNew
{
protected:
const fvMesh& mesh_;
public:
iNew(const fvMesh& mesh)
:
mesh_(mesh)
{}
virtual ~iNew()
{}
virtual autoPtr<VoFphase> operator()(Istream& is) const = 0;
};
// Member Functions
const word& name() const
{
return name_;
}
const word& keyword() const
{
return name();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,258 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "multiphaseVoFMixture.H"
#include "correctContactAngle.H"
#include "surfaceInterpolate.H"
#include "fvcGrad.H"
#include "fvcSnGrad.H"
#include "fvcDiv.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(multiphaseVoFMixture, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::multiphaseVoFMixture::calcAlphas()
{
scalar level = 0.0;
alphas_ == 0.0;
forAll(phases_, phasei)
{
alphas_ += level*phases_[phasei];
level += 1.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::multiphaseVoFMixture::multiphaseVoFMixture
(
const fvMesh& mesh,
const VoFphase::iNew& inew
)
:
VoFMixture(mesh),
IOdictionary
(
IOobject
(
"phaseProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
phases_(lookup("phases"), inew),
mesh_(mesh),
alphas_
(
IOobject
(
"alphas",
mesh_.time().name(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(dimless, 0)
),
sigmas_(lookup("sigmas")),
dimSigma_(1, 0, -2, 0, 0),
deltaN_
(
"deltaN",
1e-8/pow(average(mesh_.V()), 1.0/3.0)
)
{
calcAlphas();
alphas_.write();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::surfaceScalarField>
Foam::multiphaseVoFMixture::surfaceTensionForce(const volVectorField& U) const
{
tmp<surfaceScalarField> tstf
(
surfaceScalarField::New
(
"surfaceTensionForce",
mesh_,
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), 0)
)
);
surfaceScalarField& stf = tstf.ref();
forAll(phases_, phasei)
{
const VoFphase& alpha1 = phases_[phasei];
for (label phasej = phasei+1; phasej<phases_.size(); phasej++)
{
const VoFphase& alpha2 = phases_[phasej];
sigmaTable::const_iterator sigma =
sigmas_.find(interfacePair(alpha1, alpha2));
if (sigma == sigmas_.end())
{
FatalErrorInFunction
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
<< " in list of sigma values"
<< exit(FatalError);
}
stf += dimensionedScalar(dimSigma_, sigma())
*fvc::interpolate(K(alpha1, alpha2, U))*
(
fvc::interpolate(alpha2)*fvc::snGrad(alpha1)
- fvc::interpolate(alpha1)*fvc::snGrad(alpha2)
);
}
}
return tstf;
}
Foam::tmp<Foam::surfaceVectorField> Foam::multiphaseVoFMixture::nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
/*
// Cell gradient of alpha
volVectorField gradAlpha =
alpha2*fvc::grad(alpha1) - alpha1*fvc::grad(alpha2);
// Interpolated face-gradient of alpha
surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
*/
surfaceVectorField gradAlphaf
(
fvc::interpolate(alpha2)*fvc::interpolate(fvc::grad(alpha1))
- fvc::interpolate(alpha1)*fvc::interpolate(fvc::grad(alpha2))
);
// Face unit interface normal
return gradAlphaf/(mag(gradAlphaf) + deltaN_);
}
Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseVoFMixture::nHatf
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
// Face unit interface normal flux
return nHatfv(alpha1, alpha2) & mesh_.Sf();
}
Foam::tmp<Foam::volScalarField> Foam::multiphaseVoFMixture::K
(
const VoFphase& alpha1,
const VoFphase& alpha2,
const volVectorField& U
) const
{
tmp<surfaceVectorField> tnHatfv = nHatfv(alpha1, alpha2);
correctContactAngle
(
alpha1,
alpha2,
U.boundaryField(),
deltaN_,
tnHatfv.ref().boundaryFieldRef()
);
// Simple expression for curvature
return -fvc::div(tnHatfv & mesh_.Sf());
}
Foam::tmp<Foam::volScalarField>
Foam::multiphaseVoFMixture::nearInterface() const
{
tmp<volScalarField> tnearInt
(
volScalarField::New
(
"nearInterface",
mesh_,
dimensionedScalar(dimless, 0)
)
);
forAll(phases_, phasei)
{
tnearInt.ref() = max
(
tnearInt(),
pos0(phases_[phasei] - 0.01)*pos0(0.99 - phases_[phasei])
);
}
return tnearInt;
}
bool Foam::multiphaseVoFMixture::read()
{
if (regIOobject::read())
{
lookup("sigmas") >> sigmas_;
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,32 +22,26 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressibleMultiphaseMixture
Foam::multiphaseVoFMixture
Description
Incompressible multiphase mixture with built in solution for the
phase fractions with interface compression for interface-capturing.
Derived from viscosity so that it can be used in conjunction
with the incompressible turbulence models.
Multiphase VoF mixture with support for interface properties
Surface tension and contact-angle is handled for the interface
between each phase-pair.
SourceFiles
incompressibleMultiphaseMixture.C
multiphaseVoFMixture.C
\*---------------------------------------------------------------------------*/
#ifndef incompressibleMultiphaseMixture_H
#define incompressibleMultiphaseMixture_H
#ifndef multiphaseVoFMixture_H
#define multiphaseVoFMixture_H
#include "viscosity.H"
#include "VoFMixture.H"
#include "IOdictionary.H"
#include "incompressiblePhase.H"
#include "PtrListDictionary.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "VoFphase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,13 +49,13 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class incompressibleMultiphaseMixture Declaration
Class multiphaseVoFMixture Declaration
\*---------------------------------------------------------------------------*/
class incompressibleMultiphaseMixture
class multiphaseVoFMixture
:
public IOdictionary,
public viscosity
public VoFMixture,
public IOdictionary
{
public:
@ -97,7 +91,7 @@ public:
Pair<word>(alpha1Name, alpha2Name)
{}
interfacePair(const phase& alpha1, const phase& alpha2)
interfacePair(const VoFphase& alpha1, const VoFphase& alpha2)
:
Pair<word>(alpha1.name(), alpha2.name())
{}
@ -129,22 +123,17 @@ public:
};
private:
protected:
// Private Data
// Protected Data
//- Dictionary of phases
PtrListDictionary<incompressiblePhase> phases_;
PtrListDictionary<VoFphase> phases_;
const fvMesh& mesh_;
const volVectorField& U_;
const surfaceScalarField& phi_;
surfaceScalarField rhoPhi_;
volScalarField alphas_;
volScalarField nu_;
typedef HashTable<scalar, interfacePair, interfacePair::hash>
sigmaTable;
@ -159,101 +148,63 @@ private:
void calcAlphas();
void solveAlphas(const scalar cAlpha);
tmp<surfaceVectorField> nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
tmp<volScalarField> K
(
const VoFphase& alpha1,
const VoFphase& alpha2,
const volVectorField& U
) const;
public:
TypeName("multiphaseVoFMixture");
// Constructors
//- Construct from fvMesh
multiphaseVoFMixture
(
const fvMesh& mesh,
const VoFphase::iNew&
);
//- Destructor
virtual ~multiphaseVoFMixture()
{}
// Member Functions
//- Return the phases
PtrListDictionary<VoFphase>& phases()
{
return phases_;
}
tmp<surfaceScalarField> nHatf
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
tmp<volScalarField> K(const phase& alpha1, const phase& alpha2) const;
public:
// Constructors
//- Construct from components
incompressibleMultiphaseMixture
tmp<surfaceScalarField> surfaceTensionForce
(
const volVectorField& U,
const surfaceScalarField& phi
);
//- Destructor
virtual ~incompressibleMultiphaseMixture()
{}
// Member Functions
//- Return the phases
const PtrListDictionary<incompressiblePhase>& phases() const
{
return phases_;
}
//- Return the velocity
const volVectorField& U() const
{
return U_;
}
//- Return the volumetric flux
const surfaceScalarField& phi() const
{
return phi_;
}
const surfaceScalarField& rhoPhi() const
{
return rhoPhi_;
}
//- Return the mixture density
tmp<volScalarField> rho() const;
//- Return the mixture density for patch
tmp<scalarField> rho(const label patchi) const;
//- Return the dynamic laminar viscosity
tmp<volScalarField> mu() const;
//- Return the dynamic laminar viscosity for patch
tmp<scalarField> mu(const label patchi) const;
//- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> muf() const;
//- Return the kinematic laminar viscosity
tmp<volScalarField> nu() const;
//- Return the laminar viscosity for patch
tmp<scalarField> nu(const label patchi) const;
//- Return the face-interpolated dynamic laminar viscosity
tmp<surfaceScalarField> nuf() const;
tmp<surfaceScalarField> surfaceTensionForce() const;
const volVectorField& U
) const;
//- Indicator of the proximity of the interface
// Field values are 1 near and 0 away for the interface.
tmp<volScalarField> nearInterface() const;
//- Solve for the mixture phase-fractions
void solve();
//- Correct the mixture properties
void correct();
//- Read base phaseProperties dictionary
bool read();
};

View File

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "multiphaseVoFSolver.H"
#include "localEulerDdtScheme.H"
#include "CorrectPhi.H"
#include "geometricZeroField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
defineTypeNameAndDebug(multiphaseVoFSolver, 0);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::multiphaseVoFSolver::correctCoNum()
{
VoFSolver::correctCoNum();
const scalarField sumPhi
(
mixture.nearInterface()().primitiveField()
*fvc::surfaceSum(mag(phi))().primitiveField()
);
alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
const scalar meanAlphaCoNum =
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
Info<< "Interface Courant Number mean: " << meanAlphaCoNum
<< " max: " << alphaCoNum << endl;
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::solvers::multiphaseVoFSolver::correctInterface()
{}
Foam::tmp<Foam::surfaceScalarField>
Foam::solvers::multiphaseVoFSolver::surfaceTensionForce() const
{
return mixture.surfaceTensionForce(U);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solvers::multiphaseVoFSolver::multiphaseVoFSolver
(
fvMesh& mesh,
autoPtr<multiphaseVoFMixture> mixturePtr
)
:
VoFSolver(mesh, autoPtr<VoFMixture>(mixturePtr.ptr())),
mixture(refCast<multiphaseVoFMixture>(VoFSolver::mixture)),
phases(mixture.phases())
{
if (transient())
{
correctCoNum();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solvers::multiphaseVoFSolver::~multiphaseVoFSolver()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::multiphaseVoFSolver::preSolve()
{
VoFSolver::preSolve();
}
void Foam::solvers::multiphaseVoFSolver::prePredictor()
{
VoFSolver::prePredictor();
alphaPredictor();
}
// ************************************************************************* //

View File

@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::solvers::multiphaseVoFSolver
Description
Base solver module for the solution of multiple immiscible fluids using a
VOF (volume of fluid) phase-fraction based interface capturing approach,
with optional mesh motion and mesh topology changes including adaptive
re-meshing.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
pseudo-transient and steady simulations.
SourceFiles
multiphaseVoFSolver.C
See also
Foam::solvers::VoFSolver
Foam::solvers::incompressibleMultiphaseVoFSolver
\*---------------------------------------------------------------------------*/
#ifndef multiphaseVoFSolver_H
#define multiphaseVoFSolver_H
#include "VoFSolver.H"
#include "multiphaseVoFMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
/*---------------------------------------------------------------------------*\
Class multiphaseVoFSolver Declaration
\*---------------------------------------------------------------------------*/
class multiphaseVoFSolver
:
public VoFSolver
{
protected:
// Phase properties
//- Reference to the multiphaseVoFMixture
multiphaseVoFMixture& mixture;
//- Reference to the phases
PtrListDictionary<VoFphase>& phases;
private:
// Private Member Functions
//- Correct the cached Courant numbers
void correctCoNum();
protected:
// Protected Member Functions
//- Adjust the rDeltaT in the vicinity of the interface
virtual void setInterfaceRDeltaT(volScalarField& rDeltaT);
//- Solve for the phase-fractions
virtual void alphaPredictor() = 0;
//- Correct the interface properties following mesh-change
// and phase-fraction update
virtual void correctInterface();
//- Return the interface surface tension force for the momentum equation
virtual tmp<surfaceScalarField> surfaceTensionForce() const;
public:
//- Runtime type information
TypeName("multiphaseVoFSolver");
// Constructors
//- Construct from region mesh
multiphaseVoFSolver(fvMesh& mesh, autoPtr<multiphaseVoFMixture>);
//- Disallow default bitwise copy construction
multiphaseVoFSolver(const multiphaseVoFSolver&) = delete;
//- Destructor
virtual ~multiphaseVoFSolver();
// Member Functions
//- Called at the start of the time-step, before the PIMPLE loop
virtual void preSolve();
//- Called at the start of the PIMPLE loop
virtual void prePredictor();
// Member Operators
//- Disallow default bitwise assignment
void operator=(const multiphaseVoFSolver&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solvers
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "multiphaseVoFSolver.H"
#include "fvcSmooth.H"
#include "fvcSurfaceIntegrate.H"
#include "fvcAverage.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::multiphaseVoFSolver::setInterfaceRDeltaT
(
volScalarField& rDeltaT
)
{
const dictionary& pimpleDict = pimple.dict();
const scalar maxCo
(
pimpleDict.lookupOrDefault<scalar>("maxCo", 0.9)
);
const scalar maxAlphaCo
(
pimpleDict.lookupOrDefault<scalar>("maxAlphaCo", 0.2)
);
const scalar rDeltaTSmoothingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
const scalar alphaSpreadMax
(
pimpleDict.lookupOrDefault<scalar>("alphaSpreadMax", 0.99)
);
const scalar alphaSpreadMin
(
pimpleDict.lookupOrDefault<scalar>("alphaSpreadMin", 0.01)
);
if (maxAlphaCo < maxCo)
{
// Further limit the reciprocal time-step
// in the vicinity of the interface
const volScalarField::Internal alphaCoRdeltaT
(
fvc::surfaceSum(mag(phi))()()/((2*maxAlphaCo)*mesh.V())
);
forAll(phases, phasei)
{
const volScalarField alphaBar(fvc::average(phases[phasei]));
rDeltaT.ref() = max
(
rDeltaT(),
pos0(alphaBar() - alphaSpreadMin)
*pos0(alphaSpreadMax - alphaBar())
*alphaCoRdeltaT
);
}
}
// Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
Info<< "Flow and interface time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
if (rDeltaTSmoothingCoeff < 1.0)
{
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
}
Info<< "Smoothed flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}
// ************************************************************************* //

View File

@ -1,12 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
multiphaseInterFoam/Allwmake $targetType $*
compressibleMultiphaseInterFoam/Allwmake $targetType $*
driftFluxFoam/Allwmake $targetType $*
wmake $targetType cavitatingFoam
#------------------------------------------------------------------------------

View File

@ -1,5 +1,4 @@
EXE_INC = \
-I$(FOAM_SOLVERS)/multiphase/multiphaseInterFoam/incompressibleMultiphaseMixture/lnInclude \
-IcompressibleMultiphaseMixture/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \

View File

@ -1,3 +1,4 @@
phase/phase.C
compressiblePhase/compressiblePhase.C
compressibleMultiphaseMixture.C

View File

@ -1,5 +1,4 @@
EXE_INC = \
-I$(FOAM_SOLVERS)/multiphase/multiphaseInterFoam/incompressibleMultiphaseMixture/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/multiphaseModels/multiphaseProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
@ -7,7 +6,6 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lincompressibleMultiphaseMixture \
-lfluidThermophysicalModels \
-lmultiphaseProperties \
-lspecie \

View File

@ -1,7 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
wclean libso incompressibleMultiphaseMixture
wclean
#------------------------------------------------------------------------------

View File

@ -1,10 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
wmake $targetType incompressibleMultiphaseMixture
wmake $targetType
#------------------------------------------------------------------------------

View File

@ -1,3 +0,0 @@
multiphaseInterFoam.C
EXE = $(FOAM_APPBIN)/multiphaseInterFoam

View File

@ -1,31 +0,0 @@
fvVectorMatrix UEqn
(
fvm::ddt(rho, U) + fvm::div(rhoPhi, U)
+ MRF.DDt(rho, U)
+ turbulence->divDevTau(rho, U)
==
fvModels.source(rho, U)
);
UEqn.relax();
fvConstraints.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve
(
UEqn
==
fvc::reconstruct
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
- fvc::snGrad(p_rgh)
) * mesh.magSf()
)
);
fvConstraints.constrain(U);
}

View File

@ -1,21 +0,0 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
CorrectPhi
(
phi,
U,
p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(),
pressureReference,
pimple
);
#include "continuityErrs.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);

View File

@ -1,90 +0,0 @@
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.name(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.name(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "createPhi.H"
incompressibleMultiphaseMixture mixture(U, phi);
// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT
),
mixture.rho()
);
rho.oldTime();
// Construct incompressible turbulence model
autoPtr<incompressible::momentumTransportModel> turbulence
(
incompressible::momentumTransportModel::New(U, phi, mixture)
);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
volScalarField p
(
IOobject
(
"p",
runTime.name(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh + rho*gh
);
pressureReference pressureReference(p, p_rgh, pimple.dict());
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pressureReference.refValue()
- getRefCellValue(p, pressureReference.refCell())
);
p_rgh = p - rho*gh;
}
mesh.schemes().setFluxRequired(p_rgh.name());
#include "createMRF.H"
#include "createFvModels.H"
#include "createFvConstraints.H"

View File

@ -1,5 +0,0 @@
phase/phase.C
incompressiblePhase/incompressiblePhase.C
incompressibleMultiphaseMixture.C
LIB = $(FOAM_LIBBIN)/libincompressibleMultiphaseMixture

View File

@ -1,14 +0,0 @@
EXE_INC = \
-IalphaContactAngle \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/multiphaseModels/multiphaseProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-linterfaceProperties \
-lphysicalProperties \
-lmultiphaseProperties \
-lfiniteVolume \
-lmeshTools

View File

@ -1,595 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "incompressibleMultiphaseMixture.H"
#include "alphaContactAngleFvPatchScalarField.H"
#include "correctContactAngle.H"
#include "Time.H"
#include "subCycle.H"
#include "MULES.H"
#include "surfaceInterpolate.H"
#include "fvcGrad.H"
#include "fvcSnGrad.H"
#include "fvcDiv.H"
#include "fvcFlux.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::incompressibleMultiphaseMixture::calcAlphas()
{
scalar level = 0.0;
alphas_ == 0.0;
forAll(phases_, phasei)
{
alphas_ += level*phases_[phasei];
level += 1.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::incompressibleMultiphaseMixture::incompressibleMultiphaseMixture
(
const volVectorField& U,
const surfaceScalarField& phi
)
:
IOdictionary
(
IOobject
(
"phaseProperties",
U.time().constant(),
U.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
phases_(lookup("phases"), incompressiblePhase::iNew(U.mesh())),
mesh_(U.mesh()),
U_(U),
phi_(phi),
rhoPhi_
(
IOobject
(
"rhoPhi",
mesh_.time().name(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar(dimMass/dimTime, 0)
),
alphas_
(
IOobject
(
"alphas",
mesh_.time().name(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(dimless, 0)
),
nu_
(
IOobject
(
"nu",
mesh_.time().name(),
mesh_
),
mu()/rho()
),
sigmas_(lookup("sigmas")),
dimSigma_(1, 0, -2, 0, 0),
deltaN_
(
"deltaN",
1e-8/pow(average(mesh_.V()), 1.0/3.0)
)
{
calcAlphas();
alphas_.write();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::incompressibleMultiphaseMixture::rho() const
{
tmp<volScalarField> trho
(
phases_[0]*phases_[0].rho()
);
volScalarField& rho = trho.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
rho += phases_[phasei]*phases_[phasei].rho();
}
return trho;
}
Foam::tmp<Foam::scalarField>
Foam::incompressibleMultiphaseMixture::rho(const label patchi) const
{
tmp<scalarField> trho
(
phases_[0].boundaryField()[patchi]*phases_[0].rho().value()
);
scalarField& rho = trho.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
rho +=
phases_[phasei].boundaryField()[patchi]
*phases_[phasei].rho().value();
}
return trho;
}
Foam::tmp<Foam::volScalarField>
Foam::incompressibleMultiphaseMixture::mu() const
{
tmp<volScalarField> tmu
(
phases_[0]*phases_[0].rho()*phases_[0].nu()
);
volScalarField& mu = tmu.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
mu += phases_[phasei]*phases_[phasei].rho()*phases_[phasei].nu();
}
return tmu;
}
Foam::tmp<Foam::scalarField>
Foam::incompressibleMultiphaseMixture::mu(const label patchi) const
{
tmp<scalarField> tmu
(
phases_[0].boundaryField()[patchi]
*phases_[0].rho().value()
*phases_[0].nu(patchi)
);
scalarField& mu = tmu.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
mu +=
phases_[phasei].boundaryField()[patchi]
*phases_[phasei].rho().value()
*phases_[phasei].nu(patchi);
}
return tmu;
}
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleMultiphaseMixture::muf() const
{
tmp<surfaceScalarField> tmuf
(
fvc::interpolate(phases_[0])
*phases_[0].rho()*fvc::interpolate(phases_[0].nu())
);
surfaceScalarField& muf = tmuf.ref();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
muf +=
fvc::interpolate(phases_[phasei])
*phases_[phasei].rho()*fvc::interpolate(phases_[phasei].nu());
}
return tmuf;
}
Foam::tmp<Foam::volScalarField>
Foam::incompressibleMultiphaseMixture::nu() const
{
return nu_;
}
Foam::tmp<Foam::scalarField>
Foam::incompressibleMultiphaseMixture::nu(const label patchi) const
{
return nu_.boundaryField()[patchi];
}
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleMultiphaseMixture::nuf() const
{
return muf()/fvc::interpolate(rho());
}
Foam::tmp<Foam::surfaceScalarField>
Foam::incompressibleMultiphaseMixture::surfaceTensionForce() const
{
tmp<surfaceScalarField> tstf
(
surfaceScalarField::New
(
"surfaceTensionForce",
mesh_,
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), 0)
)
);
surfaceScalarField& stf = tstf.ref();
forAll(phases_, phasei)
{
const incompressiblePhase& alpha1 = phases_[phasei];
for (label phasej = phasei+1; phasej<phases_.size(); phasej++)
{
const incompressiblePhase& alpha2 = phases_[phasej];
sigmaTable::const_iterator sigma =
sigmas_.find(interfacePair(alpha1, alpha2));
if (sigma == sigmas_.end())
{
FatalErrorInFunction
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
<< " in list of sigma values"
<< exit(FatalError);
}
stf += dimensionedScalar(dimSigma_, sigma())
*fvc::interpolate(K(alpha1, alpha2))*
(
fvc::interpolate(alpha2)*fvc::snGrad(alpha1)
- fvc::interpolate(alpha1)*fvc::snGrad(alpha2)
);
}
}
return tstf;
}
void Foam::incompressibleMultiphaseMixture::solve()
{
correct();
const Time& runTime = mesh_.time();
const dictionary& alphaControls = mesh_.solution().solverDict("alpha");
label nAlphaSubCycles(alphaControls.lookup<label>("nAlphaSubCycles"));
scalar cAlpha(alphaControls.lookup<scalar>("cAlpha"));
if (nAlphaSubCycles > 1)
{
surfaceScalarField rhoPhiSum
(
IOobject
(
"rhoPhiSum",
runTime.name(),
mesh_
),
mesh_,
dimensionedScalar(rhoPhi_.dimensions(), 0)
);
dimensionedScalar totalDeltaT = runTime.deltaT();
List<volScalarField*> alphaPtrs(phases_.size());
forAll(phases_, phasei)
{
alphaPtrs[phasei] = &phases_[phasei];
}
for
(
subCycle<volScalarField, subCycleFields> alphaSubCycle
(
alphaPtrs,
nAlphaSubCycles
);
!(++alphaSubCycle).end();
)
{
solveAlphas(cAlpha);
rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi_;
}
rhoPhi_ = rhoPhiSum;
}
else
{
solveAlphas(cAlpha);
}
// Update the mixture kinematic viscosity
nu_ = mu()/rho();
}
void Foam::incompressibleMultiphaseMixture::correct()
{
forAll(phases_, phasei)
{
phases_[phasei].correct();
}
}
Foam::tmp<Foam::surfaceVectorField>
Foam::incompressibleMultiphaseMixture::nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
/*
// Cell gradient of alpha
volVectorField gradAlpha =
alpha2*fvc::grad(alpha1) - alpha1*fvc::grad(alpha2);
// Interpolated face-gradient of alpha
surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
*/
surfaceVectorField gradAlphaf
(
fvc::interpolate(alpha2)*fvc::interpolate(fvc::grad(alpha1))
- fvc::interpolate(alpha1)*fvc::interpolate(fvc::grad(alpha2))
);
// Face unit interface normal
return gradAlphaf/(mag(gradAlphaf) + deltaN_);
}
Foam::tmp<Foam::surfaceScalarField> Foam::incompressibleMultiphaseMixture::nHatf
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
// Face unit interface normal flux
return nHatfv(alpha1, alpha2) & mesh_.Sf();
}
Foam::tmp<Foam::volScalarField> Foam::incompressibleMultiphaseMixture::K
(
const phase& alpha1,
const phase& alpha2
) const
{
tmp<surfaceVectorField> tnHatfv = nHatfv(alpha1, alpha2);
correctContactAngle
(
alpha1,
alpha2,
U_.boundaryField(),
deltaN_,
tnHatfv.ref().boundaryFieldRef()
);
// Simple expression for curvature
return -fvc::div(tnHatfv & mesh_.Sf());
}
Foam::tmp<Foam::volScalarField>
Foam::incompressibleMultiphaseMixture::nearInterface() const
{
tmp<volScalarField> tnearInt
(
volScalarField::New
(
"nearInterface",
mesh_,
dimensionedScalar(dimless, 0)
)
);
forAll(phases_, phasei)
{
tnearInt.ref() = max
(
tnearInt(),
pos0(phases_[phasei] - 0.01)*pos0(0.99 - phases_[phasei])
);
}
return tnearInt;
}
void Foam::incompressibleMultiphaseMixture::solveAlphas
(
const scalar cAlpha
)
{
word alphaScheme("div(phi,alpha)");
word alpharScheme("div(phirb,alpha)");
surfaceScalarField phic(mag(phi_/mesh_.magSf()));
phic = min(cAlpha*phic, max(phic));
UPtrList<const volScalarField> alphas(phases_.size());
PtrList<surfaceScalarField> alphaPhis(phases_.size());
forAll(phases_, phasei)
{
const incompressiblePhase& alpha = phases_[phasei];
alphas.set(phasei, &alpha);
alphaPhis.set
(
phasei,
new surfaceScalarField
(
"phi" + alpha.name() + "Corr",
fvc::flux
(
phi_,
alpha,
alphaScheme
)
)
);
surfaceScalarField& alphaPhi = alphaPhis[phasei];
forAll(phases_, phasej)
{
incompressiblePhase& alpha2 = phases_[phasej];
if (&alpha2 == &alpha) continue;
surfaceScalarField phir(phic*nHatf(alpha, alpha2));
alphaPhi += fvc::flux
(
-fvc::flux(-phir, alpha2, alpharScheme),
alpha,
alpharScheme
);
}
// Limit alphaPhi for each phase
MULES::limit
(
1.0/mesh_.time().deltaT().value(),
geometricOneField(),
alpha,
phi_,
alphaPhi,
zeroField(),
zeroField(),
oneField(),
zeroField(),
false
);
}
MULES::limitSum(alphas, alphaPhis, phi_);
rhoPhi_ = dimensionedScalar(dimensionSet(1, 0, -1, 0, 0), 0);
volScalarField sumAlpha
(
IOobject
(
"sumAlpha",
mesh_.time().name(),
mesh_
),
mesh_,
dimensionedScalar(dimless, 0)
);
forAll(phases_, phasei)
{
incompressiblePhase& alpha = phases_[phasei];
surfaceScalarField& alphaPhi = alphaPhis[phasei];
MULES::explicitSolve
(
geometricOneField(),
alpha,
alphaPhi
);
rhoPhi_ += alphaPhi*alpha.rho();
Info<< alpha.name() << " volume fraction, min, max = "
<< alpha.weightedAverage(mesh_.V()).value()
<< ' ' << min(alpha).value()
<< ' ' << max(alpha).value()
<< endl;
sumAlpha += alpha;
}
Info<< "Phase-sum volume fraction, min, max = "
<< sumAlpha.weightedAverage(mesh_.V()).value()
<< ' ' << min(sumAlpha).value()
<< ' ' << max(sumAlpha).value()
<< endl;
// Correct the sum of the phase-fractions to avoid 'drift'
volScalarField sumCorr(1.0 - sumAlpha);
forAll(phases_, phasei)
{
incompressiblePhase& alpha = phases_[phasei];
alpha += alpha*sumCorr;
}
calcAlphas();
}
bool Foam::incompressibleMultiphaseMixture::read()
{
if (regIOobject::read())
{
lookup("sigmas") >> sigmas_;
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -1,50 +0,0 @@
tmp<volScalarField> rAU;
if (correctPhi)
{
rAU = new volScalarField
(
IOobject
(
"rAU",
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimTime/dimDensity, 1)
);
correctUphiBCs(U, phi, true);
CorrectPhi
(
phi,
U,
p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(),
pressureReference,
pimple
);
#include "continuityErrs.H"
}
else
{
correctUphiBCs(U, phi, true);
CorrectPhi
(
phi,
U,
p_rgh,
dimensionedScalar(dimTime/rho.dimensions(), 1),
geometricZeroField(),
pressureReference,
pimple
);
#include "continuityErrs.H"
}

View File

@ -1,159 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Application
multiphaseInterFoam
Description
Solver for n incompressible fluids which captures the interfaces and
includes surface-tension and contact-angle effects for each phase, with
optional mesh motion and mesh topology changes.
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "incompressibleMultiphaseMixture.H"
#include "incompressibleMomentumTransportModels.H"
#include "pimpleControl.H"
#include "pressureReference.H"
#include "fvModels.H"
#include "fvConstraints.H"
#include "CorrectPhi.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
#include "createFields.H"
#include "initCorrectPhi.H"
#include "createUfIfPresent.H"
turbulence->validate();
#include "CourantNo.H"
#include "setInitialDeltaT.H"
const surfaceScalarField& rhoPhi(mixture.rhoPhi());
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (pimple.run(runTime))
{
#include "readDyMControls.H"
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
fvModels.preUpdateMesh();
// Update the mesh for topology change, mesh to mesh mapping
mesh.update();
runTime++;
Info<< "Time = " << runTime.userTimeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstPimpleIter() || pimple.moveMeshOuterCorrectors())
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
// Move the mesh
mesh.move();
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
MRF.update();
if (correctPhi)
{
#include "correctPhi.H"
}
mixture.correct();
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
}
fvModels.correct();
mixture.solve();
rho = mixture.rho();
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.correctTransport())
{
turbulence->correct();
}
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,94 +0,0 @@
{
if (rAU.valid())
{
rAU.ref() = 1.0/UEqn.A();
}
else
{
rAU = 1.0/UEqn.A();
}
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU()));
volVectorField HbyA(constrainHbyA(rAU()*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU())*fvc::ddtCorr(U, phi, Uf))
);
MRF.makeRelative(phiHbyA);
if (p_rgh.needReference())
{
fvc::makeRelative(phiHbyA, U);
adjustPhi(phiHbyA, U, p_rgh);
fvc::makeAbsolute(phiHbyA, U);
}
surfaceScalarField phig
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
);
p_rghEqn.setReference
(
pressureReference.refCell(),
getRefCellValue(p_rgh, pressureReference.refCell())
);
p_rghEqn.solve();
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA - p_rghEqn.flux();
p_rgh.relax();
U = HbyA + rAU()*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
fvConstraints.constrain(U);
}
}
#include "continuityErrs.H"
// Correct Uf if the mesh is moving
fvc::correctUf(Uf, U, phi, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
p == p_rgh + rho*gh;
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pressureReference.refValue()
- getRefCellValue(p, pressureReference.refCell())
);
p_rgh = p - rho*gh;
}
if (!correctPhi)
{
rAU.clear();
}
}

46
bin/multiphaseInterFoam Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | Website: https://openfoam.org
# \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# multiphaseInterFoam
#
# Description
# Script to inform the user that multiphaseInterFoam has been superseded
# and replaced by the more general incompressibleMultiphaseVoF solver module
# executed by the foamRun application.
#
#------------------------------------------------------------------------------
cat <<EOF
multiphaseInterFoam has been superseded and replaced by the more general
incompressibleMultiphaseVoF solver module executed by the foamRun application:
foamRun -solver incompressibleMultiphaseVoF
EOF
exec env foamRun -solver incompressibleMultiphaseVoF "$@"
#------------------------------------------------------------------------------

View File

@ -2184,31 +2184,6 @@ _mshToFoam_ ()
}
complete -o filenames -o nospace -F _mshToFoam_ mshToFoam
_multiphaseInterFoam_ ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
local line=${COMP_LINE}
local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ")
opts="-case -doc -fileHandler -help -hostRoots -libs -listFunctionObjects -listFvConstraints -listFvModels -listMomentumTransportModels -listScalarBCs -listSwitches -listVectorBCs -noFunctionObjects -parallel -postProcess -roots -srcDoc"
for o in $used ; do opts="${opts/$o/}" ; done
extra=""
[ "$COMP_CWORD" = 1 ] || \
case "$prev" in
-case)
opts="" ; extra="-d" ;;
-fileHandler)
opts="uncollated collated masterUncollated" ; extra="" ;;
-hostRoots|-libs|-roots)
opts="" ; extra="" ;;
*) ;;
esac
COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) )
}
complete -o filenames -o nospace -F _multiphaseInterFoam_ multiphaseInterFoam
_netgenNeutralToFoam_ ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"

View File

@ -14,7 +14,9 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application multiphaseInterFoam;
application foamRun;
solver incompressibleMultiphaseVoF;
startFrom startTime;

View File

@ -14,7 +14,9 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application multiphaseInterFoam;
application foamRun;
solver incompressibleMultiphaseVoF;
startFrom startTime;
@ -32,7 +34,7 @@ writeInterval 0.01;
purgeWrite 0;
writeFormat ascii;
writeFormat binary;
writePrecision 6;

Some files were not shown because too many files have changed in this diff Show More