8 Gmsh 4.12.1
Model entities can be manipulated and transformed in a variety of ways within the geometry
module, but operations are always performed directly within their respective CAD kernels. As
explained above, there is no common internal geometrical representation: rather, Gmsh directly
performs the operations (translation, rotation, intersection, union, fragments, ...) on the native
geometrical representation using each CAD kernel’s own API. In the same philosophy, models
can be imported in the geometry module through each CAD kernel’s own import mechanisms.
For example, by default Gmsh imports STEP and IGES files through OpenCASCADE, which
will lead to the creation of model entities with an internal OpenCASCADE representation.
The Chapter 2 [Gmsh tutorial], page 15, starting with Section 2.1 [t1], page 15, is the best place
to learn how to use the geometry module: it contains examples of increasing complexity based
on both the built-in and the OpenCASCADE kernel. Note that many features of the geometry
module can be used interactively in the GUI (see Chapter 3 [Gmsh graphical user interface],
page 79), which is also a good way to learn about both Gmsh’s scripting language and the API,
as actions in the geometry module automatically append the related command in the input
script file, and can optionally also generate input for the languages supported by the API (see
the General.ScriptingLanguages option; this is still work-in-progress as of Gmsh 4.12.)
In addition to CAD-type geometrical entities, whose geometry is provided by a CAD kernel,
Gmsh also supports discrete model entities, which are defined by a mesh (e.g. STL). Gmsh does
not perform geometrical operations on such discrete entities, but they can be equipped with a
geometry through a so-called “reparametrization” procedure
1
. The parametrization is then used
for meshing, in exactly the same way as for CAD entities. See Section 2.13 [t13], page 43 for an
example.
1.2 Mesh module
A finite element mesh of a model is a tessellation of its geometry by simple geometrical elements
of various shapes (in Gmsh: lines, triangles, quadrangles, tetrahedra, prisms, hexahedra and
pyramids), arranged in such a way that if two of them intersect, they do so along a face, an
edge or a node, and never otherwise. This defines a so-called conformal mesh. The mesh mod-
ule implements several algorithms to generate such meshes automatically. By default, meshes
produced by Gmsh are considered as unstructured, even if they were generated in a structured
way (e.g., by extrusion). This implies that the mesh elements are completely defined simply by
an ordered list of their nodes, and that no predefined ordering relation is assumed between any
two elements.
In order to guarantee the conformity of the mesh, mesh generation is performed in a bottom-up
flow: curves are discretized first; the mesh of the curves is then used to mesh the surfaces; then
the mesh of the surfaces is used to mesh the volumes. In this process, the mesh of an entity is
only constrained by the mesh of its boundary, unless entities of lower dimensions are explicitly
embedded in entities of higher dimension. For example, in three dimensions, the triangles
discretizing a surface will be forced to be faces of tetrahedra in the final 3D mesh only if the
surface is part of the boundary of a volume, or if that surface has been explicitly embedded in the
volume. This automatically ensures the conformity of the mesh when, for example, two volumes
share a common surface. Mesh elements are oriented according to the geometrical orientation of
the underlying entity. Every meshing step is constrained by a mesh size field, which prescribes
the desired size of the elements in the mesh. This size field can be uniform, specified by values
associated with points in the geometry, or defined by general mesh size fields (for example
related to the distance to some boundary, to a arbitrary scalar field defined on another mesh,
etc.): see Chapter 8 [Gmsh mesh size fields], page 303. For each meshing step, all structured
mesh directives are executed first, and serve as additional constraints for the unstructured parts.
1
P. A. Beaufort, C. Geuzaine, J.-F. Remacle Automatic surface mesh generation for discrete modelsA complete
and automatic pipeline based on reparametrization. Journal of Computational Physics, 417, 109575, 2020.