solvers::compressibleMultiphaseVoF: New solver module for compressible multiphase VoF simulations

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

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

Class
    Foam::solvers::compressibleMultiphaseVoF

Description
    Solver module for the solution of multiple compressible, 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
    compressibleMultiphaseVoF.C

See also
    Foam::solvers::VoFSolver
    Foam::solvers::multiphaseVoFSolver
This commit is contained in:
Henry Weller
2023-01-10 16:01:49 +00:00
parent ffdb211bdc
commit 64e1e4e097
65 changed files with 1601 additions and 1587 deletions

View File

@ -1,7 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
wclean libso compressibleMultiphaseMixture
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 compressibleMultiphaseMixture
wmake $targetType
#------------------------------------------------------------------------------

View File

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

View File

@ -1,25 +0,0 @@
EXE_INC = \
-IcompressibleMultiphaseMixture/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/VoF \
-I$(LIB_SRC)/twoPhaseModels/interfaceCompression/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/compressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lcompressibleMultiphaseMixture \
-lphysicalProperties \
-lfluidThermophysicalModels \
-lspecie \
-linterfaceCompression \
-linterfaceProperties \
-lmomentumTransportModels \
-lcompressibleMomentumTransportModels \
-lfiniteVolume \
-lfvModels \
-lfvConstraints \
-lmeshTools

View File

@ -1,25 +0,0 @@
{
fvScalarMatrix TEqn
(
fvm::ddt(rho, T) + fvm::div(mixture.rhoPhi(), T) - fvm::Sp(contErr, T)
- fvm::laplacian(mixture.alphaEff(turbulence->nut()), T)
+ (
fvc::div(fvc::absolute(phi, U), p)()() // - contErr/rho*p
+ (fvc::ddt(rho, K) + fvc::div(mixture.rhoPhi(), K))()()
- (U()&(fvModels.source(rho, U)&U)()) - contErr*K
)*mixture.rCv()()
==
fvModels.source(rho, T)
);
TEqn.relax();
fvConstraints.constrain(TEqn);
TEqn.solve();
fvConstraints.constrain(T);
mixture.correctThermo();
mixture.correct();
}

View File

@ -1,32 +0,0 @@
fvVectorMatrix UEqn
(
fvm::ddt(rho, U) + fvm::div(mixture.rhoPhi(), U) - fvm::Sp(contErr, U)
+ turbulence->divDevTau(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);
K = 0.5*magSqr(U);
}

View File

@ -1,122 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 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
compressibleMultiphaseInterFoam
Description
Solver for n compressible, non-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.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "compressibleMultiphaseMixture.H"
#include "compressibleMomentumTransportModels.H"
#include "pimpleControl.H"
#include "fvModels.H"
#include "fvConstraints.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createTimeControls.H"
#include "createFields.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
turbulence->validate();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (pimple.run(runTime))
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.userTimeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
fvModels.correct();
mixture.solve();
#include "contErr.H"
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
#include "TEqn.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,5 +0,0 @@
phase/phase.C
compressiblePhase/compressiblePhase.C
compressibleMultiphaseMixture.C
LIB = $(FOAM_LIBBIN)/libcompressibleMultiphaseMixture

View File

@ -1,13 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/multiphaseModels/multiphaseProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lfluidThermophysicalModels \
-lmultiphaseProperties \
-lspecie \
-lfiniteVolume \
-lmeshTools

View File

