From 5bd7c4b5bb83454164ec75b3e6ad3c4b10e148b4 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 9 Jul 2019 11:44:52 +0100 Subject: [PATCH] BUG: pressure FO - corrected handling of enumeration in calcPressure function. See #1356 --- src/functionObjects/field/pressure/pressure.C | 72 +++++++++---------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/src/functionObjects/field/pressure/pressure.C b/src/functionObjects/field/pressure/pressure.C index df050772ae..312dda2f41 100644 --- a/src/functionObjects/field/pressure/pressure.C +++ b/src/functionObjects/field/pressure/pressure.C @@ -146,44 +146,38 @@ Foam::tmp Foam::functionObjects::pressure::calcPressure const tmp& tp ) const { - switch (mode_) + if (mode_ & TOTAL) { - case TOTAL: - { - return - tp - + dimensionedScalar("pRef", dimPressure, pRef_) - + rhoScale(p, 0.5*magSqr(lookupObject(UName_))); - } - case ISENTROPIC: - { - const basicThermo* thermoPtr = - p.mesh().lookupObjectPtr(basicThermo::dictName); - - if (!thermoPtr) - { - FatalErrorInFunction - << "Isentropic pressure calculation requires a " - << "thermodynamics package" - << exit(FatalError); - } - - const volScalarField gamma(thermoPtr->gamma()); - const volScalarField Mb - ( - mag(lookupObject(UName_)) - /sqrt(gamma*tp.ref()/thermoPtr->rho()) - ); - - return tp()*(pow(1 + (gamma - 1)/2*sqr(Mb), gamma/(gamma - 1))); - } - default: - { - return - tp - + dimensionedScalar("pRef", dimPressure, pRef_); - } + return + tp + + dimensionedScalar("pRef", dimPressure, pRef_) + + rhoScale(p, 0.5*magSqr(lookupObject(UName_))); } + + if (mode_ & ISENTROPIC) + { + const basicThermo* thermoPtr = + p.mesh().lookupObjectPtr(basicThermo::dictName); + + if (!thermoPtr) + { + FatalErrorInFunction + << "Isentropic pressure calculation requires a " + << "thermodynamics package" + << exit(FatalError); + } + + const volScalarField gamma(thermoPtr->gamma()); + const volScalarField Mb + ( + mag(lookupObject(UName_)) + /sqrt(gamma*tp.ref()/thermoPtr->rho()) + ); + + return tp()*(pow(1 + (gamma - 1)/2*sqr(Mb), gamma/(gamma - 1))); + } + + return tp + dimensionedScalar("pRef", dimPressure, pRef_); } @@ -207,10 +201,8 @@ Foam::tmp Foam::functionObjects::pressure::coeff return tpCoeff; } - else - { - return std::move(tp); - } + + return std::move(tp); }