Skip to content

Commit

Permalink
always store temperature in the fluid state
Browse files Browse the repository at this point in the history
  • Loading branch information
Tor Harald Sandve committed Jan 9, 2025
1 parent 55359d3 commit 3d5a460
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions opm/material/fluidstates/BlackOilFluidState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ class BlackOilFluidState
Valgrind::CheckDefined(*saltSaturation_);
}

if constexpr (enableTemperature || enableEnergy)
Valgrind::CheckDefined(*temperature_);
Valgrind::CheckDefined(temperature_);
#endif // NDEBUG
}

Expand All @@ -187,8 +186,7 @@ class BlackOilFluidState
template <class FluidState>
void assign(const FluidState& fs)
{
if constexpr (enableTemperature || enableEnergy)
setTemperature(fs.temperature(/*phaseIdx=*/0));
setTemperature(fs.temperature(/*phaseIdx=*/0));

unsigned pvtRegionIdx = getPvtRegionIndex_<FluidState>(fs);
setPvtRegionIndex(pvtRegionIdx);
Expand Down Expand Up @@ -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;
}

/*!
Expand Down Expand Up @@ -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_;
}

/*!
Expand Down Expand Up @@ -680,7 +669,7 @@ class BlackOilFluidState
return FluidSystem::canonicalToActivePhaseIdx(canonicalPhaseIdx);
}

ConditionalStorage<enableTemperature || enableEnergy, Scalar> temperature_{};
Scalar temperature_{};
ConditionalStorage<enableTemperature || enableEnergy, std::array<Scalar, numStoragePhases> > enthalpy_{};
Scalar totalSaturation_{};
std::array<Scalar, numStoragePhases> pressure_{};
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/SimulationConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

{
Expand Down

0 comments on commit 3d5a460

Please sign in to comment.