preCICE v3.1.1
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
precice::cplscheme::ParallelCouplingScheme Class Reference

Coupling scheme for parallel coupling, i.e. simultaneous execution of two coupled participants. More...

#include <ParallelCouplingScheme.hpp>

Inheritance diagram for precice::cplscheme::ParallelCouplingScheme:
[legend]
Collaboration diagram for precice::cplscheme::ParallelCouplingScheme:
[legend]

Public Member Functions

 ParallelCouplingScheme (double maxTime, int maxTimeWindows, double timeWindowSize, const std::string &firstParticipant, const std::string &secondParticipant, const std::string &localParticipant, m2n::PtrM2N m2n, constants::TimesteppingMethod dtMethod, CouplingMode cplMode, int minIterations, int maxIterations)
 Constructor.
 
 ParallelCouplingScheme (double maxTime, int maxTimeWindows, double timeWindowSize, const std::string &firstParticipant, const std::string &secondParticipant, const std::string &localParticipant, m2n::PtrM2N m2n, constants::TimesteppingMethod dtMethod, CouplingMode cplMode)
 
- Public Member Functions inherited from precice::cplscheme::BiCouplingScheme
 BiCouplingScheme (double maxTime, int maxTimeWindows, double timeWindowSize, std::string firstParticipant, std::string secondParticipant, const std::string &localParticipant, m2n::PtrM2N m2n, int minIterations, int maxIterations, CouplingMode cplMode, constants::TimesteppingMethod dtMethod)
 
void addDataToSend (const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps)
 Adds data to be sent on data exchange and possibly be modified during coupling iterations.
 
void addDataToReceive (const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps)
 Adds data to be received on data exchange.
 
void determineInitialDataExchange () override
 Determines which data is initialized and therefore has to be exchanged during initialize.
 
std::vector< std::stringgetCouplingPartners () const override final
 returns list of all coupling partners
 
bool hasAnySendData () override final
 
bool hasSendData (DataID dataID)
 
- Public Member Functions inherited from precice::cplscheme::BaseCouplingScheme
 BaseCouplingScheme (double maxTime, int maxTimeWindows, double timeWindowSize, std::string localParticipant, int minIterations, int maxIterations, CouplingMode cplMode, constants::TimesteppingMethod dtMethod)
 
bool sendsInitializedData () const override final
 Getter for _sendsInitializedData.
 
bool isInitialized () const override final
 getter for _isInitialized
 
bool addComputedTime (double timeToAdd) override final
 Adds newly computed time. Has to be called before every advance.
 
bool willDataBeExchanged (double lastSolverTimeStepSize) const override final
 Returns true, if data will be exchanged when calling advance().
 
bool hasDataBeenReceived () const override final
 getter for _hasDataBeenReceived
 
double getTime () const override final
 getter for _time
 
double getTimeWindowStart () const override final
 
int getTimeWindows () const override final
 getter for _timeWindows
 
bool hasTimeWindowSize () const override final
 Function to check whether time window size is defined by coupling scheme.
 
double getTimeWindowSize () const override final
 Returns the time window size, if one is given by the coupling scheme.
 
double getNextTimeStepMaxSize () const override final
 Returns the maximal size of the next time step to be computed.
 
bool isCouplingOngoing () const override final
 Returns true, when the coupled simulation is still ongoing.
 
bool isTimeWindowComplete () const override final
 Returns true, when the accessor can advance to the next time window.
 
bool isActionRequired (Action action) const override final
 Returns true, if the given action has to be performed by the accessor.
 
bool isActionFulfilled (Action action) const override final
 Returns true, if the given action has to be performed by the accessor.
 
void markActionFulfilled (Action action) override final
 Tells the coupling scheme that the accessor has performed the given action.
 
void requireAction (Action action) override final
 Sets an action required to be performed by the accessor.
 
std::string printCouplingState () const override
 Returns coupling state information.
 
void finalize () override final
 Finalizes the coupling scheme.
 
void initialize (double startTime, int startTimeWindow) override final
 Initializes the coupling scheme.
 
ChangedMeshes firstSynchronization (const ChangedMeshes &changes) override final
 
void firstExchange () override final
 
ChangedMeshes secondSynchronization () override final
 
void secondExchange () override final
 
void addConvergenceMeasure (int dataID, bool suffices, bool strict, impl::PtrConvergenceMeasure measure, bool doesLogging)
 Adds a measure to determine the convergence of coupling iterations.
 
void setAcceleration (const acceleration::PtrAcceleration &acceleration)
 Set an acceleration technique.
 
bool doesFirstStep () const
 Getter for _doesFirstStep.
 
bool isImplicitCouplingScheme () const override
 Function to determine whether coupling scheme is an implicit coupling scheme.
 
bool hasConverged () const override
 Checks if the implicit cplscheme has converged.
 
- Public Member Functions inherited from precice::cplscheme::CouplingScheme
CouplingSchemeoperator= (CouplingScheme &&)=delete
 
