preCICE v3.1.2
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
precice::cplscheme::BaseCouplingScheme Class Referenceabstract

Abstract base class for standard coupling schemes. More...

#include <BaseCouplingScheme.hpp>

Inheritance diagram for precice::cplscheme::BaseCouplingScheme:
[legend]
Collaboration diagram for precice::cplscheme::BaseCouplingScheme:
[legend]

Classes

struct  ConvergenceMeasureContext
 Holds meta information to perform a convergence measurement. More...
 

Public Types

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>
 

Public Member Functions

 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.
 
virtual bool hasAnySendData ()=0
 
virtual void determineInitialDataExchange ()=0
 Determines which data is initialized and therefore has to be exchanged during initialize.
 
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
CouplingSchemeoperator= (CouplingScheme &&)=delete
 
virtual ~CouplingScheme ()
 
virtual std::vector< std::stringgetCouplingPartners () const =0
 Returns list of all coupling partners.
 

Protected Member Functions

void sendNumberOfTimeSteps (const m2n::PtrM2N &m2n, const int numberOfTimeSteps)
 
void sendTimes (const m2n::PtrM2N &m2n, const Eigen::VectorXd &times)
 
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.
 
ImplicitData implicitDataToReceive () const override
 Returns a vector of implicit data to receive in the next advance.
 
std::string localParticipant () const override final
 Returns the name of the local participant.
 

Protected Attributes

DataMap _allData
 All send and receive data as a map "data ID -> data".
 
acceleration::PtrAcceleration _acceleration
 Acceleration method to speedup iteration convergence.
 

Private Member Functions

virtual void initializeReceiveDataStorage ()=0
 Functions needed for initialize()
 
virtual void exchangeInitialData ()=0
 implements functionality for initialize in base class.
 
virtual void exchangeFirstData ()=0
 Functions needed for advance()
 
virtual void exchangeSecondData ()=0
 Exchanges the second set of data.
 
virtual DataMapgetAccelerationData ()=0
 interface to provide accelerated data, depending on coupling scheme being used
 
void checkCompletenessRequiredActions ()
 If any required actions are open, an error message is issued.
 
void initializeTXTWriters ()
 Initialize txt writers for iterations and convergence tracking.
 
void advanceTXTWriters ()
 Advance txt writers for iterations and convergence tracking.
 
std::string printBasicState (int timeWindows, double time) const
 Prints the coupling state.
 
std::string printActionsState () const
 Prints the action state.
 
bool measureConvergence ()
 Measure whether coupling scheme has converged or not.
 
void newConvergenceMeasurements ()
 Reset all convergence measurements after convergence.
 
bool anyDataRequiresInitialization (DataMap &dataMap) const
 Checks whether any CouplingData in dataMap requires initialization.
 
double getWindowEndTime () const
 
double getWindowStartTime () const
 

Private Attributes

CouplingMode _couplingMode = Undefined
 Coupling mode used by coupling scheme.
 
logging::Logger _log {"cplscheme::BaseCouplingScheme"}
 
double _maxTime
 Maximum time being computed. End of simulation is reached, if getTime() == _maxTime.
 
int _maxTimeWindows
 Number of time windows that have to be computed. End of simulation is reached, if _timeWindows == _maxTimeWindows.
 
int _timeWindows = 0
 number of completed time windows; _timeWindows <= _maxTimeWindows
 
double _timeWindowSize = UNDEFINED_TIME_WINDOW_SIZE
 size of time window; _timeWindowSize <= _maxTime
 
double _nextTimeWindowSize = UNDEFINED_TIME_WINDOW_SIZE
 time window size of next window (acts as buffer for time windows size provided by first participant, if using first participant method)
 
impl::TimeHandler _time
 Time handler.
 
int _minIterations = -1
 Lower limit of iterations during one time window. Prevents convergence if _iterations < _minIterations.
 
int _maxIterations = -1
 Limit of iterations during one time window. Continue to next time window, if _iterations == _maxIterations.
 
int _iterations = -1
 Number of iterations in current time window. _iterations <= _maxIterations.
 
int _totalIterations = -1
 Number of total iterations performed.
 
bool _doesFirstStep = false
 True, if local participant is the one starting the explicit scheme.
 
bool _isTimeWindowComplete = false
 True, if _time == _timeWindowStartTime + _timeWindowSize and (coupling has converged or _iterations == _maxIterations)
 
bool _sendsInitializedData = false
 True, if this participant has to send initialized data.
 
bool _receivesInitializedData = false
 True, if this participant has to receive initialized data.
 
bool _hasDataBeenReceived = false
 True, if data has been received from other participant. Flag is used to make sure that coupling scheme is implemented and used correctly.
 
