preCICE v3.1.2
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 {
13namespace cplscheme {
14
58public:
61
72 void addCouplingScheme(const PtrCouplingScheme &scheme);
73
80 void initialize(
81 double startTime,
82 int startTimeWindow) final override;
83
85 bool sendsInitializedData() const override final;
86
88 bool isInitialized() const final override;
89
91 bool addComputedTime(double timeToAdd) final override;
92
94 //void advance() final override;
95
96 ChangedMeshes firstSynchronization(const ChangedMeshes &changes) override;
97
98 void firstExchange() override;
99
101
102 void secondExchange() override;
103
105 void finalize() final override;
106
108 std::vector<std::string> getCouplingPartners() const final override;
109
111 std::string localParticipant() const override final;
112
122 bool willDataBeExchanged(double lastSolverTimeStepSize) const final override;
123
128 bool hasDataBeenReceived() const final override;
129
135 double getTime() const final override;
136
137 double getTimeWindowStart() const override final;
138
144 int getTimeWindows() const final override;
145
150 bool hasTimeWindowSize() const final override;
151
159 double getTimeWindowSize() const final override;
160
169 double getNextTimeStepMaxSize() const final override;
170
176 bool isCouplingOngoing() const final override;
177
183 bool isTimeWindowComplete() const final override;
184
190 bool isActionRequired(Action action) const final override;
191
193 bool isActionFulfilled(Action action) const final override;
194
196 void markActionFulfilled(Action action) final override;
197
199 void requireAction(Action action) final override;
200
202 std::string printCouplingState() const final override;
203
205 bool isImplicitCouplingScheme() const final;
206
208 bool hasConverged() const final;
209
211 bool requiresSubsteps() const override final;
212
214 ImplicitData implicitDataToReceive() const override final;
215
216private:
217 mutable logging::Logger _log{"cplscheme::CompositionalCouplingScheme"};
218
220
223
226
228 bool _explicitOnHold = false;
229
238
242 void updateActiveSchemes();
243
246
249
251 void checkCompatibleTimeWindowSizes(const CouplingScheme &impl, const CouplingScheme &expl) const;
252};
253
254} // namespace cplscheme
255} // namespace precice
Acts as one coupling scheme, but consists of several composed ones.
bool requiresSubsteps() const override final
Returns true if any send data of the scheme requires substeps.
PtrCouplingScheme _implicitScheme
The optional implicit scheme to be handled last.
void initialize(double startTime, int startTimeWindow) final override
Initializes the coupling scheme and establishes a communication connection to the coupling partner.
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.
bool hasConverged() const final
True if the implicit scheme has converged or no implicit scheme is defined.
std::vector< CouplingScheme * > allSchemes() const
Returns all schemes in execution order, explicit as well as implicit.
void finalize() final override
Finalizes the coupling and disconnects communication.
bool isImplicitCouplingScheme() const final
True if one cplscheme is an implicit scheme.
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.
Schemes _explicitSchemes
Explicit coupling schemes to be executed.
double getTimeWindowSize() const final override
Returns the time window size, if one is given by the coupling scheme.
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.
std::string localParticipant() const override final
Returns the name of the local participant.
bool hasDataBeenReceived() const final override
checks all coupling schemes this coupling scheme is composed of.
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
std::string printCouplingState() const final override
Returns a string representation of the current coupling state.
bool sendsInitializedData() const override final
Returns true, if any of the composed coupling schemes sendsInitializedData for this participant.
ImplicitData implicitDataToReceive() const override final
Returns a vector of implicit data to receive in the next advance.
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.
Main namespace of the precice library.
STL namespace.