# Automating the Finite Element Method

• Anders Logg
Article

## Abstract

The finite element method can be viewed as a machine that automates the discretization of differential equations, taking as input a variational problem, a finite element and a mesh, and producing as output a system of discrete equations. However, the generality of the framework provided by the finite element method is seldom reflected in implementations (realizations), which are often specialized and can handle only a small set of variational problems and finite elements (but are typically parametrized over the choice of mesh).

This paper reviews ongoing research in the direction of a complete automation of the finite element method. In particular, this work discusses algorithms for the efficient and automatic computation of a system of discrete equations from a given variational problem, finite element and mesh. It is demonstrated that by automatically generating and compiling efficient low-level code, it is possible to parametrize a finite element code over variational problem and finite element in addition to the mesh.

## Keywords

Variational Problem Minimum Span Tree Element Tensor Operation Count Multilinear Form
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

## Abbreviations

A

The differential operator of the model A(u)=f

A

The global tensor with entries {A i }i∈ℐ

A0

The reference tensor with entries $$\{A^{0}_{i\alpha}\}_{i\in\mathcal{I}_{K},\alpha\in\mathcal{A}}$$

$$\bar{A}^{0}$$

The matrix representation of the (flattened) reference tensor A 0

AK

The element tensor with entries $$\{A^{K}_{i}\}_{i\in\mathcal{I}_{K}}$$

a

The semilinear, multilinear or bilinear form

aK

The local contribution to a multilinear form a from K

aK

The vector representation of the (flattened) element tensor A K

$$\mathcal{A}$$

The set of secondary indices

The set of auxiliary indices

e

The error, e=Uu

FK

The mapping from K 0 to K

GK

The geometry tensor with entries $$\{G_{K}^{\alpha}\}_{\alpha\in\mathcal{A}}$$

gK

The vector representation of the (flattened) geometry tensor G K

The set j=1 r [1,N j ] of indices for the global tensor A

K

The set j=1 r [1,n K j ] of indices for the element tensor A K (primary indices)

ιK

The local-to-global mapping from $$\mathcal{N}_{K}$$ to $$\mathcal{N}$$

$$\hat{\iota}_{K}$$

The local-to-global mapping from $$\hat{\mathcal{N}}_{K}$$ to $$\hat{\mathcal{N}}$$

ιKj

The local-to-global mapping from $$\mathcal{N}_{K}^{j}$$ to $$\mathcal{N}^{j}$$

K

A cell in the mesh  $$\mathcal{T}$$

K0

The reference cell

L

The linear form (functional) on $$\hat{V}$$ or $$\hat{V}_{h}$$

m

The number of discrete function spaces used in the definition of a

N

The dimension of $$\hat{V}_{h}$$ and V h

Nj

The dimension V h j

Nq

The number of quadrature points on a cell

n0

The dimension of ℘0

nK

The dimension of ℘ K

$$\hat{n}_{K}$$

The dimension of $$\hat{\mathcal{P}}_{K}$$

nKj

The dimension of ℘ K j

$$\mathcal{N}$$

The set of global nodes on V h

$$\hat{\mathcal{N}}$$

The set of global nodes on $$\hat{V}_{h}$$

$$\mathcal{N}^{j}$$

The set of global nodes on V h j

$$\mathcal{N}_{0}$$

The set of local nodes on ℘0

$$\mathcal{N}_{K}$$

The set of local nodes on ℘ K

$$\hat{\mathcal{N}}_{K}$$

The set of local nodes on $$\hat{\mathcal{P}}_{K}$$

$$\mathcal{N}_{K}^{j}$$

The set of local nodes on ℘ K j

νi0

A node on ℘0

νiK

A node on ℘ K

$$\hat{\nu}^{K}_{i}$$

A node on $$\hat{\mathcal{P}}_{K}$$

νiK,j

A node on ℘ K j

0

The function space on K 0 for V h

$$\hat{\mathcal{P}}_{0}$$

The function space on K 0 for $$\hat{V}_{h}$$

0j

The function space on K 0 for V h j

K