bool _isInitialized = false
 True, if coupling has been initialized.
 
std::set< Action_requiredActions
 
std::set< Action_fulfilledActions
 
bool _hasConverged = false
 True if implicit scheme converged.
 
std::shared_ptr< io::TXTTableWriter_iterationsWriter
 Responsible for monitoring iteration count over time window.
 
std::shared_ptr< io::TXTTableWriter_convergenceWriter
 Writes out coupling convergence within all time windows.
 
std::string _localParticipant = "unknown"
 Local participant name.
 
std::vector< ConvergenceMeasureContext_convergenceMeasures
 All convergence measures of coupling iterations.
 

Additional Inherited Members

- 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).
 

Detailed Description

Abstract base class for standard coupling schemes.

! General description A coupling scheme computes the actions to be done by the coupled participants (solvers) in time. It provides interface functions to setup, advance and shutdown the coupling scheme and interface functions to query the state of the coupling scheme and required actions of the participants.

! Usage

  1. create an object of a concrete coupling scheme class (ExplicitCouplingScheme, e.g.)
  2. add all meshes holding data to the coupling scheme by addMesh()
  3. configure the object by adding subclass specific information
  4. start the coupling scheme with initialize(), where the name of the local participant, i.e. the participant using the coupling scheme object, is needed
  5. retrieve necessary information about sent/received data and the state of the coupled simulation
  6. query actions and mark them as fulfilled
  7. compute data to be sent (possibly taking into account received data from initialize())
  8. advance the coupling scheme with advance(); where the maximum time step size (= time window size) needs to be obeyed
  9. ....
  10. when the method isCouplingOngoing() returns false, call finalize() to stop the coupling scheme

Definition at line 61 of file BaseCouplingScheme.hpp.

Member Enumeration Documentation

◆ CouplingMode

Enumerator
Explicit 
Implicit 
Undefined 

Definition at line 63 of file BaseCouplingScheme.hpp.

Constructor & Destructor Documentation

◆ BaseCouplingScheme()

precice::cplscheme::BaseCouplingScheme::BaseCouplingScheme ( double maxTime,
int maxTimeWindows,
double timeWindowSize,
std::string localParticipant,
int minIterations,
int maxIterations,
CouplingMode cplMode,
constants::TimesteppingMethod dtMethod )

Definition at line 33 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addComputedTime()

bool precice::cplscheme::BaseCouplingScheme::addComputedTime ( double timeToAdd)
finaloverridevirtual

Adds newly computed time. Has to be called before every advance.

Parameters
timeToAddtime to be added
Returns
true, if reaches end of the window by adding timeToAdd to time in this time step.

Implements precice::cplscheme::CouplingScheme.

Definition at line 423 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ addConvergenceMeasure()

void precice::cplscheme::BaseCouplingScheme::addConvergenceMeasure ( int dataID,
bool suffices,
bool strict,
impl::PtrConvergenceMeasure measure,
bool doesLogging )

Adds a measure to determine the convergence of coupling iterations.

Definition at line 635 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ addCouplingData()

PtrCouplingData precice::cplscheme::BaseCouplingScheme::addCouplingData ( const mesh::PtrData & data,
mesh::PtrMesh mesh,
bool requiresInitialization,
bool exchangeSubsteps,
CouplingData::Direction direction )
protected

Adds CouplingData with given properties to this BaseCouplingScheme and returns a pointer to the CouplingData.

If CouplingData with ID of provided data already exists in coupling scheme, no duplicate is created but a pointer to the already existing CouplingData is returned.

Parameters
datadata the CouplingData is associated with
meshmesh the CouplingData is associated with
requiresInitializationtrue, if CouplingData requires initialization
exchangeSubstepstrue, if CouplingData exchanges all substeps in send/recv
directionis the coupling data send or received?
Returns
PtrCouplingData pointer to CouplingData owned by the CouplingScheme

Definition at line 233 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ advanceTXTWriters()

void precice::cplscheme::BaseCouplingScheme::advanceTXTWriters ( )
private

Advance txt writers for iterations and convergence tracking.

Definition at line 748 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ anyDataRequiresInitialization()

bool precice::cplscheme::BaseCouplingScheme::anyDataRequiresInitialization ( DataMap & dataMap) const
private

Checks whether any CouplingData in dataMap requires initialization.

Parameters
dataMapmap containing CouplingData
Returns
true, if any CouplingData in dataMap requires initialization
Todo
implement this function using https://en.cppreference.com/w/cpp/algorithm/all_any_none_of

Definition at line 798 of file BaseCouplingScheme.cpp.

◆ checkCompletenessRequiredActions()

