preCICE v3.1.1
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,
16 const std::string & localParticipant,
17 m2n::PtrM2N m2n,
19 CouplingMode cplMode,
20 int minIterations,
21 int maxIterations)
22 : BiCouplingScheme(maxTime, maxTimeWindows, timeWindowSize, firstParticipant,
23 secondParticipant, localParticipant, std::move(m2n), minIterations, maxIterations, cplMode, dtMethod) {}
24
26 double maxTime,
27 int maxTimeWindows,
28 double timeWindowSize,
29 const std::string & firstParticipant,
30 const std::string & secondParticipant,
31 const std::string & localParticipant,
32 m2n::PtrM2N m2n,
34 CouplingMode cplMode)
35 : ParallelCouplingScheme(maxTime, maxTimeWindows, timeWindowSize, firstParticipant, secondParticipant, localParticipant, std::move(m2n), dtMethod, cplMode, UNDEFINED_MAX_ITERATIONS, UNDEFINED_MAX_ITERATIONS){};
36
38{
39 // F: send, receive, S: receive, send
40 if (doesFirstStep()) {
43 }
47 } else {
49 }
50 } else { // second participant
54 } else {
56 }
59 }
60 }
61}
62
64{
65 if (doesFirstStep()) { // first participant
66 PRECICE_DEBUG("Sending data...");
68 } else { // second participant
69 PRECICE_DEBUG("Receiving data...");
72 }
73}
74
76{
78 if (doesFirstStep()) { // first participant
79 PRECICE_DEBUG("Receiving data...");
82 } else { // second participant
83 PRECICE_DEBUG("Sending data...");
85 }
87 } else {
89
90 if (doesFirstStep()) { // first participant
91 PRECICE_DEBUG("Receiving convergence data...");
93 PRECICE_DEBUG("Receiving data...");
96 } else { // second participant
97 PRECICE_DEBUG("Perform acceleration (only second participant)...");
99 PRECICE_DEBUG("Sending convergence...");
101 PRECICE_DEBUG("Sending data...");
103 }
104
105 if (hasConverged()) {
107 }
108
110 }
111}
112
114{
115 // ParallelCouplingScheme applies acceleration to all CouplingData
116 PRECICE_ASSERT(!doesFirstStep(), "Only the second participant should do the acceleration.");
117 return _allData;
118}
119
120} // namespace precice::cplscheme
#define PRECICE_DEBUG(...)
Definition LogMacros.hpp:64
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
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 sendsInitializedData() const override final
Getter for _sendsInitializedData.
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
bool receivesInitializedData() const
Getter for _receivesInitializedData.
DataMap _allData
All send and receive data as a map "data ID -> data".
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.
Abstract base class for coupling schemes with two participants.
DataMap & getSendData()
Returns all data to be sent.
DataMap & getReceiveData()
Returns all data to be received.
Coupling scheme for parallel coupling, i.e. simultaneous execution of two coupled participants.
void exchangeFirstData() override final
Functions needed for advance()
DataMap & getAccelerationData() override final
interface to provide accelerated data, depending on coupling scheme being used
void exchangeInitialData() override final
implements functionality for initialize in base class.
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.
void exchangeSecondData() override final
Exchanges the second set of data.
contains implementations of coupling schemes for coupled simulations.
STL namespace.