Skip to content

Commit a65cd3a

Browse files
author
Tor Harald Sandve
committed
Fix issues related to commiting wellstate after 1 iteration
These changes should be merged seperatly
1 parent dfd6716 commit a65cd3a

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

opm/simulators/wells/BlackoilWellModelConstraints.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,14 @@ updateGroupIndividualControl(const Group& group,
606606
if (group_is_oscillating) {
607607
continue;
608608
}
609-
609+
const auto currentControl = wellModel_.groupState().injection_control(group.name(), phase);
610610
const auto& changed_this = this->checkGroupInjectionConstraints(group,
611611
reportStepIdx,
612612
phase);
613613
if (changed_this.first != Group::InjectionCMode::NONE)
614614
{
615615
switched_inj[group.name()][static_cast<std::underlying_type_t<Phase>>(phase)].push_back(
616-
changed_this.first);
616+
currentControl);
617617

618618
this->actionOnBrokenConstraints(group, changed_this.first, phase,
619619
group_state, deferred_logger);
@@ -658,6 +658,7 @@ updateGroupIndividualControl(const Group& group,
658658

659659
if (changed_this.first != Group::ProductionCMode::NONE)
660660
{
661+
const auto currentControl = wellModel_.groupState().production_control(group.name());
661662
std::optional<std::string> worst_offending_well = std::nullopt;
662663
changed = this->actionOnBrokenConstraints(group, reportStepIdx,
663664
controls.group_limit_action,
@@ -666,7 +667,7 @@ updateGroupIndividualControl(const Group& group,
666667
group_state, deferred_logger);
667668

668669
if(changed) {
669-
switched_prod[group.name()].push_back(changed_this.first);
670+
switched_prod[group.name()].push_back(currentControl);
670671
WellGroupHelpers<Scalar>::updateWellRatesFromGroupTargetScale(changed_this.second,
671672
group,
672673
wellModel_.schedule(),

opm/simulators/wells/BlackoilWellModelGeneric.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ checkGroupHigherConstraints(const Group& group,
697697
resv_coeff_inj,
698698
deferred_logger);
699699
if (is_changed) {
700-
switched_inj_groups_[group.name()][static_cast<std::underlying_type_t<Phase>>(phase)].push_back(Group::InjectionCMode::FLD);
700+
switched_inj_groups_[group.name()][static_cast<std::underlying_type_t<Phase>>(phase)].push_back(currentControl);
701701
BlackoilWellModelConstraints(*this).
702702
actionOnBrokenConstraints(group, Group::InjectionCMode::FLD,
703703
phase, this->groupState(),
@@ -784,7 +784,7 @@ checkGroupHigherConstraints(const Group& group,
784784
deferred_logger);
785785

786786
if (changed) {
787-
switched_prod_groups_[group.name()].push_back(Group::ProductionCMode::FLD);
787+
switched_prod_groups_[group.name()].push_back(currentControl);
788788
WellGroupHelpers<Scalar>::updateWellRatesFromGroupTargetScale(scaling_factor,
789789
group,
790790
schedule(),
@@ -1388,7 +1388,7 @@ updateAndCommunicateGroupData(const int reportStepIdx,
13881388
WellGroupHelpers<Scalar>::updateWellRates(fieldGroup,
13891389
schedule(),
13901390
reportStepIdx,
1391-
this->prevWellState(),
1391+
well_state_nupcol,
13921392
well_state);
13931393

13941394
// Set ALQ for off-process wells to zero
@@ -2033,36 +2033,36 @@ void BlackoilWellModelGeneric<Scalar>::
20332033
reportGroupSwitching(DeferredLogger& local_deferredLogger) const
20342034
{
20352035
for (const auto& [name, ctrls] : this->switched_prod_groups_) {
2036-
const Group::ProductionCMode& oldControl =
2037-
this->prevWGState().group_state.production_control(name);
2038-
if (ctrls.back() != oldControl) {
2036+
const Group::ProductionCMode& newControl =
2037+
this->groupState().production_control(name);
2038+
if (ctrls[0] != newControl) {
20392039
const std::string msg =
20402040
fmt::format(" Production Group {} control model changed from {} to {}",
20412041
name,
2042-
Group::ProductionCMode2String(oldControl),
2043-
Group::ProductionCMode2String(ctrls.back()));
2042+
Group::ProductionCMode2String(ctrls[0]),
2043+
Group::ProductionCMode2String(newControl));
20442044
local_deferredLogger.info(msg);
20452045
}
20462046
}
20472047
for (const auto& [grname, grdata] : this->switched_inj_groups_) {
20482048
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
20492049
for (Phase phase : all) {
2050-
if (!this->prevWGState().group_state.has_injection_control(grname, phase)) {
2050+
if (!this->groupState().has_injection_control(grname, phase)) {
20512051
continue;
20522052
}
20532053
const auto& ctrls = grdata[static_cast<std::underlying_type_t<Phase>>(phase)];
20542054
if (ctrls.empty()) {
20552055
continue;
20562056
}
20572057

2058-
const Group::InjectionCMode& oldControl =
2059-
this->prevWGState().group_state.injection_control(grname, phase);
2060-
if (ctrls.back() != oldControl) {
2058+
const Group::InjectionCMode& newControl =
2059+
this->groupState().injection_control(grname, phase);
2060+
if (ctrls[0] != newControl) {
20612061
const std::string msg =
20622062
fmt::format(" Injection Group {} control model changed from {} to {}",
20632063
grname,
2064-
Group::InjectionCMode2String(oldControl),
2065-
Group::InjectionCMode2String(ctrls.back()));
2064+
Group::InjectionCMode2String(ctrls[0]),
2065+
Group::InjectionCMode2String(newControl));
20662066
local_deferredLogger.info(msg);
20672067
}
20682068
}

0 commit comments

Comments
 (0)