Move Connection::Order member from Well to WellConnections

This commit is contained in:
Joakim Hove
2020-03-18 13:56:26 +01:00
parent 3f4ff89b01
commit 96d2cd59b3
9 changed files with 56 additions and 46 deletions

View File

@@ -411,7 +411,6 @@ public:
int headJ,
double ref_depth,
const WellType& wtype_arg,
Connection::Order ordering,
const UnitSystem& unit_system,
double udq_undefined,
Status status,
@@ -455,7 +454,6 @@ public:
double getRefDepth() const;
double getDrainageRadius() const;
double getEfficiencyFactor() const;
Connection::Order getWellConnectionOrdering() const;
double getSolventFraction() const;
Status getStatus() const;
const std::string& groupName() const;
@@ -551,7 +549,6 @@ private:
int headI;
int headJ;
double ref_depth;
Connection::Order ordering;
UnitSystem unit_system;
double udq_undefined;

View File

@@ -33,8 +33,8 @@ namespace Opm {
WellConnections();
WellConnections(int headI, int headJ);
WellConnections(int headI, int headJ,
WellConnections(Connection::Order ordering, int headI, int headJ);
WellConnections(Connection::Order ordering, int headI, int headJ,
size_t numRemoved,
const std::vector<Connection>& connections);
@@ -83,7 +83,7 @@ namespace Opm {
/// \param[in] well_i logical cartesian i-coordinate of well head
/// \param[in] well_j logical cartesian j-coordinate of well head
/// \param[in] grid EclipseGrid object, used for cell depths
void orderTRACK(size_t well_i, size_t well_j);
void order(size_t well_i, size_t well_j);
bool operator==( const WellConnections& ) const;
bool operator!=( const WellConnections& ) const;
@@ -92,7 +92,7 @@ namespace Opm {
int getHeadJ() const;
size_t getNumRemoved() const;
const std::vector<Connection>& getConnections() const;
Connection::Order ordering() const { return this->m_ordering; }
private:
void addConnection(int i, int j , int k ,
int complnum,
@@ -121,6 +121,7 @@ namespace Opm {
size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
Connection::Order m_ordering = Connection::Order::TRACK;
int headI, headJ;
size_t num_removed = 0;
std::vector< Connection > m_connections;

View File

@@ -291,7 +291,7 @@ namespace {
using COVal = ::Opm::RestartIO::Helpers::
VectorItems::IWell::Value::CompOrder;
switch (well.getWellConnectionOrdering()) {
switch (well.getConnections().ordering()) {
case WCO::TRACK: return COVal::Track;
case WCO::DEPTH: return COVal::Depth;
case WCO::INPUT: return COVal::Input;

View File

@@ -2913,7 +2913,22 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t
this->restart_config == data.restart_config &&
this->wellgroup_events == data.wellgroup_events;
}
namespace {
// Duplicated from Well.cpp
Connection::Order order_from_int(int int_value) {
switch(int_value) {
case 0:
return Connection::Order::TRACK;
case 1:
return Connection::Order::DEPTH;
case 2:
return Connection::Order::INPUT;
default:
throw std::invalid_argument("Invalid integer value: " + std::to_string(int_value) + " encountered when determining connection ordering");
}
}
}
void Schedule::load_rst(const RestartIO::RstState& rst_state, const EclipseGrid& grid, const FieldPropsManager& fp, const UnitSystem& unit_system)
{
@@ -2952,7 +2967,7 @@ void Schedule::load_rst(const RestartIO::RstState& rst_state, const EclipseGrid&
}
{
std::shared_ptr<Opm::WellConnections> well_connections = std::make_shared<Opm::WellConnections>(rst_well.ij[0], rst_well.ij[1], 0, connections);
std::shared_ptr<Opm::WellConnections> well_connections = std::make_shared<Opm::WellConnections>(order_from_int(rst_well.completion_ordering), rst_well.ij[0], rst_well.ij[1], 0, connections);
well.updateConnections( std::move(well_connections) );
}
@@ -3069,6 +3084,7 @@ bool Schedule::cmp(const Schedule& sched1, const Schedule& sched2, std::size_t r
const auto& connections2 = well2.getConnections();
const auto& connections1 = well1.getConnections();
well_count += not_equal( connections1.ordering(), connections2.ordering(), well_msg(well1.name(), "Connection: ordering"));
for (std::size_t icon = 0; icon < connections1.size(); icon++) {
const auto& conn1 = connections1[icon];
const auto& conn2 = connections2[icon];
@@ -3183,7 +3199,6 @@ bool Schedule::cmp(const Schedule& sched1, const Schedule& sched2, std::size_t r
well_count += not_equal( well1.seqIndex(), well2.seqIndex(), well_msg(well1.name(), "Well: seqIndex"));
well_count += not_equal( well1.getAutomaticShutIn(), well2.getAutomaticShutIn(), well_msg(well1.name(), "Well: getAutomaticShutIn"));
well_count += not_equal( well1.getAllowCrossFlow(), well2.getAllowCrossFlow(), well_msg(well1.name(), "Well: getAllowCrossFlow"));
well_count += not_equal( well1.getWellConnectionOrdering(), well2.getWellConnectionOrdering(), well_msg(well1.name(), "Well: getWellConnectionOrdering"));
well_count += not_equal( well1.getSolventFraction(), well2.getSolventFraction(), well_msg(well1.name(), "Well: getSolventFraction"));
well_count += not_equal( well1.getStatus(), well2.getStatus(), well_msg(well1.name(), "Well: getStatus"));
//well_count += not_equal( well1.getInjectionProperties(), well2.getInjectionProperties(), "Well: getInjectionProperties");

View File

@@ -79,7 +79,6 @@ Well::Well() :
headI(0),
headJ(0),
ref_depth(0.0),
ordering(Connection::Order::DEPTH),
udq_undefined(0.0),
status(Status::STOP),
drainage_radius(0.0),
@@ -131,7 +130,6 @@ Well::Well(const RestartIO::RstWell& rst_well,
headI(rst_well.ij[0]),
headJ(rst_well.ij[1]),
ref_depth(rst_well.datum_depth),
ordering(order_from_int(rst_well.completion_ordering)),
unit_system(unit_system_arg),
udq_undefined(udq_undefined_arg),
status(rst_well.active_control == def_well_closed_control ? Well::Status::SHUT : Well::Status::OPEN),
@@ -148,7 +146,7 @@ Well::Well(const RestartIO::RstWell& rst_well,
polymer_properties(std::make_shared<WellPolymerProperties>()),
brine_properties(std::make_shared<WellBrineProperties>()),
tracer_properties(std::make_shared<WellTracerProperties>()),
connections(std::make_shared<WellConnections>(headI, headJ)),
connections(std::make_shared<WellConnections>(order_from_int(rst_well.completion_ordering), headI, headJ)),
production(std::make_shared<WellProductionProperties>(unit_system_arg, wname)),
injection(std::make_shared<WellInjectionProperties>(unit_system_arg, wname))
{
@@ -288,7 +286,6 @@ Well::Well(const std::string& wname_arg,
headI(headI_arg),
headJ(headJ_arg),
ref_depth(ref_depth_arg),
ordering(ordering_arg),
unit_system(unit_system_arg),
udq_undefined(udq_undefined_arg),
status(Status::SHUT),
@@ -304,7 +301,7 @@ Well::Well(const std::string& wname_arg,
polymer_properties(std::make_shared<WellPolymerProperties>()),
brine_properties(std::make_shared<WellBrineProperties>()),
tracer_properties(std::make_shared<WellTracerProperties>()),
connections(std::make_shared<WellConnections>(headI, headJ)),
connections(std::make_shared<WellConnections>(ordering_arg, headI, headJ)),
production(std::make_shared<WellProductionProperties>(unit_system, wname)),
injection(std::make_shared<WellInjectionProperties>(unit_system, wname))
{
@@ -321,7 +318,6 @@ Well::Well(const std::string& wname_arg,
int headJ_arg,
double ref_depth_arg,
const WellType& wtype_arg,
Connection::Order ordering_arg,
const UnitSystem& units,
double udq_undefined_arg,
Status status_arg,
@@ -348,7 +344,6 @@ Well::Well(const std::string& wname_arg,
headI(headI_arg),
headJ(headJ_arg),
ref_depth(ref_depth_arg),
ordering(ordering_arg),
unit_system(units),
udq_undefined(udq_undefined_arg),
status(status_arg),
@@ -568,7 +563,7 @@ bool Well::updateStatus(Status well_state, bool update_connections) {
throw std::logic_error("Bug - should not be here");
}
auto new_connections = std::make_shared<WellConnections>(this->headI, this->headJ);
auto new_connections = std::make_shared<WellConnections>(this->connections->ordering(), this->headI, this->headJ);
for (auto c : *this->connections) {
c.setState(connection_state);
new_connections->add(c);
@@ -625,9 +620,7 @@ bool Well::updateAutoShutin(bool auto_shutin) {
bool Well::updateConnections(std::shared_ptr<WellConnections> connections_arg) {
if( this->ordering == Connection::Order::TRACK)
connections_arg->orderTRACK( this->headI, this->headJ );
connections_arg->order( this->headI, this->headJ );
if (*this->connections != *connections_arg) {
this->connections = connections_arg;
//if (this->connections->allConnectionsShut()) {}
@@ -856,7 +849,7 @@ bool Well::handleWELOPEN(const DeckRecord& record, Connection::State state_arg,
return true;
};
auto new_connections = std::make_shared<WellConnections>(this->headI, this->headJ);
auto new_connections = std::make_shared<WellConnections>(this->connections->ordering(), this->headI, this->headJ);
for (auto c : *this->connections) {
if (match(c))
@@ -887,7 +880,7 @@ bool Well::handleCOMPLUMP(const DeckRecord& record) {
return true;
};
auto new_connections = std::make_shared<WellConnections>(this->headI, this->headJ);
auto new_connections = std::make_shared<WellConnections>(this->connections->ordering(), this->headI, this->headJ);
const int complnum = record.getItem("N").get<int>(0);
if (complnum <= 0)
throw std::invalid_argument("Completion number must be >= 1. COMPLNUM=" + std::to_string(complnum) + "is invalid");
@@ -916,7 +909,7 @@ bool Well::handleWPIMULT(const DeckRecord& record) {
return true;
};
auto new_connections = std::make_shared<WellConnections>(this->headI, this->headJ);
auto new_connections = std::make_shared<WellConnections>(this->connections->ordering(), this->headI, this->headJ);
double wellPi = record.getItem("WELLPI").get< double >(0);
for (auto c : *this->connections) {
@@ -1037,10 +1030,6 @@ bool Well::updatePrediction(bool prediction_mode_arg) {
}
Connection::Order Well::getWellConnectionOrdering() const {
return this->ordering;
}
double Well::production_rate(const SummaryState& st, Phase prod_phase) const {
if( !this->isProducer() ) return 0.0;
@@ -1380,7 +1369,6 @@ bool Well::operator==(const Well& data) const {
this->getHeadJ() == data.getHeadJ() &&
this->getRefDepth() == data.getRefDepth() &&
this->getPreferredPhase() == data.getPreferredPhase() &&
this->getWellConnectionOrdering() == data.getWellConnectionOrdering() &&
this->units() == data.units() &&
this->udqUndefined() == data.udqUndefined() &&
this->getStatus() == data.getStatus() &&

View File

@@ -116,20 +116,25 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
} // anonymous namespace
WellConnections::WellConnections() :
headI(0), headJ(0), num_removed(0)
headI(0),
headJ(0),
num_removed(0)
{
}
WellConnections::WellConnections(int headIArg, int headJArg) :
WellConnections::WellConnections(Connection::Order order,int headIArg, int headJArg) :
m_ordering(order),
headI(headIArg),
headJ(headJArg)
{
}
WellConnections::WellConnections(int headIArg, int headJArg,
WellConnections::WellConnections(Connection::Order order,
int headIArg, int headJArg,
size_t numRemoved,
const std::vector<Connection>& connections) :
m_ordering(order),
headI(headIArg),
headJ(headJArg),
num_removed(numRemoved),
@@ -140,6 +145,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
WellConnections::WellConnections(const WellConnections& src, const EclipseGrid& grid) :
m_ordering(src.ordering()),
headI(src.headI),
headJ(src.headJ)
{
@@ -437,11 +443,13 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
void WellConnections::orderTRACK(size_t well_i, size_t well_j)
void WellConnections::order(size_t well_i, size_t well_j)
{
if (m_connections.empty()) {
if (m_connections.empty())
return;
if (this->m_ordering != Connection::Order::TRACK)
return;
}
// Find the first connection and swap it into the 0-position.
const double surface_z = 0.0;
@@ -498,6 +506,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
bool WellConnections::operator==( const WellConnections& rhs ) const {
return this->size() == rhs.size() &&
this->num_removed == rhs.num_removed &&
this->m_ordering == rhs.m_ordering &&
std::equal( this->begin(), this->end(), rhs.begin() );
}

View File

@@ -60,7 +60,7 @@ inline std::ostream& operator<<( std::ostream& stream, const WellConnections& cs
BOOST_AUTO_TEST_CASE(CreateWellConnectionsOK) {
Opm::WellConnections completionSet(1,1);
Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1);
BOOST_CHECK_EQUAL( 0U , completionSet.size() );
BOOST_CHECK(!completionSet.allConnectionsShut());
}
@@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(CreateWellConnectionsOK) {
BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) {
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::DeckValue;
Opm::WellConnections completionSet(1,1);
Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1);
Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true);
Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true);
completionSet.add( completion1 );
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(WellConnectionsGetOutOfRangeThrows) {
const auto kind = Opm::Connection::CTFKind::DeckValue;
Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true);
Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true);
Opm::WellConnections completionSet(1,1);
Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1);
completionSet.add( completion1 );
BOOST_CHECK_EQUAL( 1U , completionSet.size() );
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(WellConnectionsGetOutOfRangeThrows) {
BOOST_AUTO_TEST_CASE(AddCompletionCopy) {
Opm::WellConnections completionSet(10,10);
Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 10,10);
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::DeckValue;
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(ActiveCompletions) {
Opm::EclipseGrid grid(10,20,20);
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::Defaulted;
Opm::WellConnections completions(10,10);
Opm::WellConnections completions(Opm::Connection::Order::TRACK, 10,10);
Opm::Connection completion1( 0,0,0, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true);
Opm::Connection completion2( 0,0,1, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true);
Opm::Connection completion3( 0,0,2, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true);
@@ -155,7 +155,7 @@ Opm::WellConnections loadCOMPDAT(const std::string& compdat_keyword) {
const auto deck = parser.parseString(compdat_keyword);
Opm::FieldPropsManager field_props(deck, Opm::Phases{true, true, true}, grid, Opm::TableManager());
const auto& keyword = deck.getKeyword("COMPDAT", 0);
Opm::WellConnections connections(10,10);
Opm::WellConnections connections(Opm::Connection::Order::TRACK, 10,10);
for (const auto& rec : keyword)
connections.loadCOMPDAT(rec, grid, field_props);

View File

@@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(MultisegmentWellTest) {
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::DeckValue;
Opm::WellConnections connection_set(10,10);
Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10);
Opm::EclipseGrid grid(20,20,20);
connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
@@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(MultisegmentWellTest) {
BOOST_AUTO_TEST_CASE(WrongDistanceCOMPSEGS) {
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::DeckValue;
Opm::WellConnections connection_set(10,10);
Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10);
Opm::EclipseGrid grid(20,20,20);
connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
@@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE(WrongDistanceCOMPSEGS) {
BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) {
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::DeckValue;
Opm::WellConnections connection_set(10,10);
Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10);
Opm::EclipseGrid grid(20,20,20);
connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
@@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) {
BOOST_AUTO_TEST_CASE(testwsegvalv) {
auto dir = Opm::Connection::Direction::Z;
const auto kind = Opm::Connection::CTFKind::DeckValue;
Opm::WellConnections connection_set(10,10);
Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10);
Opm::EclipseGrid grid(20,20,20);
connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );
connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) );

View File

@@ -3317,7 +3317,7 @@ BOOST_AUTO_TEST_CASE(WELL_STATIC) {
const auto& connections = ws.getConnections();
BOOST_CHECK_EQUAL(connections.size(), 0);
auto c2 = std::make_shared<WellConnections>(1,1);
auto c2 = std::make_shared<WellConnections>(Connection::Order::TRACK, 1,1);
c2->addConnection(1,1,1,
100,
Connection::State::OPEN,