Select Git revision
Forked from
gmsh / gmsh
Source project has a limited visibility.
FORMATS 15.08 KiB
$Id: FORMATS,v 1.16 2003-03-06 23:01:17 geuzaine Exp $
This document describes the version 1.2 of Gmsh's mesh and
post-processing file formats.
(This document deals only with the import/export interfaces for
Gmsh. The language driving the behaviour of Gmsh for defining
geometries, options, scripts, etc. is explained step by step in the
tutorials.)
********************************************************************
Section 1: Gmsh Mesh File Format
The 'msh' file format is the native output file format for Gmsh. The
file is divided in two sections (enclosed in $KEY and $ENDKEY pairs):
$NOD/$ENDNOD defines the nodes and $ELM/$ENDELM defines the elements.
$NOD
number-of-nodes
node-number coord1 coord2 coord3
...
$ENDNOD
$ELM
number-of-elements
elm-number elm-type elm-region unused nb-nodes node-numbers
...
$ENDELM
All the syntactic variables stand for integers except coord1, coord2
and coord3 which stand for floating point values, and node-numbers
which stand for a list of nb-nodes integers.
Please note that the the node-number and elm-number numbers are not
necessarily given in a consecutive or even an ordered way.
The elm-type value defines the geometrical type for the element:
1 Line (2 nodes, 1 edge).
2 Triangle (3 nodes, 3 edges).
3 Quadrangle (4 nodes, 4 edges).
4 Tetrahedron (4 nodes, 6 edges, 4 facets).
5 Hexahedron (8 nodes, 12 edges, 6 facets).
6 Prism (6 nodes, 9 edges, 5 facets).
7 Pyramid (5 nodes, 8 edges, 5 facets).
15 Point (1 node).
The elm-region value is the number of the physical entity to which the
element belongs.
********************************************************************
Section 2: Gmsh ASCII Post-Processing File Format
An ASCII post-processing file is divided in several sections: one
format section, enclosed between $PostFormat/$EndPostFormat, and
(possibly multiple) post-processing views, enclosed between
$View/$EndView pairs:
$PostFormat
1.2 file-type data-size
$EndPostFormat
$View
view-name nb-time-steps
nb-scalar-points nb-vector-points nb-tensor-points
nb-scalar-lines nb-vector-lines nb-tensor-lines
nb-scalar-triangles nb-vector-triangles nb-tensor-triangles
nb-scalar-quadrangles nb-vector-quadrangles nb-tensor-quadrangles
nb-scalar-tetrahedra nb-vector-tetrahedra nb-tensor-tetrahedra
nb-scalar-hexahedra nb-vector-hexahedra nb-tensor-hexahedra
nb-scalar-prisms nb-vector-prisms nb-tensor-prisms
nb-scalar-pyramids nb-vector-pyramids nb-tensor-pyramids
nb-text2d nb-text2d-chars nb-text3d nb-text3d-chars
time-step-values
scalar-point-value ...
vector-point-value ...
tensor-point-value ...
scalar-line-value ...
vector-line-value ...
tensor-line-value ...
scalar-triangle-value ...
vector-triangle-value ...
tensor-triangle-value ...
scalar-quadrangle-value ...
vector-quadrangle-value ...
tensor-quadrangle-value ...
scalar-tetrahedron-value ...
vector-tetrahedron-value ...
tensor-tetrahedron-value ...
scalar-hexahedron-value ...
vector-hexahedron-value ...
tensor-hexahedron-value ...
scalar-prism-value ...
vector-prism-value ...
tensor-prism-value ...
scalar-pyramid-value ...
vector-pyramid-value ...
tensor-pyramid-value ...
text2d ... text2d-chars ...
text3d ... text3d-chars ...
$EndView
file-type is an integer equal to 0 in the ASCII file format.
data-size is an integer equal to the size of the floating point
numbers used in the file (usually, data-size == sizeof(double)).
view-name is a string containing the name of the view (max. 256 characters)
nb-time-step is an integer giving the number of time steps in the view
nb-scalar-points, nb-vector-points, etc. are integers giving the
number of scalar points, vector points, etc. in the view.
nb-text2d and nb-text3d are integers giving the number of 2D text
strings and 3d text strings in the view. nb-text2d-chars and
nb-text3d-chars are integers giving the total number of characters in
the 2d and 3d strings.
time-step-values is a list of nb-time-steps double precision numbers
giving the value of the time (or any other variable) for which an
evolution was saved.
scalar-point-value, vector-point-value, etc. are lists of double
precision numbers giving the node coordinates and the values
associated with the nodes of the nb-scalar-points, nb-vector-points,
etc. for each time-step-value. For example, vector-triangle-value is
defined as:
coord1-node1 coord1-node2 coord1-node3
coord2-node1 coord2-node2 coord2-node3
coord3-node1 coord3-node2 coord3-node3
comp1-node1-time1 comp2-node1-time1 comp3-node1-time1
comp1-node2-time1 comp2-node2-time1 comp3-node2-time1
comp1-node3-time1 comp2-node3-time1 comp3-node3-time1
comp1-node1-time2 comp2-node1-time2 comp3-node1-time2
comp1-node2-time2 comp2-node2-time2 comp3-node2-time2
comp1-node3-time2 comp2-node3-time2 comp3-node3-time2
...
text2d is a list of 4 double precision numbers:
coord1 coord2 style index
where index gives the starting index of the correspinding 2d text
string in text2d-chars.
text2d-chars is a list of nb-text2d-chars chars. Substrings are
separated with the '^' characted (which is a forbidden character in
regular strings).
text3d is a list of 5 double precision numbers:
coord1 coord2 coord3 style index
where index gives the starting index of the correspinding 3d text
string in text3d-chars.
text3d-chars is a list of nb-text3d-chars chars. Substrings are
separated with the '^' characted.
********************************************************************
Section 3: Gmsh Binary Post-Processing File Format
The binary post-processing file format is the same as the ASCII file
format, except that:
1) file-type equals 1.
2) all lists of floating point numbers and characters are written in
binary format
3) there is an additional integer, of value 1, written before
time-step-values. This integer is used for detecting if the
computer on which the binary file was written and the computer on
which the file is read are of the same type (little or big endian).
Here is a pseudo C code to write the beginning of a post-processing
file in binary format:
int one = 1;
fprintf(file, "$PostFormat\n");
fprintf(file, "%g %d %d\n", 1.2, 1, sizeof(double));
fprintf(file, "$EndPostFormat\n");
fprintf(file, "$View\n");
fprintf(file, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d "
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
view-name, nb-time-steps,
nb-scalar-points, nb-vector-points, nb-tensor-points,
nb-scalar-lines, nb-vector-lines, nb-tensor-lines,
nb-scalar-triangles, nb-vector-triangles, nb-tensor-triangles,
nb-scalar-quadrangles, nb-vector-quadrangles, nb-tensor-quadrangles,
nb-scalar-tetrahedra, nb-vector-tetrahedra, nb-tensor-tetrahedra,
nb-scalar-hexahedra, nb-vector-hexahedra, nb-tensor-hexahedra,
nb-scalar-prisms, nb-vector-prisms, nb-tensor-prisms,
nb-scalar-pyramids, nb-vector-pyramids, nb-tensor-pyramids,
nb-text2d, nb-text2d-chars, nb-text3d, nb-text3d-chars);
fwrite(&one, sizeof(int), 1, file);
fwrite(time-step-values, sizeof(double), nb-time-steps, file);
fwrite(all-scalar-point-values, sizeof(double), ..., file);
...
fprintf(file, "\n$EndView\n");
In this pseudo-code, all-scalar-point-values is the array of double
precision numbers containing all the scalar-point-value lists, put one
after each other in order to form a long array of doubles. The
principle is the same for all other kinds of values.
********************************************************************
Section 4: Gmsh Parsed Post-Processing Format
For relatively small data sets Gmsh provides an additional
post-processing format, which is parsed by the same grammar analyzer
as the geometry. You can thus, for example, embed small
post-processing views directly into your geometrical descriptions (see
the tutorial). This format is also very useful for testing purposes:
it's syntax is very permissive, and you can easily generate it by hand
or on the fly. The format of the parsed post-processing file is the
following:
View "name" {
type-of-element (list-of-coordinates) {list-of-values} ;
...
};
26 base objects can be displayed:
type-of-element list-of-coordinates list-of-values
--------------------------------------------------------------------------------
scalar point SP 3 1 * nb-time-steps
vector point VP 3 3 * nb-time-steps
tensor point TP 3 9 * nb-time-steps
scalar line SL 6 2 * nb-time-steps
vector line VL 6 6 * nb-time-steps
tensor line TL 6 18 * nb-time-steps
scalar triangle ST 9 3 * nb-time-steps
vector triangle VT 9 9 * nb-time-steps
tensor triangle TT 9 27 * nb-time-steps
scalar quadrangle SQ 12 4 * nb-time-steps
vector quadrangle VQ 12 12 * nb-time-steps
tensor quadrangle TQ 12 36 * nb-time-steps
scalar tetrahedron SS 12 4 * nb-time-steps
vector tetrahedron VS 12 12 * nb-time-steps
tensor tetrahedron TS 12 36 * nb-time-steps
scalar hexahedron SH 24 8 * nb-time-steps
vector hexahedron VH 24 24 * nb-time-steps
tensor hexahedron TH 24 72 * nb-time-steps
scalar prism SI 18 6 * nb-time-steps
vector prism VI 18 18 * nb-time-steps
tensor prism TI 18 54 * nb-time-steps
scalar pyramid SY 15 5 * nb-time-steps
vector pyramid VY 15 15 * nb-time-steps
tensor pyramid TY 15 45 * nb-time-steps
text 2d T2 4 arbitrary
text 3d T3 5 arbitrary
Contrary to the ASCII and Binary post-processing file formats (see
below), the coordinates are given by node, i.e.
(coord1, coord2,coord3) for a point,
(coord1-node1, coord2-node1, coord3-node1,
coord1-node2, coord2-node2, coord3-node2) for a line,
(coord1-node1, coord2-node1, coord3-node1,
coord1-node2, coord2-node2, coord3-node2,
coord1-node3, coord2-node3, coord3-node3) for a triangle,
etc. The values are given in the same order as for the ASCII and
Binary post-processing file formats.
********************************************************************
Section 5: Gmsh node ordering
* POINT
v
|
|
-----1-----u
|
|
* LINE edge 1: nodes 1 -> 2
v
|
|
--1-----2--u
|
|
* TRIANGLE edge 1: nodes 1 -> 2
v 2: 1 -> 3
| 3: 2 -> 3
|
3 face 1: edges 1 -2 3 nodes 1 2 3
|\
| \
|__\___u
1 2
* QUADRANGLE edge 1: nodes 1 -> 2
v 2: 1 -> 4
| 3: 2 -> 3
4--|--3 4: 3 -> 4
| | |
-----------u face 1: edges 1 -2 3 4 nodes 1 2 3 4
| | |
1--|--2
|
* TETRAHEDRON edge 1: nodes 1 -> 2
v 2: 1 -> 3
| 3: 1 -> 4
| 4: 2 -> 3
| 5: 2 -> 4
3 6: 3 -> 4
|\
| \ face 1: edges 1 -3 5 nodes 1 2 4
|__\2_____u 2: -1 2 -4 1 3 2
1\ / 3: -2 3 -6 1 4 3
\4 4: 4 -5 6 2 3 4
\
w
* HEXAHEDRON edge 1: nodes 1 -> 2
v 2: 1 -> 4
| 3: 1 -> 5
| 4: 2 -> 3
4----|--3 5: 2 -> 6
|\ | |\ 6: 3 -> 4
| 8-------7 7: 3 -> 7
| | ----|---u 8: 4 -> 8
1-|---\-2 | 9: 5 -> 6
\| \ \| 10: 5 -> 8
5-----\-6 11: 6 -> 7
\ 12: 7 -> 8
w
face 1: edges 1 -3 5 -9 nodes 1 2 6 5
2: -1 2 -4 -6 1 4 3 2
3: -2 3 -8 10 1 5 8 4
4: 4 -5 7 -11 2 3 7 6
5: 6 -7 8 -12 3 4 8 7
6: 9 -10 11 12 5 6 7 8
* PRISM edge 1: nodes 1 -> 2
v 2: 1 -> 3
3 | 3: 1 -> 4
|\| 4: 2 -> 3
| | 5: 2 -> 5
1_|2 6: 3 -> 6
\| 6 7: 4 -> 5
|_|_\___u 8: 4 -> 6
\| \ 9: 5 -> 6
4 __5
\ face 1: edges 1 -3 5 -7 nodes 1 2 5 4
\ 2: -1 2 -4 1 3 2
w 3: -2 3 -6 8 1 4 6 3
4: 4 -5 6 -9 2 3 6 5
5: 7 -8 9 4 5 6
* PYRAMID edge 1: nodes 1 -> 2
v 2: 1 -> 4
| 3: 1 -> 5
| 4: 2 -> 3
4---|---3 5: 2 -> 5
| \ | /| 6: 3 -> 4
| \ -/-|---u 7: 3 -> 5
| / 5\ | 8: 4 -> 5
1/----\-2
\ facet 1: edges 1 5 -3 nodes 1 2 5
\ 2: 2 -6 -4 -1 1 4 3 2
w 3: 3 -8 -2 1 5 4
4: 4 7 -5 2 3 5
5: 6 8 -7 3 4 5