# (3D) Mesh generation fails in parallel

**URL:** <https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303>\
**Category:** mesh\
**Created:** [January 27, 2020, 8:54pm UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303 "2020-01-27T20:54:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [January 27, 2020, 8:54pm UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/1 "2020-01-27T20:54:38Z")

</div>

I encountered a weird error trying to generate a 3D mesh in parallel. For instance,

```auto
from dolfin import *
parameters["ghost_mode"]="shared_facet" # doing calculations with CR/DG later in the code
com = MPI.comm_world
msh = UnitCubeMesh.create(com, [2,2,2], CellType.Type.tetrahedron) # UnitCubeMesh(2,2,2) also fails

```

fails when run in parallel. The following are the warnings and error messages

```auto
...
...
Process 24: *** Warning: Mesh is empty, unable to create entities of dimension 2.
Process 24: *** Warning: Mesh is empty, unable to create connectivity 2 --> 3.
...
...
 msh = UnitCubeMesh.create(comm,[2,2,2], CellType.Type.tetrahedron)
RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to create mesh entity.
*** Reason: Mesh entity index 0 out of range [0, 0] for entity of dimension 2.
*** Where: This error was encountered inside MeshEntity.cpp.
*** Process: 108
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------

```

It seems to run without any issues in serial. Any pointers as to what could be going wrong ?

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [January 27, 2020, 10:08pm UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/2 "2020-01-27T22:08:03Z")

</div>

Your error is coming from process 24 so I’m assuming you have 24 processes. Your mesh comprises 2 \times 2^3 = 16 cells. I think you have too many processes for a mesh which is too coarse.

---

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [January 27, 2020, 10:58pm UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/3 "2020-01-27T22:58:21Z")

</div>

Thanks! I should have checked that.

---

<div class="post-metadata">

**Author:** ![NataliaKor](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nataliakor/32/5871_2.png) [@NataliaKor](https://fenicsproject.discourse.group/u/NataliaKor)\
**Post date:** [October 17, 2023, 8:03am UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/4 "2023-10-17T08:03:57Z")

</div>

> [@nate](#):
>
> Your error is coming from process 24 so I’m assuming you have 24 processes. Your mesh comprises 2 \times 2^3 = 16 cells. I think you have too many processes for a mesh which is too coarse.

Hello. I have a question also. I get the same messages:

> Warning: Mesh is empty, unable to create entities of dimension 0.  
> Warning: Mesh is empty, unable to create entities of dimension 3.  
> Traceback (most recent call last):  
> File “multilayer.py”, line 60, in   
> 1: Constant((-1.0, 0.0, 0.0))  
> File “/usr/local/lib/python2.7/dist-packages/magnumfe/common/state.py”, line 582, in interpolate  
> File “/usr/local/lib/python2.7/dist-packages/magnumfe/common/state.py”, line 638, in FunctionSpace  
> File “/usr/local/lib/python2.7/dist-packages/magnumfe/common/state.py”, line 617, in VectorFunctionSpace  
> File “/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py”, line 628, in **init**  
> constrained\_domain=constrained\_domain)  
> File “/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.py”, line 168, in **init**  
> dolfin\_dofmap = cpp.DofMap(ufc\_dofmap, mesh)  
> File “/usr/lib/python2.7/dist-packages/dolfin/cpp/fem.py”, line 586, in **init**  
> \_fem.DofMap\_swiginit(self,\_fem.new\_DofMap(\*args))  
> RuntimeError:
> 
> \*\*\* -------------------------------------------------------------------------  
> \*\*\* DOLFIN encountered an error. If you are not able to resolve this issue…  
> Error: Unable to create mesh entity.  
> Reason: Mesh entity index 0 out of range [0, 0] for entity of dimension 3.  
> Where: This error was encountered inside MeshEntity.cpp.  
> Process: unknown
> 
> DOLFIN version: 1.5.0  
> Git changeset: unknown  
> But my object is too small, because I create simulation in nanostructure.  
> This is example of .geo file:

```auto
algebraic3d

solid 
1 = plane (0,0,0;-1,0,0 )
and plane (1,1,1; 1,0,0 )
and plane (0,0,0; 0,-1,0)
and plane (1,1,1; 0, 1,0 )
and plane (0,0,0.3; 0,0,-1 )
and plane (1,1,1; 0,0, 1 );

solid cube4 = plane (0,0,0; -1,0,0 )
and plane (1,1,1; 1,0,0 )
and plane (0,0,0; 0,-1,0 )
and plane (1,1,1; 0, 1,0 )
and plane (0,0,2.1; 0,0,-1 )
and plane (1,1,2.8; 0,0, 1 );

solid cube2 = plane (0,0,0; -1,0,0 )
and plane (1,1,1; 1,0,0 )
and plane (0,0,0; 0,-1,0 )
and plane (1,1,1; 0, 1,0 )
and plane (0,0,1.1; 0,0,-1 )
and plane (1,1,2.1; 0,0, 1 );

solid cube5 = plane (0,0,0; -1,0,0 )
and plane (1,1,1; 1,0,0 )
and plane (0,0,0; 0,-1,0 )
and plane (1,1,1; 0, 1,0 )
and plane (0,0,0; 0,0,-1 )
and plane (1,1,0.3; 0,0, 1 );

solid cube3 = plane (0,0,0; -1,0,0 )
and plane (1,1,1; 1,0,0 )
and plane (0,0,0; 0,-1,0 )
and plane (1,1,1; 0, 1,0 )
and plane (0,0,1.0; 0,0,-1 )
and plane (1,1,1.1; 0,0, 1 ) -maxh=0.05;

tlo cube3;
tlo cube1;
tlo cube2;
tlo cube4;
tlo cube5;

```

for creating mesh I used Netgen.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 17, 2023, 8:20am UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/5 "2023-10-17T08:20:46Z")

</div>

You are using a very outdated version of DOLFIN (v1.5.0) which was released in 2015, a long time ago. I would suggest you move to a later version of Dolfin and provide a minimal reproducible example.

---

<div class="post-metadata">

**Author:** ![NataliaKor](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nataliakor/32/5871_2.png) [@NataliaKor](https://fenicsproject.discourse.group/u/NataliaKor)\
**Post date:** [October 17, 2023, 8:26am UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/6 "2023-10-17T08:26:02Z")

</div>

My colleagues give me access only to this version. How I can update DOLFIN? It’s installed on our virtual server due to MobaXterm.

---

<div class="post-metadata">

**Author:** ![NataliaKor](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nataliakor/32/5871_2.png) [@NataliaKor](https://fenicsproject.discourse.group/u/NataliaKor)\
**Post date:** [October 17, 2023, 8:49am UTC](https://fenicsproject.discourse.group/t/3d-mesh-generation-fails-in-parallel/2303/7 "2023-10-17T08:49:18Z")

</div>

> [@dokken](#):
>
> provide a minimal reproducible example

```auto
mesh = Mesh("cubeses.xml")
cell_regions = MeshFunction("size_t", mesh, "cubeses_physical_region.xml")
facet_regions = MeshFunction("size_t", mesh, "cubeses_facet_region.xml")
state = State(mesh, cell_markers = cell_regions, facet_markers = facet_regions)
state = State(mesh,
  cell_domains = {
    'magnetic': (1, 2),
    'conducting': (4, 5, 3),
    'free': 2,
    'fixed': 1
  },
  facet_domains = {
    'contact1': 4,
    'contact2': 5,
    'outermagnet': 3
  },
  scale = 1e-9,
  m = Constant((1, 0, 0))
  )
state.material['magnetic'] = Material(
    alpha = 1.0,
    ms = 8e5,
    Aex = 1.3e-11,
    D0 = 1e-3,
    C0 = 6e6,
    beta = 0.9,
    beta_prime = 0.8,
    tau_sf = 5e-14,
    J = 4.0e-20
  )
state.material['!magnetic'] = Material(
    D0 = 5e-3,
    C0 = 6e6,
    tau_sf = 1e-14
  )
state.m.assign(
 state.interpolate({
        2: Constant((1.0, 0.0, 0.0)),
        1: Constant((-1.0, 0.0, 0.0))
    })
  )

```
