preCICE v3.1.2
|
A coupling scheme with multiple participants. More...
#include <MultiCouplingScheme.hpp>
Public Member Functions | |
MultiCouplingScheme (double maxTime, int maxTimeWindows, double timeWindowSize, const std::string &localParticipant, std::map< std::string, m2n::PtrM2N > m2ns, constants::TimesteppingMethod dtMethod, const std::string &controller, int minIterations, int maxIterations) | |
Constructor. | |
void | addDataToSend (const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps, const std::string &to) |
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, const std::string &from) |
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::string > | getCouplingPartners () const override final |
Returns list of all coupling partners. | |
bool | hasAnySendData () override final |
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 | |
CouplingScheme & | operator= (CouplingScheme &&)=delete |
virtual | ~CouplingScheme () |
Private Member Functions | |
void | exchangeFirstData () override final |
Functions needed for advance() | |
void | exchangeSecondData () override final |
Exchanges the second set of data. | |
DataMap & | getAccelerationData () override final |
interface to provide accelerated data, depending on coupling scheme being used | |
void | initializeReceiveDataStorage () override final |
Functions needed for initialize() | |
void | exchangeInitialData () override final |
implements functionality for initialize in base class. | |
Private Attributes | |
std::map< std::string, m2n::PtrM2N > | _m2ns |
A vector of m2ns. A m2n is a communication device to the other coupling participant. | |
std::map< std::string, DataMap > | _receiveDataVector |
A vector of all data to be received. | |
std::map< std::string, DataMap > | _sendDataVector |
A vector of all data to be sent. | |
logging::Logger | _log {"cplscheme::MultiCouplingScheme"} |
std::string | _controller |
name of the controller participant | |
bool | _isController |
if this is the controller or not | |
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::BaseCouplingScheme | |
void | sendNumberOfTimeSteps (const m2n::PtrM2N &m2n, const int numberOfTimeSteps) |
void | sendTimes (const m2n::PtrM2N &m2n, const Eigen::VectorXd ×) |
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. | |
std::string | localParticipant () const override final |
Returns the name of the local participant. | |
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. | |
A coupling scheme with multiple participants.
! General description A MultiCouplingScheme couples multiple participants in a fully implicit fashion. It is a specialization of BaseCouplingScheme.
Definition at line 26 of file MultiCouplingScheme.hpp.
precice::cplscheme::MultiCouplingScheme::MultiCouplingScheme | ( | double | maxTime, |
int | maxTimeWindows, | ||
double | timeWindowSize, | ||
const std::string & | localParticipant, | ||
std::map< std::string, m2n::PtrM2N > | m2ns, | ||
constants::TimesteppingMethod | dtMethod, | ||
const std::string & | controller, | ||
int | minIterations, | ||
int | maxIterations ) |
Constructor.
[in] | maxTime | Simulation time limit, or UNDEFINED_MAX_TIME. |
[in] | maxTimeWindows | Simulation time windows limit, or UNDEFINED_TIME_WINDOWS. |
[in] | timeWindowSize | Simulation time window size. |
[in] | localParticipant | Name of participant using this coupling scheme. |
[in] | m2ns | M2N communications to all other participants of coupling scheme. |
[in] | dtMethod | Method used for determining the time window size, see https://www.precice.org/couple-your-code-timestep-sizes.html |
[in] | maxIterations | maximum number of coupling sub-iterations allowed. |
Definition at line 22 of file MultiCouplingScheme.cpp.
void precice::cplscheme::MultiCouplingScheme::addDataToReceive | ( | const mesh::PtrData & | data, |
mesh::PtrMesh | mesh, | ||
bool | requiresInitialization, | ||
bool | exchangeSubsteps, | ||
const std::string & | from ) |
Adds data to be received on data exchange.
Definition at line 180 of file MultiCouplingScheme.cpp.
void precice::cplscheme::MultiCouplingScheme::addDataToSend | ( | const mesh::PtrData & | data, |
mesh::PtrMesh | mesh, | ||
bool | requiresInitialization, | ||
bool | exchangeSubsteps, | ||
const std::string & | to ) |
Adds data to be sent on data exchange and possibly be modified during coupling iterations.
Definition at line 168 of file MultiCouplingScheme.cpp.
|
overridevirtual |
Determines which data is initialized and therefore has to be exchanged during initialize.
Calls determineInitialSend and determineInitialReceive for all send and receive data of this coupling scheme.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 41 of file MultiCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
Functions needed for advance()
Exchanges the first set of data
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 121 of file MultiCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
implements functionality for initialize in base class.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 81 of file MultiCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
Exchanges the second set of data.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 140 of file MultiCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
interface to provide accelerated data, depending on coupling scheme being used
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 67 of file MultiCouplingScheme.cpp.
|
finaloverridevirtual |
Returns list of all coupling partners.
Implements precice::cplscheme::CouplingScheme.
Definition at line 51 of file MultiCouplingScheme.cpp.
|
finaloverridevirtual |
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 62 of file MultiCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
Functions needed for initialize()
Need to initialize receive data
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 73 of file MultiCouplingScheme.cpp.
|
private |
name of the controller participant
Definition at line 103 of file MultiCouplingScheme.hpp.
|
private |
if this is the controller or not
Definition at line 106 of file MultiCouplingScheme.hpp.
|
private |
Definition at line 88 of file MultiCouplingScheme.hpp.
|
private |
A vector of m2ns. A m2n is a communication device to the other coupling participant.
Definition at line 76 of file MultiCouplingScheme.hpp.
|
private |
A vector of all data to be received.
Definition at line 81 of file MultiCouplingScheme.hpp.
|
private |
A vector of all data to be sent.
Definition at line 86 of file MultiCouplingScheme.hpp.