Introduction
Version 1 is the original mesh format of Gmsh. It is a plain text
file with two sections, one for nodes and one for elements. It has no header: a file that starts with
$NOD rather than $MeshFormat is version 1. There is no binary form. This page follows
the version 1 section of the Gmsh 4.15.2 manual; the notes on how Gmsh reads and writes it follow the
source of that release.
Layout
$NOD
number-of-nodes
node-number x y z
…
$ENDNOD
$ELM
number-of-elements
elm-number elm-type reg-phys reg-elem number-of-nodes node-number …
…
$ENDELM
Values are separated by white space. A small file with one quadrangle:
$NOD
4
1 0.0 0.0 0.0
2 1.0 0.0 0.0
3 1.0 1.0 0.0
4 0.0 1.0 0.0
$ENDNOD
$ELM
1
1 3 99 2 4 1 2 3 4
$ENDELM
Nodes
| Field | Meaning |
|---|---|
node-number | Positive integer naming the node. Numbers need not be continuous or in order. |
x y z | Coordinates as floating point numbers. |
Elements
| Field | Meaning |
|---|---|
elm-number | Positive integer naming the element. Numbers need not be continuous or in order. |
elm-type | Element type code, from the table below. |
reg-phys | Tag of the physical group the element belongs to, or 0 for none. |
reg-elem | Tag of the elementary geometrical entity the element belongs to; positive. |
number-of-nodes | Count of node numbers that follow. It repeats what the type already fixes and is kept for compatibility. |
node-number … | The element’s nodes, in the order given below. |
Element types
The manual lists types 1 to 19 for this version. In every element the corner nodes come first.
| Type | Element | Nodes |
|---|---|---|
| 1 | Line | 2 |
| 2 | Triangle | 3 |
| 3 | Quadrangle | 4 |
| 4 | Tetrahedron | 4 |
| 5 | Hexahedron | 8 |
| 6 | Prism | 6 |
| 7 | Pyramid | 5 |
| 8 | Second-order line | 3: 2 corners, 1 on the edge |
| 9 | Second-order triangle | 6: 3 corners, 3 on edges |
| 10 | Second-order quadrangle | 9: 4 corners, 4 on edges, 1 on the face |
| 11 | Second-order tetrahedron | 10: 4 corners, 6 on edges |
| 12 | Second-order hexahedron | 27: 8 corners, 12 on edges, 6 on faces, 1 inside |
| 13 | Second-order prism | 18: 6 corners, 9 on edges, 3 on the four-sided faces |
| 14 | Second-order pyramid | 14: 5 corners, 8 on edges, 1 on the base |
| 15 | Point | 1 |
| 16 | Second-order quadrangle without a centre node | 8: 4 corners, 4 on edges |
| 17 | Second-order hexahedron, edge nodes only | 20: 8 corners, 12 on edges |
| 18 | Second-order prism, edge nodes only | 15: 6 corners, 9 on edges |
| 19 | Second-order pyramid, edge nodes only | 13: 5 corners, 8 on edges |
Node ordering
Positions in an element’s node list are counted here from 0. The corners are placed as follows.
| Shape | Corners |
|---|---|
| Line | 0 and 1 are the ends. |
| Triangle | 0 at the origin, 1 along u, 2 along v. |
| Quadrangle | 0, 1, 2, 3 round the face; 0 to 1 runs along u, 0 to 3 along v. |
| Tetrahedron | 0 at the origin, 1 along u, 2 along v, 3 along w. |
| Hexahedron | 0, 1, 2, 3 round one face (0 to 1 along u, 0 to 3 along v); 4, 5, 6, 7 are the nodes opposite them along w. |
| Prism | 0, 1, 2 form one triangle (1 along u, 2 along v); 3, 4, 5 are opposite them along w. |
| Pyramid | 0, 1, 2, 3 round the base; 4 is the apex. |
The remaining positions of the second-order types lie in the middle of these edges and faces, written as the corners that bound them.
| Types | Positions after the corners |
|---|---|
| 8 | 2: edge 0–1 |
| 9 | 3: 0–1; 4: 1–2; 5: 2–0 |
| 10, 16 | 4: 0–1; 5: 1–2; 6: 2–3; 7: 3–0; 8: face centre (type 10 only) |
| 11 | 4: 0–1; 5: 1–2; 6: 2–0; 7: 3–0; 8: 3–2; 9: 3–1 |
| 12, 17 | 8: 0–1; 9: 0–3; 10: 0–4; 11: 1–2; 12: 1–5; 13: 2–3; 14: 2–6; 15: 3–7; 16: 4–5; 17: 4–7; 18: 5–6; 19: 6–7. Type 12 only: 20: face 0-3-2-1; 21: face 0-1-5-4; 22: face 0-4-7-3; 23: face 1-2-6-5; 24: face 2-3-7-6; 25: face 4-5-6-7; 26: centre of the volume |
| 13, 18 | 6: 0–1; 7: 0–2; 8: 0–3; 9: 1–2; 10: 1–4; 11: 2–5; 12: 3–4; 13: 3–5; 14: 4–5. Type 13 only: 15: face 0-1-4-3; 16: face 0-2-5-3; 17: face 1-2-5-4 |
| 14, 19 | 5: 0–1; 6: 0–3; 7: 0–4; 8: 1–2; 9: 1–4; 10: 2–3; 11: 2–4; 12: 3–4; 13: centre of the base (type 14 only) |
How Gmsh reads and writes it
Current Gmsh reads version 1 with the same code as version 2. The following comes from that source.
- An element is rejected when its
number-of-nodesdiffers from the count fixed by its type, so type codes without a fixed node count cannot appear. - Elements whose
reg-elemis negative are skipped. - A node number that appears twice produces a warning.
- Gmsh writes this layout when asked for a mesh file version below 2. A negative physical tag in its model is written as a positive one, with the element’s node order reversed.
Variants
- MSH version 4 – nodes and elements in blocks by entity
- MSH version 3 – entities, and an entity on every node and element
- MSH version 2 – flat node and element lists with integer tags
- MSH version 1 –
$NODand$ELM, text only
Links
Software
- Gmsh – mesh generator that still reads and writes version 1 (Windows, macOS, Linux)
Developers
- Gmsh source – the reader and writer for versions 1 and 2 (C++)
Reference
- Gmsh reference manual: MSH file format version 1 – layout, element types and node ordering
- GModelIO_MSH2.cpp, Gmsh 4.15.2 – the reader and writer