From 716eaa8b0ac5f8d572d8d123eecde03fdecbae0a Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 23 Jan 2025 10:55:25 +0100 Subject: [PATCH] reduce scope of variables remove unused variables break some long lines while at it --- .../wells/MultisegmentWell_impl.hpp | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index f9a012652..da033094e 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -1656,32 +1656,28 @@ namespace Opm // if we fail to solve eqs, we reset status/operability before leaving const auto well_status_orig = this->wellStatus_; const auto operability_orig = this->operability_status_; - auto well_status_cur = well_status_orig; // don't allow opening wells that are stopped from schedule or has a stopped well state const bool allow_open = this->well_ecl_.getStatus() == WellStatus::OPEN && well_state.well(this->index_of_well_).status == WellStatus::OPEN; // don't allow switcing for wells under zero rate target or requested fixed status and control const bool allow_switching = !this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) && (!fixed_control || !fixed_status) && allow_open; - bool changed = false; bool final_check = false; // well needs to be set operable or else solving/updating of re-opened wells is skipped this->operability_status_.resetOperability(); this->operability_status_.solvable = true; for (; it < max_iter_number; ++it, ++debug_cost_counter_) { - its_since_last_switch++; + ++its_since_last_switch; if (allow_switching && its_since_last_switch >= min_its_after_switch){ const Scalar wqTotal = this->primary_variables_.getWQTotal().value(); - changed = this->updateWellControlAndStatusLocalIteration(simulator, well_state, group_state, - inj_controls, prod_controls, wqTotal, - deferred_logger, fixed_control, fixed_status); - if (changed){ + bool changed = this->updateWellControlAndStatusLocalIteration(simulator, well_state, group_state, + inj_controls, prod_controls, wqTotal, + deferred_logger, fixed_control, + fixed_status); + if (changed) { its_since_last_switch = 0; - switch_count++; - if (well_status_cur != this->wellStatus_) { - well_status_cur = this->wellStatus_; - } + ++switch_count; } if (!changed && final_check) { break; @@ -1690,7 +1686,8 @@ namespace Opm } } - assembleWellEqWithoutIteration(simulator, dt, inj_controls, prod_controls, well_state, group_state, deferred_logger); + assembleWellEqWithoutIteration(simulator, dt, inj_controls, prod_controls, + well_state, group_state, deferred_logger); const BVectorWell dx_well = this->linSys_.solve();