diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index f55bf1317..301586ee8 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -114,7 +114,12 @@ namespace Opm size_t numWells(size_t timestep) const; size_t getMaxNumConnectionsForWells(size_t timestep) const; bool hasWell(const std::string& wellName) const; + std::vector wellNames(const std::string& pattern, size_t timeStep, const std::vector& matching_wells = {}) const; + std::vector wellNames(const std::string& pattern) const; + std::vector wellNames(size_t timeStep) const; + std::vector wellNames() const; + const Well* getWell(const std::string& wellName) const; std::vector< const Well* > getOpenWells(size_t timeStep) const; std::vector< const Well* > getWells() const; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 31dfd7f5b..f54664e3a 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -1969,6 +1969,25 @@ namespace Opm { return {}; } + std::vector Schedule::wellNames(const std::string& pattern) const { + return this->wellNames(pattern, this->size() - 1); + } + + std::vector Schedule::wellNames(std::size_t timeStep) const { + std::vector names; + for (const auto& well_pair : this->m_wells) { + if (well_pair.second.firstTimeStep() <= timeStep) + names.push_back(well_pair.first); + } + return names; + } + + std::vector Schedule::wellNames() const { + std::vector names; + for (const auto& well_pair : this->m_wells) + names.push_back(well_pair.first); + return names; + } std::vector< Well* > Schedule::getWells(const std::string& wellNamePattern, const std::vector& matching_wells) { // If we arrive here during the handling the body of a ACTIONX keyword diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index ebe71c3c5..07563f498 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -2937,6 +2937,14 @@ BOOST_AUTO_TEST_CASE(WellNames) { BOOST_CHECK(has(anames, "W1")); BOOST_CHECK(has(anames, "W2")); + auto all_names0 = schedule.wellNames("*", 0); + BOOST_CHECK_EQUAL( all_names0.size(), 6); + BOOST_CHECK( has(all_names0, "W1")); + BOOST_CHECK( has(all_names0, "W2")); + BOOST_CHECK( has(all_names0, "W3")); + BOOST_CHECK( has(all_names0, "DEFAULT")); + BOOST_CHECK( has(all_names0, "ALLOW")); + auto all_names = schedule.wellNames("*", 2); BOOST_CHECK_EQUAL( all_names.size(), 9); BOOST_CHECK( has(all_names, "I1")); @@ -2948,4 +2956,7 @@ BOOST_AUTO_TEST_CASE(WellNames) { BOOST_CHECK( has(all_names, "DEFAULT")); BOOST_CHECK( has(all_names, "ALLOW")); BOOST_CHECK( has(all_names, "BAN")); + + auto abs_all = schedule.wellNames(); + BOOST_CHECK_EQUAL(abs_all.size(), 9); }