diff --git a/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C index ca5a0c13fb..55facc33d8 100644 --- a/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C +++ b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.C @@ -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("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; diff --git a/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H index aff03121b3..7f0a4e95ef 100644 --- a/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H +++ b/src/functionObjects/solvers/phaseScalarTransport/phaseScalarTransport.H @@ -48,14 +48,16 @@ Description Usage \table - Property | Description | Req'd? | Default - alpha | Name of the volume-fraction field | no \\ - | alpha. - alphaPhi | Name of the phase-flux field | no \\ - | alphaPhi. - 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. + alphaPhi | Name of the phase-flux field | no\\ + | alphaPhi. + 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 alphaSPtr_; //- Potential field used to generate the phase flux autoPtr PhiPtr_;