# Multiple Coupling Variable for OpenFOAM

**URL:** <https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169>\
**Category:** Using preCICE\
**Tags:** openfoam, adapters, dealii\
**Created:** [September 26, 2022, 4:11pm UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169 "2022-09-26T16:11:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![diksanm7](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/diksanm7/32/1436_2.png) [@diksanm7](https://precice.discourse.group/u/diksanm7)\
**Post date:** [September 26, 2022, 4:11pm UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169/1 "2022-09-26T16:11:27Z")

</div>

Hello,

I am currently working on FSI simulation using OpenFOAM and Deal II and want to modify the coupling variable. I want OpenFOAM adapter to read 2 variable from Deal II (displacement and acceleration). Is there a way to do that? Or is there any thread that has already discussed this (i have not found anything related to this).

Thank You

---

<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:** [September 27, 2022, 12:35pm UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169/2 "2022-09-27T12:35:58Z")

</div>

Hi @diksanm7,

that’s a good question. May I ask you to describe a bit more in detail what you want to do with the second variable? In principle, reading multiple data sets associated to the same interface is possible. However, there are currently no readers and writers for acceleration data. How do you intend process the acceleration data? You can find some general information about extending the OpenFOAM adapter in the corresponding adapter documentation [Extend the OpenFOAM adapter | preCICE - The Coupling Library](https://precice.org/adapter-openfoam-extend.html#starting-points).

---

<div class="post-metadata">

**Author:** ![diksanm7](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/diksanm7/32/1436_2.png) [@diksanm7](https://precice.discourse.group/u/diksanm7)\
**Post date:** [September 28, 2022, 6:55am UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169/3 "2022-09-28T06:55:07Z")

</div>

Hi @DavidSCN, thank you for the answer

So, i would like to implement some equations for the boundary interface. Normally, OpenFOAM writes the fluid stress and then to be read by Deal II directly (solid stress input = fluid stress). But i need correction for the solid stress input (solid stress input = fluid stress + correction stress) where the correction stress is also a function of acceleration from the previous time step. Currently, i am still working on creating the acceleration class for OpenFOAM adapter.

---

<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:** [September 28, 2022, 7:42am UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169/4 "2022-09-28T07:42:18Z")

</div>

I’m not sure if there is a predefined acceleration (of what?) field available in OpenFOAM, from which you can immediately extract the data you are looking for. If you anyway want to correct the `Stress` data field, you can also directly add your correction contribution within the `Stress` data class (no need to create a new class for it) [openfoam-adapter/ForceBase.C at da63afb96560be7cf2b2a18dbd53f983abc806c2 · precice/openfoam-adapter · GitHub](https://github.com/precice/openfoam-adapter/blob/da63afb96560be7cf2b2a18dbd53f983abc806c2/FSI/ForceBase.C#L159-L179)

If you decide to create a new class you may want to consider using a summation action in preCICE ([Action configurations | preCICE - The Coupling Library](https://precice.org/configuration-action.html#basics-and-pre-implemented-actions)). Then, preCICE will handle the summation of the two distinct data fields and transfer the sum to OpenFOAM.

---

<div class="post-metadata">

**Author:** ![diksanm7](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/diksanm7/32/1436_2.png) [@diksanm7](https://precice.discourse.group/u/diksanm7)\
**Post date:** [September 28, 2022, 12:36pm UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169/5 "2022-09-28T12:36:19Z")

</div>

I mean the acceleration is from Deal II. So it will be like this,

1. Deal II writes 2 variables which are displacement and acceleration. The displacement to be read by OpenFOAM will be corrected by function of fluid stress (solved).
2. OpenFOAM writes fluid stress. The fluid stress to be read by deal II will be corrected by function of fluid stress (solved) and the acceleration which was written by deal II earlier. I think the acceleration does not need to be read by OpenFOAM but need to be read by the adapter only.

Any suggestion about this?

---

<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:** [October 23, 2022, 9:31am UTC](https://precice.discourse.group/t/multiple-coupling-variable-for-openfoam/1169/6 "2022-10-23T09:31:11Z")

</div>

> [@diksanm7](#):
>
> OpenFOAM writes fluid stress. The fluid stress to be read by deal II will be corrected by function of fluid stress (solved) and the acceleration which was written by deal II earlier. I think the acceleration does not need to be read by OpenFOAM but need to be read by the adapter only.

Wouldn’t it be easier to perform the acceleration correction on the deal.II side instead of the OpenFOAM side?

In case this is not possible, you can still do what you are looking for in multiple ways. You could e.g. create a dedicated buffer for the acceleration [https://github.com/precice/openfoam-adapter/blob/154eb718c4708e3f65dcc3a077741314b123bcd1/Interface.H#L42-L43](https://github.com/precice/openfoam-adapter/blob/154eb718c4708e3f65dcc3a077741314b123bcd1/Interface.H#L42-L43) and read later on data from this buffer when writing the stress. As an alternative, you could probably also use the current interface of the adapter (i.e. create an acceleration data class) and access the acceleration data during the stress computation, as the data buffer of each interface is shared among data classes. All in all, it is definitely possible, but will require changes in different places.
