Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement TEMP option #4411

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,10 @@ namespace Opm {
m_diffuse = true;
}

this->m_isThermal = runspec.hasKeyword<ParserKeywords::THERMAL>()
|| runspec.hasKeyword<ParserKeywords::TEMP>();

this->m_useEnthalpy = runspec.hasKeyword<ParserKeywords::THERMAL>();
this->m_isThermal = runspec.hasKeyword<ParserKeywords::THERMAL>();
this->m_isTemp = runspec.hasKeyword<ParserKeywords::TEMP>();

if(runspec.hasKeyword<ParserKeywords::TEMP>()){
this->m_useEnthalpy = false;
if(runspec.hasKeyword<ParserKeywords::THERMAL>()){
throw std::invalid_argument {
"ERROR: In the RUNSPEC section the BOTH TEMP and THERMAL keyword "
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand All @@ -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};
};
Expand Down
27 changes: 8 additions & 19 deletions opm/material/fluidstates/BlackOilFluidState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand All @@ -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 All @@ -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_<FluidSystem, FluidState, Scalar>(fs, phaseIdx, 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,8 +669,8 @@ class BlackOilFluidState
return FluidSystem::canonicalToActivePhaseIdx(canonicalPhaseIdx);
}

ConditionalStorage<enableTemperature || enableEnergy, Scalar> temperature_{};
ConditionalStorage<enableEnergy, std::array<Scalar, numStoragePhases> > enthalpy_{};
Scalar temperature_{};
ConditionalStorage<enableTemperature || enableEnergy, std::array<Scalar, numStoragePhases> > enthalpy_{};
Scalar totalSaturation_{};
std::array<Scalar, numStoragePhases> pressure_{};
std::array<Scalar, numStoragePhases> pc_{};
Expand Down
5 changes: 0 additions & 5 deletions opm/material/fluidsystems/BlackOilFluidSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ template <class Scalar, class IndexTraits>
void BlackOilFluidSystem<Scalar,IndexTraits>::
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);

Expand Down
1 change: 0 additions & 1 deletion opm/material/fluidsystems/blackoilpvt/DryGasPvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#endif

#include <fmt/format.h>

namespace Opm {

#if HAVE_ECL_INPUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 0 additions & 1 deletion opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ initFromState(const EclipseState& eclState, const Schedule& schedule)
//////
isothermalPvt_ = new IsothermalPvt;
isothermalPvt_->initFromState(eclState, schedule);

//////
// initialize the thermal part
//////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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