void precice::cplscheme::BaseCouplingScheme::checkCompletenessRequiredActions ( )
private

If any required actions are open, an error message is issued.

Definition at line 591 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ determineInitialDataExchange()

virtual void precice::cplscheme::BaseCouplingScheme::determineInitialDataExchange ( )
pure virtual

Determines which data is initialized and therefore has to be exchanged during initialize.

Calls determineInitialSend and determineInitialReceive for all send and receive data of this coupling scheme.

Implemented in precice::cplscheme::BiCouplingScheme, and precice::cplscheme::MultiCouplingScheme.

◆ determineInitialReceive()

void precice::cplscheme::BaseCouplingScheme::determineInitialReceive ( DataMap & receiveData)
protected

Sets _receivesInitializedData, if receiveData requires initialization.

Parameters
receiveDataCouplingData being checked

Definition at line 791 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ determineInitialSend()

void precice::cplscheme::BaseCouplingScheme::determineInitialSend ( DataMap & sendData)
protected

Sets _sendsInitializedData, if sendData requires initialization.

Parameters
sendDataCouplingData being checked

Definition at line 783 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ doesFirstStep()

bool precice::cplscheme::BaseCouplingScheme::doesFirstStep ( ) const

Getter for _doesFirstStep.

Returns
_doesFirstStep

Definition at line 621 of file BaseCouplingScheme.cpp.

◆ doImplicitStep()

void precice::cplscheme::BaseCouplingScheme::doImplicitStep ( )
protected

perform a coupling iteration

See also
hasConverged

This function is called from the child classes

Definition at line 809 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ exchangeFirstData()

virtual void precice::cplscheme::BaseCouplingScheme::exchangeFirstData ( )
privatepure virtual

Functions needed for advance()

Exchanges the first set of data

Implemented in precice::cplscheme::MultiCouplingScheme, precice::cplscheme::ParallelCouplingScheme, and precice::cplscheme::SerialCouplingScheme.

◆ exchangeInitialData()

virtual void precice::cplscheme::BaseCouplingScheme::exchangeInitialData ( )
privatepure virtual

implements functionality for initialize in base class.

Implemented in precice::cplscheme::MultiCouplingScheme, precice::cplscheme::ParallelCouplingScheme, and precice::cplscheme::SerialCouplingScheme.

◆ exchangeSecondData()

virtual void precice::cplscheme::BaseCouplingScheme::exchangeSecondData ( )
privatepure virtual

◆ finalize()

void precice::cplscheme::BaseCouplingScheme::finalize ( )
finaloverridevirtual

Finalizes the coupling scheme.

Implements precice::cplscheme::CouplingScheme.

Definition at line 263 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ firstExchange()

void precice::cplscheme::BaseCouplingScheme::firstExchange ( )
finaloverridevirtual

Exchanges the first set of data.

Precondition
firstSynchronization() was called

Implements precice::cplscheme::CouplingScheme.

Definition at line 311 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ firstSynchronization()

CouplingScheme::ChangedMeshes precice::cplscheme::BaseCouplingScheme::firstSynchronization ( const ChangedMeshes & changes)
finaloverridevirtual

Synchronizes mesh changes with remote participants.

At this point, both participants may have changed the meshes. Thus, we need to send local changes and receive remote changes.

Parameters
[in]changesMeshIDs of locally changed meshes
Returns
MeshIDs of remotely changed meshes.

Implements precice::cplscheme::CouplingScheme.

Definition at line 305 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ getAccelerationData()

virtual DataMap & precice::cplscheme::BaseCouplingScheme::getAccelerationData ( )
privatepure virtual

interface to provide accelerated data, depending on coupling scheme being used

Returns
data being accelerated

Implemented in precice::cplscheme::MultiCouplingScheme, precice::cplscheme::ParallelCouplingScheme, and precice::cplscheme::SerialCouplingScheme.

◆ getNextTimeStepMaxSize()

double precice::cplscheme::BaseCouplingScheme::getNextTimeStepMaxSize ( ) const
finaloverridevirtual

Returns the maximal size of the next time step to be computed.

If no time window size is prescribed by the coupling scheme, always the maximal double accuracy floating point number value is returned.

Implements precice::cplscheme::CouplingScheme.

Definition at line 493 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ getNextTimeWindowSize()

double precice::cplscheme::BaseCouplingScheme::getNextTimeWindowSize ( ) const
protected

Getter for _nextTimeWindowSize.

Parameters
timeWindowSize

Definition at line 413 of file BaseCouplingScheme.cpp.

◆ getTime()

double precice::cplscheme::BaseCouplingScheme::getTime ( ) const
finaloverridevirtual

getter for _time

