About the Examples
The examples in this package are designed to be practical, reproducible, and educational. They demonstrate a wide range of finite element applications and PDE model problems.
Design Principles
- All examples can be run directly from the Julia REPL.
- Each example is a Julia module named after the file.
- Examples can serve as templates for your own projects.
- Many examples include test cases for automated verification.
Running the Examples
To run an example (e.g., Example212_PeriodicElasticity2D):
Download the example file (see the source code link at the top of the example page).
Start Julia in the root directory of the package (or in the directory that contains the example file). Some examples need additional dependencies beyond the core requirements, so the easiest way to get all of them is to use the package test environment. After
Pkg.activate("."), it can be activated via the package TestEnv:julia julia> using Pkg; Pkg.activate(".") julia> using TestEnv; TestEnv.activate()Include the example file and call its
mainfunction:julia julia> include("Example212_PeriodicElasticity2D.jl") julia> Example212_PeriodicElasticity2D.main()Some examples offer visual output via the optional argument
Plotter = PyPlotorPlotter = GLMakie(provided the package is installed and loaded):julia julia> Example212_PeriodicElasticity2D.main(Plotter = PyPlot)
Overview of the Examples
The examples are listed below in numerical order. Each name links to the documentation page of the example; the keywords indicate the application and the finite element concepts demonstrated there (method type, coupling, error estimation, etc.).
| Example | Description |
|---|---|
| Example103 | 1D Burgers equation (scalar conservation law) with periodic boundary conditions, solved by a DifferentialEquations-based and a manual implicit Euler time discretization — keywords: time-dependent, nonlinear, periodic boundary |
| Example105 | 1D nonlinear Poisson equation with Dirichlet data, solved by Newton iteration — keywords: conforming FEM, nonlinear |
| Example106 | 1D porous-medium (nonlinear) diffusion equation with Neumann data — keywords: conforming FEM, time-dependent, nonlinear |
| Example108 | 1D convection–diffusion–reaction with a mixed Robin/Dirichlet boundary condition, verified against an exact solution — keywords: conforming FEM, Robin boundary condition, nonlinear, convergence study |
| Example201 | 2D Poisson problem on the unit square; demonstrates BoundaryDataRestriction- and operator-based boundary data — keywords: conforming FEM, restrictions |
| Example202 | 2D Poisson problem in mixed (stress–potential) form with H(div)-conforming stress — keywords: conforming FEM, mixed method, H(div) |
| Example203 | 2D Poisson problem with inhomogeneous Dirichlet data, solved with the discontinuous Galerkin (interior penalty) method — keywords: discontinuous Galerkin, interior penalty |
| Example204 | eigenvalue problem for the Laplacian on the L-shaped domain, using a KrylovKit iterative solver — keywords: conforming FEM, eigenvalue problem |
| Example205 | 2D heat equation with Dirichlet data and time integration via DifferentialEquations — keywords: conforming FEM, time-dependent |
| Example206 | two Poisson problems on subdomains, coupled across a new internal interface region by a penalized interface condition — keywords: conforming FEM, coupled problem, interface conditions, penalty |
| Example207 | 2D advection equation with an upwind discontinuous Galerkin and inflow boundary data — keywords: discontinuous Galerkin, upwind stabilization, advection |
| Example210 | residual error estimator and adaptive mesh refinement for the Poisson problem on the L-shaped domain; also demonstrates second-order derivative evaluation — keywords: conforming FEM, error estimation, adaptive mesh refinement, convergence study |
| Example211 | locally equilibrated (dual stress-reconstruction) error estimator, assembled in parallel on non-overlapping node patch groups — keywords: conforming + mixed FEM, equilibrated error estimation, adaptive mesh refinement, low-level assembly, convergence study |
| Example212 | linear elasticity on an unstructured periodic 2D grid with periodic coupling along one axis — keywords: conforming FEM, elasticity, periodic boundary, homogenization |
| Example220 | convection–diffusion–reaction; compares a conforming discretization with and without a gradient-jump stabilization for small diffusion — keywords: conforming FEM, interior penalty stabilization, convergence study |
| Example225 | obstacle problem (Dirichlet energy minimization above an obstacle) via a penalty term and Newton iteration — keywords: conforming FEM, variational inequality, penalty, nonlinear |
| Example226 | thermoforming benchmark: nonlinear elasticity with temperature-dependent material parameters — keywords: conforming FEM, nonlinear elasticity |
| Example227 | the obstacle problem of Example225, solved with a latent-variable proximal-point algorithm instead of a penalty — keywords: conforming FEM, variational inequality, latent variable proximal point, nonlinear |
| Example230 | nonlinear (bimetal) elasticity; demonstrates region- and parameter-dependent nonlinear expressions — keywords: conforming FEM, nonlinear elasticity, convergence study |
| Example235 | Hagen–Poiseuille flow with the iterated penalty method (Bernardi–Raugel element) — keywords: incompressible flow, Stokes, iterated penalty method |
| Example240 | Stokes flow with a Scott–Vogelius type element: continuous Pk velocity functions enriched by Raviart–Thomas functions plus a discontinuous P{k-1} pressure, giving a pointwise divergence-free velocity on general meshes, with DOF reduction — keywords: incompressible flow, Stokes, H(div) velocity enrichment, inf-sup stability, convergence study |
| Example245 | DFG benchmark (flow around a cylinder) on an externally generated mesh; computes drag/lift coefficients — keywords: incompressible flow, Navier–Stokes, nonlinear, external mesh generation, postprocessing |
| Example250 | Navier–Stokes in a lid-driven cavity over a cone; demonstrates vortex formation — keywords: incompressible flow, Navier–Stokes, nonlinear |
| Example252 | planar lattice flow Navier–Stokes problem with exact data; compares the L2 error of two restriction-based discretizations — keywords: incompressible flow, Navier–Stokes, nonlinear, restrictions, convergence study |
| Example260 | three-dimensional stagnation-point flow via the 2.5D axisymmetric Navier–Stokes formulation — keywords: incompressible flow, Navier–Stokes, axisymmetric |
| Example264 | coupled Stokes (free flow) / Darcy (porous medium) problem with interface transmission conditions — keywords: incompressible flow, Stokes + Darcy, interface conditions |
| Example265 | Stokes flow in an Ω-shaped pipe driving a convection–diffusion transport equation; compares stabilized convection discretizations and uses a CallbackOperator — keywords: incompressible flow, Stokes, transport, upwind/grad-jump stabilization, callback operator |
| Example266 | Navier–Stokes flow in a bent channel with periodic coupling between inlet and outlet via a CoupledDofsRestriction and no-slip walls, discretized with Taylor–Hood elements; the periodicity of the computed velocity is verified at test points — keywords: incompressible flow, Navier–Stokes, periodic boundary, coupled DOFs, nonlinear |
| Example270 | natural convection (Boussinesq) in a triangular cavity, coupling Navier–Stokes and heat conduction — keywords: incompressible flow, Navier–Stokes, heat equation, convergence study |
| Example275 | optimal control for the Stokes problem; computes the optimal control with an adjoint formulation — keywords: incompressible flow, Stokes, optimal control, adjoint, convergence study |
| Example280 | 2D compressible Stokes flow with an equation of state; a well-balanced (gradient-robust) discretization is compared against a standard one — keywords: incompressible flow, Stokes, compressible, equation of state, convergence study |
| Example282 | stationary incompressible viscous MHD: Navier–Stokes coupled with the magnetic induction equation — keywords: incompressible flow, Navier–Stokes, MHD, nonlinear |
| Example284 | time-dependent convection of a level set by a given velocity field — keywords: conforming FEM, level set, free boundary, time-dependent |
| Example285 | phase-field Cahn–Hilliard equation in mixed form — keywords: mixed method, phase field, time-dependent |
| Example290 | three-field Biot consolidation model with an H(div)-conforming reconstruction to avoid Poisson locking — keywords: mixed method, poroelasticity, H(div), time-dependent, convergence study |
| Example295 | droplet sliding down a surface with surface tension and slip, tracked with an ALE moving mesh up to a stationary state — keywords: incompressible flow, Navier–Stokes, ALE moving mesh, free boundary, time-dependent, nonlinear |
| Example301 | 3D Poisson problem on the unit cube; demonstrates iterative (Krylov) solvers with incomplete LU preconditioners — keywords: conforming FEM, 3D, Krylov solvers and preconditioning |
| Example310 | best approximation of a divergence-free velocity by a divergence-free Raviart–Thomas (H(curl)-type) basis with a linearly independent basis construction — keywords: mixed method, H(curl), divergence-free basis, 3D |
| Example312 | 3D periodic elasticity on a generated unstructured grid with periodic coupling along one axis — keywords: conforming FEM, elasticity, periodic boundary, 3D |
| Example313 | 3D periodic Poisson problem verifying the restriction-based periodic boundary operator against the exactly linear solution — keywords: conforming FEM, periodic boundary, restrictions, 3D |
| Example330 | neo-Hookian hyperelasticity in 3D; the energy is twice differentiated automatically to set up the Newton scheme — keywords: conforming FEM, hyperelasticity, nonlinear, automatic differentiation, 3D |
Learn a Concept
If you are looking for a particular finite element concept instead of a particular problem, this table shows where to look: the corresponding documentation page(s) and the examples that demonstrate the concept. Where no documentation page exists, the listed examples are currently the primary reference.