# ERROR when reading "Velocity" in FSI

**URL:** <https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710>\
**Category:** Using preCICE\
**Tags:** openfoam, adapters, fsi\
**Created:** [September 2, 2021, 8:27am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710 "2021-09-02T08:27:55Z")\
**Posts on this page:** 13\
**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:** [September 2, 2021, 8:27am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/1 "2021-09-02T08:27:55Z")

</div>

Hi all,  
Since I want to consider a seepage velocity on the interface which is calculated by the solid participant, I add “Velocity” as a new variable in the FSI module following the steps of adding `Pressure` into the module. After recompiling the OpenFOAM adapter, I modified configuration files and set the boundary condition in U to

```
type fixedValue;
value $internalField;

```

However, when I ran both solvers, an error occurred:

```
This participant does not use Data "Velocity", but attempted to write it. 
Please extend the configuration of participant "Fluid" by defining <write-data mesh="Fluid-Mesh" name="Velocity" />.

```

So I changed the `<read-data mesh="Fluid-Mesh" name="Velocity" />` to `<write-data mesh="Fluid-Mesh" name="Velocity" />` in the configuration file. And then, even though both solvers were running, the results of U on the interface in every timestep were still

```
type fixedValue;
value uniform (0 0 0);

```

I’ve checked out the `partitioned-pipe` case. In its configuration file, there is `<read-data name="Velocity" mesh="Fluid2-Mesh" />` and the tutorial case runs fine.

