# Strange phenomenon during multiphase FSI

**URL:** <https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802>\
**Category:** Using preCICE\
**Tags:** openfoam, fsi, multiphase\
**Created:** [November 23, 2021, 3:36am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802 "2021-11-23T03:36:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [November 23, 2021, 3:36am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/1 "2021-11-23T03:36:46Z")

</div>

Hi all,  
Recently I’m doing wave-struction simulation using our in-house solver and OpenFOAM. At first, the wave propogates normally. However, the water near the structure suddenly collapses.  
The red part is water and the blue part is air.  
1.95s

 ![1_95](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/c51a9be586df2550e757d62ba73a2e6065fb8d5b.png)  
2.00s  
 ![2](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/c0b5b40200393b24f2454a125af3acea90666cfe.png)  
Since the displacement and stress results obtained from our in-house solver seem to be fine, I guess this may be related to the fluid part but I haven’t found mistakes in case setting. May it be that the data mapping doesn’t converge?

Has anyone encountered the similar situation? Any suggestions will be appreciated! 😊  
[precice-config.xml](https://precice.discourse.group/uploads/short-url/aVx5EqhLWL6i5KwOYCjX0LDsQ8l.xml) (2.6 KB)

---

<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:** [November 26, 2021, 9:56pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/2 "2021-11-26T21:56:23Z")

</div>

Are you maybe using a modified version of the adapter? How did you make the FSI module work with multiphase?

I could imagine that there is a bug here, but I need to understand the context first.

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [November 27, 2021, 11:47am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/3 "2021-11-27T11:47:15Z")

</div>

Hi Makis,

> [@Makis](#):
>
> Are you maybe using a modified version of the adapter?

Yes, I’ve modified the adapter to pass `Pressure` to the solid participant, and read the `Velocity` and `Displacement` on the interface from the solid.

> [@Makis](#):
>
> How did you make the FSI module work with multiphase?

I didn’t change much. In brief, I adopted a multiphase solver and modified some initial files.

Today, I’m sure basically that the problem is due to the `Velocity` passed to the fluid part, not the openfoam adapter. For some points on the interface, the velocity values calculated by our in-house solver are quite large which could lead to the non convergence in the fluid part. Once I removed the `Velocity` from the coupling data, the simulation converged well.

---

<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:** [November 29, 2021, 12:06pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/4 "2021-11-29T12:06:20Z")

</div>

Is the discontinuity maybe related to implicit coupling and redoing iterations? Just thinking in the direction of checkpointing.

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [November 29, 2021, 1:03pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/5 "2021-11-29T13:03:56Z")

</div>

Since our solid solver doesn’t have checkpoint function at present, I only use explicit coupling to do my tests ( It may change the structure of our solver in order to do implicit couping, but it’s on the to do list). In my simulations, I found that there is unreal oscillation for the structure. For example, the flap is supposed to vacillate to the left and right once it’s hit by waves. However, when the flap should continue to vacillate to the right, there is a sudden movement to the left. May it be the problem of the discontinuity you mentioned?

---

<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:** [November 29, 2021, 3:28pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/6 "2021-11-29T15:28:52Z")

</div>

Are your code changes available online anywhere?

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [November 30, 2021, 1:44am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/7 "2021-11-30T01:44:48Z")

</div>

The changed openfoam-adapter is uploaded here. I mainly changed the files in FSI module to write `Pressure` to the solid and read `Displacement` and `Velocity` from the solid.  
[openfoam-adapter\_modified.zip](https://precice.discourse.group/uploads/short-url/gIuWTfOhTP6rCpkvRBsGfTIqJBS.zip) (2.8 MB)

Since our solid solver is an in-house code and it is directly modified in the source code to adopt functions in preCICE library, I’m sorry this cannot be uploaded.

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [December 1, 2021, 9:12am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/8 "2021-12-01T09:12:24Z")

</div>

> [@Stan](#):
>
> For example, the flap is supposed to vacillate to the left and right once it’s hit by waves. However, when the flap should continue to vacillate to the right, there is a sudden movement to the left.

To be more clear, the strange phenomenon is shown in the figures. Fig.3 shows that the flap suddenly vacillate to the left when it should have vacillated to the right. Then, there is a kind of discontinuity of the water phase near the flap as shown in Fig.4.

 ![wave_flap.0265](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/e/e0439683b128f31171ded7fcbd7fb81fb54b5da9.png) ![wave_flap.0266](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/5/5c9533347067f4f3971d403f3229bf83066415a1.png)  
Fig.1 & Fig.2  
 ![wave_flap.0267](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/1/1dff632de85fb2d1d21637a015cb6c3ea6ada239.png) ![wave_flap.0268](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/f/fbf1fdf318ef8daaff436e59c7ee7b48db2b80da.png)  
Fig.3 & Fig.4

---

<div class="post-metadata">

**Author:** ![KyleDavisSA](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/kyledavissa/32/108_2.png) [@KyleDavisSA](https://precice.discourse.group/u/KyleDavisSA)\
**Post date:** [December 8, 2021, 12:44pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/9 "2021-12-08T12:44:49Z")

</div>

I have performed a similar case with a flap in a multiphase air/water domain, and also had some stability problems. However, this normally occurred with severe mesh distortion around the flap, causing the openFOAM to diverge. For this case I do not know what could be causing it.

Have you tried various mesh sizes i.e. both coarser and finer meshes?

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [December 10, 2021, 7:51am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/10 "2021-12-10T07:51:58Z")

</div>

Hi @KyleDavisSA ,  
Thanks for your suggestions. I haven’t since the mesh size is pretty small. But I’ll have a try with more meshes.

By the way, I noticed that there is a time warp after the coupling simulation runs for some time (For example, OpenFOAM Time is 2.9s while our in-house solver Time is 3.2s). Has anyone ever encountered the similar situation? I guess this may also be the reason why OpenFOAM diverges (discontinuity at the interface due to the time warp).

---

<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:** [December 19, 2021, 2:22pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/11 "2021-12-19T14:22:19Z")

</div>

> [@Stan](#):
>
> By the way, I noticed that there is a time warp after the coupling simulation runs for some time (For example, OpenFOAM Time is 2.9s while our in-house solver Time is 3.2s).

This sounds to me as if your in-house solver does not take the minimum between the timestep size it wants to perform and the timestep size of preCICE: [Redirecting…](https://precice.org/couple-your-code-timestep-sizes.html)

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [December 20, 2021, 2:25am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/12 "2021-12-20T02:25:35Z")

</div>

Actually it does takes the minimum time length, we define the timestep according to this `Step 5`.  
For `initialization` and `advance`, we have  
 ![1](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/5/50e230d86ca21f5f6d4ce7f3be0e8c0bf3adf255.png)

![2](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/8/8ae4362e853895c2a568d03499e2035bd69853c8.png)  
The output in terminal is shown as follow:

 ![3](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/5/55d2d159886739262dd3f3bc6fc2233c83e896c8.png)  
So it’s quite confusing for me why the time warp happens.

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [December 20, 2021, 5:52pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/13 "2021-12-20T17:52:03Z")

</div>

> [@Stan](#):
>
> Since our solid solver doesn’t have checkpoint function at present, I only use explicit coupling to do my tests

I can very well be that the instability comes from the explicit coupling. Does it work when you use a very heavy solid?

Concerning the time warp: How do you call `advance`? Could you please show that code snippet as well?

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [December 28, 2021, 1:29am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/14 "2021-12-28T01:29:13Z")

</div>

Hi @uekerman ,  
Sorry for the late reply.

> [@uekerman](#):
>
> Does it work when you use a very heavy solid?

Do you mean the density of the solid? For a solid with 2700kg/m^3，there is still a time inconsistency.

> [@uekerman](#):
>
> Concerning the time warp: How do you call `advance` ? Could you please show that code snippet as well?

Of course, we call `advance` after calling `Precicef_Write_Bvdata` in a subroutine:

 ![snippet](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/d/d04222dafc47ec664e5a5bd6eb73338fa5b77432.png)

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [December 30, 2021, 10:29am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/15 "2021-12-30T10:29:53Z")

</div>

> [@Stan](#):
>
> > [@uekerman](#):
> >
> > Does it work when you use a very heavy solid?
> 
> Do you mean the density of the solid? For a solid with 2700kg/m^3，there is still a time inconsistency.

Yes. I was referring to your stability issues here. Must not necessarily be related to the time inconsistency.

Concerning the timestep size:

In the Fortran bindings the `Dt` in `advance(Dt)` is an input and an output argument. You need to use the output value as `Precice_Dt` in your code snippet above.

More information:

> **[Step 5 – Non-matching time step sizes | preCICE - The Coupling Library](https://precice.org/couple-your-code-timestep-sizes.html)**
>
> In this step, you learn how preCICE handles non-matching time step sizes and a few more things about simulation time.

and

> <https://github.com/precice/precice/blob/8a4f4845f544a6c2a11f45e4b92ebd96874f4456/extras/bindings/fortran/src/SolverInterfaceFortran.cpp#L74-L79>

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [December 30, 2021, 3:20pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/16 "2021-12-30T15:20:07Z")

</div>

> [@uekerman](#):
>
> Yes. I was referring to your stability issues here.

Thanks for the clarification. It seems that density doesn’t affect the stability much.

> [@uekerman](#):
>
> In the Fortran bindings the `Dt` in `advance(Dt)` is an input and an output argument. You need to use the output value as `Precice_Dt` in your code snippet above.

Yes, we always use a shorter timestep between the output value of `advance(Dt)` and our preset timestep. We’ve checked the code before according to the information you suggested and there seems to be nothing wrong. Anyway, thanks for your help and the suggestions!

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [December 30, 2021, 6:21pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/17 "2021-12-30T18:21:07Z")

</div>

and you also pass the correct `Dt` to `advance`?

The first half of this video also explains the timestep size handling:

[![](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/c/c4d620fd94e95a0f0167a7a96603a77cb7166e64.jpeg "High-order and multi-rate time stepping with preCICE (Benjamin Rüth, preCICE Workshop 2020)") ](https://www.youtube.com/watch?v=7NhBmcx_MmI)

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [January 4, 2022, 2:44am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/18 "2022-01-04T02:44:53Z")

</div>

Yes, we passed the correct `Dt` to `advance` and our timestep size handling is exactly the method which is shown in this video at 9:22.

Additional information:  
The output of `DeltaTime` and `Precice_Dt` during the simulation seems to be fine, but the finish time is still different.

 ![2022-01-10 22-57-27 的屏幕截图](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/3/309fe5b3a713b7fc061e81bac7331b05fa0aac5d.png)  
 ![2022-01-10 22-59-18 的屏幕截图](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/f/f3804e797a360f7488cb2d25182fd9cf3f9bda97.png)  
 ![2022-01-10 22-59-21 的屏幕截图](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/6/68ce8ab648f894b6d60e7a4615c3edc7b0f2b489.png)  
In our code, we use our own `Total_Time` instead of `ongoing` to control the timeloop. May this problem related to the method of timeloop control?

---

<div class="post-metadata">

**Author:** ![Stan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/stan/32/599_2.png) [@Stan](https://precice.discourse.group/u/Stan)\
**Post date:** [January 12, 2022, 1:52am UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/19 "2022-01-12T01:52:10Z")

</div>

Hi all,  
I found out that the cause of my problem was the `adjustTimeStep` in OpenFOAM. I usually set `adjustTimeStep yes` in controlDict to adjust timestep length automatically. Once I close the `adjustTimeStep`, the coupling times are right for both solvers.

 ![2022-01-12 09-44-59 的屏幕截图](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/1/1ff255994d23f20411bea4cc7ac023f11c28a442.png)  
 ![2022-01-12 09-45-08 的屏幕截图](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/b/b12a44f747d242bf18896d96b08b5f4e9ed791fd.png)

It seems that OpenFOAM adapter does fully support the `adjustTimeStep` at present. Will it be on the to do list? 😃

---

<div class="post-metadata">

**Author:** ![DavidSCN](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DavidSCN](https://precice.discourse.group/u/DavidSCN)\
**Post date:** [January 20, 2022, 9:14pm UTC](https://precice.discourse.group/t/strange-phenomenon-during-multiphase-fsi/802/20 "2022-01-20T21:14:14Z")

</div>

> [@Stan](#):
>
> It seems that OpenFOAM adapter does fully support the `adjustTimeStep` at present. Will it be on the to do list?

@Stan there is a related issue on this topic [FSI: Subcycling with implicit coupling · Issue #58 · precice/openfoam-adapter · GitHub](https://github.com/precice/openfoam-adapter/issues/58). Right now, I’m not sure if all descriptions in there are still up-to-date. If you have any related insight or findings into this topic, feel invited to comment there in order to push things a little bit.
