diff --git a/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp b/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp index ff8e60431..6da88e0cd 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp @@ -28,7 +28,7 @@ namespace Opm { WellConnections * newConnectionsWithSegments(const DeckKeyword& compsegs, const WellConnections& input_connections, - const WellSegments& segments, const EclipseGrid& grid, std::size_t& totNC); + const WellSegments& segments, const EclipseGrid& grid); } #endif diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp index 037181df5..24c22c2c8 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp @@ -57,9 +57,8 @@ namespace Opm { WellCompletion::CompletionOrderEnum completionOrdering = WellCompletion::TRACK, bool allowCrossFlow = true, bool automaticShutIn = true); const std::string& name() const; - const size_t& seqIndex() const; - std::size_t getTotNoConn() const; - void setTotNoConn(std::size_t noConn); + const size_t& seqIndex() const; + std::size_t getTotNoConn() const; bool hasBeenDefined(size_t timeStep) const; const std::string getGroupName(size_t timeStep) const; void setGroupName(size_t timeStep , const std::string& groupName); @@ -208,9 +207,8 @@ namespace Opm { private: size_t m_creationTimeStep; std::string m_name; - std::size_t m_seqIndex; - std::size_t m_totNoConn=0; - + std::size_t m_seqIndex; + DynamicState< WellCommon::StatusEnum > m_status; DynamicState< int > m_isAvailableForGroupControl; diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp index 8fab014a9..4fede52c6 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp @@ -46,12 +46,13 @@ namespace Opm { const double segDistStart= 0.0, const double segDistEnd= 0.0, const bool defaultSatTabId = true); - void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, std::size_t& totNC); + void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties); using const_iterator = std::vector< Connection >::const_iterator; void add( Connection ); size_t size() const; + size_t inputSize() const; const Connection& operator[](size_t index) const; const Connection& get(size_t index) const; const Connection& getFromIJK(const int i, const int j, const int k) const; @@ -59,9 +60,6 @@ namespace Opm { const_iterator begin() const { return this->m_connections.begin(); } const_iterator end() const { return this->m_connections.end(); } - - std::size_t totNoConn() const { return this->m_connections.size(); } - void filter(const EclipseGrid& grid); bool allConnectionsShut() const; /// Order connections irrespective of input order. @@ -101,6 +99,7 @@ namespace Opm { size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos); int headI, headJ; + size_t num_removed = 0; std::vector< Connection > m_connections; }; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp index 2fce549bd..19b863a7b 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp @@ -50,7 +50,7 @@ namespace Opm { { } - std::vector< Compsegs > Compsegs::compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid, std::size_t& totNC ) { + std::vector< Compsegs > Compsegs::compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid) { // only handle the second record here // The first record here only contains the well name @@ -124,19 +124,17 @@ namespace Opm { // will decide the segment number based on the distance in a process later. } if (!record.getItem().hasValue(0)) { // only one compsegs - - if (grid.cellActive(I, J, K)) { - std::size_t seqIndex = compsegs.size(); - totNC = seqIndex+1; - compsegs.emplace_back( I, J, K, - branch, - distance_start, distance_end, - direction, - center_depth, - segment_number, - seqIndex - ); - } + + if (grid.cellActive(I, J, K)) { + std::size_t seqIndex = compsegs.size(); + compsegs.emplace_back( I, J, K, + branch, + distance_start, distance_end, + direction, + center_depth, + segment_number, + seqIndex); + } } else { // a range is defined. genrate a range of Compsegs throw std::runtime_error("entering COMPSEGS entries with a range is not supported yet!"); } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp index abbef1f47..53c427290 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp @@ -58,7 +58,7 @@ namespace Opm { void calculateCenterDepthWithSegments(const WellSegments& segment_set); - static std::vector< Compsegs > compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid, std::size_t& totNC ); + static std::vector< Compsegs > compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid); // get the segment number information and depth information based on the information from WellSegments static void processCOMPSEGS(std::vector< Compsegs >& compsegs, const WellSegments& segment_set ); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp index 1953982ee..3703ef5ca 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp @@ -27,13 +27,10 @@ namespace Opm { WellConnections * newConnectionsWithSegments(const DeckKeyword& compsegs, const WellConnections& input_connections, const WellSegments& segment_set, - const EclipseGrid& grid, - std::size_t& totNC - ) + const EclipseGrid& grid) { WellConnections * new_connection_set = new WellConnections(input_connections); - - std::vector compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( compsegs, grid, totNC ); + std::vector compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( compsegs, grid ); Compsegs::processCOMPSEGS(compsegs_vector, segment_set); Compsegs::updateConnectionsWithSegment(compsegs_vector, grid, *new_connection_set); return new_connection_set; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index b9063bc3a..b21a8b0eb 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -402,13 +402,12 @@ namespace Opm { } std::size_t Well::getTotNoConn() const { - return this->m_totNoConn; + std::size_t time_step = this->timesteps; + const auto& connections = this->getConnections(time_step); + return connections.inputSize(); } - void Well::setTotNoConn(std::size_t noConn) { - m_totNoConn = noConn; - } - + const std::string Well::getGroupName(size_t time_step) const { return m_groupName.get(time_step); } @@ -709,11 +708,7 @@ namespace Opm { void Well::handleCOMPDAT(size_t time_step, const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties) { WellConnections * connections = new WellConnections(this->getConnections(time_step)); - std::size_t totNC = 0; - connections->loadCOMPDAT(record, grid, eclipseProperties, totNC); - if (totNC > 0) { - this->setTotNoConn(totNC); - } + connections->loadCOMPDAT(record, grid, eclipseProperties); this->updateWellConnections(time_step, connections); } @@ -721,11 +716,7 @@ namespace Opm { void Well::handleCOMPSEGS(const DeckKeyword& keyword, const EclipseGrid& grid, size_t time_step) { const auto& segment_set = this->getWellSegments(time_step); const auto& completion_set = this->getConnections( time_step ); - std::size_t totNC = 0; - WellConnections * new_connection_set = newConnectionsWithSegments(keyword, completion_set, segment_set, grid, totNC); - if (totNC > 0) { - this->setTotNoConn(totNC); - } + WellConnections * new_connection_set = newConnectionsWithSegments(keyword, completion_set, segment_set, grid); this->updateWellConnections(time_step, new_connection_set); } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp index 9af76c3b8..49ed51457 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp @@ -192,7 +192,7 @@ namespace { defaultSatTabId); } - void WellConnections::loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, std::size_t& totNC) { + void WellConnections::loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties) { const auto& permx = eclipseProperties.getDoubleGridProperty("PERMX").getData(); const auto& permy = eclipseProperties.getDoubleGridProperty("PERMY").getData(); const auto& permz = eclipseProperties.getDoubleGridProperty("PERMZ").getData(); @@ -298,7 +298,6 @@ namespace { if (grid.cellActive(I, J, k)) { if (prev == this->m_connections.end()) { std::size_t noConn = this->m_connections.size(); - totNC = noConn+1; this->addConnection(I,J,k, grid.getCellDepth( I,J,k ), state, @@ -343,6 +342,10 @@ namespace { + size_t WellConnections::inputSize() const { + return m_connections.size() + this->num_removed; + } + size_t WellConnections::size() const { return m_connections.size(); } @@ -464,6 +467,7 @@ namespace { auto new_end = std::remove_if(m_connections.begin(), m_connections.end(), [&grid](const Connection& c) { return !grid.cellActive(c.getI(), c.getJ(), c.getK()); }); + this->num_removed += std::distance(new_end, m_connections.end()); m_connections.erase(new_end, m_connections.end()); } } diff --git a/tests/parser/ConnectionTests.cpp b/tests/parser/ConnectionTests.cpp index dfbfe3f87..b990c74a4 100644 --- a/tests/parser/ConnectionTests.cpp +++ b/tests/parser/ConnectionTests.cpp @@ -150,9 +150,8 @@ Opm::WellConnections loadCOMPDAT(const std::string& compdat_keyword) { Opm::Eclipse3DProperties props(deck, tables, grid ); const auto& keyword = deck.getKeyword("COMPDAT", 0); Opm::WellConnections connections; - std::size_t totnc = 0; for (const auto& rec : keyword) - connections.loadCOMPDAT(rec, grid, props, totnc); + connections.loadCOMPDAT(rec, grid, props); return connections; } diff --git a/tests/parser/MultisegmentWellTests.cpp b/tests/parser/MultisegmentWellTests.cpp index 9531bd62e..049ef9953 100644 --- a/tests/parser/MultisegmentWellTests.cpp +++ b/tests/parser/MultisegmentWellTests.cpp @@ -87,8 +87,7 @@ BOOST_AUTO_TEST_CASE(MultisegmentWellTest) { segment_set.loadWELSEGS(welsegs); BOOST_CHECK_EQUAL(6U, segment_set.size()); - std::size_t totNC = 0; - const Opm::WellConnections * new_connection_set = Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, totNC); + const Opm::WellConnections * new_connection_set = Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid); BOOST_CHECK_EQUAL(7U, new_connection_set->size()); diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index 07504a904..50a717351 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -2601,16 +2601,26 @@ BOOST_AUTO_TEST_CASE(FilterCompletions) { Runspec runspec (deck); Schedule schedule(deck, grid1 , eclipseProperties, runspec); const auto& well = schedule.getWell("OP_1"); - const auto& c1_1 = well->getConnections(1); - const auto& c1_3 = well->getConnections(3); - BOOST_CHECK_EQUAL(2, c1_1.size()); - BOOST_CHECK_EQUAL(9, c1_3.size()); + { + const auto& c1_1 = well->getConnections(1); + const auto& c1_3 = well->getConnections(3); + BOOST_CHECK_EQUAL(2, c1_1.size()); + BOOST_CHECK_EQUAL(9, c1_3.size()); + } actnum[grid1.getGlobalIndex(8,8,1)] = 0; { EclipseGrid grid2(grid1, actnum); schedule.filterConnections(grid2); + + const auto& c1_1 = well->getConnections(1); + const auto& c1_3 = well->getConnections(3); BOOST_CHECK_EQUAL(1, c1_1.size()); BOOST_CHECK_EQUAL(8, c1_3.size()); + + BOOST_CHECK_EQUAL(2, c1_1.inputSize()); + BOOST_CHECK_EQUAL(9, c1_3.inputSize()); + + BOOST_CHECK_EQUAL( well->getTotNoConn(), 9); } }