diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp index ac4820080..dd0b8e114 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp @@ -195,7 +195,7 @@ public: std::vector test_wells(const WellTestConfig& config, double sim_time); - + void filter_wells(const std::vector& existing_wells); /* The purpose of this container is to manage explicitly *closed wells*, since the class has no relation to the set of of wells defined in the diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.cpp index c3307f6ed..8a9d1b558 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.cpp @@ -110,6 +110,14 @@ namespace Opm { } + void WellTestState::filter_wells(const std::vector& existing_wells) { + std::unordered_set well_set{ existing_wells.begin(), existing_wells.end() }; + for (auto& [wname, test_well] : this->wells) { + if (well_set.count(wname) == 0) + test_well.closed = false; + } + } + size_t WellTestState::num_closed_wells() const { return std::count_if(this->wells.begin(), this->wells.end(), [](const auto& well_pair) { return well_pair.second.closed; }); diff --git a/tests/BASE.UNRST b/tests/BASE.UNRST new file mode 100644 index 000000000..7bdf08bdf Binary files /dev/null and b/tests/BASE.UNRST differ diff --git a/tests/parser/WTEST.cpp b/tests/parser/WTEST.cpp index eb82f29e7..4753dc5a5 100644 --- a/tests/parser/WTEST.cpp +++ b/tests/parser/WTEST.cpp @@ -90,6 +90,14 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE) { st.close_well("WELLX", WellTestConfig::Reason::PHYSICAL, 100. * day); BOOST_CHECK_EQUAL(st.num_closed_wells(), 2U); + { + auto st2 = st; + st2.filter_wells(std::vector{"WELLX"}); + + BOOST_CHECK(!st2.well_is_closed("WELL_NAME")); // This well has been opened/removed by the filter_wells() call + BOOST_CHECK( st2.well_is_closed("WELLX")); + } + const UnitSystem us{}; WellTestConfig wc;