preCICE v3.2.0
Loading...
Searching...
No Matches
CompositionalCouplingScheme.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <string>
5#include <vector>
6#include "Constants.hpp"
7#include "CouplingScheme.hpp"
8#include "SharedPointer.hpp"
10#include "logging/Logger.hpp"
11
12namespace precice::cplscheme {
13
57public:
59 ~CompositionalCouplingScheme() override = default;
60
71 void addCouplingScheme(const PtrCouplingScheme &scheme);
72
77 void initialize() final override;
78
79 void reinitialize() final override;
80
82 bool sendsInitializedData() const final override;
83
85 bool isInitialized() const final override;
86
88 bool addComputedTime(double timeToAdd) final override;
89
91 // void advance() final override override;
92
93 ChangedMeshes firstSynchronization(const ChangedMeshes &changes) override;
94
95 void firstExchange() override;
96
98
99 void secondExchange() override;
100
102 void finalize() final override;
103
105 std::vector<std::string> getCouplingPartners() const final override;
106
108 std::string localParticipant() const final override;
109
119 bool willDataBeExchanged(double lastSolverTimeStepSize) const final override;
120
125 bool hasDataBeenReceived() const final override;
126
132 double getTime() const final override;
133
134 double getTimeWindowStart() const final override;
135
141 int getTimeWindows() const final override;
142
147 bool hasTimeWindowSize() const final override;
148
156 double getTimeWindowSize() const final override;
157
166 double getNextTimeStepMaxSize() const final override;
167
173 bool isCouplingOngoing() const final override;
174
180 bool isTimeWindowComplete() const final override;
181
187 bool isActionRequired(Action action) const final override;
188
190 bool isActionFulfilled(Action action) const final override;
191
193 void markActionFulfilled(Action action) final override;
194
196 void requireAction(Action action) final override;
197
199 std::string printCouplingState() const final override;
200
202 bool isImplicitCouplingScheme() const final override;
203
205 bool hasConverged() const final override;
206
208 bool requiresSubsteps() const final override;
209
211 ImplicitData implicitDataToReceive() const final override;
212
213private:
214 mutable logging::Logger _log{"cplscheme::CompositionalCouplingScheme"};
215
217
220
223
225 bool _explicitOnHold = false;
226
235
239 void updateActiveSchemes();
240
243
246
249};
250
251} // namespace precice::cplscheme
Acts as one coupling scheme, but consists of several composed ones.
PtrCouplingScheme _implicitScheme
The optional implicit scheme to be handled last.
bool sendsInitializedData() const final override
Returns true, if any of the composed coupling schemes sendsInitializedData for this participant.
std::vector< CouplingScheme * > activeOrAllSchemes() const
Actions also work before initialize is called.
bool isTimeWindowComplete() const final override
Returns true, when the accessor can advance to the next time window.
std::vector< CouplingScheme * > allSchemes() const
Returns all schemes in execution order, explicit as well as implicit.
std::string localParticipant() const final override
Returns the name of the local participant.
void finalize() final override
Finalizes the coupling and disconnects communication.
ImplicitData implicitDataToReceive() const final override
Returns a vector of implicit data to receive in the next advance.
bool isCouplingOngoing() const final override
Returns true, when the coupled simulation is still ongoing.
double getTime() const final override
Returns the currently computed time of the coupling scheme.
std::vector< std::string > getCouplingPartners() const final override
Returns list of all coupling partners.
void initialize() final override
Initializes the coupling scheme and establishes a communication connection to the coupling partner.
Schemes _explicitSchemes
Explicit coupling schemes to be executed.
~CompositionalCouplingScheme() override=default
Destructor, empty.
bool isImplicitCouplingScheme() const final override
True if one cplscheme is an implicit scheme.
double getTimeWindowSize() const final override
Returns the time window size, if one is given by the coupling scheme.
bool requiresSubsteps() const final override
Returns true if any send data of the scheme requires substeps.
bool isActionRequired(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.
bool addComputedTime(double timeToAdd) final override
Adds newly computed time. Has to be called before every advance.
bool hasDataBeenReceived() const final override
checks all coupling schemes this coupling scheme is composed of.
bool hasConverged() const final override
True if the implicit scheme has converged or no implicit scheme is defined.
int getTimeWindows() const final override
Returns the currently computed time windows of the coupling scheme.
void requireAction(Action action) final override
Sets an action required to be performed by the accessor.
bool isInitialized() const final override
Returns true, if initialize has been called.
double getNextTimeStepMaxSize() const final override
Returns the maximal size of the next time step to be computed.
bool hasTimeWindowSize() const final override
Returns true, if time window size is given by any of the coupling schemes in this compositional coupl...
void addCouplingScheme(const PtrCouplingScheme &scheme)
Adds another coupling scheme in parallel to this scheme.
ChangedMeshes firstSynchronization(const ChangedMeshes &changes) override
Exchanges data and updates the state of the coupling scheme.
bool willDataBeExchanged(double lastSolverTimeStepSize) const final override
Returns true, if data will be exchanged when calling advance().
void checkCompatibleTimeWindowSizes(const CouplingScheme &impl, const CouplingScheme &expl) const
check if time windows are compatible
void reinitialize() final override
Reinitializes the coupling scheme, coupling data, and acceleration schemes.
std::string printCouplingState() const final override
Returns a string representation of the current coupling state.
bool isActionFulfilled(Action action) const final override
Returns true, if the given action has been performed by the accessor.
Interface for all coupling schemes.
Action
Actions that are required by CouplingSchemes.
STL class.
contains actions to modify exchanged data.
Definition Action.hpp:6
contains implementations of coupling schemes for coupled simulations.
std::shared_ptr< CouplingScheme > PtrCouplingScheme
contains the logging framework.
STL namespace.