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
namespace Opm {
#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
switch (gasPvtApproach_) { \
case DryGasPvt: { \
auto& pvtImpl = getRealPvt<DryGasPvt>(); \
codeToCall; \
break; \
} \
case WetGasPvt: { \
auto& pvtImpl = getRealPvt<WetGasPvt>(); \
codeToCall; \
break; \
} \
case ThermalGasPvt: { \
auto& pvtImpl = getRealPvt<ThermalGasPvt>(); \
codeToCall; \
break; \
} \
case Co2GasPvt: { \
auto& pvtImpl = getRealPvt<Co2GasPvt>(); \
codeToCall; \
break; \
} \
case NoGasPvt: \
#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
switch (gasPvtApproach_) { \
case GasPvtApproach::DryGasPvt: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::DryGasPvt>(); \
codeToCall; \
break; \
} \
case GasPvtApproach::WetGasPvt: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::WetGasPvt>(); \
codeToCall; \
break; \
} \
case GasPvtApproach::ThermalGasPvt: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGasPvt>(); \
codeToCall; \
break; \
} \
case GasPvtApproach::Co2GasPvt: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::Co2GasPvt>(); \
codeToCall; \
break; \
} \
case GasPvtApproach::NoGasPvt: \
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
@ -80,17 +87,9 @@ class GasPvtMultiplexer
public:
typedef Opm::GasPvtThermal<Scalar> GasPvtThermal;
enum GasPvtApproach {
NoGasPvt,
DryGasPvt,
WetGasPvt,
ThermalGasPvt,
Co2GasPvt
};
GasPvtMultiplexer()
{
gasPvtApproach_ = NoGasPvt;
gasPvtApproach_ = GasPvtApproach::NoGasPvt;
realGasPvt_ = nullptr;
}
@ -107,23 +106,23 @@ public:
~GasPvtMultiplexer()
{
switch (gasPvtApproach_) {
case DryGasPvt: {
delete &getRealPvt<DryGasPvt>();
case GasPvtApproach::DryGasPvt: {
delete &getRealPvt<GasPvtApproach::DryGasPvt>();
break;
}
case WetGasPvt: {
delete &getRealPvt<WetGasPvt>();
case GasPvtApproach::WetGasPvt: {
delete &getRealPvt<GasPvtApproach::WetGasPvt>();
break;
}
case ThermalGasPvt: {
delete &getRealPvt<ThermalGasPvt>();
case GasPvtApproach::ThermalGasPvt: {
delete &getRealPvt<GasPvtApproach::ThermalGasPvt>();
break;
}
case Co2GasPvt: {
delete &getRealPvt<Co2GasPvt>();
case GasPvtApproach::Co2GasPvt: {
delete &getRealPvt<GasPvtApproach::Co2GasPvt>();
break;
}
case NoGasPvt:
case GasPvtApproach::NoGasPvt:
break;
}
}
@ -139,13 +138,13 @@ public:
if (!eclState.runspec().phases().active(Phase::GAS))
return;
if (eclState.runspec().co2Storage())
setApproach(Co2GasPvt);
setApproach(GasPvtApproach::Co2GasPvt);
else if (enableThermal && eclState.getSimulationConfig().isThermal())
setApproach(ThermalGasPvt);
setApproach(GasPvtApproach::ThermalGasPvt);
else if (!eclState.getTableManager().getPvtgTables().empty())
setApproach(WetGasPvt);
setApproach(GasPvtApproach::WetGasPvt);
else if (eclState.getTableManager().hasTables("PVDG"))
setApproach(DryGasPvt);
setApproach(GasPvtApproach::DryGasPvt);
OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
}
@ -154,23 +153,23 @@ public:
void setApproach(GasPvtApproach gasPvtAppr)
{
switch (gasPvtAppr) {
case DryGasPvt:
case GasPvtApproach::DryGasPvt:
realGasPvt_ = new Opm::DryGasPvt<Scalar>;
break;
case WetGasPvt:
case GasPvtApproach::WetGasPvt:
realGasPvt_ = new Opm::WetGasPvt<Scalar>;
break;
case ThermalGasPvt:
case GasPvtApproach::ThermalGasPvt:
realGasPvt_ = new Opm::GasPvtThermal<Scalar>;
break;
case Co2GasPvt:
case GasPvtApproach::Co2GasPvt:
realGasPvt_ = new Opm::Co2GasPvt<Scalar>;
break;
case NoGasPvt:
case GasPvtApproach::NoGasPvt:
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
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);
return *static_cast<Opm::DryGasPvt<Scalar>* >(realGasPvt_);
}
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);
return *static_cast<const Opm::DryGasPvt<Scalar>* >(realGasPvt_);
@ -308,14 +307,14 @@ public:
// get the parameter object for the wet gas case
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);
return *static_cast<Opm::WetGasPvt<Scalar>* >(realGasPvt_);
}
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);
return *static_cast<const Opm::WetGasPvt<Scalar>* >(realGasPvt_);
@ -323,28 +322,28 @@ public:
// get the parameter object for the thermal gas case
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);
return *static_cast<Opm::GasPvtThermal<Scalar>* >(realGasPvt_);
}
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);
return *static_cast<const Opm::GasPvtThermal<Scalar>* >(realGasPvt_);
}
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);
return *static_cast<Opm::Co2GasPvt<Scalar>* >(realGasPvt_);
}
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);
return *static_cast<const Opm::Co2GasPvt<Scalar>* >(realGasPvt_);
@ -358,16 +357,16 @@ public:
return false;
switch (gasPvtApproach_) {
case DryGasPvt:
case GasPvtApproach::DryGasPvt:
return *static_cast<const Opm::DryGasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_);
case WetGasPvt:
case GasPvtApproach::WetGasPvt:
return *static_cast<const Opm::WetGasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_);
case ThermalGasPvt:
case GasPvtApproach::ThermalGasPvt:
return *static_cast<const Opm::GasPvtThermal<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_);
case Co2GasPvt:
case GasPvtApproach::Co2GasPvt:
return *static_cast<const Opm::Co2GasPvt<Scalar>*>(realGasPvt_) ==
*static_cast<const Opm::Co2GasPvt<Scalar>*>(data.realGasPvt_);
default:
@ -379,16 +378,16 @@ public:
{
gasPvtApproach_ = data.gasPvtApproach_;
switch (gasPvtApproach_) {
case DryGasPvt:
case GasPvtApproach::DryGasPvt:
realGasPvt_ = new Opm::DryGasPvt<Scalar>(*static_cast<const Opm::DryGasPvt<Scalar>*>(data.realGasPvt_));
break;
case WetGasPvt:
case GasPvtApproach::WetGasPvt:
realGasPvt_ = new Opm::WetGasPvt<Scalar>(*static_cast<const Opm::WetGasPvt<Scalar>*>(data.realGasPvt_));
break;
case ThermalGasPvt:
case GasPvtApproach::ThermalGasPvt:
realGasPvt_ = new Opm::GasPvtThermal<Scalar>(*static_cast<const Opm::GasPvtThermal<Scalar>*>(data.realGasPvt_));
break;
case Co2GasPvt:
case GasPvtApproach::Co2GasPvt:
realGasPvt_ = new Opm::Co2GasPvt<Scalar>(*static_cast<const Opm::Co2GasPvt<Scalar>*>(data.realGasPvt_));
break;
default:

View File

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

View File

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