functionObjects: phaseScalarTransport: Made writing of alpha*s switchable

This commit is contained in:
Will Bainbridge
2019-02-18 15:18:30 +00:00
parent c56f2a2e15
commit 4f3c3eaab1
2 changed files with 50 additions and 25 deletions

View File

@ -313,21 +313,7 @@ Foam::functionObjects::phaseScalarTransport::phaseScalarTransport
),
mesh_
),
alphaS_
(
IOobject
(
"alpha"
+ word(toupper(fieldName_[0]))
+ fieldName_(1, fieldName_.size() - 1),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(s_.dimensions(), Zero)
),
alphaSPtr_(nullptr),
PhiPtr_(nullptr)
{
if (phaseName_ == word::null)
@ -383,6 +369,7 @@ bool Foam::functionObjects::phaseScalarTransport::read(const dictionary& dict)
dict.readIfPresent("nCorr", nCorr_);
dict.readIfPresent("residualAlpha", residualAlpha_);
writeAlphaField_ = dict.lookupOrDefault<bool>("writeAlphaField", true);
if (dict.found("fvOptions"))
{
@ -479,7 +466,39 @@ bool Foam::functionObjects::phaseScalarTransport::execute()
}
// Update
alphaS_ = alpha*s_;
if (writeAlphaField_)
{
if (!alphaSPtr_.valid())
{
alphaSPtr_.set
(
new volScalarField
(
IOobject
(
"alpha"
+ word(toupper(fieldName_[0]))
+ fieldName_(1, fieldName_.size() - 1),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(s_.dimensions(), Zero)
)
);
}
alphaSPtr_() = alpha*s_;
}
else
{
if (alphaSPtr_.valid())
{
alphaSPtr_().clear();
}
}
Info<< endl;

View File

@ -48,14 +48,16 @@ Description
Usage
\table
Property | Description | Req'd? | Default
alpha | Name of the volume-fraction field | no \\
| alpha.<phase-name>
alphaPhi | Name of the phase-flux field | no \\
| alphaPhi.<phase-name>
p | Name of the pressure field | no | p
residualAlpha | Small volume fraction used to stabilise the solution \\
| no | rootSmall
Property | Description | Req'd? | Default
alpha | Name of the volume-fraction field | no\\
| alpha.<phase-name>
alphaPhi | Name of the phase-flux field | no\\
| alphaPhi.<phase-name>
p | Name of the pressure field | no | p
residualAlpha | Small volume fraction used to stabilise the solution\\
| no | rootSmall
writeAlphaField | Also write out alpha multiplied by the field\\
| no | true
\endtable
Example specification for interFoam:
@ -158,6 +160,10 @@ class phaseScalarTransport
//- Name of field whose schemes are used (optional)
word schemesField_;
//- Flag to indicate whether to write the field multiplied by the phase
// fraction
bool writeAlphaField_;
//- Run-time selectable finite volume options, e.g. sources, constraints
fv::optionList fvOptions_;
@ -165,7 +171,7 @@ class phaseScalarTransport
volScalarField s_;
//- The field multiplied by the phase fraction
volScalarField alphaS_;
autoPtr<volScalarField> alphaSPtr_;
//- Potential field used to generate the phase flux
autoPtr<volScalarField> PhiPtr_;