Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign step-by-step guide regarding time interpolation #425

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pages/docs/couple-your-code/couple-your-code-steering-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ void finalize();
What do they do?

* `initialize` establishes communication channels and sets up data structures of preCICE.
* `advance` needs to be called after the computation of every time step to _advance_ the coupling. As an argument, you have to pass the solver's last time step size (`dt`). Additionally, it maps coupling data between the coupling meshes, it communicates coupling data between the coupled participants, and it accelerates coupling data. One could say the complete coupling happens within this single function.
* `advance` needs to be called after the computation of every time step to _advance_ the coupling. As an argument, you have to pass the solver's last _time step_ size (`dt`). Additionally, it maps coupling data between the coupling meshes, it communicates coupling data between the coupled participants, and it accelerates coupling data. One could say the complete coupling happens within this single function.
* `finalize` frees the preCICE data structures and closes communication channels.

The following function allows us to query the maximum allowed time step size from preCICE:
Synchronization of the participants etc. happens at the end of a _time window_. A time window consists of one or multiple time steps of size `dt` or $\delta t$ performed by the participants. Consequently, the participants must always use a time step size smaller than the time window size, i.e. $\delta t \leq \Delta t$. The following function allows us to query the maximum allowed time step size from preCICE such that a participant does not move beyond the synchronization point:

```cpp
double getMaxTimeStepSize();
```

But let's ignore the details of time step sizes for the moment. This will be the topic of [Step 5](couple-your-code-time-step-sizes.html). We can now extend the code of our fluid solver:
With this mechanism we can either use a time step size equal to the time window size resulting in synchronization of the participants after every single time step or we can perform multiple time steps before we synchronize. We refer to the latter as _subcycling_ and will discuss this feature in more detail in [Step 5](couple-your-code-time-step-sizes.html).

Using the API methods introduced above we can now extend the code of our fluid solver:

```cpp
#include <precice/precice.hpp>
Expand All @@ -45,7 +47,7 @@ precice.initialize();
while (not simulationDone()){ // time loop
preciceDt = getMaxTimeStepSize();
solverDt = beginTimeStep(); // e.g. compute adaptive dt
dt = min(preciceDt, solverDt); // more about this in Step 5
dt = min(preciceDt, solverDt); // determine actual dt
solveTimeStep(dt);
precice.advance(dt);
endTimeStep(); // e.g. update variables, increment time
Expand Down
Loading