From b10933116318cc3b32fe7a973f1cabdb6eded6e8 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 25 Nov 2019 09:55:32 +0100 Subject: [PATCH] add group events --- .../eclipse/EclipseState/Schedule/Events.hpp | 9 ++++++- .../EclipseState/Schedule/Schedule.hpp | 6 +++++ .../EclipseState/Schedule/Schedule.cpp | 26 ++++++++++++++++++- tests/parser/ScheduleTests.cpp | 5 ++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Events.hpp b/opm/parser/eclipse/EclipseState/Schedule/Events.hpp index d858862c1..10a981420 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Events.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Events.hpp @@ -93,7 +93,14 @@ namespace Opm /* The VFP tables have changed */ VFPINJ_UPDATE = 4096, - VFPPROD_UPDATE = 8192 + VFPPROD_UPDATE = 8192, + + + /* + GROUP production or injection targets has changed + */ + GROUP_PRODUCTION_UPDATE = 16384, + GROUP_INJECTION_UPDATE = 32768 }; } diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 332a4362d..4e0d18a79 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -206,6 +206,8 @@ namespace Opm const Events& getEvents() const; const Events& getWellEvents(const std::string& well) const; bool hasWellEvent(const std::string& well, uint64_t event_mask, size_t reportStep) const; + const Events& getGroupEvents(const std::string& group) const; + bool hasGroupEvent(const std::string& group, uint64_t event_mask, size_t reportStep) const; const Deck& getModifierDeck(size_t timeStep) const; bool hasOilVaporizationProperties() const; const VFPProdTable& getVFPProdTable(int table_id, size_t timeStep) const; @@ -247,6 +249,8 @@ namespace Opm std::map well_events; + std::map group_events; + GTNode groupTree(const std::string& root_node, std::size_t report_step, const GTNode * parent) const; void updateGroup(std::shared_ptr group, size_t reportStep); @@ -322,6 +326,8 @@ namespace Opm const UnitSystem& unit_system, std::vector >& rftProperties); void addWellEvent(const std::string& well, ScheduleEvents::Events event, size_t reportStep); + void addGroupEvent(const std::string& group, ScheduleEvents::Events event, size_t reportStep); + }; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 1dba63b82..435a0fee6 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -1506,8 +1506,11 @@ namespace { if (!record.getItem("VOIDAGE_TARGET").defaultApplied(0)) injection.injection_controls += static_cast(Group::InjectionCMode::VREP); - if (group_ptr->updateInjection(injection)) + if (group_ptr->updateInjection(injection)) { this->updateGroup(std::move(group_ptr), currentStep); + m_events.addEvent( ScheduleEvents::GROUP_INJECTION_UPDATE , currentStep); + this->addGroupEvent(group_name, ScheduleEvents::GROUP_INJECTION_UPDATE, currentStep); + } } } } @@ -1590,6 +1593,8 @@ namespace { this->guide_rate_config.update( currentStep, std::move(new_config) ); this->updateGroup(std::move(group_ptr), currentStep); + m_events.addEvent( ScheduleEvents::GROUP_PRODUCTION_UPDATE , currentStep); + this->addGroupEvent(group_name, ScheduleEvents::GROUP_PRODUCTION_UPDATE, currentStep); } } } @@ -2409,6 +2414,8 @@ void Schedule::handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep, c dynamic_state.update(timeStep, group_ptr); m_events.addEvent( ScheduleEvents::NEW_GROUP , timeStep ); + group_events.insert( std::make_pair(groupName, Events(this->m_timeMap))); + this->addGroupEvent(groupName, ScheduleEvents::NEW_GROUP, timeStep); // All newly created groups are attached to the field group, // can then be relocated with the GRUPTREE keyword. @@ -2517,6 +2524,23 @@ void Schedule::handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep, c return events.hasEvent(event_mask, reportStep); } + const Events& Schedule::getGroupEvents(const std::string& group) const { + if (this->group_events.count(group) > 0) + return this->group_events.at(group); + else + throw std::invalid_argument("No such group " + group); + } + + void Schedule::addGroupEvent(const std::string& group, ScheduleEvents::Events event, size_t reportStep) { + auto& events = this->group_events.at(group); + events.addEvent(event, reportStep); + } + + bool Schedule::hasGroupEvent(const std::string& group, uint64_t event_mask, size_t reportStep) const { + const auto& events = this->getGroupEvents(group); + return events.hasEvent(event_mask, reportStep); + } + const Events& Schedule::getEvents() const { return this->m_events; } diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index 77897f669..7b86c41a5 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -1292,6 +1292,11 @@ BOOST_AUTO_TEST_CASE(createDeckModifyMultipleGCONPROD) { BOOST_CHECK_EQUAL(g2.productionControls(st).oil_target, 2000 * siFactorL); auto gh = schedule.getGroup("H1", 1); + + + BOOST_CHECK( !schedule.hasGroupEvent( "G2", ScheduleEvents::GROUP_PRODUCTION_UPDATE , 1 )); + BOOST_CHECK( schedule.hasGroupEvent( "G2", ScheduleEvents::GROUP_PRODUCTION_UPDATE , 2 )); + } BOOST_AUTO_TEST_CASE(createDeckWithDRSDT) {