diff --git a/opm/parser/eclipse/EclipseState/Schedule/Connection.hpp b/opm/parser/eclipse/EclipseState/Schedule/Connection.hpp index 973c14bba..7fbbdf7e9 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Connection.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Connection.hpp @@ -48,7 +48,10 @@ namespace Opm { double rw, const int satTableId, const WellCompletion::DirectionEnum direction, - const std::size_t seqIndex); + const std::size_t seqIndex, + const double segDistStart, + const double segDistEnd + ); bool attachedToSegment() const; @@ -72,7 +75,12 @@ namespace Opm { void scaleWellPi(double wellPi); void updateSegment(int segment_number, double center_depth, std::size_t seqIndex); const std::size_t& getSeqIndex() const; - void setSeqIndex(std::size_t index); + const std::size_t& getCompSegSeqIndex() const; + void setCompSegSeqIndex(std::size_t index); + const double& getSegDistStart() const; + const double& getSegDistEnd() const; + void setSegDistStart(const double& distStart); + void setSegDistEnd(const double& distEnd); bool operator==( const Connection& ) const; bool operator!=( const Connection& ) const; @@ -88,6 +96,9 @@ namespace Opm { std::array ijk; std::size_t m_seqIndex; + double m_segDistStart; + double m_segDistEnd; + std::size_t m_compSeg_seqIndex=0; // related segment number // -1 means the completion is not related to segment diff --git a/opm/parser/eclipse/EclipseState/Schedule/Group.hpp b/opm/parser/eclipse/EclipseState/Schedule/Group.hpp index 2abd49c04..7531d7bb4 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Group.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Group.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/opm/parser/eclipse/EclipseState/Schedule/WellConnections.hpp b/opm/parser/eclipse/EclipseState/Schedule/WellConnections.hpp index b51ae6eb3..80f421b36 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/WellConnections.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/WellConnections.hpp @@ -40,7 +40,9 @@ namespace Opm { double rw, const int satTableId, const WellCompletion::DirectionEnum direction = WellCompletion::DirectionEnum::Z, - const std::size_t seqIndex = 0); + const std::size_t seqIndex = 0, + const double segDistStart= 0.0, + const double segDistEnd= 0.0); void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties); using const_iterator = std::vector< Connection >::const_iterator; @@ -83,7 +85,9 @@ namespace Opm { double rw, const int satTableId, const WellCompletion::DirectionEnum direction = WellCompletion::DirectionEnum::Z, - const std::size_t seqIndex=0); + const std::size_t seqIndex = 0, + const double segDistStart= 0.0, + const double segDistEnd= 0.0); std::vector< Connection > m_connections; size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos); diff --git a/src/opm/output/eclipse/AggregateConnectionData.cpp b/src/opm/output/eclipse/AggregateConnectionData.cpp index cb787de43..bc7bc5a4c 100755 --- a/src/opm/output/eclipse/AggregateConnectionData.cpp +++ b/src/opm/output/eclipse/AggregateConnectionData.cpp @@ -47,6 +47,29 @@ namespace { { return inteHead[VI::intehead::NCWMAX]; } + + std::map mapSeqIndexToConnection(const Opm::WellConnections& conns) + { + // make seqIndex to Connection map + std::map seqIndConnMap; + for (const auto conn : conns) { + std::size_t sI = conn.getSeqIndex(); + seqIndConnMap.insert(std::make_pair(sI, &conn)); + } + return seqIndConnMap; + } + + std::map mapCompSegSeqIndexToConnection(const Opm::WellConnections& conns) + { + // make CompSegSeqIndex to Connection map + std::map cs_seqIndConnMap; + for (const auto conn : conns) { + std::size_t sI = conn.getCompSegSeqIndex(); + cs_seqIndConnMap.insert(std::make_pair(sI, &conn)); + } + return cs_seqIndConnMap; + } + template void connectionLoop(const std::vector& wells, @@ -60,13 +83,33 @@ namespace { const auto* well = wells[wellID]; if (well == nullptr) { continue; } - + const auto& conns = well->getActiveConnections(sim_step, grid); + std::map sIToConn; - for (auto nConn = conns.size(), connID = 0*nConn; + //Branch according to MSW well or not and + //sort active connections according to appropriate seqIndex + if (well->isMultiSegment(sim_step)) { + //sort connections according to input sequence in COMPSEGS + sIToConn = mapCompSegSeqIndexToConnection(conns); + } else + { + //sort connections according to input sequence in COMPDAT + sIToConn = mapSeqIndexToConnection(conns); + } + std::vector connSI; + int niSI = well->getConnections(sim_step).size(); + for (int iSI = 0; iSI < niSI; iSI++) { + const auto searchSI = sIToConn.find(static_cast(iSI)); + if (searchSI != sIToConn.end()) { + connSI.push_back(searchSI->second); + } + } + + for (auto nConn = connSI.size(), connID = 0*nConn; connID < nConn; ++connID) { - connOp(*well, wellID, conns.get(connID), connID); + connOp(*well, wellID, *connSI[connID], connID); } } } @@ -169,6 +212,8 @@ namespace { // multisegmented well. That information is impossible to // reconstruct here since it is discared in member function // ::Opm::Well::handleCOMPSEGS(). + sConn[20] = static_cast(conn.getSegDistEnd()); + sConn[21] = static_cast(conn.getSegDistStart()); sConn[29] = -1.0e+20f; sConn[30] = -1.0e+20f; diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 560a2215b..f034fc0f1 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -174,7 +174,6 @@ namespace { const std::map currentWellIndex(const Opm::Schedule& sched, const size_t simStep) { const auto& wells = sched.getWells(simStep); - //const std::vector< const Opm::Well* > wells = sched.getWells(simStep); // make group index for current report step std::map wellIndexMap; for (const auto* well : wells) { diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Connection.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Connection.cpp index 16034809a..09d59d3c2 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Connection.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Connection.cpp @@ -45,7 +45,10 @@ namespace Opm { double rw, const int satTableId, const WellCompletion::DirectionEnum direction, - const std::size_t seqIndex) + const std::size_t seqIndex, + const double segDistStart, + const double segDistEnd + ) : direction(direction), center_depth(depth), open_state(stateArg), @@ -55,7 +58,9 @@ namespace Opm { m_Kh(Kh), m_rw(rw), ijk({i,j,k}), - m_seqIndex(seqIndex) + m_seqIndex(seqIndex), + m_segDistStart(segDistStart), + m_segDistEnd(segDistEnd) {} /*bool Connection::sameCoordinate(const Connection& other) const { @@ -97,14 +102,35 @@ namespace Opm { return m_seqIndex; } - void Connection::setSeqIndex(std::size_t index) { - m_seqIndex = index; + const std::size_t& Connection::getCompSegSeqIndex() const { + return m_compSeg_seqIndex; } WellCompletion::DirectionEnum Connection::dir() const { return this->direction; } + const double& Connection::getSegDistStart() const { + return m_segDistStart; + } + + const double& Connection::getSegDistEnd() const { + return m_segDistEnd; + } + + + void Connection::setCompSegSeqIndex(std::size_t index) { + m_compSeg_seqIndex = index; + } + + void Connection::setSegDistStart(const double& distStart) { + m_segDistStart = distStart; + } + + void Connection::setSegDistEnd(const double& distEnd) { + m_segDistEnd = distEnd; + } + double Connection::depth() const { return this->center_depth; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp index 6dbbe24fe..a6e53108f 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp @@ -244,6 +244,11 @@ namespace Opm { Connection& connection = connection_set.getFromIJK( i, j, k ); connection.updateSegment(compseg.segment_number, compseg.center_depth,compseg.m_seqIndex); + + //keep connection sequence number from input sequence + connection.setCompSegSeqIndex(compseg.m_seqIndex); + connection.setSegDistStart(compseg.m_distance_start); + connection.setSegDistEnd(compseg.m_distance_end); } for (size_t ic = 0; ic < connection_set.size(); ++ic) { diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/WellConnections.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/WellConnections.cpp index a6d924e3d..d48e1eb72 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/WellConnections.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/WellConnections.cpp @@ -138,11 +138,13 @@ namespace { double rw, const int satTableId, const WellCompletion::DirectionEnum direction, - const std::size_t seqIndex) + const std::size_t seqIndex, + const double segDistStart, + const double segDistEnd) { int conn_i = (i < 0) ? this->headI : i; int conn_j = (j < 0) ? this->headJ : j; - Connection conn(conn_i, conn_j, k, complnum, depth, state, CF, Kh, rw, satTableId, direction, seqIndex); + Connection conn(conn_i, conn_j, k, complnum, depth, state, CF, Kh, rw, satTableId, direction, seqIndex, segDistStart, segDistEnd); this->add(conn); } @@ -156,7 +158,9 @@ namespace { double rw, const int satTableId, const WellCompletion::DirectionEnum direction, - const std::size_t seqIndex) + const std::size_t seqIndex, + const double segDistStart, + const double segDistEnd) { int complnum = -(this->m_connections.size() + 1); this->addConnection(i, @@ -170,7 +174,9 @@ namespace { rw, satTableId, direction, - seqIndex); + seqIndex, + segDistStart, + segDistEnd); } void WellConnections::loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties) { @@ -286,7 +292,7 @@ namespace { rw, satTableId, direction, - noConn ); + noConn, 0., 0. ); } else { std::size_t noConn = prev->getSeqIndex(); // The complnum value carries over; the rest of the state is fully specified by @@ -301,7 +307,7 @@ namespace { rw, satTableId, direction, - noConn ); + noConn, 0., 0. ); } } } diff --git a/tests/parser/ConnectionTests.cpp b/tests/parser/ConnectionTests.cpp index 67465dfc9..12fa09677 100644 --- a/tests/parser/ConnectionTests.cpp +++ b/tests/parser/ConnectionTests.cpp @@ -69,8 +69,8 @@ BOOST_AUTO_TEST_CASE(CreateWellConnectionsOK) { BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) { Opm::WellCompletion::DirectionEnum dir = Opm::WellCompletion::DirectionEnum::Z; Opm::WellConnections completionSet; - Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0); - Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0); + Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0, 0., 0.); + Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0, 0., 0.); completionSet.add( completion1 ); BOOST_CHECK_EQUAL( 1U , completionSet.size() ); @@ -83,8 +83,8 @@ BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) { BOOST_AUTO_TEST_CASE(WellConnectionsGetOutOfRangeThrows) { Opm::WellCompletion::DirectionEnum dir = Opm::WellCompletion::DirectionEnum::Z; - Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0); - Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0); + Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); + Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); Opm::WellConnections completionSet; completionSet.add( completion1 ); BOOST_CHECK_EQUAL( 1U , completionSet.size() ); @@ -103,9 +103,9 @@ BOOST_AUTO_TEST_CASE(AddCompletionCopy) { Opm::WellConnections completionSet; Opm::WellCompletion::DirectionEnum dir = Opm::WellCompletion::DirectionEnum::Z; - Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0); - Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0); - Opm::Connection completion3( 10,10,12, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0); + Opm::Connection completion1( 10,10,10, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); + Opm::Connection completion2( 10,10,11, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); + Opm::Connection completion3( 10,10,12, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); completionSet.add( completion1 ); completionSet.add( completion2 ); @@ -125,9 +125,9 @@ BOOST_AUTO_TEST_CASE(ActiveCompletions) { Opm::EclipseGrid grid(10,20,20); Opm::WellCompletion::DirectionEnum dir = Opm::WellCompletion::DirectionEnum::Z; Opm::WellConnections completions; - Opm::Connection completion1( 0,0,0, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0); - Opm::Connection completion2( 0,0,1, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0); - Opm::Connection completion3( 0,0,2, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0); + Opm::Connection completion1( 0,0,0, 1, 0.0, Opm::WellCompletion::OPEN , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); + Opm::Connection completion2( 0,0,1, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); + Opm::Connection completion3( 0,0,2, 1, 0.0, Opm::WellCompletion::SHUT , 99.88, 355.113, 0.25, 0, dir,0,0., 0.); completions.add( completion1 ); completions.add( completion2 ); diff --git a/tests/parser/MultisegmentWellTests.cpp b/tests/parser/MultisegmentWellTests.cpp index 854871e26..3ff613b9e 100644 --- a/tests/parser/MultisegmentWellTests.cpp +++ b/tests/parser/MultisegmentWellTests.cpp @@ -44,14 +44,14 @@ BOOST_AUTO_TEST_CASE(MultisegmentWellTest) { Opm::WellCompletion::DirectionEnum dir = Opm::WellCompletion::DirectionEnum::Z; Opm::WellConnections connection_set; - connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0) ); - connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0) ); - connection_set.add(Opm::Connection( 19, 0, 2, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0) ); + connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0, 0., 0.) ); + connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0, 0., 0.) ); + connection_set.add(Opm::Connection( 19, 0, 2, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0, 0., 0.) ); - connection_set.add(Opm::Connection( 18, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0) ); - connection_set.add(Opm::Connection( 17, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0) ); - connection_set.add(Opm::Connection( 16, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0) ); - connection_set.add(Opm::Connection( 15, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0) ); + connection_set.add(Opm::Connection( 18, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0, 0., 0.) ); + connection_set.add(Opm::Connection( 17, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0, 0., 0.) ); + connection_set.add(Opm::Connection( 16, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0, 0., 0.) ); + connection_set.add(Opm::Connection( 15, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, Opm::WellCompletion::DirectionEnum::X,0, 0., 0.) ); BOOST_CHECK_EQUAL( 7U , connection_set.size() );