From d95eb32510481f4fd40fb752338a99f1553ffd47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 7 Feb 2020 19:08:14 +0100 Subject: [PATCH] Save and Restore Well's Current Control Target Mode This commit uses the new restart file support for active well control target modes to save and restore the run's active targets. --- opm/simulators/wells/BlackoilWellModel.hpp | 15 ++++++++++- .../wells/BlackoilWellModel_impl.hpp | 26 +++++-------------- .../wells/WellStateFullyImplicitBlackoil.hpp | 7 +++++ 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index 27f02b53d..1e89e70c9 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -213,7 +213,20 @@ namespace Opm { } Opm::data::Wells wellData() const - { return well_state_.report(phase_usage_, Opm::UgGridHelpers::globalCell(grid())); } + { + auto wsrpt = well_state_.report(phase_usage_, Opm::UgGridHelpers::globalCell(grid())); + + for (const auto& well : this->wells_ecl_) { + auto xwPos = wsrpt.find(well.name()); + if (xwPos == wsrpt.end()) { // No well results. Unexpected. + continue; + } + + xwPos->second.current_control.isProducer = well.isProducer(); + } + + return wsrpt; + } // substract Binv(D)rw from r; void apply( BVector& r) const; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 00e293339..7e43190a4 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -543,24 +543,6 @@ namespace Opm { wellsToState(restartValues.wells, phaseUsage, handle_ms_well, well_state_); } - // for ecl compatible restart the current controls are not written - const auto& ioCfg = eclState().getIOConfig(); - const auto ecl_compatible_rst = ioCfg.getEclCompatibleRST(); - if (true || ecl_compatible_rst) { // always set the control from the schedule - for (int w = 0; w (well.injectionControl); - //state.currentProductionControls()[ well_index ] = static_cast(well.productionControl); + if (well.current_control.isProducer) { + state.currentProductionControls()[ well_index ] = well.current_control.prod; + } + else { + state.currentInjectionControls()[ well_index ] = well.current_control.inj; + } const auto wellrate_index = well_index * np; for( size_t i = 0; i < phs.size(); ++i ) { diff --git a/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp b/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp index e1ec6c1c9..d432e0bc1 100644 --- a/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp +++ b/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp @@ -515,6 +515,13 @@ namespace Opm well.rates.set( rt::dissolved_gas, this->well_dissolved_gas_rates_[w] ); well.rates.set( rt::vaporized_oil, this->well_vaporized_oil_rates_[w] ); + { + auto& curr = well.current_control; + + curr.prod = this->currentProductionControls()[w]; + curr.inj = this->currentInjectionControls() [w]; + } + size_t local_comp_index = 0; for( auto& comp : well.connections) { const auto rates = this->perfPhaseRates().begin()