solvers::twoPhaseSolver: new base-class for twoPhaseVoFSolver and incompressibleDriftFlux

to separate the interface treatment between VoF and drift-flux and avoid code
duplication.
This commit is contained in:
Henry Weller
2023-04-24 21:13:04 +01:00
parent d558e49336
commit f38fd3e314
37 changed files with 427 additions and 307 deletions

View File

@ -14,6 +14,7 @@ wmake $targetType multicomponentFluid
wmake $targetType XiFluid wmake $targetType XiFluid
wmake $targetType shockFluid wmake $targetType shockFluid
wmake $targetType VoFSolver wmake $targetType VoFSolver
wmake $targetType twoPhaseSolver
wmake $targetType twoPhaseVoFSolver wmake $targetType twoPhaseVoFSolver
incompressibleVoF/Allwmake $targetType $* incompressibleVoF/Allwmake $targetType $*
compressibleVoF/Allwmake $targetType $* compressibleVoF/Allwmake $targetType $*

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,6 +1,5 @@
incompressibleDriftFluxMixture/incompressibleDriftFluxMixture.C incompressibleDriftFluxMixture/incompressibleDriftFluxMixture.C
alphaSuSp.C alphaSuSp.C
pressureCorrector.C
incompressibleDriftFlux.C incompressibleDriftFlux.C
LIB = $(FOAM_LIBBIN)/libincompressibleDriftFlux LIB = $(FOAM_LIBBIN)/libincompressibleDriftFlux

View File

@ -1,5 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \
@ -17,7 +17,7 @@ EXE_INC = \
LIB_LIBS = \ LIB_LIBS = \
-lincompressibleDriftFluxViscosityModel \ -lincompressibleDriftFluxViscosityModel \
-lincompressibleDriftFluxRelativeVelocityModels \ -lincompressibleDriftFluxRelativeVelocityModels \
-ltwoPhaseVoFSolver \ -ltwoPhaseSolver \
-lphysicalProperties \ -lphysicalProperties \
-linterfaceCompression \ -linterfaceCompression \
-lincompressibleTwoPhases \ -lincompressibleTwoPhases \

View File

