preCICE v3.2.0
|
Acts as one coupling scheme, but consists of several composed ones. More...
#include <CompositionalCouplingScheme.hpp>
Public Member Functions | |
~CompositionalCouplingScheme () override=default | |
Destructor, empty. | |
void | addCouplingScheme (const PtrCouplingScheme &scheme) |
Adds another coupling scheme in parallel to this scheme. | |
void | initialize () final override |
Initializes the coupling scheme and establishes a communication connection to the coupling partner. | |
void | reinitialize () final override |
Reinitializes the coupling scheme, coupling data, and acceleration schemes. | |
bool | sendsInitializedData () const final override |
Returns true, if any of the composed coupling schemes sendsInitializedData for this participant. | |
bool | isInitialized () const final override |
Returns true, if initialize has been called. | |
bool | addComputedTime (double timeToAdd) final override |
Adds newly computed time. Has to be called before every advance. | |
ChangedMeshes | firstSynchronization (const ChangedMeshes &changes) override |
Exchanges data and updates the state of the coupling scheme. | |
void | firstExchange () override |
ChangedMeshes | secondSynchronization () override |
void | secondExchange () override |
void | finalize () final override |
Finalizes the coupling and disconnects communication. | |
std::vector< std::string > | getCouplingPartners () const final override |
Returns list of all coupling partners. | |
std::string | localParticipant () const final override |
Returns the name of the local participant. | |
bool | willDataBeExchanged (double lastSolverTimeStepSize) const final override |
Returns true, if data will be exchanged when calling advance(). | |
bool | hasDataBeenReceived () const final override |
checks all coupling schemes this coupling scheme is composed of. | |
double | getTime () const final override |
Returns the currently computed time of the coupling scheme. | |
double | getTimeWindowStart () const final override |
int | getTimeWindows () const final override |
Returns the currently computed time windows of the coupling scheme. | |
bool | hasTimeWindowSize () const final override |
Returns true, if time window size is given by any of the coupling schemes in this compositional 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 been 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 final override |
Returns a string representation of the current coupling state. | |
bool | isImplicitCouplingScheme () const final override |
True if one cplscheme is an implicit scheme. | |
bool | hasConverged () const final override |
True if the implicit scheme has converged or no implicit scheme is defined. | |
bool | requiresSubsteps () const final override |
Returns true if any send data of the scheme requires substeps. | |
ImplicitData | implicitDataToReceive () const final override |
Returns a vector of implicit data to receive in the next advance. | |
![]() | |
CouplingScheme & | operator= (CouplingScheme &&)=delete |
virtual | ~CouplingScheme ()=default |
Private Types | |
using | Schemes = std::vector<PtrCouplingScheme> |
Private Member Functions | |
void | updateActiveSchemes () |
std::vector< CouplingScheme * > | allSchemes () const |
Returns all schemes in execution order, explicit as well as implicit. | |
std::vector< CouplingScheme * > | activeOrAllSchemes () const |
Actions also work before initialize is called. | |
void | checkCompatibleTimeWindowSizes (const CouplingScheme &impl, const CouplingScheme &expl) const |
check if time windows are compatible | |
Private Attributes | |
logging::Logger | _log {"cplscheme::CompositionalCouplingScheme"} |
Schemes | _explicitSchemes |
Explicit coupling schemes to be executed. | |
PtrCouplingScheme | _implicitScheme |
The optional implicit scheme to be handled last. | |
bool | _explicitOnHold = false |
Are explicit schemes on hold? | |
std::vector< CouplingScheme * > | _activeSchemes |
Additional Inherited Members | |
![]() | |
enum struct | Action { InitializeData , ReadCheckpoint , WriteCheckpoint } |
Actions that are required by CouplingSchemes. More... | |
using | ChangedMeshes = std::vector<MeshID> |
![]() | |
static std::string | toString (Action action) |
![]() | |
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). | |
Acts as one coupling scheme, but consists of several composed ones.
The sequence of how the schemes are added by addCouplingScheme() determines their execution sequence. The schemes are executed from first added to last added, following the rule that implicit schemes need to be converged before executing the next explicit scheme/s. An example with implicit schemes I1, ..., I5 and explicit schemes E1, ..., E4 is given here. The schemes are added in the sequence
I1, I2, E1, E2, I3, E3, I4, I5, E4
The execution is as follows:
Steps 2 and 3 are computed directly when 1 is converged, i.e., no additional solver iteration/computation is necessary. Step 3, however, will require additional solver computations for every additional iteration. Similarly, 4 and 5 are computed directly when 3 is converged and 6 is computed directly when 5 is converged.
The grouping into such "active" sets is repeatedly done, in order to know which coupling schemes should be executed. The implicit coupling scheme actions constants::actionWrite/ReadIterationCheckpoint() is used to find out about whether a coupling scheme does perform iterations.
When, in an active set of implicit coupling schemes, a scheme is converged but others not, the converged scheme is put on hold until all schemes in the active set are converged. This assumes that the converged state of a coupling scheme is not deteriorated by the further iteration of the remaining non-converged schemes.
The execution of each scheme does not only depend on this sequence, but also on how the participants are configured to be first and second in the schemes. If not configured properly, a deadlock might be created.
Definition at line 56 of file CompositionalCouplingScheme.hpp.
|
private |
Definition at line 216 of file CompositionalCouplingScheme.hpp.
|
overridedefault |
Destructor, empty.
|
private |
Actions also work before initialize is called.
Definition at line 482 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Adds newly computed time. Has to be called before every advance.
timeToAdd | time to be added |
Implements precice::cplscheme::CouplingScheme.
Definition at line 104 of file CompositionalCouplingScheme.cpp.
void precice::cplscheme::CompositionalCouplingScheme::addCouplingScheme | ( | const PtrCouplingScheme & | scheme | ) |
Adds another coupling scheme in parallel to this scheme.
If this coupling scheme is a normal coupling scheme, an object of CompositionalCouplingScheme will be created that contains this and the new scheme in parallel. If this coupling scheme is already a composed scheme, the new scheme will be added as another parallel scheme.
Definition at line 51 of file CompositionalCouplingScheme.cpp.
|
private |
Returns all schemes in execution order, explicit as well as implicit.
Definition at line 472 of file CompositionalCouplingScheme.cpp.
|
private |
check if time windows are compatible
Definition at line 32 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Finalizes the coupling and disconnects communication.
Implements precice::cplscheme::CouplingScheme.
Definition at line 232 of file CompositionalCouplingScheme.cpp.
|
overridevirtual |
Exchanges the first set of data.
Implements precice::cplscheme::CouplingScheme.
Definition at line 157 of file CompositionalCouplingScheme.cpp.
|
overridevirtual |
Exchanges data and updates the state of the coupling scheme.
Implements precice::cplscheme::CouplingScheme.
Definition at line 144 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns list of all coupling partners.
Implements precice::cplscheme::CouplingScheme.
Definition at line 240 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns the maximal size of the next time step to be computed.
If no time step size is prescribed by the coupling scheme, always the maximal double accuracy floating point number value is returned.
This is the minimum of all max sizes of the composed coupling schemes.
Implements precice::cplscheme::CouplingScheme.
Definition at line 333 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns the currently computed time of the coupling scheme.
This time is the minimum time of any coupling scheme in the composition.
Implements precice::cplscheme::CouplingScheme.
Definition at line 279 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns the currently computed time windows of the coupling scheme.
The time window is the minimum time window in any coupling scheme in the composition.
Implements precice::cplscheme::CouplingScheme.
Definition at line 303 of file CompositionalCouplingScheme.cpp.
|
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 325 of file CompositionalCouplingScheme.cpp.
|
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 291 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
True if the implicit scheme has converged or no implicit scheme is defined.
Implements precice::cplscheme::CouplingScheme.
Definition at line 492 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
checks all coupling schemes this coupling scheme is composed of.
Implements precice::cplscheme::CouplingScheme.
Definition at line 269 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, if time window size is given by any of the coupling schemes in this compositional coupling scheme.
Implements precice::cplscheme::CouplingScheme.
Definition at line 317 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns a vector of implicit data to receive in the next advance.
Implements precice::cplscheme::CouplingScheme.
Definition at line 511 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Initializes the coupling scheme and establishes a communication connection to the coupling partner.
Implements precice::cplscheme::CouplingScheme.
Definition at line 71 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, if the given action has been performed by the accessor.
Implements precice::cplscheme::CouplingScheme.
Definition at line 396 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, if the given action has to be performed by the accessor.
True, if any of the composed coupling schemes requires the action.
Implements precice::cplscheme::CouplingScheme.
Definition at line 380 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, when the coupled simulation is still ongoing.
As long as one composed coupling scheme is still ongoing, returns true.
Implements precice::cplscheme::CouplingScheme.
Definition at line 359 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
True if one cplscheme is an implicit scheme.
Implements precice::cplscheme::CouplingScheme.
Definition at line 487 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, if initialize has been called.
Implements precice::cplscheme::CouplingScheme.
Definition at line 96 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, when the accessor can advance to the next time window.
Only true, if all composed coupling schemes have completed the time window.
Implements precice::cplscheme::CouplingScheme.
Definition at line 370 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns the name of the local participant.
Implements precice::cplscheme::CouplingScheme.
Definition at line 251 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Tells the coupling scheme that the accessor has performed the given action.
Implements precice::cplscheme::CouplingScheme.
Definition at line 411 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns a string representation of the current coupling state.
Implements precice::cplscheme::CouplingScheme.
Definition at line 429 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Reinitializes the coupling scheme, coupling data, and acceleration schemes.
Implements precice::cplscheme::CouplingScheme.
Definition at line 81 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Sets an action required to be performed by the accessor.
Implements precice::cplscheme::CouplingScheme.
Definition at line 422 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true if any send data of the scheme requires substeps.
Implements precice::cplscheme::CouplingScheme.
Definition at line 501 of file CompositionalCouplingScheme.cpp.
|
overridevirtual |
Exchanges the second set of data.
This concludes the step of the coupling scheme
Implements precice::cplscheme::CouplingScheme.
Definition at line 192 of file CompositionalCouplingScheme.cpp.
|
overridevirtual |
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.
Implements precice::cplscheme::CouplingScheme.
Definition at line 180 of file CompositionalCouplingScheme.cpp.
|
finaloverridevirtual |
Returns true, if any of the composed coupling schemes sendsInitializedData for this participant.
Implements precice::cplscheme::CouplingScheme.
Definition at line 87 of file CompositionalCouplingScheme.cpp.
|
private |
Updates _activeSchemes to the next ones that will participate in the upcoming step in time Called from secondExchange
Definition at line 446 of file CompositionalCouplingScheme.cpp.
|
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.
lastSolverTimeStepSize | [IN] The size of the last time step computed by the solver calling willDataBeExchanged(). |
Implements precice::cplscheme::CouplingScheme.
Definition at line 258 of file CompositionalCouplingScheme.cpp.
|
private |
All schemes to run next
This is the core of the CompositionalCouplingScheme
All schemes start at t=0, so they all run on the first time step. This is updated by finishing the complete advance calling secondExchange() using updateActiveSchemes().
Definition at line 234 of file CompositionalCouplingScheme.hpp.
|
private |
Are explicit schemes on hold?
Definition at line 225 of file CompositionalCouplingScheme.hpp.
|
private |
Explicit coupling schemes to be executed.
Definition at line 219 of file CompositionalCouplingScheme.hpp.
|
private |
The optional implicit scheme to be handled last.
Definition at line 222 of file CompositionalCouplingScheme.hpp.
|
mutableprivate |
Definition at line 214 of file CompositionalCouplingScheme.hpp.