From 96ab0e036d9f21a632f1f7a8c3a3a097aeec0bc5 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 6 Jul 2022 14:32:59 +0200 Subject: [PATCH] addressing some reviewing comments for PR#3067 --- opm/input/eclipse/Schedule/Schedule.hpp | 10 ++++---- .../eclipse/Schedule/KeywordHandlers.cpp | 25 ++++++++----------- src/opm/input/eclipse/Schedule/Schedule.cpp | 11 ++++---- .../share/keywords/000_Eclipse100/W/WPIMULT | 15 ++++------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/opm/input/eclipse/Schedule/Schedule.hpp b/opm/input/eclipse/Schedule/Schedule.hpp index 2433568dd..f695aca43 100644 --- a/opm/input/eclipse/Schedule/Schedule.hpp +++ b/opm/input/eclipse/Schedule/Schedule.hpp @@ -504,7 +504,7 @@ namespace Opm ErrorGuard& errors; SimulatorUpdate * sim_update; const std::unordered_map * target_wellpi; - std::unordered_map* wellpi_global_factor; + std::unordered_map* wpimult_global_factor; const ScheduleGrid& grid; HandlerContext(const ScheduleBlock& block_, @@ -517,7 +517,7 @@ namespace Opm ErrorGuard& errors_, SimulatorUpdate * sim_update_, const std::unordered_map * target_wellpi_, - std::unordered_map* wellpi_global_factor_ = nullptr) + std::unordered_map* wpimult_global_factor_) : block(block_) , keyword(keyword_) , currentStep(currentStep_) @@ -527,7 +527,7 @@ namespace Opm , errors(errors_) , sim_update(sim_update_) , target_wellpi(target_wellpi_) - , wellpi_global_factor(wellpi_global_factor_) + , wpimult_global_factor(wpimult_global_factor_) , grid(grid_) {} @@ -596,7 +596,7 @@ namespace Opm bool actionx_mode, SimulatorUpdate* sim_update, const std::unordered_map* target_wellpi, - std::unordered_map* wellpi_global_factor = nullptr); + std::unordered_map* wpimult_global_factor = nullptr); void prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword); void store_wgnames(const DeckKeyword& keyword); @@ -605,7 +605,7 @@ namespace Opm void invalidNamePattern( const std::string& namePattern, const HandlerContext& context) const; static std::string formatDate(std::time_t t); std::string simulationDays(std::size_t currentStep) const; - void applyGlobalWPIMULT( const std::unordered_map& factors); + void applyGlobalWPIMULT( const std::unordered_map& wpimult_global_factor); bool must_write_rst_file(std::size_t report_step) const; diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index 1abc8dcb6..dca365ad8 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -1778,16 +1778,13 @@ Well{0} entered with disallowed 'FIELD' parent group: // the I, J, K location and completion number range. // When defaulted, it assumes it is negative // When inputting a negative value, it assumes it is defaulted. - auto defaultConCompRec = [] (const DeckRecord& rec)-> bool { - bool default_con_comp = true; - for (size_t i = 2; i < rec.size(); ++i) { - const auto& item = rec.getItem(i); - if (item.get(0) >= 0) { - default_con_comp = false; - break; - } - } - return default_con_comp; + auto defaultConCompRec = [](const DeckRecord& wpimult) + { + return std::all_of(wpimult.begin() + 2, wpimult.end(), + [](const DeckItem& item) + { + return item.defaultApplied(0) || (item.get(0) < 0); + }); }; for (const auto& record : handlerContext.keyword) { @@ -1801,13 +1798,13 @@ Well{0} entered with disallowed 'FIELD' parent group: // whether it is the last one. const bool default_con_comp = defaultConCompRec(record); if (default_con_comp) { - auto wellpi_global_factor = handlerContext.wellpi_global_factor; - if (!wellpi_global_factor) { - throw std::runtime_error(" wellpi_global_factor is nullptr in function handleWPIMULT "); + auto wpimult_global_factor = handlerContext.wpimult_global_factor; + if (!wpimult_global_factor) { + throw std::runtime_error(" wpimult_global_factor is nullptr in function handleWPIMULT "); } const auto scaling_factor = record.getItem("WELLPI").get(0); for (const auto& wname : well_names) { - (*wellpi_global_factor)[wname] = scaling_factor; + (*wpimult_global_factor)[wname] = scaling_factor; } continue; } diff --git a/src/opm/input/eclipse/Schedule/Schedule.cpp b/src/opm/input/eclipse/Schedule/Schedule.cpp index 357eaa1ca..bcaf5e62c 100644 --- a/src/opm/input/eclipse/Schedule/Schedule.cpp +++ b/src/opm/input/eclipse/Schedule/Schedule.cpp @@ -314,7 +314,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const std::optional bool actionx_mode, SimulatorUpdate* sim_update, const std::unordered_map* target_wellpi, - std::unordered_map* wellpi_global_factor) + std::unordered_map* wpimult_global_factor) { static const std::unordered_set require_grid = { @@ -323,7 +323,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const std::optional }; - HandlerContext handlerContext { block, keyword, grid, currentStep, matching_wells, actionx_mode, parseContext, errors, sim_update, target_wellpi, wellpi_global_factor}; + HandlerContext handlerContext { block, keyword, grid, currentStep, matching_wells, actionx_mode, parseContext, errors, sim_update, target_wellpi, + wpimult_global_factor}; /* The grid and fieldProps members create problems for reiterating the Schedule section. We therefor single them out very clearly here. @@ -537,10 +538,8 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e } // for (auto report_step = load_start } - void Schedule::applyGlobalWPIMULT( const std::unordered_map& wellpi_global_factor) { - for (const auto& elem : wellpi_global_factor) { - const auto& well_name = elem.first; - const auto factor = elem.second; + void Schedule::applyGlobalWPIMULT( const std::unordered_map& wpimult_global_factor) { + for (const auto& [well_name, factor] : wpimult_global_factor) { auto well = this->snapshots.back().wells(well_name); if (well.applyGlobalWPIMULT(factor)) { this->snapshots.back().wells.update(std::move(well)); diff --git a/src/opm/input/eclipse/share/keywords/000_Eclipse100/W/WPIMULT b/src/opm/input/eclipse/share/keywords/000_Eclipse100/W/WPIMULT index 38a6b0990..eaeee663a 100644 --- a/src/opm/input/eclipse/share/keywords/000_Eclipse100/W/WPIMULT +++ b/src/opm/input/eclipse/share/keywords/000_Eclipse100/W/WPIMULT @@ -15,28 +15,23 @@ }, { "name": "I", - "value_type": "INT", - "default" : -1 + "value_type": "INT" }, { "name": "J", - "value_type": "INT", - "default" : -1 + "value_type": "INT" }, { "name": "K", - "value_type": "INT", - "default" : -1 + "value_type": "INT" }, { "name": "FIRST", - "value_type": "INT", - "default" : -1 + "value_type": "INT" }, { "name": "LAST", - "value_type": "INT", - "default" : -1 + "value_type": "INT" } ] }