changed: make enums enum class

and put them outside class defintion to avoid template
parameter dependence.
This commit is contained in:
Arne Morten Kvarving 2021-05-05 21:22:04 +02:00
parent 13f0659d71
commit 7241acabac
3 changed files with 193 additions and 193 deletions

View File

@ -37,32 +37,39 @@
#endif #endif
namespace Opm { namespace Opm {
#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \ #define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
switch (gasPvtApproach_) { \ switch (gasPvtApproach_) { \
case DryGasPvt: { \ case GasPvtApproach::DryGasPvt: { \
auto& pvtImpl = getRealPvt<DryGasPvt>(); \ auto& pvtImpl = getRealPvt<GasPvtApproach::DryGasPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case WetGasPvt: { \ case GasPvtApproach::WetGasPvt: { \
auto& pvtImpl = getRealPvt<WetGasPvt>(); \ auto& pvtImpl = getRealPvt<GasPvtApproach::WetGasPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case ThermalGasPvt: { \ case GasPvtApproach::ThermalGasPvt: { \
auto& pvtImpl = getRealPvt<ThermalGasPvt>(); \ auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGasPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case Co2GasPvt: { \ case GasPvtApproach::Co2GasPvt: { \
auto& pvtImpl = getRealPvt<Co2GasPvt>(); \ auto& pvtImpl = getRealPvt<GasPvtApproach::Co2GasPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case NoGasPvt: \ case GasPvtApproach::NoGasPvt: \
throw std::logic_error("Not implemented: Gas PVT of this deck!"); \ throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
} \ } \
enum class GasPvtApproach {
NoGasPvt,
DryGasPvt,
WetGasPvt,
ThermalGasPvt,
Co2GasPvt
};
/*! /*!
* \brief This class represents the Pressure-Volume-Temperature relations of the gas * \brief This class represents the Pressure-Volume-Temperature relations of the gas
@ -80,17 +87,9 @@ class GasPvtMultiplexer
public: public:
typedef Opm::GasPvtThermal<Scalar> GasPvtThermal; typedef Opm::GasPvtThermal<Scalar> GasPvtThermal;
enum GasPvtApproach {
NoGasPvt,
DryGasPvt,
WetGasPvt,
ThermalGasPvt,
Co2GasPvt
};
GasPvtMultiplexer() GasPvtMultiplexer()
{ {
gasPvtApproach_ = NoGasPvt; gasPvtApproach_ = GasPvtApproach::NoGasPvt;
realGasPvt_ = nullptr; realGasPvt_ = nullptr;
} }
@ -107,23 +106,23 @@ public:
~GasPvtMultiplexer() ~GasPvtMultiplexer()
{ {
switch (gasPvtApproach_) { switch (gasPvtApproach_) {
case DryGasPvt: { case GasPvtApproach::DryGasPvt: {
delete &getRealPvt<DryGasPvt>(); delete &getRealPvt<GasPvtApproach::DryGasPvt>();
break; break;
} }
case WetGasPvt: { case GasPvtApproach::WetGasPvt: {
delete &getRealPvt<WetGasPvt>(); delete &getRealPvt<GasPvtApproach::WetGasPvt>();
break; break;
} }
case ThermalGasPvt: { case GasPvtApproach::ThermalGasPvt: {
delete &getRealPvt<ThermalGasPvt>(); delete &getRealPvt<GasPvtApproach::ThermalGasPvt>();
break; break;
} }
case Co2GasPvt: { case GasPvtApproach::Co2GasPvt: {
delete &getRealPvt<Co2GasPvt>(); delete &getRealPvt<GasPvtApproach::Co2GasPvt>();
break; break;
} }
case NoGasPvt: case GasPvtApproach::NoGasPvt:
break; break;
} }
} }
@ -139,13 +138,13 @@ public:
if (!eclState.runspec().phases().active(Phase::GAS)) if (!eclState.runspec().phases().active(Phase::GAS))
return; return;
if (eclState.runspec().co2Storage()) if (eclState.runspec().co2Storage())
setApproach(Co2GasPvt); setApproach(GasPvtApproach::Co2GasPvt);
else if (enableThermal && eclState.getSimulationConfig().isThermal()) else if (enableThermal && eclState.getSimulationConfig().isThermal())
setApproach(ThermalGasPvt); setApproach(GasPvtApproach::ThermalGasPvt);
else if (!eclState.getTableManager().getPvtgTables().empty()) else if (!eclState.getTableManager().getPvtgTables().empty())
setApproach(WetGasPvt); setApproach(GasPvtApproach::WetGasPvt);
else if (eclState.getTableManager().hasTables("PVDG")) else if (eclState.getTableManager().hasTables("PVDG"))
setApproach(DryGasPvt); setApproach(GasPvtApproach::DryGasPvt);
OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule)); OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
} }
@ -154,23 +153,23 @@ public:
void setApproach(GasPvtApproach gasPvtAppr) void setApproach(GasPvtApproach gasPvtAppr)
{ {
switch (gasPvtAppr) { switch (gasPvtAppr) {
case DryGasPvt: case GasPvtApproach::DryGasPvt:
realGasPvt_ = new Opm::DryGasPvt<Scalar>; realGasPvt_ = new Opm::DryGasPvt<Scalar>;
break; break;
case WetGasPvt: case GasPvtApproach::WetGasPvt:
realGasPvt_ = new Opm::WetGasPvt<Scalar>; realGasPvt_ = new Opm::WetGasPvt<Scalar>;
break; break;
case ThermalGasPvt: case GasPvtApproach::ThermalGasPvt:
realGasPvt_ = new Opm::GasPvtThermal<Scalar>; realGasPvt_ = new Opm::GasPvtThermal<Scalar>;
break; break;
case Co2GasPvt: case GasPvtApproach::Co2GasPvt:
realGasPvt_ = new Opm::Co2GasPvt<Scalar>; realGasPvt_ = new Opm::Co2GasPvt<Scalar>;
break; break;
case NoGasPvt: case GasPvtApproach::NoGasPvt:
throw std::logic_error("Not implemented: Gas PVT of this deck!"); throw std::logic_error("Not implemented: Gas PVT of this deck!");
} }
@ -293,14 +292,14 @@ public:
// get the parameter object for the dry gas case // get the parameter object for the dry gas case
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == DryGasPvt, Opm::DryGasPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, Opm::DryGasPvt<Scalar> >::type& getRealPvt()
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<Opm::DryGasPvt<Scalar>* >(realGasPvt_); return *static_cast<Opm::DryGasPvt<Scalar>* >(realGasPvt_);
} }
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == DryGasPvt, const Opm::DryGasPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, const Opm::DryGasPvt<Scalar> >::type& getRealPvt() const
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<const Opm::DryGasPvt<Scalar>* >(realGasPvt_); return *static_cast<const Opm::DryGasPvt<Scalar>* >(realGasPvt_);
@ -308,14 +307,14 @@ public:
// get the parameter object for the wet gas case // get the parameter object for the wet gas case
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == WetGasPvt, Opm::WetGasPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, Opm::WetGasPvt<Scalar> >::type& getRealPvt()
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<Opm::WetGasPvt<Scalar>* >(realGasPvt_); return *static_cast<Opm::WetGasPvt<Scalar>* >(realGasPvt_);
} }
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == WetGasPvt, const Opm::WetGasPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, const Opm::WetGasPvt<Scalar> >::type& getRealPvt() const
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<const Opm::WetGasPvt<Scalar>* >(realGasPvt_); return *static_cast<const Opm::WetGasPvt<Scalar>* >(realGasPvt_);
@ -323,28 +322,28 @@ public:
// get the parameter object for the thermal gas case // get the parameter object for the thermal gas case
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == ThermalGasPvt, Opm::GasPvtThermal<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, Opm::GasPvtThermal<Scalar> >::type& getRealPvt()
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<Opm::GasPvtThermal<Scalar>* >(realGasPvt_); return *static_cast<Opm::GasPvtThermal<Scalar>* >(realGasPvt_);
} }
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == ThermalGasPvt, const Opm::GasPvtThermal<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, const Opm::GasPvtThermal<Scalar> >::type& getRealPvt() const
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<const Opm::GasPvtThermal<Scalar>* >(realGasPvt_); return *static_cast<const Opm::GasPvtThermal<Scalar>* >(realGasPvt_);
} }
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == Co2GasPvt, Opm::Co2GasPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, Opm::Co2GasPvt<Scalar> >::type& getRealPvt()
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<Opm::Co2GasPvt<Scalar>* >(realGasPvt_); return *static_cast<Opm::Co2GasPvt<Scalar>* >(realGasPvt_);
} }
template <GasPvtApproach approachV> template <GasPvtApproach approachV>
typename std::enable_if<approachV == Co2GasPvt, const Opm::Co2GasPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, const Opm::Co2GasPvt<Scalar> >::type& getRealPvt() const
{ {
assert(gasPvtApproach() == approachV); assert(gasPvtApproach() == approachV);
return *static_cast<const Opm::Co2GasPvt<Scalar>* >(realGasPvt_); return *static_cast<const Opm::Co2GasPvt<Scalar>* >(realGasPvt_);
@ -358,16 +357,16 @@ public:
return false; return false;
switch (gasPvtApproach_) { switch (gasPvtApproach_) {
case DryGasPvt: case GasPvtApproach::DryGasPvt:
return *static_cast<const Opm::DryGasPvt<Scalar>*>(realGasPvt_) == return *static_cast<const Opm::DryGasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_); *static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_);
case WetGasPvt: case GasPvtApproach::WetGasPvt:
return *static_cast<const Opm::WetGasPvt<Scalar>*>(realGasPvt_) == return *static_cast<const Opm::WetGasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_); *static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_);
case ThermalGasPvt: case GasPvtApproach::ThermalGasPvt:
return *static_cast<const Opm::GasPvtThermal<Scalar>*>(realGasPvt_) == return *static_cast<const Opm::GasPvtThermal<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_); *static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_);
case Co2GasPvt: case GasPvtApproach::Co2GasPvt:
return *static_cast<const Opm::Co2GasPvt<Scalar>*>(realGasPvt_) == return *static_cast<const Opm::Co2GasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::Co2GasPvt<Scalar>*>(data.realGasPvt_); *static_cast<const Opm::Co2GasPvt<Scalar>*>(data.realGasPvt_);
default: default:
@ -379,16 +378,16 @@ public:
{ {
gasPvtApproach_ = data.gasPvtApproach_; gasPvtApproach_ = data.gasPvtApproach_;
switch (gasPvtApproach_) { switch (gasPvtApproach_) {
case DryGasPvt: case GasPvtApproach::DryGasPvt:
realGasPvt_ = new Opm::DryGasPvt<Scalar>(*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_)); realGasPvt_ = new Opm::DryGasPvt<Scalar>(*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_));
break; break;
case WetGasPvt: case GasPvtApproach::WetGasPvt:
realGasPvt_ = new Opm::WetGasPvt<Scalar>(*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_)); realGasPvt_ = new Opm::WetGasPvt<Scalar>(*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_));
break; break;
case ThermalGasPvt: case GasPvtApproach::ThermalGasPvt:
realGasPvt_ = new Opm::GasPvtThermal<Scalar>(*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_)); realGasPvt_ = new Opm::GasPvtThermal<Scalar>(*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_));
break; break;
case Co2GasPvt: case GasPvtApproach::Co2GasPvt:
realGasPvt_ = new Opm::Co2GasPvt<Scalar>(*static_cast<const Opm::Co2GasPvt<Scalar>*>(data.realGasPvt_)); realGasPvt_ = new Opm::Co2GasPvt<Scalar>(*static_cast<const Opm::Co2GasPvt<Scalar>*>(data.realGasPvt_));
break; break;
default: default:

View File

@ -39,36 +39,45 @@
#endif #endif
namespace Opm { namespace Opm {
#define OPM_OIL_PVT_MULTIPLEXER_CALL(codeToCall) \ #define OPM_OIL_PVT_MULTIPLEXER_CALL(codeToCall) \
switch (approach_) { \ switch (approach_) { \
case ConstantCompressibilityOilPvt: { \ case OilPvtApproach::ConstantCompressibilityOilPvt: { \
auto& pvtImpl = getRealPvt<ConstantCompressibilityOilPvt>(); \ auto& pvtImpl = getRealPvt<OilPvtApproach::ConstantCompressibilityOilPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case DeadOilPvt: { \ case OilPvtApproach::DeadOilPvt: { \
auto& pvtImpl = getRealPvt<DeadOilPvt>(); \ auto& pvtImpl = getRealPvt<OilPvtApproach::DeadOilPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case LiveOilPvt: { \ case OilPvtApproach::LiveOilPvt: { \
auto& pvtImpl = getRealPvt<LiveOilPvt>(); \ auto& pvtImpl = getRealPvt<OilPvtApproach::LiveOilPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case ThermalOilPvt: { \ case OilPvtApproach::ThermalOilPvt: { \
auto& pvtImpl = getRealPvt<ThermalOilPvt>(); \ auto& pvtImpl = getRealPvt<OilPvtApproach::ThermalOilPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case BrineCo2Pvt: { \ case OilPvtApproach::BrineCo2Pvt: { \
auto& pvtImpl = getRealPvt<BrineCo2Pvt>(); \ auto& pvtImpl = getRealPvt<OilPvtApproach::BrineCo2Pvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case NoOilPvt: \ case OilPvtApproach::NoOilPvt: \
throw std::logic_error("Not implemented: Oil PVT of this deck!"); \ throw std::logic_error("Not implemented: Oil PVT of this deck!"); \
} \ } \
enum class OilPvtApproach {
NoOilPvt,
LiveOilPvt,
DeadOilPvt,
ConstantCompressibilityOilPvt,
ThermalOilPvt,
BrineCo2Pvt
};
/*! /*!
* \brief This class represents the Pressure-Volume-Temperature relations of the oil * \brief This class represents the Pressure-Volume-Temperature relations of the oil
@ -88,18 +97,9 @@ class OilPvtMultiplexer
public: public:
typedef Opm::OilPvtThermal<Scalar> OilPvtThermal; typedef Opm::OilPvtThermal<Scalar> OilPvtThermal;
enum OilPvtApproach {
NoOilPvt,
LiveOilPvt,
DeadOilPvt,
ConstantCompressibilityOilPvt,
ThermalOilPvt,
BrineCo2Pvt
};
OilPvtMultiplexer() OilPvtMultiplexer()
{ {
approach_ = NoOilPvt; approach_ = OilPvtApproach::NoOilPvt;
realOilPvt_ = nullptr; realOilPvt_ = nullptr;
} }
@ -116,28 +116,28 @@ public:
~OilPvtMultiplexer() ~OilPvtMultiplexer()
{ {
switch (approach_) { switch (approach_) {
case LiveOilPvt: { case OilPvtApproach::LiveOilPvt: {
delete &getRealPvt<LiveOilPvt>(); delete &getRealPvt<OilPvtApproach::LiveOilPvt>();
break; break;
} }
case DeadOilPvt: { case OilPvtApproach::DeadOilPvt: {
delete &getRealPvt<DeadOilPvt>(); delete &getRealPvt<OilPvtApproach::DeadOilPvt>();
break; break;
} }
case ConstantCompressibilityOilPvt: { case OilPvtApproach::ConstantCompressibilityOilPvt: {
delete &getRealPvt<ConstantCompressibilityOilPvt>(); delete &getRealPvt<OilPvtApproach::ConstantCompressibilityOilPvt>();
break; break;
} }
case ThermalOilPvt: { case OilPvtApproach::ThermalOilPvt: {
delete &getRealPvt<ThermalOilPvt>(); delete &getRealPvt<OilPvtApproach::ThermalOilPvt>();
break; break;
} }
case BrineCo2Pvt: { case OilPvtApproach::BrineCo2Pvt: {
delete &getRealPvt<BrineCo2Pvt>(); delete &getRealPvt<OilPvtApproach::BrineCo2Pvt>();
break; break;
} }
case NoOilPvt: case OilPvtApproach::NoOilPvt:
break; break;
} }
} }
@ -155,15 +155,15 @@ public:
// TODO move the BrineCo2 approach to the waterPvtMultiplexer // TODO move the BrineCo2 approach to the waterPvtMultiplexer
// when a proper gas-water simulator is supported // when a proper gas-water simulator is supported
if (eclState.runspec().co2Storage()) if (eclState.runspec().co2Storage())
setApproach(BrineCo2Pvt); setApproach(OilPvtApproach::BrineCo2Pvt);
else if (enableThermal && eclState.getSimulationConfig().isThermal()) else if (enableThermal && eclState.getSimulationConfig().isThermal())
setApproach(ThermalOilPvt); setApproach(OilPvtApproach::ThermalOilPvt);
else if (!eclState.getTableManager().getPvcdoTable().empty()) else if (!eclState.getTableManager().getPvcdoTable().empty())
setApproach(ConstantCompressibilityOilPvt); setApproach(OilPvtApproach::ConstantCompressibilityOilPvt);
else if (eclState.getTableManager().hasTables("PVDO")) else if (eclState.getTableManager().hasTables("PVDO"))
setApproach(DeadOilPvt); setApproach(OilPvtApproach::DeadOilPvt);
else if (!eclState.getTableManager().getPvtoTables().empty()) else if (!eclState.getTableManager().getPvtoTables().empty())
setApproach(LiveOilPvt); setApproach(OilPvtApproach::LiveOilPvt);
OPM_OIL_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule)); OPM_OIL_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
} }
@ -280,27 +280,27 @@ public:
void setApproach(OilPvtApproach appr) void setApproach(OilPvtApproach appr)
{ {
switch (appr) { switch (appr) {
case LiveOilPvt: case OilPvtApproach::LiveOilPvt:
realOilPvt_ = new Opm::LiveOilPvt<Scalar>; realOilPvt_ = new Opm::LiveOilPvt<Scalar>;
break; break;
case DeadOilPvt: case OilPvtApproach::DeadOilPvt:
realOilPvt_ = new Opm::DeadOilPvt<Scalar>; realOilPvt_ = new Opm::DeadOilPvt<Scalar>;
break; break;
case ConstantCompressibilityOilPvt: case OilPvtApproach::ConstantCompressibilityOilPvt:
realOilPvt_ = new Opm::ConstantCompressibilityOilPvt<Scalar>; realOilPvt_ = new Opm::ConstantCompressibilityOilPvt<Scalar>;
break; break;
case ThermalOilPvt: case OilPvtApproach::ThermalOilPvt:
realOilPvt_ = new Opm::OilPvtThermal<Scalar>; realOilPvt_ = new Opm::OilPvtThermal<Scalar>;
break; break;
case BrineCo2Pvt: case OilPvtApproach::BrineCo2Pvt:
realOilPvt_ = new Opm::BrineCo2Pvt<Scalar>; realOilPvt_ = new Opm::BrineCo2Pvt<Scalar>;
break; break;
case NoOilPvt: case OilPvtApproach::NoOilPvt:
throw std::logic_error("Not implemented: Oil PVT of this deck!"); throw std::logic_error("Not implemented: Oil PVT of this deck!");
} }
@ -317,70 +317,70 @@ public:
// get the concrete parameter object for the oil phase // get the concrete parameter object for the oil phase
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == LiveOilPvt, Opm::LiveOilPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == OilPvtApproach::LiveOilPvt, Opm::LiveOilPvt<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::LiveOilPvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::LiveOilPvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == LiveOilPvt, const Opm::LiveOilPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == OilPvtApproach::LiveOilPvt, const Opm::LiveOilPvt<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::LiveOilPvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::LiveOilPvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == DeadOilPvt, Opm::DeadOilPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == OilPvtApproach::DeadOilPvt, Opm::DeadOilPvt<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::DeadOilPvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::DeadOilPvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == DeadOilPvt, const Opm::DeadOilPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == OilPvtApproach::DeadOilPvt, const Opm::DeadOilPvt<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::DeadOilPvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::DeadOilPvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == ConstantCompressibilityOilPvt, Opm::ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOilPvt, Opm::ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::ConstantCompressibilityOilPvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::ConstantCompressibilityOilPvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == ConstantCompressibilityOilPvt, const Opm::ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOilPvt, const Opm::ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::ConstantCompressibilityOilPvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::ConstantCompressibilityOilPvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == ThermalOilPvt, Opm::OilPvtThermal<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == OilPvtApproach::ThermalOilPvt, Opm::OilPvtThermal<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::OilPvtThermal<Scalar>* >(realOilPvt_); return *static_cast<Opm::OilPvtThermal<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == ThermalOilPvt, const Opm::OilPvtThermal<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == OilPvtApproach::ThermalOilPvt, const Opm::OilPvtThermal<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<const Opm::OilPvtThermal<Scalar>* >(realOilPvt_); return *static_cast<const Opm::OilPvtThermal<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == BrineCo2Pvt, Opm::BrineCo2Pvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == OilPvtApproach::BrineCo2Pvt, Opm::BrineCo2Pvt<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::BrineCo2Pvt<Scalar>* >(realOilPvt_); return *static_cast<Opm::BrineCo2Pvt<Scalar>* >(realOilPvt_);
} }
template <OilPvtApproach approachV> template <OilPvtApproach approachV>
typename std::enable_if<approachV == BrineCo2Pvt, const Opm::BrineCo2Pvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == OilPvtApproach::BrineCo2Pvt, const Opm::BrineCo2Pvt<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<const Opm::BrineCo2Pvt<Scalar>* >(realOilPvt_); return *static_cast<const Opm::BrineCo2Pvt<Scalar>* >(realOilPvt_);
@ -394,19 +394,19 @@ public:
return false; return false;
switch (approach_) { switch (approach_) {
case ConstantCompressibilityOilPvt: case OilPvtApproach::ConstantCompressibilityOilPvt:
return *static_cast<const Opm::ConstantCompressibilityOilPvt<Scalar>*>(realOilPvt_) == return *static_cast<const Opm::ConstantCompressibilityOilPvt<Scalar>*>(realOilPvt_) ==
*static_cast<const Opm::ConstantCompressibilityOilPvt<Scalar>*>(data.realOilPvt_); *static_cast<const Opm::ConstantCompressibilityOilPvt<Scalar>*>(data.realOilPvt_);
case DeadOilPvt: case OilPvtApproach::DeadOilPvt:
return *static_cast<const Opm::DeadOilPvt<Scalar>*>(realOilPvt_) == return *static_cast<const Opm::DeadOilPvt<Scalar>*>(realOilPvt_) ==
*static_cast<const Opm::DeadOilPvt<Scalar>*>(data.realOilPvt_); *static_cast<const Opm::DeadOilPvt<Scalar>*>(data.realOilPvt_);
case LiveOilPvt: case OilPvtApproach::LiveOilPvt:
return *static_cast<const Opm::LiveOilPvt<Scalar>*>(realOilPvt_) == return *static_cast<const Opm::LiveOilPvt<Scalar>*>(realOilPvt_) ==
*static_cast<const Opm::LiveOilPvt<Scalar>*>(data.realOilPvt_); *static_cast<const Opm::LiveOilPvt<Scalar>*>(data.realOilPvt_);
case ThermalOilPvt: case OilPvtApproach::ThermalOilPvt:
return *static_cast<const Opm::OilPvtThermal<Scalar>*>(realOilPvt_) == return *static_cast<const Opm::OilPvtThermal<Scalar>*>(realOilPvt_) ==
*static_cast<const Opm::OilPvtThermal<Scalar>*>(data.realOilPvt_); *static_cast<const Opm::OilPvtThermal<Scalar>*>(data.realOilPvt_);
case BrineCo2Pvt: case OilPvtApproach::BrineCo2Pvt:
return *static_cast<const Opm::BrineCo2Pvt<Scalar>*>(realOilPvt_) == return *static_cast<const Opm::BrineCo2Pvt<Scalar>*>(realOilPvt_) ==
*static_cast<const Opm::BrineCo2Pvt<Scalar>*>(data.realOilPvt_); *static_cast<const Opm::BrineCo2Pvt<Scalar>*>(data.realOilPvt_);
default: default:
@ -418,19 +418,19 @@ public:
{ {
approach_ = data.approach_; approach_ = data.approach_;
switch (approach_) { switch (approach_) {
case ConstantCompressibilityOilPvt: case OilPvtApproach::ConstantCompressibilityOilPvt:
realOilPvt_ = new Opm::ConstantCompressibilityOilPvt<Scalar>(*static_cast<const Opm::ConstantCompressibilityOilPvt<Scalar>*>(data.realOilPvt_)); realOilPvt_ = new Opm::ConstantCompressibilityOilPvt<Scalar>(*static_cast<const Opm::ConstantCompressibilityOilPvt<Scalar>*>(data.realOilPvt_));
break; break;
case DeadOilPvt: case OilPvtApproach::DeadOilPvt:
realOilPvt_ = new Opm::DeadOilPvt<Scalar>(*static_cast<const Opm::DeadOilPvt<Scalar>*>(data.realOilPvt_)); realOilPvt_ = new Opm::DeadOilPvt<Scalar>(*static_cast<const Opm::DeadOilPvt<Scalar>*>(data.realOilPvt_));
break; break;
case LiveOilPvt: case OilPvtApproach::LiveOilPvt:
realOilPvt_ = new Opm::LiveOilPvt<Scalar>(*static_cast<const Opm::LiveOilPvt<Scalar>*>(data.realOilPvt_)); realOilPvt_ = new Opm::LiveOilPvt<Scalar>(*static_cast<const Opm::LiveOilPvt<Scalar>*>(data.realOilPvt_));
break; break;
case ThermalOilPvt: case OilPvtApproach::ThermalOilPvt:
realOilPvt_ = new Opm::OilPvtThermal<Scalar>(*static_cast<const Opm::OilPvtThermal<Scalar>*>(data.realOilPvt_)); realOilPvt_ = new Opm::OilPvtThermal<Scalar>(*static_cast<const Opm::OilPvtThermal<Scalar>*>(data.realOilPvt_));
break; break;
case BrineCo2Pvt: case OilPvtApproach::BrineCo2Pvt:
realOilPvt_ = new Opm::BrineCo2Pvt<Scalar>(*static_cast<const Opm::BrineCo2Pvt<Scalar>*>(data.realOilPvt_)); realOilPvt_ = new Opm::BrineCo2Pvt<Scalar>(*static_cast<const Opm::BrineCo2Pvt<Scalar>*>(data.realOilPvt_));
break; break;
default: default:

View File

@ -38,26 +38,34 @@
#define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall) \ #define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall) \
switch (approach_) { \ switch (approach_) { \
case ConstantCompressibilityWaterPvt: { \ case WaterPvtApproach::ConstantCompressibilityWaterPvt: { \
auto& pvtImpl = getRealPvt<ConstantCompressibilityWaterPvt>(); \ auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityWaterPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case ConstantCompressibilityBrinePvt: { \ case WaterPvtApproach::ConstantCompressibilityBrinePvt: { \
auto& pvtImpl = getRealPvt<ConstantCompressibilityBrinePvt>(); \ auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrinePvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case ThermalWaterPvt: { \ case WaterPvtApproach::ThermalWaterPvt: { \
auto& pvtImpl = getRealPvt<ThermalWaterPvt>(); \ auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWaterPvt>(); \
codeToCall; \ codeToCall; \
break; \ break; \
} \ } \
case NoWaterPvt: \ case WaterPvtApproach::NoWaterPvt: \
throw std::logic_error("Not implemented: Water PVT of this deck!"); \ throw std::logic_error("Not implemented: Water PVT of this deck!"); \
} }
namespace Opm { namespace Opm {
enum class WaterPvtApproach {
NoWaterPvt,
ConstantCompressibilityBrinePvt,
ConstantCompressibilityWaterPvt,
ThermalWaterPvt
};
/*! /*!
* \brief This class represents the Pressure-Volume-Temperature relations of the water * \brief This class represents the Pressure-Volume-Temperature relations of the water
* phase in the black-oil model. * phase in the black-oil model.
@ -68,16 +76,9 @@ class WaterPvtMultiplexer
public: public:
typedef Opm::WaterPvtThermal<Scalar> WaterPvtThermal; typedef Opm::WaterPvtThermal<Scalar> WaterPvtThermal;
enum WaterPvtApproach {
NoWaterPvt,
ConstantCompressibilityBrinePvt,
ConstantCompressibilityWaterPvt,
ThermalWaterPvt
};
WaterPvtMultiplexer() WaterPvtMultiplexer()
{ {
approach_ = NoWaterPvt; approach_ = WaterPvtApproach::NoWaterPvt;
realWaterPvt_ = nullptr; realWaterPvt_ = nullptr;
} }
@ -94,19 +95,19 @@ public:
~WaterPvtMultiplexer() ~WaterPvtMultiplexer()
{ {
switch (approach_) { switch (approach_) {
case ConstantCompressibilityWaterPvt: { case WaterPvtApproach::ConstantCompressibilityWaterPvt: {
delete &getRealPvt<ConstantCompressibilityWaterPvt>(); delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityWaterPvt>();
break; break;
} }
case ConstantCompressibilityBrinePvt: { case WaterPvtApproach::ConstantCompressibilityBrinePvt: {
delete &getRealPvt<ConstantCompressibilityBrinePvt>(); delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityBrinePvt>();
break; break;
} }
case ThermalWaterPvt: { case WaterPvtApproach::ThermalWaterPvt: {
delete &getRealPvt<ThermalWaterPvt>(); delete &getRealPvt<WaterPvtApproach::ThermalWaterPvt>();
break; break;
} }
case NoWaterPvt: case WaterPvtApproach::NoWaterPvt:
break; break;
} }
} }
@ -123,11 +124,11 @@ public:
return; return;
if (enableThermal && eclState.getSimulationConfig().isThermal()) if (enableThermal && eclState.getSimulationConfig().isThermal())
setApproach(ThermalWaterPvt); setApproach(WaterPvtApproach::ThermalWaterPvt);
else if (!eclState.getTableManager().getPvtwTable().empty()) else if (!eclState.getTableManager().getPvtwTable().empty())
setApproach(ConstantCompressibilityWaterPvt); setApproach(WaterPvtApproach::ConstantCompressibilityWaterPvt);
else if (enableBrine && !eclState.getTableManager().getPvtwSaltTables().empty()) else if (enableBrine && !eclState.getTableManager().getPvtwSaltTables().empty())
setApproach(ConstantCompressibilityBrinePvt); setApproach(WaterPvtApproach::ConstantCompressibilityBrinePvt);
OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule)); OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
} }
@ -185,19 +186,19 @@ public:
void setApproach(WaterPvtApproach appr) void setApproach(WaterPvtApproach appr)
{ {
switch (appr) { switch (appr) {
case ConstantCompressibilityWaterPvt: case WaterPvtApproach::ConstantCompressibilityWaterPvt:
realWaterPvt_ = new Opm::ConstantCompressibilityWaterPvt<Scalar>; realWaterPvt_ = new Opm::ConstantCompressibilityWaterPvt<Scalar>;
break; break;
case ConstantCompressibilityBrinePvt: case WaterPvtApproach::ConstantCompressibilityBrinePvt:
realWaterPvt_ = new Opm::ConstantCompressibilityBrinePvt<Scalar>; realWaterPvt_ = new Opm::ConstantCompressibilityBrinePvt<Scalar>;
break; break;
case ThermalWaterPvt: case WaterPvtApproach::ThermalWaterPvt:
realWaterPvt_ = new Opm::WaterPvtThermal<Scalar>; realWaterPvt_ = new Opm::WaterPvtThermal<Scalar>;
break; break;
case NoWaterPvt: case WaterPvtApproach::NoWaterPvt:
throw std::logic_error("Not implemented: Water PVT of this deck!"); throw std::logic_error("Not implemented: Water PVT of this deck!");
} }
@ -214,42 +215,42 @@ public:
// get the concrete parameter object for the water phase // get the concrete parameter object for the water phase
template <WaterPvtApproach approachV> template <WaterPvtApproach approachV>
typename std::enable_if<approachV == ConstantCompressibilityWaterPvt, Opm::ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWaterPvt, Opm::ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_); return *static_cast<Opm::ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
} }
template <WaterPvtApproach approachV> template <WaterPvtApproach approachV>
typename std::enable_if<approachV == ConstantCompressibilityWaterPvt, const Opm::ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWaterPvt, const Opm::ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_); return *static_cast<Opm::ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
} }
template <WaterPvtApproach approachV> template <WaterPvtApproach approachV>
typename std::enable_if<approachV == ConstantCompressibilityBrinePvt, Opm::ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrinePvt, Opm::ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_); return *static_cast<Opm::ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
} }
template <WaterPvtApproach approachV> template <WaterPvtApproach approachV>
typename std::enable_if<approachV == ConstantCompressibilityBrinePvt, const Opm::ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrinePvt, const Opm::ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_); return *static_cast<Opm::ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
} }
template <WaterPvtApproach approachV> template <WaterPvtApproach approachV>
typename std::enable_if<approachV == ThermalWaterPvt, Opm::WaterPvtThermal<Scalar> >::type& getRealPvt() typename std::enable_if<approachV == WaterPvtApproach::ThermalWaterPvt, Opm::WaterPvtThermal<Scalar> >::type& getRealPvt()
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::WaterPvtThermal<Scalar>* >(realWaterPvt_); return *static_cast<Opm::WaterPvtThermal<Scalar>* >(realWaterPvt_);
} }
template <WaterPvtApproach approachV> template <WaterPvtApproach approachV>
typename std::enable_if<approachV == ThermalWaterPvt, const Opm::WaterPvtThermal<Scalar> >::type& getRealPvt() const typename std::enable_if<approachV == WaterPvtApproach::ThermalWaterPvt, const Opm::WaterPvtThermal<Scalar> >::type& getRealPvt() const
{ {
assert(approach() == approachV); assert(approach() == approachV);
return *static_cast<Opm::WaterPvtThermal<Scalar>* >(realWaterPvt_); return *static_cast<Opm::WaterPvtThermal<Scalar>* >(realWaterPvt_);
@ -263,13 +264,13 @@ public:
return false; return false;
switch (approach_) { switch (approach_) {
case ConstantCompressibilityWaterPvt: case WaterPvtApproach::ConstantCompressibilityWaterPvt:
return *static_cast<const Opm::ConstantCompressibilityWaterPvt<Scalar>*>(realWaterPvt_) == return *static_cast<const Opm::ConstantCompressibilityWaterPvt<Scalar>*>(realWaterPvt_) ==
*static_cast<const Opm::ConstantCompressibilityWaterPvt<Scalar>*>(data.realWaterPvt_); *static_cast<const Opm::ConstantCompressibilityWaterPvt<Scalar>*>(data.realWaterPvt_);
case ConstantCompressibilityBrinePvt: case WaterPvtApproach::ConstantCompressibilityBrinePvt:
return *static_cast<const Opm::ConstantCompressibilityBrinePvt<Scalar>*>(realWaterPvt_) == return *static_cast<const Opm::ConstantCompressibilityBrinePvt<Scalar>*>(realWaterPvt_) ==
*static_cast<const Opm::ConstantCompressibilityBrinePvt<Scalar>*>(data.realWaterPvt_); *static_cast<const Opm::ConstantCompressibilityBrinePvt<Scalar>*>(data.realWaterPvt_);
case ThermalWaterPvt: case WaterPvtApproach::ThermalWaterPvt:
return *static_cast<const Opm::WaterPvtThermal<Scalar>*>(realWaterPvt_) == return *static_cast<const Opm::WaterPvtThermal<Scalar>*>(realWaterPvt_) ==
*static_cast<const Opm::WaterPvtThermal<Scalar>*>(data.realWaterPvt_); *static_cast<const Opm::WaterPvtThermal<Scalar>*>(data.realWaterPvt_);
default: default:
@ -281,13 +282,13 @@ public:
{ {
approach_ = data.approach_; approach_ = data.approach_;
switch (approach_) { switch (approach_) {
case ConstantCompressibilityWaterPvt: case WaterPvtApproach::ConstantCompressibilityWaterPvt:
realWaterPvt_ = new Opm::ConstantCompressibilityWaterPvt<Scalar>(*static_cast<const Opm::ConstantCompressibilityWaterPvt<Scalar>*>(data.realWaterPvt_)); realWaterPvt_ = new Opm::ConstantCompressibilityWaterPvt<Scalar>(*static_cast<const Opm::ConstantCompressibilityWaterPvt<Scalar>*>(data.realWaterPvt_));
break; break;
case ConstantCompressibilityBrinePvt: case WaterPvtApproach::ConstantCompressibilityBrinePvt:
realWaterPvt_ = new Opm::ConstantCompressibilityBrinePvt<Scalar>(*static_cast<const Opm::ConstantCompressibilityBrinePvt<Scalar>*>(data.realWaterPvt_)); realWaterPvt_ = new Opm::ConstantCompressibilityBrinePvt<Scalar>(*static_cast<const Opm::ConstantCompressibilityBrinePvt<Scalar>*>(data.realWaterPvt_));
break; break;
case ThermalWaterPvt: case WaterPvtApproach::ThermalWaterPvt:
realWaterPvt_ = new Opm::WaterPvtThermal<Scalar>(*static_cast<const Opm::WaterPvtThermal<Scalar>*>(data.realWaterPvt_)); realWaterPvt_ = new Opm::WaterPvtThermal<Scalar>(*static_cast<const Opm::WaterPvtThermal<Scalar>*>(data.realWaterPvt_));
break; break;
default: default: