# Gmsh import error/ Keyword "tetra"

**URL:** https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417
**Category:** Errors
**Created:** [August 19, 2021, 6:49pm UTC](https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417 "2021-08-19T18:49:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Noya](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@Noya](https://fenicsproject.discourse.group/u/Noya)
#### Post date: [August 19, 2021, 6:49pm UTC](https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417/1 "2021-08-19T18:49:27Z")

</div>

hello all,

I have created a 3D mesh with gmsh.  
Now when I want to convert it from .msh to .xdmf I get the following error:

> Traceback (most recent call last):  
> File “/home/noya/hallo.py”, line 5, in   
> tet\_data = msh.cell\_data\_dict[“gmsh:physical”][“tetra”]  
> KeyError: ‘tetra’

```auto
from fenics import*
import meshio

msh = meshio.read("torus.msh")
tet_data = msh.cell_data_dict["gmsh:physical"]["tetra"]
tri_data = msh.cell_data_dict["gmsh:physical"]["triangle"]

```

How can I fix it? What do I wrong?

Best regards,  
Noya

---

<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: [August 19, 2021, 7:23pm UTC](https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417/2 "2021-08-19T19:23:20Z")

</div>

> [@Noya](#):
>
> `msh.cell_data_dict`

Start by printing: `msh.cell_data_dict`, then you can see what contents you have in it. As long as you haven’t provided us with how you generated the mesh, there isn’t much we can do to help you.

---

<div class="post-metadata">

### Author: ![Noya](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@Noya](https://fenicsproject.discourse.group/u/Noya)
#### Post date: [August 19, 2021, 8:03pm UTC](https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417/3 "2021-08-19T20:03:32Z")

</div>

Okay, thank you.

the output from `print(`msh.cell\_data\_dict`)` is

> {‘gmsh:physical’: {‘triangle6’: array([4, 4, 4, …, 3, 3, 3]), ‘tetra10’: array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
> 1, 1, 1])}, ‘gmsh:geometrical’: {‘triangle6’: array([1, 1, 1, …, 8, 8, 8]), ‘tetra10’: array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,  
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  
> 3, 3, 3])}}

I cannot input the msh file cause it has to much characters  
I have done the following :  
 ![Bildschirmfoto von 2021-08-19 21-59-45](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/f/f3257113fd7a42874b71f1a6d3a8e59c448096cd.png)  
 ![Bildschirmfoto von 2021-08-19 21-59-48](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/5/54a4bbbe49619604517f43c3572ffb98504520b4.png)  
and created it before with `Mesh 3;` in the geo file

I have now replaced each tetra with tetra10 and each triangle with triangle6. now the previous error is gone, but I get the error

> Traceback (most recent call last):  
> File “/home/noya/hallo.py”, line 30, in   
> mshfile.read(mesh)  
> 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](mailto: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 recognise cell type.  
\*\*\* Reason: Unknown value “tetrahedron\_10”.  
\*\*\* Where: This error was encountered inside XDMFFile.cpp.  
\*\*\* Process: 0

* * *

\*\*\* DOLFIN version: 2019.2.0.dev0  
\*\*\* Git changeset: unknown  
\*\*\* -----------------------

```auto
mesh = Mesh()
with XDMFFile("mesht.xdmf") as mshfile:
    mshfile.read(mesh)

```

Are there to much elements?

best regards, noya

---

<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: [August 21, 2021, 6:57am UTC](https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417/4 "2021-08-21T06:57:22Z")

</div>

Dolfin does not support second order geometries from GMSH, you need to use dolfinx as menitioned here: [Cell type is tetra10](https://fenicsproject.discourse.group/t/cell-type-is-tetra10/4761)  
and here: [Import second order mesh to FEnics using mesh.io - #2 by dokken](https://fenicsproject.discourse.group/t/import-second-order-mesh-to-fenics-using-mesh-io/2005/2)

Note that you do not need a second order mesh to use higher order function spaces.

---

<div class="post-metadata">

### Author: ![Noya](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@Noya](https://fenicsproject.discourse.group/u/Noya)
#### Post date: [August 21, 2021, 8:08am UTC](https://fenicsproject.discourse.group/t/gmsh-import-error-keyword-tetra/6417/5 "2021-08-21T08:08:32Z")

</div>

Thank you.  
But why have I second order elements? I set in the .geo-file `Mesh.ElementOrder = 1` . I’m a little bit confused.

Edit: Got it. Thank you. You should also save the mesh again and not only the geo-file. 🤦‍♀️
