Merge pull request #2463 from joakim-hove/get_events

Add method WellGroupEvents.at() to get individual events
This commit is contained in:
Joakim Hove 2021-05-09 13:52:22 +02:00 committed by GitHub
commit c1442803bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -171,6 +171,7 @@ namespace Opm
bool hasEvent(const std::string& wgname, uint64_t eventMask) const;
void clearEvent(const std::string& wgname, uint64_t eventMask);
void reset();
const Events& at(const std::string& wgname) const;
bool operator==(const WellGroupEvents& data) const;
template<class Serializer>

View File

@ -102,5 +102,10 @@ namespace Opm {
return this->m_wellgroup_events == data.m_wellgroup_events;
}
}
const Events& WellGroupEvents::at(const std::string& wgname) const {
return this->m_wellgroup_events.at(wgname);
}
}

View File

@ -50,5 +50,15 @@ BOOST_AUTO_TEST_CASE(CreateEmpty) {
events.clearEvent(Opm::ScheduleEvents::NEW_WELL | Opm::ScheduleEvents::WELL_STATUS_CHANGE | Opm::ScheduleEvents::NEW_GROUP);
BOOST_CHECK_EQUAL( false , events.hasEvent(Opm::ScheduleEvents::NEW_WELL));
BOOST_CHECK_EQUAL( false , events.hasEvent(Opm::ScheduleEvents::WELL_STATUS_CHANGE));
Opm::WellGroupEvents wg_events;
wg_events.addWell("W1");
wg_events.addEvent("W1", Opm::ScheduleEvents::WELL_STATUS_CHANGE );
auto ev = wg_events.at("W1");
BOOST_CHECK_EQUAL( false , ev.hasEvent(Opm::ScheduleEvents::NEW_GROUP));
BOOST_CHECK_EQUAL( true , ev.hasEvent(Opm::ScheduleEvents::WELL_STATUS_CHANGE));
BOOST_CHECK_THROW(wg_events.at("NO_SUCH_WELL"), std::exception);
}