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 block and – 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.
Problems on manifolds#
Mixed Poisson equation on the sphere – solve the Poisson equation in mixed form on the sphere, with Raviart-Thomas elements on a surface taken from a Gmsh volume mesh, widening the ghost layer with a custom partitioner so that the facets can be signed in parallel.
Mixed Poisson on a Möbius strip – solve the same equation on a Möbius strip, where no consistent orientation of the cells exists, on a higher-order mesh built by hand, with a cylinder as a control.
The eikonal equation on a Möbius strip – compute the distance to the boundary of a Möbius strip, solving the eikonal equation with the latent variable proximal point algorithm in mixed form.
Mixed Poisson on a branching surface – solve the Poisson equation in mixed form on three sheets meeting along a line, with a Raviart-Thomas space on each sheet, coupled by a Lagrange multiplier on the joint, transferring mesh tags to the submeshes of the sheets.
Time-dependent and nonlinear problems#
Cahn-Hilliard equation – solve the time-dependent, nonlinear Cahn-Hilliard equation with a Newton solver.
Snap-through buckling of a shallow arch – trace the snap-through buckling of a hyperelastic arch past a limit point, using PETSc’s
SNESNEWTONALarc-length continuation 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 block and – see Mixed and hybridised formulations: a block-preconditioned solver, including a Hypre AMS preconditioner for \(H(\mathrm{div})\).
Domain decomposition solvers – solve the Poisson, linearised elasticity and curl-curl equations with BDDC and PCHPDDM domain decomposition preconditioners, using PETSc’s unassembled
MATISmatrix format.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).
Mixed Poisson equation on the sphere – see Problems on manifolds: take a surface from a Gmsh volume mesh, and ghost a cell wherever it shares a vertex by writing a partitioner.
Mixed Poisson on a Möbius strip – see Problems on manifolds: build a non-orientable higher-order surface mesh by hand.
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.