|
preCICE v3.3.0
|
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 final override |
| 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 final override |
| returns list of all coupling partners | |
| bool | hasAnySendData () final override |
| 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 final override |
| Getter for _sendsInitializedData. | |
| bool | isInitialized () const final override |
| getter for _isInitialized | |
| bool | addComputedTime (double timeToAdd) final override |
| Adds newly computed time. Has to be called before every advance. | |
| bool | willDataBeExchanged (double lastSolverTimeStepSize) const final override |
| Returns true, if data will be exchanged when calling advance(). | |
| bool | hasDataBeenReceived () const final override |
| getter for _hasDataBeenReceived | |
| double | getTime () const final override |
| getter for _time | |
| double | getTimeWindowStart () const final override |
| double | getTimeWindowProgress () const |
| int | getTimeWindows () const final override |
| getter for _timeWindows | |
| bool | hasTimeWindowSize () const final override |
| Function to check whether time window size is defined by coupling scheme. | |
| double | getTimeWindowSize () const final override |
| Returns the time window size, if one is given by the coupling scheme. | |
| double | getNextTimeStepMaxSize () const final override |
| Returns the maximal size of the next time step to be computed. | |
| bool | isCouplingOngoing () const final override |
| Returns true, when the coupled simulation is still ongoing. | |
| bool | isTimeWindowComplete () const final override |
| Returns true, when the accessor can advance to the next time window. | |
| bool | isActionRequired (Action action) const final override |
| Returns true, if the given action has to be performed by the accessor. | |
| bool | isActionFulfilled (Action action) const final override |
| Returns true, if the given action has to be performed by the accessor. | |
| void | markActionFulfilled (Action action) final override |
| Tells the coupling scheme that the accessor has performed the given action. | |
| void | requireAction (Action action) final override |
| Sets an action required to be performed by the accessor. | |
| std::string | printCouplingState () const override |
| Returns coupling state information. | |
| void | finalize () final override |
| Finalizes the coupling scheme. | |
| void | initialize () final override |
| Initializes the coupling scheme and establishes a communication connection to the coupling partner. Initializes coupling data. | |
| void | reinitialize () final override |
| Reinitializes the coupling scheme, coupling data, and acceleration schemes. | |
| ChangedMeshes | firstSynchronization (const ChangedMeshes &changes) final override |
| void | firstExchange () final override |
| ChangedMeshes | secondSynchronization () final override |
| void | secondExchange () final override |
| void | addConvergenceMeasure (int dataID, bool suffices, bool strict, impl::PtrConvergenceMeasure measure) |
| 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 ()=default |
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 () final override |
| implements functionality for initialize in base class. | |
| void | exchangeFirstData () final override |
| Functions needed for advance() | |
| void | exchangeSecondData () final override |
| Exchanges the second set of data. | |
| DataMap & | getAccelerationData () final override |
| 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 () final override |
| Functions needed for initialize() | |
| Protected Member Functions inherited from precice::cplscheme::BaseCouplingScheme | |
| void | sendTimes (const m2n::PtrM2N &m2n, precice::span< double const > times) |
| void | sendData (const m2n::PtrM2N &m2n, const DataMap &sendData) |
| Sends data sendDataIDs given in mapCouplingData with communication. | |
| std::vector< double > | receiveTimes (const m2n::PtrM2N &m2n) |
| 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 final override |
| Returns true if any send data of the scheme requires substeps. | |
| std::string | localParticipant () const final override |
| Returns the name of the local participant. | |
| double | getWindowEndTime () const |
| double | getWindowStartTime () const |
| 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 ) |
|
finaloverrideprivatevirtual |
Functions needed for advance()
Exchanges the first set of data
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 121 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
implements functionality for initialize in base class.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 91 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
Exchanges the second set of data.
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 154 of file SerialCouplingScheme.cpp.
|
finaloverrideprivatevirtual |
interface to provide accelerated data, depending on coupling scheme being used
Implements precice::cplscheme::BaseCouplingScheme.
Definition at line 211 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 217 of file SerialCouplingScheme.cpp.
|
private |
Receives and sets the time window size, if this participant is the one to receive.
Definition at line 72 of file SerialCouplingScheme.cpp.
|
private |
Sends time window size, if this participant is the one to send.
Definition at line 61 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.