DOLFIN User Manual
August 30, 2007
Hoffman, Jansson, Logg, Wells
www.fenics.org
Visit http://www.fenics.org/ for the latest version of this manual.
Contents
About this manual 11
1 Quickstart 13
1.1 Downloading and installing DOLFIN . . . . . . . . . . . . . . 13
1.2 Solving Poisson’s equation with DOLFIN . . . . . . . . . . . . 14
1.2.1 Setting up the variational formulation . . . . . . . . . . 15
1.2.2 Writing the solver . . . . . . . . . . . . . . . . . . . . . 16
1.2.3 Compiling the program . . . . . . . . . . . . . . . . . . 22
1.2.4 Running the program . . . . . . . . . . . . . . . . . . . 23
1.2.5 Visualizing the solution . . . . . . . . . . . . . . . . . . 23
2 Linear algebra 25
2.1 Matrices and vectors . . . . . . . . . . . . . . . . . . . . . . . 25
2.1.1 Sparse matrices . . . . . . . . . . . . . . . . . . . . . . 27
2.1.2 Dense matrices . . . . . . . . . . . . . . . . . . . . . . 28
3
2.1.3 The common interface . . . . . . . . . . . . . . . . . . 28
2.2 Solving linear systems . . . . . . . . . . . . . . . . . . . . . . 28
2.2.1 Iterative methods . . . . . . . . . . . . . . . . . . . . . 28
2.2.2 Direct methods . . . . . . . . . . . . . . . . . . . . . . 30
2.3 Solving eigenvalue problems . . . . . . . . . . . . . . . . . . . 31
2.4 Linear algebra backends . . . . . . . . . . . . . . . . . . . . . 32
2.4.1 uBlas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.4.2 PETSc . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3 The mesh 35
3.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.1.1 Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.1.2 Mesh entities . . . . . . . . . . . . . . . . . . . . . . . 35
3.2 Mesh iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.3 Mesh functions . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.4 Mesh refinement . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.5 Working with meshes . . . . . . . . . . . . . . . . . . . . . . . 37
3.5.1 Reading a mesh from file . . . . . . . . . . . . . . . . . 37
3.5.2 Extracting a boundary mesh . . . . . . . . . . . . . . . 38
3.5.3 Built-in meshes . . . . . . . . . . . . . . . . . . . . . . 39
3.5.4 Creating meshes . . . . . . . . . . . . . . . . . . . . . . 39
4 Functions 41
4.1 Basic properties . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.1.1 Representation . . . . . . . . . . . . . . . . . . . . . . 42
4.1.2 Assignment . . . . . . . . . . . . . . . . . . . . . . . . 42
4.1.3 Components and subfunctions . . . . . . . . . . . . . . 42
4.1.4 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.2 Discrete functions . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.3 User-defined functions . . . . . . . . . . . . . . . . . . . . . . 44
4.3.1 Cell-dependent functions . . . . . . . . . . . . . . . . . 44
5 Ordinary differential equations 47
6 Partial differential equations 49
7 Nonlinear solver 51
7.1 Nonlinear functions . . . . . . . . . . . . . . . . . . . . . . . . 51
7.2 Newton solver . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.2.1 Linear solver . . . . . . . . . . . . . . . . . . . . . . . 53
7.2.2 Application of Dirichlet boundary conditions . . . . . . 54
7.3 Incremental Newton solver . . . . . . . . . . . . . . . . . . . . 55
8 Input/output 57
8.1 Files and objects . . . . . . . . . . . . . . . . . . . . . . . . . 57