The local function space on K for V h

$$\hat{\mathcal{P}}_{K}$$

The local function space on K for $$\hat{V}_{h}$$

Kj

The local function space on K for V h j

Pq(K)

The space of polynomials of degree ≤q on K

$$\overline{\mathcal{P}}_{K}$$

The local function space on K generated by {℘ K j } j=1 m

R

The residual, R(U)=A(U)−f

r

The arity of the multilinear form a (the rank of A and A K )

U

The discrete approximate solution, Uu

(Ui)

The vector of expansion coefficients for U=∑ i=1 N U i φ i

u

The exact solution of the given model A(u)=f

V

The space of trial functions on Ω (the trial space)

$$\hat{V}$$

The space of test functions on Ω (the test space)

Vh

The space of discrete trial functions on Ω (the discrete trial space)

$$\hat{V}_{h}$$

The space of discrete test functions on Ω (the discrete test space)

Vhj

A discrete function space on Ω

|V|

The dimension of a vector space V

Φi

A basis function in ℘0

$$\hat{\Phi}_{i}$$

A basis function in $$\hat{\mathcal{P}}_{0}$$

Φij

A basis function in ℘ 0 j

φi

A basis function in V h

$$\hat{\phi}_{i}$$

A basis function in $$\hat{V}_{h}$$

φij

A basis function in V h j

φiK

A basis function in ℘ K

$$\hat{\phi}_{i}^{K}$$

A basis function in $$\hat{\mathcal{P}}_{K}$$

φiK,j

A basis function in ℘ K j

φ

The dual solution

$$\mathcal{T}$$

The mesh

Ω

A bounded domain in ℝ d

## References

