From f9e142dc8dae4353cabc2e873aa174336bf9ee9c Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 21 May 2021 07:48:50 +0200 Subject: [PATCH] Use well index when iterating over polymer perforation rates --- opm/simulators/wells/StandardWell_impl.hpp | 3 ++- opm/simulators/wells/WellState.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 74102d8bf..1e1e3cfce 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -794,7 +794,8 @@ namespace Opm cq_s_poly *= extendEval(intQuants.polymerConcentration() * intQuants.polymerViscosityCorrection()); } // Note. Efficiency factor is handled in the output layer - well_state.perfRatePolymer()[first_perf_ + perf] = cq_s_poly.value(); + auto * perf_rate_polymer = &well_state.perfRatePolymer()[first_perf_]; + perf_rate_polymer[perf] = cq_s_poly.value(); cq_s_poly *= well_efficiency_factor_; connectionRates[perf][contiPolymerEqIdx] = Base::restrictEval(cq_s_poly); diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 258f6c712..ab348c948 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -788,7 +788,8 @@ void WellState::reportConnections(data::Well& well, comp.rates.set( pi [ i ], *(connPI + i) ); } if ( pu.has_polymer ) { - comp.rates.set( rt::polymer, this->perfRatePolymer()[wt.second[1] + local_comp_index]); + const auto * perf_polymer_rate = &this->perfRatePolymer()[wt.second[1]]; + comp.rates.set( rt::polymer, perf_polymer_rate[local_comp_index]); } if ( pu.has_brine ) { comp.rates.set( rt::brine, this->perfRateBrine()[wt.second[1] + local_comp_index]); @@ -1017,8 +1018,8 @@ double WellState::solventWellRate(const int w) const double WellState::polymerWellRate(const int w) const { - return parallel_well_info_[w]->sumPerfValues(&perfRatePolymer_[0] + first_perf_index_[w], - &perfRatePolymer_[0] + first_perf_index_[w] + num_perf_[w]); + const auto * perf_rates_polymer = &perfRatePolymer_[first_perf_index_[w]]; + return parallel_well_info_[w]->sumPerfValues(perf_rates_polymer, perf_rates_polymer + this->num_perf_[w]); } double WellState::brineWellRate(const int w) const