diff --git a/opm/simulators/wells/StandardWellPrimaryVariables.cpp b/opm/simulators/wells/StandardWellPrimaryVariables.cpp index 6171bdb5f..688a43d53 100644 --- a/opm/simulators/wells/StandardWellPrimaryVariables.cpp +++ b/opm/simulators/wells/StandardWellPrimaryVariables.cpp @@ -222,19 +222,16 @@ update(const WellState& well_state, DeferredLogger& deferred_logger) template void StandardWellPrimaryVariables:: -updatePolyMW(const BVectorWell& dwells) +updatePolyMW(const WellState& well_state) { if (well_.isInjector()) { + const auto& ws = well_state.well(well_.indexOfWell()); + const auto& perf_data = ws.perf_data; + const auto& water_velocity = perf_data.water_velocity; + const auto& skin_pressure = perf_data.skin_pressure; for (int perf = 0; perf < well_.numPerfs(); ++perf) { - const int wat_vel_index = Bhp + 1 + perf; - const int pskin_index = Bhp + 1 + well_.numPerfs() + perf; - - const double relaxation_factor = 0.9; - const double dx_wat_vel = dwells[0][wat_vel_index]; - value_[wat_vel_index] -= relaxation_factor * dx_wat_vel; - - const double dx_pskin = dwells[0][pskin_index]; - value_[pskin_index] -= relaxation_factor * dx_pskin; + value_[Bhp + 1 + perf] = water_velocity[perf]; + value_[Bhp + 1 + well_.numPerfs() + perf] = skin_pressure[perf]; } } } @@ -286,6 +283,25 @@ updateNewton(const BVectorWell& dwells, value_[Bhp] = std::max(value_[Bhp] - dx1_limited, 1e5); } +template +void StandardWellPrimaryVariables:: +updateNewtonPolyMW(const BVectorWell& dwells) +{ + if (well_.isInjector()) { + for (int perf = 0; perf < well_.numPerfs(); ++perf) { + const int wat_vel_index = Bhp + 1 + perf; + const int pskin_index = Bhp + 1 + well_.numPerfs() + perf; + + const double relaxation_factor = 0.9; + const double dx_wat_vel = dwells[0][wat_vel_index]; + value_[wat_vel_index] -= relaxation_factor * dx_wat_vel; + + const double dx_pskin = dwells[0][pskin_index]; + value_[pskin_index] -= relaxation_factor * dx_pskin; + } + } +} + template void StandardWellPrimaryVariables:: copyToWellState(WellState& well_state, diff --git a/opm/simulators/wells/StandardWellPrimaryVariables.hpp b/opm/simulators/wells/StandardWellPrimaryVariables.hpp index 9e576ae1c..72f78bfbf 100644 --- a/opm/simulators/wells/StandardWellPrimaryVariables.hpp +++ b/opm/simulators/wells/StandardWellPrimaryVariables.hpp @@ -111,13 +111,16 @@ public: //! \brief Copy values from well state. void update(const WellState& well_state, DeferredLogger& deferred_logger); + //! \brief Copy polymer molecular weigt values from well state. + void updatePolyMW(const WellState& well_state); + //! \brief Update values from newton update vector. void updateNewton(const BVectorWell& dwells, const double dFLimit, const double dBHPLimit); //! \brief Update polymer molecular weight values from newton update vector. - void updatePolyMW(const BVectorWell& dwells); + void updateNewtonPolyMW(const BVectorWell& dwells); //! \brief Copy values to well state. void copyToWellState(WellState& well_state, DeferredLogger& deferred_logger) const; diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 06323e027..b0a11720d 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -979,7 +979,7 @@ namespace Opm { // for the water velocity and skin pressure if constexpr (Base::has_polymermw) { - this->primary_variables_.updatePolyMW(dwells); + this->primary_variables_.updateNewtonPolyMW(dwells); } } @@ -2036,16 +2036,7 @@ namespace Opm // other primary variables related to polymer injection if constexpr (Base::has_polymermw) { - if (this->isInjector()) { - const auto& ws = well_state.well(this->index_of_well_); - const auto& perf_data = ws.perf_data; - const auto& water_velocity = perf_data.water_velocity; - const auto& skin_pressure = perf_data.skin_pressure; - for (int perf = 0; perf < this->number_of_perforations_; ++perf) { - this->primary_variables_.value_[Bhp + 1 + perf] = water_velocity[perf]; - this->primary_variables_.value_[Bhp + 1 + this->number_of_perforations_ + perf] = skin_pressure[perf]; - } - } + this->primary_variables_.updatePolyMW(well_state); } for (double v : this->primary_variables_.value_) { if(!isfinite(v))