Opm::ReservoirCouplingMaster< Scalar > Class Template Reference

#include <ReservoirCouplingMaster.hpp>

Public Types

using MessageTag = ReservoirCoupling::MessageTag
 
using Seconds = ReservoirCoupling::Seconds
 
using Potentials = ReservoirCoupling::Potentials< Scalar >
 
using SlaveGroupProductionData = ReservoirCoupling::SlaveGroupProductionData< Scalar >
 
using InjectionGroupTarget = ReservoirCoupling::InjectionGroupTarget< Scalar >
 
using MasterGroupNodePressure = ReservoirCoupling::MasterGroupNodePressure< Scalar >
 
using ProductionGroupConstraints = ReservoirCoupling::ProductionGroupConstraints< Scalar >
 

Public Member Functions

 ReservoirCouplingMaster (const Parallel::Communication &comm, const Schedule &schedule, int argc, char **argv)
 
bool activated ()
 
void addSlaveCommunicator (MPI_Comm comm)
 
void addSlaveName (const std::string &name)
 
void addSlaveActivationDate (double date)
 
void addSlaveStartDate (std::time_t date)
 
void clearDeferredLogger ()
 
int effectiveGCW (const std::string &group_name) const
 Effective group-controlled-wells (GCW) count for a master group, used by guide-rate distribution independently of the group's production control mode. More...
 
void setEffectiveGCW (const std::string &group_name, int value)
 
void resetEffectiveGCW ()
 Clear all effective-GCW entries. Call at the start of each master-group constraint calculation before any entries are set, so stale caps from a previous sync step do not leak in. More...
 
double getActivationDate () const
 
int getArgc () const
 
char * getArgv (int index) const
 
char ** getArgv () const
 
const Parallel::CommunicationgetComm () const
 
const std::vector< std::string > & getMasterGroupNamesForSlave (std::size_t slave_idx) const
 Get the master group names associated with a slave reservoir by index. More...
 
std::size_t getMasterGroupCanonicalIdx (const std::string &slave_name, const std::string &master_group_name) const
 Get the canonical index of the master group for a given slave name and master group name. The index is used to map slave group data sent from the slaves, like potentials to the corresponding master group. More...
 
Scalar getMasterGroupRate (const std::string &group_name, ReservoirCoupling::Phase phase, ReservoirCoupling::RateKind kind) const
 
std::map< std::string, std::string > & getMasterGroupToSlaveNameMap ()
 
double getSimulationStartDate () const
 
double getSlaveActivationDate (int index) const
 
const double * getSlaveActivationDates () const
 
MPI_Comm getSlaveComm (int index) const
 
std::map< std::string, std::vector< std::string > > & getSlaveNameToMasterGroupsMap ()
 
const PotentialsgetSlaveGroupPotentials (const std::string &master_group_name)
 
int getSlaveIdx (const std::string &slave_name) const
 
const std::string & getSlaveName (int index) const
 
double getSlaveStartDate (int index) const
 
const double * getSlaveStartDates ()
 
void initStartOfReportStep (int report_step_idx)
 
void initTimeStepping ()
 
bool isFirstSubstepOfSyncTimestep () const
 
bool isMasterGroup (const std::string &group_name) const
 
bool needsSlaveDataReceive () const
 Check if the master needs to receive production data from the slaves. More...
 
void setNeedsSlaveDataReceive (bool value)
 Set whether the master needs to receive production data from the slaves. More...
 
ReservoirCoupling::Loggerlogger ()
 
ReservoirCoupling::Loggerlogger () const
 
void maybeActivate (int report_step)
 
void maybeReceiveActivationHandshakeFromSlaves (double current_time)
 
double maybeChopSubStep (double suggested_timestep, double current_time) const
 
void maybeSpawnSlaveProcesses (int report_step)
 
std::size_t numSlaveGroups (unsigned int index)
 
std::size_t numSlaves () const
 
std::size_t numSlavesStarted () const
 
std::size_t numActivatedSlaves () const
 
void rebuildSlaveIdxToMasterGroupsVector ()
 
void receiveNextReportDateFromSlaves ()
 
void receiveProductionDataFromSlaves ()
 
void receiveInjectionDataFromSlaves ()
 
void resizeNextReportDates (int size)
 
void resizeSlaveActivationDates (int size)
 
void resizeSlaveStartDates (int size)
 
const Schedule & schedule () const
 
void sendNextTimeStepToSlaves (double next_time_step)
 
void sendCoupledNetworkActiveStatusToSlave (std::size_t slave_idx, bool active) const
 Send a single boolean to a slave telling it whether the master will iterate the cross-rescoup network exchange this sync timestep. More...
 
void sendInjectionTargetsToSlave (std::size_t slave_idx, const std::vector< InjectionGroupTarget > &injection_targets) const
 
void sendMasterGroupNodePressuresToSlave (std::size_t slave_idx, const std::vector< MasterGroupNodePressure > &pressures) const
 Send master-computed network-leaf node pressures to a slave. More...
 
void sendNumGroupConstraintsToSlave (std::size_t slave_idx, std::size_t num_injection_targets, std::size_t num_production_constraints) const
 
void sendNumMasterGroupNodePressuresToSlave (std::size_t slave_idx, std::size_t num_pressures, bool is_final) const
 Send the count of master-computed network-leaf node pressures plus the master's is_final flag for this sync-step iteration. More...
 
void sendProductionConstraintsToSlave (std::size_t slave_idx, const std::vector< ProductionGroupConstraints > &production_constraints) const
 
void setDeferredLogger (DeferredLogger *deferred_logger)
 
void setFirstSubstepOfSyncTimestep (bool value)
 
data::ReservoirCouplingGroupRates collectGroupRatesForSummary () const
 Collect production/injection rates for all master groups. More...
 
void setSlaveActivationDate (int index, double date)
 
void setSlaveNextReportTimeOffset (int index, double offset)
 
void setSlaveStartDate (int index, std::time_t date)
 
bool slaveIsActivated (int index) const
 
bool syncAtReportSteps () const
 Whether the master syncs with slaves at slave report-step boundaries (true) or at every master actual time step (false, default CLI flag value). More...
 
void updateMasterGroupNameOrderMap (const std::string &slave_name, const std::map< std::string, std::size_t > &master_group_map)
 
void sendDontTerminateSignalToSlaves ()
 Send "don't terminate" signal (value=0) to all active slaves. More...
 
void sendTerminateAndDisconnect ()
 Send terminate signal to all active slaves and disconnect intercommunicators. More...
 

Member Typedef Documentation

◆ InjectionGroupTarget

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::InjectionGroupTarget = ReservoirCoupling::InjectionGroupTarget<Scalar>

◆ MasterGroupNodePressure

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::MasterGroupNodePressure = ReservoirCoupling::MasterGroupNodePressure<Scalar>

◆ MessageTag

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::MessageTag = ReservoirCoupling::MessageTag

◆ Potentials

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::Potentials = ReservoirCoupling::Potentials<Scalar>

◆ ProductionGroupConstraints

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::ProductionGroupConstraints = ReservoirCoupling::ProductionGroupConstraints<Scalar>

◆ Seconds

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::Seconds = ReservoirCoupling::Seconds

◆ SlaveGroupProductionData

template<class Scalar >
using Opm::ReservoirCouplingMaster< Scalar >::SlaveGroupProductionData = ReservoirCoupling::SlaveGroupProductionData<Scalar>

Constructor & Destructor Documentation

◆ ReservoirCouplingMaster()

template<class Scalar >
Opm::ReservoirCouplingMaster< Scalar >::ReservoirCouplingMaster ( const Parallel::Communication comm,
const Schedule &  schedule,
int  argc,
char **  argv 
)

Member Function Documentation

◆ activated()

template<class Scalar >
bool Opm::ReservoirCouplingMaster< Scalar >::activated ( )
inline

◆ addSlaveActivationDate()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::addSlaveActivationDate ( double  date)
inline

◆ addSlaveCommunicator()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::addSlaveCommunicator ( MPI_Comm  comm)
inline

◆ addSlaveName()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::addSlaveName ( const std::string &  name)
inline

◆ addSlaveStartDate()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::addSlaveStartDate ( std::time_t  date)
inline

◆ clearDeferredLogger()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::clearDeferredLogger ( )
inline

◆ collectGroupRatesForSummary()

template<class Scalar >
data::ReservoirCouplingGroupRates Opm::ReservoirCouplingMaster< Scalar >::collectGroupRatesForSummary ( ) const

Collect production/injection rates for all master groups.

Returns a ReservoirCouplingGroupRates struct that can be passed through DynamicSimulatorState to Summary::eval().

◆ effectiveGCW()

template<class Scalar >
int Opm::ReservoirCouplingMaster< Scalar >::effectiveGCW ( const std::string &  group_name) const
inline

Effective group-controlled-wells (GCW) count for a master group, used by guide-rate distribution independently of the group's production control mode.

Set by RescoupConstraintsCalculator during master-group constraint calculation. A participating master group (GCONPROD item 8 RESPOND_TO_PARENT = YES) defaults to 1 so it is counted in the parent's guide-rate sum even while on individual control; it is set to 0 when capped at its slave's potential or when its slave is inactive. See GroupStateHelper::updateGroupControlledWellsRecursive_ for the reader.

Returns
The stored effective GCW, or 1 if the group has no explicit entry (the participating-and-uncapped default).

◆ getActivationDate()

template<class Scalar >
double Opm::ReservoirCouplingMaster< Scalar >::getActivationDate ( ) const
inline

◆ getArgc()

template<class Scalar >
int Opm::ReservoirCouplingMaster< Scalar >::getArgc ( ) const
inline

◆ getArgv() [1/2]

template<class Scalar >
char ** Opm::ReservoirCouplingMaster< Scalar >::getArgv ( ) const
inline

◆ getArgv() [2/2]

template<class Scalar >
char * Opm::ReservoirCouplingMaster< Scalar >::getArgv ( int  index) const
inline

◆ getComm()

template<class Scalar >
const Parallel::Communication & Opm::ReservoirCouplingMaster< Scalar >::getComm ( ) const
inline

◆ getMasterGroupCanonicalIdx()

template<class Scalar >
std::size_t Opm::ReservoirCouplingMaster< Scalar >::getMasterGroupCanonicalIdx ( const std::string &  slave_name,
const std::string &  master_group_name 
) const

Get the canonical index of the master group for a given slave name and master group name. The index is used to map slave group data sent from the slaves, like potentials to the corresponding master group.

Parameters
slave_nameThe name of the slave reservoir.
master_group_nameThe name of the master group.
Returns
The canonical index of the master group for the given slave name and master group name.

◆ getMasterGroupNamesForSlave()

template<class Scalar >
const std::vector< std::string > & Opm::ReservoirCouplingMaster< Scalar >::getMasterGroupNamesForSlave ( std::size_t  slave_idx) const

Get the master group names associated with a slave reservoir by index.

This method retrieves the list of master group names that are associated with a specific slave reservoir identified by its index.

Parameters
slave_idxThe zero-based index of the slave reservoir (must be < numSlaves())
Returns
A const reference to a vector of master group names for the specified slave
Exceptions
std::runtime_errorif slave_idx is out of bounds
Note
Performance: This method uses O(1) direct vector access when possible, falling back to O(log n) map lookup for error handling.
See also
RescoupConstraintsCalculator::calculateAndSendTargets() for primary usage context

◆ getMasterGroupRate()

template<class Scalar >
Scalar Opm::ReservoirCouplingMaster< Scalar >::getMasterGroupRate ( const std::string &  group_name,
ReservoirCoupling::Phase  phase,
ReservoirCoupling::RateKind  kind 
) const

◆ getMasterGroupToSlaveNameMap()

template<class Scalar >
std::map< std::string, std::string > & Opm::ReservoirCouplingMaster< Scalar >::getMasterGroupToSlaveNameMap ( )
inline

◆ getSimulationStartDate()

template<class Scalar >
double Opm::ReservoirCouplingMaster< Scalar >::getSimulationStartDate ( ) const
inline

◆ getSlaveActivationDate()

template<class Scalar >
double Opm::ReservoirCouplingMaster< Scalar >::getSlaveActivationDate ( int  index) const
inline

◆ getSlaveActivationDates()

template<class Scalar >
const double * Opm::ReservoirCouplingMaster< Scalar >::getSlaveActivationDates ( ) const
inline

◆ getSlaveComm()

template<class Scalar >
MPI_Comm Opm::ReservoirCouplingMaster< Scalar >::getSlaveComm ( int  index) const
inline

◆ getSlaveGroupPotentials()

template<class Scalar >
const Potentials & Opm::ReservoirCouplingMaster< Scalar >::getSlaveGroupPotentials ( const std::string &  master_group_name)

◆ getSlaveIdx()

