make sure wells has valid controls

This commit is contained in:
Tor Harald Sandve 2021-02-26 08:15:01 +01:00
parent d78f5dc259
commit f861188d60
2 changed files with 12 additions and 26 deletions

View File

@ -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 <nw; ++w) {
const auto& well = wells_ecl_[w];
const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
+ ScheduleEvents::PRODUCTION_UPDATE
+ ScheduleEvents::INJECTION_UPDATE
+ ScheduleEvents::NEW_WELL;
if(!schedule()[timeStepIdx].wellgroup_events().hasEvent(well.name(), effective_events_mask))
continue;
if (well.isProducer()) {
const auto controls = well.productionControls(summaryState);
well_state_.currentProductionControls()[w] = controls.cmode;
}
else {
const auto controls = well.injectionControls(summaryState);
well_state_.currentInjectionControls()[w] = controls.cmode;
}
}
const Group& fieldGroup = schedule().getGroup("FIELD", timeStepIdx);
WellGroupHelpers::setCmodeGroup(fieldGroup, schedule(), summaryState, timeStepIdx, well_state_);

View File

@ -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);
@ -207,12 +217,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<np; ++i, ++idx, ++oldidx )