Rst connection - use proper enums for direction and state

This commit is contained in:
Joakim Hove
2020-02-03 07:26:25 +01:00
parent b3dc5483f1
commit 42fc0666be
3 changed files with 38 additions and 5 deletions

View File

@@ -20,6 +20,9 @@
#define RST_CONNECTION
#include <array>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp>
namespace Opm {
namespace RestartIO {
@@ -30,11 +33,11 @@ struct RstConnection {
int insert_index;
std::array<int,3> ijk;
int status;
Connection::State state;
int drain_sat_table;
int imb_sat_table;
int completion;
int dir;
Connection::Direction dir;
int segment;
float tran;

View File

@@ -41,7 +41,7 @@ namespace Opm {
enum class State {
OPEN = 1,
SHUT = 2,
AUTO = 3
AUTO = 3 // Seems like the AUTO state can not be serialized to restart files.
};
static const std::string State2String( State enumValue );

View File

@@ -26,14 +26,44 @@ namespace VI = ::Opm::RestartIO::Helpers::VectorItems;
namespace Opm {
namespace RestartIO {
namespace {
template <typename T>
T from_int(int);
template <>
Connection::State from_int(int int_state) {
if (int_state == 1)
return Connection::State::OPEN;
return Connection::State::SHUT;
}
template <>
Connection::Direction from_int(int int_dir) {
switch (int_dir) {
case 1:
return Connection::Direction::X;
case 2:
return Connection::Direction::Y;
case 3:
return Connection::Direction::Z;
throw
std::invalid_argument("Can not convert: " + std::to_string(int_dir) + " to string");
}
}
}
RstConnection::RstConnection(const int* icon, const float* scon, const double* xcon) :
insert_index(icon[VI::IConn::SeqIndex] - 1),
ijk({icon[VI::IConn::CellI] - 1, icon[VI::IConn::CellJ] - 1, icon[VI::IConn::CellK] - 1}),
status(icon[VI::IConn::ConnStat]),
state(from_int<Connection::State>(icon[VI::IConn::ConnStat])),
drain_sat_table(icon[VI::IConn::Drainage]),
imb_sat_table(icon[VI::IConn::Imbibition]),
completion(icon[VI::IConn::ComplNum] - 1),
dir(icon[VI::IConn::ConnDir]),
dir(from_int<Connection::Direction>(icon[VI::IConn::ConnDir])),
segment(icon[VI::IConn::Segment] - 1),
tran(scon[VI::SConn::ConnTrans]),
depth(scon[VI::SConn::Depth]),