interFoam: Replaced twoPhaseChangeModel with the VoFCavitation fvModel

Replacing the specific twoPhaseChangeModel with a consistent and general fvModel
interface will support not just cavitation using the new VoFCavitation fvModel
but also other phase-change and interface manipulation models in the future and
is easier to use for case-specific and other user customisation.
This commit is contained in:
Henry Weller
2022-09-27 19:28:11 +01:00
parent f412d39174
commit d3df91a5eb
47 changed files with 883 additions and 961 deletions

View File

@ -68,7 +68,7 @@ Foam::fv::VoFTurbulenceDamping::VoFTurbulenceDamping
"phaseProperties"
)
),
interface_(refCast<const interfaceProperties>(mixture_)),
interface_(mixture_),
turbulence_
(
mesh.lookupObject<compressibleMomentumTransportModel>

View File

@ -103,7 +103,7 @@ Foam::autoPtr<Foam::relativeVelocityModel> Foam::relativeVelocityModel::New
const uniformDimensionedVectorField& g
)
{
word modelType(dict.lookup(typeName));
const word modelType(dict.lookup(typeName));
Info<< "Selecting relative velocity model " << modelType << endl;

View File

@ -3,6 +3,7 @@ cd ${0%/*} || exit 1 # Run from this directory
wclean libso incompressibleInterPhaseTransportModel
wclean libso VoFTurbulenceDamping
wclean libso VoFCavitation
wclean
wclean interMixingFoam

View File

@ -6,6 +6,7 @@ cd ${0%/*} || exit 1 # Run from this directory
wmake $targetType incompressibleInterPhaseTransportModel
wmake $targetType VoFTurbulenceDamping
wmake $targetType VoFCavitation
wmake $targetType
wmake $targetType interMixingFoam

View File

@ -5,7 +5,6 @@ EXE_INC = \
-I$(LIB_SRC)/twoPhaseModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/incompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/twoPhaseChange/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/phaseIncompressible/lnInclude \
@ -16,7 +15,6 @@ EXE_INC = \
EXE_LIBS = \
-limmiscibleIncompressibleTwoPhaseMixture \
-ltwoPhaseChangeModels \
-lmomentumTransportModels \
-lincompressibleMomentumTransportModels \
-lincompressibleInterPhaseTransportModel \

View File

@ -4,8 +4,8 @@
+ MRF.DDt(rho, U)
+ turbulence.divDevTau(rho, U)
==
phaseChange.SU(rho, rhoPhi, U)
+ fvModels.source(rho, U)
// phaseChange.SU(rho, rhoPhi, U)
fvModels.source(rho, U)
);
UEqn.relax();

View File

@ -0,0 +1,3 @@
VoFCavitation.C
LIB = $(FOAM_LIBBIN)/libVoFCavitation

View File

@ -0,0 +1,16 @@
EXE_INC = \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/incompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/cavitation/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lphysicalProperties \
-limmiscibleIncompressibleTwoPhaseMixture \
-lcavitationModels \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 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/>.
\*---------------------------------------------------------------------------*/
#include "VoFCavitation.H"
#include "immiscibleIncompressibleTwoPhaseMixture.H"
#include "fvcDdt.H"
#include "fvcDiv.H"
#include "fvmSup.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(VoFCavitation, 0);
addToRunTimeSelectionTable
(
fvModel,
VoFCavitation,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::VoFCavitation::VoFCavitation
(
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
fvModel(sourceName, modelType, dict, mesh),
mixture_
(
mesh.lookupObjectRef<immiscibleIncompressibleTwoPhaseMixture>
(
"phaseProperties"
)
),
cavitation_(cavitationModel::New(dict, mixture_)),
alphaName_(mixture_.alpha1().name())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::wordList Foam::fv::VoFCavitation::addSupFields() const
{
return {alphaName_, "p_rgh", "U"};
}
void Foam::fv::VoFCavitation::addSup
(
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
if (fieldName == alphaName_)
{
volScalarField::Internal alphalCoeff
(
1.0/mixture_.rho1()
- mixture_.alpha1()()*(1.0/mixture_.rho1() - 1.0/mixture_.rho2())
);
const Pair<tmp<volScalarField::Internal>> mDotAlphal
(
cavitation_->mDotAlphal()
);
const volScalarField::Internal vDotcAlphal(alphalCoeff*mDotAlphal[0]());
const volScalarField::Internal vDotvAlphal(alphalCoeff*mDotAlphal[1]());
eqn += fvm::Sp(vDotvAlphal - vDotcAlphal, eqn.psi()) + vDotcAlphal;
}
}
void Foam::fv::VoFCavitation::addSup
(
const volScalarField&,
fvMatrix<scalar>& eqn,
const word& fieldName
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
if (fieldName == "p_rgh")
{
const volScalarField::Internal& rho =
mesh().lookupObject<volScalarField>("rho");
const volScalarField::Internal& gh =
mesh().lookupObject<volScalarField>("gh");
const dimensionedScalar pCoeff
(
1.0/mixture_.rho1() - 1.0/mixture_.rho2()
);
const Pair<tmp<volScalarField::Internal>> mDotP
(
cavitation_->mDotP()
);
const volScalarField::Internal vDotcP(pCoeff*mDotP[0]);
const volScalarField::Internal vDotvP(pCoeff*mDotP[1]);
eqn +=
(vDotvP - vDotcP)*(cavitation_->pSat() - rho*gh)
- fvm::Sp(vDotvP - vDotcP, eqn.psi());
}
}
void Foam::fv::VoFCavitation::addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const word& fieldName
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}
if (fieldName == "U")
{
const surfaceScalarField& rhoPhi =
mesh().lookupObject<surfaceScalarField>("rhoPhi");
eqn += fvm::Sp(fvc::ddt(rho) + fvc::div(rhoPhi), eqn.psi());
}
}
void Foam::fv::VoFCavitation::topoChange(const polyTopoChangeMap&)
{}
void Foam::fv::VoFCavitation::mapMesh(const polyMeshMap& map)
{}
void Foam::fv::VoFCavitation::distribute(const polyDistributionMap&)
{}
bool Foam::fv::VoFCavitation::movePoints()
{
return true;
}
void Foam::fv::VoFCavitation::correct()
{
cavitation_->correct();
}
// ************************************************************************* //

View File

@ -0,0 +1,204 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 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/>.
Class
Foam::fv::VoFCavitation
Description
Cavitation fvModel
Usage
Example usage:
\verbatim
VoFCavitation
{
type VoFCavitation;
libs ("libVoFCavitation.so");
model SchnerrSauer;
KunzCoeffs
{
pSat 2300; // Saturation pressure
UInf 20.0;
tInf 0.005; // L = 0.1 m
Cc 1000;
Cv 1000;
}
MerkleCoeffs
{
pSat 2300; // Saturation pressure
UInf 20.0;
tInf 0.005; // L = 0.1 m
Cc 80;
Cv 1e-03;
}
SchnerrSauerCoeffs
{
pSat 2300; // Saturation pressure
n 1.6e+13;
dNuc 2.0e-06;
Cc 1;
Cv 1;
}
}
\endverbatim
SourceFiles
VoFCavitation.C
\*---------------------------------------------------------------------------*/
#ifndef VoFCavitation_H
#define VoFCavitation_H
#include "fvModel.H"
#include "cavitationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class immiscibleIncompressibleTwoPhaseMixture;
class interfaceProperties;
class incompressibleMomentumTransportModel;
namespace fv
{
/*---------------------------------------------------------------------------*\
Class VoFCavitation Declaration
\*---------------------------------------------------------------------------*/
class VoFCavitation
:
public fvModel
{
// Private Data
//- Reference to the mixture properties
const immiscibleIncompressibleTwoPhaseMixture& mixture_;
autoPtr<cavitationModel> cavitation_;
//- The name of the VoF phase-fraction
word alphaName_;
public:
//- Runtime type information
TypeName("VoFCavitation");
// Constructors
//- Construct from explicit source name and mesh
VoFCavitation
(
const word& sourceName,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Disallow default bitwise copy construction
VoFCavitation
(
const VoFCavitation&
) = delete;
// Member Functions
//- Return the list of fields for which the option adds source term
// to the transport equation
virtual wordList addSupFields() const;
//- Add implicit/explicit contributions to VoF phase-fraction equation
virtual void addSup
(
fvMatrix<scalar>& eqn,
const word& fieldName
) const;
//- Add implicit/explicit contributions to p_rgh equation
virtual void addSup
(
const volScalarField& psi,
fvMatrix<scalar>& eqn,
const word& fieldName
) const;
//- Add contribution to U equation
virtual void addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const word& fieldName
) const;
// Mesh changes
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
//- Update for mesh motion
virtual bool movePoints();
//- Correct the cavitation model
virtual void correct();
// Member Operators
//- Disallow default bitwise assignment
void operator=(const VoFCavitation&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,6 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/twoPhaseModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/incompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/incompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
@ -10,6 +11,7 @@ EXE_INC = \
LIB_LIBS = \
-lphysicalProperties \
-limmiscibleIncompressibleTwoPhaseMixture \
-ltwoPhaseMixture \
-linterfaceProperties \
-lmomentumTransportModels \

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "VoFTurbulenceDamping.H"
#include "incompressibleTwoPhaseMixture.H"
#include "immiscibleIncompressibleTwoPhaseMixture.H"
#include "interfaceProperties.H"
#include "incompressibleMomentumTransportModel.H"
#include "fvMatrix.H"
@ -63,12 +63,12 @@ Foam::fv::VoFTurbulenceDamping::VoFTurbulenceDamping
delta_("delta", dimLength, dict),
mixture_
(
mesh.lookupObject<incompressibleTwoPhaseMixture>
mesh.lookupObject<immiscibleIncompressibleTwoPhaseMixture>
(
"phaseProperties"
)
),
interface_(refCast<const interfaceProperties>(mixture_)),
interface_(mixture_),
turbulence_
(
mesh.lookupObject<incompressibleMomentumTransportModel>

View File

@ -81,7 +81,7 @@ SourceFiles
namespace Foam
{
class incompressibleTwoPhaseMixture;
class immiscibleIncompressibleTwoPhaseMixture;
class interfaceProperties;
class incompressibleMomentumTransportModel;
@ -98,7 +98,7 @@ class VoFTurbulenceDamping
{
// Private Data
//- The name of the Lagrangian phase
//- The name of the VoF phase
word phaseName_;
//- Field name
@ -109,7 +109,7 @@ class VoFTurbulenceDamping
dimensionedScalar delta_;
//- Reference to the mixture properties
const incompressibleTwoPhaseMixture& mixture_;
const immiscibleIncompressibleTwoPhaseMixture& mixture_;
//- Reference to the interface properties
const interfaceProperties& interface_;

View File

@ -1,15 +1,15 @@
// Phase change alpha1 source
Pair<tmp<volScalarField::Internal>> phaseChangeS
(
phaseChange.Salpha(alpha1)
);
const tmp<volScalarField::Internal>& Su = phaseChangeS[0];
const tmp<volScalarField::Internal>& Sp = phaseChangeS[1];
tmp<volScalarField> divU;
tmp<volScalarField::Internal> Su;
tmp<volScalarField::Internal> Sp;
if (Sp.valid())
if (fvModels.addsSupToField(alpha1.name()))
{
// Phase change alpha1 source
const fvScalarMatrix alphaSup(fvModels.source(alpha1));
Su = alphaSup.Su();
Sp = alphaSup.Sp();
divU =
(
mesh.moving()

View File

@ -3,5 +3,5 @@ volScalarField& alpha2(mixture.alpha2());
const dimensionedScalar& rho1 = mixture.rho1();
const dimensionedScalar& rho2 = mixture.rho2();
twoPhaseChangeModel& phaseChange = phaseChangePtr();
//twoPhaseChangeModel& phaseChange = phaseChangePtr();
tmp<volScalarField> rAU;

View File

@ -34,11 +34,6 @@ volVectorField U
Info<< "Reading phaseProperties\n" << endl;
immiscibleIncompressibleTwoPhaseMixture mixture(U, phi);
autoPtr<twoPhaseChangeModel> phaseChangePtr
(
twoPhaseChangeModel::New(mixture)
);
// Need to store rho for ddt(rho, U)
volScalarField rho

View File

@ -1,7 +1,7 @@
if
(
!runTime.restart()
|| isType<twoPhaseChangeModels::noPhaseChange>(phaseChange)
|| !fvModels.addsSupToField(alpha1.name())
)
{
if (correctPhi)

View File

@ -40,7 +40,6 @@ Description
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "immiscibleIncompressibleTwoPhaseMixture.H"
#include "noPhaseChange.H"
#include "incompressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "pressureReference.H"
@ -99,7 +98,7 @@ int main(int argc, char *argv[])
if
(
correctPhi
&& !isType<twoPhaseChangeModels::noPhaseChange>(phaseChange)
&& fvModels.addsSupToField(alpha1.name())
&& mesh.topoChanged()
)
{
@ -133,7 +132,7 @@ int main(int argc, char *argv[])
if
(
correctPhi
&& !isType<twoPhaseChangeModels::noPhaseChange>(phaseChange)
&& fvModels.addsSupToField(alpha1.name())
&& !divU.valid()
)
{

View File

@ -39,7 +39,19 @@
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Cache the phase change pressure source
fvScalarMatrix Sp_rgh(phaseChange.Sp_rgh(rho, gh, p_rgh));
fvScalarMatrix Sp_rgh
(
fvModels.source
(
volScalarField::New
(
"1",
mesh,
dimensionedScalar(dimless/dimPressure, 1)
),
p_rgh
)
);
while (pimple.correctNonOrthogonal())
{