From 3f40960469737751dcdfc5a36deb60ddf91b8dff Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Oct 2023 17:46:37 +0200 Subject: [PATCH 1/5] added: utility function Schedule::isWList checks if the given pattern is the name of a WList --- opm/input/eclipse/Schedule/Schedule.hpp | 2 ++ src/opm/input/eclipse/Schedule/Schedule.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/opm/input/eclipse/Schedule/Schedule.hpp b/opm/input/eclipse/Schedule/Schedule.hpp index b2d14bd23..0818f5532 100644 --- a/opm/input/eclipse/Schedule/Schedule.hpp +++ b/opm/input/eclipse/Schedule/Schedule.hpp @@ -654,6 +654,8 @@ namespace Opm bool must_write_rst_file(std::size_t report_step) const; + bool isWList(std::size_t report_step, const std::string& pattern) const; + void applyEXIT(const DeckKeyword&, std::size_t currentStep); SimulatorUpdate applyAction(std::size_t reportStep, const std::string& action_name, const std::vector& matching_wells); diff --git a/src/opm/input/eclipse/Schedule/Schedule.cpp b/src/opm/input/eclipse/Schedule/Schedule.cpp index eee5219be..5a4c24caf 100644 --- a/src/opm/input/eclipse/Schedule/Schedule.cpp +++ b/src/opm/input/eclipse/Schedule/Schedule.cpp @@ -1757,6 +1757,17 @@ File {} line {}.)", pattern, location.keyword, location.filename, location.linen return this->snapshots[report_step].rst_file(rst_config, previous_output); } + bool Schedule::isWList(std::size_t report_step, const std::string& pattern) const + { + const ScheduleState * sched_state; + + if (report_step < this->snapshots.size()) + sched_state = &this->snapshots[report_step]; + else + sched_state = &this->snapshots.back(); + + return sched_state->wlist_manager.get().hasList(pattern); + } const std::map< std::string, int >& Schedule::rst_keywords( size_t report_step ) const { if (report_step == 0) From a7a84f6f2f54b114c5b99a926072ab797ab53828 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Oct 2023 17:50:57 +0200 Subject: [PATCH 2/5] added: allowEmpty parameter to Schedule::wellNames allows bypassing exception if there are no matches. --- opm/input/eclipse/Schedule/Schedule.hpp | 4 +++- src/opm/input/eclipse/Schedule/Schedule.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/opm/input/eclipse/Schedule/Schedule.hpp b/opm/input/eclipse/Schedule/Schedule.hpp index 0818f5532..29a711988 100644 --- a/opm/input/eclipse/Schedule/Schedule.hpp +++ b/opm/input/eclipse/Schedule/Schedule.hpp @@ -645,7 +645,9 @@ namespace Opm void prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword); void store_wgnames(const DeckKeyword& keyword); - std::vector wellNames(const std::string& pattern, const HandlerContext& context); + std::vector wellNames(const std::string& pattern, + const HandlerContext& context, + bool allowEmpty = false); std::vector wellNames(const std::string& pattern, std::size_t timeStep, const std::vector& matching_wells, InputErrorAction error_action, ErrorGuard& errors, const KeywordLocation& location) const; void invalidNamePattern( const std::string& namePattern, const HandlerContext& context) const; static std::string formatDate(std::time_t t); diff --git a/src/opm/input/eclipse/Schedule/Schedule.cpp b/src/opm/input/eclipse/Schedule/Schedule.cpp index 5a4c24caf..8da9592f8 100644 --- a/src/opm/input/eclipse/Schedule/Schedule.cpp +++ b/src/opm/input/eclipse/Schedule/Schedule.cpp @@ -1216,11 +1216,14 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e - std::vector Schedule::wellNames(const std::string& pattern, const HandlerContext& context) { + std::vector Schedule::wellNames(const std::string& pattern, + const HandlerContext& context, + bool allowEmpty) + { std::vector valid_names; const auto& report_step = context.currentStep; auto names = this->wellNames(pattern, report_step, context.matching_wells); - if (names.empty()) { + if (names.empty() && !allowEmpty) { const auto& location = context.keyword.location(); if (this->action_wgnames.has_well(pattern)) { std::string msg = fmt::format(R"(Well: {} not yet defined for keyword {}. From 396bc10db488f1c3399742d98069d12e8a3a45ca Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Oct 2023 17:52:02 +0200 Subject: [PATCH 3/5] changed: Schedule::handleWELOPEN allow operation on empty well lists. in particular this will be necessary supporting WLIST modifications by ACTIONX --- src/opm/input/eclipse/Schedule/KeywordHandlers.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index 3fd3686a9..afeb88a3f 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -1494,7 +1494,9 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno) for (const auto& record : keyword) { const auto& wellNamePattern = record.getItem( "WELL" ).getTrimmedString(0); const auto& status_str = record.getItem( "STATUS" ).getTrimmedString( 0 ); - const auto well_names = this->wellNames(wellNamePattern, handlerContext); + const auto well_names = this->wellNames(wellNamePattern, handlerContext, + isWList(handlerContext.currentStep, + wellNamePattern)); /* if all records are defaulted or just the status is set, only * well status is updated From a18b799468ca75195f90e892f1e8621b76b97b59 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Oct 2023 17:59:01 +0200 Subject: [PATCH 4/5] changed: pass matching_wells in handleWLIST --- src/opm/input/eclipse/Schedule/KeywordHandlers.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index afeb88a3f..84572e82f 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -1984,7 +1984,9 @@ Well{0} entered with 'FIELD' parent group: throw std::invalid_argument("The action:" + action + " is not recognized."); for (const auto& well_arg : well_args) { - const auto& names = this->wellNames(well_arg, handlerContext.currentStep); + // does not use overload for context to avoid throw + const auto& names = this->wellNames(well_arg, handlerContext.currentStep, + handlerContext.matching_wells); if (names.empty() && well_arg.find("*") == std::string::npos) throw std::invalid_argument("The well: " + well_arg + " has not been defined in the WELSPECS"); From 54bdca66e1aef8956aa53991f15fe3c021cf4e82 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Oct 2023 17:52:56 +0200 Subject: [PATCH 5/5] added: enable WLIST in ACTIONX --- src/opm/input/eclipse/Schedule/Action/ActionX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opm/input/eclipse/Schedule/Action/ActionX.cpp b/src/opm/input/eclipse/Schedule/Action/ActionX.cpp index b9554a2e5..cfe569516 100755 --- a/src/opm/input/eclipse/Schedule/Action/ActionX.cpp +++ b/src/opm/input/eclipse/Schedule/Action/ActionX.cpp @@ -67,7 +67,7 @@ bool ActionX::valid_keyword(const std::string& keyword) { "MULTX", "MULTX-", "MULTY", "MULTY-", "MULTZ", "MULTZ-", "NEXT", "NEXTSTEP", "UDQ", - "WCONINJE", "WCONPROD", "WECON", "WEFAC", "WELOPEN", "WELPI", "WELTARG", "WGRUPCON", "WPIMULT", "WELSEGS", "WELSPECS", "WSEGVALV", "WTEST", "WTMULT", + "WCONINJE", "WCONPROD", "WECON", "WEFAC", "WELOPEN", "WELPI", "WELTARG", "WGRUPCON", "WPIMULT", "WELSEGS", "WELSPECS", "WSEGVALV", "WTEST", "WTMULT", "WLIST", "TEST" }; return (actionx_allowed_list.find(keyword) != actionx_allowed_list.end());