From 7571215f44fc217d4d1b9c3ba0e66f2788db42bd Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 13 Sep 2022 08:33:51 +0200 Subject: [PATCH] some cleanup --- .../wells/BlackoilWellModelGeneric.cpp | 12 ++++++------ opm/simulators/wells/BlackoilWellModel_impl.hpp | 17 +++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index f908836de7..6f4726a4bb 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1219,7 +1219,7 @@ checkGroupHigherConstraints(const Group& group, auto currentControl = this->groupState().injection_control(group.name(), phase); if (currentControl != Group::InjectionCMode::FLD && group.injectionGroupControlAvailable(phase)) { const Group& parentGroup = schedule().getGroup(group.parent(), reportStepIdx); - const std::pair changed_this = WellGroupHelpers::checkGroupConstraintsInj( + const auto [is_changed, scaling_factor] = WellGroupHelpers::checkGroupConstraintsInj( group.name(), group.parent(), parentGroup, @@ -1235,10 +1235,10 @@ checkGroupHigherConstraints(const Group& group, summaryState_, resv_coeff_inj, deferred_logger); - if (changed_this.first) { + if (is_changed) { switched_inj_groups_.insert({ {group.name(), phase}, Group::InjectionCMode2String(Group::InjectionCMode::FLD)}); actionOnBrokenConstraints(group, Group::InjectionCMode::FLD, phase, deferred_logger); - WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ true, this->groupState(), this->wellState()); + WellGroupHelpers::updateWellRatesFromGroupTargetScale(scaling_factor, group, schedule(), reportStepIdx, /* isInjector */ true, this->groupState(), this->wellState()); changed = true; } } @@ -1258,7 +1258,7 @@ checkGroupHigherConstraints(const Group& group, const Group::ProductionCMode& currentControl = this->groupState().production_control(group.name()); if (currentControl != Group::ProductionCMode::FLD && group.productionGroupControlAvailable()) { const Group& parentGroup = schedule().getGroup(group.parent(), reportStepIdx); - const std::pair changed_this = WellGroupHelpers::checkGroupConstraintsProd( + const auto [is_changed, scaling_factor] = WellGroupHelpers::checkGroupConstraintsProd( group.name(), group.parent(), parentGroup, @@ -1273,11 +1273,11 @@ checkGroupHigherConstraints(const Group& group, summaryState_, resv_coeff, deferred_logger); - if (changed_this.first) { + if (is_changed) { switched_prod_groups_.insert({group.name(), Group::ProductionCMode2String(Group::ProductionCMode::FLD)}); const auto exceed_action = group.productionControls(summaryState_).exceed_action; actionOnBrokenConstraints(group, exceed_action, Group::ProductionCMode::FLD, deferred_logger); - WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState()); + WellGroupHelpers::updateWellRatesFromGroupTargetScale(scaling_factor, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState()); changed = true; } } diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index a8ad80f148..99625dd789 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -468,26 +468,27 @@ namespace Opm { if (terminal_output_) { for (const auto& [name, to] : switched_prod_groups_) { - std::string msg = " Production Group " + name - + " control mode changed from "; const Group::ProductionCMode& oldControl = this->prevWGState().group_state.production_control(name); std::string from = Group::ProductionCMode2String(oldControl); - msg += from; - msg += " to " + to; if (to != from) { + std::string msg = " Production Group " + name + + " control mode changed from "; + msg += from; + msg += " to " + to; local_deferredLogger.info(msg); } } for (const auto& [key, to] : switched_inj_groups_) { const std::string& name = key.first; const Opm::Phase& phase = key.second; - std::string msg = " Injection Group " + name - + " control mode changed from "; + const Group::InjectionCMode& oldControl = this->prevWGState().group_state.injection_control(name, phase); std::string from = Group::InjectionCMode2String(oldControl); - msg += from; - msg += " to " + to; if (to != from) { + std::string msg = " Injection Group " + name + + " control mode changed from "; + msg += from; + msg += " to " + to; local_deferredLogger.info(msg); } }