@ -43,8 +43,23 @@ namespace solvers
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::incompressibleDriftFlux::correctCoNum()
{
VoFSolver::correctCoNum();
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::solvers::incompressibleDriftFlux::setInterfaceRDeltaT
(
volScalarField& rDeltaT
)
{}
void Foam::solvers::incompressibleDriftFlux::correctInterface() void Foam::solvers::incompressibleDriftFlux::correctInterface()
{} {}
@ -65,7 +80,7 @@ Foam::solvers::incompressibleDriftFlux::surfaceTensionForce() const
Foam::solvers::incompressibleDriftFlux::incompressibleDriftFlux(fvMesh& mesh) Foam::solvers::incompressibleDriftFlux::incompressibleDriftFlux(fvMesh& mesh)
: :
twoPhaseVoFSolver twoPhaseSolver
( (
mesh, mesh,
autoPtr<twoPhaseVoFMixture>(new incompressibleDriftFluxMixture(mesh)) autoPtr<twoPhaseVoFMixture>(new incompressibleDriftFluxMixture(mesh))
@ -73,7 +88,7 @@ Foam::solvers::incompressibleDriftFlux::incompressibleDriftFlux(fvMesh& mesh)
mixture mixture
( (
refCast<incompressibleDriftFluxMixture>(twoPhaseVoFSolver::mixture) refCast<incompressibleDriftFluxMixture>(twoPhaseSolver::mixture)
.initialise(U) .initialise(U)
), ),
@ -110,6 +125,11 @@ Foam::solvers::incompressibleDriftFlux::incompressibleDriftFlux(fvMesh& mesh)
// Read the controls // Read the controls
readControls(); readControls();
if (transient())
{
correctCoNum();
}
if (correctPhi || mesh.topoChanging()) if (correctPhi || mesh.topoChanging())
{ {
rAU = new volScalarField rAU = new volScalarField
@ -153,6 +173,12 @@ Foam::solvers::incompressibleDriftFlux::~incompressibleDriftFlux()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::scalar Foam::solvers::incompressibleDriftFlux::maxDeltaT() const
{
return fluidSolver::maxDeltaT();
}
void Foam::solvers::incompressibleDriftFlux::prePredictor() void Foam::solvers::incompressibleDriftFlux::prePredictor()
{ {
VoFSolver::prePredictor(); VoFSolver::prePredictor();
@ -196,6 +222,12 @@ void Foam::solvers::incompressibleDriftFlux::prePredictor()
} }
void Foam::solvers::incompressibleDriftFlux::pressureCorrector()
{
incompressiblePressureCorrector(p);
}
void Foam::solvers::incompressibleDriftFlux::thermophysicalPredictor() void Foam::solvers::incompressibleDriftFlux::thermophysicalPredictor()
{} {}

View File

@ -46,7 +46,7 @@ SourceFiles
See also See also
Foam::solvers::VoFSolver Foam::solvers::VoFSolver
Foam::solvers::twoPhaseVoFSolver Foam::solvers::twoPhaseSolver
Foam::solvers::compressibleVoF Foam::solvers::compressibleVoF
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -54,7 +54,7 @@ See also
#ifndef incompressibleDriftFlux_H #ifndef incompressibleDriftFlux_H
#define incompressibleDriftFlux_H #define incompressibleDriftFlux_H
#include "twoPhaseVoFSolver.H" #include "twoPhaseSolver.H"
#include "incompressibleDriftFluxMixture.H" #include "incompressibleDriftFluxMixture.H"
#include "relativeVelocityModel.H" #include "relativeVelocityModel.H"
#include "momentumTransportModel.H" #include "momentumTransportModel.H"
@ -73,7 +73,7 @@ namespace solvers
class incompressibleDriftFlux class incompressibleDriftFlux
: :
public twoPhaseVoFSolver public twoPhaseSolver
{ {
protected: protected:
@ -105,6 +105,16 @@ protected:
autoPtr<compressible::momentumTransportModel> momentumTransport; autoPtr<compressible::momentumTransportModel> momentumTransport;
private:
// Private Member Functions
//- Correct the cached Courant numbers
virtual void correctCoNum();
protected:
// Protected Member Functions // Protected Member Functions
//- Return the pressure reference //- Return the pressure reference
@ -140,6 +150,9 @@ protected:
const dictionary& alphaControls const dictionary& alphaControls
); );
//- Adjust the rDeltaT in the vicinity of the interface
virtual void setInterfaceRDeltaT(volScalarField& rDeltaT);
//- Calculate the alpha equation sources //- Calculate the alpha equation sources
virtual void alphaSuSp virtual void alphaSuSp
( (
@ -184,6 +197,9 @@ public:
// Member Functions // Member Functions
//- Return the current maximum time-step for stable solution
virtual scalar maxDeltaT() const;
//- Called at the start of the PIMPLE loop //- Called at the start of the PIMPLE loop
virtual void prePredictor(); virtual void prePredictor();

View File

@ -1,6 +1,6 @@
EXE_INC = \ EXE_INC = \
-I../incompressibleDriftFluxMixture \ -I../incompressibleDriftFluxMixture \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/twoPhaseModels/twoPhaseMixture/lnInclude \

View File

@ -1,7 +1,7 @@
EXE_INC = \ EXE_INC = \
-I../incompressibleDriftFluxMixture \ -I../incompressibleDriftFluxMixture \
-I../mixtureViscosityModels/lnInclude \ -I../mixtureViscosityModels/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/twoPhaseModels/twoPhaseMixture/lnInclude \

View File

@ -1,7 +1,6 @@
incompressibleTwoPhaseVoFMixture/incompressibleTwoPhaseVoFMixture.C incompressibleTwoPhaseVoFMixture/incompressibleTwoPhaseVoFMixture.C
incompressibleInterPhaseTransportModel/incompressibleInterPhaseTransportModel.C incompressibleInterPhaseTransportModel/incompressibleInterPhaseTransportModel.C
alphaSuSp.C alphaSuSp.C
pressureCorrector.C
incompressibleVoF.C incompressibleVoF.C
LIB = $(FOAM_LIBBIN)/libincompressibleVoF LIB = $(FOAM_LIBBIN)/libincompressibleVoF

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/incompressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/incompressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/incompressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/incompressibleVoF/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \

View File

@ -147,6 +147,12 @@ void Foam::solvers::incompressibleVoF::prePredictor()
} }
void Foam::solvers::incompressibleVoF::pressureCorrector()
{
incompressiblePressureCorrector(p);
}
void Foam::solvers::incompressibleVoF::thermophysicalPredictor() void Foam::solvers::incompressibleVoF::thermophysicalPredictor()
{} {}

View File

@ -1,155 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-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 "incompressibleVoF.H"
#include "constrainHbyA.H"
#include "constrainPressure.H"
#include "adjustPhi.H"
#include "findRefCell.H"
#include "fvcMeshPhi.H"
#include "fvcFlux.H"
#include "fvcDdt.H"
#include "fvcDiv.H"
#include "fvcSnGrad.H"
#include "fvcReconstruct.H"
#include "fvmLaplacian.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::incompressibleVoF::pressureCorrector()
{
volVectorField& U = U_;
surfaceScalarField& phi(phi_);
fvVectorMatrix& UEqn = tUEqn.ref();
setrAU(UEqn);
const surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU()));
while (pimple.correct())
{
volVectorField HbyA(constrainHbyA(rAU()*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ 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
(
(
surfaceTensionForce()
- 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;
}
}
clearrAU();
tUEqn.clear();
}
// ************************************************************************* //

View File

@ -9,6 +9,7 @@ EXE_INC = -ggdb3 \
\ \
-I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \ -I$(FOAM_SOLVERS)/modules/compressibleVoF/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/twoPhaseVoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/twoPhaseModels/VoF \ -I$(LIB_SRC)/twoPhaseModels/VoF \

View File

@ -0,0 +1,6 @@
twoPhaseVoFMixture/twoPhaseVoFMixture.C
alphaPredictor.C
pressureCorrector.C
twoPhaseSolver.C
LIB = $(FOAM_LIBBIN)/libtwoPhaseSolver

View File

@ -0,0 +1,23 @@
EXE_INC = \
-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)/twoPhaseModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lVoFSolver \
-lphysicalProperties \
-linterfaceCompression \
-linterfaceProperties \
-ltwoPhaseMixture \
-lfiniteVolume \
-lmeshTools \
-lfvModels \
-lfvConstraints \
-lsampling

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "twoPhaseVoFSolver.H" #include "twoPhaseSolver.H"
#include "subCycle.H" #include "subCycle.H"
#include "interfaceCompression.H" #include "interfaceCompression.H"
#include "CMULES.H" #include "CMULES.H"
@ -33,7 +33,7 @@ License
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::surfaceScalarField> Foam::solvers::twoPhaseVoFSolver::alphaPhi Foam::tmp<Foam::surfaceScalarField> Foam::solvers::twoPhaseSolver::alphaPhi
( (
const surfaceScalarField& phi, const surfaceScalarField& phi,
const volScalarField& alpha, const volScalarField& alpha,
@ -68,7 +68,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::solvers::twoPhaseVoFSolver::alphaPhi
} }
void Foam::solvers::twoPhaseVoFSolver::alphaSolve void Foam::solvers::twoPhaseSolver::alphaSolve
( (
const dictionary& alphaControls const dictionary& alphaControls
) )
@ -364,7 +364,7 @@ void Foam::solvers::twoPhaseVoFSolver::alphaSolve
} }
void Foam::solvers::twoPhaseVoFSolver::alphaPredictor() void Foam::solvers::twoPhaseSolver::alphaPredictor()
{ {
const dictionary& alphaControls = mesh.solution().solverDict(alpha1.name()); const dictionary& alphaControls = mesh.solution().solverDict(alpha1.name());

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "incompressibleDriftFlux.H" #include "twoPhaseSolver.H"
#include "constrainHbyA.H" #include "constrainHbyA.H"
#include "constrainPressure.H" #include "constrainPressure.H"
#include "adjustPhi.H" #include "adjustPhi.H"
@ -38,7 +38,10 @@ License
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::incompressibleDriftFlux::pressureCorrector() void Foam::solvers::twoPhaseSolver::incompressiblePressureCorrector
(
volScalarField& p
)
{ {
volVectorField& U = U_; volVectorField& U = U_;
surfaceScalarField& phi(phi_); surfaceScalarField& phi(phi_);

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "twoPhaseSolver.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
defineTypeNameAndDebug(twoPhaseSolver, 0);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solvers::twoPhaseSolver::twoPhaseSolver
(
fvMesh& mesh,
autoPtr<twoPhaseVoFMixture> mixturePtr
)
:
VoFSolver(mesh, autoPtr<VoFMixture>(mixturePtr.ptr())),
mixture(refCast<twoPhaseVoFMixture>(VoFSolver::mixture_)),
alpha1(mixture.alpha1()),
alpha2(mixture.alpha2()),
alphaRestart
(
typeIOobject<surfaceScalarField>
(
IOobject::groupName("alphaPhi", alpha1.group()),
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
).headerOk()
),
alphaPhi1
(
IOobject
(
IOobject::groupName("alphaPhi", alpha1.group()),
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
phi*fvc::interpolate(alpha1)
)
{
mesh.schemes().setFluxRequired(alpha1.name());
if (alphaRestart)
{
Info << "Restarting alpha" << endl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solvers::twoPhaseSolver::~twoPhaseSolver()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::twoPhaseSolver::preSolve()
{
VoFSolver::preSolve();
// Do not apply previous time-step mesh compression flux
// if the mesh topology changed
if (mesh().topoChanged())
{
talphaPhi1Corr0.clear();
}
}
void Foam::solvers::twoPhaseSolver::prePredictor()
{
VoFSolver::prePredictor();
alphaPredictor();
mixture.correct();
}
// ************************************************************************* //

View File

@ -0,0 +1,190 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::twoPhaseSolver
Description
Solver module base-class for for 2 immiscible fluids, 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.
Optional fvModels and fvConstraints are provided to enhance the simulation
in many ways including adding various sources, Lagrangian
particles, surface film etc. and constraining or limiting the solution.
SourceFiles
twoPhaseSolver.C
See also
Foam::solvers::fluidSolver
\*---------------------------------------------------------------------------*/
#ifndef twoPhaseSolver_H
#define twoPhaseSolver_H
#include "VoFSolver.H"
#include "twoPhaseVoFMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
/*---------------------------------------------------------------------------*\
Class twoPhaseSolver Declaration
\*---------------------------------------------------------------------------*/
class twoPhaseSolver
:
public VoFSolver
{
protected:
// Phase properties
//- Reference to the twoPhaseVoFMixture
twoPhaseVoFMixture& mixture;
//- Reference to the phase1-fraction
volScalarField& alpha1;
//- Reference to the phase2-fraction
volScalarField& alpha2;
//- Switch indicating if this is a restart
bool alphaRestart;
// Kinematic properties
// Phase-1 volumetric flux
surfaceScalarField alphaPhi1;
// Cached temporary fields
//- MULES Correction
tmp<surfaceScalarField> talphaPhi1Corr0;
private:
// Private Member Functions
//- Solve for the phase-fractions
void alphaSolve(const dictionary& alphaControls);
protected:
// Protected Member Functions
virtual tmp<surfaceScalarField> alphaPhi
(
const surfaceScalarField& phi,
const volScalarField& alpha,
const dictionary& alphaControls
);
//- Solve for the phase-fractions
void alphaPredictor();
//- Calculate the alpha equation sources
virtual void alphaSuSp
(
tmp<volScalarField::Internal>& Su,
tmp<volScalarField::Internal>& Sp
) = 0;
//- Correct the interface properties following mesh-change
// and phase-fraction update
virtual void correctInterface() = 0;
//- Return the interface surface tension force for the momentum equation
virtual tmp<surfaceScalarField> surfaceTensionForce() const = 0;
//- Construct and solve the incompressible pressure equation
// in the PISO loop
void incompressiblePressureCorrector(volScalarField& p);
public:
//- Runtime type information
TypeName("twoPhaseSolver");
// Constructors
//- Construct from region mesh
twoPhaseSolver(fvMesh& mesh, autoPtr<twoPhaseVoFMixture>);
//- Disallow default bitwise copy construction
twoPhaseSolver(const twoPhaseSolver&) = delete;
//- Destructor
virtual ~twoPhaseSolver();
// 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 twoPhaseSolver&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solvers
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,6 +1,4 @@
twoPhaseVoFMixture/twoPhaseVoFMixture.C
setInterfaceRDeltaT.C setInterfaceRDeltaT.C
alphaPredictor.C
twoPhaseVoFSolver.C twoPhaseVoFSolver.C
LIB = $(FOAM_LIBBIN)/libtwoPhaseVoFSolver LIB = $(FOAM_LIBBIN)/libtwoPhaseVoFSolver

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(FOAM_SOLVERS)/modules/twoPhaseSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/VoFSolver/lnInclude \
-I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \ -I$(FOAM_SOLVERS)/modules/fluidSolver/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \
@ -11,8 +12,7 @@ EXE_INC = \
-I$(LIB_SRC)/sampling/lnInclude -I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \ LIB_LIBS = \
-lVoFSolver \ -ltwoPhaseSolver \
-lfluidSolver \
-lphysicalProperties \ -lphysicalProperties \
-linterfaceCompression \ -linterfaceCompression \
-linterfaceProperties \ -linterfaceProperties \

View File

@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "twoPhaseVoFSolver.H" #include "twoPhaseVoFSolver.H"
#include "localEulerDdtScheme.H"
#include "fvcAverage.H" #include "fvcAverage.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -42,7 +41,7 @@ namespace solvers
void Foam::solvers::twoPhaseVoFSolver::correctCoNum() void Foam::solvers::twoPhaseVoFSolver::correctCoNum()
{ {
VoFSolver::correctCoNum(); twoPhaseSolver::correctCoNum();
const scalarField sumPhi const scalarField sumPhi
( (
@ -83,47 +82,10 @@ Foam::solvers::twoPhaseVoFSolver::twoPhaseVoFSolver
autoPtr<twoPhaseVoFMixture> mixturePtr autoPtr<twoPhaseVoFMixture> mixturePtr
) )
: :
VoFSolver(mesh, autoPtr<VoFMixture>(mixturePtr.ptr())), twoPhaseSolver(mesh, mixturePtr),
mixture(refCast<twoPhaseVoFMixture>(VoFSolver::mixture_)), interface(mixture, alpha1, alpha2, U)
alpha1(mixture.alpha1()),
alpha2(mixture.alpha2()),
alphaRestart
(
typeIOobject<surfaceScalarField>
(
IOobject::groupName("alphaPhi", alpha1.group()),
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
).headerOk()
),
interface(mixture, alpha1, alpha2, U),
alphaPhi1
(
IOobject
(
IOobject::groupName("alphaPhi", alpha1.group()),
runTime.name(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
phi*fvc::interpolate(alpha1)
)
{ {
mesh.schemes().setFluxRequired(alpha1.name());
if (alphaRestart)
{
Info << "Restarting alpha" << endl;
}
if (transient()) if (transient())
{ {
correctCoNum(); correctCoNum();
@ -137,27 +99,4 @@ Foam::solvers::twoPhaseVoFSolver::~twoPhaseVoFSolver()
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::solvers::twoPhaseVoFSolver::preSolve()
{
VoFSolver::preSolve();
// Do not apply previous time-step mesh compression flux
// if the mesh topology changed
if (mesh().topoChanged())
{
talphaPhi1Corr0.clear();
}
}
void Foam::solvers::twoPhaseVoFSolver::prePredictor()
{
VoFSolver::prePredictor();
alphaPredictor();
mixture.correct();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -55,8 +55,7 @@ See also
#ifndef twoPhaseVoFSolver_H #ifndef twoPhaseVoFSolver_H
#define twoPhaseVoFSolver_H #define twoPhaseVoFSolver_H
#include "VoFSolver.H" #include "twoPhaseSolver.H"
#include "twoPhaseVoFMixture.H"
#include "interfaceProperties.H" #include "interfaceProperties.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -72,78 +71,31 @@ namespace solvers
class twoPhaseVoFSolver class twoPhaseVoFSolver
: :
public VoFSolver public twoPhaseSolver
{ {
protected: protected:
// Phase properties
//- Reference to the twoPhaseVoFMixture
twoPhaseVoFMixture& mixture;
//- Reference to the phase1-fraction
volScalarField& alpha1;
//- Reference to the phase2-fraction
volScalarField& alpha2;
//- Switch indicating if this is a restart
bool alphaRestart;
// Interface properties // Interface properties
interfaceProperties interface; interfaceProperties interface;
// Kinematic properties
// Phase-1 volumetric flux
surfaceScalarField alphaPhi1;
// Cached temporary fields
//- MULES Correction
tmp<surfaceScalarField> talphaPhi1Corr0;
private: private:
// Private Member Functions // Private Member Functions
//- Correct the cached Courant numbers //- Correct the cached Courant numbers
void correctCoNum(); virtual void correctCoNum();
//- Solve for the phase-fractions
void alphaSolve(const dictionary& alphaControls);
protected: protected:
// Protected Member Functions // Protected Member Functions
virtual tmp<surfaceScalarField> alphaPhi
(
const surfaceScalarField& phi,
const volScalarField& alpha,
const dictionary& alphaControls
);
//- Solve for the phase-fractions
void alphaPredictor();
//- Adjust the rDeltaT in the vicinity of the interface //- Adjust the rDeltaT in the vicinity of the interface
virtual void setInterfaceRDeltaT(volScalarField& rDeltaT); virtual void setInterfaceRDeltaT(volScalarField& rDeltaT);
//- Calculate the alpha equation sources
virtual void alphaSuSp
(
tmp<volScalarField::Internal>& Su,
tmp<volScalarField::Internal>& Sp
) = 0;
//- Correct the interface properties following mesh-change //- Correct the interface properties following mesh-change
// and phase-fraction update // and phase-fraction update
virtual void correctInterface(); virtual void correctInterface();
@ -173,12 +125,6 @@ public:
// Member Functions // 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 // Member Operators

View File

@ -26,6 +26,4 @@ relativeVelocityModel simple;
residualAlpha 0; residualAlpha 0;
} }
sigma 0;
// ************************************************************************* // // ************************************************************************* //

View File

@ -50,8 +50,6 @@ adjustTimeStep on;
maxCo 5; maxCo 5;
maxAlphaCo 1;
maxDeltaT 1; maxDeltaT 1;
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,6 +26,4 @@ relativeVelocityModel simple;
residualAlpha 0; residualAlpha 0;
} }
sigma 0;
// ************************************************************************* // // ************************************************************************* //

View File

@ -50,8 +50,6 @@ adjustTimeStep yes;
maxCo 1; maxCo 1;
maxAlphaCo 1;
maxDeltaT 0.05; maxDeltaT 0.05;
// ************************************************************************* // // ************************************************************************* //

View File

@ -26,6 +26,4 @@ relativeVelocityModel simple;
residualAlpha 0; residualAlpha 0;
} }
sigma 0;
// ************************************************************************* // // ************************************************************************* //