opm-simulators
Loading...
Searching...
No Matches
Opm::GroupStateHelper< Scalar, IndexTraits > Class Template Reference

Classes

class  WellStateGuard
class  GroupStateGuard
class  ScopedLoggerGuard
 RAII guard that owns a DeferredLogger and auto-gathers on destruction. More...

Public Types

using GroupTarget = typename SingleWellState<Scalar, IndexTraits>::GroupTarget

Public Member Functions

 GroupStateHelper (WellState< Scalar, IndexTraits > &well_state, GroupState< Scalar > &group_state, const Schedule &schedule, const SummaryState &summary_state, const GuideRate &guide_rate, const PhaseUsageInfo< IndexTraits > &phase_usage_info, const Parallel::Communication &comm, bool terminal_output)
void accumulateGroupEfficiencyFactor (const Group &group, Scalar &factor) const
std::pair< bool, Scalar > checkGroupConstraintsInj (const std::string &name, const std::string &parent, const Group &group, const Scalar *rates, const Phase injection_phase, const Scalar efficiency_factor, const std::vector< Scalar > &resv_coeff, const bool check_guide_rate) const
std::pair< bool, Scalar > checkGroupConstraintsProd (const std::string &name, const std::string &parent, const Group &group, const Scalar *rates, const Scalar efficiency_factor, const std::vector< Scalar > &resv_coeff, const bool check_guide_rate) const
std::pair< Group::ProductionCMode, Scalar > checkGroupProductionConstraints (const Group &group) const
const Parallel::Communication & comm () const
DeferredLoggerdeferredLogger () const
 Get the deferred logger.
std::vector< Scalar > getGroupRatesAvailableForHigherLevelControl (const Group &group, const bool is_injector) const
Scalar getInjectionGroupTarget (const Group &group, const Phase &injection_phase, const std::vector< Scalar > &resv_coeff) const
GuideRateModel::Target getInjectionGuideTargetMode (Phase injection_phase) const
 Get the guide rate target mode for an injection phase.
Scalar getProductionGroupTarget (const Group &group) const
Scalar getProductionGroupTargetForMode (const Group &group, const Group::ProductionCMode cmode) const
 Get the production target for a specific control mode (not necessarily the active one).
GuideRateModel::Target getProductionGuideTargetMode (const Group &group) const
 Get the guide rate target mode for a production group.
std::pair< Scalar, Group::ProductionCMode > getAutoChokeGroupProductionTargetRate (const Group &bottom_group, const Group &group, const std::vector< Scalar > &resv_coeff, Scalar efficiencyFactor) const
GuideRate::RateVector getProductionGroupRateVector (const std::string &group_name) const
std::optional< GroupTarget > getWellGroupTargetInjector (const std::string &name, const std::string &parent, const Group &group, const Scalar *rates, const Phase injection_phase, const Scalar efficiency_factor, const std::vector< Scalar > &resv_coeff) const
std::optional< GroupTarget > getWellGroupTargetProducer (const std::string &name, const std::string &parent, const Group &group, const Scalar *rates, const Scalar efficiency_factor, const std::vector< Scalar > &resv_coeff) const
GuideRate::RateVector getWellRateVector (const std::string &name) const
std::vector< std::string > groupChainTopBot (const std::string &bottom, const std::string &top) const
int groupControlledWells (const std::string &group_name, const std::string &always_included_child, const bool is_production_group, const Phase injection_phase) const
 returns the number of wells that are actively under group control for a given group with name given by group_name
GroupState< Scalar > & groupState () const
const GuideRate & guideRate () const
bool isRank0 () const
bool isReservoirCouplingMaster () const
bool isReservoirCouplingMasterGroup (const Group &group) const
bool isReservoirCouplingSlave () const
bool isReservoirCouplingSlaveGroup (const Group &group) const
constexpr int numPhases () const
int phaseToActivePhaseIdx (const Phase phase) const
const PhaseUsageInfo< IndexTraits > & phaseUsage () const
GroupStateGuard pushGroupState (GroupState< Scalar > &group_state)
ScopedLoggerGuard pushLogger (bool do_mpi_gather=true) const
 Push a new logger onto the stack with auto-cleanup on destruction.
