1#include <boost/range/adaptor/map.hpp>
24 double timeWindowSize,
33 :
BiCouplingScheme(maxTime, maxTimeWindows, timeWindowSize, firstParticipant, secondParticipant,
localParticipant,
std::move(
m2n), minIterations, maxIterations, cplMode, dtMethod)
52 double timeWindowSize,
59 :
SerialCouplingScheme(maxTime, maxTimeWindows, timeWindowSize, firstParticipant, secondParticipant,
localParticipant,
std::move(
m2n), dtMethod, cplMode,
UNDEFINED_MAX_ITERATIONS,
UNDEFINED_MAX_ITERATIONS) {};
84 PRECICE_CHECK(dt ==
getTimeWindowSize(),
"May only use a larger time window size in the first iteration of the window. Otherwise old time window size must equal new time window size.");
143 PRECICE_DEBUG(
"Perform acceleration (only second participant)...");
226 for (
auto cpldata :
getReceiveData() | boost::adaptors::map_values) {
227 idata.
add(cpldata->getDataID(), isSecond);
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
bool hasTimeWindowSize() const final override
Function to check whether time window size is defined by coupling scheme.
void initializeWithZeroInitialData(const DataMap &receiveData)
Initializes storage in receiveData as zero.
bool isCouplingOngoing() const final override
Returns true, when the coupled simulation is still ongoing.
void setTimeWindowSize(double timeWindowSize)
Setter for _timeWindowSize.
void receiveDataForWindowEnd(const m2n::PtrM2N &m2n, const DataMap &receiveData)
Like receiveData, but temporarily sets window time to end of window.
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
double getTimeWindowSize() const final override
Returns the time window size, if one is given by the coupling scheme.
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.
double getWindowStartTime() const
double getWindowEndTime() const
double getNextTimeWindowSize() const
Getter for _nextTimeWindowSize.
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 setNextTimeWindowSize(double timeWindowSize)
Setter for _nextTimeWindowSize.
void receiveData(const m2n::PtrM2N &m2n, const DataMap &receiveData)
Receives data receiveDataIDs given in mapCouplingData with communication.
bool doesFirstStep() const
Getter for _doesFirstStep.
double getTimeWindowStart() const final override
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)
m2n::PtrM2N getM2N() const
static const int UNDEFINED_MAX_ITERATIONS
To be used, when the number of max iterations is not defined (for explicit coupling).
static const double UNDEFINED_TIME_WINDOW_SIZE
To be used, when the time window size is determined dynamically during the coupling.
DataMap & getAccelerationData() final override
interface to provide accelerated data, depending on coupling scheme being used
void receiveAndSetTimeWindowSize()
Receives and sets the time window size, if this participant is the one to receive.
void exchangeInitialData() final override
implements functionality for initialize in base class.
bool _participantSetsTimeWindowSize
Determines, if the time window size is set by the participant.
void exchangeSecondData() final override
Exchanges the second set of data.
void exchangeFirstData() final override
Functions needed for advance()
void sendTimeWindowSize()
Sends time window size, if this participant is the one to send.
SerialCouplingScheme(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.
ImplicitData implicitDataToReceive() const final override
Returns a vector of implicit data to receive in the next advance.
bool _participantReceivesTimeWindowSize
Determines, if the time window size is received by the participant.
@ FIRST_PARTICIPANT_SETS_TIME_WINDOW_SIZE
contains implementations of coupling schemes for coupled simulations.
std::map< int, PtrCouplingData > DataMap
contains the logic of the parallel communication between participants.
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.
void add(DataID did, bool toKeep)