diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 5977b903e..b857af135 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -271,26 +271,6 @@ namespace Opm { well_state_.initWellStateMSWell(wells_ecl_, phase_usage_, &previous_well_state_); } - const int nw = wells_ecl_.size(); - for (int w = 0; w name(), effective_events_mask); diff --git a/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp b/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp index cb5590cae..e9ede1547 100644 --- a/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp +++ b/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp @@ -167,6 +167,16 @@ namespace Opm current_injection_controls_.resize(nw); current_production_controls_.resize(nw); + for (int w = 0; w < nw; ++w) { + if (wells_ecl[w].isProducer()) { + const auto controls = wells_ecl[w].productionControls(summary_state); + currentProductionControls()[w] = controls.cmode; + } + else { + const auto controls = wells_ecl[w].injectionControls(summary_state); + currentInjectionControls()[w] = controls.cmode; + } + } perfRateSolvent_.clear(); perfRateSolvent_.resize(nperf, 0.0); @@ -196,6 +206,11 @@ namespace Opm continue; } + if (is_producer_[newIndex] != prevState->is_producer_[oldIndex]) { + // Well changed to/from injector from/to producer, do not use its privious values. + continue; + } + // bhp bhp()[ newIndex ] = prevState->bhp()[ oldIndex ]; @@ -207,12 +222,8 @@ namespace Opm // continue; //} - // if there is no effective control event happens to the well, we use the current_injection/production_controls_ from prevState - // otherwise, we use the control specified in the deck - if (!effective_events_occurred_[w]) { - current_injection_controls_[ newIndex ] = prevState->currentInjectionControls()[ oldIndex ]; - current_production_controls_[ newIndex ] = prevState->currentProductionControls()[ oldIndex ]; - } + current_injection_controls_[ newIndex ] = prevState->currentInjectionControls()[ oldIndex ]; + current_production_controls_[ newIndex ] = prevState->currentProductionControls()[ oldIndex ]; // wellrates for( int i=0, idx=newIndex*np, oldidx=oldIndex*np; i