Add event for injection type changed

This commit is contained in:
Tor Harald Sandve
2021-03-09 11:36:17 +01:00
parent 6d04924966
commit 456e94d524
3 changed files with 43 additions and 1 deletions

View File

@@ -111,6 +111,11 @@ namespace Opm
* Well/group efficiency factor has changed
*/
WELLGROUP_EFFICIENCY_UPDATE = (1 << 17),
/*
* Injection type changed
*/
INJECTION_TYPE_CHANGED = (1 << 18),
};
}

View File

@@ -985,8 +985,8 @@ namespace {
auto well2 = this->snapshots.back().wells.get( well_name );
auto injection = std::make_shared<Well::WellInjectionProperties>(well2.getInjectionProperties());
auto previousInjectorType = injection->injectorType;
injection->handleWCONINJE(record, well2.isAvailableForGroupControl(), well_name);
if (well2.updateInjection(injection))
update_well = true;
@@ -999,6 +999,8 @@ namespace {
if (update_well) {
this->snapshots.back().events().addEvent(ScheduleEvents::INJECTION_UPDATE);
this->snapshots.back().wellgroup_events().addEvent( well_name, ScheduleEvents::INJECTION_UPDATE);
if(previousInjectorType != injection->injectorType)
this->snapshots.back().wellgroup_events().addEvent( well_name, ScheduleEvents::INJECTION_TYPE_CHANGED);
this->snapshots.back().wells.update( std::move(well2) );
}
@@ -1045,6 +1047,7 @@ namespace {
bool update_well = false;
auto well2 = this->snapshots.back().wells.get( well_name );
auto injection = std::make_shared<Well::WellInjectionProperties>(well2.getInjectionProperties());
auto previousInjectorType = injection->injectorType;
injection->handleWCONINJH(record, well2.isProducer(), well_name);
if (well2.updateInjection(injection))
@@ -1059,6 +1062,8 @@ namespace {
if (update_well) {
this->snapshots.back().events().addEvent( ScheduleEvents::INJECTION_UPDATE );
this->snapshots.back().wellgroup_events().addEvent( well_name, ScheduleEvents::INJECTION_UPDATE);
if(previousInjectorType != injection->injectorType)
this->snapshots.back().wellgroup_events().addEvent( well_name, ScheduleEvents::INJECTION_TYPE_CHANGED);
this->snapshots.back().wells.update( std::move(well2) );
}

View File

@@ -533,6 +533,38 @@ END
BOOST_CHECK_THROW(sched[3].groups.get("I"), std::exception);
}
BOOST_AUTO_TEST_CASE(Change_Injector_Type) {
const auto input = std::string { R"(
SCHEDULE
WELSPECS
-- Group 'I' does not exist before now (report step 4, zero-based = 3)
'I1' 'I' 5 5 2522.5 'WATER' /
/
WCONINJE
'I1' 'WATER' 'OPEN' 'RATE' 200 1* 450.0 /
/
TSTEP
50 50 /
WCONINJE
'I1' 'GAS' 'OPEN' 'RATE' 200 1* 450.0 /
/
TSTEP
50 50 /
END
)"
};
const auto sched = make_schedule(input);
BOOST_CHECK( sched[0].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_UPDATE) );
BOOST_CHECK( !sched[1].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_UPDATE) );
BOOST_CHECK( sched[2].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_UPDATE) );
BOOST_CHECK( !sched[3].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_UPDATE) );
BOOST_CHECK( !sched[0].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_TYPE_CHANGED) );
BOOST_CHECK( !sched[1].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_TYPE_CHANGED) );
BOOST_CHECK( sched[2].wellgroup_events().hasEvent("I1", ScheduleEvents::Events::INJECTION_TYPE_CHANGED) );
BOOST_CHECK( !sched[3].wellgroup_events().hasEvent("I1",ScheduleEvents::Events::INJECTION_TYPE_CHANGED) );
}
BOOST_AUTO_TEST_CASE(WellsIterator_Empty_EmptyVectorReturned) {
const auto& schedule = make_schedule( createDeck() );