You are on page 1of 7

Problems in Two Spacial Dimensions

Diffusion, Laplace and Poisson Equations

Solution Using Linear and Bilinear Finite Elements
Lets recall the diffusion equation governing, for example, transient problems in heat transfer. If
u(x, y, t) is the temperature in a 2d conducting body (e.g. a thin plate with insulated faces) occupying
a region D of the x, y-plane, then
c

u
u
=
(kx ) +
(ky ) + Q(x, y, t), (x, y) D, t > 0
t
x
x
y
y

where , c, kx , ky are the density, specific heat, and conductivities in the two coordinate directions
respectively, and Q is the given rate of heat generation in D. On the surface of the body (edge of
the thin conducting plate), denoted by D, a variety conditions can be specified. Well consider the
following fairly general case: We assume that D = 3j=1 Dj with Dj three disjoint regions and
require that u = g1 (x, y, t) on D1 , qn = g2 (x, y, t) on D2 , and qn hu = g3 (x, y, t) on D3 , where
gj , h are given functions, and qn = nx kx u/x ny ky u/y is the heat flux in the direction of the
exterior normal vector, (nx , ny ) to D. In addition to these boundary conditions, we give the initial
condition u(x, y, 0) = g0 (x, y), (x, y) D, where g0 is the given initial temperature in the body.
We will begin by looking at steady state problems with kx = ky = k =constant. Setting Q/k =
f (x, y) we see that the temperature satisfies the Poisson equation u = f or
(

2u 2u
+ 2 ) = f.
x2
y

