# FSI ( Openfoam + my solver using python)

**URL:** <https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823>\
**Category:** Is preCICE for me?\
**Tags:** openfoam, fsi\
**Created:** [March 10, 2024, 9:47am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823 "2024-03-10T09:47:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/aman/32/2224_2.png) [@Aman](https://precice.discourse.group/u/Aman)\
**Post date:** [March 10, 2024, 9:47am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/1 "2024-03-10T09:47:46Z")

</div>

I want to couple OpenFOAM with my Python code. My problem statement is to simulate vortex-induced vibration for long flexible pipe. I want to model multiple 2D OpenFOAM cases to obtain the force. I am choosing multiple 2D cases to reduce computational costs. I want to use overset mesh and the PimpleFoam solver. My in-house Python code, based on FEM, provides deflection at each time step, which displaces the overset mesh.

1. Is Precice useful for this case?
2. Is it better to use multiple 2D planes cross-sections in a flexible pipe or a single 3D pipe?
3. What tutorials would be helpful to me?  
 ![image](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/0/03d214ec86574f73e77343dc131fdf6a33b0dd3b.png)

---

<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:** [March 11, 2024, 7:42pm UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/2 "2024-03-11T19:42:55Z")

</div>

Hi Aman,

> [@Aman](#):
>
> Is Precice useful for this case?

Yes, preCICE in general can do this: you have a clear separation between the flow and the structure domains.

> [@Aman](#):
>
> Is it better to use multiple 2D planes cross-sections in a flexible pipe or a single 3D pipe?

Both should be possible, the 2D cross-sections should be computationally cheaper, but more complicated to model. The single 3D pipe should be easy to model in OpenFOAM for the flow, and I hope in your in-house Python code for the structure.

General rule of thumb: It is important to choose tools you already know or have good documentation and some community. preCICE itself is easy, the complicated part are the simulation codes (OpenFOAM, your in-house solver, etc).

> [@Aman](#):
>
> What tutorials would be helpful to me?

Sounds like our elastic tube tutorials could be helpful:

- 3D: [Elastic tube 3D | preCICE - The Coupling Library](https://precice.org/tutorials-elastic-tube-3d.html)
- 1D: [1D Elastic Tube | preCICE - The Coupling Library](https://precice.org/tutorials-elastic-tube-1d.html)

> [@Aman](#):
>
> vortex-induced vibration

I assume that turbulence modelling in important for you. You might encounter this issue regarding checkpointing. In that case, please help me reproduce it:

> <https://github.com/precice/openfoam-adapter/issues/158>
>
> Hi there,
> 
> This issue was found when I was doing a FSI simulation using OpenFO…AM v7 / CalculiX v2.15 / preCICE v2.0.0.
> Please let me lead you to this \[discourse-post\](https://precice.discourse.group/t/different-dimensions-for-dimensions-issue/535) for more details.
> 
> As suggested by @MakisH , a brief introduction to the settings of turbulence model in OpenFOAM is to simply turn on the turbulence by setting \`/constant/turbulenceProperties\` file, using:
> \`\`\`
> simulationType RAS;
> RAS
> {
> RASModel kOmegaSST;
> turbulence on;
> }
> \`\`\`
> Of course, the corresponding initial conditions such as \`k\`, \`omega\`, \`nut\`, \`p\` and \`U\` are well defined in the \`0/\` directory.
> 
> When the turbulence model is turned on, the FSI simulation stops at the 2nd iteration of the first time step of the coupling (shown in the figure in the \[post\](https://precice.discourse.group/t/different-dimensions-for-dimensions-issue/535/2))
> 
> Interestingly however, when I turned off the turbulence (switch to \`laminar\`):
> 
> \`simulationType laminar;\`
> 
> The FSI simulation went well and no errors are reported. However, the results are definitely not I'm expecting since the turbulent behaviours cannot be well resolved in my FSI simulation.
> 
> As @MakisH said, I do also suspect this issue might be originated from the OpenFOAM adapter side, so I'm looking for help from developers.
> 
> Should you requires more information please contact me directly and I'm happy to assists.

> [@Aman](#):
>
> I want to use overset mesh

What do you need the overset mesh for?

---

<div class="post-metadata">

**Author:** ![Aman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/aman/32/2224_2.png) [@Aman](https://precice.discourse.group/u/Aman)\
**Post date:** [March 12, 2024, 6:20am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/3 "2024-03-12T06:20:12Z")

</div>

Thank you for your response. The 2D overset mesh will displace according to displacement data from the FEM solver, while the background mesh will remain fixed.

I have one more query: Like multiple solver couplings, as mentioned in the multiple perpendicular flap tutorial? Can I use multiple couplings to create, let’s say, 20 2D cases of OpenFOAM (representing forces) and couple them with a single Python solver (representing displacement)?

The OpenFOAM cases will run simultaneously, providing forces, which will then be transferred to the FEM code to generate displacement. This displacement will in turn displace the 20 meshes of OpenFOAM simultaneously, and so on.

---

<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:** [March 12, 2024, 7:23am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/4 "2024-03-12T07:23:12Z")

</div>

Sounds a bit complicated (maybe unnecessarily complicated), but yet, this is possible. You would need to configure 21 different participants, though, which will be cumbersome (people have tried making scripts to generate such configuration files, using jinja2).

Maybe try running a few tutorials first to get more ideas on what is common and easy and what is not.

---

<div class="post-metadata">

**Author:** ![Aman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/aman/32/2224_2.png) [@Aman](https://precice.discourse.group/u/Aman)\
**Post date:** [March 12, 2024, 11:46am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/5 "2024-03-12T11:46:46Z")

</div>

Okk . Thanks ,i will try.

---

<div class="post-metadata">

**Author:** ![Gong\_CHEN](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/gong_chen/32/2212_2.png) [@Gong\_CHEN](https://precice.discourse.group/u/Gong_CHEN)\
**Post date:** [October 10, 2024, 5:13am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/6 "2024-10-10T05:13:14Z")

</div>

Hi, makis, I have uploaded the case may reproduce the problem.  
`https://github.com/precice/openfoam-adapter/issues/158`

---

<div class="post-metadata">

**Author:** ![Shri](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Shri](https://precice.discourse.group/u/Shri)\
**Post date:** [March 1, 2025, 10:22am UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/7 "2025-03-01T10:22:10Z")

</div>

Hello Makis and Aman, I am also working on the same problem. So far, I have used OpenFOAM to solve both the fluid and structure equations for both morphing and overset meshes. However, I now want to use OpenFOAM to solve the fluid equations while using preCICE to handle the structural displacement.  
Is this possible? If so, could you please guide me on how to achieve it?

---

<div class="post-metadata">

**Author:** ![Aman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/aman/32/2224_2.png) [@Aman](https://precice.discourse.group/u/Aman)\
**Post date:** [March 15, 2025, 4:29pm UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/8 "2025-03-15T16:29:19Z")

</div>

Hi shri , kindly explain me what you want to do

---

<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:** [March 19, 2025, 1:22pm UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/9 "2025-03-19T13:22:05Z")

</div>

@Shri please open a new thread describing what you want to simulate. See some tutorials that might be similar to what you are trying to do: [Perpendicular flap | preCICE - The Coupling Library](https://precice.org/tutorials-perpendicular-flap.html)

---

<div class="post-metadata">

**Author:** ![Shri](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Shri](https://precice.discourse.group/u/Shri)\
**Post date:** [March 21, 2025, 2:22pm UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/10 "2025-03-21T14:22:08Z")

</div>

hello aman & Makis, first of all, thank you for your response. I am currently working on vortex-induced vibration phenomena using OpenFOAM7. In my steup, the fluid and structure equations are solved using pimpleFoam and the sixDOFRigidBodyMotion respectively. However, I now need to modify the structure equation, which is not possible directly within OpenFoam. To address this, I am considering coupling OpenFOAM with Python so that the fluid equations can be solved in OpenFOAM while the structural equation is solved in Python. Is it possible to implement such a coupling, and if so, how can it be achieved?

---

<div class="post-metadata">

**Author:** ![Aman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/aman/32/2224_2.png) [@Aman](https://precice.discourse.group/u/Aman)\
**Post date:** [March 21, 2025, 2:33pm UTC](https://precice.discourse.group/t/fsi-openfoam-my-solver-using-python/1823/11 "2025-03-21T14:33:10Z")

</div>

Yes it is possible and I also did the similar thing using openfoam and python using precice . Perpendicular flap example helped me in this.Kindly ping me in [prasadaman333@gmail.com](mailto:prasadaman333@gmail.com)
