Merge pull request #2758 from joakim-hove/wtest-filter-wells

Filter out wells from WellTestState
This commit is contained in:
Joakim Hove 2021-10-18 08:09:38 +02:00 committed by GitHub
commit f892fbeb18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -195,7 +195,7 @@ public:
std::vector<std::string> test_wells(const WellTestConfig& config, double sim_time); std::vector<std::string> test_wells(const WellTestConfig& config, double sim_time);
void filter_wells(const std::vector<std::string>& existing_wells);
/* /*
The purpose of this container is to manage explicitly *closed 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 since the class has no relation to the set of of wells defined in the

View File

@ -110,6 +110,14 @@ namespace Opm {
} }
void WellTestState::filter_wells(const std::vector<std::string>& existing_wells) {
std::unordered_set<std::string> 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 { 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; }); return std::count_if(this->wells.begin(), this->wells.end(), [](const auto& well_pair) { return well_pair.second.closed; });

BIN
tests/BASE.UNRST Normal file

Binary file not shown.

View File

@ -90,6 +90,14 @@ BOOST_AUTO_TEST_CASE(WTEST_STATE) {
st.close_well("WELLX", WellTestConfig::Reason::PHYSICAL, 100. * day); st.close_well("WELLX", WellTestConfig::Reason::PHYSICAL, 100. * day);
BOOST_CHECK_EQUAL(st.num_closed_wells(), 2U); BOOST_CHECK_EQUAL(st.num_closed_wells(), 2U);
{
auto st2 = st;
st2.filter_wells(std::vector<std::string>{"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{}; const UnitSystem us{};
WellTestConfig wc; WellTestConfig wc;