Hands-on tutorials for engineers learning FEniCSx (DOLFINx 0.10). Covers fundamentals through coupled physics and design automation. Each tutorial is a Python script with inline comments plus a companion markdown explanation.
# Pull the Docker image
docker pull dolfinx/dolfinx:stable
# Run a tutorial
docker run --rm -v $(pwd):/work -w /work dolfinx/dolfinx:stable \
python3 tutorials/01_fundamentals/01_poisson.pyFor visualization (optional):
docker run -it --rm -v $(pwd):/work -w /work dolfinx/dolfinx:stable bash
pip install pyvista matplotlib
python3 tutorials/01_fundamentals/01_poisson.pyOutput files (XDMF) go to output/ and can be opened in ParaView.
| # | Topic | Script |
|---|---|---|
| - | Docker environment & install verification | 00_setup/ |
| # | Topic | Script |
|---|---|---|
| 00 | FEM math refresher (weak forms, basis functions) | 01_fundamentals/00_math_fundamentals.py |
| 01 | Poisson equation — the 7-step FEniCSx pipeline | 01_fundamentals/01_poisson.py |
| 02 | Boundary conditions (Dirichlet, Neumann, Robin) | 01_fundamentals/02_boundary_conditions.py |
| 03 | Visualization and export (XDMF, PyVista) | 01_fundamentals/03_visualization.py |
| 04 | Mesh convergence study | 01_fundamentals/04_convergence.py |
| 05 | Gmsh integration: 2D meshes | 01_fundamentals/05_gmsh_2d.py |
| 06 | Gmsh integration: 3D meshes | 01_fundamentals/06_gmsh_3d.py |
| 07 | Gmsh parametric geometry | 01_fundamentals/07_gmsh_parametric.py |
| # | Topic | Script |
|---|---|---|
| 01 | Steady conduction with Robin BCs | 02_heat_transfer/01_steady_heat.py |
| 02 | Transient conduction (backward Euler) | 02_heat_transfer/02_transient_heat.py |
| # | Topic | Script |
|---|---|---|
| 01 | Linear elasticity (3D cantilever, von Mises) | 03_solid_mechanics/01_linear_elasticity.py |
| 02 | Hyperelasticity (neo-Hookean, Newton solver) | 03_solid_mechanics/02_hyperelasticity.py |
| 03 | CAD workflow: spring stiffness from STEP/OCC | 03_solid_mechanics/03_cad_spring_stiffness.py |
| # | Topic | Script |
|---|---|---|
| 01 | Stokes flow (Taylor-Hood elements) | 04_fluid_flow/01_stokes.py |
| 02 | Navier-Stokes (IPCS splitting scheme) | 04_fluid_flow/02_navier_stokes.py |
| # | Topic | Script |
|---|---|---|
| 01 | Thermoelastic coupling | 05_coupled_and_automation/01_thermoelastic.py |
| 02 | Parametric sweep (CSV export) | 05_coupled_and_automation/02_parametric_sweep.py |
| 03 | Optimization (scipy + FEniCSx) | 05_coupled_and_automation/03_optimization.py |
If you want to start running your own simulations quickly, you don't need to go through every tutorial in order.
The minimum path (3-4 tutorials):
-
01_fundamentals/01_poisson.py— The 7-step FEniCSx pipeline: mesh, function space, BCs, weak form, solve, export. Every other tutorial reuses this skeleton. Understand this one well. -
01_fundamentals/03_visualization.py— Skim. Know how to export XDMF and view in ParaView. -
Pick the physics you need:
- Structural:
03_solid_mechanics/01_linear_elasticity.py - Thermal:
02_heat_transfer/01_steady_heat.py - Fluid:
04_fluid_flow/01_stokes.py
The jump from Poisson is mainly the function space and weak form — the solver setup is identical.
- Structural:
-
03_solid_mechanics/03_cad_spring_stiffness.py— If you're working with real CAD parts instead of boxes. Covers the Gmsh OCC / STEP import pipeline.
Skip until you actually need them:
- Hyperelasticity (03/02) — large deformations only
- Transient heat (02/02) — time-dependent problems only
- Navier-Stokes (04/02) — when Stokes isn't enough
- Coupled/optimization (05/) — multi-physics or parametric studies
The pattern to internalize: every FEniCSx simulation is the same loop — define the mesh, pick the function space, write the weak form in UFL, solve, post-process. The weak form is the only part that changes between physics; the rest is boilerplate. Once you've done it twice, you can set up a new problem by copying an existing tutorial and modifying it.
- FEniCSx (DOLFINx 0.10) via
dolfinx/dolfinx:stableDocker image - Gmsh for meshing (built-in and OCC/STEP workflows)
- PETSc for linear algebra (KSP, SNES)
- matplotlib / PyVista for visualization (optional)
- scipy for optimization loops (tutorial 05/03)