Returns
the currently computed time of the coupling scheme.

Implements precice::cplscheme::CouplingScheme.

Definition at line 478 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ getTimeWindows()

int precice::cplscheme::BaseCouplingScheme::getTimeWindows ( ) const
finaloverridevirtual

getter for _timeWindows

Returns
the number of currently computed time windows of the coupling scheme.

Implements precice::cplscheme::CouplingScheme.

Definition at line 488 of file BaseCouplingScheme.cpp.

◆ getTimeWindowSize()

double precice::cplscheme::BaseCouplingScheme::getTimeWindowSize ( ) const
finaloverridevirtual

Returns the time window size, if one is given by the coupling scheme.

An assertion is thrown, if no valid time window size is given. Check with hasTimeWindowSize().

Implements precice::cplscheme::CouplingScheme.

Definition at line 407 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ getTimeWindowStart()

double precice::cplscheme::BaseCouplingScheme::getTimeWindowStart ( ) const
finaloverridevirtual

Returns the time window start time of the current time window For compositional schemes, this returns the earliest start of an active time window

Implements precice::cplscheme::CouplingScheme.

Definition at line 483 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ getWindowEndTime()

double precice::cplscheme::BaseCouplingScheme::getWindowEndTime ( ) const
private
Returns
the end of the time window, defined as timeWindowStart + timeWindowSize

Definition at line 866 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ getWindowStartTime()

double precice::cplscheme::BaseCouplingScheme::getWindowStartTime ( ) const
private
Returns
the start of the time window

Definition at line 861 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ hasAnySendData()

virtual bool precice::cplscheme::BaseCouplingScheme::hasAnySendData ( )
pure virtual
Returns
true, if coupling scheme has any sendData

Implemented in precice::cplscheme::BiCouplingScheme, and precice::cplscheme::MultiCouplingScheme.

◆ hasConverged()

bool precice::cplscheme::BaseCouplingScheme::hasConverged ( ) const
overridevirtual

Checks if the implicit cplscheme has converged.

Precondition
doImplicitStep() or receiveConvergence() has been called

Implements precice::cplscheme::CouplingScheme.

Definition at line 96 of file BaseCouplingScheme.cpp.

◆ hasDataBeenReceived()

bool precice::cplscheme::BaseCouplingScheme::hasDataBeenReceived ( ) const
finaloverridevirtual

getter for _hasDataBeenReceived

Returns
true, if data has been received in last call of advance().

Implements precice::cplscheme::CouplingScheme.

Definition at line 452 of file BaseCouplingScheme.cpp.

◆ hasTimeWindowSize()

bool precice::cplscheme::BaseCouplingScheme::hasTimeWindowSize ( ) const
finaloverridevirtual

Function to check whether time window size is defined by coupling scheme.

There are two reasons why a scheme might have a time window size: 1) a fixed time window size is given in the scheme 2) the participant received the time window size from another participant in the scheme

Returns
true, if time window size is available.

Implements precice::cplscheme::CouplingScheme.

Definition at line 402 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ implicitDataToReceive()

ImplicitData precice::cplscheme::BaseCouplingScheme::implicitDataToReceive ( ) const
overrideprotectedvirtual

Returns a vector of implicit data to receive in the next advance.

Implements precice::cplscheme::CouplingScheme.

Reimplemented in precice::cplscheme::SerialCouplingScheme.

Definition at line 882 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ initialize()

void precice::cplscheme::BaseCouplingScheme::initialize ( double startTime,
int startTimeWindow )
finaloverridevirtual

Initializes the coupling scheme.

Parameters
[in]startTimestarting time of coupling scheme
[in]startTimeWindowstarting counter of time window, from which coupling scheme starts

Implements precice::cplscheme::CouplingScheme.

Definition at line 270 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ initializeReceiveDataStorage()

virtual void precice::cplscheme::BaseCouplingScheme::initializeReceiveDataStorage ( )
privatepure virtual

Functions needed for initialize()

Need to initialize receive data

Implemented in precice::cplscheme::BiCouplingScheme, and precice::cplscheme::MultiCouplingScheme.

◆ initializeTXTWriters()

void precice::cplscheme::BaseCouplingScheme::initializeTXTWriters ( )
private

Initialize txt writers for iterations and convergence tracking.

Definition at line 713 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ initializeWithZeroInitialData()

void precice::cplscheme::BaseCouplingScheme::initializeWithZeroInitialData ( const DataMap & receiveData)
protected

Initializes storage in receiveData as zero.

Parameters
receiveDataDataMap associated with received data

Definition at line 224 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ isActionFulfilled()

bool precice::cplscheme::BaseCouplingScheme::isActionFulfilled ( Action action) const
finaloverridevirtual