What could possibly go wrong?  
[precice-config.xml](https://precice.discourse.group/uploads/short-url/4QTlL4hBdx0xWhITeuGcj8SJRXi.xml) (2.1 KB)  
[preciceDict.txt](https://precice.discourse.group/uploads/short-url/OL2egrEf0bD6LC6rxmVjCjAk9V.txt) (508 Bytes)

---

<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 2, 2021, 11:15am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/2 "2021-09-02T11:15:12Z")

</div>

I think you need to change the

```diff
- <write-data name="Velocity" mesh="Fluid-Mesh"/>
+ <read-data name="Velocity" mesh="Fluid-Mesh"/>

```

on the Fluid side and accordingly

```diff
- <exchange data="Velocity" mesh="Fluid-Mesh" from="Solid" to="Fluid" />
+ <exchange data="Velocity" mesh="Solid-Mesh" from="Solid" to="Fluid" />

```

---

<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:** [September 3, 2021, 1:15am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/3 "2021-09-03T01:15:59Z")

</div>

Hi David,  
Yes, at the beginning, I set the precice-config.xml exactly as you suggested, and then I got the error

> [@Stan](#):
>
> ```
> This participant does not use Data "Velocity", but attempted to write it. 
> Please extend the configuration of participant "Fluid" by defining <write-data mesh="Fluid-Mesh" name="Velocity" />.
> 
> ```

---

<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 3, 2021, 6:37am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/4 "2021-09-03T06:37:36Z")

</div>

_Hm_ Which solid solver do you use? In the OpenFOAM adapter, did you add the velocity field in the `addRead` functions? Since you don’t need it on the ‘writing’ side: how about deleting it from the `addWriter` side? I think the config should be fine. You could check it again using the config-visualizer.

---

<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:** [September 3, 2021, 8:36am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/5 "2021-09-03T08:36:03Z")

</div>

The solid solver is just a simple code (compiled using `-lprecice`) that provides displacement and velocity to the fluid solver. (As always, I’d like to use a simple code to test whether “Velocity” could be accurately coupled in FSI module before modifying our in-house solid solver with preCICE)

Yes, I added the velocity field in the `addRead` functions. Both Velocity.C and Velocity.H are copied to FSI directory and `Velocity.C` has been included in the `files` in Make directory. Now I commented the ‘writing’ side and the same error occurs again. 🤔  
[addVelocity.zip](https://precice.discourse.group/uploads/short-url/mSFXHbFBRwRla5gNg0EvjOlDQZ3.zip) (4.3 KB)

---

<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 3, 2021, 1:04pm UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/6 "2021-09-03T13:04:59Z")

</div>

Could you compile the Adapter with `ADAPTER_PREP_FLAGS="-DADAPTER_DEBUG_MODE"` in the `Allwmake` file (run `Allclean` before) and enable a preCICE debug output by exchanging the following log tag in the configuration file:

```xml
<log>
    <sink type="stream" output="stdout" filter= "(%Severity% > debug) or (%Severity% >= trace )" enabled="true" />
</log>

```

and post the generated log file here?

---

<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:** [September 3, 2021, 2:22pm UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/7 "2021-09-03T14:22:38Z")

</div>

Yes, of course. I’ve recompiled the adapter and modified the configuration file as you suggested. The output of ‘Allwmake’(i.e. ‘ldd.log’ and ‘wmake.log’) and the log of fluid solver are uploaded.  
Thanks for your help!  
[Allwmake.zip](https://precice.discourse.group/uploads/short-url/npHjrheF3uHuDcnyVhesv5zg6Tm.zip) (4.2 KB)  
[fluidSolver.zip](https://precice.discourse.group/uploads/short-url/lAEtyas5U4F20MEf6WvIhdODuYj.zip) (6.6 KB)

---

<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 3, 2021, 4:06pm UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/8 "2021-09-03T16:06:17Z")

</div>

You have an error in `FSI.C` line 226, should be a reader there, not a writer…

---

<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:** [September 4, 2021, 8:18am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/9 "2021-09-04T08:18:59Z")

</div>

I’m sorry that I was so careless…  
After correcting this mistake, I found that the values on the interface BC in U is a uniform value instead of a nonuniform List :

```
caisson
{
    type fixedValue;
    value uniform (0.000499167 0.000249584 0);
}

```

I’ve tried to add another Interface in `preciceDict` as follows:

 ![interfaces](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/9c8c0085df7854fcd142ceafdd533b44a52c789a.png)

but I still got a uniform value.

---

<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:** [September 9, 2021, 7:22am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/10 "2021-09-09T07:22:54Z")

</div>

This problem has been solved. It is due to the mapping method setting in the configuration file. After I changed the mapping method from `nearest-neighbor` to `rbf-thin-plate-splines`, the velocity values of all the cells on the coupling interface (i.e. a `nonuniform List<vector>`) are written correctly in ‘U’ file.

Maybe this is the [numerical deficiency](https://precice.org/configuration-mapping.html) that `nearest-neighbor` method has?

---

<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 13, 2021, 1:37pm UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/11 "2021-09-13T13:37:52Z")

</div>

@Stan thank you for documenting your steps and progress here. As the topic already mentions a few technical issues with the configuration, I would like once again to recommend to future readers to use the config visualizer: [Config visualization | preCICE - The Coupling Library](https://precice.org/tooling-config-visualization.html)

Regarding your last post:

> [@Stan](#):
>
> This problem has been solved. It is due to the mapping method setting in the configuration file. After I changed the mapping method from `nearest-neighbor` to `rbf-thin-plate-splines` , the velocity values of all the cells on the coupling interface (i.e. a `nonuniform List<vector>` ) are written correctly in ‘U’ file.
> 
> Maybe this is the [numerical deficiency](https://precice.org/configuration-mapping.html) that `nearest-neighbor` method has?

I cannot see how the preCICE mapping could affect these errors: yes, nearest-neighbor is less accurate, but this could only lead to numerical errors, not such configuration errors. Can you reproduce this behavior?

Otherwise, let’s close this thread and continue discussing in separate threads for new questions. 😃

---

<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:** [September 14, 2021, 7:27am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/12 "2021-09-14T07:27:08Z")

</div>

Hi Makis,  
Sorry for the late reply.

> [@Makis](#):
>
> yes, nearest-neighbor is less accurate, but this could only lead to numerical errors, not such configuration errors.

Yes, I cannot agree more. However, I’m pretty sure that the output of `U` is different between these two methods and I have reproduced this behavior as follows:  
( `caisson` is the interface in the simulation. Please do not focus on the values on boundary `caisson`, I gave the same values to those cells on the interface just out of convenience. The figure on the left is the output using `nearest-neighbor` method and the figure on the right is the case in which `rbf-thin-plate-splines` method is adopted. All the other settings of these two case are exactly the same. I dont’ know what may lead to this problem.)

 ![OutputofDifferentMappingMethods](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/eac5c7cba624e2cb08c2d57a10bb050ebb7a8725.png)

In addition, the config visualizer is quite convenient and useful. You can see that the mapping method is the only difference between the two case.

 ![config_nn](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/83d1322a6d73cc8034f3d2a03730ea635d656d28.png)  
 ![config_rbf](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/056debb05b7cde5ad5970f370e89363152d54322.png)

Since `Pressure` can be successfully output and the additional `Velocity` can be read through openfoam-adapter (once the values are read by OpenFOAM, they are used in the next timestep, right?), I’m sure that preCICE is of great help of my study. After several problems in our in-house code are solved, I’ll adopt preCICE to couple it with OpenFOAM using the same method as soon as possible.  
By the way, thanks again for the generous help provided by preCICE team! 😉

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [September 17, 2021, 7:28am UTC](https://precice.discourse.group/t/error-when-reading-velocity-in-fsi/710/13 "2021-09-17T07:28:02Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
