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

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 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 ()
double getActivationDate () const
int getArgc () const
char * getArgv (int index) const
char ** getArgv () const
const Parallel::Communication & getComm () 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.
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.
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 Potentials & getSlaveGroupPotentials (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.
void setNeedsSlaveDataReceive (bool value)
 Set whether the master needs to receive production data from the slaves.
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 sendInjectionTargetsToSlave (std::size_t slave_idx, const std::vector< InjectionGroupTarget > &injection_targets) const
void sendNumGroupConstraintsToSlave (std::size_t slave_idx, std::size_t num_injection_targets, std::size_t num_production_constraints) const
void sendProductionConstraintsToSlave (std::size_t slave_idx, const std::vector< ProductionGroupConstraints > &production_constraints) const
void setDeferredLogger (DeferredLogger *deferred_logger)
void setFirstSubstepOfSyncTimestep (bool value)
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
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.
void sendTerminateAndDisconnect ()
 Send terminate signal to all active slaves and disconnect intercommunicators.

Member Function Documentation

◆ 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

◆ 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

◆ 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.

◆ 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.

◆ 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

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