From 89a712603f5fe98ac5343f98283b4fed05fcb69e Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 21 May 2021 11:56:33 +0200 Subject: [PATCH] Use well index for misc perforation data --- opm/simulators/wells/StandardWell_impl.hpp | 12 ++++++++---- opm/simulators/wells/WellState.cpp | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 2a6033ddd..f34ec15c8 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -1304,9 +1304,11 @@ namespace Opm // other primary variables related to polymer injectivity study if constexpr (Base::has_polymermw) { if (this->isInjector()) { + auto * perf_water_velocity = &well_state.perfWaterVelocity()[this->first_perf_]; + auto * perf_skin_pressure = &well_state.perfSkinPressure()[this->first_perf_]; for (int perf = 0; perf < number_of_perforations_; ++perf) { - well_state.perfWaterVelocity()[first_perf_ + perf] = primary_variables_[Bhp + 1 + perf]; - well_state.perfSkinPressure()[first_perf_ + perf] = primary_variables_[Bhp + 1 + number_of_perforations_ + perf]; + perf_water_velocity[perf] = primary_variables_[Bhp + 1 + perf]; + perf_skin_pressure[perf] = primary_variables_[Bhp + 1 + number_of_perforations_ + perf]; } } } @@ -2809,9 +2811,11 @@ namespace Opm // other primary variables related to polymer injection if constexpr (Base::has_polymermw) { if (this->isInjector()) { + const auto * water_velocity = &well_state.perfWaterVelocity()[first_perf_]; + const auto * skin_pressure = &well_state.perfSkinPressure()[first_perf_]; for (int perf = 0; perf < number_of_perforations_; ++perf) { - primary_variables_[Bhp + 1 + perf] = well_state.perfWaterVelocity()[first_perf_ + perf]; - primary_variables_[Bhp + 1 + number_of_perforations_ + perf] = well_state.perfSkinPressure()[first_perf_ + perf]; + primary_variables_[Bhp + 1 + perf] = water_velocity[perf]; + primary_variables_[Bhp + 1 + number_of_perforations_ + perf] = skin_pressure[perf]; } } } diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 452de91da..8e9fcd868 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -478,12 +478,19 @@ void WellState::init(const std::vector& cellPressures, if (pu.has_polymermw) { if (global_num_perf_same) { - int oldPerf_idx = oldPerf_idx_beg; - for (int perf = connpos; perf < connpos + num_perf_this_well; ++perf, ++oldPerf_idx ) + auto * throughput_target = &perf_water_throughput_[connpos]; + auto * pressure_target = &perf_skin_pressure_[connpos]; + auto * velocity_target = &perf_water_velocity_[connpos]; + + const auto * throughput_src = &prevState->perfThroughput()[oldPerf_idx_beg]; + const auto * pressure_src = &prevState->perfSkinPressure()[oldPerf_idx_beg]; + const auto * velocity_src = &prevState->perfWaterVelocity()[oldPerf_idx_beg]; + + for (int perf = 0; perf < num_perf_this_well; ++perf) { - perf_water_throughput_[ perf ] = prevState->perfThroughput()[ oldPerf_idx ]; - perf_skin_pressure_[ perf ] = prevState->perfSkinPressure()[ oldPerf_idx ]; - perf_water_velocity_[ perf ] = prevState->perfWaterVelocity()[ oldPerf_idx ]; + throughput_target[ perf ] = throughput_src[perf]; + pressure_target[ perf ] = pressure_src[perf]; + velocity_target[ perf ] = velocity_src[perf]; } } }