WellStateGuard pushWellState (WellState< Scalar, IndexTraits > &well_state)
int reportStepIdx () const
const Schedule & schedule () const
ReservoirCoupling::Proxy< Scalar > & rescoup ()
const ReservoirCoupling::Proxy< Scalar > & rescoup () const
ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster ()
const ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster () const
ReservoirCouplingSlave< Scalar > & reservoirCouplingSlave ()
const ReservoirCouplingSlave< Scalar > & reservoirCouplingSlave () const
void setCmodeGroup (const Group &group)
template<class AverageRegionalPressureType>
void setRegionAveragePressureCalculator (const Group &group, const FieldPropsManager &fp, std::map< std::string, std::unique_ptr< AverageRegionalPressureType > > &regional_average_pressure_calculator) const
void setReportStep (int report_step)
const SummaryState & summaryState () const
Scalar sumSolventRates (const Group &group, const bool is_injector) const
Scalar sumWellResRates (const Group &group, const int phase_pos, const bool injector) const
Scalar sumWellSurfaceRates (const Group &group, const int phase_pos, const bool injector) const
Scalar sumWellPhaseRates (bool res_rates, const Group &group, const int phase_pos, const bool injector, const bool network=false) const
bool terminalOutput () const
template<class RegionalValues>
void updateGpMaintTargetForGroups (const Group &group, const RegionalValues &regional_values, const double dt)
int updateGroupControlledWells (const bool is_production_group, const Phase injection_phase)
 update the number of wells that are actively under group control for a given group with name given by group_name its main usage is to detect cases where there is no wells under group control
void updateGroupProductionRates (const Group &group)
void updateGroupTargetReduction (const Group &group, const bool is_injector)
void updateNetworkLeafNodeProductionRates ()
void updateNONEProductionGroups ()
 Set production control to NONE for groups not targeting any well.
void updateREINForGroups (const Group &group, bool sum_rank)
void updateReservoirRatesInjectionGroups (const Group &group)
void updateState (WellState< Scalar, IndexTraits > &well_state, GroupState< Scalar > &group_state)
void updateSurfaceRatesInjectionGroups (const Group &group)
void updateVREPForGroups (const Group &group)
void updateWellRates (const Group &group, const WellState< Scalar, IndexTraits > &well_state_nupcol, WellState< Scalar, IndexTraits > &well_state) const
const WellState< Scalar, IndexTraits > & wellState () const
void updateWellRatesFromGroupTargetScale (const Scalar scale, const Group &group, bool is_injector, WellState< Scalar, IndexTraits > &well_state) const
std::pair< std::optional< std::string >, Scalar > worstOffendingWell (const Group &group, const Group::ProductionCMode &offended_control) const
 Returns the name of the worst offending well and its fraction (i.e. violated_phase / preferred_phase).

Member Function Documentation

◆ deferredLogger()

template<typename Scalar, typename IndexTraits>
DeferredLogger & Opm::GroupStateHelper< Scalar, IndexTraits >::deferredLogger ( ) const
inline

Get the deferred logger.

Exceptions
std::logic_errorif no logger has been set via pushLogger()

◆ getInjectionGuideTargetMode()

template<typename Scalar, typename IndexTraits>
GuideRateModel::Target Opm::GroupStateHelper< Scalar, IndexTraits >::getInjectionGuideTargetMode ( Phase injection_phase) const

Get the guide rate target mode for an injection phase.

Parameters
injection_phaseThe injection phase (WATER, OIL, or GAS)
Returns
The corresponding GuideRateModel::Target for the injection phase

◆ getProductionGuideTargetMode()

template<typename Scalar, typename IndexTraits>
GuideRateModel::Target Opm::GroupStateHelper< Scalar, IndexTraits >::getProductionGuideTargetMode ( const Group & group) const

Get the guide rate target mode for a production group.

Parameters
groupThe production group
Returns
The GuideRateModel::Target based on the group's production control mode

◆ pushLogger()

template<typename Scalar, typename IndexTraits>
ScopedLoggerGuard Opm::GroupStateHelper< Scalar, IndexTraits >::pushLogger ( bool do_mpi_gather = true) const
inline

Push a new logger onto the stack with auto-cleanup on destruction.

Creates a new DeferredLogger and pushes it onto the logger stack. When the returned guard goes out of scope:

  1. If do_mpi_gather is true: Messages are gathered across MPI ranks via gatherDeferredLogger() and logged on rank 0 (if terminal_output is enabled)
  2. If do_mpi_gather is false: Messages are logged locally without MPI gather
  3. The previous logger is restored
Parameters
do_mpi_gatherIf true (default), gather messages across MPI ranks on destruction. Set to false when called from contexts where MPI synchronization is not possible (e.g., NLDD domain-local operations called at different times on different ranks).
Returns
RAII guard that owns the logger and handles cleanup

◆ updateNONEProductionGroups()

template<typename Scalar, typename IndexTraits>
void Opm::GroupStateHelper< Scalar, IndexTraits >::updateNONEProductionGroups ( )

Set production control to NONE for groups not targeting any well.

For each group in the production controls map, checks whether any open producer well has GRUP control with that group as its target. If not, the group's production control is set to NONE. This is needed to get correct summary output for GMCTP/FMCTP, see https://github.com/OPM/opm-simulators/pull/6596 for more details.

Exceptions (groups excluded from the NONE reset):

  • Groups specified for gas lift optimization (GLO)
  • RC master hierarchy groups (master groups + ancestors up to FIELD), which actively distribute targets to slave groups

The documentation for this class was generated from the following files: