mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
cleanup group switching output to terminal
This commit is contained in:
@@ -1172,8 +1172,7 @@ bool
|
||||
BlackoilWellModelGeneric::
|
||||
checkGroupHigherConstraints(const Group& group,
|
||||
DeferredLogger& deferred_logger,
|
||||
const int reportStepIdx,
|
||||
std::set<std::string>& switched_groups)
|
||||
const int reportStepIdx)
|
||||
{
|
||||
// Set up coefficients for RESV <-> surface rate conversion.
|
||||
// Use the pvtRegionIdx from the top cell of the first well.
|
||||
@@ -1203,9 +1202,8 @@ checkGroupHigherConstraints(const Group& group,
|
||||
|
||||
std::vector<double> rates(phase_usage_.num_phases, 0.0);
|
||||
|
||||
const bool skip = switched_groups.count(group.name()) || group.name() == "FIELD";
|
||||
|
||||
if (!skip && group.isInjectionGroup()) {
|
||||
bool isField = group.name() == "FIELD";
|
||||
if (!isField && group.isInjectionGroup()) {
|
||||
// Obtain rates for group.
|
||||
std::vector<double> resv_coeff_inj(phase_usage_.num_phases, 0.0);
|
||||
calcInjRates(fipnum, pvtreg, resv_coeff_inj);
|
||||
@@ -1217,11 +1215,13 @@ checkGroupHigherConstraints(const Group& group,
|
||||
}
|
||||
const Phase all[] = { Phase::WATER, Phase::OIL, Phase::GAS };
|
||||
for (Phase phase : all) {
|
||||
// Check higher up only if under individual (not FLD) control.
|
||||
auto currentControl = this->groupState().injection_control(group.name(), phase);
|
||||
if (currentControl != Group::InjectionCMode::FLD && group.injectionGroupControlAvailable(phase)) {
|
||||
const Group& parentGroup = schedule().getGroup(group.parent(), reportStepIdx);
|
||||
const std::pair<bool, double> changed_this = WellGroupHelpers::checkGroupConstraintsInj(
|
||||
const bool skip = switched_inj_groups_.count({group.name(), phase});
|
||||
if (!skip) {
|
||||
// Check higher up only if under individual (not FLD) control.
|
||||
auto currentControl = this->groupState().injection_control(group.name(), phase);
|
||||
if (currentControl != Group::InjectionCMode::FLD && group.injectionGroupControlAvailable(phase)) {
|
||||
const Group& parentGroup = schedule().getGroup(group.parent(), reportStepIdx);
|
||||
const std::pair<bool, double> changed_this = WellGroupHelpers::checkGroupConstraintsInj(
|
||||
group.name(),
|
||||
group.parent(),
|
||||
parentGroup,
|
||||
@@ -1237,27 +1237,30 @@ checkGroupHigherConstraints(const Group& group,
|
||||
summaryState_,
|
||||
resv_coeff_inj,
|
||||
deferred_logger);
|
||||
if (changed_this.first) {
|
||||
switched_groups.insert(group.name());
|
||||
actionOnBrokenConstraints(group, Group::InjectionCMode::FLD, phase, deferred_logger);
|
||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ true, this->groupState(), this->wellState());
|
||||
changed = true;
|
||||
if (changed_this.first) {
|
||||
switched_inj_groups_.insert({ {group.name(), phase}, Group::InjectionCMode2String(Group::InjectionCMode::FLD)});
|
||||
actionOnBrokenConstraints(group, Group::InjectionCMode::FLD, phase, deferred_logger);
|
||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ true, this->groupState(), this->wellState());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip && group.isProductionGroup()) {
|
||||
if (!isField && group.isProductionGroup()) {
|
||||
// Obtain rates for group.
|
||||
for (int phasePos = 0; phasePos < phase_usage_.num_phases; ++phasePos) {
|
||||
const double local_current_rate = WellGroupHelpers::sumWellSurfaceRates(group, schedule(), this->wellState(), reportStepIdx, phasePos, /* isInjector */ false);
|
||||
// Sum over all processes
|
||||
rates[phasePos] = -comm_.sum(local_current_rate);
|
||||
}
|
||||
std::vector<double> resv_coeff(phase_usage_.num_phases, 0.0);
|
||||
calcRates(fipnum, pvtreg, resv_coeff);
|
||||
// Check higher up only if under individual (not FLD) control.
|
||||
const Group::ProductionCMode& currentControl = this->groupState().production_control(group.name());
|
||||
const bool skip = switched_prod_groups_.count(group.name());
|
||||
if (!skip) {
|
||||
for (int phasePos = 0; phasePos < phase_usage_.num_phases; ++phasePos) {
|
||||
const double local_current_rate = WellGroupHelpers::sumWellSurfaceRates(group, schedule(), this->wellState(), reportStepIdx, phasePos, /* isInjector */ false);
|
||||
// Sum over all processes
|
||||
rates[phasePos] = -comm_.sum(local_current_rate);
|
||||
}
|
||||
std::vector<double> resv_coeff(phase_usage_.num_phases, 0.0);
|
||||
calcRates(fipnum, pvtreg, resv_coeff);
|
||||
// Check higher up only if under individual (not FLD) control.
|
||||
const Group::ProductionCMode& currentControl = this->groupState().production_control(group.name());
|
||||
if (currentControl != Group::ProductionCMode::FLD && group.productionGroupControlAvailable()) {
|
||||
const Group& parentGroup = schedule().getGroup(group.parent(), reportStepIdx);
|
||||
const std::pair<bool, double> changed_this = WellGroupHelpers::checkGroupConstraintsProd(
|
||||
@@ -1276,18 +1279,19 @@ checkGroupHigherConstraints(const Group& group,
|
||||
resv_coeff,
|
||||
deferred_logger);
|
||||
if (changed_this.first) {
|
||||
switched_groups.insert(group.name());
|
||||
switched_prod_groups_.insert({group.name(), Group::ProductionCMode2String(Group::ProductionCMode::FLD)});
|
||||
const auto exceed_action = group.productionControls(summaryState_).exceed_action;
|
||||
actionOnBrokenConstraints(group, exceed_action, Group::ProductionCMode::FLD, deferred_logger);
|
||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// call recursively down the group hiearchy
|
||||
for (const std::string& groupName : group.groups()) {
|
||||
bool changed_this = checkGroupHigherConstraints( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx, switched_groups);
|
||||
bool changed_this = checkGroupHigherConstraints( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx);
|
||||
changed = changed || changed_this;
|
||||
}
|
||||
|
||||
@@ -1298,43 +1302,49 @@ bool
|
||||
BlackoilWellModelGeneric::
|
||||
updateGroupIndividualControl(const Group& group,
|
||||
DeferredLogger& deferred_logger,
|
||||
const int reportStepIdx,
|
||||
std::set<std::string>& switched_groups)
|
||||
const int reportStepIdx)
|
||||
{
|
||||
bool changed = false;
|
||||
const bool skip = switched_groups.count(group.name());
|
||||
if (!skip && group.isInjectionGroup())
|
||||
if (group.isInjectionGroup())
|
||||
{
|
||||
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
|
||||
for (Phase phase : all) {
|
||||
if (!group.hasInjectionControl(phase)) {
|
||||
continue;
|
||||
}
|
||||
const bool skip = switched_inj_groups_.count({group.name(), phase});
|
||||
if (skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& changed_this = checkGroupInjectionConstraints(group, reportStepIdx, phase);
|
||||
if (changed_this.first != Group::InjectionCMode::NONE)
|
||||
{
|
||||
switched_groups.insert(group.name());
|
||||
switched_inj_groups_.insert({{group.name(), phase}, Group::InjectionCMode2String(changed_this.first)});
|
||||
actionOnBrokenConstraints(group, changed_this.first, phase, deferred_logger);
|
||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!skip && group.isProductionGroup()) {
|
||||
const auto& changed_this = checkGroupProductionConstraints(group, reportStepIdx, deferred_logger);
|
||||
const auto controls = group.productionControls(summaryState_);
|
||||
if (changed_this.first != Group::ProductionCMode::NONE)
|
||||
{
|
||||
switched_groups.insert(group.name());
|
||||
actionOnBrokenConstraints(group, controls.exceed_action, changed_this.first, deferred_logger);
|
||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState());
|
||||
changed = true;
|
||||
if (group.isProductionGroup()) {
|
||||
const bool skip = switched_prod_groups_.count(group.name());
|
||||
if (!skip) {
|
||||
const auto& changed_this = checkGroupProductionConstraints(group, reportStepIdx, deferred_logger);
|
||||
const auto controls = group.productionControls(summaryState_);
|
||||
if (changed_this.first != Group::ProductionCMode::NONE)
|
||||
{
|
||||
switched_prod_groups_.insert({group.name(), Group::ProductionCMode2String(changed_this.first)});
|
||||
actionOnBrokenConstraints(group, controls.exceed_action, changed_this.first, deferred_logger);
|
||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// call recursively down the group hiearchy
|
||||
for (const std::string& groupName : group.groups()) {
|
||||
bool changed_this = updateGroupIndividualControl( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx, switched_groups);
|
||||
bool changed_this = updateGroupIndividualControl( schedule().getGroup(groupName, reportStepIdx), deferred_logger, reportStepIdx);
|
||||
changed = changed || changed_this;
|
||||
}
|
||||
|
||||
@@ -1344,7 +1354,6 @@ updateGroupIndividualControl(const Group& group,
|
||||
bool
|
||||
BlackoilWellModelGeneric::
|
||||
updateGroupIndividualControls(DeferredLogger& deferred_logger,
|
||||
std::set<std::string>& switched_groups,
|
||||
const int reportStepIdx,
|
||||
const int iterationIdx)
|
||||
{
|
||||
@@ -1356,17 +1365,16 @@ updateGroupIndividualControls(DeferredLogger& deferred_logger,
|
||||
|
||||
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
|
||||
return updateGroupIndividualControl(fieldGroup, deferred_logger,
|
||||
reportStepIdx, switched_groups);
|
||||
reportStepIdx);
|
||||
}
|
||||
|
||||
bool
|
||||
BlackoilWellModelGeneric::
|
||||
updateGroupHigherControls(DeferredLogger& deferred_logger,
|
||||
const int reportStepIdx,
|
||||
std::set<std::string>& switched_groups)
|
||||
const int reportStepIdx)
|
||||
{
|
||||
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
|
||||
return checkGroupHigherConstraints(fieldGroup, deferred_logger, reportStepIdx, switched_groups);
|
||||
return checkGroupHigherConstraints(fieldGroup, deferred_logger, reportStepIdx);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1418,7 +1426,7 @@ actionOnBrokenConstraints(const Group& group,
|
||||
|
||||
Parallel::Communication cc = comm_;
|
||||
if (!ss.str().empty() && cc.rank() == 0)
|
||||
deferred_logger.info(ss.str());
|
||||
deferred_logger.debug(ss.str());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user