mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move updateGroupIndividualControl into BlackoilWellModelConstraints
This commit is contained in:
@@ -448,4 +448,69 @@ actionOnBrokenConstraints(const Group& group,
|
|||||||
deferred_logger.debug(ss.str());
|
deferred_logger.debug(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BlackoilWellModelConstraints::
|
||||||
|
updateGroupIndividualControl(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
std::map<std::pair<std::string,Opm::Phase>,std::string>& switched_inj,
|
||||||
|
std::map<std::string, std::string>& switched_prod,
|
||||||
|
GroupState& group_state,
|
||||||
|
WellState& well_state,
|
||||||
|
DeferredLogger& deferred_logger) const
|
||||||
|
{
|
||||||
|
bool changed = false;
|
||||||
|
if (group.isInjectionGroup())
|
||||||
|
{
|
||||||
|
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
|
||||||
|
for (Phase phase : all) {
|
||||||
|
if (!group.hasInjectionControl(phase)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto& changed_this = this->checkGroupInjectionConstraints(group,
|
||||||
|
reportStepIdx,
|
||||||
|
phase);
|
||||||
|
if (changed_this.first != Group::InjectionCMode::NONE)
|
||||||
|
{
|
||||||
|
switched_inj.insert({{group.name(), phase},
|
||||||
|
Group::InjectionCMode2String(changed_this.first)});
|
||||||
|
this->actionOnBrokenConstraints(group, changed_this.first, phase,
|
||||||
|
group_state, deferred_logger);
|
||||||
|
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second,
|
||||||
|
group,
|
||||||
|
wellModel_.schedule(),
|
||||||
|
reportStepIdx,
|
||||||
|
/* isInjector */ false,
|
||||||
|
wellModel_.groupState(),
|
||||||
|
well_state);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group.isProductionGroup()) {
|
||||||
|
const auto& changed_this = this->checkGroupProductionConstraints(group,
|
||||||
|
reportStepIdx,
|
||||||
|
deferred_logger);
|
||||||
|
const auto controls = group.productionControls(wellModel_.summaryState());
|
||||||
|
if (changed_this.first != Group::ProductionCMode::NONE)
|
||||||
|
{
|
||||||
|
switched_prod.insert({group.name(),
|
||||||
|
Group::ProductionCMode2String(changed_this.first)});
|
||||||
|
|
||||||
|
this->actionOnBrokenConstraints(group,
|
||||||
|
controls.exceed_action,
|
||||||
|
changed_this.first,
|
||||||
|
group_state, deferred_logger);
|
||||||
|
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second,
|
||||||
|
group,
|
||||||
|
wellModel_.schedule(),
|
||||||
|
reportStepIdx,
|
||||||
|
/* isInjector */ false,
|
||||||
|
wellModel_.groupState(),
|
||||||
|
well_state);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class BlackoilWellModelGeneric;
|
|||||||
class DeferredLogger;
|
class DeferredLogger;
|
||||||
class GroupState;
|
class GroupState;
|
||||||
class SummaryState;
|
class SummaryState;
|
||||||
|
class WellState;
|
||||||
|
|
||||||
/// Class for handling constraints for the blackoil well model.
|
/// Class for handling constraints for the blackoil well model.
|
||||||
class BlackoilWellModelConstraints
|
class BlackoilWellModelConstraints
|
||||||
@@ -46,18 +47,6 @@ public:
|
|||||||
/// Return true if any well has a THP constraint.
|
/// Return true if any well has a THP constraint.
|
||||||
bool hasTHPConstraints() const;
|
bool hasTHPConstraints() const;
|
||||||
|
|
||||||
//! \brief Check and return value and type of constraints for an injection well group.
|
|
||||||
std::pair<Group::InjectionCMode, double>
|
|
||||||
checkGroupInjectionConstraints(const Group& group,
|
|
||||||
const int reportStepIdx,
|
|
||||||
const Phase& phase) const;
|
|
||||||
|
|
||||||
//! \brief Check and return value and type of constraints for a production well group.
|
|
||||||
std::pair<Group::ProductionCMode, double>
|
|
||||||
checkGroupProductionConstraints(const Group& group,
|
|
||||||
const int reportStepIdx,
|
|
||||||
DeferredLogger& deferred_logger) const;
|
|
||||||
|
|
||||||
//! \brief Check the constraints of a well group.
|
//! \brief Check the constraints of a well group.
|
||||||
bool checkGroupConstraints(const Group& group,
|
bool checkGroupConstraints(const Group& group,
|
||||||
const int reportStepIdx,
|
const int reportStepIdx,
|
||||||
@@ -77,7 +66,28 @@ public:
|
|||||||
GroupState& group_state,
|
GroupState& group_state,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
|
//! \brief Update the individual controls for wells in a group.
|
||||||
|
bool updateGroupIndividualControl(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
std::map<std::pair<std::string,Opm::Phase>,std::string>& switched_inj,
|
||||||
|
std::map<std::string, std::string>& switched_prod,
|
||||||
|
GroupState& group_state,
|
||||||
|
WellState& well_state,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! \brief Check and return value and type of constraints for an injection well group.
|
||||||
|
std::pair<Group::InjectionCMode, double>
|
||||||
|
checkGroupInjectionConstraints(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
const Phase& phase) const;
|
||||||
|
|
||||||
|
//! \brief Check and return value and type of constraints for a production well group.
|
||||||
|
std::pair<Group::ProductionCMode, double>
|
||||||
|
checkGroupProductionConstraints(const Group& group,
|
||||||
|
const int reportStepIdx,
|
||||||
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
const BlackoilWellModelGeneric& wellModel_; //!< Reference to well model
|
const BlackoilWellModelGeneric& wellModel_; //!< Reference to well model
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -779,54 +779,6 @@ checkGroupHigherConstraints(const Group& group,
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
BlackoilWellModelGeneric::
|
|
||||||
updateGroupIndividualControl(const Group& group,
|
|
||||||
DeferredLogger& deferred_logger,
|
|
||||||
const int reportStepIdx)
|
|
||||||
{
|
|
||||||
bool changed = false;
|
|
||||||
if (group.isInjectionGroup())
|
|
||||||
{
|
|
||||||
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
|
|
||||||
for (Phase phase : all) {
|
|
||||||
if (!group.hasInjectionControl(phase)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const auto& changed_this =
|
|
||||||
BlackoilWellModelConstraints(*this).
|
|
||||||
checkGroupInjectionConstraints(group, reportStepIdx, phase);
|
|
||||||
if (changed_this.first != Group::InjectionCMode::NONE)
|
|
||||||
{
|
|
||||||
switched_inj_groups_.insert({{group.name(), phase}, Group::InjectionCMode2String(changed_this.first)});
|
|
||||||
BlackoilWellModelConstraints(*this).
|
|
||||||
actionOnBrokenConstraints(group, changed_this.first, phase,
|
|
||||||
this->groupState(), deferred_logger);
|
|
||||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState());
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (group.isProductionGroup()) {
|
|
||||||
const auto& changed_this =
|
|
||||||
BlackoilWellModelConstraints(*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)});
|
|
||||||
BlackoilWellModelConstraints(*this).
|
|
||||||
actionOnBrokenConstraints(group, controls.exceed_action,
|
|
||||||
changed_this.first,
|
|
||||||
this->groupState(), deferred_logger);
|
|
||||||
WellGroupHelpers::updateWellRatesFromGroupTargetScale(changed_this.second, group, schedule(), reportStepIdx, /* isInjector */ false, this->groupState(), this->wellState());
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BlackoilWellModelGeneric::
|
BlackoilWellModelGeneric::
|
||||||
updateEclWells(const int timeStepIdx,
|
updateEclWells(const int timeStepIdx,
|
||||||
|
|||||||
@@ -302,10 +302,6 @@ protected:
|
|||||||
DeferredLogger& deferred_logger,
|
DeferredLogger& deferred_logger,
|
||||||
const int reportStepIdx);
|
const int reportStepIdx);
|
||||||
|
|
||||||
bool updateGroupIndividualControl(const Group& group,
|
|
||||||
DeferredLogger& deferred_logger,
|
|
||||||
const int reportStepIdx);
|
|
||||||
|
|
||||||
void updateAndCommunicateGroupData(const int reportStepIdx,
|
void updateAndCommunicateGroupData(const int reportStepIdx,
|
||||||
const int iterationIdx);
|
const int iterationIdx);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <opm/grid/utility/cartesianToCompressed.hpp>
|
#include <opm/grid/utility/cartesianToCompressed.hpp>
|
||||||
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
||||||
|
|
||||||
|
#include <opm/simulators/wells/BlackoilWellModelConstraints.hpp>
|
||||||
#include <opm/simulators/wells/VFPProperties.hpp>
|
#include <opm/simulators/wells/VFPProperties.hpp>
|
||||||
#include <opm/simulators/utils/MPIPacker.hpp>
|
#include <opm/simulators/utils/MPIPacker.hpp>
|
||||||
#include <opm/simulators/linalg/bda/WellContributions.hpp>
|
#include <opm/simulators/linalg/bda/WellContributions.hpp>
|
||||||
@@ -1576,7 +1577,15 @@ namespace Opm {
|
|||||||
changed = true;
|
changed = true;
|
||||||
updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
|
updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
|
||||||
}
|
}
|
||||||
bool changed_individual = updateGroupIndividualControl( group, deferred_logger, reportStepIdx);
|
bool changed_individual =
|
||||||
|
BlackoilWellModelConstraints(*this).
|
||||||
|
updateGroupIndividualControl(group,
|
||||||
|
reportStepIdx,
|
||||||
|
this->switched_inj_groups_,
|
||||||
|
this->switched_prod_groups_,
|
||||||
|
this->groupState(),
|
||||||
|
this->wellState(),
|
||||||
|
deferred_logger);
|
||||||
if (changed_individual) {
|
if (changed_individual) {
|
||||||
changed = true;
|
changed = true;
|
||||||
updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
|
updateAndCommunicate(reportStepIdx, iterationIdx, deferred_logger);
|
||||||
|
|||||||
Reference in New Issue
Block a user