Table of Contents
Fetching ...

Practical Introduction to FEM with GMSH: A MATLAB/Octave Perspective

Victor Dominguez, Alejandro Duque

TL;DR

This work delivers a transparent, educational 3D FEM framework based on $P_m$-elements implemented in MATLAB/Octave, with GMSH-enabled mesh input that links CAD geometry to numerical simulation. The method relies on an efficient element-by-element assembly and a Dirichlet lifting to solve the convection-diffusion-advection model, while extending naturally to elasticity and BEM–FEM couplings. It demonstrates practical performance across heat conduction, eigenfrequency analysis, and acoustic scattering, underscoring the approach's flexibility and scalability for teaching and research. By exposing the mesh data flow from GMSH to the FEM solver, the paper provides a robust, modular platform for exploring advanced FEM variants and coupling strategies in a high-level language.

Abstract

The Finite Element Method (FEM) is a powerful computational tool for solving partial differential equations (PDEs). Although commercial and open-source FEM software packages are widely available, an independent implementation of FEM provides significant educational value, provides a deeper understanding of the method, and enables the development of custom solutions tailored to specialized applications or integration with other solvers. This work introduces a 3D $\mathbb{P}_m$-element FEM implementation in MATLAB/Octave that is designed to balance educational clarity with computational efficiency. A key feature is its integration with GMSH, an open-source 3D mesh generator with CAD capabilities that streamlines mesh generation for complex geometries. By leveraging GMSH data structures, we provide a seamless connection between geometric modeling and numerical simulation. The implementation focuses on solving the general convection-diffusion-advection equation and serves as a flexible foundation for addressing advanced problems, including elasticity, mixed formulations, and integration with other numerical methods.

Practical Introduction to FEM with GMSH: A MATLAB/Octave Perspective

TL;DR

This work delivers a transparent, educational 3D FEM framework based on -elements implemented in MATLAB/Octave, with GMSH-enabled mesh input that links CAD geometry to numerical simulation. The method relies on an efficient element-by-element assembly and a Dirichlet lifting to solve the convection-diffusion-advection model, while extending naturally to elasticity and BEM–FEM couplings. It demonstrates practical performance across heat conduction, eigenfrequency analysis, and acoustic scattering, underscoring the approach's flexibility and scalability for teaching and research. By exposing the mesh data flow from GMSH to the FEM solver, the paper provides a robust, modular platform for exploring advanced FEM variants and coupling strategies in a high-level language.

Abstract

The Finite Element Method (FEM) is a powerful computational tool for solving partial differential equations (PDEs). Although commercial and open-source FEM software packages are widely available, an independent implementation of FEM provides significant educational value, provides a deeper understanding of the method, and enables the development of custom solutions tailored to specialized applications or integration with other solvers. This work introduces a 3D -element FEM implementation in MATLAB/Octave that is designed to balance educational clarity with computational efficiency. A key feature is its integration with GMSH, an open-source 3D mesh generator with CAD capabilities that streamlines mesh generation for complex geometries. By leveraging GMSH data structures, we provide a seamless connection between geometric modeling and numerical simulation. The implementation focuses on solving the general convection-diffusion-advection equation and serves as a flexible foundation for addressing advanced problems, including elasticity, mixed formulations, and integration with other numerical methods.

Paper Structure

This paper contains 29 sections, 85 equations, 12 figures, 7 algorithms.

Figures (12)

  • Figure 1: Left: (2D) Sketch of the domain $\Omega$. Right: example of conformal simplicial mesh of $\Omega$.
  • Figure 2: Reference tetrahedral element.
  • Figure 3: Node indexing on the $\mathbb{P}_1$ (top-left), $\mathbb{P}_2$ (top-right), $\mathbb{P}_3$ (bottom-left) and $\mathbb{P}_4$ (bottom-right) reference elements. The first inner node appears with $\mathbb{P}_4$ and it is marked in red
  • Figure 4: Mapping from $\widehat{K}$ to $K$.
  • Figure 5: Examples of node heritage for $\mathbb{P}_2$ elements. Left: Nodes in a tetrahedron $K$ and the inherited nodes in a triangular face $A$. Right: Nodes in the reference triangle $\widehat{A}$
  • ...and 7 more figures