check group constraints from top

This commit is contained in:
Tor Harald Sandve 2022-09-29 09:22:56 +02:00
parent eb0a516ff0
commit 54e0496203
4 changed files with 40 additions and 58 deletions

View File

@ -288,6 +288,11 @@ namespace Opm {
const int iterationIdx,
DeferredLogger& deferred_logger);
bool updateGroupControls(const Group& group,
DeferredLogger& deferred_logger,
const int reportStepIdx,
const int iterationIdx);
WellInterfacePtr getWell(const std::string& well_name) const;
bool hasWell(const std::string& well_name) const;

View File

@ -1270,12 +1270,6 @@ checkGroupHigherConstraints(const Group& group,
}
// call recursively down the group hiearchy
for (const std::string& groupName : group.groups()) {
bool changed_this = checkGroupHigherConstraints( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx);
changed = changed || changed_this;
}
return changed;
}
@ -1315,41 +1309,9 @@ updateGroupIndividualControl(const Group& group,
}
}
// call recursively down the group hiearchy
for (const std::string& groupName : group.groups()) {
bool changed_this = updateGroupIndividualControl( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx);
changed = changed || changed_this;
}
return changed;
}
bool
BlackoilWellModelGeneric::
updateGroupIndividualControls(DeferredLogger& deferred_logger,
const int reportStepIdx,
const int iterationIdx)
{
const int nupcol = schedule()[reportStepIdx].nupcol();
// don't switch group control when iterationIdx > nupcol
// to avoid oscilations between group controls
if (iterationIdx > nupcol)
return false;
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
return updateGroupIndividualControl(fieldGroup, deferred_logger,
reportStepIdx);
}
bool
BlackoilWellModelGeneric::
updateGroupHigherControls(DeferredLogger& deferred_logger,
const int reportStepIdx)
{
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
return checkGroupHigherConstraints(fieldGroup, deferred_logger, reportStepIdx);
}
void
BlackoilWellModelGeneric::
actionOnBrokenConstraints(const Group& group,

View File

@ -343,13 +343,6 @@ protected:
DeferredLogger& deferred_logger,
const int reportStepIdx);
bool updateGroupIndividualControls(DeferredLogger& deferred_logger,
const int reportStepIdx,
const int iterationIdx);
bool updateGroupHigherControls(DeferredLogger& deferred_logger,
const int reportStepIdx);
void actionOnBrokenConstraints(const Group& group,
const Group::ExceedAction& exceed_action,
const Group::ProductionCMode& newControl,

View File

@ -1452,20 +1452,15 @@ namespace Opm {
std::set<std::string> switched_wells;
if (checkGroupControls) {
// Check group individual constraints.
bool changed_individual = updateGroupIndividualControls(deferred_logger,
episodeIdx, iterationIdx);
if (changed_individual)
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
// Check group's constraints from higher levels.
bool changed_higher = updateGroupHigherControls(deferred_logger,
episodeIdx);
if (changed_higher)
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
const int nupcol = schedule()[episodeIdx].nupcol();
// don't switch group control when iterationIdx > nupcol
// to avoid oscilations between group controls
if (iterationIdx <= nupcol) {
const Group& fieldGroup = schedule().getGroup("FIELD", episodeIdx);
updateGroupControls(fieldGroup, deferred_logger, episodeIdx, iterationIdx);
}
// Check wells' group constraints and communicate.
bool changed_well_group = false;
for (const auto& well : well_container_) {
@ -1518,6 +1513,33 @@ namespace Opm {
updateAndCommunicateGroupData(reportStepIdx, iterationIdx);
}
template<typename TypeTag>
bool
BlackoilWellModel<TypeTag>::
updateGroupControls(const Group& group,
DeferredLogger& deferred_logger,
const int reportStepIdx,
const int iterationIdx)
{
bool changed = false;
bool changed_hc = checkGroupHigherConstraints( group, deferred_logger, reportStepIdx);
if (changed_hc) {
changed = true;
updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
}
bool changed_individual = updateGroupIndividualControl( group, deferred_logger, reportStepIdx);
if (changed_individual) {
changed = true;
updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
}
// call recursively down the group hierarchy
for (const std::string& groupName : group.groups()) {
bool changed_this = updateGroupControls( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx,iterationIdx);
changed = changed || changed_this;
}
return changed;
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::