diff --git a/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp b/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp index 6539f018b1d..383ad66ac1f 100644 --- a/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp +++ b/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp @@ -104,13 +104,10 @@ namespace Opm { m_diffuse = true; } - this->m_isThermal = runspec.hasKeyword() - || runspec.hasKeyword(); - - this->m_useEnthalpy = runspec.hasKeyword(); + this->m_isThermal = runspec.hasKeyword(); + this->m_isTemp = runspec.hasKeyword(); if(runspec.hasKeyword()){ - this->m_useEnthalpy = false; if(runspec.hasKeyword()){ throw std::invalid_argument { "ERROR: In the RUNSPEC section the BOTH TEMP and THERMAL keyword " @@ -140,6 +137,7 @@ namespace Opm { result.m_VAPOIL = true; result.m_VAPWAT = true; result.m_isThermal = true; + result.m_isTemp = true; result.m_diffuse = true; result.m_PRECSALT = true; @@ -206,9 +204,9 @@ namespace Opm { return this->m_isThermal; } - bool SimulationConfig::useEnthalpy() const + bool SimulationConfig::isTemp() const { - return this->m_useEnthalpy; + return this->m_isTemp; } bool SimulationConfig::isDiffusive() const @@ -233,6 +231,7 @@ namespace Opm { && (this->hasDISGASW() == data.hasDISGASW()) && (this->hasVAPOIL() == data.hasVAPOIL()) && (this->hasVAPWAT() == data.hasVAPWAT()) + && (this->isTemp() == data.isTemp()) && (this->isThermal() == data.isThermal()) && (this->isDiffusive() == data.isDiffusive()) && (this->hasPRECSALT() == data.hasPRECSALT()) @@ -252,6 +251,7 @@ namespace Opm { && (full_config.hasDISGASW() == rst_config.hasDISGASW()) && (full_config.hasVAPOIL() == rst_config.hasVAPOIL()) && (full_config.hasVAPWAT() == rst_config.hasVAPWAT()) + && (full_config.isTemp() == rst_config.isTemp()) && (full_config.isThermal() == rst_config.isThermal()) && (full_config.isDiffusive() == rst_config.isDiffusive()) && (full_config.hasPRECSALT() == rst_config.hasPRECSALT()) diff --git a/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp b/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp index a7dd7fd7ab6..72df281a344 100644 --- a/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp +++ b/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp @@ -57,7 +57,7 @@ namespace Opm { bool hasVAPOIL() const; bool hasVAPWAT() const; bool isThermal() const; - bool useEnthalpy() const; + bool isTemp() const; bool isDiffusive() const; bool hasPRECSALT() const; @@ -78,8 +78,8 @@ namespace Opm { serializer(m_DISGASW); serializer(m_VAPOIL); serializer(m_VAPWAT); + serializer(m_isTemp); serializer(m_isThermal); - serializer(m_useEnthalpy); serializer(m_diffuse); serializer(m_PRECSALT); } @@ -97,8 +97,8 @@ namespace Opm { bool m_DISGASW{false}; bool m_VAPOIL{false}; bool m_VAPWAT{false}; + bool m_isTemp{false}; bool m_isThermal{false}; - bool m_useEnthalpy{false}; bool m_diffuse{false}; bool m_PRECSALT{false}; }; diff --git a/opm/material/fluidstates/BlackOilFluidState.hpp b/opm/material/fluidstates/BlackOilFluidState.hpp index 7675ae3d8be..b8fab65c5b7 100644 --- a/opm/material/fluidstates/BlackOilFluidState.hpp +++ b/opm/material/fluidstates/BlackOilFluidState.hpp @@ -150,7 +150,7 @@ class BlackOilFluidState Valgrind::CheckDefined(density_[storagePhaseIdx]); Valgrind::CheckDefined(invB_[storagePhaseIdx]); - if constexpr (enableEnergy) + if constexpr (enableTemperature || enableEnergy) Valgrind::CheckDefined((*enthalpy_)[storagePhaseIdx]); } @@ -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); @@ -215,7 +213,7 @@ class BlackOilFluidState setPressure(phaseIdx, fs.pressure(phaseIdx)); setDensity(phaseIdx, fs.density(phaseIdx)); - if constexpr (enableEnergy) + if constexpr (enableEnergy || enableTemperature) setEnthalpy(phaseIdx, fs.enthalpy(phaseIdx)); setInvB(phaseIdx, getInvB_(fs, phaseIdx, 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,8 +669,8 @@ class BlackOilFluidState return FluidSystem::canonicalToActivePhaseIdx(canonicalPhaseIdx); } - ConditionalStorage temperature_{}; - ConditionalStorage > enthalpy_{}; + Scalar temperature_{}; + ConditionalStorage > enthalpy_{}; Scalar totalSaturation_{}; std::array pressure_{}; std::array pc_{}; diff --git a/opm/material/fluidsystems/BlackOilFluidSystem.cpp b/opm/material/fluidsystems/BlackOilFluidSystem.cpp index b41e19245bb..e09ac4b32ed 100644 --- a/opm/material/fluidsystems/BlackOilFluidSystem.cpp +++ b/opm/material/fluidsystems/BlackOilFluidSystem.cpp @@ -43,11 +43,6 @@ template void BlackOilFluidSystem:: initFromState(const EclipseState& eclState, const Schedule& schedule) { - if (eclState.getSimulationConfig().useEnthalpy()) { - enthalpy_eq_energy_ = false; - } else { - enthalpy_eq_energy_ = true; - } std::size_t num_regions = eclState.runspec().tabdims().getNumPVTTables(); initBegin(num_regions); diff --git a/opm/material/fluidsystems/blackoilpvt/DryGasPvt.cpp b/opm/material/fluidsystems/blackoilpvt/DryGasPvt.cpp index f62bc3af8ce..ee81852396c 100644 --- a/opm/material/fluidsystems/blackoilpvt/DryGasPvt.cpp +++ b/opm/material/fluidsystems/blackoilpvt/DryGasPvt.cpp @@ -33,7 +33,6 @@ #endif #include - namespace Opm { #if HAVE_ECL_INPUT diff --git a/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.cpp b/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.cpp index d48fc2e6c93..bbd1bdc43b0 100644 --- a/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.cpp +++ b/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.cpp @@ -116,7 +116,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) setApproach(GasPvtApproach::Co2Gas); else if (eclState.runspec().h2Storage()) setApproach(GasPvtApproach::H2Gas); - else if (enableThermal && eclState.getSimulationConfig().isThermal()) + else if (enableThermal && (eclState.getSimulationConfig().isThermal() || eclState.getSimulationConfig().isTemp())) setApproach(GasPvtApproach::ThermalGas); else if (!eclState.getTableManager().getPvtgwTables().empty() && !eclState.getTableManager().getPvtgTables().empty()) diff --git a/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp b/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp index 2676bddfb58..9f37912d6ed 100644 --- a/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp +++ b/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp @@ -46,7 +46,6 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) ////// isothermalPvt_ = new IsothermalPvt; isothermalPvt_->initFromState(eclState, schedule); - ////// // initialize the thermal part ////// diff --git a/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp b/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp index ac0f6cd3801..08f1d0b8e4b 100644 --- a/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp +++ b/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp @@ -77,7 +77,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) setApproach(OilPvtApproach::BrineCo2); else if (eclState.runspec().h2Storage()) setApproach(OilPvtApproach::BrineH2); - else if (enableThermal && eclState.getSimulationConfig().isThermal()) + else if (enableThermal && (eclState.getSimulationConfig().isThermal() || eclState.getSimulationConfig().isTemp())) setApproach(OilPvtApproach::ThermalOil); else if (!eclState.getTableManager().getPvcdoTable().empty()) setApproach(OilPvtApproach::ConstantCompressibilityOil); diff --git a/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.cpp b/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.cpp index d3dd4b6af59..397e0666869 100644 --- a/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.cpp +++ b/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.cpp @@ -73,7 +73,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) setApproach(WaterPvtApproach::BrineCo2); else if (eclState.runspec().h2Storage() || eclState.runspec().h2Sol()) setApproach(WaterPvtApproach::BrineH2); - else if (enableThermal && eclState.getSimulationConfig().isThermal()) + else if (enableThermal && (eclState.getSimulationConfig().isThermal() || eclState.getSimulationConfig().isTemp())) setApproach(WaterPvtApproach::ThermalWater); else if (!eclState.getTableManager().getPvtwTable().empty()) setApproach(WaterPvtApproach::ConstantCompressibilityWater); 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()); } {