From 6220cdf6135a25e43b671175ddfced8ad9a6f9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 28 Aug 2020 08:41:48 +0200 Subject: [PATCH] Restore Groups' Active Constraints on Restart First step towards better restarts of models with group control. --- opm/simulators/wells/BlackoilWellModel.hpp | 1 + .../wells/BlackoilWellModel_impl.hpp | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index 49cf2e805..b02764dc6 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -414,6 +414,7 @@ namespace Opm { // convert well data from opm-common to well state from opm-core void wellsToState( const data::Wells& wells, + const data::GroupValues& groupValues, const PhaseUsage& phases, const bool handle_ms_well, WellStateFullyImplicitBlackoil& state ) const; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index ce498a1b0..8d25e5df1 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -547,7 +547,7 @@ namespace Opm { const size_t numCells = Opm::UgGridHelpers::numCells(grid()); const bool handle_ms_well = (param_.use_multisegment_well_ && anyMSWellOpenLocal()); well_state_.resize(wells_ecl_, schedule(), handle_ms_well, numCells, phaseUsage, well_perf_data_, summaryState, globalNumWells); // Resize for restart step - wellsToState(restartValues.wells, phaseUsage, handle_ms_well, well_state_); + wellsToState(restartValues.wells, restartValues.groups, phaseUsage, handle_ms_well, well_state_); } previous_well_state_ = well_state_; @@ -1599,10 +1599,13 @@ namespace Opm { void BlackoilWellModel:: wellsToState( const data::Wells& wells, + const data::GroupValues& groupValues, const PhaseUsage& phases, const bool handle_ms_well, WellStateFullyImplicitBlackoil& state) const { + using GPMode = Group::ProductionCMode; + using GIMode = Group::InjectionCMode; using rt = data::Rates::opt; const auto np = phases.num_phases; @@ -1692,6 +1695,24 @@ namespace Opm { } } } + + for (const auto& [group, value] : groupValues) { + const auto cpc = value.currentControl.currentProdConstraint; + const auto cgi = value.currentControl.currentGasInjectionConstraint; + const auto cwi = value.currentControl.currentWaterInjectionConstraint; + + if (cpc != GPMode::NONE) { + state.setCurrentProductionGroupControl(group, cpc); + } + + if (cgi != GIMode::NONE) { + state.setCurrentInjectionGroupControl(Phase::GAS, group, cgi); + } + + if (cwi != GIMode::NONE) { + state.setCurrentInjectionGroupControl(Phase::WATER, group, cwi); + } + } }