Merge pull request #2758 from joakim-hove/wtest-filter-wells
Filter out wells from WellTestState
This commit is contained in:
commit
f892fbeb18
@ -195,7 +195,7 @@ public:
|
||||
|
||||
|
||||
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*,
|
||||
since the class has no relation to the set of of wells defined in the
|
||||
|
@ -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 {
|
||||
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
BIN
tests/BASE.UNRST
Normal file
Binary file not shown.
@ -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<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{};
|
||||
|
||||
WellTestConfig wc;
|
||||
|
Loading…
Reference in New Issue
Block a user