ENH: Improved backwards compatibility for pressure FO

This commit is contained in:
Andrew Heather
2019-06-19 15:02:58 +01:00
parent 355d6c4c4f
commit 32bd3800b1
2 changed files with 12 additions and 10 deletions

View File

@ -281,10 +281,17 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
rhoInfInitialised_ = true; rhoInfInitialised_ = true;
} }
if (dict.found("calcTotal")) if (!modeNames.readIfPresent("mode", dict, mode_))
{ {
// Backwards compatibility - check for the presence of 'calcTotal' // Backwards compatibility
if (dict.getCompat<bool>("mode", {{"calcTotal", 1812}})) // - check for the presence of 'calcTotal' and 'calcCoeff'
bool calcTotal =
dict.getOrDefaultCompat<bool>("mode", {{"calcTotal", 1812}}, false);
bool calcCoeff =
dict.getOrDefaultCompat<bool>("mode", {{"calcCoeff", 1812}}, false);
if (calcTotal)
{ {
mode_ = TOTAL; mode_ = TOTAL;
} }
@ -293,15 +300,11 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
mode_ = STATIC; mode_ = STATIC;
} }
if (dict.getCompat<bool>("mode", {{"calcCoeff", 1812}})) if (calcCoeff)
{ {
mode_ = static_cast<mode>(COEFF | mode_); mode_ = static_cast<mode>(COEFF | mode_);
} }
} }
else
{
mode_ = modeNames.get("mode", dict);
}
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0); pRef_ = dict.lookupOrDefault<scalar>("pRef", 0);

View File

@ -82,8 +82,7 @@ Usage
type pressure; type pressure;
libs ("libfieldFunctionObjects.so"); libs ("libfieldFunctionObjects.so");
... ...
calcTotal no; mode staticCoeff;
calcCoeff yes;
} }
\endverbatim \endverbatim