From 3d5a4602abd1923b4bd9f0933dd2bdbb5d33be13 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 8 Jan 2025 12:03:48 +0100 Subject: [PATCH] always store temperature in the fluid state --- .../fluidstates/BlackOilFluidState.hpp | 21 +++++-------------- tests/parser/SimulationConfigTest.cpp | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/opm/material/fluidstates/BlackOilFluidState.hpp b/opm/material/fluidstates/BlackOilFluidState.hpp index 269107235c9..b8fab65c5b7 100644 --- a/opm/material/fluidstates/BlackOilFluidState.hpp +++ b/opm/material/fluidstates/BlackOilFluidState.hpp @@ -175,8 +175,7 @@ class BlackOilFluidState Valgrind::CheckDefined(*saltSaturation_); } - if constexpr (enableTemperature || enableEnergy) - Valgrind::CheckDefined(*temperature_); + Valgrind::CheckDefined(temperature_); #endif // NDEBUG } @@ -187,8 +186,7 @@ class BlackOilFluidState template void assign(const FluidState& fs) { - if constexpr (enableTemperature || enableEnergy) - setTemperature(fs.temperature(/*phaseIdx=*/0)); + setTemperature(fs.temperature(/*phaseIdx=*/0)); unsigned pvtRegionIdx = getPvtRegionIndex_(fs); setPvtRegionIndex(pvtRegionIdx); @@ -260,14 +258,10 @@ class BlackOilFluidState /*! * \brief Set the temperature [K] * - * If neither the enableTemperature nor the enableEnergy template arguments are set - * to true, this method will throw an exception! */ void setTemperature(const Scalar& value) { - assert(enableTemperature || enableEnergy); - - (*temperature_) = value; + temperature_ = value; } /*! @@ -370,12 +364,7 @@ class BlackOilFluidState */ const Scalar& temperature(unsigned) const { - if constexpr (enableTemperature || enableEnergy) { - return *temperature_; - } else { - static Scalar tmp(FluidSystem::reservoirTemperature(pvtRegionIdx_)); - return tmp; - } + return temperature_; } /*! @@ -680,7 +669,7 @@ class BlackOilFluidState return FluidSystem::canonicalToActivePhaseIdx(canonicalPhaseIdx); } - ConditionalStorage temperature_{}; + Scalar temperature_{}; ConditionalStorage > enthalpy_{}; Scalar totalSaturation_{}; std::array pressure_{}; diff --git a/tests/parser/SimulationConfigTest.cpp b/tests/parser/SimulationConfigTest.cpp index 71538934e03..79a56944501 100644 --- a/tests/parser/SimulationConfigTest.cpp +++ b/tests/parser/SimulationConfigTest.cpp @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(SimulationConfig_TEMP_THERMAL) const auto fp = FieldPropsManager(deck, Phases{true, true, true}, eg, tm); const auto simulationConfig = Opm::SimulationConfig(false, deck, fp); - BOOST_CHECK(simulationConfig.isThermal()); + BOOST_CHECK(simulationConfig.isTemp()); } {