template<class Scalar >
int Opm::ReservoirCouplingMaster< Scalar >::getSlaveIdx ( const std::string &  slave_name) const

◆ getSlaveName()

template<class Scalar >
const std::string & Opm::ReservoirCouplingMaster< Scalar >::getSlaveName ( int  index) const
inline

◆ getSlaveNameToMasterGroupsMap()

template<class Scalar >
std::map< std::string, std::vector< std::string > > & Opm::ReservoirCouplingMaster< Scalar >::getSlaveNameToMasterGroupsMap ( )
inline

◆ getSlaveStartDate()

template<class Scalar >
double Opm::ReservoirCouplingMaster< Scalar >::getSlaveStartDate ( int  index) const
inline

◆ getSlaveStartDates()

template<class Scalar >
const double * Opm::ReservoirCouplingMaster< Scalar >::getSlaveStartDates ( )
inline

◆ initStartOfReportStep()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::initStartOfReportStep ( int  report_step_idx)

◆ initTimeStepping()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::initTimeStepping ( )

◆ isFirstSubstepOfSyncTimestep()

template<class Scalar >
bool Opm::ReservoirCouplingMaster< Scalar >::isFirstSubstepOfSyncTimestep ( ) const

◆ isMasterGroup()

template<class Scalar >
bool Opm::ReservoirCouplingMaster< Scalar >::isMasterGroup ( const std::string &  group_name) const

◆ logger() [1/2]

template<class Scalar >
ReservoirCoupling::Logger & Opm::ReservoirCouplingMaster< Scalar >::logger ( )
inline

◆ logger() [2/2]

template<class Scalar >
ReservoirCoupling::Logger & Opm::ReservoirCouplingMaster< Scalar >::logger ( ) const
inline

◆ maybeActivate()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::maybeActivate ( int  report_step)

◆ maybeChopSubStep()

template<class Scalar >
double Opm::ReservoirCouplingMaster< Scalar >::maybeChopSubStep ( double  suggested_timestep,
double  current_time 
) const

◆ maybeReceiveActivationHandshakeFromSlaves()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::maybeReceiveActivationHandshakeFromSlaves ( double  current_time)

◆ maybeSpawnSlaveProcesses()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::maybeSpawnSlaveProcesses ( int  report_step)

◆ needsSlaveDataReceive()

template<class Scalar >
bool Opm::ReservoirCouplingMaster< Scalar >::needsSlaveDataReceive ( ) const

Check if the master needs to receive production data from the slaves.

This flag is used to control reservoir coupling synchronization of summary data sent from the slaves to the master process. The master blocks in timeStepSucceeded() until all slaves have sent their production data.

Returns
true if the master needs to receive production data from the slaves, false if not

◆ numActivatedSlaves()

template<class Scalar >
std::size_t Opm::ReservoirCouplingMaster< Scalar >::numActivatedSlaves ( ) const

◆ numSlaveGroups()

template<class Scalar >
std::size_t Opm::ReservoirCouplingMaster< Scalar >::numSlaveGroups ( unsigned int  index)

◆ numSlaves()

template<class Scalar >
std::size_t Opm::ReservoirCouplingMaster< Scalar >::numSlaves ( ) const
inline

◆ numSlavesStarted()

template<class Scalar >
std::size_t Opm::ReservoirCouplingMaster< Scalar >::numSlavesStarted ( ) const

◆ rebuildSlaveIdxToMasterGroupsVector()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::rebuildSlaveIdxToMasterGroupsVector ( )

◆ receiveInjectionDataFromSlaves()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::receiveInjectionDataFromSlaves ( )

◆ receiveNextReportDateFromSlaves()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::receiveNextReportDateFromSlaves ( )

◆ receiveProductionDataFromSlaves()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::receiveProductionDataFromSlaves ( )

◆ resetEffectiveGCW()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::resetEffectiveGCW ( )
inline

Clear all effective-GCW entries. Call at the start of each master-group constraint calculation before any entries are set, so stale caps from a previous sync step do not leak in.

◆ resizeNextReportDates()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::resizeNextReportDates ( int  size)

◆ resizeSlaveActivationDates()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::resizeSlaveActivationDates ( int  size)
inline

◆ resizeSlaveStartDates()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::resizeSlaveStartDates ( int  size)
inline

◆ schedule()

template<class Scalar >
const Schedule & Opm::ReservoirCouplingMaster< Scalar >::schedule ( ) const
inline