virtual ~CouplingScheme ()
 

Private Member Functions

void exchangeInitialData () override final
 implements functionality for initialize in base class.
 
void exchangeFirstData () override final
 Functions needed for advance()
 
void exchangeSecondData () override final
 Exchanges the second set of data.
 
DataMapgetAccelerationData () override final
 interface to provide accelerated data, depending on coupling scheme being used
 

Private Attributes

logging::Logger _log {"cplscheme::ParallelCouplingScheme"}
 

Friends

struct testing::ParallelCouplingSchemeFixture
 

Additional Inherited Members

- Public Types inherited from precice::cplscheme::BaseCouplingScheme
enum  CouplingMode { Explicit , Implicit , Undefined }
 
- Public Types inherited from precice::cplscheme::CouplingScheme
enum struct  Action { InitializeData , ReadCheckpoint , WriteCheckpoint }
 Actions that are required by CouplingSchemes. More...
 
using ChangedMeshes = std::vector<MeshID>
 
- Static Public Member Functions inherited from precice::cplscheme::CouplingScheme
static std::string toString (Action action)
 
- Static Public Attributes inherited from precice::cplscheme::CouplingScheme
static const double UNDEFINED_MAX_TIME = -1.0
 Does not define a time limit for the coupled simulation.
 
static const int UNDEFINED_TIME_WINDOWS = -1
 Does not define limit on time windows for the coupled simulation.
 
static const double UNDEFINED_TIME_WINDOW_SIZE = -1.0
 To be used, when the time window size is determined dynamically during the coupling.
 
static const int UNDEFINED_MAX_ITERATIONS = -1
 To be used, when the number of max iterations is not defined (for explicit coupling).
 
static const int UNDEFINED_MIN_ITERATIONS = -1
 To be used, when the number of min iterations is not defined (for explicit coupling).
 
static const int INFINITE_MAX_ITERATIONS = -2
 To be used, when the number of max iterations is infinite (for implicit coupling).
 
- Protected Member Functions inherited from precice::cplscheme::BiCouplingScheme
DataMapgetSendData ()
 Returns all data to be sent.
 
DataMapgetReceiveData ()
 Returns all data to be received.
 
const DataMapgetReceiveData () const
 Returns all data to be received.
 
CouplingDatagetSendData (DataID dataID)
 Sets the values.
 
CouplingDatagetReceiveData (DataID dataID)
 Returns all data to be received with data ID as given.
 
m2n::PtrM2N getM2N () const
 
void initializeReceiveDataStorage () override final
 Functions needed for initialize()
 
- Protected Member Functions inherited from precice::cplscheme::BaseCouplingScheme
void sendNumberOfTimeSteps (const m2n::PtrM2N &m2n, const int numberOfTimeSteps)
 
void sendTimes (const m2n::PtrM2N &m2n, const Eigen::VectorXd &times)
 
void sendData (const m2n::PtrM2N &m2n, const DataMap &sendData)
 Sends data sendDataIDs given in mapCouplingData with communication.
 
int receiveNumberOfTimeSteps (const m2n::PtrM2N &m2n)
 
Eigen::VectorXd receiveTimes (const m2n::PtrM2N &m2n, int nTimeSteps)
 
void receiveData (const m2n::PtrM2N &m2n, const DataMap &receiveData)
 Receives data receiveDataIDs given in mapCouplingData with communication.
 
void receiveDataForWindowEnd (const m2n::PtrM2N &m2n, const DataMap &receiveData)
 Like receiveData, but temporarily sets window time to end of window.
 
void initializeWithZeroInitialData (const DataMap &receiveData)
 Initializes storage in receiveData as zero.
 
PtrCouplingData addCouplingData (const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps, CouplingData::Direction direction)
 Adds CouplingData with given properties to this BaseCouplingScheme and returns a pointer to the CouplingData.
 
bool isExplicitCouplingScheme () const
 Function to determine whether coupling scheme is an explicit coupling scheme.
 
void setTimeWindowSize (double timeWindowSize)
 Setter for _timeWindowSize.
 
double getNextTimeWindowSize () const
 Getter for _nextTimeWindowSize.
 
void setNextTimeWindowSize (double timeWindowSize)
 Setter for _nextTimeWindowSize.
 
void setDoesFirstStep (bool doesFirstStep)
 Setter for _doesFirstStep.
 
void notifyDataHasBeenReceived ()
 Used to set flag after data has been received using receiveData().
 
bool receivesInitializedData () const
 Getter for _receivesInitializedData.
 
void setTimeWindows (int timeWindows)
 Setter for _timeWindows.
 
void sendConvergence (const m2n::PtrM2N &m2n)
 sends convergence to other participant via m2n
 
void receiveConvergence (const m2n::PtrM2N &m2n)
 receives convergence from other participant via m2n
 
void doImplicitStep ()
 perform a coupling iteration
 
