70 double timeWindowSize,
113 double getTime() const final override;
196 impl::PtrConvergenceMeasure measure);
199 void setAcceleration(const acceleration::PtrAcceleration &acceleration);
416 mutable logging::Logger
_log{
"cplscheme::BaseCouplingScheme"};
Abstract base class for standard coupling schemes.
virtual bool hasAnySendData()=0
bool hasTimeWindowSize() const final override
Function to check whether time window size is defined by coupling scheme.
std::set< Action > _fulfilledActions
void initializeWithZeroInitialData(const DataMap &receiveData)
Initializes storage in receiveData as zero.
std::string printCouplingState() const override
Returns coupling state information.
bool isCouplingOngoing() const final override
Returns true, when the coupled simulation is still ongoing.
ChangedMeshes secondSynchronization() final override
void setTimeWindowSize(double timeWindowSize)
Setter for _timeWindowSize.
std::vector< ConvergenceMeasureContext > _convergenceMeasures
All convergence measures of coupling iterations.
void determineInitialReceive(DataMap &receiveData)
Sets _receivesInitializedData, if receiveData requires initialization.
bool addComputedTime(double timeToAdd) final override
Adds newly computed time. Has to be called before every advance.
void sendTimes(const m2n::PtrM2N &m2n, precice::span< double const > times)
std::string _localParticipant
Local participant name.
double _timeWindowSize
size of time window; _timeWindowSize <= _maxTime
double getNextTimeStepMaxSize() const final override
Returns the maximal size of the next time step to be computed.
void determineInitialSend(DataMap &sendData)
Sets _sendsInitializedData, if sendData requires initialization.
bool isTimeWindowComplete() const final override
Returns true, when the accessor can advance to the next time window.
virtual void exchangeSecondData()=0
Exchanges the second set of data.
void reinitialize() final override
Reinitializes the coupling scheme, coupling data, and acceleration schemes.
void receiveDataForWindowEnd(const m2n::PtrM2N &m2n, const DataMap &receiveData)
Like receiveData, but temporarily sets window time to end of window.
bool _hasDataBeenReceived
True, if data has been received from other participant. Flag is used to make sure that coupling schem...
void notifyDataHasBeenReceived()
Used to set flag after data has been received using receiveData().
virtual void determineInitialDataExchange()=0
Determines which data is initialized and therefore has to be exchanged during initialize.
bool _isInitialized
True, if coupling has been initialized.
bool isExplicitCouplingScheme() const
Function to determine whether coupling scheme is an explicit coupling scheme.
int _maxIterations
Limit of iterations during one time window. Continue to next time window, if _iterations == _maxItera...
void sendData(const m2n::PtrM2N &m2n, const DataMap &sendData)
Sends data sendDataIDs given in mapCouplingData with communication.
virtual void exchangeFirstData()=0
Functions needed for advance()
bool _doesFirstStep
True, if local participant is the one starting the explicit scheme.
bool _receivesInitializedData
True, if this participant has to receive initialized data.
void storeIteration()
used for storing all Data at end of doImplicitStep for later reference.
void initializeTXTWriters()
Initialize txt writers for iterations and convergence tracking.
ChangedMeshes firstSynchronization(const ChangedMeshes &changes) final override
bool isImplicitCouplingScheme() const override
Function to determine whether coupling scheme is an implicit coupling scheme.
bool _hasConverged
True if implicit scheme converged.
void setTimeWindows(int timeWindows)
Setter for _timeWindows.
void sendConvergence(const m2n::PtrM2N &m2n)
sends convergence to other participant via m2n
int _minIterations
Lower limit of iterations during one time window. Prevents convergence if _iterations < _minIteration...
double getTimeWindowSize() const final override
Returns the time window size, if one is given by the coupling scheme.
impl::TimeHandler _time
Time handler.
bool _sendsInitializedData
True, if this participant has to send initialized data.
bool _isTimeWindowComplete
True, if _time == _timeWindowStartTime + _timeWindowSize and (coupling has converged or _iterations =...
int _totalIterations
Number of total iterations performed.
bool anyDataRequiresInitialization(DataMap &dataMap) const
Checks whether any CouplingData in dataMap requires initialization.
bool hasConverged() const override
Checks if the implicit cplscheme has converged.
std::shared_ptr< io::TXTTableWriter > _convergenceWriter
Writes out coupling convergence within all time windows.
double _maxTime
Maximum time being computed. End of simulation is reached, if getTime() == _maxTime.
void finalize() final override
Finalizes the coupling scheme.
std::vector< double > receiveTimes(const m2n::PtrM2N &m2n)
void setAcceleration(const acceleration::PtrAcceleration &acceleration)
Set an acceleration technique.
bool reachedEndOfTimeWindow() const
Function to check whether end of time window is reached. Does not check for convergence.
bool hasDataBeenReceived() const final override
getter for _hasDataBeenReceived
bool requiresSubsteps() const final override
Returns true if any send data of the scheme requires substeps.
void moveToNextWindow()
finalizes this window's data and initializes data for next window.
void addConvergenceMeasure(int dataID, bool suffices, bool strict, impl::PtrConvergenceMeasure measure)
Adds a measure to determine the convergence of coupling iterations.
int _maxTimeWindows
Number of time windows that have to be computed. End of simulation is reached, if _timeWindows == _ma...
void doImplicitStep()
perform a coupling iteration
std::string printBasicState(int timeWindows, double time) const
Prints the coupling state.
double getTime() const final override
getter for _time
std::string printActionsState() const
Prints the action state.
bool receivesInitializedData() const
Getter for _receivesInitializedData.
void requireAction(Action action) final override
Sets an action required to be performed by the accessor.
int getTimeWindows() const final override
getter for _timeWindows
bool isInitialized() const final override
getter for _isInitialized
ImplicitData implicitDataToReceive() const override
Returns a vector of implicit data to receive in the next advance.
bool sendsInitializedData() const final override
Getter for _sendsInitializedData.
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 Coupl...
double getWindowStartTime() const
int _timeWindows
number of completed time windows; _timeWindows <= _maxTimeWindows
void initialize() final override
Initializes the coupling scheme and establishes a communication connection to the coupling partner....
void markActionFulfilled(Action action) final override
Tells the coupling scheme that the accessor has performed the given action.
void advanceTXTWriters()
Advance txt writers for iterations and convergence tracking.
acceleration::PtrAcceleration _acceleration
Acceleration method to speedup iteration convergence.
double getWindowEndTime() const
bool willDataBeExchanged(double lastSolverTimeStepSize) const final override
Returns true, if data will be exchanged when calling advance().
virtual DataMap & getAccelerationData()=0
interface to provide accelerated data, depending on coupling scheme being used
double getNextTimeWindowSize() const
Getter for _nextTimeWindowSize.
double _nextTimeWindowSize
time window size of next window (acts as buffer for time windows size provided by first participant,...
DataMap _allData
All send and receive data as a map "data ID -> data".
void checkCouplingDataAvailable()
Issues an error if coupling data does not contain stamples.
CouplingMode _couplingMode
Coupling mode used by coupling scheme.
bool isActionRequired(Action action) const final override
Returns true, if the given action has to be performed by the accessor.
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 firstExchange() final override
void setNextTimeWindowSize(double timeWindowSize)
Setter for _nextTimeWindowSize.
std::shared_ptr< io::TXTTableWriter > _iterationsWriter
Responsible for monitoring iteration count over time window.
bool isActionFulfilled(Action action) const final override
Returns true, if the given action has to be performed by the accessor.
virtual void exchangeInitialData()=0
implements functionality for initialize in base class.
int _iterations
Number of iterations in current time window. _iterations <= _maxIterations.
virtual void initializeReceiveDataStorage()=0
Functions needed for initialize()
void secondExchange() final override
void newConvergenceMeasurements()
Reset all convergence measurements after convergence.
BaseCouplingScheme(double maxTime, int maxTimeWindows, double timeWindowSize, std::string localParticipant, int minIterations, int maxIterations, CouplingMode cplMode, constants::TimesteppingMethod dtMethod)
void setDoesFirstStep(bool doesFirstStep)
Setter for _doesFirstStep.
bool measureConvergence()
Measure whether coupling scheme has converged or not.
void receiveData(const m2n::PtrM2N &m2n, const DataMap &receiveData)
Receives data receiveDataIDs given in mapCouplingData with communication.
void checkCompletenessRequiredActions()
If any required actions are open, an error message is issued.
bool doesFirstStep() const
Getter for _doesFirstStep.
std::set< Action > _requiredActions
double getTimeWindowStart() const final override
Interface for all coupling schemes.
std::vector< MeshID > ChangedMeshes
Action
Actions that are required by CouplingSchemes.
static const double UNDEFINED_TIME_WINDOW_SIZE
To be used, when the time window size is determined dynamically during the coupling.
A C++ 11 implementation of the non-owning C++20 std::span type.
Main namespace of the precice library.
Holds meta information to perform a convergence measurement.
impl::PtrConvergenceMeasure measure
PtrCouplingData couplingData
std::string logHeader() const