Gmsh
Gmsh is an open-source three-dimensional finite element mesh generator with built-in computer-aided design (CAD) engine and post-processing facilities, designed to provide a fast, lightweight, and user-friendly tool for creating meshes used in numerical simulations such as finite element analysis.[1][2] Developed by Christophe Geuzaine and Jean-François Remacle, Gmsh originated in the summer of 1996 as a project to address the need for accessible meshing tools in computational mechanics, with its first public release in 1998 and the source code made available under the GNU General Public License (GPL) in 2003.[2] A major rewrite occurred in 2006, leading to version 2.0 in February 2007, which expanded its capabilities and improved performance, enabling it to generate approximately one million tetrahedra per minute while using around 150 MB of RAM on standard hardware.[2] The software is distributed under GPL v2 or later, ensuring free use and modification for open-source projects, though commercial licenses are available for proprietary applications.[1] Gmsh features four integrated modules—geometry description, meshing, solving, and post-processing—that allow users to create parametric models, generate structured or unstructured meshes (including high-order and quadrilateral elements), interface with external solvers like GetDP, and visualize results through tools such as isosurfaces and streamlines.[1][2] It supports multiple input methods, including a graphical user interface (GUI), command-line operation, scripting via.geo files, and application programming interfaces (APIs) in languages like C++, Python, Julia, and Fortran, making it versatile for both academic research and industrial workflows across platforms including Windows, Linux, and macOS.[1] Key algorithms include numerical integration for 1D meshing, local modifications like edge flipping for 2D, and Delaunay-based refinement for 3D, with options to integrate external CAD kernels (e.g., OpenCascade) and meshers (e.g., Netgen, Tetgen) for enhanced flexibility.[2]
Introduction
Overview
Gmsh is an open-source three-dimensional finite element mesh generator with a built-in computer-aided design (CAD) engine and post-processor. Released under the GNU General Public License, it enables the creation of complex geometries, generation of high-quality meshes, and visualization of simulation results in a unified environment.[1][2] The tool's core design goals emphasize speed, minimal resource usage, and accessibility for users in scientific computing, achieved through parametric input scripts and versatile visualization features that support both interactive and automated workflows. This lightweight architecture allows Gmsh to generate large meshes efficiently, such as up to one million tetrahedra per minute on standard hardware, without compromising usability.[1][2] Gmsh finds primary application in generating unstructured meshes for finite element methods, supporting simulations across engineering disciplines like structural analysis and electromagnetics, as well as physics problems involving complex geometries. Its integrated modules—geometry definition for CAD modeling, meshing for discretization, solver interfacing for numerical computations, and post-processing for result analysis—streamline the preparation and evaluation of finite element simulations in academic and industrial settings.[2][1] The typical workflow begins with defining parametric geometries using the CAD engine, proceeds to mesh generation tailored to the problem's requirements, optionally integrates with external solvers for computation, and concludes with post-processing to output and visualize data in formats compatible with various analysis tools.[1][2]History
Gmsh was initiated in 1996 as a side project by Christophe Geuzaine and Jean-François Remacle at the Université de Liège in Belgium, with the aim of creating a lightweight, user-friendly tool for finite element mesh generation and processing.[3] The project began during their graduate studies, focusing initially on basic geometry and mesh capabilities to support their research in computational electromagnetics.[2] The first public release of Gmsh occurred in 1998, following two years of intermittent development.[4] Initially distributed as proprietary software, it transitioned to open-source status in 2003 under the GNU General Public License (GPL), enabling broader collaboration and community contributions.[3] A significant milestone came with the release of Gmsh 2.0 in February 2007, which integrated the OpenCASCADE kernel for enhanced CAD import and Boolean operations, expanding its applicability to complex geometries.[2] Development continued steadily through subsequent versions, with the foundational capabilities formalized in a 2009 paper published in the International Journal for Numerical Methods in Engineering.[5] Following the 2009 publication, Gmsh's adoption expanded rapidly from its academic origins to become a staple in both research and industrial finite element workflows by the mid-2010s, as reflected in its integration with major simulation platforms and high citation impact.[6] Ongoing enhancements through the 4.x series addressed advanced meshing needs, such as high-order elements.[3] As of November 2025, Gmsh remains actively maintained on GitLab, with version 4.15.0 released on October 26, 2025, incorporating improvements in performance and plugin support.[7] Version 5.0 is currently in development, promising further refinements to its core engine and interfaces.[1]Technical Features
Geometry Modeling
Gmsh's geometry modeling capabilities are centered around a built-in CAD engine that enables the creation and manipulation of models suitable for subsequent meshing processes. The software employs a boundary representation (B-rep) approach to define watertight geometric models, constructing them from elementary entities such as points (0D), curves (1D), surfaces (2D), and volumes (3D). These entities are identified by unique tags and can be combined hierarchically to form complex geometries, ensuring topological consistency and physical closure for robust simulations.[8] Parametric modeling in Gmsh is primarily achieved through the .geo scripting language, which allows users to define geometries programmatically in a bottom-up manner. For instance, basic primitives like lines, circles, splines, plane surfaces, ruled surfaces, and spheres can be created using commands such asPoint, Line, Circle, Plane Surface, and Sphere, with parameters controlling sizes and positions. Boolean operations, including union (BooleanUnion), intersection (BooleanIntersection), difference (BooleanDifference), and fragmentation (BooleanFragments), facilitate the combination or subtraction of entities to build intricate shapes. Additionally, geometric transformations such as translation (Translate), rotation (Rotate), scaling (Scale), and symmetry (Symmetry) enable precise adjustments, often applied to duplicated entities for repetitive structures.[9][10]
Since version 2.0, released in 2007, Gmsh has integrated the OpenCASCADE kernel to enhance its handling of complex geometries, selectable via SetFactory("OpenCASCADE"). This integration supports non-uniform rational B-splines (NURBS) for defining smooth curves and surfaces, enabling advanced features like fillets, chamfers, and pipes. It also allows direct import of standard CAD formats such as STEP and IGES files using ShapeFromFile, preserving labels, colors, and native representations for seamless workflow integration.[11][12][13]
For scenarios involving imported data without parametric definitions, Gmsh supports discrete geometry handling, where meshes or point clouds (e.g., from STL files) are treated as discrete entities via commands like Discrete Curve or addDiscreteEntity in the API. These can be reparametrized for further manipulation, bridging raw data to structured models while maintaining compatibility with the b-rep framework.[14]
Mesh Generation
Gmsh's mesh generation capabilities enable the discretization of geometric models into finite element meshes suitable for numerical simulations, primarily through a bottom-up approach that progresses from 1D curves to 2D surfaces and 3D volumes, ensuring conformity across dimensions.[15] The process relies on user-defined or automatic mesh sizes, with the software supporting both isotropic and anisotropic meshing to adapt to geometric features like curvature and proximity.[2] By default, Gmsh produces unstructured meshes, but it allows for structured or hybrid configurations in specific regions.[15] Unstructured mesh generation in Gmsh supports simplicial elements such as line segments in 1D, triangles in 2D, and tetrahedra in 3D, as well as non-simplicial types like quadrilaterals and hexahedra through recombination techniques applied post-generation.[15] For instance, theRecombine Surface option transforms triangular meshes into quadrilateral ones while preserving boundary constraints.[15] This flexibility accommodates a wide range of applications, from general-purpose simulations to those requiring prismatic or pyramidal elements in hybrid 3D meshes.[2]
The core algorithms for mesh generation include Delaunay triangulation, which employs the Bowyer-Watson method for efficient 2D and 3D tetrahedralization, offering robustness for complex geometries and supporting up to approximately 7 million tetrahedra per gigabyte of memory.[2] In 2D, the Frontal-Delaunay algorithm advances a mesh front to produce high-quality triangles, while the MeshAdapt method, based on local modifications, handles intricate surfaces robustly.[15] For 3D, the Frontal algorithm prioritizes element quality through front advancement, and parallel options like HXT enable high-performance meshing on multi-core systems via OpenMP. As of version 4.15.0 (October 2025), enhancements include optimized parallel processing for large-scale meshing.[15][16] Additionally, the BAMG (Bidimensional Anisotropic Mesh Generator) algorithm facilitates anisotropic 2D surface meshing, controlled by parameters such as Mesh.Algorithm = 7 and Mesh.AnisoMax, to align elements with directional features.[15]
Automatic mesh sizing fields are computed based on geometric properties, including curvature via MeshSizeFromCurvature and proximity using distance fields, ensuring refined resolution near boundaries or sharp features without manual intervention.[15] These fields combine multiple sources—such as vertex-defined sizes, background meshes, or gradings—by taking the minimum value, with an efficiency index τ (ranging from 0 to 1, ideally near 1) guiding the balance between element count and accuracy.[2]
High-order meshing in Gmsh generates curved elements up to arbitrary polynomial orders, set via Mesh.ElementOrder, to accurately represent curved geometries and reduce discretization errors in simulations.[15] Optimization techniques, including elastic smoothing (Mesh.HighOrderOptimize = 2), ensure valid element shapes by adjusting node positions, with parameters like Mesh.HighOrderThresholdMin controlling the curvature tolerance for higher-order conversions.[15]
For computational fluid dynamics and boundary-dominated problems, Gmsh supports boundary layer meshing through extrusion with layered sweeps from source surfaces, creating structured prismatic layers within otherwise unstructured volumes.[2] In 2D, the BoundaryLayer field explicitly defines these regions. Structured mesh options, such as transfinite interpolation or elliptic smoothing, can be applied to selected entities for regular grids in channels or extruded shapes.[15]
Meshes are exported in various formats, including the native MSH (versions 2.2, 4.0, or 4.1 by default for binary efficiency), I-DEAS UNV, MED for Salome integration, and others like VTK or CGNS, selectable via the Mesh.Format option or command-line flags.[15] These formats facilitate seamless integration with solvers such as GetDP.[15]
Element quality is assessed using metrics like the radii ratio γ_K (from 0 for degenerate to 1 for equilateral elements), with optimization routines such as Laplacian smoothing (Mesh.Smoothing > 0) or Netgen-based untangling improving the minimum γ_K—for example, from 0.001 to 0.41 in tetrahedral meshes.[2] Threshold-based optimization (Mesh.OptimizeThreshold) targets poor elements to enhance overall mesh validity and simulation reliability.[15]
Post-Processing
Gmsh's post-processing module provides a built-in viewer for analyzing simulation results on finite element meshes, supporting the display of scalar, vector, and tensor fields defined at nodes or elements.[15] This module handles multiple datasets, referred to as "views," which can include time-dependent data across various steps, enabling the examination of transient phenomena without reloading files.[15] For instance, a single view can store data for up to hundreds of time steps, facilitating animations and comparative analysis.[2] Visualization in the post-processor leverages OpenGL for efficient rendering, offering options such as isosurfaces and iso-curves for scalar fields, 3D arrows or displacement maps for vectors, and ellipsoids or eigenvalue-based plots for tensors.[15] Additional techniques include streamlines to depict flow patterns, cutting planes for sectional views, and glyph plots for localized field representations, with adaptive sampling to balance detail and performance—such as adjusting recursion levels or target error thresholds during rendering.[15] These options apply to the underlying meshes generated in Gmsh, ensuring consistent display of geometric and topological structures.[2] The module supports mathematical operations on fields, including interpolation between datasets, evaluation of user-defined expressions (e.g., combining components into derived quantities like divergence), and extensions via plugins.[15] Plugins, numbering around 30 in the standard distribution, enable advanced tasks such as error estimation through a posteriori computations or boundary layer extraction, and users can implement custom plugins in C++ for specialized analyses.[2] Non-destructive transformations, like scaling or clipping, preserve original data integrity during exploration.[15] Export functionalities allow saving visualizations as images in formats like PNG and GIF, animations for time-series data, or raw datasets in VTK for integration with external tools.[15] High-quality vector outputs are generated using the GL2PS library, supporting off-screen rendering for large-scale images.[2] High-order visualization capabilities match the curved elements produced during meshing, accurately representing solutions from high-order finite element methods by interpolating data onto adaptive grids with schemes that preserve polynomial degrees.[2] This ensures fidelity in displaying discontinuous or high-degree fields, critical for applications like discontinuous Galerkin simulations.[15]Solver Capabilities
Gmsh provides an embedded solver interface through its integration with GetDP, an open-source finite element solver that enables multiphysics simulations directly within the Gmsh environment. This coupling allows users to perform finite element analyses for problems in electrostatics, magnetics, acoustics, and heat transfer using mixed finite elements based on de Rham-type complexes in one, two, or three dimensions.[17][15] The interface leverages the ONELAB framework, a client-server model that facilitates seamless data exchange between Gmsh and GetDP, including geometry, mesh, and parameter synchronization without requiring modifications to the source code.[15][18] Key aspects of the solver setup are defined within Gmsh's .geo files, where physical groups identify domains, boundaries, and volumes for applying boundary conditions and material properties. For instance, commands likePhysical Surface or Physical Volume group geometric entities, enabling the specification of Dirichlet or Neumann boundary conditions and material attributes such as permittivity in electrostatics or thermal conductivity in heat transfer problems.[15] GetDP then processes these definitions in its .pro input files, supporting iterative solving with linear and nonlinear solvers backed by libraries like PETSc for preconditioned iterative methods and MUMPS for direct sparse solvers.[17] Parallel computation is available via MPI for distributed-memory systems, allowing scalable simulations on clusters when Gmsh and GetDP are compiled with MPI support.[17][15]
While this integration excels in lightweight prototyping for rapid model setup and testing—particularly for academic and research applications involving moderate-sized problems—Gmsh is not a full standalone solver comparable to dedicated frameworks like FEniCS.[15] Instead, it focuses on providing an accessible entry point for solver execution, with ONELAB ensuring parameter consistency across tools for iterative design workflows.[18] This approach prioritizes ease of use in multiphysics contexts but may require external post-processing for complex visualizations beyond Gmsh's built-in capabilities.[5]
User Interfaces
Graphical User Interface
The graphical user interface (GUI) of Gmsh provides an interactive environment for users to create, mesh, and visualize models without relying on scripting or command-line inputs. It is structured around four primary modules—geometry, mesh, solver, and post-processing—accessible through intuitive menus, toolbars, and an OpenGL-based rendering window. The interface features a central graphics view for real-time visualization, a tree-based panel for managing entities and options, and dedicated panels for module-specific operations, enabling a seamless workflow from model design to analysis.[19] The main windows include the geometry editor, which allows users to build models interactively in the 3D graphics view using mouse-driven tools. For instance, points can be created by clicking in the view or entering coordinates via dialog boxes, while lines and curves are drawn by connecting points with selection tools from the toolbar. Surfaces are formed by selecting boundaries, and more complex 3D volumes are generated through operations like extrusion (dragging faces along a direction) or revolution (rotating profiles around an axis), all visualized in real-time with rotation, zoom, and pan controls via mouse gestures. The options tree, accessible under Tools > Options, provides hierarchical access to parameters such as tolerances and snapping behaviors, ensuring precise entity manipulation.[8][19] Meshing is handled through menu-driven controls in the Mesh module, where users select algorithms like Delaunay triangulation for 2D or Frontal-Delaunay for 3D via dropdown menus under Mesh > 2D or 3D. Refinement options, such as element size factors or adaptive biasing, are adjusted in the options tree or dialog prompts before computation, with progress tracked in the status bar. Once generated, the mesh viewer displays the result with color-coded quality metrics—e.g., highlighting skewed elements—and allows interactive checks like edge length histograms or Jacobian evaluations through right-click context menus, facilitating iterative improvements without restarting the process.[20][21] Post-processing panels support visualization of simulation results by loading data files (e.g., .pos or .msh formats) via File > Merge, which populates the view list in the tree panel. Users manipulate views by toggling visibility, adjusting isosurface levels, or animating time steps with slider controls in the graphics window. Plugin activation, accessed via Plugins > Built-in or keyboard shortcut Shift+U, extends functionality for tasks like streamline plotting or cut-plane slicing, with parameters tunable in dedicated dialogs for customized output.[22][23] Gmsh's GUI ensures cross-platform compatibility with a native appearance on Windows, Linux, and macOS, powered by the FLTK toolkit for lightweight, responsive rendering and theming options adjustable via General > FltkTheme in the options tree. This setup supports efficient interactive workflows, such as opening a new project (File > New), building geometry step-by-step, meshing on demand (e.g., pressing '2' for 2D), and exporting views, all within a single session.[24][19]Command-Line Interface
Gmsh provides a command-line interface (CLI) for non-interactive operations, enabling automated geometry modeling, mesh generation, and post-processing in scripting pipelines and batch environments.[25] The CLI parses input files such as.geo scripts without launching the graphical user interface, making it suitable for integration into computational workflows.[25]
Basic invocation uses the command gmsh [options] file.geo, where file.geo specifies the input geometry or mesh script file.[25] For example, gmsh model.geo processes the file and generates output based on embedded commands.[25] For non-interactive operation, use batch flags such as -2 for 2D meshing: gmsh model.geo -2, which parses the file, executes geometry and mesh definitions if specified, and exits without GUI interaction.[25]
Key options control meshing dimensions, output, and verbosity. The -2 flag generates a 2D mesh and exits, as in gmsh model.geo -2.[25] Similarly, -3 produces a 3D mesh.[25] Output files are specified with -o filename.msh, for instance gmsh model.geo -2 -o output.msh, exporting the mesh in MSH format.[25] Verbosity is adjusted via -v level, where level ranges from 0 (silent) to 5 (debug), with the default at 2; higher levels provide detailed progress and warnings.[25]
Batch mode supports scripting integration by combining options for automated runs, such as scaling mesh sizes globally with -clscale factor before meshing: gmsh model.geo -clscale 0.5 -2 -o coarse.msh.[25] The -parse_and_exit option parses .geo files solely for validation or geometry unrolling without meshing.[25]
Error handling outputs issues to the terminal, with severity indicated by verbosity settings; syntax errors in .geo files halt execution immediately.[25] Logging is enabled via -log filename to redirect messages to a file, facilitating debugging in pipelines: gmsh model.geo -2 -log run.log.[25] The Exit n; command within scripts aborts with exit code n for programmatic error propagation.[25]
On platform-specific notes, the CLI operates on headless servers without display dependencies, ideal for high-performance computing (HPC) environments.[25] Threading is configured with -nt threads for parallel meshing, e.g., gmsh model.geo -nt 8 -3 -o output.msh, leveraging OpenMP on multi-core systems.[25] The -nopopup option suppresses any potential dialog prompts in server setups.[25] While the CLI excels in automation, the graphical user interface serves as an alternative for interactive exploration.[25]
Scripting and Programming Interfaces
Gmsh provides a built-in scripting language in plain text files with the.geo extension, enabling parametric definition of geometry and meshes through a syntax that includes basic entities like points, lines, curves, surfaces, and volumes. For instance, a point is defined as Point(tag) = {x, y, z, mesh_size}, a line as Line(tag) = {start_point, end_point}, and a plane surface as Plane Surface(tag) = {curve_loop}.[8] This language supports control structures such as For loops for iteration (e.g., For i In {1:5} ... EndFor to create repeated entities) and If conditionals for logic (e.g., If (x > 0) ... EndIf to adjust parameters based on values).[26] Macros allow reusable code blocks, defined with Macro name ... Return and invoked via Call name;, facilitating modular geometry construction like parametric holes in surfaces.[26] External modules can be included using Include "file.geo"; to import definitions from other scripts, promoting composable workflows.[26]
The Gmsh API offers bindings for programmatic control and embedding in custom applications, with the core implemented in C++ for direct access to modules like geometry, meshing, and post-processing.[27] C bindings provide a procedural interface, while Python bindings, generated via SWIG, enable high-level scripting with functions like gmsh.model.geo.addPoint(x, y, z, lc).[27] Julia and Fortran bindings support object-oriented and procedural usage, respectively, with Fortran's official API introduced in version 4.11.0 to align with other languages.[27] These APIs allow full control over model creation, mesh generation, and solver integration, with tutorials demonstrating equivalents across languages, such as creating a simple geometry in C++ via gmsh::model::geo::addPoint(0, 0, 0, lc);.
Gmsh acts as an ONELAB client in a client-server architecture for exchanging parameters with other tools, using commands like DefineConstant[ param = {value, Min min, Max max, Step step} ]; to define numbers, strings, or choices that can be modified externally via TCP/IP or files.[28] This facilitates coupled simulations, where parameters such as mesh sizes or boundary conditions are synchronized between Gmsh and solvers like GetDP.
For parametric mesh generation, a Python example creates an anisotropic mesh for an aneurysm model by defining geometry points and curves programmatically, then generating and optimizing the mesh with gmsh.model.mesh.generate(3) and gmsh.model.mesh.optimize("Netgen"). In C++, plugin development is exemplified by post-processing plugins that process views, such as the SimplePartition plugin in tutorial t21, which partitions data using PView::create() and custom filters.
Starting with version 4.x, the Python API was enhanced to better support high-order elements, including functions like gmsh.view.addHomogeneousModelData for associating high-order datasets with views, as demonstrated in tutorial x4.py for curved tetrahedral meshes.
Development and Community
Licensing and Versions
Gmsh has been distributed under the GNU General Public License (GPL) version 2 or later since its open-sourcing in 2003, permitting free use, modification, and distribution as long as derivative works adhere to the same terms.[29] This license includes an exception to facilitate linking with external libraries without imposing GPL restrictions on those libraries.[30] For proprietary applications requiring closed-source embedding or distribution, commercial licenses are available from the developers.[31] The project follows a release model featuring periodic stable versions, development snapshots, and software development kits (SDKs) for integration. The latest stable release as of November 2025 is version 4.15.0, released on October 26, 2025, with prior versions such as 4.14.1 (September 2, 2025) and 4.13.1 (May 24, 2024) providing incremental improvements and bug fixes.[16] Development snapshots, like the ongoing Gmsh 5.0.0 branch, allow early access to experimental features via the source repository.[32] SDKs are provided for Windows, Linux, and macOS, enabling programmatic use without the full graphical interface.[1] Gmsh maintains backward compatibility for its core scripting files (.geo), which define geometries and meshes, across major versions, ensuring that legacy scripts can generally be processed without modification.[15] Deprecations and breaking changes, such as the removal of obsolete partitioning code in version 4.0.0 or renaming of parser functions in 4.15.0, are documented in the changelog to guide users on updates.[16] Options likeGeometry.OCCSafeUnbind in version 4.10.2 provide toggles for compatibility with prior behaviors.[16]
Core dependencies include the OpenCASCADE library for advanced geometry modeling and boolean operations, and the FLTK toolkit for the graphical user interface.[15] Solver capabilities optionally require PETSc for parallel linear algebra operations.[33] These dependencies are bundled in precompiled binaries, but source builds necessitate their installation.
ONELAB GmbH, associated with the project's maintainers, provides professional support services and facilitates access to closed-source licensing options for commercial deployments.[34]