void moveToNextWindow ()
 finalizes this window's data and initializes data for next window.
 
void storeIteration ()
 used for storing all Data at end of doImplicitStep for later reference.
 
void determineInitialSend (DataMap &sendData)
 Sets _sendsInitializedData, if sendData requires initialization.
 
void determineInitialReceive (DataMap &receiveData)
 Sets _receivesInitializedData, if receiveData requires initialization.
 
bool reachedEndOfTimeWindow () const
 Function to check whether end of time window is reached. Does not check for convergence.
 
bool requiresSubsteps () const override final
 Returns true if any send data of the scheme requires substeps.
 
ImplicitData implicitDataToReceive () const override
 Returns a vector of implicit data to receive in the next advance.
 
- Protected Attributes inherited from precice::cplscheme::BaseCouplingScheme
DataMap _allData
 All send and receive data as a map "data ID -> data".
 
acceleration::PtrAcceleration _acceleration
 Acceleration method to speedup iteration convergence.
 

Detailed Description

Coupling scheme for parallel coupling, i.e. simultaneous execution of two coupled participants.

For more information, look into Benjamin's thesis, Section 3.5. https://mediatum.ub.tum.de/doc/1320661/document.pdf

Definition at line 26 of file ParallelCouplingScheme.hpp.

Constructor & Destructor Documentation

◆ ParallelCouplingScheme() [1/2]

precice::cplscheme::ParallelCouplingScheme::ParallelCouplingScheme ( double maxTime,
int maxTimeWindows,
double timeWindowSize,
const std::string & firstParticipant,
const std::string & secondParticipant,
const std::string & localParticipant,
m2n::PtrM2N m2n,
constants::TimesteppingMethod dtMethod,
CouplingMode cplMode,
int minIterations,
int maxIterations )

Constructor.

Parameters
[in]maxTimeSimulation time limit, or UNDEFINED_MAX_TIME.
[in]maxTimeWindowsSimulation time windows limit, or UNDEFINED_TIME_WINDOWS.
[in]timeWindowSizeSimulation time window size.
[in]firstParticipantName of participant starting simulation.
[in]secondParticipantName of second participant in coupling.
[in]localParticipantName of participant using this coupling scheme.
[in]m2nCommunication object for com. between participants.
[in]dtMethodMethod used for determining the time window size, see https://www.precice.org/couple-your-code-timestep-sizes.html
[in]cplModeSet implicit or explicit coupling
[in]maxIterationsmaximum number of coupling iterations allowed for implicit coupling per time window

Definition at line 10 of file ParallelCouplingScheme.cpp.

◆ ParallelCouplingScheme() [2/2]

precice::cplscheme::ParallelCouplingScheme::ParallelCouplingScheme ( double maxTime,
int maxTimeWindows,
double timeWindowSize,
const std::string & firstParticipant,
const std::string & secondParticipant,
const std::string & localParticipant,
m2n::PtrM2N m2n,
constants::TimesteppingMethod dtMethod,
CouplingMode cplMode )

Definition at line 25 of file ParallelCouplingScheme.cpp.

Member Function Documentation

◆ exchangeFirstData()

void precice::cplscheme::ParallelCouplingScheme::exchangeFirstData ( )
finaloverrideprivatevirtual

Functions needed for advance()

Exchanges the first set of data

Implements precice::cplscheme::BaseCouplingScheme.

Definition at line 63 of file ParallelCouplingScheme.cpp.

Here is the call graph for this function:

◆ exchangeInitialData()

void precice::cplscheme::ParallelCouplingScheme::exchangeInitialData ( )
finaloverrideprivatevirtual

implements functionality for initialize in base class.

Implements precice::cplscheme::BaseCouplingScheme.

Definition at line 37 of file ParallelCouplingScheme.cpp.

Here is the call graph for this function:

◆ exchangeSecondData()

void precice::cplscheme::ParallelCouplingScheme::exchangeSecondData ( )
finaloverrideprivatevirtual

Exchanges the second set of data.

Implements precice::cplscheme::BaseCouplingScheme.

Definition at line 75 of file ParallelCouplingScheme.cpp.

Here is the call graph for this function:

◆ getAccelerationData()

DataMap & precice::cplscheme::ParallelCouplingScheme::getAccelerationData ( )
finaloverrideprivatevirtual

interface to provide accelerated data, depending on coupling scheme being used

Returns
data being accelerated

Implements precice::cplscheme::BaseCouplingScheme.

Definition at line 113 of file ParallelCouplingScheme.cpp.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ testing::ParallelCouplingSchemeFixture

Definition at line 27 of file ParallelCouplingScheme.hpp.

Member Data Documentation

◆ _log

logging::Logger precice::cplscheme::ParallelCouplingScheme::_log {"cplscheme::ParallelCouplingScheme"}
private

Definition at line 68 of file ParallelCouplingScheme.hpp.


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