# Parallel FEnics case fail

**URL:** <https://precice.discourse.group/t/parallel-fenics-case-fail/834>\
**Category:** Using preCICE\
**Tags:** adapters\
**Created:** [December 17, 2021, 9:08am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834 "2021-12-17T09:08:19Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [December 17, 2021, 9:08am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/1 "2021-12-17T09:08:19Z")

</div>

Hi Everybody, I got a question regarding the parallelization of Fenics. When I run CHT problem with FEniCS and FEniCS, I get the following error message

 ![2021-12-17 17-00-27 的屏幕截图](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/c/c3dcc948c31da3da1f72c2e3473ccc0a04fdd450.png)

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [December 20, 2021, 5:53pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/2 "2021-12-20T17:53:02Z")

</div>

Hi @fish,

Welcome to the forum!

From the error my best guess is that a processor which does not have a part of the coupling mesh is somehow trying to update data on an Expression which is leading to a sizeless array being passed to `scipy.interpolate.Rbf`. Ideally this should not happen as the FEniCS adapter checks within the function `update_coupling_expression` if the particular processor partition has any vertices or not. Lets try to figure out your case better.  
Are you running the [partitioned-heat](https://github.com/precice/tutorials/tree/8e71370f0700caa25892af04145be79a3f79aff5/partitioned-heat-conduction/fenics) or the [flow-over-heated-plate](https://github.com/precice/tutorials/tree/8e71370f0700caa25892af04145be79a3f79aff5/flow-over-heated-plate/solid-fenics) tutorial cases as they are? Or have you modified something? Also, how do you execute the parallel FEniCS code?

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [December 22, 2021, 3:07am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/3 "2021-12-22T03:07:16Z")

</div>

Hi@ [IshaanDesai](https://precice.discourse.group/u/IshaanDesai), I am running the partitioned-heat-complex tutorial cases, and some fluid equation are added in my code. Besides, anything is not changed. The running way of parallel likes: 1、mpirun -n 8 python3 solid.py … 2、mpirun -n 20 python3 fluid.py … And also, the calculate domain is changed 1e-7\*1e-7(2D) and have a small cavity on my mesh.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [December 22, 2021, 1:48pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/4 "2021-12-22T13:48:30Z")

</div>

Hi @fish

Adding fluid equations to the existing FEniCS should not break anything as long as you use FEniCS Expression objects to define the equations and also handle boundary conditions.

The small cavity in the mesh can be problematic as we have not tested the parallelization against scenarios where the coupling interface has discontinuities. Is that the case for your cavity geometry?

What happens if you run the code with less processors? Even just `2` processors. Does it still give the same error?

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [December 22, 2021, 2:20pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/5 "2021-12-22T14:20:01Z")

</div>

Hi @IshaanDesai , the strange thing is when I run the code with less processors, everything is ok. So I think as you say the small cavity on the interface of mesh which lead to the problem. But I have no idea to solve it.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [December 22, 2021, 4:06pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/6 "2021-12-22T16:06:10Z")

</div>

Okay, the fact that your code runs on less processors is already a good indicator! If you have directly modified the `partitioned-heat-conduction` case then you probably have [these lines](https://github.com/precice/tutorials/blob/4ce3842580a38eaa400fec0e10ec31a014a37d22/partitioned-heat-conduction/fenics/heat.py#L142-L148) in your code right? These lines will generate VTK files which will highlight the mesh partitions done by FEniCS. Using a VTK file viewer like ParaView we can visualize the mesh partition. Can you show how the mesh partitions look like for the case which runs and the case which fails? Looking at the visual output would give us more insight.

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [December 22, 2021, 5:56pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/7 "2021-12-22T17:56:33Z")

</div>

Hi@ [IshaanDesai](https://precice.discourse.group/u/IshaanDesai), the following is my fluidmesh. I have marked the mesh partitions using different color. Besides, I want to upload the zip file of my mesh, the file too big to upload.

 ![1](https://global.discourse-cdn.com/free1/uploads/precice/original/2X/3/33bdeb15206d1080996f573ae612686c8c276faa.png)

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [December 22, 2021, 6:42pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/8 "2021-12-22T18:42:51Z")

</div>

Okay, is this the case which runs or the case which fails? Can you upload mesh partition figures for both? That would give a better idea of what is going wrong.

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [December 23, 2021, 2:57am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/9 "2021-12-23T02:57:16Z")

</div>

Hi @[IshaanDesai](https://precice.discourse.group/u/IshaanDesai), I add a minimal code example in zip file and a txt file about how to run the example. I am very appreciate for your help!  
[minimalcode.zip](https://precice.discourse.group/uploads/short-url/i5lb4314Efz4I2jFxz9kyH4N5hQ.zip) (22.8 KB)

[readme(how to run code).txt](https://precice.discourse.group/uploads/short-url/gnhJqNY6Ypdy2uENuA0y10BPNzk.txt) (135 Bytes)

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [January 3, 2022, 6:43am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/10 "2022-01-03T06:43:52Z")

</div>

Hi @fish

I found it difficult to replicate your issue on my local machine. I think it is only possible to replicate this for a high number of processors. Instead I went through your code and I think the most likely cause of error is that somehow you pass an array to the adapter function `update_coupling_expression` which does not have any entries in it. That means that the second input argument to the function called `values` is an empty array. Can you check if this is the case?

While working on your case I also realized that we do not check if the input data to `update_coupling_expression` is empty or not and we need to check this. Feel free to open an issue in the adapter repo regarding this.

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [January 3, 2022, 12:40pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/11 "2022-01-03T12:40:50Z")

</div>

@ [IshaanDesai](https://precice.discourse.group/u/IshaanDesai)Thank you very much! I will check my code and consider to open an issue in the adapter repo regarding this.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [January 3, 2022, 4:50pm UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/12 "2022-01-03T16:50:53Z")

</div>

@fish If the problem is indeed what we predicted then opening an issue is good but also lets try to resolve it here for your particular case. Hence please also update here 🙂

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [January 4, 2022, 7:39am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/13 "2022-01-04T07:39:44Z")

</div>

@IshaanDesai ok, no problem. But I have no idea how to check it now! I will do something to remove this problem.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [January 4, 2022, 8:02am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/14 "2022-01-04T08:02:20Z")

</div>

Actually it is quite simple to check it. In your FEniCS code you have a call `precice.update_coupling_expression(coupling_expression, read_data)`. What we want to find out is for the case that you see the above error is the `read_data` array empty or does it have data.

Basically the error you have encountered is possible when you have a non-empty rank, that is a rank which has some part of the coupling interface, but you try to update the coupling Expression with empty data.

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [January 4, 2022, 8:20am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/15 "2022-01-04T08:20:59Z")

</div>

Hi[IshaanDesai](https://precice.discourse.group/u/IshaanDesai), My problem is how can I get the read\_data value and output it. And also how can I get the coupling Expression and output it to check if it is empty.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [January 4, 2022, 8:23am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/16 "2022-01-04T08:23:53Z")

</div>

Hi @fish

Okay I now understand what you are asking. I would suggest just printing the read data to the terminal before calling `precice.update_coupling_expression`. Also printing the rank number alongside it is a good idea. By printing the array to the terminal you can find out if it has some data or not.

---

<div class="post-metadata">

**Author:** ![fish](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fish](https://precice.discourse.group/u/fish)\
**Post date:** [January 4, 2022, 8:27am UTC](https://precice.discourse.group/t/parallel-fenics-case-fail/834/17 "2022-01-04T08:27:49Z")

</div>

@ [IshaanDesai](https://precice.discourse.group/u/IshaanDesai),OK, I will try it. Thank you very much!