Returns true, if the given action has to be performed by the accessor.

Implements precice::cplscheme::CouplingScheme.

Definition at line 523 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ isActionRequired()

bool precice::cplscheme::BaseCouplingScheme::isActionRequired ( Action action) const
finaloverridevirtual

Returns true, if the given action has to be performed by the accessor.

Implements precice::cplscheme::CouplingScheme.

Definition at line 517 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ isCouplingOngoing()

bool precice::cplscheme::BaseCouplingScheme::isCouplingOngoing ( ) const
finaloverridevirtual

Returns true, when the coupled simulation is still ongoing.

Implements precice::cplscheme::CouplingScheme.

Definition at line 506 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ isExplicitCouplingScheme()

bool precice::cplscheme::BaseCouplingScheme::isExplicitCouplingScheme ( ) const
protected

Function to determine whether coupling scheme is an explicit coupling scheme.

Returns
true, if coupling scheme is explicit

Definition at line 247 of file BaseCouplingScheme.cpp.

◆ isImplicitCouplingScheme()

bool precice::cplscheme::BaseCouplingScheme::isImplicitCouplingScheme ( ) const
overridevirtual

Function to determine whether coupling scheme is an implicit coupling scheme.

Returns
true, if coupling scheme is implicit

Implements precice::cplscheme::CouplingScheme.

Definition at line 90 of file BaseCouplingScheme.cpp.

◆ isInitialized()

bool precice::cplscheme::BaseCouplingScheme::isInitialized ( ) const
finaloverridevirtual

getter for _isInitialized

Returns
true, if initialize has been called.

Implements precice::cplscheme::CouplingScheme.

Definition at line 418 of file BaseCouplingScheme.cpp.

◆ isTimeWindowComplete()

bool precice::cplscheme::BaseCouplingScheme::isTimeWindowComplete ( ) const
finaloverridevirtual

Returns true, when the accessor can advance to the next time window.

Implements precice::cplscheme::CouplingScheme.

Definition at line 512 of file BaseCouplingScheme.cpp.

◆ localParticipant()

std::string precice::cplscheme::BaseCouplingScheme::localParticipant ( ) const
finaloverrideprotectedvirtual

Returns the name of the local participant.

Implements precice::cplscheme::CouplingScheme.

Definition at line 898 of file BaseCouplingScheme.cpp.

◆ markActionFulfilled()

void precice::cplscheme::BaseCouplingScheme::markActionFulfilled ( Action action)
finaloverridevirtual

Tells the coupling scheme that the accessor has performed the given action.

Implements precice::cplscheme::CouplingScheme.

Definition at line 529 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ measureConvergence()

bool precice::cplscheme::BaseCouplingScheme::measureConvergence ( )
private

Measure whether coupling scheme has converged or not.

Returns
Whether coupling scheme has converged

Definition at line 652 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ moveToNextWindow()

void precice::cplscheme::BaseCouplingScheme::moveToNextWindow ( )
protected

finalizes this window's data and initializes data for next window.

Definition at line 394 of file BaseCouplingScheme.cpp.

◆ newConvergenceMeasurements()

void precice::cplscheme::BaseCouplingScheme::newConvergenceMeasurements ( )
private

Reset all convergence measurements after convergence.

Definition at line 626 of file BaseCouplingScheme.cpp.

◆ notifyDataHasBeenReceived()

void precice::cplscheme::BaseCouplingScheme::notifyDataHasBeenReceived ( )
protected

Used to set flag after data has been received using receiveData().

Definition at line 462 of file BaseCouplingScheme.cpp.

◆ printActionsState()

std::string precice::cplscheme::BaseCouplingScheme::printActionsState ( ) const
private

Prints the action state.

Returns
a string representing the required actions.

Definition at line 582 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ printBasicState()

std::string precice::cplscheme::BaseCouplingScheme::printBasicState ( int timeWindows,
double time ) const
private

Prints the coupling state.

Parameters
timeWindowscurrent number of completed time windows
timecurrent time

Definition at line 556 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ printCouplingState()

std::string precice::cplscheme::BaseCouplingScheme::printCouplingState ( ) const
overridevirtual

Returns coupling state information.

Includes current iteration, max iterations, time, time window and action.

Implements precice::cplscheme::CouplingScheme.

Definition at line 542 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ reachedEndOfTimeWindow()

bool precice::cplscheme::BaseCouplingScheme::reachedEndOfTimeWindow ( ) const
protected

Function to check whether end of time window is reached. Does not check for convergence.

Returns
true if end time of time window is reached or if this participant defines time window size (participant first method)

Definition at line 766 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ receiveConvergence()

