# Running FSI flap\_perp example with OpenFOAM and Calculix

**URL:** <https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178>\
**Category:** Official adapters and tutorials\
**Tags:** openfoam, calculix, fsi\
**Created:** [March 20, 2020, 6:39pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178 "2020-03-20T18:39:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmaslov](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@dmaslov](https://precice.discourse.group/u/dmaslov)\
**Post date:** [March 20, 2020, 6:39pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/1 "2020-03-20T18:39:49Z")

</div>

Hello Everyone!  
The whole week of staying home due to the quarantine I happily dedicated trying to make at least the tutorial, which is presented [here](https://github.com/precice/precice/wiki/Tutorial-for-FSI-with-OpenFOAM-and-CalculiX). My current settings are OpenFOAM 7 with appropriate adapter, Calculix 2.15 ccx and cgx with own appropriate adaptor and preCICE v2.0.1, installed from .deb package and linked to libraries. The tutorial cases which come with each of the packages run smooth according to the instructions.

The problem is that I still cannot launch the FSI simulation in Step 3 of tutorial, `flap_perp` with `./Allrun` or subsequently doing `runSolid` and then `runFluid` and vice verse.

In case I try `./Allrun` the output of `Fluid.log` is  
`./Allrun: line 58: -case: command not found`  
whereas this line in `Allrun` states following:  
` ${Solver1} -case ${Participant1} > ${Participant1}.log 2>&1 &`

and the output of Solid.log is

* * *

CalculiX Version 2.15, Copyright© 1998-2018 Guido Dhondt  
CalculiX comes with ABSOLUTELY NO WARRANTY. This is free  
software, and you are welcome to redistribute it under  
certain conditions, see gpl.htm

* * *

You are using an executable made on Sa 15. Dez 15:34:34 CET 2018

In the event I apply `./Allclean` and start from the scratch with `./runFluid` the simulation seems going ok in terminal as it enters in loop and ends with the line  
`---[precice] Setting up master communication to coupling partner/s`  
I guess at this point it waits till the solid solver comes, so I launch `./runSolid` in a separate terminal window and the last two lines of the outputs in the terminal are as follow:

```
 Determining the structure of the matrix:
./runSolid: line 19: 14818 Segmentation fault (core dumped) ccx_preCICE -i Solid/flap -precice-participant Calculix

```

Please let me know if it is resolvable and if I can supply more info.

Best regards,  
Dmytro.

---

<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 20, 2020, 7:12pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/2 "2020-03-20T19:12:58Z")

</div>

I cannot reproduce this problem, but let’s try to find what could be going wrong.

The error you get:

```
./Allrun: line 58: -case: command not found

```

is triggered by:

```bash
${Solver1} -case ${Participant1} > ${Participant1}.log 2>&1 &

```

and essentially means that `${Solver1}` (and also `${Participant1}`) is empty. This is supposed to already have a value from:

```bash
Solver1=$(getApplication)

```

which gets the OpenFOAM application defined in the case’s `system/controlDict`. It should be `pimpleFoam` and if you replace the respective line, it should run:

```diff
- ${Solver1} -case ${Participant1} > ${Participant1}.log 2>&1 &
+ pimpleFoam -case Fluid > Fluid.log 2>&1 &

```

My guess is that something is wrong (i.e. different) with your shell. Do you maybe use some other shell instead of Bash? As far as I know, it also works with zsh, but maybe you are using something else.

---

<div class="post-metadata">

**Author:** ![dmaslov](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@dmaslov](https://precice.discourse.group/u/dmaslov)\
**Post date:** [March 23, 2020, 3:20pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/3 "2020-03-23T15:20:10Z")

</div>

Hello @Makis, thank You for the reply. Indeed I work with bash, for some reason the sourcing of the OpenFOAM routines after launching the `Allrun` file was not working. Now, the case is launching normally till the line 57 of the `Allrun` file, which is

`${Solver2} -i ${Participant2}/flap -precice-participant Calculix > ${Participant2}.log 2>&1 &`

or, in more readible terms,

`ccx_preCICE -i Solid/flap -precice-participant Calculix > Solid.log 2>&1 &`

After running the case until this line and than manually introducing this command in the  
terminal, the response is as follow:

`Segmentation fault (core dumped)`

In case I try to run first ./runFluid, the terminal output last line is

`---[precice] Setting up master communication to coupling partner/s`

and than ./runSolid, the terminal output last 7 lines are like this:

```
 STEP 1

 Dynamic analysis was selected

 Newton-Raphson iterative procedure is active

 Nonlinear geometric effects are taken into account

 Decascading the MPC's

 Determining the structure of the matrix:
./runSolid: line 19: 32067 Segmentation fault (core dumped) ccx_preCICE -i Solid/flap -precice-participant Calculix

```

Any thoughts?

Best regards,  
Dmytro.

---

<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 23, 2020, 5:45pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/4 "2020-03-23T17:45:02Z")

</div>

So, you get a segmentation fault while running the CalculiX adapter (using the flap\_perp tutorial, as-is). You already said that you are using CalculiX 2.15 with the right version of the adapter.

The expected output is:

```
 STEP 1

 Dynamic analysis was selected

 Newton-Raphson iterative procedure is active

 Nonlinear geometric effects are taken into account

 Decascading the MPC's

 Determining the structure of the matrix:
 number of equations
 240
 number of nonzero lower triangular matrix elements
 3128

Starting FSI analysis via preCICE using the geometrically non-linear CalculiX solver...
 Using up to 1 cpu(s) for the stress calculation.

 Using up to 1 cpu(s) for the symmetric stiffness/mass contributions.

 Factoring the system of equations using the symmetric spooles solver
 Using 1 cpu for spooles.

 Using up to 1 cpu(s) for the stress calculation.

About to enter preCICE setup in Calculix with names Calculix and config.yml 
Setting up preCICE participant Calculix, using config file: config.yml
---[precice] This is preCICE version 2.0.0

```

so, it looks like it breaks ?before? the first call to preCICE. Did anything go wrong during building the CalculiX adapter? Any warnings?

---

<div class="post-metadata">

**Author:** ![dmaslov](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@dmaslov](https://precice.discourse.group/u/dmaslov)\
**Post date:** [March 24, 2020, 10:13am UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/5 "2020-03-24T10:13:13Z")

</div>

The adapter was built without building the Calculix instelf. The location of the adapter folder is in `/usr/local/CalculiX/calculix-adapter-master` and, after configuring `Makefile`with correct paths, was built with `sudo make`. On a run there were numerous warnings of three types

`Warning: ‘nnr’ may be used uninitialized in this function [-Wmaybe-uninitialized]`

`/usr/local/CalculiX/ccx_2.15/src/mastruct.c:42:49: warning: unused variable ‘istart’ [-Wunused-variable]`

`Warning: ‘multslav’ may be used uninitialized in this function [-Wmaybe-uninitialized]`

Already tried with all three types of compilers `FC = mpifort` OR `mpif90` OR `gfortran`, the terminal output is more or less the same in terms of warnings, in all cases the `ccx_preCICE` is generated and located at `/usr/bin/ccx_preCICE`.

---

<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 24, 2020, 10:27am UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/6 "2020-03-24T10:27:23Z")

</div>

These warning could be related, but it still looks like they are originating in CalculiX itself. What compiler versions are you using? Keep also [this issue](https://github.com/precice/calculix-adapter/issues/15) in mind.

Can you run any CalculiX-only case? (not sure what you could try, but there are some examples on their website)

If you trace this down to the CalculiX adapter, could you please [open an issue](https://github.com/precice/calculix-adapter/issues)?

---

<div class="post-metadata">

**Author:** ![dmaslov](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@dmaslov](https://precice.discourse.group/u/dmaslov)\
**Post date:** [March 25, 2020, 4:04pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/7 "2020-03-25T16:04:28Z")

</div>

Hello @Makis, thanks for the reply.

The compiler version is provided by

`$ gfortran --version`

results with

`GNU Fortran (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0`  
This compiler was used for both the CalculiX and adapter installation.  
The issue, which You mention, is adopted already in the text `Makefile` of the adapter, do I need to change to something else?

Regarding running the case - yes, I can, majority of the test examples from the CalculiX web-site execute with no problems,for example the `$ ccx_2.15 beamp` provides a normal output in terminal and results coincide precisely with the example values.

After analyzing everything once again from the beginning, found that due to lack of knowledge of scripting in Ububntu, I did not implement correct adding the CalculiX adapter to the `PATH`, my bad! By chance found this long [script](https://gist.github.com/jeonwooyoung/a5cbed916a5b19f41c7f59d74f25be15), which can provide a better insight for Ubuntu beginners how to program and install things correctly. The FSI case with flap successfully finished simulation and the results look nice, will continue playing with them around. Thank you very much!!

---

<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 25, 2020, 5:05pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/8 "2020-03-25T17:05:42Z")

</div>

I understand that you solved your issue (great!) but I am not sure I understand what the problem was at the end. Could you please add a few more details?

It could be useful for future readers, as well as for us, trying to improve things. 🙂

---

<div class="post-metadata">

**Author:** ![dmaslov](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@dmaslov](https://precice.discourse.group/u/dmaslov)\
**Post date:** [March 25, 2020, 7:15pm UTC](https://precice.discourse.group/t/running-fsi-flap-perp-example-with-openfoam-and-calculix/178/9 "2020-03-25T19:15:41Z")

</div>

The lesson is - _make a proper path with proper commands for all necessary libs/bins_. The short story short: I did  
`echo "export PATH=/usr/local/CalculiX/calculix-adapter-master/bin:$PATH>> /home/dmaslov/.bashrc`  
to provide a clear path for the `preCICE` adapter after installing it and everything worked. So the problem was that the path to generated `/bin/preCICE` was not correct.

The long story…  
After installing the adapter there was an issue with `libyaml-cpp.so.0.5` when the `ccx_preCICE` was called, discussed [here](https://gist.github.com/AkashkumarDev/07e203ad88d72f16cfde). I decided to take a closer look at what is happening with making this lib visible, while it was not located at `/usr/local/lib`, as suggested in solution. After searching how to do it properly, I realized that the best way is to use another command for such cases, which are best shown in [this](https://gist.github.com/jeonwooyoung/a5cbed916a5b19f41c7f59d74f25be15) script, instead of trying to manually add it in `~/.profile`.
