From 1b3cee80887858b965cee79d4b80dc0e5bda45e7 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 29 Jun 2022 14:20:35 +0200 Subject: [PATCH] using C++17 style for to reduce nesting level of for loop --- opm/simulators/wells/MultisegmentWellEval.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellEval.cpp b/opm/simulators/wells/MultisegmentWellEval.cpp index 80c9c229e..e9a3eafd4 100644 --- a/opm/simulators/wells/MultisegmentWellEval.cpp +++ b/opm/simulators/wells/MultisegmentWellEval.cpp @@ -1554,16 +1554,15 @@ assembleICDPressureEq(const int seg, // top segment can not be a spiral ICD device assert(seg != 0); - if(this->segmentSet()[seg].segmentType() == Segment::SegmentType::VALVE) { - const Valve& valve = this->segmentSet()[seg].valve(); - if (valve.status() == Opm::ICDStatus::SHUT) { // we switch here to be a zero rate equation - resWell_[seg][SPres] = this->primary_variables_evaluation_[seg][GTotal].value(); - duneD_[seg][seg][SPres][GTotal] = 1.; + if (const auto& segment = this->segmentSet()[seg]; + (segment.segmentType() == Segment::SegmentType::VALVE) && + (segment.valve().status() == Opm::ICDStatus::SHUT) ) { // we use a zero rate equation to handle SHUT valve + resWell_[seg][SPres] = this->primary_variables_evaluation_[seg][GTotal].value(); + duneD_[seg][seg][SPres][GTotal] = 1.; - auto& ws = well_state.well(baseif_.indexOfWell()); - ws.segments.pressure_drop_friction[seg] = 0.; - return; - } + auto& ws = well_state.well(baseif_.indexOfWell()); + ws.segments.pressure_drop_friction[seg] = 0.; + return; } // the pressure equation is something like