void precice::cplscheme::BaseCouplingScheme::receiveConvergence ( const m2n::PtrM2N & m2n)
protected

receives convergence from other participant via m2n

Parameters
m2nused for receiving
Returns
convergence bool

Definition at line 854 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ receiveData()

void precice::cplscheme::BaseCouplingScheme::receiveData ( const m2n::PtrM2N & m2n,
const DataMap & receiveData )
protected

Receives data receiveDataIDs given in mapCouplingData with communication.

Parameters
m2nM2N used for communication
receiveDataDataMap associated with received data

Definition at line 174 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ receiveDataForWindowEnd()

void precice::cplscheme::BaseCouplingScheme::receiveDataForWindowEnd ( const m2n::PtrM2N & m2n,
const DataMap & receiveData )
protected

Like receiveData, but temporarily sets window time to end of window.

This function is only needed for SerialCouplingScheme, if substeps="false". Here, a special situation arises for the second participant, because it receives data for the end of the window from the first participant: If substeps="false" only values without timestamps are exchanged. Therefore, getTime() is used to determine the time associated with the values. However, getTime() of the second participant points to the beginning of the window, if we enter a new window. We need to temporarily modify the return value of getTime() to point to the end of the window to be able to store the values at the correct point in time.

Note: This function could be removed by a) removing the option to turn off exchange of substeps or by b) refactoring the communication such that sent/received values always carry a timestamp.

Parameters
m2nM2N used for communication
receiveDataDataMap associated with received data

Definition at line 211 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ receiveNumberOfTimeSteps()

int precice::cplscheme::BaseCouplingScheme::receiveNumberOfTimeSteps ( const m2n::PtrM2N & m2n)
protected

Definition at line 155 of file BaseCouplingScheme.cpp.

◆ receivesInitializedData()

bool precice::cplscheme::BaseCouplingScheme::receivesInitializedData ( ) const
protected

Getter for _receivesInitializedData.

Returns
_receivesInitializedData

Definition at line 468 of file BaseCouplingScheme.cpp.

◆ receiveTimes()

Eigen::VectorXd precice::cplscheme::BaseCouplingScheme::receiveTimes ( const m2n::PtrM2N & m2n,
int nTimeSteps )
protected

Definition at line 164 of file BaseCouplingScheme.cpp.

◆ requireAction()

void precice::cplscheme::BaseCouplingScheme::requireAction ( Action action)
finaloverridevirtual

Sets an action required to be performed by the accessor.

Implements precice::cplscheme::CouplingScheme.

Definition at line 536 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ requiresSubsteps()

bool precice::cplscheme::BaseCouplingScheme::requiresSubsteps ( ) const
finaloverrideprotectedvirtual

Returns true if any send data of the scheme requires substeps.

Implements precice::cplscheme::CouplingScheme.

Definition at line 871 of file BaseCouplingScheme.cpp.

◆ secondExchange()

void precice::cplscheme::BaseCouplingScheme::secondExchange ( )
finaloverridevirtual

Exchanges the second set of data.

This concludes the step of the coupling scheme

Precondition
secondSynchronization() was called

Implements precice::cplscheme::CouplingScheme.

Definition at line 334 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ secondSynchronization()

CouplingScheme::ChangedMeshes precice::cplscheme::BaseCouplingScheme::secondSynchronization ( )
finaloverridevirtual

Receive mesh changes from remote participants in the second step.

At this point, the remote participant may have changed the meshes if it is using a serial coupling scheme. In contrast, the local participant has already communicated local changes to the remote participant during firstSynchronization(). Hence we only need to receive remote changes here.

Note
local changes are covered by firstSynchronization()
Returns
MeshIDs of remotely changed meshes.
Precondition
firstExchange() was called

Implements precice::cplscheme::CouplingScheme.

Definition at line 329 of file BaseCouplingScheme.cpp.

◆ sendConvergence()

void precice::cplscheme::BaseCouplingScheme::sendConvergence ( const m2n::PtrM2N & m2n)
protected

sends convergence to other participant via m2n

Parameters
m2nused for sending

Definition at line 847 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ sendData()

void precice::cplscheme::BaseCouplingScheme::sendData ( const m2n::PtrM2N & m2n,
const DataMap & sendData )
protected

Sends data sendDataIDs given in mapCouplingData with communication.

Parameters
m2nM2N used for communication
sendDataDataMap associated with sent data

Definition at line 115 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ sendNumberOfTimeSteps()

void precice::cplscheme::BaseCouplingScheme::sendNumberOfTimeSteps ( const m2n::PtrM2N & m2n,
const int numberOfTimeSteps )
protected

Definition at line 101 of file BaseCouplingScheme.cpp.