◆ sendCoupledNetworkActiveStatusToSlave()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendCoupledNetworkActiveStatusToSlave ( std::size_t  slave_idx,
bool  active 
) const

Send a single boolean to a slave telling it whether the master will iterate the cross-rescoup network exchange this sync timestep.

◆ sendDontTerminateSignalToSlaves()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendDontTerminateSignalToSlaves ( )

Send "don't terminate" signal (value=0) to all active slaves.

This method is called at the start of each iteration in the master's substep loop, before receiving the next report date from slaves. The slave waits for this signal at the start of each iteration - if it receives 0, it continues; if it receives 1 (from sendTerminateAndDisconnect()), it terminates.

◆ sendInjectionTargetsToSlave()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendInjectionTargetsToSlave ( std::size_t  slave_idx,
const std::vector< InjectionGroupTarget > &  injection_targets 
) const

◆ sendMasterGroupNodePressuresToSlave()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendMasterGroupNodePressuresToSlave ( std::size_t  slave_idx,
const std::vector< MasterGroupNodePressure > &  pressures 
) const

Send master-computed network-leaf node pressures to a slave.

◆ sendNextTimeStepToSlaves()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendNextTimeStepToSlaves ( double  next_time_step)
inline

◆ sendNumGroupConstraintsToSlave()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendNumGroupConstraintsToSlave ( std::size_t  slave_idx,
std::size_t  num_injection_targets,
std::size_t  num_production_constraints 
) const

◆ sendNumMasterGroupNodePressuresToSlave()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendNumMasterGroupNodePressuresToSlave ( std::size_t  slave_idx,
std::size_t  num_pressures,
bool  is_final 
) const

Send the count of master-computed network-leaf node pressures plus the master's is_final flag for this sync-step iteration.

◆ sendProductionConstraintsToSlave()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendProductionConstraintsToSlave ( std::size_t  slave_idx,
const std::vector< ProductionGroupConstraints > &  production_constraints 
) const

◆ sendTerminateAndDisconnect()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::sendTerminateAndDisconnect ( )

Send terminate signal to all active slaves and disconnect intercommunicators.

This method must be called at the end of the simulation to cleanly shut down the MPI intercommunicators created by MPI_Comm_spawn(). It performs two steps:

  1. Sends a terminate signal to all active slaves (only from rank 0)
  2. Disconnects the intercommunicators (collective operation)

Both master and slaves must call their respective disconnect methods for MPI_Comm_disconnect() to complete - it is a collective operation.

◆ setDeferredLogger()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setDeferredLogger ( DeferredLogger deferred_logger)
inline

◆ setEffectiveGCW()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setEffectiveGCW ( const std::string &  group_name,
int  value 
)
inline

◆ setFirstSubstepOfSyncTimestep()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setFirstSubstepOfSyncTimestep ( bool  value)

◆ setNeedsSlaveDataReceive()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setNeedsSlaveDataReceive ( bool  value)

Set whether the master needs to receive production data from the slaves.

See needsSlaveDataReceive() for details.

Parameters
valuetrue if the master needs to receive production data from the slaves, false if not

◆ setSlaveActivationDate()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setSlaveActivationDate ( int  index,
double  date 
)
inline

◆ setSlaveNextReportTimeOffset()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setSlaveNextReportTimeOffset ( int  index,
double  offset 
)

◆ setSlaveStartDate()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::setSlaveStartDate ( int  index,
std::time_t  date 
)
inline

◆ slaveIsActivated()

template<class Scalar >
bool Opm::ReservoirCouplingMaster< Scalar >::slaveIsActivated ( int  index) const
inline

◆ syncAtReportSteps()

template<class Scalar >
bool Opm::ReservoirCouplingMaster< Scalar >::syncAtReportSteps ( ) const
inline

Whether the master syncs with slaves at slave report-step boundaries (true) or at every master actual time step (false, default CLI flag value).

Set from the –rescoup-sync-at-report-steps CLI flag in the constructor. See Parameters::RescoupSyncAtReportSteps.

◆ updateMasterGroupNameOrderMap()

template<class Scalar >
void Opm::ReservoirCouplingMaster< Scalar >::updateMasterGroupNameOrderMap ( const std::string &  slave_name,
const std::map< std::string, std::size_t > &  master_group_map 
)

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