1. 1.
Arge SE, Bruaset AM, Langtangen HP (eds) (1997) Modern software tools for scientific computing. Birkhäuser, Basel
2. 2.
Arnold DN, Winther R (2002) Mixed finite elements for elasticity. Numer Math 92:401–419
3. 3.
Babuška I (1971) Error bounds for finite element method. Numer Math 16:322–333
4. 4.
Bagheri B, Scott LR (2003) Analysa, URL: http://people.cs.uchicago.edu/~ridg/al/aa.html
5. 5.
Bagheri B, Scott LR (2004) About Analysa. Tech rep TR-2004-09, University of Chicago, Department of Computer Science Google Scholar
6. 6.
Balay S, Eijkhout V, Gropp WD, McInnes LC, Smith BF (1997) Efficient management of parallelism in object oriented numerical software libraries. In: Arge E, Bruaset AM, Langtangen HP (eds) Modern software tools in scientific computing. Birkhäuser, Basel, pp. 163–202 Google Scholar
7. 7.
Balay S, Buschelman K, Eijkhout V, Gropp WD, Kaushik D, Knepley MG, McInnes LC, Smith BF, Zhang H (2004) PETSc users manual. Tech rep ANL-95/11-Revision 2.1.5, Argonne National Laboratory Google Scholar
8. 8.
Balay S, Buschelman K, Gropp WD, Kaushik D, Knepley MG, McInnes LC, Smith BF, Zhang H (2006) PETSc. URL: http://www.mcs.anl.gov/petsc/
9. 9.
Bangerth W (2000) Using modern features of C++ for adaptive finite element methods: dimension-independent programming in deal.II. In: Deville M, Owens R (eds) Proceedings of the 16th IMACS world congress 2000, Lausanne, Switzerland, 2000. Document Sessions/118-1 Google Scholar
10. 10.
Bangerth W, Kanschat G (1999) Concepts for object-oriented finite element software—the deal.II library. Preprint 99-43 (SFB 359), IWR Heidelberg, October Google Scholar
11. 11.
Bangerth W, Hartmann R, Kanschat G (2006) deal.II differential equations analysis library. URL: http://www.dealii.org/
12. 12.
Beazley DM (2006) SWIG: an easy to use tool for integrating scripting languages with C and C++. Presented at the 4th Annual Tcl/Tk Workshop, Monterey, CA, 2006 Google Scholar
13. 13.
Beazley DM et al (2006) Simplified wrapper and interface generator. URL: http://www.swig.org/
14. 14.
Becker EB, Carey GF, Oden JT (1981) Finite elements: an introduction. Prentice-Hall, Englewood Cliffs
15. 15.
Becker R, Rannacher R (2001) An optimal control approach to a posteriori error estimation in finite element methods. Acta Numer 10:1–102
16. 16.
Blackford LS, Demmel J, Dongarra J, Duff I, Hammarling S, Henry G, Heroux M, Kaufman L, Lumsdaine A, Petitet A, Pozo R, Remington K, Whaley RC (2002) An updated set of basic linear algebra subprograms (BLAS). ACM Trans Math Softw 28:135–151
17. 17.
Boffi D (1997) Three-dimensional finite element methods for the Stokes problem. SIAM J Numer Anal 34:664–670
18. 18.
Brenner SC, Scott LR (1994) The mathematical theory of finite element methods. Springer, Berlin
19. 19.
Brezzi F (1974) On the existence, uniqueness and approximation of saddle-point problems arising from Lagrangian multipliers. RAIRO Anal Numér R-2:129–151
20. 20.
Brezzi F, Fortin M (1991) Mixed and hybrid finite element methods. Springer series in computational mathematics, vol 15. Springer, New York
21. 21.
Brezzi F, Douglas J Jr, Marini LD (1985) Two families of mixed finite elements for second order elliptic problems. Numer Math 47:217–235
22. 22.
Bruaset AM, Langtangen HP et al (2006) Diffpack. URL: http://www.diffpack.com/
23. 23.
Castigliano CAP (1879) Théorie de l’équilibre des systèmes élastiques et ses applications. AF Negro, Torino Google Scholar
24. 24.
Ciarlet PG (1976) Numerical analysis of the finite element method. Les Presses de l’Universite de Montreal Google Scholar
25. 25.
Ciarlet PG (1978) The finite element method for elliptic problems. North-Holland, Amsterdam
26. 26.
CIMNE International Center for Numerical Methods in Engineering (2006) GiD. URL: http://gid.cimne.upc.es/
27. 27.
Cormen TH, Leiserson CE, Rivest RL, Stein C (2001) Introduction to algorithms, 2nd edn. MIT Press Google Scholar
28. 28.
Courant R (1943) Variational methods for the solution of problems of equilibrium and vibrations. Bull Am Math Soc 49:1–23
29. 29.
Crouzeix M, Raviart PA (1973) Conforming and nonconforming finite element methods for solving the stationary Stokes equations. RAIRO Anal Numér 7:33–76
30. 30.
Demmel JW (1997) Applied numerical linear algebra. SIAM Google Scholar
31. 31.
Dubiner M (1991) Spectral methods on triangles and other domains. J Sci Comput 6:345–390
32. 32.
Dular P, Geuzaine C (2005) GetD reference manual Google Scholar
33. 33.
Dular P, Geuzaine C (2006) GeD: a general environment for the treatment of discrete problems. URL: http://www.geuz.org/getdp/
34. 34.
Dupont T, Hoffman J, Johnson C, Kirby RC, Larson MG, Logg A, Scott LR (2003) The FEniCS project tech rep 2003-21, Chalmers Finite Element Center Preprint Series Google Scholar
35. 35.
Eaton JW (2006) Octave. URL: http://www.octave.org/
36. 36.
Eriksson K, Johnson C (1991) Adaptive finite element methods for parabolic problems I: a linear model problem. SIAM J Numer Anal 28(1):43–77
37. 37.
Eriksson K, Johnson C (1991) Adaptive finite element methods for parabolic problems II: optimal order error estimates in l l 2 and l l . SIAM J Numer Anal 32:706–740
38. 38.
Eriksson K, Johnson C (1995) Adaptive finite element methods for parabolic problems IV: nonlinear problems. SIAM J Numer Anal 32:1729–1749
39. 39.
Eriksson K, Johnson C (1995) Adaptive finite element methods for parabolic problems V: long-time integration. SIAM J Numer Anal 32:1750–1763
40. 40.
Eriksson K, Johnson C Adaptive finite element methods for parabolic problems III: time steps variable in space, in preparation Google Scholar
41. 41.
Eriksson K, Johnson C, Larsson S (1998) Adaptive finite element methods for parabolic problems VI: analytic semigroups. SIAM J Numer Anal 35:1315–1325
42. 42.
Eriksson K, Estep D, Hansbo P, Johnson C (1995) Introduction to adaptive methods for differential equations. Acta Numer 4:105–158
43. 43.
Eriksson K, Estep D, Hansbo P, Johnson C (1996) Computational differential equations. Cambridge University Press, Cambridge
44. 44.
Eriksson K, Estep D, Johnson C (2003) Applied mathematics: body and soul, vol I. Springer, Berlin Google Scholar
45. 45.
Eriksson K, Estep D, Johnson C (2003) Applied mathematics: body and soul, vol II. Springer, Berlin Google Scholar
46. 46.
Eriksson K, Estep D, Johnson C (2003) Applied mathematics: body and soul, vol III. Springer, Berlin Google Scholar
47. 47.
Eriksson K, Johnson C, Logg A (2003) Explicit time-stepping for stiff ODEs. SIAM J Sci Comput 25:1142–1157
48. 48.
Eriksson K, Johnson C, Hoffman J, Jansson J, Larson MG, Logg A (2006) Body and soul applied mathematics education reform project. URL: http://www.bodysoulmath.org/
49. 49.
Estep D, French D (1994) Global error control for the continuous Galerkin finite element method for ordinary differential equations. M2AN 28:815–852 Google Scholar
50. 50.
Estep D, Larson M, Williams R (2000) Estimating the error of numerical solutions of systems of nonlinear reaction–diffusion equations. Mem Am Math Soc 696:1–109
51. 51.
Free Software Foundation (1991) GNU GPL. URL: http://www.gnu.org/copyleft/gpl.html
52. 52.
Free Software Foundation (1999) GNU LGPL. URL: http://www.gnu.org/copyleft/lesser.html
53. 53.
Free Software Foundation (2006) The free software definition. URL: http://www.gnu.org/philosophy/free-sw.html
54. 54.
Fries T-P, Matthies HG (2004) A review of Petrov–Galerkin stabilization approaches and an extension to meshfree methods. Tech rep Informatikbericht 2004-01, Institute of Scientific Computing, Technical University Braunschweig Google Scholar
55. 55.
Galerkin BG (1915) Series solution of some problems in elastic equilibrium of rods and plates. Vestnik inzhenerov i tekhnikov 19:897–908 Google Scholar
56. 56.
Golub GH, van Loan CF (1996) Matrix computations, 3rd edn. Johns Hopkins University Press Google Scholar
57. 57.
Hecht F, Pironneau O, Hyaric AL, Ohtsuka K (2005) FreeFEM++ manual Google Scholar
58. 58.
Hoffman J, Johnson C (2004) Encyclopedia of computational mechanics, vol 3. Wiley, New York. Chapter 7: computability and adaptivity in CFD Google Scholar
59. 59.
Hoffman J, Johnson C (2006) A new approach to computational turbulence modeling. Comput Methods Appl Mech Eng 195:2865–2880
60. 60.
Hoffman J, Johnson C (2006) Computational turbulent incompressible flow: applied mathematics: body and soul, vol 4. Springer, Berlin Google Scholar
61. 61.
Hoffman J, Logg A (2002) DOLFIN: Dynamic Object oriented Library for FINite element computation. Tech rep 2002-06, Chalmers Finite Element Center Preprint Series Google Scholar
62. 62.
Hoffman J, Logg A (2004) Puffin user manual Google Scholar
63. 63.
Hoffman J, Logg A (2006) Puffin. URL: http://www.fenics.org/puffin/
64. 64.
Hoffman J, Johnson C, Logg A (2004) Dreams of calculus—perspectives on mathematics education. Springer, Berlin
65. 65.
Hoffman J, Jansson J, Johnson C, Knepley MG, Kirby RC, Logg A, Scott LR, Wells GN (2006) FEniCS. http://www.fenics.org/
66. 66.
Hoffman J, Jansson J, Logg A, Wells GN (2006) DOLFIN. http://www.fenics.org/dolfin/
67. 67.
Hoffman J, Jansson J, Logg A, Wells GN (2004) DOLFIN user manual Google Scholar
68. 68.
Hughes TJR (1987) The finite element method: linear static and dynamic finite element analysis. Prentice-Hall, Englewood Cliffs
69. 69.
Hughes TJR, Franca LP, Balestra M (1986) A new finite element formulation for computational fluid dynamics. V. Circumventing the Babuška-Brezzi condition: a stable Petrov-Galerkin formulation of the Stokes problem accommodating equal-order interpolations. Comput Methods Appl Mech Eng 59:85–99
70. 70.
Hulme BL (1972) Discrete Galerkin and related one-step methods for ordinary differential equations. Math Comput 26:881–891
71. 71.
Hulme BL (1972) One-step piecewise polynomial Galerkin methods for initial value problems. Math Comput 26:415–426
72. 72.
International Organization for Standardization (1996) ISO/IEC 14977:1996: information technology—syntactic metalanguage—extended BNF Google Scholar
73. 73.
Jansson J (2006) Ko. URL: http://www.fenics.org/ko/
74. 74.
Jansson J, Johnson C, Logg A (2005) Computational modeling of dynamical systems. Math Models Methods Appl Sci 15:471–481
75. 75.
Jansson J, Logg A, et al (2006) Body and soul computer sessions. URL: http://www.bodysoulmath.org/sessions/
76. 76.
Karpeev DA, Knepley MG (2005) Flexible representation of computational meshes. ACM Trans Math Softw, submitted Google Scholar
77. 77.
Karpeev DA, Knepley MG (2006) Sieve. URL: http://www.fenics.org/sieve/
78. 78.
Kirby RC (2004) FIAT: a new paradigm for computing finite element basis functions. ACM Trans Math Softw 30:502–516
79. 79.
Kirby RC (2006) FIAT. URL: http://www.fenics.org/fiat/
80. 80.
Kirby RC (2006) Optimizing FIAT with the level 3 BLAS. ACM Trans Math Softw 32(2):223–235. http://doi.acm.org/10.1145/1141885.1141889
81. 81.
Kirby RC, Logg A (2006) A compiler for variational forms. ACM Trans Math Softw 32(3):417–444
82. 82.
Kirby RC, Logg A (2007) Efficient compilation of a class of variational forms. ACM Trans Math Softw 33(3), accepted 31 August 2006 Google Scholar
83. 83.
Kirby RC, Knepley MG, Scott LR (2005) Evaluation of the action of finite element operators. BIT, submitted Google Scholar
84. 84.
Kirby RC, Knepley MG, Logg A, Scott LR (2005) Optimizing the evaluation of finite element matrices. SIAM J Sci Comput 27:741–758
85. 85.
Kirby RC, Logg A, Scott LR, Terrel AR (2006) Topological optimization of the evaluation of finite element matrices, SIAM J Sci Comput 28(1):224–240
86. 86.
Kitware (2006) The visualization ToolKit. URL: http://www.vtk.org/
87. 87.
Knepley MG, Smith BF (2006) ANL SIDL environment. URL: http://www-unix.mcs.anl.gov/ase/
88. 88.
Langtangen HP (1999) Computational partial differential equations—numerical methods and diffpack programming. Lecture notes in computational science and engineering. Springer, Berlin
89. 89.
Langtangen HP (2005) Python scripting for computational science, 2nd edn. Springer, Berlin Google Scholar
90. 90.
Logg A (2003) Multi-adaptive Galerkin methods for ODEs I. SIAM J Sci Comput 24:1879–1902
91. 91.
Logg A (2003) Multi-adaptive Galerkin methods for ODEs II: implementation and applications. SIAM J Sci Comput 25:1119–1141
92. 92.
Logg A (2004) Automation of computational mathematical modeling. PhD thesis, Chalmers University of Technology, Sweden Google Scholar
93. 93.
Logg A (2004) Multi-adaptive time-integration. Appl Numer Math 48:339–354
94. 94.
Logg A (2006) FFC. http://www.fenics.org/ffc/
95. 95.
Logg A (2006) FFC user manual Google Scholar
96. 96.
Logg A (2006) Multi-adaptive Galerkin methods for ODEs III: a priori error estimates. SIAM J Numer Anal 43:2624–2646
97. 97.
Long K (2003) Sundance, a rapid prototyping tool for parallel PDE-constrained optimization. In: Large-scale PDE-constrained optimization. Lecture notes in computational science and engineering. Springer, Berlin Google Scholar
98. 98.
Long K (2004) Sundance 2.0 tutorial. Tech rep TR-2004-09, Sandia National Laboratories Google Scholar
99. 99.
Long K (2006) Sundance. URL: http://software.sandia.gov/sundance/
100. 100.
Mackie RI (1992) Object oriented programming of the finite element method. Int J Numer Meth Eng 35 Google Scholar
101. 101.
Masters I, Usmani AS, Cross JT, Lewis RW (1997) Finite element analysis of solidification using object-oriented and parallel techniques. Int J Numer Meth Eng 40:2891–2909
102. 102.
Nédélec J-C (1980) Mixed finite elements in R 3. Numer Math 35:315–341 Google Scholar
103. 103.
Oliphant T et al (2006) Python numeric. URL: http://numeric.scipy.org/
104. 104.
OpenDX (2006) URL: http://www.opendx.org/
105. 105.
Pironneau O, Hecht F, Hyaric AL, Ohtsuka K (2006) FreeFEM. URL: http://www.freefem.org/
106. 106.
Ramachandra P (2006) MayaVi. URL: http://mayavi.sourceforge.net/
107. 107.
Raviart P-A, Thomas JM (1977) A mixed finite element method for 2nd order elliptic problems. In: Mathematical aspects of finite element methods. Proc conf, consiglio naz. delle ricerche (CNR), Rome, 1975. Lecture notes in math, vol 606. Springer, Berlin, pp 292–315 Google Scholar
108. 108.
Rayleigh (1870) On the theory of resonance. Trans Roy Soc A 161:77–118 Google Scholar
109. 109.
Ritz W (1908) Über eine neue Methode zur Lösung gewisser Variationsprobleme der mathematischen Physik. J Reine Angew Math 135:1–61
110. 110.
Saad Y (2003) Iterative methods for sparse linear systems, 2nd edn. SIAM Google Scholar
111. 111.
Samuelsson A, Wiberg N-E (1998) Finite element method basics. Studentlitteratur Google Scholar
112. 112.
Sandia National Laboratories (2006) ParaView. URL: http://www.paraview.org/
113. 113.
Strang G, Fix GJ (1973) An analysis of the finite element method. Prentice-Hall, Englewood Cliffs
114. 114.
Tecplot (2006) URL: http://www.tecplot.com/
115. 115.
The Mathworks (2006) MATLAB. URL: http://www.mathworks.com/products/matlab/
116. 116.
Whaley RC, Dongarra J (1997) Automatically tuned linear algebra software. Tech rep UT-CS-97-366, University of Tennessee, December. URL: http://www.netlib.org/lapack/lawns/lawn131.ps
117. 117.
Whaley RC, Dongarra J, et al (2006) ATLAS. URL: http://math-atlas.sourceforge.net/
118. 118.
Whaley RC, Petitet A, Dongarra JJ (2001) Automated empirical optimization of software and the ATLAS project. Parallel Comput. 27–35. Also available as University of Tennessee LAPACK Working Note #147, UT-CS-00-448, 2000 (www.netlib.org/lapack/lawns/lawn147.ps)
119. 119.
Zienkiewicz OC, Taylor RL, Zhu JZ (2005) The finite element method—its basis and fundamentals, 6th edn. Elsevier, Amsterdam, first published in 1976 Google Scholar