Demos#
These demos illustrate the use of DOLFINx. Each is available as a Python script and as a Jupyter notebook (see the “Download sources” box at the top of each demo page). If you are new to DOLFINx, start with Poisson equation and then work through Getting started.
The remaining sections are organised by topic rather than by difficulty, and a demo that illustrates more than one topic is listed in more than one section. Some demos have additional requirements, noted below: the electromagnetics demos require DOLFINx to be built with complex PETSc scalars, and a few demos only run in serial.
Getting started#
Poisson equation – the recommended starting point: solve the Poisson equation with mixed Dirichlet/Neumann boundary conditions.
Helmholtz equation – solve the Helmholtz equation with both real-valued and complex-valued formulations.
Biharmonic equation – solve the biharmonic equation using an interior penalty discontinuous Galerkin method.
Interpolation, IO and visualisation#
Visualisation with PyVista – visualise finite element functions with PyVista, including warp-by-scalar and warp-by-vector plots.
Interpolation and IO – interpolate into an \(H(\mathrm{curl})\) Nédélec space and visualise it via a discontinuous Lagrange space.
Mixed and hybridised formulations#
Mixed formulation of the Poisson equation with a block preconditioner – solve the Poisson equation in mixed (flux, potential) form with a block-preconditioned iterative solver.
Stokes equations using Taylor-Hood elements – solve the Stokes equations with Taylor-Hood elements, comparing five block and monolithic solver strategies.
Divergence conforming discontinuous Galerkin method for Navier-Stokes – solve the Navier-Stokes equations with a divergence-conforming discontinuous Galerkin method.
HDG scheme for the Poisson equation – solve the Poisson equation with a hybridised discontinuous Galerkin (HDG) scheme, using a submesh of facets.
Static condensation of linear elasticity – solve a mixed linear elasticity formulation with static condensation of the stress degrees-of-freedom, using a numba-generated kernel.
Time-dependent and nonlinear problems#
Cahn-Hilliard equation – solve the time-dependent, nonlinear Cahn-Hilliard equation with a Newton solver.
Divergence conforming discontinuous Galerkin method for Navier-Stokes – time-step the semi-implicit divergence-conforming Navier-Stokes scheme (see also Mixed and hybridised formulations).
Linear solvers, preconditioners and matrix-free methods#
Elasticity using algebraic multigrid – solve the linear elasticity equations using a smoothed aggregation algebraic multigrid solver.
Solve the Poisson and linearised elasticity equations using pyamg – solve the Poisson and linearised elasticity equations using algebraic multigrid from pyamg (serial only).
Stokes equations using Taylor-Hood elements – see Mixed and hybridised formulations: five Stokes solver configurations, from block-preconditioned to fully monolithic.
Mixed formulation of the Poisson equation with a block preconditioner – see Mixed and hybridised formulations: a block-preconditioned solver, including a Hypre AMS preconditioner for \(H(\mathrm{div})\).
Matrix-free conjugate gradient solver for the Poisson equation – solve the Poisson equation with a matrix-free conjugate gradient solver.
Matrix-free solvers in DOLFINx using PETSc – solve a blocked projection problem with a matrix-free PETSc
SHELLoperator.Solving PDEs with different scalar (float) types – solve the Poisson equation using different scalar types (single/double precision, real/complex) and SciPy sparse solvers.
Custom and advanced finite elements#
Variants of Lagrange elements – create Lagrange elements with different node placements (equispaced versus Gauss–Lobatto–Legendre) using Basix.
Creating TNT elements using Basix’s custom element interface – define a custom finite element (a tiniest tensor element) using Basix’s custom element interface.
Mesh generation, partitioning and parallel data#
Mesh generation with Gmsh – generate and tag meshes using the Gmsh Python interface.
Mesh partitioning – compare graph and geometric mesh partitioning strategies and measure partition quality.
Parallel communication pattern analysis – build and analyse the parallel communication pattern of a distributed mesh with NetworkX.
Helmholtz equation on a mixed-topology mesh – solve a Helmholtz problem on a mesh with mixed cell topology (in development, serial only).
Electromagnetics#
All demos in this section require DOLFINx to be built with complex PETSc scalars.
Electromagnetic modal analysis for a waveguide – compute eigenmodes of a half-loaded rectangular waveguide using SLEPc.
Electromagnetic scattering from a wire with scattering BCs – simulate electromagnetic scattering from a wire using scattering boundary conditions.
Electromagnetic scattering from a wire with PML – simulate electromagnetic scattering from a wire using a perfectly matched layer (PML).
Electromagnetic scattering from a sphere (axisymmetric) – simulate axisymmetric electromagnetic scattering from a sphere using an axisymmetric PML.