@ -1,648 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-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 "compressibleMultiphaseMixture.H"
#include "alphaContactAngleFvPatchScalarField.H"
#include "correctContactAngle.H"
#include "Time.H"
#include "subCycle.H"
#include "MULES.H"
#include "fvcDiv.H"
#include "fvcGrad.H"
#include "fvcSnGrad.H"
#include "fvcFlux.H"
#include "fvcMeshPhi.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(compressibleMultiphaseMixture, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::compressibleMultiphaseMixture::calcAlphas()
{
scalar level = 0.0;
alphas_ == 0.0;
forAll(phases_, phasei)
{
alphas_ += level*phases_[phasei];
level += 1.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::compressibleMultiphaseMixture::compressibleMultiphaseMixture
(
const volVectorField& U,
const surfaceScalarField& phi
)
:
IOdictionary
(
IOobject
(
"phaseProperties",
U.time().constant(),
U.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
mesh_(U.mesh()),
p_
(
IOobject
(
"p",
U.mesh().time().name(),
U.mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
U.mesh()
),
T_
(
IOobject
(
"T",
U.mesh().time().name(),
U.mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
U.mesh()
),
phases_(lookup("phases"), compressiblePhase::iNew(T_)),
rho_
(
IOobject
(
"rho",
U.mesh().time().name(),
U.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U.mesh(),
dimensionedScalar("rho", dimDensity, 0)
),
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)
),
sigmas_(lookup("sigmas")),
dimSigma_(1, 0, -2, 0, 0),
deltaN_
(
"deltaN",
1e-8/pow(average(mesh_.V()), 1.0/3.0)
)
{
calcAlphas();
alphas_.write();
correct();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::compressibleMultiphaseMixture::correctThermo()
{
forAll(phases_, phasei)
{
phases_[phasei].correct(p_, T_);
}
}
void Foam::compressibleMultiphaseMixture::correct()
{
rho_ = phases_[0]*phases_[0].thermo().rho();
for (label phasei=1; phasei<phases_.size(); phasei++)
{
rho_ += phases_[phasei]*phases_[phasei].thermo().rho();
}
forAll(phases_, phasei)
{
phases_[phasei].Alpha() =
phases_[phasei]*phases_[phasei].thermo().rho()/rho_;
}
}
void Foam::compressibleMultiphaseMixture::correctRho(const volScalarField& dp)
{
forAll(phases_, phasei)
{
phases_[phasei].thermo().rho() += phases_[phasei].thermo().psi()*dp;
}
}
Foam::tmp<Foam::volScalarField> Foam::compressibleMultiphaseMixture::nu() const
{
volScalarField mu(phases_[0].Alpha()*phases_[0].thermo().mu());
for (label phasei=1; phasei<phases_.size(); phasei++)
{
mu += phases_[phasei].Alpha()*phases_[phasei].thermo().mu();
}
return mu/rho_;
}
Foam::tmp<Foam::scalarField> Foam::compressibleMultiphaseMixture::nu
(
const label patchi
) const
{
scalarField mu
(
phases_[0].Alpha().boundaryField()[patchi]
*phases_[0].thermo().mu(patchi)
);
for (label phasei=1; phasei<phases_.size(); phasei++)
{
mu +=
phases_[phasei].Alpha().boundaryField()[patchi]
*phases_[phasei].thermo().mu(patchi);
}
return mu/rho_.boundaryField()[patchi];
}
Foam::tmp<Foam::volScalarField> Foam::compressibleMultiphaseMixture::alphaEff
(
const volScalarField& nut
) const
{
tmp<volScalarField> talphaEff
(
phases_[0]
*(
phases_[0].thermo().kappa()
+ phases_[0].thermo().rho()*phases_[0].thermo().Cp()*nut
)/phases_[0].thermo().Cv()
);
for (label phasei=1; phasei<phases_.size(); phasei++)
{
talphaEff.ref() +=
phases_[phasei]
*(
phases_[phasei].thermo().kappa()
+ phases_[phasei].thermo().rho()*phases_[phasei].thermo().Cp()*nut
)/phases_[phasei].thermo().Cv();
}
return talphaEff;
}
Foam::tmp<Foam::volScalarField> Foam::compressibleMultiphaseMixture::rCv() const
{
tmp<volScalarField> trCv(phases_[0]/phases_[0].thermo().Cv());
for (label phasei=1; phasei<phases_.size(); phasei++)
{
trCv.ref() += phases_[phasei]/phases_[phasei].thermo().Cv();
}
return trCv;
}
Foam::tmp<Foam::surfaceScalarField>
Foam::compressibleMultiphaseMixture::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 compressiblePhase& alpha1 = phases_[phasei];
for (label phasej = phasei+1; phasej<phases_.size(); phasej++)
{
const compressiblePhase& 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::compressibleMultiphaseMixture::solve()
{
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(0.0*rhoPhi_);
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);
}
correct();
}
Foam::tmp<Foam::surfaceVectorField> Foam::compressibleMultiphaseMixture::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::compressibleMultiphaseMixture::nHatf
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
// Face unit interface normal flux
return nHatfv(alpha1, alpha2) & mesh_.Sf();
}
Foam::tmp<Foam::volScalarField> Foam::compressibleMultiphaseMixture::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::compressibleMultiphaseMixture::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::compressibleMultiphaseMixture::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 compressiblePhase& alpha = phases_[phasei];
alphas.set(phasei, &alpha);
alphaPhis.set
(
phasei,
new surfaceScalarField
(
phi_.name() + alpha.name(),
fvc::flux
(
phi_,
alpha,
alphaScheme
)
)
);
surfaceScalarField& alphaPhi = alphaPhis[phasei];
forAll(phases_, phasej)
{
compressiblePhase& 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)
);
volScalarField divU(fvc::div(fvc::absolute(phi_, U_)));
forAll(phases_, phasei)
{
compressiblePhase& alpha = phases_[phasei];
surfaceScalarField& alphaPhi = alphaPhis[phasei];
volScalarField::Internal Sp
(
IOobject
(
"Sp",
mesh_.time().name(),
mesh_
),
mesh_,
dimensionedScalar(alpha.dgdt().dimensions(), 0)
);
volScalarField::Internal Su
(
IOobject
(
"Su",
mesh_.time().name(),
mesh_
),
// Divergence term is handled explicitly to be
// consistent with the explicit transport solution
divU.v()*min(alpha.v(), scalar(1))
);
{
const scalarField& dgdt = alpha.dgdt();
forAll(dgdt, celli)
{
if (dgdt[celli] < 0.0 && alpha[celli] > 0.0)
{
Sp[celli] += dgdt[celli]*alpha[celli];
Su[celli] -= dgdt[celli]*alpha[celli];
}
else if (dgdt[celli] > 0.0 && alpha[celli] < 1.0)
{
Sp[celli] -= dgdt[celli]*(1.0 - alpha[celli]);
}
}
}
forAll(phases_, phasej)
{
const compressiblePhase& alpha2 = phases_[phasej];
if (&alpha2 == &alpha) continue;
const scalarField& dgdt2 = alpha2.dgdt();
forAll(dgdt2, celli)
{
if (dgdt2[celli] > 0.0 && alpha2[celli] < 1.0)
{
Sp[celli] -= dgdt2[celli]*(1.0 - alpha2[celli]);
Su[celli] += dgdt2[celli]*alpha[celli];
}
else if (dgdt2[celli] < 0.0 && alpha2[celli] > 0.0)
{
Sp[celli] += dgdt2[celli]*alpha2[celli];
}
}
}
MULES::explicitSolve
(
geometricOneField(),
alpha,
alphaPhi,
Sp,
Su
);
rhoPhi_ += fvc::interpolate(alpha.thermo().rho())*alphaPhi;
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;
calcAlphas();
}
// ************************************************************************* //

View File

@ -1,295 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-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::compressibleMultiphaseMixture
Description
SourceFiles
compressibleMultiphaseMixture.C
\*---------------------------------------------------------------------------*/
#ifndef compressibleMultiphaseMixture_H
#define compressibleMultiphaseMixture_H
#include "compressiblePhase.H"
#include "PtrListDictionary.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class compressibleMultiphaseMixture Declaration
\*---------------------------------------------------------------------------*/
class compressibleMultiphaseMixture
:
public IOdictionary,
public viscosity
{
public:
class interfacePair
:
public Pair<word>
{
public:
class hash
:
public Hash<interfacePair>
{
public:
hash()
{}
label operator()(const interfacePair& key) const
{
return word::hash()(key.first()) + word::hash()(key.second());
}
};
// Constructors
interfacePair()
{}
interfacePair(const word& alpha1Name, const word& alpha2Name)
:
Pair<word>(alpha1Name, alpha2Name)
{}
interfacePair(const phase& alpha1, const phase& alpha2)
:
Pair<word>(alpha1.name(), alpha2.name())
{}
// Friend Operators
friend bool operator==
(
const interfacePair& a,
const interfacePair& b
)
{
return
(
((a.first() == b.first()) && (a.second() == b.second()))
|| ((a.first() == b.second()) && (a.second() == b.first()))
);
}
friend bool operator!=
(
const interfacePair& a,
const interfacePair& b
)
{
return (!(a == b));
}
};
private:
// Private Data
const fvMesh& mesh_;
//- Pressure
volScalarField p_;
//- Mixture temperature
volScalarField T_;
//- Dictionary of phases
PtrListDictionary<compressiblePhase> phases_;
volScalarField rho_;
const volVectorField& U_;
const surfaceScalarField& phi_;
surfaceScalarField rhoPhi_;
volScalarField alphas_;
typedef HashTable<scalar, interfacePair, interfacePair::hash>
sigmaTable;
sigmaTable sigmas_;
dimensionSet dimSigma_;
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
// Private Member Functions
void calcAlphas();
void solveAlphas(const scalar cAlpha);
tmp<surfaceVectorField> nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
tmp<surfaceScalarField> nHatf
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
tmp<volScalarField> K
(
const phase& alpha1,
const phase& alpha2
) const;
public:
//- Runtime type information
TypeName("compressibleMultiphaseMixture");
// Constructors
//- Construct from components
compressibleMultiphaseMixture
(
const volVectorField& U,
const surfaceScalarField& phi
);
//- Destructor
virtual ~compressibleMultiphaseMixture()
{}
// Member Functions
//- Return the phases
const PtrListDictionary<compressiblePhase>& phases() const
{
return phases_;
}
//- Return non-const access to the phases
PtrListDictionary<compressiblePhase>& phases()
{
return phases_;
}
//- Return pressure [Pa]
volScalarField& p()
{
return p_;
}
//- Return mixture temperature [K]
volScalarField& T()
{
return T_;
}
//- Return mixture density [kg/m^3]
const volScalarField& rho() const
{
return rho_;
}
//- Return mixture velocity
const volVectorField& U() const
{
return U_;
}
//- Return the volumetric flux
const surfaceScalarField& phi() const
{
return phi_;
}
const surfaceScalarField& rhoPhi() const
{
return rhoPhi_;
}
//- Correct the thermodynamics of each phase
virtual void correctThermo();
//- Update properties
virtual void correct();
//- Update densities for given pressure change
void correctRho(const volScalarField& dp);
//- Kinematic viscosity of mixture [m^2/s]
virtual tmp<volScalarField> nu() const;
//- Kinematic viscosity of mixture for patch [m^2/s]
virtual tmp<scalarField> nu(const label patchi) const;
//- Return the effective temperature transport coefficient
// derived from the phase internal energy equations i.e. <kappa/Cv>
virtual tmp<volScalarField> alphaEff
(
const volScalarField& nut
) const;
//- Return the phase-averaged reciprocal Cv
tmp<volScalarField> rCv() const;
tmp<surfaceScalarField> surfaceTensionForce() 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();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,93 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-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 "compressiblePhase.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::compressiblePhase::compressiblePhase
(
const word& name,
const volScalarField& T
)
:
phase(name, T.mesh()),
thermo_(nullptr),
Alpha_
(
IOobject
(
IOobject::groupName("Alpha", name),
T.mesh().time().name(),
T.mesh()
),
T.mesh(),
dimensionedScalar(dimless, 0)
),
dgdt_
(
IOobject
(
IOobject::groupName("dgdt", name),
T.mesh().time().name(),
T.mesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
T.mesh(),
dimensionedScalar(dimless/dimTime, 0)
)
{
{
volScalarField Tp(IOobject::groupName("T", name), T);
Tp.write();
}
thermo_ = rhoThermo::New(T.mesh(), name);
thermo_->validate(name, "e");
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::compressiblePhase> Foam::compressiblePhase::clone() const
{
NotImplemented;
return autoPtr<compressiblePhase>(nullptr);
}
void Foam::compressiblePhase::correct
(
const volScalarField& p,
const volScalarField& T
)
{
thermo_->he() = thermo_->he(p, T);
thermo_->correct();
}
// ************************************************************************* //

View File

@ -1,158 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-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::compressiblePhase
Description
Single incompressible phase derived from the phase-fraction.
Used as part of the multiPhaseMixture for interface-capturing multi-phase
simulations.
SourceFiles
compressiblePhase.C
\*---------------------------------------------------------------------------*/
#ifndef compressiblePhase_H
#define compressiblePhase_H
#include "phase.H"
#include "dictionaryEntry.H"
#include "rhoThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class compressiblePhase Declaration
\*---------------------------------------------------------------------------*/
class compressiblePhase
:
public phase
{
// Private Data
autoPtr<rhoThermo> thermo_;
volScalarField Alpha_;
volScalarField::Internal dgdt_;
public:
// Constructors
//- Construct from components
compressiblePhase
(
const word& phaseName,
const volScalarField& T
);
//- Return clone
autoPtr<compressiblePhase> clone() const;
//- Return a pointer to a new compressiblePhase created on freestore
// from Istream
class iNew
{
const volScalarField& T_;
public:
iNew
(
const volScalarField& T
)
:
T_(T)
{}
autoPtr<compressiblePhase> operator()(Istream& is) const
{
return autoPtr<compressiblePhase>
(
new compressiblePhase(is, T_)
);
}
};
// Member Functions
//- Return const-access to phase rhoThermo
const rhoThermo& thermo() const
{
return thermo_();
}
//- Return access to phase rhoThermo
rhoThermo& thermo()
{
return thermo_();
}
//- Return const-access to phase mass-fraction
const volScalarField& Alpha() const
{
return Alpha_;
}
//- Return access to phase mass-fraction
volScalarField& Alpha()
{
return Alpha_;
}
//- Return const-access to phase divergence
const volScalarField::Internal& dgdt() const
{
return dgdt_;
}
//- Return access to phase divergence
volScalarField::Internal& dgdt()
{
return dgdt_;
}
void correct
(
const volScalarField& p,
const volScalarField& T
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,48 +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 "phase.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phase::phase(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)
{}
// ************************************************************************* //

View File

@ -1,94 +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/>.
Class
Foam::phase
Description
Single incompressible phase derived from the phase-fraction.
Used as part of the multiPhaseMixture for interface-capturing multi-phase
simulations.
SourceFiles
phase.C
\*---------------------------------------------------------------------------*/
#ifndef phase_H
#define phase_H
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class phase Declaration
\*---------------------------------------------------------------------------*/
class phase
:
public volScalarField
{
// Private Data
word name_;
public:
// Constructors
//- Construct from components
phase
(
const word& name,
const fvMesh& mesh
);
// Member Functions
const word& name() const
{
return name_;
}
const word& keyword() const
{
return name();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,10 +0,0 @@
volScalarField::Internal contErr
(
(fvc::ddt(rho) + fvc::div(mixture.rhoPhi()))()
);
forAll(mixture.phases(), phasei)
{
const volScalarField& rho = mixture.phases()[phasei].thermo().rho();
contErr -= (fvModels.source(mixture.phases()[phasei], rho)&rho);
}

View File

@ -1,62 +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"
Info<< "Constructing compressibleMultiphaseMixture\n" << endl;
compressibleMultiphaseMixture mixture(U, phi);
const volScalarField& rho = mixture.rho();
dimensionedScalar pMin("pMin", dimPressure, mixture);
mesh.schemes().setFluxRequired(p_rgh.name());
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
// Construct compressible turbulence model
autoPtr<compressible::momentumTransportModel> turbulence
(
compressible::momentumTransportModel::New
(
rho,
U,
mixture.rhoPhi(),
mixture
)
);
Info<< "Creating field kinetic energy K\n" << endl;
volScalarField K("K", 0.5*magSqr(U));
#include "createFvModels.H"
#include "createFvConstraints.H"

View File

@ -1,114 +0,0 @@
{
volScalarField rAU("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)
+ fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi)
);
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);
PtrList<fvScalarMatrix> p_rghEqnComps(mixture.phases().size());
forAll(mixture.phases(), phasei)
{
const compressiblePhase& phase = mixture.phases()[phasei];
const rhoThermo& thermo = phase.thermo();
const volScalarField& rho = thermo.rho()();
p_rghEqnComps.set
(
phasei,
(
fvc::ddt(rho) + thermo.psi()*correction(fvm::ddt(p_rgh))
+ fvc::div(phi, rho) - fvc::Sp(fvc::div(phi), rho)
- (fvModels.source(phase, rho)&rho)
).ptr()
);
}
// Cache p_rgh prior to solve for density update
volScalarField p_rgh_0(p_rgh);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqnIncomp
(
fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p_rgh)
);
tmp<fvScalarMatrix> p_rghEqnComp;
forAll(mixture.phases(), phasei)
{
const compressiblePhase& phase = mixture.phases()[phasei];
tmp<fvScalarMatrix> p_rghEqnCompi
(
(max(phase, scalar(0))/phase.thermo().rho())
*p_rghEqnComps[phasei]
);
if (phasei == 0)
{
p_rghEqnComp = p_rghEqnCompi;
}
else
{
p_rghEqnComp.ref() += p_rghEqnCompi;
}
}
solve(p_rghEqnComp + p_rghEqnIncomp);
if (pimple.finalNonOrthogonalIter())
{
p = max(p_rgh + mixture.rho()*gh, pMin);
p_rgh = p - rho*gh;
forAll(mixture.phases(), phasei)
{
compressiblePhase& phase = mixture.phases()[phasei];
phase.dgdt() =
pos0(phase)
*(p_rghEqnComps[phasei] & p_rgh)/phase.thermo().rho();
}
phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA
+ rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf);
U.correctBoundaryConditions();
fvConstraints.constrain(U);
}
}
// Update densities from change in p_rgh
mixture.correctRho(p_rgh - p_rgh_0);
mixture.correct();
// Correct p_rgh for consistency with p and the updated densities
p_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
K = 0.5*magSqr(U);
Info<< "max(U) " << max(mag(U)).value() << endl;
Info<< "min(p_rgh) " << min(p_rgh).value() << endl;
}