# What are savestate() and reloadstate() in implicit coupling?

**URL:** <https://precice.discourse.group/t/what-are-savestate-and-reloadstate-in-implicit-coupling/1845>\
**Category:** Using preCICE\
**Tags:** fsi, implicit, checkpointing\
**Created:** [March 21, 2024, 10:37am UTC](https://precice.discourse.group/t/what-are-savestate-and-reloadstate-in-implicit-coupling/1845 "2024-03-21T10:37:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fan\_wu](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fan_wu/32/1855_2.png) [@fan\_wu](https://precice.discourse.group/u/fan_wu)\
**Post date:** [March 21, 2024, 10:37am UTC](https://precice.discourse.group/t/what-are-savestate-and-reloadstate-in-implicit-coupling/1845/1 "2024-03-21T10:37:51Z")

</div>

Dear community members,

I have coupled my immersed boundary method program with calculix. After testing, my Perpendicular flap example has the same results as the official openFoam provided. However, I used a loose coupling strategy, which is an explicit strategy. Because the density ratio of this problem is relatively large, even the explicit strategy can obtain good results.

However, I encountered difficulties when reproducing the Turek Hron FSI3 example. Because the density ratio is 1, implicit coupling must be used. However, it has been impossible to reach convergence.

I compared the forces on the solid when calculated by the separate fluid solver（no fsi）, and the results were correct.

I suspect that there is an error in the saving and reloading states function. I am showing the code of my program. Can anyone tell me which variables need to be saved? I have saved all variables as much as possible. Is this correct? If the reloading is to the original state, why does the force and displacement change? How is implicit coupling implemented?

Please help me, thank you!

 ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/c/c6bed5a8e83b7c9c1c3caf2d1021db8580607536.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/7/7bca7dae251c8ce388ae8cfa689bed6bfede766d.png)

---

<div class="post-metadata">

**Author:** ![fsimonis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/fsimonis/32/6_2.png) [@fsimonis](https://precice.discourse.group/u/fsimonis)\
**Post date:** [April 16, 2024, 8:48am UTC](https://precice.discourse.group/t/what-are-savestate-and-reloadstate-in-implicit-coupling/1845/2 "2024-04-16T08:48:08Z")

</div>

Hi,

When in doubt, checkpoint everything 😉  
Your solver must be able to jump back in time.

We have an extensive documentation on how implicit coupling works:

> **[Step 6 – Implicit coupling | preCICE - The Coupling Library](https://precice.org/couple-your-code-implicit-coupling.html)**
>
> In previous steps, we only considered explicit coupling. We now move onto implicit coupling, so sub-iterating each time step multiple times until a convergence threshold is reached. This stabilzes strongly-coupled problems.

---

<div class="post-metadata">

**Author:** ![Makis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/makis/32/25_2.png) [@Makis](https://precice.discourse.group/u/Makis)\
**Post date:** [May 6, 2024, 1:20pm UTC](https://precice.discourse.group/t/what-are-savestate-and-reloadstate-in-implicit-coupling/1845/3 "2024-05-06T13:20:52Z")

</div>

You probably already read the documentation page and answered your questions, but for the future reader:

Implicit coupling is iterative: you try reading some data on the interface, the coupling does not converge, so the acceleration gives you new data to try, and the process repeats. Every time you “try” data, you update all the internal state of the solver. So, before applying the new values, you need to restore the internal state to how it was supposed to be. You do this by writing and reading checkpoints.

What typically goes into a checkpoint:

- Time and time stepping information
- The mesh itself, in case it changes. You are using an IBM, so you probably need to checkpoint the location of the boundary.
- The solution fields (displacement, force, …)
- Any derived fields (stress tensors etc) that are not automatically recomputed

More or less everything you would also write into a restart file.
