preCICE v3.2.0
Loading...
Searching...
No Matches
ParallelCouplingScheme.cpp
Go to the documentation of this file.
2
3#include <utility>
4
7
8namespace precice::cplscheme {
9
11 double maxTime,
12 int maxTimeWindows,
13 double timeWindowSize,
14 const std::string &firstParticipant,
15 const std::string &secondParticipant,
18 CouplingMode cplMode,
19 int minIterations,
20 int maxIterations)
21 : BiCouplingScheme(maxTime, maxTimeWindows, timeWindowSize, firstParticipant,
22 secondParticipant, localParticipant, std::move(m2n), minIterations, maxIterations, cplMode, constants::TimesteppingMethod::FIXED_TIME_WINDOW_SIZE) {}
23
25 double maxTime,
26 int maxTimeWindows,
27 double timeWindowSize,
28 const std::string &firstParticipant,
29 const std::string &secondParticipant,
32 CouplingMode cplMode)
33 : ParallelCouplingScheme(maxTime, maxTimeWindows, timeWindowSize, firstParticipant, secondParticipant, localParticipant, std::move(m2n), cplMode, UNDEFINED_MAX_ITERATIONS, UNDEFINED_MAX_ITERATIONS) {};
34
61
63{
65 if (doesFirstStep()) { // first participant
66 PRECICE_DEBUG("Sending data...");
68 } else { // second participant
69 PRECICE_DEBUG("Receiving data...");
72 }
73}
74
76{
79 if (doesFirstStep()) { // first participant
80 PRECICE_DEBUG("Receiving data...");
83 } else { // second participant
84 PRECICE_DEBUG("Sending data...");
86 }
88 } else {
90
91 if (doesFirstStep()) { // first participant
92 PRECICE_DEBUG("Receiving convergence data...");
94 PRECICE_DEBUG("Receiving data...");
97 } else { // second participant
98 PRECICE_DEBUG("Perform acceleration (only second participant)...");
100 PRECICE_DEBUG("Sending convergence...");
102 PRECICE_DEBUG("Sending data...");
104 }
105
106 if (hasConverged()) {
108 }
109
111 }
112}
113
115{
116 // ParallelCouplingScheme applies acceleration to all CouplingData
117 PRECICE_ASSERT(!doesFirstStep(), "Only the second participant should do the acceleration.");
118 return _allData;
119}
120
121} // namespace precice::cplscheme
#define PRECICE_DEBUG(...)
Definition LogMacros.hpp:61
#define PRECICE_ASSERT(...)
Definition assertion.hpp:85
void initializeWithZeroInitialData(const DataMap &receiveData)
Initializes storage in receiveData as zero.
void notifyDataHasBeenReceived()
Used to set flag after data has been received using receiveData().
bool isExplicitCouplingScheme() const
Function to determine whether coupling scheme is an explicit coupling scheme.
void sendData(const m2n::PtrM2N &m2n, const DataMap &sendData)
Sends data sendDataIDs given in mapCouplingData with communication.
void storeIteration()
used for storing all Data at end of doImplicitStep for later reference.
bool isImplicitCouplingScheme() const override
Function to determine whether coupling scheme is an implicit coupling scheme.
void sendConvergence(const m2n::PtrM2N &m2n)
sends convergence to other participant via m2n
bool hasConverged() const override
Checks if the implicit cplscheme has converged.
void moveToNextWindow()
finalizes this window's data and initializes data for next window.
void doImplicitStep()
perform a coupling iteration
double getTime() const final override
getter for _time
bool receivesInitializedData() const
Getter for _receivesInitializedData.
bool sendsInitializedData() const final override
Getter for _sendsInitializedData.
DataMap _allData
All send and receive data as a map "data ID -> data".
std::string localParticipant() const final override
Returns the name of the local participant.
void receiveConvergence(const m2n::PtrM2N &m2n)
receives convergence from other participant via m2n
void receiveData(const m2n::PtrM2N &m2n, const DataMap &receiveData)
Receives data receiveDataIDs given in mapCouplingData with communication.
bool doesFirstStep() const
Getter for _doesFirstStep.
DataMap & getSendData()
Returns all data to be sent.
DataMap & getReceiveData()
Returns all data to be received.
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)
static const int UNDEFINED_MAX_ITERATIONS
To be used, when the number of max iterations is not defined (for explicit coupling).
void exchangeSecondData() final override
Exchanges the second set of data.
void exchangeInitialData() final override
implements functionality for initialize in base class.
void exchangeFirstData() final override
Functions needed for advance()
DataMap & getAccelerationData() final override
interface to provide accelerated data, depending on coupling scheme being used
ParallelCouplingScheme(double maxTime, int maxTimeWindows, double timeWindowSize, const std::string &firstParticipant, const std::string &secondParticipant, const std::string &localParticipant, m2n::PtrM2N m2n, CouplingMode cplMode, int minIterations, int maxIterations)
Constructor.
contains implementations of coupling schemes for coupled simulations.
std::map< int, PtrCouplingData > DataMap
contains the logic of the parallel communication between participants.
Definition BoundM2N.cpp:12
std::shared_ptr< M2N > PtrM2N
constexpr bool equals(const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares two Eigen::MatrixBase for equality up to tolerance.
STL namespace.