• CFD, Fluid Flow, FEA, Heat/Mass Transfer
  • +91 987-11-19-383
  • amod.cfd@gmail.com

GMSH - Open Source Meshing Program

Visual Description of GMSH Tutorials

The purpose of this web-page is to summarize the capabilities of FreeCAD and GMSH by adding user experience while running the tutorial cases. The information is being updated gradually, starting with a visual description of the output from each tutorial. This will help a potential user of GMSH to directly jump to the tutorial which fits his/her requirements. Though it is imperative to go though all the tutorials the way the authors of this program have designed. The publisher of cfdyna.com has not made contribution to some of the example cases included here and asserts no claim or copyright. The purpose is to compile information in a place for reference to current and future users of GMSH program for learning purposes.

While FreeCAD uses Python for scripting, GMSH calls its scripting language as 'affectation'. A new variable is defined as eSize = 1e-2; and a new point can be created as Point(1) = {0, 0, 0, eSize};

The recommended method to convert a GMSH mesh to OpenFOAM format is to use utility gmshToFoam. The syntax is gmshToFoam case.msh -case oFCase


FreeCAD + GMSH: Z-Bend

The FreeCAD file, STEP and STL geometry can be found here: Z-Bend FreeCAD, Z-Bend geometry in STEP format and Z-Bend STL Geometry. The STL geometry can be used in snappyHexMesh to generate a mesh for CFD simulation in OpenFOAM. The STEP/IGES format can be imported in GMSH using File -> Merge option. The mesh can be generated in GMSH after setting element size as depicted below. Progress information and messages are displayed in the bottom part of GUI in GMSH. If it is not visible, use Tools -> Message Console path or control-L command to activate / deactivate it.
Element size setting in GMSH

Z-Bend FreeCAD and STL geometry

Z-Bend Mesh in GMSH


GMSH: Tutorial-01

Description and features: The most basic functionality of GMSH capability to create points, lines, surface and physical entities (that is regions or zones). The domain is 2D and mesh generated is triangular which is default setting.

GMSH Tutorial 01

GMSH: Tutorial-02

Description and features: This is an example of volume meshing with tetrahedrons. The surfaces bounding the volume are all planar.

GMSH Tutorial 02

GMSH: Tutorial-03

Description and features: Here the capability to generate hybrid mesh (hexahedron + tetrahedrons) along with 1:1 interface is explained. Creation of surface by extrusion with twisting is visible. The mesh has also been generated by extrude feature. This example also demonstrates application of including a *.geo file into another GMSH *.geo file.

GMSH Tutorial 03

The functionality presented in this tutorial can be used to generate following two meshes with extrude feature. The main *.geo file can be downloaded from here. The section of the pipe is generated by this file.
GMSH quarterCylinder

The main *.geo file can be downloaded from here. The section of the pipe is generated by this file.

GMSH elbow bend

Note the following:
  • When point is extruded, it results in a line and end-point on the other side of the line. The 'top' of extruded entity is a 'point'. The extruded entity is a 'line'. Thus: out[0] = 'top' node, out[1] = 'line'
  • Similarly, when a line is extruded, it results in a surface, 3 aditional lines bounding the new surface and 3 new nodes. out[0] = 'top' edge, out[1] = 'surface', out[3] = 'side' curve 1, out[4] = 'side' curve 2 ...

GMSH: Tutorial-04

Description and features: This tutorial explains usage of curve primitives other than straight lines such as arcs, splines, B-splines, circular and elliptical arcs ...
GMSH Tutorial 04

GMSH: Tutorial-05

Description and features: The usage of loop to create geometrical entities, arrays to store variables and application of user-defined macro is explained in this example.
GMSH Tutorial 05

GMSH: Tutorial-06

Description and features: The generation of structured mesh using transfinite interpolation is explained through this tutorials. Optinally, elliptical smoothing can be used to smoothen the grid but (like any smoothing operation) it may not necessarily improve the quality of the mesh.
GMSH Tutorial 06

GMSH: Tutorial-07, 08, 09

