Move enum CompletionOrder to Connection class

This commit is contained in:
Joakim Hove
2019-08-28 07:06:58 +02:00
parent 15e192876e
commit a2fc480e16
14 changed files with 68 additions and 83 deletions

View File

@@ -254,7 +254,7 @@ namespace Opm
void addGroupToGroup( const std::string& parent_group, const std::string& child_group, size_t timeStep);
void addGroupToGroup( const std::string& parent_group, const Group2& child_group, size_t timeStep);
void addGroup(const std::string& groupName , size_t timeStep, const UnitSystem& unit_system);
void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder, const UnitSystem& unit_system);
void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, Connection::Order connection_order, const UnitSystem& unit_system);
void handleUDQ(const DeckKeyword& keyword, size_t currentStep);
void handleWLIST(const DeckKeyword& keyword, size_t currentStep);
void handleCOMPORD(const ParseContext& parseContext, ErrorGuard& errors, const DeckKeyword& compordKeyword, size_t currentStep);

View File

@@ -26,21 +26,6 @@ namespace Opm {
namespace WellCompletion {
enum CompletionOrderEnum{
DEPTH,
INPUT,
TRACK
};
const std::string CompletionOrderEnum2String( CompletionOrderEnum enumValue );
CompletionOrderEnum CompletionOrderEnumFromString(const std::string& comporderStringValue);
}
namespace WellTarget {
enum ControlModeEnum {
ORAT = 1,

View File

@@ -48,6 +48,7 @@ namespace Opm {
static const std::string State2String( State enumValue );
static State StateFromString( const std::string& stringValue );
enum class Direction{
X = 1,
Y = 2,
@@ -58,6 +59,14 @@ namespace Opm {
static Direction DirectionFromString(const std::string& stringValue);
enum class Order {
DEPTH,
INPUT,
TRACK
};
static const std::string Order2String( Order enumValue );
static Order OrderFromString(const std::string& comporderStringValue);

View File

@@ -182,7 +182,7 @@ public:
double ref_depth,
Phase phase,
WellProducer::ControlModeEnum whistctl_cmode,
WellCompletion::CompletionOrderEnum ordering,
Connection::Order ordering,
const UnitSystem& unit_system,
double udq_undefined);
@@ -208,7 +208,7 @@ public:
double getRefDepth() const;
double getDrainageRadius() const;
double getEfficiencyFactor() const;
WellCompletion::CompletionOrderEnum getWellConnectionOrdering() const;
Connection::Order getWellConnectionOrdering() const;
const WellProductionProperties& getProductionProperties() const;
const WellInjectionProperties& getInjectionProperties() const;
const WellEconProductionLimits& getEconLimits() const;
@@ -292,7 +292,7 @@ private:
int headJ;
double ref_depth;
Phase phase;
WellCompletion::CompletionOrderEnum ordering;
Connection::Order ordering;
UnitSystem unit_system;
double udq_undefined;

View File

@@ -28,6 +28,8 @@ namespace Opm {
class Eclipse3DProperties;
class WellConnections {
public:
WellConnections(int headI, int headJ);
// cppcheck-suppress noExplicitConstructor
WellConnections(const WellConnections& src, const EclipseGrid& grid);

View File

@@ -9,7 +9,7 @@ std::string state( const Connection& c ) {
}
std::string direction( const Connection& c ) {
return WellCompletion::DirectionEnum2String( c.dir() );
return Connection::Direction2String( c.dir() );
}
}

View File

@@ -239,7 +239,7 @@ namespace {
int compOrder(const Opm::Well2& well)
{
using WCO = ::Opm::WellCompletion::CompletionOrderEnum;
using WCO = ::Opm::Connection::Order;
using COVal = ::Opm::RestartIO::Helpers::
VectorItems::IWell::Value::CompOrder;

View File

@@ -606,7 +606,7 @@ namespace {
addGroup(groupName , currentStep, unit_system);
if (!hasWell(wellName)) {
WellCompletion::CompletionOrderEnum wellConnectionOrder = WellCompletion::TRACK;
auto wellConnectionOrder = Connection::Order::TRACK;
if( const auto* compordp = COMPORD_in_timestep() ) {
const auto& compord = *compordp;
@@ -617,7 +617,7 @@ namespace {
const std::string& wellNamePattern = compordRecord.getItem(0).getTrimmedString(0);
if (Well2::wellNameInWellNamePattern(wellName, wellNamePattern)) {
const std::string& compordString = compordRecord.getItem(1).getTrimmedString(0);
wellConnectionOrder = WellCompletion::CompletionOrderEnumFromString(compordString);
wellConnectionOrder = Connection::OrderFromString(compordString);
}
}
}
@@ -1976,7 +1976,7 @@ void Schedule::handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep, c
void Schedule::addWell(const std::string& wellName,
const DeckRecord& record,
size_t timeStep,
WellCompletion::CompletionOrderEnum wellConnectionOrder,
Connection::Order wellConnectionOrder,
const UnitSystem& unit_system) {
// We change from eclipse's 1 - n, to a 0 - n-1 solution

View File

@@ -24,36 +24,6 @@
namespace Opm {
namespace WellCompletion {
const std::string CompletionOrderEnum2String( CompletionOrderEnum enumValue ) {
switch( enumValue ) {
case DEPTH:
return "DEPTH";
case INPUT:
return "INPUT";
case TRACK:
return "TRACK";
default:
throw std::invalid_argument("Unhandled enum value");
}
}
CompletionOrderEnum CompletionOrderEnumFromString(const std::string& stringValue ) {
if (stringValue == "DEPTH")
return DEPTH;
else if (stringValue == "INPUT")
return INPUT;
else if (stringValue == "TRACK")
return TRACK;
else
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
}
/*****************************************************************/
namespace GroupInjection {

View File

@@ -312,6 +312,31 @@ Connection::Direction Connection::DirectionFromString(const std::string& s )
}
const std::string Connection::Order2String( Order enumValue ) {
switch( enumValue ) {
case Order::DEPTH:
return "DEPTH";
case Order::INPUT:
return "INPUT";
case Order::TRACK:
return "TRACK";
default:
throw std::invalid_argument("Unhandled enum value");
}
}
Connection::Order Connection::OrderFromString(const std::string& stringValue ) {
if (stringValue == "DEPTH")
return Order::DEPTH;
else if (stringValue == "INPUT")
return Order::INPUT;
else if (stringValue == "TRACK")
return Order::TRACK;
else
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
}

View File

@@ -81,7 +81,7 @@ Well2::Well2(const std::string& wname_arg,
double ref_depth_arg,
Phase phase_arg,
WellProducer::ControlModeEnum whistctl_cmode,
WellCompletion::CompletionOrderEnum ordering_arg,
Connection::Order ordering_arg,
const UnitSystem& unit_system_arg,
double udq_undefined_arg) :
wname(wname_arg),
@@ -334,7 +334,7 @@ bool Well2::updateAutoShutin(bool auto_shutin) {
bool Well2::updateConnections(const std::shared_ptr<WellConnections> connections_arg) {
if( this->ordering == WellCompletion::TRACK)
if( this->ordering == Connection::Order::TRACK)
connections_arg->orderConnections( this->headI, this->headJ );
if (*this->connections != *connections_arg) {
@@ -681,7 +681,7 @@ bool Well2::updatePrediction(bool prediction_mode_arg) {
}
WellCompletion::CompletionOrderEnum Well2::getWellConnectionOrdering() const {
Connection::Order Well2::getWellConnectionOrdering() const {
return this->ordering;
}

View File

@@ -2355,8 +2355,6 @@ BOOST_AUTO_TEST_CASE(TestCompletionStateEnumLoop) {
BOOST_AUTO_TEST_CASE(TestCompletionDirectionEnum2String)
{
using namespace WellCompletion;
BOOST_CHECK("X" == Connection::Direction2String(Connection::Direction::X));
BOOST_CHECK("Y" == Connection::Direction2String(Connection::Direction::Y));
BOOST_CHECK("Z" == Connection::Direction2String(Connection::Direction::Z));
@@ -2364,8 +2362,6 @@ BOOST_AUTO_TEST_CASE(TestCompletionDirectionEnum2String)
BOOST_AUTO_TEST_CASE(TestCompletionDirectionEnumFromString)
{
using namespace WellCompletion;
BOOST_CHECK_THROW(Connection::DirectionFromString("XXX"), std::invalid_argument);
BOOST_CHECK(Connection::Direction::X == Connection::DirectionFromString("X"));
@@ -2375,8 +2371,6 @@ BOOST_AUTO_TEST_CASE(TestCompletionDirectionEnumFromString)
BOOST_AUTO_TEST_CASE(TestCompletionConnectionDirectionLoop)
{
using namespace WellCompletion;
BOOST_CHECK(Connection::Direction::X == Connection::DirectionFromString(Connection::Direction2String(Connection::Direction::X)));
BOOST_CHECK(Connection::Direction::Y == Connection::DirectionFromString(Connection::Direction2String(Connection::Direction::Y)));
BOOST_CHECK(Connection::Direction::Z == Connection::DirectionFromString(Connection::Direction2String(Connection::Direction::Z)));

View File

@@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE2) {
const UnitSystem us{};
std::vector<Well2> wells;
wells.emplace_back("WELL_NAME", "A", 0, 0, 1, 1, 200., Phase::OIL, WellProducer::NONE, WellCompletion::TRACK, us, 0.);
wells.emplace_back("WELL_NAME", "A", 0, 0, 1, 1, 200., Phase::OIL, WellProducer::NONE, Connection::Order::TRACK, us, 0.);
{
wells[0].updateStatus(Well2::Status::SHUT);
auto shut_wells = st.updateWells(wc, wells, 5000);
@@ -111,8 +111,8 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE) {
const UnitSystem us{};
std::vector<Well2> wells;
wells.emplace_back("WELL_NAME", "A", 0, 0, 1, 1, 200., Phase::OIL, WellProducer::NONE, WellCompletion::TRACK, us, 0.);
wells.emplace_back("WELLX", "A", 0, 0, 2, 2, 200., Phase::OIL, WellProducer::NONE, WellCompletion::TRACK, us, 0.);
wells.emplace_back("WELL_NAME", "A", 0, 0, 1, 1, 200., Phase::OIL, WellProducer::NONE, Connection::Order::TRACK, us, 0.);
wells.emplace_back("WELLX", "A", 0, 0, 2, 2, 200., Phase::OIL, WellProducer::NONE, Connection::Order::TRACK, us, 0.);
WellTestConfig wc;
{
@@ -182,9 +182,9 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE_COMPLETIONS) {
const UnitSystem us{};
std::vector<Well2> wells;
wells.emplace_back("WELL_NAME", "A", 0, 0, 1, 1, 200., Phase::OIL, WellProducer::NONE, WellCompletion::TRACK, us, 0.);
wells.emplace_back("WELL_NAME", "A", 0, 0, 1, 1, 200., Phase::OIL, WellProducer::NONE, Connection::Order::TRACK, us, 0.);
wells[0].updateStatus(Well2::Status::OPEN);
wells.emplace_back("WELLX", "A", 0, 0, 2, 2, 200., Phase::OIL, WellProducer::NONE, WellCompletion::TRACK, us, 0.);
wells.emplace_back("WELLX", "A", 0, 0, 2, 2, 200., Phase::OIL, WellProducer::NONE, Connection::Order::TRACK, us, 0.);
wells[1].updateStatus(Well2::Status::OPEN);
auto closed_completions = st.updateWells(wc, wells, 5000);

View File

@@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(WellCOMPDATtestINPUT) {
}
BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK_EQUAL( 0U , well.getConnections( ).size() );
}
@@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
// HACK: This test checks correctly setting of isProducer/isInjector. This property depends on which of
// WellProductionProperties/WellInjectionProperties is set last, independent of actual values.
{
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
/* 1: Well is created as producer */
@@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
{
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
/* Set a reservoir injection rate => Well becomes an Injector */
auto injectionProps2 = std::make_shared<Opm::Well2::WellInjectionProperties>(well.getInjectionProperties());
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
}
{
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
/* Set rates => Well becomes a producer; injection rate should be set to 0. */
auto injectionProps3 = std::make_shared<Opm::Well2::WellInjectionProperties>(well.getInjectionProperties());
@@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
}
BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) {
Opm::Well2 well("WELL1" , "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1" , "G1", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK_EQUAL("G1" , well.groupName());
well.updateGroup( "GROUP2");
@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) {
BOOST_AUTO_TEST_CASE(addWELSPECS_setData_dataSet) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK_EQUAL(23, well.getHeadI());
BOOST_CHECK_EQUAL(42, well.getHeadJ());
@@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(addWELSPECS_setData_dataSet) {
BOOST_AUTO_TEST_CASE(XHPLimitDefault) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
auto productionProps = std::make_shared<Opm::WellProductionProperties>(well.getProductionProperties());
@@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) {
BOOST_AUTO_TEST_CASE(InjectorType) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
auto injectionProps = std::make_shared<Opm::Well2::WellInjectionProperties>(well.getInjectionProperties());
injectionProps->injectorType = Opm::Well2::InjectorType::WATER;
@@ -307,7 +307,7 @@ BOOST_AUTO_TEST_CASE(InjectorType) {
BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK( !well.getProductionProperties().hasProductionControl( Opm::WellProducer::ORAT ));
@@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) {
BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) {
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RATE ));
BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RESV ));
@@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) {
/*********************************************************************/
BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) {
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK_EQUAL(Opm::GuideRate::UNDEFINED, well.getGuideRatePhase());
@@ -407,7 +407,7 @@ BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) {
}
BOOST_AUTO_TEST_CASE(WellEfficiencyFactorSet) {
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
BOOST_CHECK_EQUAL(1.0, well.getEfficiencyFactor());
BOOST_CHECK( well.updateEfficiencyFactor(0.9));
@@ -758,7 +758,7 @@ BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) {
BOOST_AUTO_TEST_CASE(WELL_CONTROLS) {
Opm::Well2 well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Opm::WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Opm::Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::WellProductionProperties prod("OP1");
Opm::SummaryState st;
well.productionControls(st);
@@ -779,8 +779,8 @@ BOOST_AUTO_TEST_CASE(WELL_CONTROLS) {
BOOST_AUTO_TEST_CASE(ExtraAccessors) {
Opm::Well2 inj("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 prod("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 inj("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
Opm::Well2 prod("WELL1" , "GROUP", 0, 1, 0, 0, 0.0, Opm::Phase::OIL, Opm::WellProducer::CMODE_UNDEFINED, Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0);
auto inj_props= std::make_shared<Opm::Well2::WellInjectionProperties>(inj.getInjectionProperties());
inj_props->VFPTableNumber = 100;