# Read simple gmsh msh using read\_from\_msh in dolfinx

**URL:** <https://fenicsproject.discourse.group/t/read-simple-gmsh-msh-using-read-from-msh-in-dolfinx/13902>\
**Category:** General\
**Created:** [March 13, 2024, 4:06pm UTC](https://fenicsproject.discourse.group/t/read-simple-gmsh-msh-using-read-from-msh-in-dolfinx/13902 "2024-03-13T16:06:23Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [March 13, 2024, 5:03pm UTC](https://fenicsproject.discourse.group/t/read-simple-gmsh-msh-using-read-from-msh-in-dolfinx/13902/3 "2024-03-13T17:03:00Z")

</div>

The reasoning behind @Jesus_Vellojin answer is that `dolfinx.io.gmshio` uses the GMSH Python API under the hood to extract the cells of interest using the physical groups:

> <https://github.com/FEniCS/dolfinx/blob/main/python/dolfinx/io/gmshio.py#L125>

It is also written explicitly in the docs:  
[https://docs.fenicsproject.org/dolfinx/v0.7.3/python/generated/dolfinx.io.gmshio.html#dolfinx.io.gmshio.model\_to\_mesh](https://docs.fenicsproject.org/dolfinx/v0.7.3/python/generated/dolfinx.io.gmshio.html#dolfinx.io.gmshio.model_to_mesh)

In general, gmsh doesn’t store un-tagged surfaces, lines, etc, as written in

> 1.2.3 Elementary entities vs. physical groups  
> It is usually convenient to combine elementary geometrical entities into more meaningful groups, e.g. to define some mathematical (“domain”, “boundary with Neumann condition”), functional (“left wing”, “fuselage”) or material (“steel”, “carbon”) properties. Such grouping is done in Gmsh’s geometry module (see [Geometry module](http://gmsh.info/doc/texinfo/gmsh.html#Geometry-module)) through the definition of “physical groups”.  
> By default in the native Gmsh MSH mesh file format (see [Gmsh file formats](http://gmsh.info/doc/texinfo/gmsh.html#Gmsh-file-formats)), as well as in most other mesh formats, if physical groups are defined, the output mesh only contains those elements that belong to at least one physical group. (Different mesh file formats treat physical groups in slightly different ways, depending on their capability to define groups.) To save all mesh elements whether or not physical groups are defined, use the `Mesh.SaveAll` option (see [Mesh options](http://gmsh.info/doc/texinfo/gmsh.html#Mesh-options)) or specify `-save_all` on the command line. In some formats (e.g. MSH2), setting `Mesh.SaveAll` will however discard all physical group definitions.

in

> **[Gmsh 4.12.2](http://gmsh.info/doc/texinfo/gmsh.html)**
>
> Gmsh 4.12.2

If you save all entities in a GMSH model, you risk overlapping/duplicate cells/facets etc.

---

_[View the full topic](https://fenicsproject.discourse.group/t/read-simple-gmsh-msh-using-read-from-msh-in-dolfinx/13902)._
