From 32906b5022c10d342bb3c9a25ef6a261527e5f49 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 24 Nov 2023 10:27:11 +0100 Subject: [PATCH] HandlerContext: wpimult_global_factor is never nullptr use a reference instead of a pointer --- opm/input/eclipse/Schedule/Schedule.hpp | 2 +- src/opm/input/eclipse/Schedule/HandlerContext.hpp | 4 ++-- src/opm/input/eclipse/Schedule/KeywordHandlers.cpp | 7 ++----- src/opm/input/eclipse/Schedule/Schedule.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/opm/input/eclipse/Schedule/Schedule.hpp b/opm/input/eclipse/Schedule/Schedule.hpp index 7f7af7b8d..2e8908004 100644 --- a/opm/input/eclipse/Schedule/Schedule.hpp +++ b/opm/input/eclipse/Schedule/Schedule.hpp @@ -556,7 +556,7 @@ namespace Opm bool actionx_mode, SimulatorUpdate* sim_update, const std::unordered_map* target_wellpi, - std::unordered_map* wpimult_global_factor = nullptr, + std::unordered_map& wpimult_global_factor, WelSegsSet* welsegs_wells = nullptr, std::set* compsegs_wells = nullptr); diff --git a/src/opm/input/eclipse/Schedule/HandlerContext.hpp b/src/opm/input/eclipse/Schedule/HandlerContext.hpp index b6f4a82d1..344bf36af 100644 --- a/src/opm/input/eclipse/Schedule/HandlerContext.hpp +++ b/src/opm/input/eclipse/Schedule/HandlerContext.hpp @@ -53,7 +53,7 @@ public: ErrorGuard& errors_, SimulatorUpdate* sim_update_, const std::unordered_map* target_wellpi_, - std::unordered_map* wpimult_global_factor_, + std::unordered_map& wpimult_global_factor_, WelSegsSet* welsegs_wells_, std::set* compsegs_wells_) : block(block_) @@ -96,7 +96,7 @@ public: const bool actionx_mode; const ParseContext& parseContext; ErrorGuard& errors; - std::unordered_map* wpimult_global_factor{nullptr}; + std::unordered_map& wpimult_global_factor; const ScheduleGrid& grid; private: diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index be07c943a..3390b6bed 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -2291,13 +2291,10 @@ Well{0} entered with 'FIELD' parent group: // whether it is the last one. const bool default_con_comp = defaultConCompRec(record); if (default_con_comp) { - auto wpimult_global_factor = handlerContext.wpimult_global_factor; - if (!wpimult_global_factor) { - throw std::runtime_error(" wpimult_global_factor is nullptr in function handleWPIMULT "); - } + auto& wpimult_global_factor = handlerContext.wpimult_global_factor; const auto scaling_factor = record.getItem("WELLPI").get(0); for (const auto& wname : well_names) { - (*wpimult_global_factor)[wname] = scaling_factor; + wpimult_global_factor.insert_or_assign(wname, scaling_factor); } continue; } diff --git a/src/opm/input/eclipse/Schedule/Schedule.cpp b/src/opm/input/eclipse/Schedule/Schedule.cpp index 98834215b..31ae7f202 100644 --- a/src/opm/input/eclipse/Schedule/Schedule.cpp +++ b/src/opm/input/eclipse/Schedule/Schedule.cpp @@ -372,7 +372,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* wpimult_global_factor, + std::unordered_map& wpimult_global_factor, WelSegsSet* welsegs_wells, std::set* compsegs_wells) { @@ -690,7 +690,7 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e false, nullptr, target_wellpi, - &wpimult_global_factor, + wpimult_global_factor, &welsegs_wells, &compsegs_wells); keyword_index++; @@ -1522,7 +1522,7 @@ File {} line {}.)", pattern, location.keyword, location.filename, location.linen /*actionx_mode=*/false, &sim_update, &target_wellpi, - &wpimult_global_factor); + wpimult_global_factor); } this->applyGlobalWPIMULT(wpimult_global_factor); this->end_report(reportStep); @@ -1577,7 +1577,7 @@ File {} line {}.)", pattern, location.keyword, location.filename, location.linen true, &sim_update, &target_wellpi, - &wpimult_global_factor); + wpimult_global_factor); } this->applyGlobalWPIMULT(wpimult_global_factor);