Preface
Preliminaries
The FEniCS Project
What you will learn
Working with this tutorial
Obtaining the software
Installation using Docker containers
Installation using Ubuntu packages
Testing your installation
Obtaining the tutorial examples
Background knowledge
Programming in Python
The finite element method
Fundamentals: Solving the Poisson equation
Mathematical problem formulation
Finite element variational formulation
Abstract finite element variational formulation
Choosing a test problem
FEniCS implementation
The complete program
Running the program
Dissection of the program
The important first line
Generating simple meshes
Defining the finite element function space
Defining the trial and test functions
Defining the boundary and the boundary conditions
Defining the source term
Defining the variational problem
Forming and solving the linear system
Plotting the solution
Exporting and post-processing the solution
Computing the error
Examining degrees of freedom and vertex values
Deflection of a membrane
Scaling the equation
Defining the mesh
Defining the load
Defining the variational problem
Plotting the solution
Making curve plots through the domain
Visualizing the solution in ParaView
Using the built-in visualization tool
Exercise 1: Visualize a solution in a cube
A Gallery of finite element solvers
The heat equation
PDE problem
Variational formulation
FEniCS implementation
Diffusion of a Gaussian function
A nonlinear Poisson equation
PDE problem
Variational formulation
FEniCS implementation
The equations of linear elasticity
PDE problem
Variational formulation
FEniCS implementation
The Navier–Stokes equations
PDE problem
Variational formulation
FEniCS implementation
Exercise 2: Simulate channel flow in a 3D geometry
Flow past a cylinder
A system of advection–diffusion–reaction equations
PDE problem
Variational formulation
FEniCS implementation
Setting initial conditions for mixed systems
Setting boundary conditions for mixed systems
Accessing components of mixed systems
Subdomains and boundary conditions
Combining Dirichlet and Neumann conditions
PDE problem
Variational formulation
FEniCS implementation
Setting multiple Dirichlet conditions
Defining subdomains for different materials
Using expressions to define subdomains
Using mesh functions to define subdomains
Vectorized version of subdomain definitions
Using C++ code snippets to define subdomains
Exercise 3: Efficiency of Python vs C++ expressions
Setting multiple Dirichlet, Neumann, and Robin conditions
Three types of boundary conditions
PDE problem
Variational formulation
FEniCS implementation
Test problem
Debugging boundary conditions
Generating meshes with subdomains
PDE problem
Variational formulation
FEniCS implementation
Extensions: Improving the Poisson solver
Refactoring the Poisson solver
A more general solver function
Writing the solver as a Python module
Verification and unit tests
Parameterizing the number of space dimensions
Exercise 4: Solve a Poisson problem
Exercise 5: Refactor the code for membrane deflection
Working with linear solvers
Controlling the solution process
List of linear solver methods and preconditioners
Linear variational problem and solver objects
Explicit assembly and solve
Examining matrix and vector values
Examining the degrees of freedom
Postprocessing computations
A variable-coefficient Poisson problem
Flux computations
Computing functionals
Computing convergence rates
Taking advantage of structured mesh data
Bibliography