From f48ee17d59c67f545fc881e8a492458c4cec070e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 11 May 2021 12:28:10 +0200 Subject: [PATCH] changed: make has_foam contexpr and use if constexpr to eliminate some code --- opm/simulators/wells/WellInterface.hpp | 2 +- opm/simulators/wells/WellInterface_impl.hpp | 22 ++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index 75d6737b9..3585242cb 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -114,7 +114,7 @@ namespace Opm static const bool has_temperature = getPropValue(); // flag for polymer molecular weight related static const bool has_polymermw = getPropValue(); - static const bool has_foam = getPropValue(); + static constexpr bool has_foam = getPropValue(); static const bool has_brine = getPropValue(); static const int contiSolventEqIdx = Indices::contiSolventEqIdx; static const int contiZfracEqIdx = Indices::contiZfracEqIdx; diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index f80310023..a15894056 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -400,19 +400,19 @@ namespace Opm WellInterface:: wfoam() const { - if (!has_foam) { - return 0.0; + if constexpr (has_foam) { + auto injectorType = well_ecl_.injectorType(); + + if (injectorType == InjectorType::GAS) { + WellFoamProperties fprop = well_ecl_.getFoamProperties(); + return fprop.m_foamConcentration; + } else { + // Not a gas injection well => no foam. + return 0.0; + } } - auto injectorType = well_ecl_.injectorType(); - - if (injectorType == InjectorType::GAS) { - WellFoamProperties fprop = well_ecl_.getFoamProperties(); - return fprop.m_foamConcentration; - } else { - // Not a gas injection well => no foam. - return 0.0; - } + return 0.0; }