preCICE v3.1.2
|
Coupling scheme for serial coupling, i.e. staggered execution of two coupled participants. More...
#include <SerialCouplingScheme.hpp>
Public Member Functions | |
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. | |
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) | |
ImplicitData | implicitDataToReceive () const override final |
Returns a vector of implicit data to receive in the next advance. | |
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::string > | getCouplingPartners () 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 | |
CouplingScheme & | operator= (CouplingScheme &&)=delete |
virtual | ~CouplingScheme () |
Private Member Functions | |
void | sendTimeWindowSize () |
Sends time window size, if this participant is the one to send. | |
void | receiveAndSetTimeWindowSize () |
Receives and sets the time window size, if this participant is the one to receive. | |
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. | |
DataMap & | getAccelerationData () override final |
interface to provide accelerated data, depending on coupling scheme being used | |
Private Attributes | |
logging::Logger | _log {"cplschemes::SerialCouplingSchemes"} |
bool | _participantSetsTimeWindowSize = false |
Determines, if the time window size is set by the participant. | |
bool | _participantReceivesTimeWindowSize = false |
Determines, if the time window size is received by the participant. | |
Friends | |
struct | testing::SerialCouplingSchemeFixture |
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 | |
DataMap & | getSendData () |
Returns all data to be sent. | |
DataMap & | getReceiveData () |
Returns all data to be received. | |
const DataMap & | getReceiveData () const |
Returns all data to be received. | |
CouplingData * | getSendData (DataID dataID) |
Sets the values. | |
CouplingData * | getReceiveData (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 ×) |
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. | |
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. | |
Coupling scheme for serial coupling, i.e. staggered 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 24 of file SerialCouplingScheme.hpp.
precice::cplscheme::SerialCouplingScheme::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.
[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] | firstParticipant | Name of participant starting simulation. |
[in] | secondParticipant | Name of second participant in coupling. |
[in] | localParticipant | Name of participant using this coupling scheme. |
[in] | m2n | Communication object for com. between participants. |
[in] | dtMethod | Method used for determining the time window size, see https://www.precice.org/couple-your-code-timestep-sizes.html |
[in] | cplMode | Set implicit or explicit coupling |
[in] | maxIterations | maximum number of coupling iterations allowed for implicit coupling per time window |
Definition at line 21 of file SerialCouplingScheme.cpp.
precice::cplscheme::SerialCouplingScheme::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 ) |
Definition at line 48 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
Functions needed for advance()
Exchanges the first set of data
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 119 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
implements functionality for initialize in base class.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 90 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
Exchanges the second set of data.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 148 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
interface to provide accelerated data, depending on coupling scheme being used
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 201 of file SerialCouplingScheme.cpp.
|
finaloverridevirtual |
Returns a vector of implicit data to receive in the next advance.
Reimplemented from precice::cplscheme::BaseCouplingScheme.
Definition at line 207 of file SerialCouplingScheme.cpp.
|
private |
Receives and sets the time window size, if this participant is the one to receive.
Definition at line 71 of file SerialCouplingScheme.cpp.
|
private |
Sends time window size, if this participant is the one to send.
Definition at line 60 of file SerialCouplingScheme.cpp.
|
friend |
Definition at line 25 of file SerialCouplingScheme.hpp.
|
private |
Definition at line 68 of file SerialCouplingScheme.hpp.
|
private |
Determines, if the time window size is received by the participant.
Definition at line 74 of file SerialCouplingScheme.hpp.
|
private |
Determines, if the time window size is set by the participant.
Definition at line 71 of file SerialCouplingScheme.hpp.