If no heat is generated within the body, the temperature satisfies the Laplace equation u = 0.
A large number of other physical problems turn out to be governed by the Laplace or Poisson
equation (e.g., potential flow problems in fluid mechanics, displacement of a membrane in elasticity,
electrostatic potential in electromagnetic theory, to name a few). As in the case of an ODE, we
start with the partial differential equation (PDE), develop the weak form, decide on a space of
functions in which to represent the approximate solution (well again choose continuous, piecewise
linear functions this time on triangles instead of intervals). Using Galerkins method this will lead
us to a numerical method of solution.
Before we begin, it is probably wise to review the statement of the divergence theorem (in 2D),
because we will use it in obtaining the weak form. In 1D this theorem will be familiar as the
fundamental theorem of calculus, i.e., that if a real valued function f is defined, continuous, and
Rb
has a continuous derivative f 0 on an interval [a, b], then a f 0 (x) dx = f (b) f (a). Note that the
integral involves values of the function on the boundary of its interval of definition. To generalize to
two dimensions, we need to consider functions defined on sets in R2 . The sets we will consider will
always be geometrically simple triangles, rectangles, ellipses, etc. possibly having holes which are
themselves triangles, rectangles, ellipses.
First, lets recall that a smooth curve in 2d is defined as a map X : R R2 X(t) = (
x(t), y(t)), 0
t ` with the component functions differentiable, and X 0 6= 0. The points X(0) and X(`) are
called the initial and final ends of the curve. If X(0) = X(`) the curve is closed otherwise its
open. For example, the equations x = t, y = t2 , 0 t 1 define an open curve (a parabola),
while x = r cos(t), y = r sin(t), 0 t 2 define a closed curve (a circle of radius r). We wont
distinguish between the set of points C = {X(t) : 0 t `} and the curve X. If f : D R2 R
is a function whose domain includes C, we define the integral of f along C (from the initial end to
1

Z

f ds =

f (X(t))kX 0 (t)k dt.

R
The integral C f ds is defined by the right hand side above with the limits of integration interchanged
andR represents the integral along C from the final end to the initial end. Clearly,
R
f
ds
=
C f ds. It is often convenient to replace t as the parameter along the curve by
C
Rt
s = s(t) = 0 kX 0 ( )k d . The function s represents distance along the curve measured from
X(0), and since s0 6= 0 we can always solve s = s(t) for t = t(s). (For our examples, the circle
has the distance function s = s(t) = rt (i.e., the arc length), while in the case of the parabola

Rt
s = s(t) = 0 1 + 4 2 d = [ln(2t + 4t2 + 1) + 2t 4t2 + 1]/4.) With distance along C as the
parameter, the line integral takes the simpler form
Z
Z L
f (X(s))ds
f ds =
C

where L = s(`) is the length of C, and we use the notational abuse X(t(s)) = X(s).
Lets denote a geometrically simple region of interest by D and its boundary curve by D. (Technically, D is a connected open set, and in fact, for all our applications is the interior of a polygon.)
The boundary curve will always be closed and piecewise smooth, i.e., it will consist of one or several
pieces each of which is a smooth curve as described above with the final end of the last piece equal to
the initial end of the first. For simplicity, well treat D as if it has only one piece and use distance s
along the curve as the parameter: X = (
x(s), y(s)), 0 s L. We assume that as one travels along
D in the direction of increasing s, D lies to the left. In particular, at each point of the boundary
curve (with the exception of possible corner points when is more than one piece) there is unit a
tangent vector, X 0 (s) = (
x0 (s), y0 (s)), and a normal vector ~n(s) = (
y 0 ,
x0 ) obtained by rotating
0

X (s) by 90 in the clockwise direction (~n points out of D).

Suppose that on the region D there is defined a vector function f~ = (fx , fy ) where both components
then the divergence theorem states that
fj , j = x, y have continuous first partial derivatives on D,
Z
Z
f~ dA =
~n f~ ds,
D

where f~ = fx /x + fy /y and ~n f~ = nx fx + ny fy . Note that the left hand side is a 2d integral

and the right hand side is a 1d integral. (Of course, the integral of the scalar function g = ~n f~ is
defined as in the discussion above.)
It may be worth while to derive the divergence theorem in the simple case of a rectangle D =
(a, b) (c, d). In this case, D = 4j=1 Dj with, D1 described by x = s a, y = c, 0 s b a,
D2 by x = b, y = s c, 0 s d c, etc.. Then
R
R
Rd
Rd
R
Rd
fx /x dA = c fx (x, y)|x=b
x=a dy = c fx (b, y) dy c fx (a, y) dy = D2 fx ds D4 fx ds,
D
R
R
Rb
Rb
R
Rb
fy /y dA = a fy (x, y)|y=d
y=c dx = a fy (x, d) dx a fy (x, c) dx = D3 fy ds D1 fy ds,
D
Rd
R
R dc
where, for example, we have used D4 fx ds = 0 fx (a, d s) ds = c fx (a, y) dy. Adding the two
equations above and noting, for example, that on the side x = b, c y d the outer normal is in
the positive x-direction so that ~n f~ = fx while on x = a, c y d the outer normal is oppositely
directed so that ~n f~ = fx .
2

A second concept we need to discuss before embarking on 2d finite element methods is the use of
continuous, piecewise linear interpolation of functions of two variables on triangles and on triangulated domains. This is the generalization to 2d piecewise linear interpolation of functions of a single
variable on intervals.
First, lets describe a triangulation of a domain D. We will always approximate D by a collection
of straight line segments. Thus, we can always assume that D is a polygon. A subdivision of D is a
A triangulation of a
finite collections of sets Tj , j = 1, . . . , nt such that Ti Tj = and Tj = D.
polygonal D is a subdivision of D consisting of triangles and having the property that no vertex of
any triangle lies in the interior of an edge of another triangle.
Now, suppose we have a triangulation of D and a function f (x, y) defined on D. Let Pi = (xi , yi ),
i = 1, . . . , N be the vertices of the triangles in the triangulation, and fi = f (Pi ) the values of f at
these points. On each triangle Tj we define a linear function Lj (x, y) = aj x + bj y + cj by requiring
Lj (Pk ) = fk at each vertex of Tj . These three equations completely determine the three coefficients
of Lj . In addition, the function L(x, y) which equals Lj on Tj is continuous on the entire polygonal
domain D. This continuity is clear on individual triangles. It also holds on the edges because along
a common edge of two triangles we have a linear function of one variable (say distance along the
edge) and this is uniquely determined by the values fj at the end points. We will provide more detail
on efficient computing of the continuous piecewise linear interpolant of a data set in what follows.
Now Ill describe the model problem to be used in illustrating the formulation of the weak form, and
subsequent development of the 2D finite element method. Suppose that f is a given function, and
D is a given region of the x, yplane with boundary D. Consider the problem of determining the
solution u(x, y) of the partial differential equation
2u 2u
+ 2 = f,
x2
y

(x, y) D,

which satisfies the boundary conditions

u = p,

(x, y) Dp ,

nx

u
u
+ ny
= q,
x
y

(x, y) Dq ,

where p, q, are given functions, Dp , Dq , are curves which together compose D, and (nx , ny ) is
the unit exterior normal to the boundary.
We assume that the basic domain is triangulated, divided into ne triangles which meet one another
only along their edges and are such that no vertex of any triangle is an interior point of the edge
of another triangle. The vertices of the triangles are called (global) nodes (labeled (xk , yk ), k =
1, . . . , n), and the triangles themselves are called elements. We denote the vertices of a typical
element e by (xe1 , y1e ), (xe2 , y2e ), (xe3 , y3e ). 1,2,3 are called the local node numbers of element e =
1, . . . , ne . Local node 1 is chosen arbitrarily, the remaining nodes are labeled in sequence as the
boundary is traversed in the counterclockwise direction. The relation between local and global
nodes is provided by the configuration matrix n(e, j), e = 1, . . . , ne , j = 1, 2, 3, where n(e, j) is the
global node number corresponding to local node j of element e.
We begin to develop our numerical method by finding the weak form of the model equation. To
obtain this form, we define the residual

 2
u 2u
+ 2 f,
r=
x2
y

and note that if u is a solution of the differential equation, and w is an arbitrary function possessing
first partial derivatives and vanishing of Dp then
Z
rw dA = 0.
D

Noting that

2u 2u
+ 2 = (wu) + w u,
w
x2
y
R
R M N
and using the divergence theorem (i.e. R ( x + y ) dA = R (M nx +N ny ) ds) applied to (M, N ) =
(wu/x, wu/y) and the region R = D we find
Z
Z
Z
u w u w
u
u
(
+
) dA =
f w dA +
+ ny )w ds,
(nx
y y
x
y
D x x
D
Dq


where since w = 0 on Dp the last integral above is only over the portion Dq over the boundary
traversed in the counterclockwise direction (ds is the length element along the boundary). We call
u
this last equation the weak form of the partial differential equation. Note that B(u) = nx u
x +ny y =
q(x, y) is given on the boundary Dq so that the right hand side can be computed in terms of given
functions. If u is a smooth function taking the values u = p on Dp , and the function u satisfies
the weak form for every w which vanishes on Dp , then by reversing the integration by parts it will
follow that u satisfies the differential equation in D and its normal derivative takes the value q on
the portion Dq of the boundary.
We will use the weak form as our starting place for finding approximate solutions (also called trial
functions). In general, Ill denote the approximation by the same letter as the exact one (although
this is not, in general, considered a good practice). The only type of approximation we consider for
the present is constructed by triangulating the domain, letting uj j = 1, . . . , n denote the values of
the solution at the vertices of the triangles (these are the numbers that well actually compute!) and
using piecewise linear interpolation on the triangles to define the trial function u(x, y) on the entire
triangulated domain. We can give an explicit representation of u on any triangular element e as
follows: We define the three linear functions (element shape functions) Hie (x, y) = aei x + bei y + cei
on e by requiring that Hie (xej , yje ) = ij , i.e., Hie equals 1 at local node i and 0 at the other two
nodes of e . As we mentioned above, for each fixed i these three conditions determine the three
coefficients aei , bei , cei uniquely, i.e., we have the equations

e
e
i1
x1 y1e 1
ai
xe2 y2e 1 bei = i2 , i = 1, 2, 3.
i3
cei
xe3 y3e 1
The solutions of these equations can be written as:
Hie =

1
[(xe y e xek yje ) + (yje yke )x + (xek xej )y],
2Ae j k

where Ae is the area of e , and (i, j, k) take the values (1,2,3), (2,3,1) and (3,1,2). The formula for
the shape function can be pictured as follows:

P3
A2 P
P1

A1

A3

P2

The point P = (x, y) in the element defines 3 sub-triangles Aej , j = 1, 2, 3, where Aej is opposite
to Pj = (xej , yje ) and Hje = Aej /Ae . The Hje , as mentioned above, are called the element shape
functions, and in terms of these shape functions, the trial solution in the element may be expressed
as u(x, y) = ue1 H1e (x, y) + ue2 H2e (x, y) + ue3 H3e (x, y), or
e
u1
u = ( H1e (x, y) H2e (x, y) H3e (x, y) ) u32 ,
u33
where uej is the value of the trial solution at the local node j. (Of course, the uej are related to the
global nodal values ui via the connectivity matrix, i.e., uej = un(e,j) ).
The global interpolant is obtained by piecing together the element interpolation P
functions. This
n
interpolant may be expressed in the same way as the one dimensional case, u(x, y) = i=1 i (x, y)ui ,
or

u1
..

u = ( 1 n )
,
.
un
where each i is defined in terms of Hje as follows: Let Ki be the set of element numbers defined
by Ki = {e : n(e, j) = i, j {1, 2, 3}}, and Di = eKi e be the union of all triangles e such
that node i equals n(e, 1), n(e, 2) or n(e, 3). Then i vanishes outside of Di and if n(e, j) = i, then
i |e = Hje , where i |e denotes i restricted to e . The i are the two dimensional versions of the
tent functions we used in solving ODEs. The graphs of these new functions are truly tents in 3D
sense, i.e., the base of the tent with apex above the point Pi is the union of the triangular domains
having Pi as a vertex. The tent itself rises to unit height above Pi , and the walls of the tent are
composed of triangular plane surfaces.
We are now in a position to find the algebraic equations which determine the nodal values of u. As
our test functions w we take the same i described above omitting those i which lie on Dp (since
w = 0 is imposed here). In this way we have the same number of test functions w = i as unknown
values of u. To make the algebra easier we actually ignore this restriction on w i.e., we use every
i and then throw out the extra equations at the end. Substituting the test and trial functions into
the weak form gives
n Z
X
j=1


Z
Z
i j
i j
+
) dA uj =
f i dA +
qi ds,
x x
y y
D
Dq

i = 1, . . . , n

The integrals on the left hand side form the elements of the global n n stiffness matrix K = [Kij ].
If we introduce the n 1 column vector = [1 2 n ]T , we can express K in the form

Z 
T
T
K=
+
dA.
x x
y y
D
Letting F denote the n 1 vector
F =

f dA +

q ds,

Dq

and U = [u1 u2 un ]T , we have the formal system of linear equations KU = F whose solution
provides the unknown values of the trial function at the nodes. The system is only formal, since we
have not taken into account the known values of uj on the Dp . This is easy to do. If uj is known,
we set the jth row Kj equal to zero and then set Kjj = 1. Finally, we set Fj = uj . Obviously, these
simple changes will enforce the required condition. (If desired, the symmetry of K can be retained
if we also set the jth column Kj equal to zero of course, with the exception of Kjj = 1.)
As in the case of one dimensional problems, we dont need to work with n n matrices. We can
focus on individual triangular elements containingR just three nodes. To see how this comes about,
consider, for example, the n 1 contribution L = D f dA to the load vector. Since D = e e , we
can write L as the sum
ne Z
ne
X
X
L=
f dA =
Le ,
e=1

e=1

where L = D |e f dA, and the restriction of to element e is completely determined by the

shape functions Hje , that is, in element e, all components of vanish except the three composed
from the element basis functions Hje , j = 1, 2, 3. These non vanishing components may be found
from the configuration or connectivity matrix: Hje = n(e,j) |e . Thus, we can compute the 3 1
element vector
e
e
Z
Z
H1
H1
H2e f dA =
H e f dA, H e = H2e
Le =
e
e
H3e
H3e
and use this vector to build L, e.g., add LRe1 to Ln(e,1) , etc.. Similar remarks apply to the stiffness
matrix K and the remaining portion Q = Dq q ds of the load vector. Thus,
K=

ne Z
X
e=1

T
T
+
x x
y y

dA =

ne
X

K e

e=1

where K
is determined by the restriction of the derivatives of to the element e . Thus, this
n n matrix has all its components zero except those arising from the 3 3 element matrix
 Z
Z
Hre Hse
H e H e T
H e H e T
Hre Hse
e
+
) dA =
+
) dA.
(
[Krs ] =
(
y y
x
y y
e x
e x x
Once these matrices are computed, the n n matrices K e can be found using the configuration
matrix, and the global stiffness matrix can be assembled by a simple summation. In more detail, if
e
e
n(e, r) = i, n(e, s) = j, then Krs
is equal to Kij
. In the same way, the remaining portion of the
load vector can be written as
ne Z
ne
X
X
Q=
q ds =
Q e ,
e=1

Dq e

e=1

where Qe is determined by the restriction of to the boundary of elements e which form part of
Dq . These n 1 vectors can be composed from the 3 1 element vectors
Z
 Z
e
e
e
Q = [Qr ] =
qHr ds =
qH e ds,
e

where we note that on e only two components of H e are nonzero.

All that remains is to describe explicitly the process of constructing the global stiffness and load
vectors from the element K e and F e . In fact, this is an easy process once the connectivity matrix is
given. It is probably best explained using specific examples to illustrate the details, and we will take
advantage of the textbook exercises to do this. One point that has to be kept in mind: We are dealing
with a case in which there is a single unknown at each node (the value ui of the trial function at the
node). The text examples are written to handle a more general case in which there are nd unknowns
per node. This complicates things in the following minor way: With one unknown per node, node k
can be associated with unknown uk so there is no problem keeping track of the unknowns. With nd
unknowns per node or a total of n nd unknowns in the system, we keep track of them as follows: At
node 1 we have unknowns (degrees of freedom) 1, . . . , nd and at node 2 unknowns nd + 1, . . . , 2nd ,
and in general, at node k unknowns (k 1) nd + 1, . . . , knd . To deal with this complication, we
can use an additional book keeping matrix beside the connectivity matrix. In our text this is called
the index matrix, say J. It simply keeps a count of the indices of the unknowns that are associated
with each element. It is a simple matter to compute J for any element so J can be thought of as a
vector with nd np components, where np is the number of points per element (np = 3 in the case of
linear triangles). For theoretical considerations it is probably better to think of J as an ne nd np
matrix where J(e, k), k = 1, . . . , nd np provides the information which n(e, j), j = 1, . . . , np does in
the case nd = 1.
This essentially completes our discussion of the weak formulation of the Laplace and Poisson equations and the subsequent assembly process used in developing the finite element equations. Note
that if D = Dq , the solution is only determined to within an arbitrary constant (since u = c will
be a solution of the homogeneous equation (f = 0) for any constant c). In this case, the stiffness
matrix will have rank n 1, and provided the problem is consistent will determine the nodal values
to within an arbitrary constant.