Description and features: The tutorials 7, 8 and 9 demonstrates post-processig capabilities of GMSH.
GMSH Tutorial 07

GMSH Tutorial 08

GMSH Tutorial 09

GMSH: Tutorial-10

Description and features: This demonstration is to create mesh density points to have finer mesh in a local area. The example also explains how to modulate the mesh element sizes using a mathematical function with the MathEval field.
GMSH Tutorial 10

GMSH: Tutorial-11

Description and features: As explained in tutorials 3 and 6, the extruded and transfinite meshes can be "recombined" into quads/prisms/hexahedra by using the "Recombine" keyword to generate structured mesh. This example explains method to create unstructured quad elements using same algorithm.
GMSH Tutorial 11

GMSH: Tutorial-12

Description and features: Excerpts - "Compound geometrical entities can be defined to compute a new parametrization of groups of elementary geometrical entities. This parametrization can then be used for remeshing the compound as if it were a single CAD entity."
GMSH Tutorial 12

GMSH: Tutorial-13

Description and features: Import of geometry in STL format created in MCAD programs, re-meshing of the geometry (re-meshing as STL format is already a mesh data).
GMSH Tutorial 13

GMSH: Tutorial-14

Description and features: Excepts - "Homology computation in GMSH finds representative chains of (relative) (co)homology space bases using a mesh of a model. The representative basis chains are stored in the mesh as physical groups of Gmsh, one for each chain."
GMSH Tutorial 14

GMSH: Tutorial-15

Description and features: Here is application of embedded points, lines and surfaces is explained. Geometrical entities are embedded to ensure mesh and not at/along these entities say to represent a baffle (line) or a (point for) heat source.
GMSH Tutorial 15



EXAMPLES FROM WWW

Unstructured and Structured Hybrid Meshes

The *.geo file can be downloaded from here. Note that GMSH can create structured mesh only on surfaces defined by 3 or 4 edges.
GMSH Unstructured and Structured Hybrid Meshes


Structured Mesh of a Solid Cuboid

The *.geo file can be downloaded from here.
GMSH Structured Mesh of a Solid Cuboid


Structured Mesh of a Hollow Cuboid

Reference: Generation of structured meshes via extrusion in GMSH by Roman Putanowicz, Cracow Univeristy of Technology.

The *.geo file can be downloaded from here.

GMSH Structured Mesh of a Hollow Cuboid


Cylinder in a Cross-flow

The *.geo file can be downloaded from here.

GMSH Cylinder in a Cross-flow


Structured Mesh of an Box Channel Beam

The extension of previous example is an box-channel beam which has application in structural simulations. The *.geo file can be downloaded from here.
GMSH Structured Mesh of an Box Channel Beam


Unstructured Mesh of an Icecream Cone

The *.geo file can be downloaded from here.
Unstructured Mesh of an Icecream Cone


Unstructured Mesh of an 2D Rotor-Stator Geometry

The *.geo file can be downloaded from here.
Unstructured Mesh of an 2D Rotor-Stator Geometry


Hex Nut in a Cube

The *.geo file can be downloaded from here.
Hex Nut in a Cube


Unstructured Tetra Mesh of a Geneva Wheel

The *.geo file can be downloaded from here.
geneva Wheel


Unstructured Hexa Mesh of a Geneva Wheel

The *.geo file can be downloaded from here.
geneva Wheel hexa mesh



Unstructured Tetra Mesh of an Annular Duct

The *.geo file can be downloaded from here.
Annular Duct


Troubleshooting

Sometimes the GMSH gives persistent error message during start-up. The best way is to clear some sort of cache using following option. This problem may appear when GMSH is forced shut-down when it became unresponsive due to some error in the *.geo file.

Reset Database in GMSH

The content on CFDyna.com is being constantly refined and improvised with on-the-job experience, testing, and training. Examples might be simplified to improve insight into the physics and basic understanding. Linked pages, articles, references, and examples are constantly reviewed to reduce errors, but we cannot warrant full correctness of all content.