phaseScalarTransport: Improved interface and documentation

This function now looks up an alphaPhi field by default and exits with
an error if the field cannot be found. In order to solve for alphaPhi a
new 'solveAlphaPhi' switch has to be set.

The documentation has been updated to reflect the fact that the VoF
solvers now store all the alphaPhi fluxes necessary for a in-phase
equation to be constructed.

The phaseScalarTransport function has been added to the damBreakLaminar
tutorial.
This commit is contained in:
Will Bainbridge
2023-12-06 12:39:34 +00:00
parent e1d6448fcf
commit 2bc91ecff0
11 changed files with 370 additions and 43 deletions

View File

@ -90,7 +90,7 @@ Foam::volScalarField& Foam::functionObjects::phaseScalarTransport::Phi()
( (
IOobject IOobject
( (
"Phi" + s_.name(), typedName(IOobject::groupName("Phi", phaseName_)),
time_.name(), time_.name(),
mesh_, mesh_,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
@ -112,16 +112,11 @@ Foam::volScalarField& Foam::functionObjects::phaseScalarTransport::Phi()
Foam::tmp<Foam::surfaceScalarField> Foam::tmp<Foam::surfaceScalarField>
Foam::functionObjects::phaseScalarTransport::alphaPhi() Foam::functionObjects::phaseScalarTransport::alphaPhi()
{ {
// If alphaPhi exists then return it if (!solveAlphaPhi_)
if (mesh_.foundObject<surfaceScalarField>(alphaPhiName_))
{ {
return mesh_.lookupObject<surfaceScalarField>(alphaPhiName_); return mesh_.lookupObject<surfaceScalarField>(alphaPhiName_);
} }
// Otherwise generate it ...
Info<< type() << ": " << surfaceScalarField::typeName << " "
<< alphaPhiName_ << " was not found, so generating it" << endl;
const volScalarField& alpha = const volScalarField& alpha =
mesh_.lookupObject<volScalarField>(alphaName_); mesh_.lookupObject<volScalarField>(alphaName_);
const surfaceScalarField& phi = const surfaceScalarField& phi =
@ -288,8 +283,6 @@ Foam::functionObjects::phaseScalarTransport::phaseScalarTransport
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
fieldName_(dict.lookup("field")), fieldName_(dict.lookup("field")),
phaseName_(IOobject::group(fieldName_)), phaseName_(IOobject::group(fieldName_)),
nCorr_(0),
residualAlpha_(rootSmall),
s_ s_
( (
IOobject IOobject
@ -330,18 +323,20 @@ bool Foam::functionObjects::phaseScalarTransport::read(const dictionary& dict)
{ {
fvMeshFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
solveAlphaPhi_ = dict.lookupOrDefault<bool>("solveAlphaPhi", false);
alphaName_ = alphaName_ =
dict.lookupOrDefault<word> dict.lookupOrDefault<word>
( (
"alpha", "alpha",
IOobject::groupName("alpha", phaseName_) IOobject::groupName("alpha", phaseName_)
); );
const word defaultAlphaPhiName =
IOobject::groupName("alphaPhi", phaseName_);
alphaPhiName_ = alphaPhiName_ =
dict.lookupOrDefault<word> solveAlphaPhi_
( ? typedName(defaultAlphaPhiName)
"alphaPhi", : dict.lookupOrDefault<word>("alphaPhi", defaultAlphaPhiName);
IOobject::groupName("alphaPhi", phaseName_)
);
phiName_ = dict.lookupOrDefault<word>("phi", "phi"); phiName_ = dict.lookupOrDefault<word>("phi", "phi");
rhoName_ = rhoName_ =
dict.lookupOrDefault<word> dict.lookupOrDefault<word>
@ -356,8 +351,8 @@ bool Foam::functionObjects::phaseScalarTransport::read(const dictionary& dict)
alphaD_ = dict.lookupOrDefault<scalar>("alphaD", 1); alphaD_ = dict.lookupOrDefault<scalar>("alphaD", 1);
alphaDt_ = dict.lookupOrDefault<scalar>("alphaDt", 1); alphaDt_ = dict.lookupOrDefault<scalar>("alphaDt", 1);
dict.readIfPresent("nCorr", nCorr_); nCorr_ = dict.lookupOrDefault<label>("nCorr", 0);
dict.readIfPresent("residualAlpha", residualAlpha_); residualAlpha_ = dict.lookupOrDefault<scalar>("residualAlpha", rootSmall);
writeAlphaField_ = dict.lookupOrDefault<bool>("writeAlphaField", true); writeAlphaField_ = dict.lookupOrDefault<bool>("writeAlphaField", true);
return true; return true;

View File

@ -37,27 +37,25 @@ Description
detailed below. Note that the phase-name will be determined by stripping detailed below. Note that the phase-name will be determined by stripping
the extension from the supplied field name. the extension from the supplied field name.
If \c alphaPhi is specified and found in the database then it will be used If the solver does not provide an \c alphaPhi flux, or that flux is for
to transport the field. This is the likely mode of operation if this some reason unreliable, then the \c solveAlphaPhi switch can be used to
function is used with Euler-Euler solvers, in which \c alphaPhi -like make this function solve a pressure-like equation from which \c alphaPhi is
fluxes are available. If \c alphaPhi is not found, then a pressure-like recovered.
equation will be solved in order to construct it so that it exactly matches
the time-derivative of the phase volume or mass. This is likely to be
necessary in volume-of-fluid solvers where \c alphaPhi is not part of the
solution procedure. The pressure field name will be required in this case.
Usage Usage
\table \table
Property | Description | Req'd? | Default Property | Description | Req'd? | Default
alpha | Name of the volume-fraction field | no\\ alpha | Name of the volume-fraction field | no\\
| alpha.<phase-name> | alpha.<phase-name>
alphaPhi | Name of the phase-flux field | no\\ alphaPhi | Name of the phase-flux field | no\\
| alphaPhi.<phase-name> | alphaPhi.<phase-name>
p | Name of the pressure field | no | p solveAlphaPhi | Solve for the alphaPhi flux, rather than looking it\\
up | no | false
p | Name of the pressure field | no | p
residualAlpha | Small volume fraction used to stabilise the solution\\ residualAlpha | Small volume fraction used to stabilise the solution\\
| no | rootSmall | no | rootSmall
writeAlphaField | Also write out alpha multiplied by the field\\ writeAlphaField | Also write out alpha multiplied by the field\\
| no | true | no | true
\endtable \endtable
Example specification for incompressibleVoF: Example specification for incompressibleVoF:
@ -68,7 +66,6 @@ Usage
libs ("libsolverFunctionObjects.so"); libs ("libsolverFunctionObjects.so");
field s.water; field s.water;
p p_rgh;
} }
\endverbatim \endverbatim
@ -123,6 +120,9 @@ class phaseScalarTransport
//- Name of the phase in which to solve //- Name of the phase in which to solve
const word phaseName_; const word phaseName_;
//- Solve for the alphaPhi flux, rather than looking it up (optional)
bool solveAlphaPhi_;
//- Name of phase volume-fraction field (optional) //- Name of phase volume-fraction field (optional)
word alphaName_; word alphaName_;

View File

@ -0,0 +1,39 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object tracer.air;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
wall
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,39 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "0";
object tracer.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
wall
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue $internalField;
value $internalField;
}
}
// ************************************************************************* //

View File

@ -6,10 +6,12 @@ cd ${0%/*} || exit 1 # Run from this directory
cleanVoFCase cleanVoFCase
rm -rf 0 system find 0 -type f -not -name tracer.* -delete
find constant -type f -not \( \ find constant -type f -not \( \
-name fvModels -or -name momentumTransport \ -name fvModels -or -name momentumTransport \
\) -delete \) -delete
rm -f system/blockMeshDict
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -9,10 +9,6 @@ isTest "$@" && path=.. || path=$FOAM_TUTORIALS/incompressibleVoF
cp -rn $path/damBreak/0 $path/damBreak/constant $path/damBreak/system . cp -rn $path/damBreak/0 $path/damBreak/constant $path/damBreak/system .
rm -f 0/alpha.water rm -f 0/alpha.water
# Increase the number of limiter iterations
runApplication foamDictionary system/fvSolution \
-entry solvers/"alpha.water.*"/nLimiterIter -set 5
# Run # Run
runApplication blockMesh runApplication blockMesh
runApplication setFields runApplication setFields

View File

@ -16,12 +16,5 @@ FoamFile
simulationType laminar; simulationType laminar;
RAS
{
model kEpsilon;
turbulence on;
printCoeffs on;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application foamRun;
solver incompressibleVoF;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 1;
deltaT 0.001;
writeControl adjustableRunTime;
writeInterval 0.05;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 1;
maxAlphaCo 1;
maxDeltaT 1;
functions
{
#includeFunc phaseScalarTransport(field=tracer.water)
#includeFunc phaseScalarTransport(field=tracer.air, residualAlpha=1e-6)
}
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
div(phi,alpha) Gauss interfaceCompression vanLeer 1;
div(rhoPhi,U) Gauss linearUpwind grad(U);
div(phi,k) Gauss upwind;
div(phi,epsilon) Gauss upwind;
div(phi,omega) Gauss upwind;
div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
div(alphaPhi,tracer) Gauss vanLeer;
}
laplacianSchemes
{
default Gauss linear uncorrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default uncorrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"alpha.water.*"
{
nAlphaCorr 2;
nAlphaSubCycles 1;
MULESCorr yes;
nLimiterIter 5;
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-8;
relTol 0;
}
"pcorr.*"
{
solver PCG;
preconditioner DIC;
tolerance 1e-5;
relTol 0;
}
p_rgh
{
solver PCG;
preconditioner DIC;
tolerance 1e-07;
relTol 0.05;
}
p_rghFinal
{
$p_rgh;
relTol 0;
}
"(U|k|epsilon|omega).*"
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-06;
relTol 0;
minIter 1;
}
"tracer.*"
{
solver PBiCGStab;
preconditioner DILU;
tolerance 1e-06;
relTol 0;
}
}
PIMPLE
{
momentumPredictor no;
nOuterCorrectors 1;
nCorrectors 3;
nNonOrthogonalCorrectors 0;
}
relaxationFactors
{
equations
{
".*" 1;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defaultFieldValues
(
volScalarFieldValue alpha.water 0
volScalarFieldValue tracer.water 0
volScalarFieldValue tracer.air 0
);
regions
(
boxToCell
{
box (0 0 -1) (0.1461 0.292 1);
fieldValues
(
volScalarFieldValue alpha.water 1
);
}
boxToCell
{
box (0 0 -1) (0.1461 0.146 1);
fieldValues
(
volScalarFieldValue tracer.water 1
);
}
boxToCell
{
box (0 0.292 -1) (0.1461 0.438 1);
fieldValues
(
volScalarFieldValue tracer.air 1
);
}
);
// ************************************************************************* //