Introduction
MSH is the mesh file format of Gmsh, the finite element mesh generator by Christophe Geuzaine and Jean-François Remacle. A file lists nodes with their coordinates and the elements that join them – points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, pyramids and their higher-order forms – and can carry the names of physical groups, the model’s geometrical entities, periodic links and result data. Solvers and mesh converters read it widely.
The file is made of text sections between a $Name line and a matching closing line. Most
versions also have a binary form, in which the section lines stay text and the numbers inside them are
stored as bytes.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.MSH | MSH version 1 | Gmsh’s original text mesh with $NOD and $ELM sections. | Open |
.MSH | MSH version 2 | Gmsh’s long-used mesh format: flat node and element lists with integer tags. | Open |
.MSH | MSH version 3 | Gmsh’s entity-aware mesh layout, between versions 2 and 4. | Open |
.MSH | MSH version 4 | Gmsh’s current mesh format, 4.0 and 4.1: nodes and elements in blocks by entity. | Open |
MSH 4
Versions 4.0 and 4.1. The file starts with $MeshFormat and a version number beginning with
4. Nodes and elements are grouped in blocks by model entity. Version 4.1 is the current format, described
in the Gmsh reference manual.
MSH 3
A version number from 3.0 up to, but not including, 4. Gmsh’s source still reads and writes it, but its manual does not describe it.
MSH 2
A version number below 3, usually 2.2. Nodes and elements are flat lists and each element carries a list of integer tags. It is still very common.
MSH 1
No $MeshFormat section: the file starts with $NOD. Text only.
The first line, and the number at the start of the second, tell them apart.
In the explorer
A dropped Gmsh .msh file of version 1, 2, 3, 4.0 or 4.1, text or binary in either byte
order, shows every section and record in the byte tree and in tables, with the physical names, the
element types and the result data. Surface elements and the outer faces of volume elements are drawn in
3D, coloured by physical group or elementary entity, in parts of three million triangles when the mesh
is large; line and point elements have a view of their own. Curved elements are drawn with straight
sides between their edge nodes. Polyhedra and element types 138 and 139, whose node layout is not
documented, are listed but not drawn. Result values are shown in tables. Files up to 256 MB are
read.
Links
Software
- Gmsh – mesh generator and post-processor that reads and writes MSH (Windows, macOS, Linux)
Developers
- Gmsh source – the readers and writers for every MSH version (C++)
- meshio – library and converter for mesh files, including Gmsh MSH (Python)
Reference
- Gmsh reference manual: MSH file format – the current format and the legacy versions 2 and 1
- GModelIO_MSH.cpp, Gmsh 4.15.2 – which reader each version number selects