◆ sendsInitializedData()

bool precice::cplscheme::BaseCouplingScheme::sendsInitializedData ( ) const
finaloverridevirtual

Getter for _sendsInitializedData.

Returns
_sendsInitializedData

Implements precice::cplscheme::CouplingScheme.

Definition at line 300 of file BaseCouplingScheme.cpp.

◆ sendTimes()

void precice::cplscheme::BaseCouplingScheme::sendTimes ( const m2n::PtrM2N & m2n,
const Eigen::VectorXd & times )
protected

Definition at line 108 of file BaseCouplingScheme.cpp.

◆ setAcceleration()

void precice::cplscheme::BaseCouplingScheme::setAcceleration ( const acceleration::PtrAcceleration & acceleration)

Set an acceleration technique.

Definition at line 614 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ setDoesFirstStep()

void precice::cplscheme::BaseCouplingScheme::setDoesFirstStep ( bool doesFirstStep)
protected

Setter for _doesFirstStep.

Definition at line 457 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ setNextTimeWindowSize()

void precice::cplscheme::BaseCouplingScheme::setNextTimeWindowSize ( double timeWindowSize)
protected

Setter for _nextTimeWindowSize.

Parameters
timeWindowSize

Definition at line 258 of file BaseCouplingScheme.cpp.

◆ setTimeWindows()

void precice::cplscheme::BaseCouplingScheme::setTimeWindows ( int timeWindows)
protected

Setter for _timeWindows.

Sets the computed time windows of the coupling scheme. Used for testing to allow to advance in time without a coupling partner.

Parameters
timeWindowsnumber of time windows

Definition at line 473 of file BaseCouplingScheme.cpp.

◆ setTimeWindowSize()

void precice::cplscheme::BaseCouplingScheme::setTimeWindowSize ( double timeWindowSize)
protected

Setter for _timeWindowSize.

Parameters
timeWindowSize

Definition at line 253 of file BaseCouplingScheme.cpp.

◆ storeIteration()

void precice::cplscheme::BaseCouplingScheme::storeIteration ( )
protected

used for storing all Data at end of doImplicitStep for later reference.

Definition at line 775 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

◆ willDataBeExchanged()

bool precice::cplscheme::BaseCouplingScheme::willDataBeExchanged ( double lastSolverTimeStepSize) const
finaloverridevirtual

Returns true, if data will be exchanged when calling advance().

Also returns true after the last call of advance() at the end of the simulation.

Parameters
lastSolverTimeStepSize[IN] The size of the last time step computed by the solver calling willDataBeExchanged().

Implements precice::cplscheme::CouplingScheme.

Definition at line 444 of file BaseCouplingScheme.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ _acceleration

acceleration::PtrAcceleration precice::cplscheme::BaseCouplingScheme::_acceleration
protected

Acceleration method to speedup iteration convergence.

Definition at line 241 of file BaseCouplingScheme.hpp.

◆ _allData

DataMap precice::cplscheme::BaseCouplingScheme::_allData
protected

All send and receive data as a map "data ID -> data".

Definition at line 238 of file BaseCouplingScheme.hpp.

◆ _convergenceMeasures

std::vector<ConvergenceMeasureContext> precice::cplscheme::BaseCouplingScheme::_convergenceMeasures
private

All convergence measures of coupling iterations.

Before initialization, only dataID and measure variables are filled. Then, the data is fetched from send and receive data assigned to the cpl scheme.

Definition at line 507 of file BaseCouplingScheme.hpp.

◆ _convergenceWriter

std::shared_ptr<io::TXTTableWriter> precice::cplscheme::BaseCouplingScheme::_convergenceWriter
private

Writes out coupling convergence within all time windows.

Definition at line 474 of file BaseCouplingScheme.hpp.

◆ _couplingMode

CouplingMode precice::cplscheme::BaseCouplingScheme::_couplingMode = Undefined
private

Coupling mode used by coupling scheme.

Definition at line 411 of file BaseCouplingScheme.hpp.

◆ _doesFirstStep

bool precice::cplscheme::BaseCouplingScheme::_doesFirstStep = false
private

True, if local participant is the one starting the explicit scheme.

Definition at line 446 of file BaseCouplingScheme.hpp.

◆ _fulfilledActions

std::set<Action> precice::cplscheme::BaseCouplingScheme::_fulfilledActions
private

Definition at line 465 of file BaseCouplingScheme.hpp.

◆ _hasConverged

bool precice::cplscheme::BaseCouplingScheme::_hasConverged = false
private

True if implicit scheme converged.

Definition at line 468 of file BaseCouplingScheme.hpp.

◆ _hasDataBeenReceived

