CAD File Import, Mesh, and Grid Generation with Gmsh
Gmsh is a cross platform two and three dimensional mesh and grid generation software tool. As Gmsh supports many CAD file formats such as STEP, IGES, and STL, and also includes a variety of integrated mesh generation algorithms, such as Tetgen, Netgen, and Blossom-Quad, Gmsh can be used with FEATool to allow for more complex geometries and models than the built-in CAD and geometry tools support.
The following tutorial describes how Gmsh can be used to import a CAD geometry from a STEP file and generate a mesh for use with FEATool.
Gmsh CAD File Import and Mesh Generation Tutorial
This is a tutorial example showing how to import STEP model into Gmsh, and generate a 3D volume finite element mesh. The STEP file CAD model used in the example can be downloaded from the link below
1. CAD Model Import with the Merge Operation
The first step is to use the Gmsh
Merge option, found in
File menu. This opens a file selection dialog box
where the CAD file to import can be chosen. Select the spanner.step
file and press Open to automatically let Gmsh load, import, and
construct edges and faces for the geometry. If the model has been
imported successfully it should be displayed and shown in the GUI CAD
window where it can be inspected.
2. Setting Mesh Options and Specifying Grid Size
Gmsh supports several options to specify mesh and grid sizes. One can
for example prescribe sizes at points, and define mesh size
functions. Here the Min/Max Element Size option is used to set a
global maximum mesh size of 6 mm (as the model units is defined in
millimeters). This option is found on the
Mesh > General
tab of the
Options dialog box. A description of the
available mesh options is available in the
Gmsh reference guide.
3. 3D Mesh and Grid Generation
To generate a 3D volume mesh, first click on the [+] Mesh node in the left hand side tree list to expand it, then click to the 3D node option to call the selected mesh generation algorithm. If everything goes correctly the final mesh should be displayed in the Gmsh GUI window.
4. Mesh Info, Saving and Mesh Export
Progress information and messages are displayed in the bottom line of the Gmsh GUI. Clicking on this line also opens the message and log window where one can see information about the mesh generation process.
Once a mesh has been generated it can be saved in the Gmsh ASCII file
format by using the
Save Mesh option from the
File menu (the file will be saved in the same directory
and name as the imported CAD file but with the .msh file extension).
FEATool-Gmsh Mesh Import and Export Function
To import and use a Gmsh grid file with FEATool GUI one can either use
Import Grid > Gmsh Format option found under the
Grid mode menu.
Alternatively, the impexp_gmsh function can be used directly on the MATLAB command line, with for example the following commands
grid = impexp_gmsh( 'spanner.msh', 'import' ) plotgrid( grid ) plotbdr( grid )
How to import the CAD model in FEATool, define and set up simulations is explained in the following parametric structural mechanics simulation, and stress and displacement analysis tutorial.