A Gentle Introduction To The Finite Element Method: Francisco-Javier Sayas 2008
A Gentle Introduction To The Finite Element Method: Francisco-Javier Sayas 2008
A Gentle Introduction To The Finite Element Method: Francisco-Javier Sayas 2008
FranciscoJavier Sayas
2008
An introduction
If you havent been hiding under a stone during your studies of engineering, mathemat-
ics or physics, it is very likely that you have already heard about the Finite Element
Method. Maybe you even know some theoretical and practical aspects and have played
a bit with some FEM software package. What you are going to find here is a detailed
and mathematically biased introduction to several aspects of the Finite Element Method.
This is not however a course on the Analysis of the method. It is just a demonstration
of how it works, written as applied mathematicians usually write it. There is going to be
mathematics involved, but not lists of theorems and proofs. We are also going from the
most particular cases towards useful generalizations, from example to theory.
An aspect where this course differs from most of the many introductory books on
finite elements is the fact that I am going to begin directly with the twodimensional
case. Ive just sketched the one dimensional case in an appendix. Many people think that
the onedimensional case is a better way of introducing the method, but I have an inner
feeling that the method losses richness in that very simple situation, so I prefer going
directly to the plane.
The course is divided into five lessons and is thought to be read in that order. We
cover the following subjects (but not in this order):
It is going to be one hundred pages with many figures and many ideas repeated over and
over, so that you can read it with ease. These notes have evolved during the decade I
have been teaching finite elements to mixed audiences of mathematicians, physicists and
engineers. The tone is definitely colloquial. I could just claim that these are my classnotes
1
and thats what Im like1 . Theres much more than that. First, I believe in doing your
best at being entertaining when teaching. At least thats what I try. Behind that there is
a deeper philosophical point: take your work (and your life) seriously but, please, dont
take yourself too seriously.
I also believe that people should be duly introduced when they meet. All this naming
old time mathematicians and scientists only by their last names looks to me too much
like the Army. Or worse, high school!2 I think you have already been properly introduced
to the great Leonhard Euler, David Hilbert, Carl Friedrich Gauss, Pierre Simon Laplace
and George Green. If you havent so far, consider it done here. This is not about history.
Its just good manners. Do you see what I mean by being colloquial?
Anyway, this is not about having fun3 , but since we are at it, let us try to have a good
time while learning. If you take your time to read these notes with care and try the
exercises at the end of each lesson, I can assure that you will have made a significant step
in your scientific persona. Enjoy!
1
To the very common comment every person has his/her ways, the best answer Ive heard is Oh, God,
no! We have good manners for that.
2
In my high school, boys were called by their last names. I was Sayas all over. On the other hand,
girls were called by their first names.
3
Unfortunately too many professional mathematicians advocate fun or beauty as their main motiva-
tions to do their job. It is so much better to have a scientific vocation than this aristocratic detachment
from work...
2
Lesson 1
D
N
Figure 1.1: The domain and the Dirichlet and Neumann boundaries
We are thus given a polygon in the plane R2 . We call this polygon . Its boundary
is a closed polygonal curve . (There is not much difference if we suppose that there is
3
one or more holes inside , in which case the boundary is composed by more than one
polygonal curve).
The boundary of the polygon, . is divided into two parts, that cover the whole of
and do not overlap:
the Dirichlet boundary D ,
4
There are two functions g0 and g1 given on the two different parts of the boundary.
They will play very different roles in our formulation. As a general rule, we will
demand that g0 is a continuous function, whereas g1 will be allowed to be discon-
tinuous.
n u = u n,
where n is the unit normal vector on points of pointing always outwards and u
is, obviously, the gradient of u.
We are not going to bother about regularity issues here. If you see a derivative, admit
that it exists and go on. We will reach a point where everything is correctly formulated.
And that moment we will make hypotheses more precise. If you are a mathematician and
are already getting nervous, calm down and believe that I know what Im talking about.
Being extra rigorous is not what is important at this precise time and place.
5
Remark. This theorem is in fact a simple consequence of the Divergence Theorem:
Z Z Z
(div p) v + p v = (p n) v.
Here div p is the divergence of the vector field p, that is, if p = (p1 , p2 )
p1 p2
div p = + .
x1 x2
If you take p = u you obtain Greens Theorem.
Note that we have parted the integral on as the sum of the integrals over the two sub
boundaries, the Dirichlet and the Neumann boundary. You may be wondering what v is
in this context. In fact, it is nothing but a test. Wait for comments on this as the section
progresses.
Now we substitute what we know in this formula: we know that u = f c u in
and that n u = g1 on N . Therefore, after some reordering
Z Z Z Z Z
u v + c uv = fv+ g1 v + (n u) v.
N D
Note now that Ive written all occurrences of u on the left hand side of the equation except
for one I have left on the right. In fact we dont know the value of n u on that part of
the boundary. So what we will do is imposing that v cancels in that part, that is,
v = 0, on D .
Therefore
Z Z Z Z
u v + c uv = fv+ g1 v, if v = 0 on D .
N
As written now, data (f and g1 ) are in the righthand side and coefficients of the
equation (the only one we have is c) are in the lefthand side.
6
The expression on the lefthand side is linear in both u and v. It is a bilinear form
of the variables u and v. The expression on the righthand side is linear in v.
Without specifying spaces where u and v are, the weak formulation can be written as
follows:
find u such that
u = g0 , on D ,
Z Z Z Z
u v + c uv = fv+ g1 v, for all v, such that v = 0 on D .
N
Note how the two boundary conditions appear in very different places of this formulation:
The Dirichlet condition (given displacements) is imposed apart from the formulation
and involves imposing it homogeneously to the testing function v. It is called an
essential boundary condition.
The Neumann condition (given normal stresses) appears inside the formulation. It
is called a natural boundary condition.
Being essential or natural is not inherently tied to the boundary condition: it is related
to the role of the boundary condition in the formulation. So when you hear (or say)
essential boundary condition, you mean a boundary condition that is imposed apart from
the formulation, whereas a natural boundary condition appears inside the formulation.
For this weak formulation of a second order elliptic equation we have
Dirichlet=essential Neumann=natural
What is v? At this point, you might (you should) be wondering what is v in the
formulation. In the jargon of weak formulations, v is called a test function. It tests the
equation that is satisfied by u. The main idea is that instead of looking at the equation
as something satisfied pointbypoint in the domain , you have an averaged version of
the equation. Then v plays the role of a weight function, something you use to average
the equation. In many contexts (books on mechanics, engineering or physics) v is called a
virtual displacement (or virtual work, or virtual whatever is pertinent), emphasizing the
fact that v is not the unknown of the system, but something that only exists virtually to
write down the problem. The weak formulation is, in that context, a principle of virtual
displacements (principle of virtual work, etc).
7
A fully precise definition of this space requires either the introduction of the Lebesgue
integral or applying some limiting ideas. If you know what this is all about, good for you!
If you dont, go on: for most functions you know you will always be able to check whether
they belong to this space or not by computing or estimating the integral and seeing if it
is finite or not.
The second space is one of the wide family of Sobolev spaces:
n o
u u
H 1 () = u L2 () x ,
1 x2
L2
() .
Sometimes this norm is called the energy norm and functions that have this norm finite
(that is, functions in H 1 ()) are called functions of finite energy. The concept of energy
is however related to the particular problem, so its better to get used to have the space
and its norm clearly written down and think of belonging to this space as a type of
admissibility condition.
A particular subset of this space will be of interest for us:
H1D () = {v H 1 () | v = 0, on D }.
Note that H1D () is a subspace of H 1 (), that is, linear combinations of elements of
H1D () belong to the same space.
Go the whole nine yards and take time to browse a book on distribution theory and
Sobolev spaces. It takes a while but you end up with a pretty good intuition of
what this all is about.
Take the short way. You first consider the space of functions
n o
u u
C 1 () = u C() x ,
1 x2
C() ,
8
which is simple to define, and then you close it with the norm k k1, . To do that
you have to know what closing or completing a space is (its something similar to
what you do to define real numbers from rational numbers). Then you have to prove
that restricting to D still makes sense after this completion procedure.
My recommendation at this point is to simply go on. If you are a mathematician you can
take later on some time with a good simple book on elliptic PDEs and will see that it is
not that complicated. If you are a physicist or an engineer you will probably not need to
understand all the details of this. Theres going to be a very important result in the next
section that you will have to remember and thats almost all. Nevertheless, if you keep on
doing research related to finite elements, you should really know something more about
this. In due time you will have to find any of the dozens of books on Partial Differential
Equations for Scientists and Engineers, and read the details, which will however not be
given in the excruciating detail of PDE books for mathematicians. But this is only an
opinion.
Let me recall that the condition on the general test function v H1D () is the same as
that is, v is in the same space as the unknown u but satisfies a homogeneous version of
the essential boundary condition.
The data are in the following spaces
f L2 (), g1 L2 (N ), g0 H 1/2 (D ).
We have already spoken of the first of these spaces. The space L2 (N ) is essentially the
same idea, with line integrals on N instead of domain integrals on . The last space
looks more mysterious: it is simply the space of restrictions to D of functions of H 1 (),
that is, g0 H 1/2 (D ) means that there exists at least a function u0 H 1 () such that
u0 = g0 on D . In fact, all other functions satisfying this condition (in particular our
solution u) belong to
(can you see why?). Unlike H1D (), this set is not a subspace of H 1 (). The only
exception is the trivial case, when g0 = 0, since the set becomes H1D ().
9
That g0 belongs to H 1/2 (D ) means simply that we are not looking for the solution on
the empty set. I cannot give you here a simple and convincing explanation on the name
of this space. Sorry for that.
p(x1 , x2 ) = a0 + a1 x1 + a2 x2 .
The set of these functions is denoted P1 . Everybody knows that a linear function is
uniquely determined by its values on three different nonaligned points, that is, on the
vertices of a (nondegenerate) triangle.
Let us then take an arbitrary nondegenerate triangle, that we call K. You might
prefer calling the triangle T , as many people do. However, later on (in Lesson 3) the
triangle will stop being a triangle and will become something else, maybe a quadrilateral,
and then the meaning of the initial T will be lost. We draw it as in Figure 1.2, marking
its three vertices. With this we mean that a function
p P1 = {a0 + a1 x1 + a2 x2 | a0 , a1 , a2 R}
is uniquely determined by its values on these points. Uniquely determined means two
things: (a) there is only one function with given values on the vertices; (b) there is in fact
one function, that is, the values on the vertices are arbitrary. We can take any values we
want and will have an element of P1 with these values on the vertices. Graphically it is
just hanging a flat (linear) function from three nonaligned points.
Thus, a function p P1 can be determined
10
3
K
2
2.2 Triangulations
So far we have functions on a single triangle. Now we go for partitions of the domain into
triangles. A triangulation of is a subdivision of this domain into triangles. Triangles
must cover all but no more and must fulfill the following rule:
If two triangles have some intersection, it is either on common vertex or a
common full edge. In particular, two different triangles do not overlap.
Figure 1.3 shows two forbidden configurations. See Figure 1.5 to see how a triangulation
looks like. There is another rule, related to the partition of into D and N :
The triangulation must respect the partition of the boundary into Dirichlet and
Neumann boundaries.
This means that an edge of a triangle that lies on cannot be part Dirichlet and part
Neumann. Therefore if there is a transition from Dirichlet to Neumann boundaries, there
must be a vertex of a triangle in that transition point. Note that this situation has to be
taken into account only when there is a transition from Dirichlet to Neumann conditions
inside a side of the polygon .
The set of the triangles (that is, the list thereof) will be generally denoted Th . The
subindex h makes reference to the diameter of the triangulation, defined as the length
of the longest edge of all triangles, that is, the longest distance between vertices of the
triangulation.
11
Figure 1.3: Situations not admitted in triangulations. In the second one we see the
appearance of what is called a hanging node.
If we fix values on the set of vertices of the triangulation Th , there exists a unique uh Vh
with those values on the vertices. Therefore an element of Vh is uniquely determined by
its values on the set of vertices of the triangulation. The values on the vertices of the
whole triangulation are the degrees of freedom that determine an element of Vh . In this
context we will call nodes to the vertices in their role as points where we take values.
(Note that in forthcoming lessons there will be other nodes in addition to vertices).
Elements of the space Vh are called linear finite element functions or simply P1 finite
elements.
Let us take now a numbering of the set of nodes (that is, vertices) of the triangulation.
At this moment any numbering goes2 . In Figure 1.7 we have a numbering of the nodes of
the triangulation of our model domain. The vertices will be generically denoted pi with
i varying from one to the number of vertices, which we call N .
2
And in many instances this will be so to the end of the discretization process. Using one numbering
or another has a great influence on the shape of the linear section we will obtain in Section 3, but this
shape is relevant only for some choices of the method to solve the corresponding linear system
12
N
Because of what we have explained above, if we fix one node (vertex) and associate
the value one to this node and zero to all others, there exists a unique function i Vh
that has these values, that is,
1, j = i,
i (pj ) = ij =
0, j 6= i.
The aspect of one of these functions is shown in Figure 1.8.
Notice that if a triangle K has not pi as one of its vertices, i vanishes all over K,
since the value of i on the three vertices of K is zero. Therefore, the support of i (the
closure of the set of points where i is not zero) is the same as the union of triangles that
share pi as vertex. In Figure 1.9 you can see the type of supports you can find.
There is even more. Take uh Vh . It is simple to see that
N
X
uh = uh (pj )j .
j=1
PN
Why? Let me explain. Take the function j=1 uh (pj )j and evaluate it in pi : you obtain
N
X N
X
uh (pj )j (pi ) = uh (pj )ji = uh (pi ).
j=1 j=1
Therefore, this function has exactly the same nodal values as uh and must be uh . The
fact that two functions of Vh with the same nodal values are the same function is the
linear independence of the nodal functions {i }. What we have proved is the fact that
{i | i = 1, . . . , N } is a basis of Vh and therefore
dim Vh = N = #{vertices}.
13
Figure 1.5: A triangulation of
x2
K K
x1
is a general element of Vh . With this basis, the coefficients are precisely the values of uh
on the nodes, that is, uj = uh (pj ). Hence, the coefficients of uh in this basis are something
more than coefficients: there are values of the function on points.
An important result. As you can see, when defining the space Vh we have just glued
together P1 functions on triangles. Thanks to the way we have made the triangulation
and to the way we chose the local degrees of freedom, what we obtained was a continuous
function. One can think, is this so important? Could I take something discontinuous? At
this level, the answer is a very load and clear NO! The reason is the following result that
allows us to know whether certain functions are in H 1 () or not.
14
14
10
5
15
6 11
2
16
12 18
3 7
8 17
4
13
Figure 1.8: The graph of a nodal basis function: it looks like a camping tent.
There is certain intuition to be had on why this result is true. If you take a derivative of a
piecewise smooth function, you obtain Dirac distributions along the lines where there are
discontinuities. Dirac distributions are not functions and it does not make sense to see if
the are squareintegrable or not. Therefore, if there are discontinuities, the function fails
to have a squareintegrable gradient.
15
Figure 1.9: Supports of two nodal basis functions
Figure 1.10: Dirichlet nodes corresponding to the domain as depicted in Figure 1.1
In truth, in parallel to what happens with how the Dirichlet and Neumann boundary
conditions are treated in the weak formulation, we will inherit two different discrete
entities:
Neumann edges.
H1D () = {v H 1 () | v = 0 on D }.
16
Recall now the demand we did on the triangulation to respect the partition of into
Dirichlet and Neumann parts. Because of this, vh Vh vanishes on D if and only if it
vanishes on the Dirichlet edges. Again, since values of piecewise linear functions on edges
are determined by the values on the corresponding vertices, we have
The good news is the fact that we can easily construct a basis of VhD . We simply eliminate
the elements of the nodal basis corresponding to Dirichlet nodes. To see that recall that
when we write vh Vh as a linear combination of elements of the nodal basis, what we
have is actually
X N
vh = vh (pj )j .
j=1
17
3 The finite element method
3.1 The discrete variational problem
After almost fifteen pages of introducing things we can finally arrive to a numerical ap-
proximation of our initial problem. Recall that we wrote the problem in the following
form
find u H 1 (), such that
u = g0 , on D ,
Z Z Z Z
u v + c uv = fv+ g1 v, v H1D ().
N
The finite element method (with linear finite elements on triangles) consists of the follow-
ing discrete version of the preceding weak formulation:
find uh Vh , such that
uh (p) = g0 (p), for all Dirichlet node p,
Z Z Z Z
uh vh + c uh vh = f vh + g1 vh , vh VhD .
N
4
This way of substituting the Dirichlet condition by a sort of interpolated Dirichlet condition is neither
the only nor the best way of doing this approximation, but it is definitely the simplest, so we will keep
it like this for the time being.
18
Our next claim is the following: the discrete equations
Z Z Z Z
uh vh + c uh vh = f vh + g1 vh , vh VhD
N
Obviously this second group of equations is a (small) part of the original one: it is enough
to take vh = i VhD . However, because of the linearity of the first expression in vh , if
we have the second for all i , we have the equation for all possible linear combinations of
these functions, that is for all vh VhD . Recapitulating, the method is equivalent to this
set of N equations to determine the function uh :
find uh Vh , such that
uh (pj ) = g0 (pj ), j Dir,
Z Z Z Z
uh i + c uh i = f i + g1 i , i Ind.
N
To arrive to a linear system, we have first to write uh in terms of the nodal basis functions
X X
uh = uj j + uj j .
jInd jDir
and move to the righthand side what we already know (the Dirichlet data)
X Z Z Z Z
j i + c j j u j = f i + g1 i
jInd N
X Z Z
j i + c j j g0 (pj ).
jDir
This is a linear system with as many equations as unknowns, namely with #Ind =
dim VhD equations and unknowns. The unknowns are in fact the nodal values of uh
on the free (nonDirichlet) vertices of the triangulation. After solving this linear system,
the formula for uh lets us recover the function everywhere, not only on nodes.
19
Remark Unlike the finite difference method, the finite element method gives as a result
a function defined on the whole domain and not a set of point values. Reconstruction
of the function from computed quantities is in the essence of the method and cannot be
counted as a posprocessing of nodal values.
Both matrices are defined for i, j = 1, . . . , N (although parts of these matrices wont
be used). Both matrices are symmetric. The mass matrix M is positive definite. The
stiffness matrix is positive semidefinite and in fact almost positive definite: if we eliminate
take any index i and erase the ith row and the ith column of W, the resulting matrix
is positive definite.
The system can be easily written in terms of these matrices, using the vector
Z Z
bi = f i + g1 i , i Ind,
N
to obtain
X X
Wij + c Mij uj = bi Wij + c Mij g0 (pj ), i Ind.
jInd jDir
Note that this is clearly a square symmetric system. If c = 0 (then the original equation
is the Poisson equation u = f and no reaction term appears), only the stiffness matrix
appears. Therefore, stiffness comes from diffusion. Likewise mass proceeds from reaction.
The matrix is positive definite except in one special situation: when c = 0 and there
are no Dirichlet conditions (i.e., D = , i.e., Ind = {1, . . . , N } and VhD = Vh ). For the
pure Neumann problem for the Laplace operator there are some minor solvability issues
similar to the occurrence of rigid motions in mechanical problems. Let us ignore this
minor complication for now.
Now look again at the figure showing the supports of nodal basis functions (we copy
it right here for convenience) and look at the mass matrix
Z
Mij = j i .
If the supports of i and j have no intersecting area, the integral defining Mij vanishes.
In fact, since the product of i and j is a nonnegative function, Mij = 0 if and only
20
Figure 1.11: Supports of two nodal basis functions
if the area of the intersection of the supports is zero5 . This happens whenever pi and pj
are not vertices of the same triangle.
We say that two nodes are adjacent if they belong to the same triangle.
In the case of the stiffness matrix we have a similar (maybe weaker result): if the nodes
i and j are not adjacent, then Wij = 0.
This fact makes that the mass and stiffness matrices display a great sparsity character.
Given a row i, there are only nonzero entries on positions related to adjacent nodes to
the ith node.
Going back to the system
X X
Wij + c Mij uj = bi Wij + c Mij g0 (pj ), i Ind,
jInd jDir
As it is now, all data appear in the righthand side of the system (Neumann data
and source terms are in the vector b, Dirichlet data appear multipying columns of
the stiffnessplusmass matrix).
5
By definition the support of a function includes the boundary of the set where the function is non
zero. Therefore, it is possible that the intersection is one edge. The integral is still zero.
21
4 Exercises
E1.1. third type of boundary condition
Let us consider our usual polygon and the boundary value problem
"
u + u = f, in ,
n u + k u = g, on .
Here k is a positive parameter. This type of boundary condition is usually called a
boundary condition of the third kind (first being Dirichlet and second Neumann) or a
Robin (or Fourier) boundary condition.
1. Write down the weak formulation for this problem. Note that the condition is nat-
ural and there will not be essential boundary condition in the resulting formulation.
2. Write down in detail (as in Sections 3.2/ 3.3) the linear system that has to be solved
when we apply the finite element method to this problem. Check that there is a new
matrix that can be seen as a boundarymass matrix. How many nonzero entries
has each row of this new matrix?
If we take very small and the following slightly modified version of the boundary con-
dition
n u + u = g0 , on
(take k = 1 and g = 1 g0 ), we are enforcing the Dirichlet condition in an approximate
way. This is done in some commercial packages.
9
4
8
3
7
2
1 6 11
22
1. Write the index sets Dir and Ind.
that is, m(i) indicates the column number where the first nonzero entry of the ith
row is. Compute the profile of W + M (without eliminating Dirichlet rows and
columns). Draw the form of the matrix using the profile.
6. In the preceding graph mark which rows and columns will be modified by introduc-
tion of Dirichlet conditions. Compute the profile of the reduced matrix (without
Dirichlet rows and columns).
23
Lesson 2
1 Assembly
The first lesson left us with a linear system to solve in order to approximate the boundary
value problem with the finite element method. There is however the trick question on
how to compute all the integrals that appear in the matrix and righthand side of the
system. This is done by a clever process called assembly of the system, another of the
many good deeds of the finite element method that has made it so extremely popular (as
in popular among scientists and engineers, of course) in the last decades.
At this moment we need the polygonal domain and:
a triangulation Th ,
a numbering of the nodes {pi } (nodes are the vertices of the triangles),
16
3 7
12 18
8 17
4
13
24
1.1 The mass and stiffness matrices
We are going to center our attention in the efficient construction of the stiffness matrix
Z
wij = j i
On each triangle we are going to define three local nodal basis functions. First assign
a number to each of the three vertices of a triangle K:
pK
1 , pK
2 , pK
3 .
that satisfy
NK (pK
) = , , = 1, 2, 3.
It is simple to see that the nodal basis function i restricted to the triangle K is either
zero (this happens when pi is not one of the three vertices of K) or one of the NK
functions. More precisely, let n be the global number of the local node with number
in the triangle K. This means that
NK = n , on the triangle K.
This is due to be simple, since the functions NK are polynomials of degree one (unlike
the functions i that are only piecewise polynomials). We will show later on strategies to
do this computation. Note at this moment that computation of this matrix depends only
on the triangle K and does not take into account any other element of the triangulation.
Therefore
K K
k = wn n
All other elements of the matrix WK are zero. Recall again that WK is a nNon nNod
matrix and that X
W= WK .
K
25
14
10
5
19
17
20 15
16 6 18 11
2
21
15 16
4 22
12 14 18
5 7 7
1 3
13 23
6 8
1
2 3
11 12
8 17
4 9 10
13
K
2
local global
1 1 12
2 16
3 11
The assembly process requires then a given numbering of triangles as shown in Figure
2.2. The order of this numbering is only used to do the computations but does not modify
the shape of the final result.
The process to assemble the mass matrix is the same. Effective assembly of the mass
and stiffness matrices can be done at the same time. Instead of computing separately the
matrix KK and a similar one for the mass matrix, we can directly try to compute the
3 3 matrix with elements
Z Z
K K
N N + c NK NK , , = 1, 2, 3.
K K
26
1.2 The reference element
To compute the elements
Z Z
NK NK and NK NK
K K
we need: (a) either and effective way of evaluating the functions NK and their gradients;
(b) or a closed form for the resulting integrals. Both possibilities are done usually by
moving to the socalled reference element.
For triangles, the reference element is the triangle with vertices
b 1 = (0, 0),
p b 2 = (1, 0),
p b 3 = (0, 1).
p
To distinguish variables in the reference element and in a general triangle (in this context
^K
1 2
An unimportant detail. Some people prefer to use a different reference triangle, with
the same shape but with vertices on (1, 1), (1, 1) and (1, 1). Some details of the
forthcoming computations have to be adapted if this choice is taken.
The local nodal functions in the reference triangles are three P1 functions satisfying
b (b
N p ) = , , = 1, 2, 3.
or, if you prefer hatting variables (this is the last time we will write both expressions)
b1 = 1 x
N b yb, b2 = x
N b, b3 = yb
N
27
Let us now take the three vertices of a triangle K
pK
1 = (x1 , y1 ), pK
2 = (x2 , y2 ), pK
3 = (x3 , y3 ).
p ) = pK
FK (b , = 1, 2, 3.
Notice that the second expression we have written for the transformation gives it in terms
of the nodal basis functions in the reference domain. You can think of it as a coincidence.
In a way it is: the coincidence stems from the fact that the type of functions we are using
for finite elements is the same as the functions needed to transform linearly triangles in
the plane.
It is simple now to prove that
b = N K FK ,
N = 1, 2, 3,
The symbol is used for composition. In the last expression, what we have is
b (F 1 (x, y)).
NK (x, y) = N K
Since computing FK1 is straightforward from the explicit expression for FK , this formula
gives a simple way of evaluating the functions NK .
To evaluate the gradient of NK we have to be more careful, since we have to apply
the chain rule. Let us denote briefly gradients as
x b
= , =
y
(note that we are writing gradients as column vectors). The following formula is the result
of applying the chain rule
B> b
K FK = ( FK ).
B> K
K is the transposed of the matrix of the linear transformation FK . Taking = N in
this expression and moving things a little, we obtain a formula for the gradient of the
local basis functions
K
N = B > bN
( b ) F 1
.
K K
28
The expression may look complicated but it is very simple to use. If we want to compute
the value of the gradient of NK at a point (x, y) K, we first compute the transformed
b at this point
point (, ) = FK1 (x, y) in the reference triangle, evaluate the gradient of N
and then multiply it by the matrix B> K , which is the transposed of the inverse of BK ,
i.e.,
> 1 y3 y1 (y2 y1 )
BK =
det BK (x2 x1 ) x2 x1
with
det BK = (x2 x1 )(y3 y1 ) (y2 y1 )(x3 x1 )
(remember that | det BK | = 2 area K). In fact, for this very elementary method, the
gradients of the three basis functions on the reference element are constant vectors
bNb1 = 1 bNb2 = 1 bNb3 = 0 ,
, ,
1 0 1
so computation of the constant vectors NK is very simple, and we dont even have to
use the inverse transformation FK1 for the gradients. We do, however, to evaluate NK .
where mK are the midpoints of the edges of K. If is a polynomial of degree one, the
first formula gives the exact value. The second formula is even better: if is a polynomial
of degree two, the midpoints formula is exact.
In the very simple case of P1 elements, we have NK constant and therefore
Z
NK NK = (area K) NK NK ,
K
and this computation is very simple. For the mass matrix, we note that NK NK is a
polynomial of degree two and therefore, the midpoints formula gives the exact value of
the integrals Z
NK NK
K
with just three evaluations of the functions.
29
1.4 Doing everything on the reference element
This section gives another idea on how to compute the local mass and stiffness matrices.
You can skip it without losing continuity and go to Section 1.5. The change of variables
applied to the integral of the local mass matrix gives
Z Z
K K
N N = | det BK | b N
N b .
K b
K
where
cK K
11 c12
CK = B1 >
K BK =
cK K
12 c22
is a symmetric 22 matrix that depends only on the triangle. If we compute the following
3 3 matrices in the reference element
Z 1 1 0
b =
K b N
N b = 21 1 1 0
b
K , 0 0 0
Z 1 0 1
b =
K b N
N b = 21 0 0 0
b
K , 1 0 1
Z 1 0 1
b =
K N b
b N = 21 1 0 1
b
K , 0 0 0
we have
Z
NK NK = | det BK | cK b cK b cK b b >
11 K + 22 K + 12 (K + K ) .
K ,
30
1.5 Righthand sides
Construction of the righthand side of the linear system requires the computation of two
vectors: Z Z
f i , g1 i .
N
In principle, this has to be done for indices of free nodes (i Ind), but in practice what is
done is to compute them for all i and then discard the elements corresponding to Dirichlet
nodes.
The surface forces (sources terms) can be treated in a similar way to the stiffness and
mass matrices: Z XZ
f i = f i .
K K
and then add these elements in the positions (n1 , n2 , n3 ) of the full vector. This process
can be done at the same time as the matrix assembly, since it goes triangle by triangle.
For the P1 element, the following extremely simple approximation is enough:
Z 3
X Z 3 Z
| det BK | X b
f NK 1
3
f (pK
) NK = f (pK
) N
K =1 K 3 =1
b
K
3
| det BK | X
= f (pK
).
18 =1
Note that three integrals related to the element K are approximated by the same number.
What we have done is approximating f by a function that is constant over each triangle:
the constant value on the triangle is the average of the values on its vertices. Otherwise,
we can try a quadrature rule to approximate the integrals. It is important at this stage
to note that the choice of an adequate quadrature rule has to take into account two facts:
it has to be precise enough not to lose the good properties of the finite element
method, but
it has to be simple enough not to be wasting efforts in computing with high precision
a quantity that is only needed with some precision.
In principle, we could think of using a very precise rule to compute the integrals as exactly
as possible. This is overdoing it and forgetting one of the most important principles of
wellunderstood scientific computing: errors from different sources have to be balanced.
It doesnt make much sense to spend time in computing exactly a quantity when that
number is to be used in the middle of many approximate computations.
31
The presence of Neumann boundary conditions imposes the computation of the fol-
lowing integrals Z
g1 i .
N
This process is made separately to the ones of computing domain integrals for the matrices
and the source terms. First of all we have to decompose the Neumann boundary in the
set of edges that lie on it (for that we will need a numbering of the Neumann edges):
Z XZ
g1 i = g1 i .
N L L
Note first that unless pi is on the Neumann boundary, this integral vanishes.
Next, for each edge consider the two vertices that delimit it: pL1 and pL2 . As we had
with triangular elements, we will need the relation between the extremal points of each
Neumann edge and the global numbering. If
the function
x1 x2
[0, 1] 3 t 7 L (t) = (1 t) +t
y1 y2
is a parameterization of the segment L. We now consider the following two functions
1 = 1 t, 2 = t.
They are just the nodal basis functions on the reference element [0, 1] for the space of
linear polynomials in one dimension. It is simple to see that
1 (t), if pi = pL1 ,
(i L )(t) = 2 (t), if pi = pL2 ,
0, otherwise.
(as before n denotes the global index for the local node ). We can the use numerical
quadrature for this line integral. Alternatively we can approximate
Z Z
L L
length L
1
g1 n 2 g1 (p1 ) + g1 (p2 ) i = g1 (pL1 ) + g1 (pL2 ) , = 1, 2.
L L 4
32
1
2
L
1
local global
1 5
2 10
Figure 2.6: The 2nd Neumann edges and its numberings. For this edge, n1 = 5 and
n2 = 10.
33
Finally there is a linear operator that serves us to describe the essential conditions: for
us u is the value of u on the boundary D . Notice that
V0 = {v V | v = 0}.
Only when g0 = 0 (or when theres no D and the whole boundary is a Neumann bound-
ary), the problem reduces to an even simpler one
"
find u V0 such that
a(u, v) = `(v), v V0 .
Therefore, when the essential condition is homogeneous (or when there is no essential
condition), the set where we look for u and the test space are the same. In other cases,
the restriction imposed to the tests v is the homogeneous version of the essential condition.
2.2 Wellposedness
Let us recall that the natural norm in our space V = H 1 () was
Z Z 1/2
2 2
kuk = kuk1, = |u| + |u| .
There are several conditions that ensure the wellposedness of the problem
find u V , such that
u = g0 ,
a(u, v) = `(v), v V0 ,
Wellposedness means existence and uniqueness of solution and continuity of the solu-
tion with respect to the data.
Let us first list the properties that are satisfied in all the situations we are addressing
in this course:
34
V is a Hilbert space (a vector space, with an inner product so that the space is
complete with respect to the associate norm)1 ,
V0 is a closed subspace of V ,
the bilinear form a is continuous in V , that is, there exists M > 0 such that
|a(u, v)| M kuk kvk, u, v V,
As already mentioned, all of these properties are satisfied in our case. In fact
Z Z
2 2
C` |f | + C |g1 |2 .
N
There is a last property, called ellipticity, which reads: there exists > 0 such that
a(v, v) kvk2 , v V0 .
Note that the property is only demanded on the set V0 . In our case it is not satisfied in
all situations. In fact, it is satisfied in all but one case:
if c > 0 the property is satisfied with depending only on c,
if c = 0 and length D > 0, the property is satisfied with depending on and on
the partition of the boundary in Dirichlet and Neumann parts.
If all the properties mentioned above hold, then the problem
"
find u V0 such that
a(u, v) = `(v), v V0 ,
has a unique solution and
kuk C` /.
If g0 6= 0 then the problem
find u V , such that
u = g0 ,
a(u, v) = `(v), v V0
has a unique solution if there exists a u0 V such that u0 = g0 . In that case, the
continuity of the solution with respect to the data has a more complicated expression
n o
kuk C` / + (M/ + 1) inf ku0 k u0 = g, .
1
Maybe this sentence looks too hard. You should know what a vector space and also what an inner
(or scalar) product is. When you have an inner product, you have an associated norm and with it a
concept of convergence of sequences of elements of V . Completeness is a property that ensures that all
Cauchy sequences have a limit. In essence, it means that convergence has to happen inside the space.
We cannot have a sequence of elements of V converging to something that is not in V .
35
Remark. For the pure Neumann problem with c = 0
"
u = f, in ,
n u = g1 , on ,
we cannot verify the conditions to prove existence and uniqueness. In fact existence and
uniqueness is not completely guaranteed. First of all, because of the divergence theorem
we must have Z Z Z
u = div(u) = n u
and therefore the data have to satisfy the compatibility condition
Z Z
f + g1 = 0.
If this condition is satisfied, there is more that one solution, since constant functions
satisfy the homogeneous equation
"
u = 0, in ,
n u = 0, on .
Vh0 V0
The P1 finite element method for the reactiondiffusion problem with homogeneous Dirich-
let conditions is therefore an example of Galerkin method2 .
The Galerkin equations are equivalent to a linear system. Let us do here the detailed
argument, although you will see that we already did exactly this in Section 3 of the
previous lesson.
2
Galerkin comes from Boris Galerkin. A good pronunciation of the word would be something more
like Galyorkin, with emphasis on the lyor syllable. Most English speakers pronounce it however as if it
was an English word
36
First we need a basis of Vh0 : {i | i Ind}. The index set Ind is now anything
you want to number the finite basis of the set. In general we would number form one
to the dimension of the space, but in our model problem the numbering proceeds from
eliminating some indices from a wider numbering. Then we notice that the abstract set
of equations
a(uh , vh ) = `(vh ), vh Vh0
is equivalent to
a(uh , i ) = `(i ), i Ind.
Finally, we decompose X
uh = uj j
jInd
There are as many unknowns as there are equations here. Note that in the general case,
the values uj are not nodal values, since an arbitrary basis of a linear space has nothing
to do with nodes or evaluations of functions.
If the hypotheses of Section 2.2 hold, this system has a unique solution. Furthermore
we have the following result, which is popularly referred to as Ceas Lemma3 :
M n o
0
ku uh k inf ku vh k vh Vh .
The result might not seem to say much at first sight. There are however some aspects
that have to be remarked here:
The result gives an upper bound of the error between the exact solution u and
the approximate solution uh (the finite element solution) and this error bound is
measured in the energy norm and not in any other one.
The term n o
0
inf ku vh k vh Vh
is just an approximation error, completely unrelated to the original problem. It
measures how well the (unknown) exact solution can be approximated by elements
of the space where we are looking for the solution. Because of how this term is
estimated in particular situations (in FEM, for instance) many people call this
an interpolation error. We will see a bit of this on the following section. This
approximation error is measured also in the energy norm, of course.
The only other constants in the inequality depend on the problem, but not on data.
Note however that complicated solutions (solutions that vary a lot, or that have
large gradients, or anything you can think of as difficult to grasp with a simple
3
Cea, as in Jean Cea. French. Do you best with the pronunciation of the name.
37
approximation) will not necessarily be approximated as well as simple smooth solu-
tions. Since we do not know the solution (by definition, it is the unknown), how can
we have an idea of this error? The answer is the lifetime work of numerical analysts
and people who do scientific computation. Just three ideas:
for simple smooth solutions, numerical analysis shows usually how error be-
haves quite precisely, which gives us a hint of the best possible behavior of our
method;
PDE theory sometimes helps in understanding where things can go wrong and
we can do some effort in concentrating approximation in that area;
finally, there is a whole new (new as in only twenty years old or so) branch
of computational knowledge related to error estimation and adaptivity, allow-
ing you to improve your computations with information you harvest from the
already performed computations.
The theoretical frame for the case with nonhomogeneous Dirichlet conditions is somewhat
more delicate, because we have to go someplace more abstract to write correctly the
approximation of the condition
u = g0 , on D
by
uh (p) = g0 (p), p Dirichlet node,
without making any use of the particularities of the finite element space P1 . This can be
done in several ways, and we are not going to detail them. Particularized to FEM the
result will look like this
M n o
ku uh k (1 + ) inf ku vh k vh Vh , vh (p) = g0 (p), p Dirichlet node .
Note that the approximation error in the righthand side includes the imposition of the
discrete essential boundary condition.
38
interpolation in Vh , that is, interpolation with continuous piecewise linear functions. Be-
cause of the Dirichlet boundary condition u vanishes on Dirichlet nodes, and so does
consequently h u. Therefore h u Vh0 and we can use the bound
M
ku uh k1, ku h uk1, .
We have therefore bounded the error of the finite element method by the error of interpola-
tion of the exact solution in the finite element space. A nice thing about this interpolation
process is the fact that it is done trianglebytriangle, so actually, the global error for
interpolation is the sum of the errors that we have done elementbyelement.
In basic courses on numerical methods you will have seen that it is possible to estimate
the error of interpolation without knowing the solution, but that this bound of the error
is proportional to some quantity depending on a high order derivative of the function
that is interpolated. You will have seen this in one space dimension. In several space
dimensions, it is a bit more difficult but not so much. The result is the following: there
exists a constant C that depends on the minimum angle of the triangulation such that
Z 1/2
2 2 2
ku h uk1, Ch |xx u| + |xy u| + |yy u| ,
where h is the size of the longest edge of the triangulation. The expression on the right
hand side is an example of a Sobolev seminorm. It is denoted usually as
Z 1/2
|u|2, = |xx u|2 + |xy u|2 + |yy u|2 .
3 Quadratic elements
Its very low order makes the P1 method not very attractive. Just to expect having an
additional digit in precision you should have edges ten times shorter, which amounts to
4
Inradius is the geometric term for the radius of the inscribed circumference.
39
increasing dramatically the number of unknowns. Instead, it is often recommended to use
a higher order method, which is exactly what we are going to do right now.
The following result is easy to prove: a function in P2 is uniquely determined by its values
on the six nodes of the triangle. Take now two points p1 and p2 . The function
[0, 1] 3 t 7 (1 t) p1 + t p2
parameterizes linearly the segment between these two points. If p P2 , then a simple
computation shows that
n o
p((1 t)p1 + t p2 ) P2 (t) = b0 + b1 t + b2 t2 b0 , b1 , b2 R ,
that is, seen on any segment (on any straight line actually) an element of P2 is a parabolic
function, which, as everyone knows, is determined by three different points. Therefore
the value of a function in P2 on an edge of the triangle is uniquely determined by its three
values on the nodes that lie on that edge (two vertices and one midpoint).
Because of this last property, we can glue together two P2 triangles as we did in the
P1 case. Take a triangulation in the usual conditions, fix values of a function in all the
nodes (vertices and midpoints) and on each triangle construct the only function in P2
40
that matches the given values. The resulting function is continuous. In fact it is a general
element of the space
n o
Vh = uh C() uh |K P2 , K Th .
All the arguments exposed in Lesson 1 hold also here. The dimension of this space is
For the same reasons as in the P1 case, these functions constitute a basis of Vh and any
function of this space can be expressed as
N
X
uh = uh (pj )j .
j=1
those associated to vertices, whose support is the set of triangles surrounding the
vertex,
those associated to midpoints, whose support is the set of two triangles (only one if
the edge is on the boundary) that share the edge.
Take the usual triangulation and make yourself some drawing of the form of the supports
of the nodal basis functions.
The concept of a Dirichlet node is the same: it is any node on a Dirichlet edge,
Dirichlet edges being edges on the Dirichlet boundary D . The following result is then a
straightforward consequence of the fact that value on edges is determined by degrees of
freedom on edges:
by simply ignoring nodal basis functions i associated to Dirichlet nodes. Can you notice
that I am copypasting formulas from Lesson 1?
41
Very important. The whole of Section 3 in Lesson 1 can be read with these adapted
concepts. Theres nothing new at all, but the different concepts of local spaces and nodes.
You should have a detailed look again at that section to convince yourself that this is so.
In particular pay attention to mass and stiffness matrices and note that the number of
adjacent nodes for each node is increased with respect to P1 triangles (we will explore this
in an exercise).
4
5
^K
1 6 2
b4 = 4,
N b5 = 4(1 ),
N b6 = 4(1 )
N
takes the unit value on the corresponding node (the one numbered with the subindex)
and vanishes in all other five nodes.
Lets do again some copypasting. The functions
b F 1 ,
NK = N = 1, . . . , 6
K
42
where n is the global index corresponding to the local node in K. Here is again the
formula for the gradient
K
N = B > bN
( b ) F 1
.
K K
Note that now bNb is not constant, so the inverse transformation F 1 is needed also to
K
evaluate the gradient.
We then compute the local matrices, which are 6 6 matrices,
Z Z
K K
N N and NK NK
K K
and add the contributions of all triangles to assemble the full stiffness and mass matrices.
3.3 Convergence
The general error bound
M n o
ku uh k1, (1 + ) inf ku vh k1, vh Vh , vh (p) = g0 (p), p Dirichlet node .
still holds here. In the case of homogeneous Dirichlet conditions, we can use the same
arguments as in the preceding section to obtain a full bound like
ku uh k1, Ch2 |u|3, ,
where:
the constant C depends on the PDE operator, on the geometry and on the smallest
angle (becoming worse as the triangles become flatter)
the new Sobolev seminorm |u|3, uses the third order partial derivatives of u.
The result is valid only when this last seminorm is finite, which is much more to require
than what we had at the beginning. Note that the order two in energy norm (H 1 ()
norm) is good news, since using smaller triangles really pays off and the gain of precision
is due to be much faster than in the P1 case. In the final exercise of this section we will
explore whats the price to be paid (theres no free lunch, you know).
43
Figure 2.9: The P3 triangle
two points per side, at relative distances 1/3 and 2/3 from the vertices,
the barycenter, which is computed by averaging the coordinates of the three vertices
1 K
v
3 1
+ 13 v2K + 13 v3K .
Note also that each edge has four nodes on it. The local space is that of polynomials of
degree up to three P3 . Instead of writing a general element of this space, let us list the
monomials that are used:
1
x y
x2 xy y2
x3 x2 y xy 2 y 3
Count them. Ten monomials (i.e., ten coefficients) and ten nodes. Well, thats a surprise!
Two other surprises:
a function in P3 is uniquely determined by its values on the ten nodes of the triangle,
Note that a P3 function restricted to a segment (straight line) is a cubic function of one
variable.
We are almost done here. We can construct the spaces Vh , the nodal basis functions
i , the subspace VhD by eliminating Dirichlet nodes, etc. The dimension of Vh is
44
4.2 Static condensation
There is however a new entity here, and thats the very isolated interior node. I say
isolated since that node is only adjacent to the other nodes of the same triangle. This has
some consequences at the practical level that we are going to explore right now.
Let i be the nodal basis function associated to a node that is the barycenter of the
triangle K. Then supp i = K. Therefore
Z Z
a(j , i ) = j i + c j i , j,
K K
and Z
`(i ) = f i
K
(do you see why there is no Neumann term here?) which means that once we have gone
through the element K in the assembly process we will have done the ith row of the
system, with no contributions from other elements. The idea of static condensation is
simple: get rid of that equation and unknown in the same process of assembly.
Let us consider that the 0th node is the barycenter of K. Let KK and bK be the
local matrix and righthand side contributions from the triangle K
Z Z Z
K K K K K K
k = N N + c N N , b = f NK , , = 0, . . . , 9.
K K K
Now we decompose the matrix and the vector into blocks, separating the contribution
from the interior node from all others:
" K # " K #
K00 KK 01 b0
, ,
KK K
10 K11 bK
1
with K
KK
00 =
K
k0,0 , KK
01 =
K
k0,1 . . . k0,9 , bK
0 = bK
0
K
K K
k1,0 k1,1 . . . k1,9 bK
1
.. .. .
. ..
KK
10 = . , K
K11 = . . , bK
1 = . .
K K K K
k9,0 k9,1 . . . k9,9 b9
You will be wondering why are we calling matrices to blocks 1 1 (scalars) and 1 9
or 9 1 (row or column vectors). The reason is twofold: first, the role these scalars and
vectors are playing are the ones of blocks in a matrix so wed better use block notation,
independent of their shape; second, we will thus be able to recycle all that comes right
now for more complicated situations.
The (ten) equations related to the nodes of the element K are
KK K K K K
00 u0 + K01 u1 = b0 ,
KK K K K K
10 u0 + (K11 + A)u1 + Buother = b1 + b.
The unknowns are separated in the same blocks (1 and 9) and are denoted with local
numbering, that is uK K
0 is the unknown associate to the barycenter of K and u1 is the
column vector of the nine unknowns associated to all the other nodes on K.
45
The matrix A includes all contributions from other elements to nodes of K. It will
be added in the assembly process when we go through these elements.
The block B includes all contributions from other triangles to other unknowns
(generically written as uother ), that is, unknowns on nodes that are not on K but
are adjacent to those on K.
Finally, b includes all contributions from other triangles and possibly also from
Neumann edges, to the righthand side.
Now we can write uK
0 (which, in this case, is just the unknown corresponding to the
barycenter of K) as
K 1 K K 1 K K
uK
0 = K00 b0 K00 K01 u1
and substitute this expression in the block of the remaining equations for the triangle K
(the noninterior unknowns), obtaining
K 1 K K 1 K
KK11 K K
10 K 00 K 01 + A uK K K
1 + Buother = b1 K10 K00 b0 + b
This means that instead of assembling the full (10 10) block from K and its correspond-
ing righthand side, we can forget about the interior nodes (just one) on condition of
assembling
K 1 K K 1 K
KK K
11 K10 K00 K01 , bK K
1 K10 K00 b0
instead of the original matrix. Once we have solved the system, the interior variables are
solved using the local equations
KK K K K K
00 u0 + K01 u1 = b0 ,
Remark. This is a method for implementing the P3 FEM in a way that the information
of the interior nodes is incorporated to the assembly process directly without having to
use the corresponding unknown. This doesnt mean that the node is not there. We only
compute it separately after having added its contribution to assembly directly. So dont
confuse this, which is nothing else than an implementation trick, with some finite elements
(in the class of the socalled exotic elements) that avoid interior nodes.
Maybe Ive left you wondering about that strange Algebra in the assembly process
and it somehow rings a bell. It should. Write the extended matrix
" K #
K00 KK 01 b0
K
KK K K
10 K11 b1
and apply Gaussian block elimination (the KK00 block is just 1 1, so this is just Gauss
elimination) you obtain
" K #
K00 KK 01 bK0
K 1 K K 1 K .
0 KK 11 KK
10 K 00 K 01 b K
1 K K
10 K00 b0
46
Da, daaaa! There they are. The blocks you wanted. Again, our diagonal block was a
scalar, so this was easy. What would have happened if it was a matrix? Do you have to
compute that inverse and apply all that Algebra? No, you dont. Gauss block elimination
is a nice way of writing the result of Gauss elimination. The point is you apply row
elimination to create all those zeros, with no row changes and without trying to create
any other zeros. Blocks of the form
K 1 K
KK K
11 K10 K00 K01
are called Schur complements. If the original matrix is symmetric and positive definite,
they are still symmetric and positive definite.
(can you guess whats in |u|4, ?). These best possible conditions include the fact that
triangles do not become too flat, since the constant C becomes worse and worse as triangles
get flatter and flatter. Note that if you apply static condensation to the P3 you complicate
the assembly process but you end up with a system of order
#{vertices} + 2 #{edges}
(minus the number of Dirichlet nodes), which is smaller than the one you obtain without
condensation. There is an additional advantage of applying condensation. With the usual
information of a grid generator (you will have to read the Appendix for that) you can
easily construct a coherent numbering including vertices and edges, which works for P2
elements. Going from P2 to P3 means that you have to double the number of unknowns
per edge (which is easy) and add the triangles. The numbering of triangles becomes then
relevant. It is not, I insist, for the assembly process. If you apply static condensation,
you avoid the unknowns related to barycenter and the numbering of verticesandedges
is enough for the P3 element.
The P4 element is constructed easily following these lines:
You divide each edge into five equally sized pieces. Then you join these new points
on different sides with lines that run parallel to the edges. With that you have
created a grid of 15 nodes: three vertices, three points per edge, three interior
points, placed on the intersections of the interior lines.
The three interior nodes can be treated with static condensation: the KK 00 blocks
are now 3 3 blocks. With this you reduce in three times the number of triangles
the size of the global system to be solved without affecting convergence.
47
Order of the method is.... four! (That was easy)
It is possible to create Pk methods for arbitrary k. You will find people around that will
assert that these methods are useless or just of theoretical interest. Be warned: maybe
they find them useless, but some other people work with really high order methods and
find many advantages in them5 . However, if you go from P4 upwards, you implement the
method in a very different way. Nodal bases are not the best choice in that case and
there is a different way of constructing nodefree bases. For that you will have to go to
specialized literature or take my Advanced Finite Element course: its the first lesson of
that course actually.
5 Exercises
E2.1. Basis function for the P2 element
Try to sketch the form of the nodal basis functions for a P2 finite element space (similar
as Figure 1.8). Note that there are two different types of functions, those associated to
vertices and those associated to midpoints of edges.
u1 = gx , u2 = gy , on D ,
Z Z Z
u1 u2 v u
1 u2 v
( + 2) + + + = v fx + v tx , v H1D (),
Z x y x y x y Z Z N
u1 u2 v u1 u2 v
+ + + ( + 2) = v fy + v ty , v H1D (),
y x x x y y N
where:
is the plane section of the cylindrical solid
48
H1D () = {v H 1 () | v|D = 0}.
We are given a triangulation Th , the associated P1 nodal basis functions (i ), etc. We
call Ind and Dir to the usual index sets. We approximate the pair (u1 , u2 ) by the discrete
functions X X
u1h = u1j j , u2h = u2j j
j j
Alternating tests with the two variational equations, and grouping both unknowns on the
same node (u1j , u2j ) prove that the resulting finite element system can be written in the
form 1 1
X uj X gj
Aij 2 = F i + Ti Aij , i Ind .
uj gj2
jInd jDir
where Aij are 2 2 matrices. Whats the dimension of the system? Prove that A>
ij = Aji
and deduce that the system is symmetric.
Foreword. For reasons that are not so easy to explain as many people think, P1 elements
are never used in elasticity problems because their performance is rather bad. Note that
in what you have done here P1 or Pk is all the same, so you can be applying this to P2
elements, which work well for this problem.
1. If you consider the Neumann problem there (no Dirichlet nodes), how many un-
knowns are there in the system corresponding to the P2 method?
2. What are the adjacent nodes to the node that is marked on the figure?
3. A red refinement of a triangle consists of taking the midpoints of the edges and
joining them to create four triangles per triangle (see Figure 2.11). If you apply a
red refinement to all the elements of the triangulation above and the apply the P1
element, how many unknowns do you have in the system? Which nodes are adjacent
to the same marked nodes in this new triangulation for the P1 method?
49
4. Discussion. The error of the P2 method is bounded by something times h2 . The
error of the P1 method on the uniform red refinement is something else times h/2.
The constant (the unspecified something) for each case is different. In principle,
when the triangulation is fine enough h2 wins over h/2 (it is smaller). With the same
number of unknowns one method is better than the other. Wheres the difference?
50
Lesson 3
We are going to introduce here finite elements on rectangles and parallelograms. These
elements share many features with finite elements on triangles, but there are plenty of
novelties. To learn about finite elements on arbitrary quadrilaterals (trapezes and trape-
zoids) you will have to wait to Lesson 4. They constitute a different species and have to
be studied later on to grasp their difficulties.
51
1.1 The reference space
First of all we need a new polynomial space, which we are going to introduce in reference
variables, n o
Q1 = a0 + a1 + a2 + a3 a0 , a1 , a2 , a3 R .
These are polynomials on two variables that are of degree at most one in each variable
b is going to be the
separately. Note that this space contains P1 . The reference square K
one with vertices on
b 1 = (1, 1),
p b 2 = (1, 1),
p b 3 = (1, 1),
p b 4 = (1, 1),
p
that is K b = [1, 1] [1, 1]. Note that many books prefer to take the unit square
[0, 1] [0, 1] as reference element. Some details change if this choice is made1 . This is not
so important. Note that Ive chosen to number the vertices in rotating order. Whether
we do this in this way (rotating clockwise or counterclockwise is immaterial) or in a
different way is relevant and we have to be very careful with this. Unlike what happens
with triangles, here we really have to know what points are vertices of each edge and we
need to fix an order to say that.
^
p4 ^
p 3
^ ^
p1 p2
52
b Q1 such that
As usual, we can construct functions N
b (b
N p ) = , , = 1, . . . , 4.
b3 = 1 (1 + )(1 + ),
N b4 = 1 (1 )(1 + ).
N
4 4
The nice joint formula 14 (1 )(1 ) for the whole set justifies the choice of this reference
square over [0, 1] [0, 1].
pK
= (x , y ), = 1, . . . , 4.
b into K. For instance, this one does the
Consider now a linear map that transforms K
job: " # " # " # " #
x 1 x1 1 x2 1 x4
= ( + ) + (1 + ) + (1 + ) .
y 2 y1 2 y2 2 y4
p1
p4
y K
^ FK p2
p ^
4 p
3
p3
^
K x
^ ^
p1 p
2
Figure 3.3: The reference square K b is mapped to the physical domain K. Note that
vertices are notated in rotating order, even if the sense is different.
b1, p
If we had taken before the reference triangle with vertices on p b 2 and p
b 4 , the P1
basis functions we would had found would have been
21 ( + ), 1
2
(1 + ), 1
2
(1 + ).
53
What we are doing is mapping this triangle into the triangle with vertices p1 , p2 and p4 .
b 3 is mapped automatically to p3 , because K is a parallelogram and
The additional point p
linear transformations preserve parallelism. Lets not worry about the explicit formula
b K and write simply
for the transformation. Well call it FK : K
" # " #
x
= BK + bK .
y
Q1 (K) = {q : K R | q FK Q1 }
q FK1 | qb Q1 }.
= {b
Note that the space is defined by transforming the space Q1 on the reference element
to the physical element K. In a way, that happened also with the Pk , only with the
simplicity that in that case
Pk (K) = Pk
and the space in physical and reference variables was the same.
Before giving properties of Q1 (K) (we need things like local degrees of freedom, the
possibility of gluing together different elements, et cetera), lets have a look at the func-
tions in this space. A function in Q1 is of the form
qb = a0 + a1 + a2 + a3 .
The reference variables can be written in terms of the physical variables by inverting the
transformation FK . We obtain something of the form:
" # " #" # " # " #
a b x e ax + by + e
= + =
c d y f cx + dy + f
qb FK1 = a0 + a1 (a x + b y + e) + a2 (c x + d y + f ) + a3 (a x + b y + e)(c x + d y + f )
= b0 + b1 x + b2 y + a3 (a c x2 + b d y 2 + (a d + b c) x y),
which means that functions in Q1 (K) have a linear part plus a term of degree two that
depends on the element K (see how the coefficients of FK1 are there). Actually, it looks
like the space depends on the transformation chosen to map K from K, b but thats not
so. The following list of facts is of easy verification:
The space Q1 (K) depends only on K, not on the concrete transformation FK we
have chosen. This is an important property, that means that we have not to worry
about the way in which we ordered the vertices of the parallelogram K. We only
need a list in rotating order and nothing else.
If K is a rectangle with sides parallel to the cartesian axes (and in fact, only in this
case), the space Q1 (K) is simply Q1 .
54
In all cases
P1 Q1 (K) P2 ,
so Q1 (K) contains all polynomials of degree at most one and is a space of polyno-
mials of degree at most four. The first part of this property is what will give order
of convergence to the finite element method using this space.
b F 1 ,
NK = N = 1, . . . , 4
K
NK (pK
) = , , = 1, . . . , 4.
From the last two bullet points of this list we easily recover the needed properties to
construct finite element spaces. First
and
You might have noticed that the second property looks longer than usual. It has to be
like that. What we assert there is not only that the function on an edge (side) depends
only on the values on the two vertices that lie on that edge, but also that the type of
function itself does not depend on where are the other two vertices. Restricted to one of
the sides we always have a linear function.
two different elements can meet only on a common vertex or a full edge of both,
and
55
the partition has to respect the division of the boundary in Dirichlet and Neumann
parts.
Recall that the last property is used only when there is a transition point from D to N
somewhere inside a side of . The properties are exactly the same as those demanded to
triangulations. In fact, there is a tradition to calling simply elements to the constitutive
figures (triangles or parallelograms) and triangulation to the partition, even if it is a
parallelogramization (thats an ugly word!), a tradition we are going to honor.
If we now fix values on the nodes (and now nodes are vertices of the elements again),
we can construct a unique function on each K such that it belongs to the local space
Q1 (K) and matches the values on the vertices. Because of the second local property, the
functions on the edges do not depend really on the particular space Q1 (K) (i.e., on the
shape of the element). They are always linear and fixed by the values on the corresponding
two vertices. Therefore, what we obtain is a globally continuous function, an element of
n o
Vh = uh C() uh |K Q1 (K), K Th .
We have done this enough times so that you already now what would come here if we just
bothered to rewrite all the details:
is the same as the space of elements of Vh that are zero on Dirichlet nodes.
Then we number nodes and define the nodal basis functions, to obtain a basis of
Vh with functions that have small support (four elements at most in a triangulation
like the one of Figure 3.4, although there could be more with some special displays
of parallelograms). Ignoring functions related to Dirichlet nodes we obtain a basis
of VhD .
56
In the assembly process we notice that, restricted to an element K, a nodal basis
function i is either the zero function or one of the four NK . Computing local 4 4
matrices and assembling them in the usual fashion, we can construct effectively the
matrix of the system. The same thing applies to the righthand side. Whenever we
want to evaluate NK or its gradient, we have the usual formulas. Note that in this
case, the gradients are not constant.
Are we there yet? Almost. We were forgetting about the order. The process is the
same one. For the homogeneous Dirichlet problem we obtain
ku uh k1, Ch|u|2, .
The constant depends on the domain (as well as on the division of into Dirichlet
and Neumann parts) and also on a parameter that measures the maximum flatness of
elements.
Unlike in the case of triangles, flatness of elements is not given by extreme acuteness
of angles, but can happen with elongated rectangles. Now, the measurement of flatness
has to be the ratio between the maximum distance between points of an element and the
radius of the largest circumference we can inscribe in K. This measurement of flatness
is also valid for triangles and is the one that is given usually in textbooks. As a general
rule, in this type of error analysis, elements cannot become too flat.
You will notice that, at least in theory, performance of P1 and Q1 elements seems to be
very similar. Linear elements on triangles can be adapted to more complicated geometries
and make assembly a bit simpler. In some cases (in particular in many important test
cases in mechanics) using rectangles as elements reflects better the inherent geometrical
features of the problem and is to be advised. In a forthcoming exercise we will observe
that Q1 elements are just a bit stiffer (more rigid) than P1 elements.
57
Figure 3.5: A triangulation made of triangles and rectangles.
division in rectangles, but the connecting piece seems to demand the use of triangles, so
we decide to use both.
An element of this new type of triangulation can be either a triangle or a parallelogram.
The triangulation has to fulfill the usual requirements: intersections can only happen in
common vertices or common edges and DirichletNeumann partition of the boundary has
to be respected. The local space will depend on the type of element:
"
P1 , if K is a triangle,
P(K) =
Q1 (K), if K is a parallelogram.
and
Seen on edges, all these discrete functions are linear, so we can glue triangles with paral-
lelograms of any shape, as we were able to glue different parallelograms together.
Other than this, life goes on as usual. In the process of assembly is where we use
whether an element is a parallelogram or a rectangle: the reference domain is different
depending on which and local matrices have different sizes (3 3 for triangles, 4 4 for
parallelograms). This looks more complicated but you have to think in terms of the grid
generator. If it gives you triangles and rectangles, either they are given in a different list
(and you assemble first ones and the the other) or it gives you information about the
58
x2
K
L
x1 K
type of geometry of each element, which you obviously learn by only looking at the list
of vertices of the element.
What about error? Lets stick again to the case of homogeneous Dirichlet condition.
Ceas lemma still applies
M n o
ku uh k inf ku vh k vh Vh0
and the righthand side is an approximation error which can be bounded locally, element
by element. Hence, the error of the method can be bounded by the error of approximating
with linear functions on triangles and with Q1 (K) functions on parallelograms. In both
cases, we have an htype error. Order one.
1, , , 2, , 2, 2 , 2 , 22.
There is nine of them. (We will need nine nodes in the reference domain). Looking
carefully youll see that Q2 is the space of polynomials in the variables and that have
degree at most two in each variable separately. It includes therefore all polynomials of
degree two but goes up to polynomials of degree four.
59
Theres a nice table that will simplify your life in remembering these spaces. It serves
to compare P2 (the order two space for triangles) with Q2 (the order two space for squares)
2 2 2 2 2
2
1 2 1 2
(You will have to recognize that thats clever). We now consider nine points (nodes) on
the reference square:
the four vertices,
Figure 3.7: The Q2 reference element on the left. A parallelogram with the Q2 (K) nodes
marked on the right.
q FK1 | qb Q2 },
Q2 (K) = {q : K R | q FK Q2 } = {b
60
Q2 (K) = Q2 when K is a rectangle in the horizontalvertical direction, but in
general
P2 Q2 (K) P4 ,
b {N
we can construct nine nodal basis functions on K, b | = 1, . . . , 9} and transform
them to
NK = Nb F 1
K
the two nodal properties that hold on the reference square still hold on K; in
particular, restriction of an element of Q1 (K) to one of the four sides is a polynomial
of degree at most two, and is independent on the shape of K.
From here on, everything is just a copy of the Q1 case: global spaces, global nodal
basis functions, restriction of those to elements giving the local nodal functions, Dirichlet
nodes, etc. Note that the interior node is just that: interior. Therefore you can apply
static condensation to this node. In Pk we had to wait to k = 3 to obtain an interior
node.
The fact that the polynomial degree increases is something you cannot take too lightly.
For instance, when computing the local mass matrices
Z
NK NK ,
K
61
(b) reduces to nothing. When there are transitions inside a face, these transitions have to
be along straight lines or polygonal lines. Otherwise, the method introduces another kind
of error, as the discrete geometry is not able to describe precisely the exact geometry.
This is similar to what happens in curved boundaries, a problem that we will explore
briefly in the following lesson.
An element of
n o
P1 = a0 + a1 x + a2 y + a3 z a0 , a1 , a2 , a3 R
With this in hand we can do our business as usual. Nothing is really changed by going
to the three dimensional case. The reference element is usually taken as the tetrahedron
with vertices on (0, 0, 0), (1, 0, 0), (0, 1, 0) and (0, 0, 1). Fortunately, the order of the local
numbering of vertices is irrelevant, since all permutations give valid numberings.
The price to pay for this simplicity is the fact that tetrahedra are much more strange
animals than they look at first sight. In particular it is not that simple to fathom how to
divide a given tetrahedron into pieces that are not too deformed. Look at what happens
(Figure 3.10) when you cut the four corners of a regular tetrahedron. Inside you obtain a
regular octahedron that can be easily divided into two pyramids with square basis, each
of which can be divided into two similar tetrahedra. The resulting interior four tetrahedra
are not regular anymore. There are more ways of doing this kind of things. My point
here is that tetrahedra are easy but not so easy.
Local dimension of the space is four. When you glue the corresponding P1 elements to
create a finite element space the full dimension is the number of vertices. Dirichlet nodes
are defined as usual (nodes on the Dirichlet boundary, or vertices of faces that are on the
Dirichlet boundary). Order is one.
62
Figure 3.9: The reference tetrahedron, as seen from behind (sort of). The reference
variables are , and (some authors prefer z for the third one)
Figure 3.10: When you cut the four corners of a regular tetrahedron you end up with a
regular octahedron
It is not difficult to define Pk elements on the tetrahedron for any k. Note that the
local dimensions of the Pk spaces (as well as the number of necessary nodes) increase
now much faster than in the two dimensional cases, because there are many more new
monomials. The space Pk uses all monomials of the form
xi1 y i2 z i3 , i1 , i2 , i3 0, i1 + i2 + i3 k.
For instance
dim P2 = 9, dim P3 = 19.
Theres a formula for this but we will not give it here.
It is simple to give the nodes in the reference domain. For the Pk element, they are
just the points with coordinates
i1 i2 i3
, ,
k k k
, i1 , i2 , i3 0, i1 + i2 + i3 k.
We have to wait to k = 4 to obtain an interior node that we can condense statically.
63
3.2 Elements on parallelepipeds
The Qk (K) elements are very naturally defined on parallelepipeds. The reference element
is the cube [1, 1] [1, 1] [1, 1] or also [0, 1] [0, 1] [0, 1], depending on personal
preferences. The reference space Qk is the one of all linear combinations of monomials
i1 i2 i3 , 0 i1 , i2 , i3 k
and has therefore dimension (k + 1)3 . Nodes are easily found by subdividing uniformly
the cube into equally sized smaller cubes. Interior nodes appear already with k = 2. The
local spaces on parallelepipeds (the image of a cube under a linear transformation) are
the new spaces Qk (K) defined as usual.
One has to be extra careful here in giving always vertices in a coherent order, so that
we dont try to map the figure incorrectly from the reference element. That is the price
to pay for the geometrical simplicity. The increase of the polynomial degree is also a
nonminor issue: for Q1 (K) elements we have polynomials of degree three!
4 Exercises
E3.1. Comparison of P1 and Q1
Consider a square domain and two triangulations of it as the ones given in Figure
3.11. In the first triangulation we consider a P1 method for the usual equation, only with
Neumann conditions. In the second partition we consider a Q1 method.
Check that we have the same number of unknowns in both cases. Draw the form of
the massplusstiffness matrices in both cases. Check that the Q1 has in principle more
nonzero elements, since there are pairs of adjacent nodes that are not in the triangular
mesh.
64
E3.4. Elements on prisms
The reference prism with triangular basis can be taken for instance as the set of points
(, , ) with
0 , , + 1, 0 1.
In the two plane variables it works like a triangle. In the vertical variables it works like a
parallelogram. Propose a correct polynomial space in this reference configuration so that
the six vertices are valid nodes for a finite element using prisms.
65
Lesson 4
In this lesson we are going to have a fast look at several different questions related to how
the Finite Element Method is used (or adapted) in different situations. The section on
eigenvalues is of particular importance, since we will be using it for the stability analysis
of evolution problems.
1 Isoparametric elements
So far we have only dealt with polygonal domains. You will agree that in many instances
boundaries are due to be curved, so we will have to take into account that fact.
First of all when creating a triangulation, you are substituting your real curved domain
by a polygonal approximation. Your grid generator is going to take care of the following
detail: all boundary nodes of the triangulation have to be placed on the real boundary. This
means in particular that if you need smaller triangles, you cannot obtain them by simply
subdividing your existing grid and you definitely have to call back your grid generator to
give you new vertices that are on the boundary.
You might think, well thats it then, isnt it? You have your triangles and you apply
your triangular finite element scheme. The answer is yes if you are going to apply the P1
method.
Note for a moment that functions on H 1 () are defined on and functions of Vh on
the approximated polygon. Therefore the discrete space Vh is not a subspace of H 1 ().
However, an error analysis is still possible. What this error shows is that the error
produced by the geometry approximation beats the error of the method if we try to do P2
elements or higher, so it doesnt pay off to use high order elements if the approximation
to the boundary is so rough.
66
Let us see how to mend this for the P2 approximation. Note that this is not a purely
theoretical question and that part of what we are going to learn here will be used to define
finite elements on general quadrilaterals.
P4
^ P3 P2
P3
K
^
P4
^
K
P1
^
P ^
1 P 2
Figure 4.2: The reference triangle and a deformation of the image triangle
67
It sends the chosen points in the reference domain to the ones in the physical space
p ) = pK
FK (b , = 1, . . . , 4.
If = 0, then
FK (0, t) = FK0 (0, t).
This means that the image of the vertical edge in reference coordinates is the segment
joining pK K
1 and p3 , covered at constant velocity, as if we were using the linear
transformation. The same thing happens to the horizontal side of K. b
If pK K K
b 2 and
4 is aligned with p2 and p3 , then the image of the edge that joins p
K K
b 3 is the segment that joins p2 and p3 . However, this segment is parameterized
p
at constant velocity only when pK K K
4 is the midpoint of p2 and p3 (in that case
x = y = 0 and we have only the linear term in the transformation FK ).
The Jacobian matrix of FK is not constant:
" # " #
x2 x1 + 4x x3 x1 + 4y
BK = DF (, ) = B0K + 4 x y =
y2 y1 + 4x y3 y1 + 4y
When pK K K
4 is not too far from the midpoint of p2 and p3 , that is, when the deviation
b under this transforma-
(x , y ) is not too large, it is possible to prove that the image of K
tion K = FK (K) b is mapped bijectively from the reference element and therefore we can
construct an inverse to
b K.
FK : K
We do not have an explicit expression of how elements of P2 (K) are, but we know that
b
if N are the six nodal basis functions of the P2 reference element, then the functions
b F 1
NK = N K
68
P4
P3 P2
P5
P6
P1
The first property allows us to use the six nodes as local degrees of freedom. The second
one allows as to glue P2 (K) on curved triangles with P2 elements on straight triangles,
since the values on the straight sides are just polynomials.
If K is a usual straight triangle and we take pK
4 to be the midpoint of the corresponding
edge, then FK is a linear map and P2 (K) = P2 .
Let us then begin with an approximate triangulation of a curved domain following the
rules:
Intersection of two different triangles can only happen in a common vertex or edge.
There must be a vertex placed on each transition point from Dirichlet to Neumann
boundaries.
69
Triangles with an edge on the of the approximating polygon can have only one edge
on this boundary and both vertices have to be on the exact boundary .
Look again at Figure 4.1 to see what we mean. Not only we want boundary triangles to
hang from the real boundary, but we want to avoid a triangle to have two edges on the
boundary1 .
The second part of the triangulation process consists of choosing a point on the exact
boundary for each boundary edge. This point should be close to the midpoint of the
straight edge that approximates the real curved boundary. We use this new point to
construct an isoparametric triangle with the same vertices for each boundary triangle.
When we write the equations of the finite element method using these local spaces,
we must have in mind that the union of all triangles (curved on the boundary, straight
otherwise) is not the original domain , but an approximation of it, which we will call
h . We will still call Dirichlet nodes to nodes on the Dirichlet boundary, remarking
that these nodes are in the correct boundary , so we will be able to read data on them
when needed. The full finite element space is
n o
Vh = uh C() uh |K P2 (K), K Th ,
Note that functions of VhD are not really zero on the Dirichlet boundary D but on the
curved approximation of that boundary, an approximation hanging from the vertices of
the initial triangulation and from the additional point per edge that was used to create
the isoparametric elements. It will not come out as a surprise, since the process of gluing
spaces is the same as what we did with P2 elements, that the dimension of Vh is the number
of nodes (that is the number of vertices plus the number of edges) and the dimension of
VhD is the number of nonDirichlet edges. A nodal basis can be constructed as usual.
The restriction to elements of nodal basis functions will be again the local basis functions,
themselves defined as the transformed local nodal functions on the reference element.
1
Many grid generators, even for polygonal domains, avoid putting two edges of the same triangle on
the boundary. There is a simple reason for that: if two edges of a triangle are in a homogeneous Dirichlet
boundary and we are using P1 elements, the function vanishes in the whole triangle, which is a poor
result.
70
The discrete bilinear form is ah : Vh Vh R
Z Z
ah (uh , vh ) = uh vh + uh vh ,
h h
Note that the bilinear form poses no problem whatsoever. The fact that we are working
on the approximate domain is sort of invisible to the assembly process: we will go element
by element transforming from the reference configuration and after having added all terms
we will have computed an integral over h instead of . More on this at the end of this
section.
The issue of the data functions is a little more delicate. When we want to compute
Z Z
f i or, in fact, f NK
K K
for one of the curved domains K it is perfectly possible that the source function is not
defined in parts of K. Look at Figure 4.5 and see how there is a small piece of the discrete
geometry that lies outside the domain. Several theoretically sound possibilities can be
proposed to mend this. In practice, and since you are due to use quadrature formulas for
this integrals, just avoid using quadrature points in those areas.
The situation for the Neumann conditions (given normal derivative) is even more
complicated and I have been deliberately vague in writing
Z
g i
h
N
without specifying what I mean by hN . The fact is g1 is defined in the exact Neumann
boundary and i in its approximation, so the integral is just a way of speaking. Assembly
of this term will be done edgebyedge. For each edge integral we could just try to use
a quadrature formula that evaluates only on the three common points between the exact
and the discrete geometry or think of something more clever. Lets not do this right now.
I just wanted you to see that complications arise very easily.
Even when computing the local integrals
Z Z
K K
N N NK NK
K K
71
for K isoparametric we still have to be careful. Let us begin with the easy one, the mass
matrix. We have a formula for the local basis functions
b F 1 .
NK = N K
If we want to evaluate NK in a point of K, say (x, y), we need to compute FK1 (x, y).
This is the same as solving the nonlinear system
x = (x2 x1 ) + (x3 x1 ) + x1 + 4x
y = (y2 y1 ) + (y3 y1 ) + y1 + 4y .
It is only a 2 2 system and equations are quadratic, but it is still a nonlinear system
and you will need Newtons method or something similar to get an approximate solution.
Of course we know the exact solution for six points (the six nodes), since they are mapped
back to the six nodes of the reference domain, so using these points is for free. It looks
like we are done, but you have still to notice that the integral is happening over a very
strange domain for which we dont have quadrature formulas. What is the wise thing to
do? Move everything back to the reference domain:
Z Z
K K
N N = b N
| det BK |N bK.
K b
K
With this strategy, the integral is defined on a plain triangle and we just need to compute
the nonconstant determinant of
" #
x2 x1 + 4x x3 x1 + 4y
BK =
y2 y1 + 4x y3 y1 + 4y
on the chosen quadrature points. The stiffness matrix is more challenging. Instead of
trying to work the integral on the curved domains (with the complication of having to
invert FK every time we need an evaluation), what we do is go backwards to the reference
domain and write Z
b N
| det BK | (CK N b ),
b
K
where
CK = B1 >
K BK
(we did this in Lesson 2) is a nonconstant matrix that requires inversion of BK every
time an evaluation is needed.
The whole thing looks more complicated than it is, because there are many aspects
to take care of at the same time. The lesson you have to learn here is that evaluating
anything (a basis function, its gradient, etc) has a price so you should try to balance a
sufficiently precise approximation (exact computation is not possible any longer) of the
integrals with taking as few quadrature points as possible.
72
2 Elements on quadrilaterals
Going back to the case of polygonal domains, we might be still more interested in using
grids of quadrilaterals type than triangular grids. It can be a question of your geometry
being described in a simpler form by using quadrilaterals, a preference for Qk elements or
a physical motivation to prioritize directions in the discrete level2 . Whatever your reasons
are, here is a way of defining finite elements of quadrilaterals that are not parallelograms.
By the way, many people say quads, which is a nice shortening. Im not going to write
it again.
The construction is reminiscent of that of isoparametric elements. We begin with the
reference square [1, 1] [1, 1] and recall the four Q1 basis functions
1
(1 )(1 )
4
(it is easy to check which one corresponds to each vertex). Now we take a general convex
quadrilateral3 and take its four vertices in rotating order: pK K
1 , . . . , p4 .
^
p4 ^
p 3
^ ^
p1 p2
b satisfy
Since the functions N
b (b
N p ) = , , = 1, . . . , 4,
73
b is mapped at constant velocity
Moreover, the restriction of FK to one of the four sides of K
to the corresponding edge of K. Obviously, by continuity, the interior of K b is mapped to
the interior of K.
The map FK in fact transforms a uniform Cartesian into something very similar in
K, as shown in Figure 4.7. Computation of FK1 is therefore very simple on points of this
special grid in the quadrilateral.
Figure 4.7: The image by the bilinear map of a Cartesian grid in the reference square.
I think you can already imagine what the local nodes are, how we can glue elements on
different quadrilaterals and so on. If K is a parallelogram, FK is a linear map and we
obtain the usual Qk spaces, which are composed of polynomial functions. In other cases,
elements of the space are functions of the form qb FK1 with qb a polynomial. The inverse
map FK1 is not linear anymore. Now it is rational function. Therefore, elements of Qk (K)
are not polynomials any longer, which is not really relevant, since we are only going to
use the basis functions, which we obtain by transforming from the reference element.
Just a fast list of facts:
The spaces Qk (K) depend on the quadrilateral and not on the order we have given
the vertices to construct the transformation.
Restricted to the four sides, functions of Qk (K) are just polynomials of degree up
to k in one variable. Therefore, the type of functions is independent of the shape of
the quadrilateral and the values on sides is determined by the values on nodes that
are on the side.
74
Thanks to these properties we can easily construct finite element spaces on quadrilateral
grids (composed of convex quadrilaterals). Parallelograms are a particular case of these
elements, so we can use all types of quadrilaterals together . Therefore, we can combine
these elements with triangular elements of the same degree: for instance Q1 (K) elements
on quadrilaterals with P1 elements on triangles.
3 Mass lumping
Let us just here add some comment about the mass matrix in the finite element method.
For the usual Pk and Qk , we should expect the mass matrix
Z
j i
to be wellconditioned. Recall that the mass matrix is symmetric and positive definite.
The spectral condition number of this type of matrices is the ratio between its largest and
its smallest eigenvalue (all of them are real and positive) and good conditioning means
that this ratio is not large. In particular it means that if
X
uh = uj j
j
are of the same size and thus and the Euclidean norm of the vector of coefficients represents
faithfully the L2 ()norm of the function up to a scaling factor. In its turn, good
conditioning means that the use of the most common iterative methods for systems with
symmetric positive definite matrices (such as Conjugate Gradient) is going to converge
quickly.
However, sometimes it seems convenient to substitute the mass matrix by an even
simpler matrix. In the next lesson we will see a situation where this seems justified.
Substitution of the mass matrix by a diagonal matrix is called mass lumping, since it
lumps mass on the nodes instead of distributing it along pairs of nodes. We are going to
explain this process for the P1 case.
Recall briefly the threevertex quadrature rule on triangles (we mentioned it in the
lesson on assembly)
Z 3
area K X
(pK
),
K 3 =1
where pK are the three vertices of K. This formula integrates exactly all polynomials of
degree one. However, it introduces error when applied to a polynomial of degree two. In
particular, the approximation
Z 3
K K area X K K K K area K
N N N (p )N (p ) =
K K =1 3
75
is not exact. (We have accumulated as many as three indices in the last expression. Do
you see why the result holds? Note that local basis functions are one on a single vertex
and zero on the other two). If we apply this approximation at the assembly process for
the mass matrix, we are substituting the 3 3 local mass matrices by a 3 3 diagonal
matrix. Adding up all contributions we are approximating
Z
j i 0, i 6= j
and
Z XZ X n area K o
2
|i | = |i |2 K such that pi K
K K 3
= 31 area supp i .
Once again, the support of i is the set of triangles that surround the node pi .
In an exercise at the end of this lesson we will see a very, very simple way of computing
the lumped mass matrix once the exact mass matrix has been computed.
Note two things. First of all, u = 0 is not an interesting solution since it always satisfies
the conditions, no matter what is. Second, boundary conditions in eigenvalue problems
have to be zero. If you have two different solutions u for the same , any linear combination
of them is another solution. The set of eigenfunctions (thats u) for a given eigenvalue
(thats ) is a subspace of ... (wait for it).
In this problem D = . The space H1 () is given a different name. This one
n o
H01 () = u H 1 () u = 0, on .
76
The set of eigenfunctions for a given eigenvalue is a subspace of H01 (). Therefore, also
of H 1 () and of L2 (), which are bigger and bigger spaces. Substituting the definition
of eigenfunction inside Greens formula
Z Z Z
u v + u v = (n u) v
Do we know how many eigenvalues are going to appear? Yes, we do. Infinitely many.
But among those infinitely many, not so many, since we will be able to count them. I am
going to try and break up the theoretical result in many pieces so that you really grasp
whats in here:
All eigenvalues are real and positive.
They can be numbered and they diverge to infinity. There is therefore no accumu-
lation point of eigenvalues. In other words, if you choose a finite interval, there is
only a finite number of eigenvalues in it.
with 6= . Then Z
u v = 0.
0 < 1 2 . . . n . . . , n
77
and associate to each eigenvalue an eigenfunction
"
n = n n , in ,
n = 0, on ,
so that Z
n m = nm
and we have taken all possible eigenvalues and (linearly independent) eigenfunctions.
Note again that eigenfunctions for different eigenvalues are per se orthogonal and that
we enforce orthogonality of eigenfunctions of the same eigenvalue by an orthogonalization
process.
There is an additional property that needed this kind of numbering of eigenvalues and
eigenfunctions to be properly introduced:
The sequence of eigenfunctions we have just obtained is a complete orthogonal set
in L2 (), which means that if u L2 (), then
X Z
u= uj j , uj = u j ,
j=1
78
Note that these are just the parts of the stiffness and mass matrices related to non
Dirichlet nodes. Let N = #Ind be the number of nonDirichlet problems. The discrete
eigenvalue problem is equivalent to this other problem
"
find h such that there exists 0 6= u RN satisfying
Wu = h Mu.
This last problem is a generalized eigenvalue problem for matrices. Let me condense the
main properties of this problem for you. Recall that N = N (h) is the dimension of the
problem.
Note that unlike in the original problems, there is no question about having more than N
eigenvalues, since we are dealing with an N N matrix. Counting eigenvalues as many
times as their multiplicity we have N of them that we can arrange in increasing order
Choosing linearly independent eigenvectors in case we have multiplicity higher than one,
we can choose vectors n such that
Wn = h,n Mn
and
n (Mm ) = nm .
The vectors n give a basis of RN . The corresponding finite element functions
N
X
h,n = n,j j , n = (n1 , . . . , nN )>
j=1
form a basis for Vh0 . Note that the Morthogonality of the eigenvectors is just the matrix
form of the orthogonality condition
Z
uh,n uh,m = nm .
79
4.3 Convergence
So far we have two different problems. The continuous problem (the Dirichlet eigenvalues
of the Laplace operator) has infinitely many solutions. The discrete problem (approxi-
mation by finite elements of the weak formulation of the eigenvalue problem) has a finite
number of solutions. We will not deal in full detail with convergence of the discrete so-
lutions to the exact solutions. We will however mention here two important properties.
The first one is, lets say so, peculiar:
with the increasing order of continuous and discrete eigenvalues that takes into
account their multiplicity, discrete eigenvalues always overestimate continuous
eigenvalues
n h,n , n = 1, . . . , N.
5 Exercises
E4.1. Bad quadrilaterals
Figure 4.7 will help you to solve both questions in this exercise.
1. Take four points that define a convex quadrilateral, given in rotating order: pK K
1 , p2 ,
K K
p3 and p4 . (They could be, for instance, the vertices of the reference square). If
we give the third and the fourth vertices in the wrong order to the transformation,
what is the transformed figure we obtain?
80
2. Take now the four vertices of a nonconvex quadrilateral given in rotating order
and consider the usual bilinear transformation from the reference square. Using the
fact that vertical and horizontal lines in the reference square are mapped to straight
lines in the physical element, what kind of figure are we mapping?
(To do this, compare nodal values of both functions and note that constant functions
belong to Vh .) Finally use the following trick based on the preceding identity
Z XZ
i = j i
j
to prove that
1
X
3
area supp i = mij
j
and therefore the ith diagonal element of the lumped mass matrix can be computed by
adding all the elements of the ith row of the mass matrix.
81
Lesson 5
Evolution problems
There are many different approaches in the application of finite element techniques to
evolution problems. In fact, there are also many different types of evolution problems. In
this lesson we are going to concentrate on two evolution equations:
the heat equation, a good example of parabolic behavior (transient diffusion)
the wave equation, the simplest model of hyperbolic equation of the second order.
We can group the FEMbased approaches for these evolution equations:
methods that discretize space and time simultaneously, and
methods that discretize one of these variables and then the other.
We are going to do as follows. Well first take the heat equation and do time discretization
with finite differences and then space discretization with finite elements. Afterwards we
will see how discretization only of the space variable with FEM leads to a system of
ordinary differential equations, for which you can use a great variety of methods. If we
use a finite element type method for the time variable we end up with something very
similar to applying a FEM discretization at the same time to spaceandtime. Finally,
well go for the wave equation and show some basic ideas.
82
Many new things again, so lets go step by step:
When both f and g are independent of time, there is still evolution, but we will
see that it is just a transient state converging to a steadystate solution. Well talk
about this on the section about stability.
In principle, we are going to make ourselves our life simple by assuming that u0 is a
continuous function (and we can evaluate it without difficulty) and that f and g0 are
continuous in the time variable.
If our time interval is finite (as it is for any practical problem), the partition finishes in a
certain point tM . This is not important right now. The timestep is
n = tn+1 tn .
For us, doing a time step will be moving from an already computed approximation if time
tn to time tn+1 . The timesteps n are given as if they were known from the beginning.
Unless you are taking it to be uniform (which is not really a very good idea in most
practical situations), timesteps are computed with information about the behavior of
the numerical solution solution and about the performance of the method as we proceed
in discrete time. For the sake of exposition, we do as if we already knew all timesteps in
advance.
We freeze the source term and boundary data at each time tn by simple evaluation
fn = f ( , tn ) : R, gn = g( , tn ) : R.
When the data functions are not continuous we should be willing to average in a time
interval around tn instead. Time semidiscretization strives to obtain approximations
u( , tn ) un : R.
83
The first attempt we will do is the forward (or explicit) Euler method. It consists of
looking at the equation in discrete time n and approximating a time derivative in this
time by the forward quotient
(tn+1 ) (tn ) (tn+1 ) (tn )
0 (tn ) = .
tn+1 tn n
If we take the heat equation and use this forward Euler approximation, we obtain the
recurrence
un+1 un
= un + fn
n
or in explicit form
un+1 = un + n un + n fn .
This recurrence is started at n = 0 with the initial data function u0 . Bullet points again:
Note that all functions are functions of the space variable, so the Laplace operator in
space variables is just the Laplace operator. Time is now discrete time and appears
as the n subindex everywhere.
In principle this formula gives you un+1 from un and the source function. Where is
g? Weve lost it in the way! There seems to be no way of imposing the boundary
condition without entering in open conflict with the recurrence.
Theres more. If you begin with u0 , you take two derivatives to compute u1 . Then
another two to compute u2 and so on and so on. You had better have many space
derivatives available! How could we possibly think of approximating un by a finite
element function, which only has the first derivatives?
The answer to the last two questions comes from the use of a weak formulation for the
recurrence. The price will be losing this explicit recurrence character that made the
forward Euler approximation really explicit.
Consider Greens Theorem applied to un . Yes, I know we want to compute un+1 (we
already know un ). Follow me anyway. We have
Z Z Z
(un ) v + un v = (n un ) v.
Multiply this by n and for lack of knowledge of the Neumann boundary data function,
impose v to be zero on the boundary. We have therefore
Z Z
n (un ) v + n un v = 0, for all v such that v = 0 on .
84
Now there seems to be room for imposing the missing Dirichlet boundary condition,
implicitly at time n + 1, since the test is satisfying the homogeneous Dirichlet boundary
condition. The sequence of problems would be consequently: begin with u0 and then for
each n,
find un+1 H 1 () such that
un+1 = gn+1 , on ,
Z Z Z Z
un+1 v = un v n un v + n fn v, v H01 ().
H01 () = {v H 1 () | v = 0, on }.
The problem looks more like what we have been solving so far1 . Only there is no stiffness
term for the unknown, which is a problem (there is no way we will obtain ellipticity of
the bilinear form in energy norm), and at the same time there is a stiffness term in the
righthand side, which is more complicated than usual. Dont worry, we are getting near
something reasonable.
Vh H 1 ()
associated to a triangulation of the domain, a nodal basis, the concept of Dirichlet nodes
(all nodes on the boundary) and the subspace
Nodes are numbered as usual and we take two lists: Dir, the one of indices of Dirichlet
nodes, and Ind, the remaining nodes. The Dirichlet nodes are then
pi , i Dir.
The main point now is to substitute all the infinitedimensional elements of the problem
find un+1 H 1 () such that
un+1 = gn+1 , on ,
Z Z Z Z
un+1 v = un v n un v + n fn v, v H01 (),
1
For knowledgeable mathematicians, I know, this sequence of problems is giving you the creeps. It is
so illposed! You will have to wait to the fully discretized problem to get some satisfaction.
85
by the their discrete counterparts, which is easy: for each n we have to
find uhn+1 Vh such that
uh (pi ) = gn+1 (pi ), i Dir,
n+1
Z Z Z Z
h h h
un+1 vh = un vh n un vh + n fn vh , vh Vh0 .
This looks more like something we can do. Before going for matrices, we have to give a
starting point for this recurrence: uh0 Vh can be computed by interpolating in the nodes
of the grid the initial data function u0 . This is not the best option, but it is definitely the
simplest one.
We need to reintroduce matrices and vectors to give a simpler idea of what we are
doing here in each time step. The nodal values of un are given in the vector un . They
are divided into values on free/interior nodes unInd and values on the Dirichlet nodes unDir .
Actually, the Dirichlet condition states that
un+1
Dir = gn+1 ,
The matrix MInd is square shaped, with as many rows as there are interior nodes. On the
other hand MDir is rectangular, with as many rows as there are interior nodes and one
column per Dirichlet node. We will glue them together in the rectangular matrix
Mall = MInd MDir .
Its rectangular shape reflects the fact that testing with nodal basis function is ignored.
We similarly construct the matrices WDir , WInd and Wall .
At this stage of the course we have seen this kind of arguments enough times so that
you will easily recognize that the step in variational form
find uhn+1 Vh such that
uh (pi ) = gn+1 (pi ), i Dir,
n+1
Z Z Z Z
h h h
un+1 vh = un vh n un vh + n fn vh , vh Vh0 ,
86
where fn is the vector with elements
Z
fn i , i Ind.
MInd un+1 n n
Ind = Mall u n Wall u fn MDir gn+1
to compute only values on free nodes. Values on Dirichlet nodes are incorporated to this
formulation but we have also to remind ourselves to keep them in the full vector un+1 ,
that will be used in the next timestep.
The matrix is always the same and it is always the mass matrix, so you have good
conditioning of the system together with symmetry and positive definiteness.
If you are not happy yet with the implicit character of these equations, you can
substitute the mass matrix (at least the one that appears on the left hand side) by
the lumped mass matrix, which is diagonal. A diagonal system is immediate to
solve.
Diffusion or propagation of heat? There are some good reasons to make the method
completely explicit: you compute the time steps faster, since you dont have to solve any
linear system, no matter how well conditioned this is. There are reasons not to make it
fully explicit. In fact the argument Im going to give to you here is somewhat tricky and
youll have to take it with a grain of salt. The real reason for going implicit is given in
the stability analysis.
Let us consider just the first time step in the case where f 0 and g 0. We only have
to compute the free nodes in all steps, because the boundary condition is homogeneous.
Let us consider the P1 method and let us take a free node that is completely surrounded
by free nodes. As initial condition we take an impulse in that node, that is, if the node is
given the index i, we are starting with
uh0 = i .
87
In matrix form we are beginning with the vector ei , that has all components zero but the
ith that is one. This is the system we solve:
Note that the ith row of MInd and WInd is the only one used in the righthand side. It
contains nonzero elements only on the positions of adjacent (neighboring) nodes. The
vector MInd ei 0 WInd ei propagates the unit value on the ith node to its neighboring
nodes. All other elements of this vector are still zero.
If you do mass lumping, thats all that is going to be nonzero in u1 . In the next step,
we will reach the following set of neighbors (neighbors of neighbors of the ith node).
What we are doing here is propagating heat at finite speed: the physics are all wrong!
Heat diffusion is done at infinite speed. A unit impulse in time zero heats all the domain
at any positive time. In truth, the values far from the heating source are very, very small
at small times, but they are non zero. If we keep the mass matrix without lumping, at
least it looks like we can reach all nodes in the first time step. The reason is the fact
that M1 Ind has most (if not all) elements nonzero. The process is much more similar to
1
diffusion, although what we call diffusion, thats done by WInd . But I cannot explain why
right now.
Changing spaces with time. In some cases, with highly varying source terms and
boundary conditions it could be wiser to change the finite element space from time to
time, maybe even at all timesteps2 . Think in the step n 7 (n + 1). Assume that unh we
computed with a P1 finite element on a given triangulation. The space is denoted Vh,n
0
and Vh,n is the subspace obtained by eliminating the Dirichlet nodes. For whichever the
reason, we are going to change grid and compute uhn+1 in a new space Vh,n+1 . In principle
these are the discrete variational equations:
find uhn+1 Vh,n+1 such that
uh (pi ) = gn+1 (pi ), i Dir(n + 1),
n+1
Z Z Z Z
h h h 0
un+1 vh = un vh n un vh + n fn vh , vh Vh,n+1 .
It looks the same but it isnt exactly the same. If you add a superindex with the discrete
time to the nodal bases, you will see that in the lefthand side, you have a usual mass
matrix for the current space Z
n+1
j n+1
i .
88
These matrices do not need even to be square. But theres more. The very nice idea of
assembly is much more complicated if the triangulations are not related and what we did
in Lesson 2 is definitely not valid here anymore. With this nave approach things really
get messy.
What can be done in practice is taking a very different approach, consisting of pre-
processing the solution in time n to move it to the grid of time n + 1. In essence it is like
interpolating uhn to the new space Vh,n+1 . This can be a somewhat complicated process
but has the advantage that the uhn we input in the righthand side is now in the same
space as the uhn+1 we want to compute and the assembly process can be used again.
with f and g independent of time. If we ignore the initial condition we can look for the
only steadystate solution to the problem
"
ulim = f, in ,
ulim = g, on .
Assume now that we know all Dirichlet eigenvalues and eigenfunctions of the Laplace
operator in : "
k = k k , in ,
k = 0. on .
The solution to the heat diffusion problem is
X Z
k t
u(x, t) = ulim (x) + ck e k (x), ck = (u0 ulim ) k .
k=1
This formula3 shows that the solution goes exponentially fast to the steadystate solution.
The occurrence of negative exponentials at increasing velocities (k diverges as k goes to
infinity) makes the initial times very hard to compute with precision.
In case we are dealing with zero data
f 0, g 0,
3
You might (should) recognize it from your course(s) on differential equations. It is the solution
obtained by separation of variables
89
the formula for the solution is really simple: its just diffusion of the initial condition
towards the zero solution
X Z
k t
u(x, t) = ck e k (x), ck = u0 k .
k=1
Let us see what the numerical method does. Since boundary conditions vanish we dont
have to take into account Dirichlet nodes. In the nth timestep we solve
MInd un+1 n n
Ind = MInd uInd n WInd uInd .
Let us drop the Ind subindex and keep in mind that we are only computing in the interior
nodes. Also for simplicity assume that n = for all n, that is, we are using a fixed time
step. This is the very simple nth time step:
There is only a finite number of linearly independent eigenvectors (that are nodal
values of the discrete eigenvectors):
Wk = h,k Mk .
Maybe you should go back to Section 4 of Lesson 4 to review this. Recall that h,k k
approximates this kth exact eigenvalue for h sufficiently small. Take u0 = k as initial
condition in the recurrence that determines the discrete time steps. Then the equation
for the first timestep is
Mu1 = Mk Wk = (1 h,k ) Mk .
Therefore, using the fact that M is invertible, we have u1 = (1 h,k )k . The following
time steps are similar and we obtain the following formula for all the timesteps
un = (1 h,k )n k .
Note that h,k is trying to approximate k and k is trying to approximate the nodal values
of k . The formula for the recurrence is trying to approximate the diffusive solution
ek n k = ek tn k .
Is it doing a good job? Independently of whether this approximation is good or not, let
us just look at the asymptotic behavior. The exact solution goes to zero as n goes to
infinity. What about the discrete solution? Well, not always. It will do the right thing if
|1 h,k | < 1,
h,k < 2.
90
This should be satisfied for all discrete eigenvalues. Since we have ordered them from
smallest to largest, it has to be satisfied by the largest of them
Why do I say that it has? The fact is that any initial condition can be decomposed as
N (h)
X
0
u = ck k
k=1
The orthogonality condition of the discrete eigenvector proves that un goes to zero as
n (that is, it has the correct asymptotic value) if and only if all conditions h,k < 2
hold.
Lets discuss the condition
h,N (h) < 2.
If we take the fixed timestep to begin with, the condition is of the form
Note that h,N (h) N (h) . If we take a very fine grid (a very precise finite element
method) it is very likely that you are getting to capture a very large eigenvalue and the
stability condition does not hold any longer. This conditional stability says that given
the timestep you can only try to do this good with finite elements, but if you try to be
too precise you lose stability. This may be a shock to you. One would think that each
part of the discretization process can be done as precisely as possible without taking care
of the others. The conditional stability denies that.
If you fix the finite element grid, the inequality can be read as
which says that you have to take timesteps that are short enough in order not to lose
stability4 . It is difficult to make oneself an idea of how the largest discrete eigenvalue
grows with finer grids. For the one dimensional problem the precise formula is known.
Given the variety of polygonal domains you can think of, the question is less clear in two
dimensions.
4
People in the ODE discretization community call this problem stiff and say that explicit methods
are not linearly stable and should not be applied (or applied with great care) to stiff problems. More on
this in Section 3.
91
Remark. In fact, the term (1 h,k )n can be oscillating even when going to zero, so
we even might like it to be positive in addition to convergent to zero. The condition is
then h,k < 1.
What else? Convergence of course. Well, lets not do this here. The issue becomes
really difficult. Note only that: (a) use of forward Euler in time means you should expect
no more that error proportional to time step (order one); (b) the effort made in the space
discretization should agree with the low order in time; (c) imposition of nonhomogeneous
Dirichlet conditions becomes openly critical here. Doing the simplest thing here makes
you lose convergence order. You have to look at the theory (and we are so not going to
to that now) to understand why. Anyway, never use high order in space with low order
in time. You are wasting your efforts. Second, be careful with stability. You dont have
it for free! If you have fixed your timestep you cannot try to be too precise in space.
un+1 = gn+1 , on .
Equation and boundary condition constitute a boundary value problem like those we have
been studying all along this course. Note that the diffusion parameter is the time step
(it is very small) but that this parameter is also multiplying the source term. If you
92
formally take it to zero, what you obtain is a constant solution, which is what happens
with evolution when you stop the clock counting times.
The boundary value problem to obtain un+1 has nothing special. Its weak formulation
is done in the usual way, as if there was no time in the equation
find un+1 H 1 () such that
un+1 = gn+1 , on ,
Z Z Z Z
n un+1 v + un+1 v = un v + n fn v, v H01 ().
The recurrence (the timesteps) has to be started with an initial condition of uh0 given,
as we had in the explicit method. You can go back to the previous section and you will
notice that the only serious change is the stiffness term changing sides. It is implicit now.
Using the same notations for the vectors of unknowns and for the pieces of the matrices,
we have a fully implicit method now
n+1
uDir = gn+1 ,
n Wall + Mall un+1 = Mall un fn ,
Note again that the stiffness matrix has changed sides in the system. The system to be
solved in each time step is actually
n WInd + MInd un+1
Ind = M all u n
+ n W Dir + f n MDir gn+1 .
You can take from here a first idea: the cost of programming the forward and the backward
Euler is exactly the same. The main difference is that in the implicit method you have to
solve a linear system in each time step and there is not diagonal approximation for the
corresponding matrix. The matrix itself varies with timestep, but if you have to look for
a preconditioner, you just have to take care of the stiffness matrix, which is the bad guy
here (mass=good, stiffness=bad) in terms of conditioning. For fixed time stepping, the
matrix is always the same, by the way.
If you put a point source in time zero, it diffuses instantaneously to the whole domain
thanks to the inverse of the matrix of the system.
93
2.3 Stability analysis
With vanishing boundary conditions and zero sources as well as with fixed timestep we
solve the recurrence
(W + M)un+1 = Mun
to follow the free evolution of the system with initial condition u0 . If u0 = k (we use
the same notation as in the corresponding subsection for the forward method), then the
eigenvectors satisfy
(W + M)k = (1 + h,k )Mk .
Therefore, it is simple to check that
un = (1 + h,k )n k .
This discrete evolution is always correct, since 0 < (1 + h,k )1 < 1. The method is
therefore unconditionally stable. Expected convergence is similar to the one of the
forward Euler approximation, since both time discretizations have the same order. What
changes here is stability.
94
Using Greens Theorem we obtain a weak formulation
u = g, on ,
Z Z Z
u v + ut v = f v, v H01 ().
Hey, teacher! Your forgot to write the space for u! No, I didnt. We can try to think of u
as a function that for each t, gives an element of H 1 (), but I really prefer not to write
the correct spaces. First of all, because they are complicated. Second,... because they are
complicated, if we want to have the right spaces where we are certain to have a solution
and not some safe spaces where everything looks nice but we will never be able to show
that there is a solution.
Instead, let us go to discretization. The idea is the same: for each time we associate
a function in the finite element space (it will be the same space for all times). So, fix Vh
and Vh0 as usual. A timedependent element of Vh is something of the form
N
X
uh (t, x) = uj (t) j (x).
j=1
The coefficients vary with time, but the global basis is always the same since the triangula-
tion is fixed. In fact, when we are dealing with the nodal basis functions uj (t) = uh (t, pj ),
so we are following the nodal values of the discrete function. The partial derivative of
this function with respect to time is
N
X
uj j .
j=1
Then, the semidiscrete in space problem looks for uh such that for all t
uh ( , t) Vh ,
uh (p, t) = g(p, t), for all p Dirichlet node,
Z Z Z
x uh vh + uh,t vh = f vh , v Vh0 .
where u0h Vh approximates the initial condition u0 . If we decide ourselves for interpo-
lating data, this means that we are giving an initial condition to the coefficients
uj (0) = u0 (pj ), j.
The problem can be easily written using these coefficients
ui (t) = g(pi , t), i Dir,
N Z N Z Z
X X
i i uj (t) + j i uj (t) = f i , i Ind.
j=1 j=1
95
This system holds for all t. This is a somewhat nonstandard but simple differential
system. We can get rid of the algebraic (nonstandard) part by simply substituting the
Dirichlet conditions inside the formulation to obtain
X X Z X
wij uj (t) + mij uj (t) = f i wij g(t, pj ) mij gt (t, pj ) , i Ind.
jInd jInd jDir
This looks much more like a system of linear differential equations. Let us simplify
expression by adding notations. We consider the following functions of time:
Z
fi (t) = f ( , t)i , i Ind,
gj (t) = g(t, pj ), j Dir.
The system is therefore
X X X
wij uj (t) + mij uj (t) = fi (t) wij gj (t) mij gj (t) , i Ind.
jInd jInd jDir
You will have noticed that this way of discretizing the problem, imposes the need to com-
pute the time derivative of the Dirichlet data. Its because they are essential (Neumann
data would appear like source terms, happily placed inside integral signs). If you want to
avoid this derivative of data, you have to deal with the algebraicdifferential system as
was first obtained.
Using the matrix notation introduced in the first section of this lesson, we can write
WInd uInd + MInd uInd = f WDir g MDir g.
Now, we write everything together, more in the style of how we write differential systems:
"
uInd (0) = u0 ,
MInd uInd = WInd uInd + f WDir g MDir g.
This is a linear system of differential equations (with initial values) given in implicit form.
To make it explicit you would have to premultiply by M1 Ind . In principle you dont have
to compute the inverse of the mass matrix to know how to multiply by it. The reason is
the fact that
the vector M1
Ind v is the solution to the system MInd x = v.
Therefore, you just need to know how to solve linear systems with MInd as matrix. You
dont even need that much. Most packages that solve numerically systems of differen-
tial equations (with RungeKutta methods for instance) already consider the implicit
situation, where the derivative is premultiplied by an invertible matrix.
This approach allows you to use high order in space and high order in time very easily,
because the processes are separated. In fact, many people in the numerical ODE commu-
nity use the heat equation after space discretization as a benchmark for their methods,
since the resulting system is stiff. Remember all those fastly decaying exponentials in
the separation of variable solutions? In the differential system they become large neg-
ative eigenvalues, which are difficult to handle. For stiff problems, the safe bet is the
use implicit methods. Anything explicit will be understandably conditionally convergent,
requiring short time steps or a very rigid step control strategy.
96
Remark. If you apply the forward or backward Euler method to this differential system
you obtain the methods you had in Sections 1 and 2 if:
g is independent of time
g depends on time but you substitute the occurrence of g in the nth time step by
the quotient (gn+1 gn )/n .
This coincidence of lower order methods in the simplest cases is something you find over
and over in numerical analysis.
If we try the finite difference in time approach, the simplest thing to do is to apply the
central difference approximation (some people call this Newmarks method7 ) to the second
derivative. If we take a fixed time step, this means approximating
97
(Only free nodes appear in all the expressions, since we have taken homogeneous Dirichlet
boundary conditions). The initial value for u0 is easy. You have data. You still need u1
(the nodal values of uh1 . For that, you can do very easy (and not very well) by taking a
Taylor approximation
u1 = u0 + v0 ,
or take a false discrete time 1 and use the equation
u1 2u0 + u1
= u0 + f0
2
together with the central difference approximation
u1 u1
= v0
2
to obtain the equation
u1 = 21 2 u0 + u0 + v0 + 12 2 f0 .
Then you need to give a weak formulation of this too. And do all the finite element stuff.
Nothing you dont know how to do. Some really fast last strokes:
Space discretization has made the equations implicit but its only with the mass
matrix. To obtain the good physics (finite velocity of propagation), the use of the
lumped mass matrix is highly recommended. Wait for a couple of points to know
more about this.
2 h,N < 4
Things with the wave equation happen quite fast so most people are willing to
accept the short timestep imposed by a CFL condition, since they want to observe
the propagation anyway.
Implicit methods have the advantage of unconditional stability but get the physics
wrong. When you are trying to follow the propagation of wavefronts you sort
of dislike the diffusion that would be caused by the presence of the inverse of the
stiffness matrix.
Wave propagation is however a delicate matter. If you take the explicit method,
made fully explicit by the use of mass lumping, you move (in the P1 method) from
node to node in each time step. That is, the speed of numerical propagation is
8
We have already met Richard Courant, moral father of the P1 element. Now, meet Kurt Friedrichs
and Hans Lewy. All three of them were German (Lewys birthplace counts as Poland nowadays) and
moved to America.
98
controlled by the time step. If you take a very, very short timestep to be sure that
you are satisfying the CFL condition, you may be going too fast, so you have to
play it safe but not too safe. This balance between stability and correct speed of
propagation makes the discretization of wave phenomena a difficult but extremely
interesting problem.
5 Exercises
E5.1. CrankNicolson and FEM for the heat equation
The CrankNicolson scheme consists of using the quotient to approximate the average of
the derivative in tn and tn+1 :
Write a weak formulation taking care of not having the Laplacian of un in the right
hand side but a stiffness term (you will have to use Greens formula twice, once in
tn and once in tn+1 ).
Write the discrete equations obtained from the FEM discretization of the weak
formulation.
Show that the method is unconditionally stable (use the same particular case: fixed
timestep, f 0 and g 0).
Prove it. (You just have to follow step by step what we did for the heat equation and
the forward Euler discretization. Note again the we have dropped the subscript Ind
everywhere).
99
E5.3. Space semidiscretization of the wave equation
We begin again
ut = x u + f, in (0, ),
u( , 0) = u0 , in ,
ut ( , 0) = v0 , in ,
u( , t) = 0, on for all t > 0.
(Note that we have homogeneous Dirichlet boundary conditions). Taking the approach of
spacefirst, prove that we arrive at a system of differential equations of the second order:
You just have to follow carefully the same process for the heat equation, with the addi-
tional simplification of having zero boundary conditions. To finish, note that we have two
initial conditions that we can incorporate to the differential system.
100
Appendices: Additional matters
2
4
1
5
data are needed for the implementation of the P1 finite element method:
The global number of nodes nNod.
A numbering of the nodes and their coordinates. This can simply be done by giving
a double vector with the coordinates of all nodes. Numbering is done by component:
x1 y 1
x2 y 2
.. ..
. .
101
The number of triangles.
(for instance, the 4th row of this matrix are the global indices for the 1st, 2nd and
3rd vertices of the fourth triangle).
A list of Dirichlet nodes (Dir), mentioning on what boundary subdomain they are
so that we know which function to evaluate.
The number of Neumann edges (edges that lie on the Neumann boundary)
A list of the Neumann edges, indicating what their vertices are and on which bound-
ary subdomain they lie.
A list of Dirichlet edges (edges on the Dirichlet boundary), indicating what their
vertices are and on which boundary subdomain they lie.
From this list, the construction of the list Dir and the complementary list Ind is a simple
preprocess that has to be performed before the assembly process is begun.
In the example we have been following along this Lesson and the previous one, we
have the following data:
23 triangles
6 Neumann edges
102
A list of Dirichlet nodes, indicating the boundary subdomain (the side of ) where
they are
9 1
13 1
17 1
18 2
15 2
14 2
(in this list it is not relevant that the order is increasing). Node number 18 could
be placed on the 2nd or the 1st side. Since the Dirichlet condition cannot be
discontinuous in this formulation, it is immaterial which choice is taken.
The list Ind is obtained from the list {1, 2, . . . , 18} by erasing everything that appears
on the firs column of Dir
List of Neumann edges (the third column is the number of the side of where they
are:
10 14 3
5 10 3
2 5 4
1 2 4
1 4 5
4 9 5
Instead of the list of Dirichlet nodes with their associated boundary side, we could
be given a list of Dirichlet edges with the boundary side (third column)
9 13 1
13 17 1
17 18 1
18 15 2
15 14 2
103