bool precice::cplscheme::BaseCouplingScheme::_hasDataBeenReceived = false
private

True, if data has been received from other participant. Flag is used to make sure that coupling scheme is implemented and used correctly.

Definition at line 458 of file BaseCouplingScheme.hpp.

◆ _isInitialized

bool precice::cplscheme::BaseCouplingScheme::_isInitialized = false
private

True, if coupling has been initialized.

Definition at line 461 of file BaseCouplingScheme.hpp.

◆ _isTimeWindowComplete

bool precice::cplscheme::BaseCouplingScheme::_isTimeWindowComplete = false
private

True, if _time == _timeWindowStartTime + _timeWindowSize and (coupling has converged or _iterations == _maxIterations)

Definition at line 449 of file BaseCouplingScheme.hpp.

◆ _iterations

int precice::cplscheme::BaseCouplingScheme::_iterations = -1
private

Number of iterations in current time window. _iterations <= _maxIterations.

Definition at line 440 of file BaseCouplingScheme.hpp.

◆ _iterationsWriter

std::shared_ptr<io::TXTTableWriter> precice::cplscheme::BaseCouplingScheme::_iterationsWriter
private

Responsible for monitoring iteration count over time window.

Definition at line 471 of file BaseCouplingScheme.hpp.

◆ _localParticipant

std::string precice::cplscheme::BaseCouplingScheme::_localParticipant = "unknown"
private

Local participant name.

Definition at line 477 of file BaseCouplingScheme.hpp.

◆ _log

logging::Logger precice::cplscheme::BaseCouplingScheme::_log {"cplscheme::BaseCouplingScheme"}
mutableprivate

Definition at line 413 of file BaseCouplingScheme.hpp.

◆ _maxIterations

int precice::cplscheme::BaseCouplingScheme::_maxIterations = -1
private

Limit of iterations during one time window. Continue to next time window, if _iterations == _maxIterations.

Definition at line 437 of file BaseCouplingScheme.hpp.

◆ _maxTime

double precice::cplscheme::BaseCouplingScheme::_maxTime
private

Maximum time being computed. End of simulation is reached, if getTime() == _maxTime.

Definition at line 416 of file BaseCouplingScheme.hpp.

◆ _maxTimeWindows

int precice::cplscheme::BaseCouplingScheme::_maxTimeWindows
private

Number of time windows that have to be computed. End of simulation is reached, if _timeWindows == _maxTimeWindows.

Definition at line 419 of file BaseCouplingScheme.hpp.

◆ _minIterations

int precice::cplscheme::BaseCouplingScheme::_minIterations = -1
private

Lower limit of iterations during one time window. Prevents convergence if _iterations < _minIterations.

Definition at line 434 of file BaseCouplingScheme.hpp.

◆ _nextTimeWindowSize

double precice::cplscheme::BaseCouplingScheme::_nextTimeWindowSize = UNDEFINED_TIME_WINDOW_SIZE
private

time window size of next window (acts as buffer for time windows size provided by first participant, if using first participant method)

Definition at line 428 of file BaseCouplingScheme.hpp.

◆ _receivesInitializedData

bool precice::cplscheme::BaseCouplingScheme::_receivesInitializedData = false
private

True, if this participant has to receive initialized data.

Definition at line 455 of file BaseCouplingScheme.hpp.

◆ _requiredActions

std::set<Action> precice::cplscheme::BaseCouplingScheme::_requiredActions
private

Definition at line 463 of file BaseCouplingScheme.hpp.

◆ _sendsInitializedData

bool precice::cplscheme::BaseCouplingScheme::_sendsInitializedData = false
private

True, if this participant has to send initialized data.

Definition at line 452 of file BaseCouplingScheme.hpp.

◆ _time

impl::TimeHandler precice::cplscheme::BaseCouplingScheme::_time
private

Time handler.

Definition at line 431 of file BaseCouplingScheme.hpp.

◆ _timeWindows

int precice::cplscheme::BaseCouplingScheme::_timeWindows = 0
private

number of completed time windows; _timeWindows <= _maxTimeWindows

Definition at line 422 of file BaseCouplingScheme.hpp.

◆ _timeWindowSize

double precice::cplscheme::BaseCouplingScheme::_timeWindowSize = UNDEFINED_TIME_WINDOW_SIZE
private

size of time window; _timeWindowSize <= _maxTime

Definition at line 425 of file BaseCouplingScheme.hpp.

◆ _totalIterations

int precice::cplscheme::BaseCouplingScheme::_totalIterations = -1
private

Number of total iterations performed.

Definition at line 443 of file BaseCouplingScheme.hpp.


The documentation for this class was generated from the following files: