# Multiphase FSI case with the OpenFOAM adapter

**URL:** <https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163>\
**Category:** Using preCICE\
**Tags:** openfoam, multiphase\
**Created:** [September 21, 2022, 9:21am UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163 "2022-09-21T09:21:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![raynold\_tan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/raynold_tan/32/1430_2.png) [@raynold\_tan](https://precice.discourse.group/u/raynold_tan)\
**Post date:** [September 21, 2022, 9:21am UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/1 "2022-09-21T09:21:47Z")

</div>

Hi all,

I am currently working on a multiphase FSI simulation of the dambreak problem where the water will impact onto a flexible beam. Attached is the picture. I am having an issue where the moment the water impact onto the flexible beam, the time step become prohibitively small until the simulation crash (t=0.11). I am not very sure of the cause of the problem. Inside the fluid-open foam solver setting of the 0 folder, I am not 100percent sure of the boundary condition inside the pointDisplacement file. I have used the following settings:

boundaryField  
{

```
interface
{
    type fixedValue;
    value $internalField;
}

leftWall
{
    type slip;
}

rightWall
{
    type slip;
}

lowerWall
{
    type fixedValue;
    value uniform (0 0 0);
}

atmosphere
{
    type fixedValue;
    value uniform (0 0 0);
}

defaultFaces
{
    type empty;
}

```

}

The attached picture shows the timestep at which the simulation crash. (the time step becomes too small) Also, my another concern is regarding about the openfoam adapter. I have a look inside the Forcebase.C file of the FSI module. I noticed that the pressure forces are calculated by searching for the ‘p’ variable at the beginning. However, in the case of interFoam, p\_rgh is defined inside the 0 folder. I am not sure if this will cause any issue with the coupling. That we should use the p\_rgh variable instead of the p variable?  
However, it is noted that the coupled simulation was able to run smoothly for a while.

 ![flexible_dambreak](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/f/f13e66e691c828c4499ac0a6e91a7a212567f105.png)

The precice-config file was set up similarly as the one used inside the official tutorial perpendicular flap case. Please advise if you know how to resolve the issue. It should also be mentioned that solids4Foam is used as the structural solver. A linearElastic model was used to model the beam.

---

<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:** [September 21, 2022, 11:55am UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/2 "2022-09-21T11:55:03Z")

</div>

Hi @raynold_tan,

> [@raynold\_tan](#):
>
> I noticed that the pressure forces are calculated by searching for the ‘p’ variable at the beginning. However, in the case of interFoam, p\_rgh is defined inside the 0 folder. I am not sure if this will cause any issue with the coupling. That we should use the p\_rgh variable instead of the p variable?

yes, you need to ask interFoam to use `p_rgh` as the temperature name. It should then use that as a pressure field:

> <https://github.com/precice/openfoam-adapter/blob/f521d3c9308b2b75d1e4232ec59a3a38ceb0a7c1/FF/Pressure.C#L8-L10>

You can do that by adding `nameP` in your `preciceDict`, similar to these instructions: [Configure the OpenFOAM adapter | preCICE - The Coupling Library](https://precice.org/adapter-openfoam-config.html#parameters-and-fields-with-different-names)

I realized we have not yet documented this option, but you can find out the exact option by looking at this part of the code:

> <https://github.com/precice/openfoam-adapter/blob/f521d3c9308b2b75d1e4232ec59a3a38ceb0a7c1/FF/FF.C#L58-L60>

I opened a [related issue](https://github.com/precice/openfoam-adapter/issues/250) to update the documentation with everything FF-related soon.

Other than that, maybe people that have done similar multi-phase simulations in the past (e.g., @Jianzhou722, @Alphaoo1, @bitronteofil, or @Michael) could also help here. See also a few related topics:

- [FSI with interFoam and CalculiX: Convergence](https://precice.discourse.group/t/fsi-with-interfoam-and-calculix-convergence/334)
- [FSI with interFoam and CalculiX](https://precice.discourse.group/t/fsi-with-interfoam-and-calculix/277)
- [FSI: OpenFOAM adapter with interFOAM](https://precice.discourse.group/t/fsi-openfoam-adapter-with-interfoam/175)
- [OpenFOAM adapter for InterFoam: Density in Incompressible flow](https://precice.discourse.group/t/openfoam-adapter-for-interfoam-density-in-incompressible-flow/826)

---

<div class="post-metadata">

**Author:** ![raynold\_tan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/raynold_tan/32/1430_2.png) [@raynold\_tan](https://precice.discourse.group/u/raynold_tan)\
**Post date:** [September 21, 2022, 1:06pm UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/3 "2022-09-21T13:06:31Z")

</div>

Hi Makis,

I noticed that the lines of code you have pointed me to are implemented inside the Fluid-Fluid Coupling module. I was wondering if this matters for the FSI module. I am running a FSI case.

> <https://github.com/precice/openfoam-adapter/blob/f521d3c9308b2b75d1e4232ec59a3a38ceb0a7c1/FSI/ForceBase.C#L148-L149>

Or that the lines of code from FF module should be added to the FSI module?

---

<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:** [September 22, 2022, 10:46am UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/4 "2022-09-22T10:46:07Z")

</div>

Ah, you are right, I am looking too frequently at the FF module lately…

I assume you could try directly changing `p` to `p_rgh` in the code you linked and rebuild the adapter. What happens then?

---

<div class="post-metadata">

**Author:** ![raynold\_tan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/raynold_tan/32/1430_2.png) [@raynold\_tan](https://precice.discourse.group/u/raynold_tan)\
**Post date:** [September 22, 2022, 5:26pm UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/5 "2022-09-22T17:26:08Z")

</div>

Hi Makis,

I have finally identified the issue of the cause of the crash. It is due to the time stepping size. To get the simulation working, I have actually set a much smaller tilmestep size of t=0.0001 in the controlDict of the fluid and solid cases. Also, the timestep set in the precise-config.xml file has to be set to t=0.0001 for the simulation to run stably. It. seems that for the FSI module, the use of the p variable to compute the pressure forces are correct for the interFoam solver (as well) because the p variable is generated after time step 0. I also added a p file inside the 0 folder where the boundaries are set to calculated. So the p variable can indeed be found and is used in the coupling.

I am still investigating how the tilmestep size cane be increased without having the issue of sub cycling in the FSI simulation, which would cause the FSI simulation to crash after some time. If you have any suggestions as to how the settings for the coupling or interpolation inside the precice-config file can allow for larger time steps, please let me know.

---

<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:** [September 23, 2022, 8:51am UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/6 "2022-09-23T08:51:43Z")

</div>

Could you attach your `precice-config.xml`?

---

<div class="post-metadata">

**Author:** ![raynold\_tan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/raynold_tan/32/1430_2.png) [@raynold\_tan](https://precice.discourse.group/u/raynold_tan)\
**Post date:** [September 23, 2022, 12:16pm UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/7 "2022-09-23T12:16:53Z")

</div>

Attached is the config file. I did not change anything much except for the timestep (time window size) = 0.0001 and the max time value = 1.0 which is the final time of the simulation.

[precice-config.xml](https://precice.discourse.group/uploads/short-url/jR5oVkJXX6b7Q6ChRmrnwQnyjRi.xml) (2.4 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:** [September 28, 2022, 1:49pm UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/8 "2022-09-28T13:49:04Z")

</div>

I am not sure what else you need to do to improve the situation. Probably not much in terms of the acceleration, but maybe the problem is in the coupling setup itself: what you are coupling, how you are setting boundary conditions, etc.

---

<div class="post-metadata">

**Author:** ![raynold\_tan](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/raynold_tan/32/1430_2.png) [@raynold\_tan](https://precice.discourse.group/u/raynold_tan)\
**Post date:** [September 28, 2022, 2:51pm UTC](https://precice.discourse.group/t/multiphase-fsi-case-with-the-openfoam-adapter/1163/9 "2022-09-28T14:51:58Z")

</div>

Hi Makis,

I was able to circumvent this issue by setting the adjustTimestep inside the controlDict of the fluid side to ‘No’. I was able to use a larger timestep without blowing up the simulation. For some reason, when the adjustable timestep is set to ‘Yes’, it somehow trigger the sub cycling behaviour on the fluid side. And then I get the message: ‘sub cycling not fully supported and may cause instabilities’. But the thing I don’t understand is why the timestep just get smaller. I checked the Courant number and the interface Courant number and yet it is much below the specified value in the controlDict.

Raynold
