FEM
FEM
FEM
page 199
Chapter 9
The FE procedure to solve 2D problems is the same as that for 1D problems, as the flow
chart below demonstrates.
9.1
Let us first recall the 2D version of the well known Divergence Theorem in Cartesian
coordinates.
Theorem 9.1. If F H 1 () H 1 (), then
ZZ
F dS =
Fn ds ,
(9.1)
,
x y
T
(9.2)
199
2015/3/6
page 200
200
T
u u
. Thus since
The second Greens theorem is the corollary where F = v u = v , v
x y
u
v
+
v
F =
x
x
y
y
=
u v
2u
u v
2u
+v 2 +
+v 2
x x
x
y y
y
= u v + v u
where u = u = uxx + uyy , we obtain
ZZ
ZZ
F dxdy =
(u v + v u) dxdy
Z
=
F n ds
Z
Z
u
ds ,
=
v u n ds =
v
n
u
where writing n = (nx , ny ) we have defined, n
= nx u
+ ny u
, the normal derivative
x
y
derivative of u. This result immediately yields the formula for integration by parts in 2D:
n
Note: the normal derivative u/n is sometimes written more concisely as un .
Some important elliptic PDE in 2D Cartesian coordinates are:
uxx + uyy = 0,
Laplace equation,
Poisson equation,
uxx uyy + u = f,
When > 0, the generalized Helmholtz equation is easier to solve than when < 0.
Incidentally, the expressions involved in these PDE may also be abbreviated using the
gradient operator , e.g., uxx + uyy = u = u as mentioned before. We also recall
that the general linear second order elliptic PDE has the form
a(x, y)uxx + 2b(x, y)uxy + c(x, y)uyy + d(x, y)ux + e(x, y)uy + g(x, y)u = f (x, y)
with discriminant b2 ac < 0. A second order self-adjoint elliptic equation has the form
(p(x, y)u) + q(x, y)u = f (x, y) .
(9.4)
2015/3/6
page 201
9.1.1
201
Boundary conditions
In 2D, the domain boundary is one or several curves. We consider the following various
linear BC.
Dirichlet BC on the entire boundary, i.e., u(x, y)| = u0 (x, y) is given.
Neumann BC on the entire boundary, i.e., u/n| = g(x, y) is given.
In this case, the solution to a Poisson equation may not be unique or even exist, depending upon whether a compatibility condition is satisfied. Integrating the Poisson
equation over the domain, we have
ZZ
f dxdy =
ZZ
u dxdy =
ZZ
u dxdy =
un ds =
g(x, y) ds = 0 ,
is given, where (x, y), (x, y), and (x, y) are known functions.
Dirichlet, Neumann, and Mixed BC on some parts of the boundary.
9.1.2
Multiplying the self-adjoint equation (9.4) by a test function v(x, y) H 1 (), we have
ZZ
ZZ
f v dxdy ;
and on using the formula for integration by parts the left-hand side becomes
ZZ
pvun ds ,
Here N is the part of boundary where a Neumann boundary condition is applied; and
the solution space resides in
V = v(x, y) , v(x, y) = 0 , (x, y) D , v(x, y) H 1 () ,
(9.5)
2015/3/6
page 202
202
9.1.3
ZZ
L(v) =
ZZ
f v dxdy
(9.6)
(9.7)
(9.8)
where C is a constant.
Z Z
(|u v| + |uv|) dxdy
|a(u, v)| max {pmax , qmax }
ZZ
|v|2 dxdy
pmin
ZZ
ZZ
1
1
|v|2 dxdy + pmin
|v|2 dxdy
= pmin
2
2
ZZ
ZZ
1
pmin
pmin
|v|2 dxdy +
|v|2 dxdy
2
2C
1
1
kvk21 ,
pmin min 1,
2
C
therefore a(u, v) is V-elliptic.
4. Finally, we show that L(v) is continuous:
|L(v)| = |(f, v)0 | kf k0 kvk0 kf k0 kvk1 .
Consequently, the solutions to the weak form and the minimization form are unique and
bounded in H01 ().
2015/3/6
page 203
9.2
203
The general procedure of the FE method is the same for any dimension, and the Galerkin
FE method involves the following main steps.
Generate a triangulation over the domain. Usually the triangulation is composed of
either triangles or quadrilaterals (rectangles). There are a number of mesh generation software packages available, e.g., the Matlab PDE toolbox from Mathworks,
Triangle from Carnegie Mellon University, etc. Some are available through the Internet.
Construct basis functions over the triangulation. We only consider the conforming
FE method in this book.
Assemble the stiffness matrix and the load vector element by element, using either
the Galerkin method (the weak form) or the Ritz method (the minimization form).
Solve the system of equations.
Do the error analysis.
9.2.1
Given a general domain, we can approximate the domain by a polygon and then generate
a triangulation over the polygon, and we can refine the triangulation if necessary. A simple
approach is the mid-point rule by connecting all the middle points of three sides of existing
triangles to get a refined mesh.
A triangulation usually has the mesh parameters
p :
Kj :
Ni :
hj :
j :
h:
h = max{hj } ,
= min{j } ,
with
1
j
> 0,
hj
where the constant is a measurement of the triangulation quality. The larger the , the
better the quality of the triangulation. Given a triangulation, a node is also the vertex of
all adjacent triangles. We do not discuss hanging nodes here.
9.2.2
For linear second order elliptic PDE, we know the solution space is in the H 1 (). Unlike the
1D case, an element v(x, y) in H 1 () may not be continuous under the Sobolev embedding
2015/3/6
page 204
204
theorem. However, in practice most solutions are indeed continuous, especially for second
order PDE with certain regularities. Thus, we still look for a solution in the continuous
function space C 0 (). Let us first consider how to construct piecewise linear functions
over a mesh with the Dirichlet BC
u(x, y)| = 0 .
Given a triangulation, we define
n
Vh =
v(x, y) is continuous in and piecewise linear over each Kj ,
(9.9)
v(x, y)| = 0 } .
We need to determine the dimension of this space and construct a set of basis functions.
On each triangle, a linear function has the form
vh (x, y) = + x + y ,
(9.10)
(9.11)
1 x1
det 1 x2
1 x3
y1
> 0,
y2 = 2 area of the triangle 6= 0 since
hj
y3
(9.12)
2015/3/6
page 205
205
a3
p1
a1
a2
p2
l1 x + l2 y + l3 = 0 ,
We can solve for x or for y:
or
x=
l2 y + l3
l1
if
l1 6= 0 ,
y=
l1 x + l3
l2
if
l2 6= 0 .
l2
l3
l1
= + x
l2
l2
= + x
= 1 + 1 x .
Similarly, we have
p2 (x, y) =
1 + 1 x .
Since p1 (A) = p2 (A) and p1 (B) = p2 (B),
1 + 1 x1 = p(A) ,
1 + 1 x2 = p(B) ,
1 + 1 x1 = p(A) ,
1 + 1 x2 = p(B) ,
2015/3/6
page 206
206
where both of the linear system of algebraic equations have the same coefficient matrix
1 x1
1 x2
that is non-singular since x1 6= x2 (because points A and B are distinct). Thus we conclude
that 1 =
1 and 1 = 1 , so the two linear functions have the same expression along the
line segment, i.e., they are identical along the line segment.
Corollary 9.5. A piecewise linear function in C 0 () over a triangulation (a set of nonoverlapping triangles) is uniquely determined by its values at the vertices.
Theorem 9.6. The dimension of the finite dimensional space composed of piecewise linear
functions in C 0 () H 1 () over a triangulation for (9.4) is the number of interior nodal
points plus the number of nodal points on the boundary where the natural BC are imposed
(Neumann and mixed boundary conditions).
Example 9.1. Given the triangulation shown in Fig. 9.2, a piecewise continuous function
vh (x, y) is determined by its values on the vertices of all triangles, more precisely, vh (x, y)
is determined from
(0, 0, v(N1 )) ,
(0, 0, v(N2 )) ,
(0, v(N3 ), v(N2 )) ,
(0, v(N1 ), v(N3 )) ,
(x, y) K1 ,
(x, y) K5 ,
(0, 0, v(N3 )) ,
(x, y) K2 ,
(x, y) K3 ,
(0, 0, v(N2 )) ,
(x, y) K4 ,
(x, y) K7 ,
(x, y) K6 ,
(x, y) K8 .
Note that although three values of the vertices are the same, like the values for K3 and
K4 , the geometries are different, hence, the functions will likely have different expressions
on different triangles.
0
0
4
5
2
6
3
7
0
1
1
2015/3/6
page 207
9.2.3
207
1
0
if i = j ,
(9.13)
otherwise ,
where Nj are nodal points. The shape looks like a tent without a door, and its support
is the union of the triangles surrounding the node Ni , cf., Fig. 9.3, where Fig. 9.3 (a) is
the mesh plot of the global basis function, and Fig. 9.3 (b) is the plot of a triangulation
and the contour plot of the global basis function centered at a node. The basis function is
piecewise linear and it is supported only in the surrounding triangles.
(a)
(b)
2
1
0.8
0.6
0.4
0
0.2
0
2
1
0
1
2
1.5
0.5
0.5
1.5
2
2
Figure 9.3. A global basis function j . (a) the mesh plot; (b) the triangulation and the contour plot of the global basis function.
It is almost impossible to give a closed form of a global basis function except for
some very special geometries (cf., the example in the next section). However, it is much
easier to write down the shape function.
Example 9.2. Let us consider a Poisson equation and a uniform mesh, as an example to
demonstrate the piecewise linear basis functions and the FE method:
(uxx + uyy ) = f (x, y) ,
u(x, y)| = 0 .
We know how to use the standard central FD scheme with the five point stencil to solve
the Poisson equation. With some manipulations, the linear system of equations on using
the FE method with a uniform triangulation (cf., Fig. 9.4) proves to be the same as that
obtained from the FD method.
2015/3/6
page 208
208
5
6
4
3
Given a uniform triangulation as shown in Fig. 9.4, if we use row-wise ordering for
the nodal points
(xi , yj ) ,
xi = ih ,
yj = jh ,
h=
1
,
n
i = 1, 2, , m 1 , j = 1, 2, , n 1 ,
then the global basis function defined at (xi , yj ) = (ih, jh) are
j(n1)+i
x (i 1)h + y (j 1)h
y (j 1)h
(x
ih)
x ih + y jh
=
1
h (y jh)
x (i 1)h
Region 1
Region 2
Region 3
Region 4
Region 5
Region 6
otherwise .
If m = n = 3, there are 9 interior nodal points such that the stiffness matrix is a 9 9
2015/3/6
page 209
209
matrix:
A=
0 ,
where stands for the nonzero entries and o happens to be zero. Generally, the stiffness
matrix is block tri-diagonal:
4
1
0
B
I
0
4
1
B
I
1
I
A=
, where B =
1
4
1
I B I
1
4
I B
and I is the identity matrix. The component of the load vector Fi can be approximated
as
ZZ
ZZ
i dxdy = h2 fij ,
f (x, y)i dxdy fij
D
so after dividing by h we get the same system of equations as in the FD scheme, namely,
9.2.4
We know that the FE solution uh is the best solution in terms of the energy norm in the
finite dimensional space Vh , i.e., ku uh ka ku vh ka , assuming that u is the solution to
the weak form. However, this does not give a quantitative estimate for the FE solution,
and we may wish to have a more precise error estimate in terms of the solution information
and the mesh size h. This can be done through the interpolation function, for which an
error estimate is often available from the approximation theory. Note that the solution
information appears as part of the error constants in the error estimates, even though
2015/3/6
page 210
210
the solution is unknown. We will use the mesh parameters defined on page 203 in the
discussion here.
Definition 9.7. Given a triangulation of Th , let K Th be a triangle with vertices ai ,
i = 1, 2, 3. The interpolation function for a function v(x, y) on the triangle is defined as
vI (x, y) =
3
X
v(ai )i (x, y) ,
(9.14)
i=1
where i (x, y) is the piecewise linear function that satisfies i (aj ) = ij (with ij being the
Kronecker delta). A global interpolation function is defined as
vI (x, y) =
nnode
X
v(ai )i (x, y) ,
(9.15)
i=1
where the ai are all nodal points and i (x, y) is the global basis function centered at ai .
Theorem 9.8. If v(x, y) C 2 (K), then we have an error estimate for the interpolation
function on a triangle K,
kv vI k 2h2 max kD vk ,
||=2
(9.16)
||=1
8h2
max kD vk .
||=2
(9.17)
a3
a2
a1
1
Figure 9.5. A diagram used to prove Theorem 9.8.
Proof: From the definition of the interpolation function and the Taylor expansion
2015/3/6
page 211
211
3
X
v(ai )i (x, y)
i=1
v
v
(x, y)(xi x) +
(x, y)(yi y)+
i (x, y) v(x, y) +
x
y
i=1
3
X
1 2v
2v
1 2v
(, )(xi x)2 +
(, )(xi x)(yi y) +
(, )(yi y)2
2 x2
xy
2 y 2
3
X
i (x, y)v(x, y) +
i=1
3
X
i (x, y)
i=1
v
v
(x, y)(xi x) +
(x, y)(yi y)
x
y
+ R(x, y) ,
where (, ) is a point in the triangle K. It is easy to show that
|R(x, y)| 2h2 max kD vk
||=2
3
X
i=1
P
since (x, y) 0 and 3i=1 i (x, y) = 1. If we take v(x, y) = 1, which is a linear function,
then v/x = v/y = 0 and max||=2 kD vk = 0. The interpolation is simply the
function itself, since it uniquely determined by the values at the vertices of T , hence
vI (x, y) = v(x, y) =
3
X
i=1
v(ai )i (x, y) =
3
X
i (x, y) = 1 .
(9.18)
i=1
If we take v(x, y) = d1 x+d2 y, which is also a linear function, then v/x = d1 , v/y = d2 ,
and max||=2 kD vk = 0. The interpolation is again simply the function itself, since it
uniquely determined by the values at the vertices of K. Thus from the previous Taylor
P
expansion and the identity 3i=1 i (x, y) = 1, we have
vI (x, y) = v(x, y) = v(x, y) +
3
X
i=1
P3
hence
i=1 i (x, y) (d1 (xi x) + d2 (yi y)) = 0 for any d1 and d2 i.e. the linear
part in the expansion is the interpolation function. Consequently, for a general function
v(x, y) C 2 (K) we have
vI (x, y) = v(x, y) + R(x, y) ,
kv vI k 2h2 max kD vk ,
||=2
v
v
(x0 , y0 )(x x0 ) +
(x0 , y0 )(y y0 ) + R2 (x, y),
x
y
2015/3/6
page 212
212
v
v
(x0 , y0 )(x x0 ) +
(x0 , y0 )(y y0 ) + R1 (x, y),
x
y
i = 1, 2, 3 .
Since p1 (ai ) + R1 (ai ) = p1 (ai ) + R2 (ai ), it follows that R1 (ai ) = R2 (ai ), i.e., R1 (x, y) is
the interpolation function of R2 (x, y) in the triangle K, and we have
R1 (x, y) =
3
X
R2 (ai )i (x, y) .
i=1
v
v
(x0 , y0 )(x x0 ) +
(x0 , y0 )(y y0 ) + R1 (x, y)
x
y
X
v
R1
v
i
vI
(x, y) =
(x0 , y0 ) +
(x, y) =
(x0 , y0 ) +
(x, y) .
R2 (ai )
x
x
x
x
x
i=1
Applying the Taylor expansion for v(x, y)/x at (x0 , y0 ) gives
v
v
2v
2v
(x, y) =
(x0 , y0 ) +
(
x, y)(x x0 ) +
(
x, y)(y y0 ) ,
2
x
x
x
xy
where (
x, y) is a point in the triangle K. From the last two equalities,
2
3
2
X
v
v
v
i
I
i
R2 (a )
x, y)(x x0 ) +
(
x, y)(y y0 )
x x = x2 (
xy
x
i=1
max kD vk
||=2
2h + 2h2
!
3
X
i
x .
i=1
= (x x2 ) sin + (y y2 ) cos .
Then 1 (x, y) = 1 (, ) = C = /1 , where 1 is the coordinate in the (, ) coordinate
system, such that
1
1 1
1
1
1
=
x cos sin 1 cos |1 | .
2015/3/6
page 213
213
2h
+
max
kD
vk
max kD vk ,
x
||=2
x
||=2
from the fact that h. Similarly, we may obtain the same error estimate for vI /y.
Corollary 9.9. Given a triangulation of Th , we have the following error estimates for the
interpolation function:
kv vI kL2 (Th ) C1 h2 kvkH 2 (Th ) , kv vI kH 1 (Th ) C2 hkvkH 2 (Th ) ,
(9.20)
9.2.5
(x, y) ,
u(x, y) = u0 (x, y) ,
where u0 (x, y) is a given function, i.e., a Dirichlet BC is prescribed. If we assume that
p, q C(), p(x, y) p0 > 0, q(x, y) 0, f L2 () and the boundary is smooth
(in C 1 ), then we know the weak form has a unique solution and the energy norm kvka is
equivalent to the H 1 norm kvk1 . Furthermore, we know that the solution u(x, y) C 2 ().
Given a triangulation Th with a polygonal approximation to the outer boundary , let Vh
be the piecewise linear function space over the triangulation Th and uh be the FE solution.
Then we have the following theorem for the error estimates.
Theorem 9.10.
ku uh ka C1 hkukH 2 (Th ) ,
ku uh kL2 (Th ) C3 h2 kukH 2 (Th ) ,
(9.21)
ku uh k C4 h2 kukH 2 (Th ) ,
(9.22)
2015/3/6
page 214
214
9.3
Any triangle with nonzero area can be transformed to the right-isosceles master triangle,
or standard triangle , cf. the right diagram in Fig. 9.6. There are three nonzero basis
functions over this standard triangle , namely,
1 (, ) = 1 ,
(9.23)
2 (, ) = ,
(9.24)
3 (, ) = .
(9.25)
(x3 , y3 )
(0, 1)
(x, y)
(x2 , y2 )
(, )
(x1 , y1 )
(0, 0)
(1, 0)
Figure 9.6. The linear transform from an arbitrary triangle to the standard
triangle (master element) and the inverse map.
The linear transform from a triangle with vertices (x1 , y1 ), (x2 , y2 ) and (x3 , y3 )
arranged in the counter-clockwise direction to the master triangle is
x=
3
X
j=1
xj j (, ) ,
y=
3
X
yj j (, ) ,
(9.26)
j=1
or
1
(y3 y1 )(x x1 ) (x3 x1 )(y y1 ) ,
2Ae
1
(y2 y1 )(x x1 ) + (x2 x1 )(y y1 ) ,
=
2Ae
=
(9.27)
(9.28)
where Ae is the area of the triangle that can be calculated using the formula in (9.12).
2015/3/6
page 215
9.3.1
215
Quadrature formulas
ZZ
ZZ
(x, y)
dd ,
f (x, y)j (x, y) dxdy =
f (, ) j (, )
(, )
e
ZZ
ZZ
((x, y)
dd .
p(x, y)i j dxdy =
p(, ) (x,y) i (x,y) j
, )
e
b
c
c
d
g(, )dd =
S
L
X
wk g(k , k ) ,
(9.29)
k=1
where S is the standard right triangle and L is the number of points involved in the
quadrature. Below we list some commonly used quadrature formulas in 2D using one,
three and four points. The geometry of the points are illustrated in Fig. 9.7, and the
coordinates of the points and the weights are given in Table 9.1. It is notable that only
the three-point quadrature formula is closed, since the three points are on the boundary
of the triangle, and the other quadrature formulas are open.
9.4
The procedure is essentially the same as in the 1D case, but some details are slightly
different.
9.4.1
Description of a triangulation
A triangulation is determined by its elements and nodal points. We use the following
notation:
2015/3/6
page 216
216
Points
a
b
c
a
b
c
d
(k , k )
1
,
3
0,
1
,
2
1
,
2
1
,
3
2
,
15
11
,
15
2
,
15
1
3
1
2
0
1
2
1
3
11
15
2
15
2
15
wk
1
2
1
6
1
6
1
6
27
96
25
96
25
96
25
96
Nodal points: Ni , (x1 , y1 ), (x2 , y2 ), , (xnnode , ynnode ), i.e., we assume there are
nnode nodal points.
A 2D array nodes is used to describe the relation between the nodal points and the
elements: nodes(3, nelem). The first index is the index of nodal point in an element,
usually in the counter-clockwise direction, and the second index is the index of the
element.
Example 9.3. Below we show the relation between the index of the nodal points and
elements, and its relations, cf. also Fig. 9.8.
2015/3/6
page 217
217
nodes(1, 1) = 5 ,
(x5 , y5 ) = (0, h) ,
nodes(2, 1) = 1 ,
(x1 , y1 ) = (0, 0) ,
nodes(3, 1) = 6 ,
(x6 , y6 ) = (h, h) ,
nodes(1, 10) = 7 ,
(x7 , y7 ) = (2h, h) ,
nodes(2, 10) = 11 ,
nodes(3, 10) = 6 ,
(x6 , y6 ) = (h, h) .
13
16
13
17
15
14
16
18
12
7
11
10
12
8
3
1
2
1
5
4
6
3
9.4.2
2015/3/6
page 218
218
so
1
(y3 y1 ) ,
=
x
2Ae
1
(y2 y1 ) ,
=
x
2Ae
1
(x3 x1 ) ,
=
y
2Ae
1
(x2 x1 ) .
=
y
2Ae
2015/3/6
page 219
219
Iterative method plus preconditioning, e.g., Jacobi, Gauss-Seidel, SOR, conjugate gradient methods, etc.
Error analysis.
Construct interpolation functions.
Error estimates for interpolation functions.
FE solution is the best approximation in the FE space in the energy norm.
9.5
With constant coefficients, there is a closed form for the local stiffness matrix, in terms
of the coordinates of the nodal points, so the FE algorithm can be simplified. We now
introduce the simplified FE algorithm. A good reference is: An introduction to the FE
method with applications to non-linear problems by R.E. White, John Wiley & Sons.
Let us consider the Poisson equation problem
u = f (x, y), (x, y) ,
With the piecewise linear basis functions defined on a triangulation on , we can derive
analytic expressions for the basis functions and the entries of the local stiffness matrix.
Theorem 9.11. Consider a triangle determined by (x1 , y1 ), (x2 , y2 ) and (x3 , y3 ). Let
a i = x j ym x m yj ,
(9.30)
ci = xm xj ,
(9.32)
bi = y j y m ,
(9.31)
1 x 1 y1
1 x 3 y3
i (x, y) =
(9.33)
(9.34)
2015/3/6
page 220
220
a1 + b1 x + c1 y
,
2
(x2 y3 x3 y2 ) + (y2 y3 )x + (x3 x2 )y
,
2
1 (x2 , y2 ) =
1 (x3 , y3 ) =
We also have the following theorem, which is essential for the simplified FE method.
Theorem 9.12. With the same notation as in Theorem 9.11, we have
ZZ
m! n! l!
2 ,
(1 )m (2 )n (3 )l dxdy =
(m + n + l + 2) !
e
ZZ
bi bj + ci cj
,
i j dxdy =
4
e
ZZ
+ f3
,
F1e =
1 f (x, y) dxdy f1 + f2
6
12
12
e
ZZ
F2e =
2 f (x, y) dxdy f1
+ f2 + f3
,
12
6
12
e
ZZ
+ f2
+ f3 ,
F3e =
3 f (x, y) dxdy f1
12
12
6
e
(9.35)
where fi = f (xi , yi ).
The proof is straightforward since we have the analytic form for i . We approximate
f (x, y) using
f (x, y) f1 1 + f2 2 + f3 3 ,
and therefore
F1e
ZZ
f1
(9.36)
1 f (x, y) dxdy
e
ZZ
12 dxdy + f2
ZZ
1 2 dxdy + f3
e
ZZ
(9.37)
1 3 dxdy .
e
Note that the integrals in the last expression can be obtained from the formula (9.35).
There is a negligible error from approximating f (x, y) compared with the error from the
FE approximation when we seek approximate solution only in Vh space instead of H 1 ()
space. Similarly we can get approximation F2e and F3e .
2015/3/6
page 221
9.5.1
221
Assume that we have a triangulation, e,g., a triangulation generated from Matlab by saving
the mesh. Then we have
p(1, 1), p(1, 2), , p(1, nnode)
% Set-up: assume we have a triangulation p,e,t from Matlab PDE tool box
% already.
[ijunk,nelem] = size(t);
[ijunk,nnode] = size(p);
for i=1:nelem
nodes(1,i)=t(1,i);
nodes(2,i)=t(2,i);
nodes(3,i)=t(3,i);
end
gk=zeros(nnode,nnode);
gf = zeros(nnode,1);
for nel = 1:nelem,
for j=1:3,
% The coordinates of the nodes in the
jj = nodes(j,nel);
% element.
xx(j) = p(1,jj);
yy(j) = p(2,jj);
end
for nel = 1:nelem,
2015/3/6
page 222
222
% Area.
for ir = 1:3,
ii = nodes(ir,nel);
for ic=1:3,
ak = (b(ir)*b(ic) + c(ir)*c(ic))/(4*delta);
jj = nodes(ic,nel);
gk(ii,jj) = gk(ii,jj) + ak;
end
j = ir+1 - fix((ir+1)/3)*3;
if j == 0
j = 3;
end
m = ir+2 - fix((ir+2)/3)*3;
if m == 0
m = 3;
end
gf(ii) = gf(ii)+( f(xx(ir),yy(ir))*2.0 + f(xx(j),yy(j)) ...
+ f(xx(m),yy(m)) )*delta/12.0;
end
end
%------------------------------------------------------
2015/3/6
page 223
223
% End.
Example 9.4. We test the simplified FE method for the Poisson equation using the
following example:
Domain: Unit square with a hole, cf. Fig. 9.9.
9.6
2015/3/6
page 224
224
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
(b)
3
x 10
1.8
1.6
2
1.4
1.2
0.8
4
0.6
6
0.4
0.2
1
8
1
0.5
1
0.5
0.5
1
0.5
0
0.5
0
0.5
0.5
1
0.5
1
Figure 9.10. (a) A plot of the FE solution when f (x, y) = 4; (b) The
corresponding error plot.
As previously mentioned, we consider conforming piecewise polynomial FE spaces.
A set of polynomials of degree k is denoted by
(
)
i+jk
X
i j
Pk = v(x, y) , v(x, y) =
aij x x ,
i,j=0
2015/3/6
page 225
225
(k i + 1) =
k
X
i=0
(k + 1)
= (k + 1)2
k
X
i=0
(k + 1)(k + 2)
k(k + 1)
=
.
2
2
9.6.1
(9.38)
As there are six parameters and six conditions, we expect to be able to determine
the quadratic function uniquely. Highlights of the proof are as follows.
We just need to prove the homogeneous case v(ai ) = 0, v(aij ) = 0, since the righthand side does not affect the existence and uniqueness.
2015/3/6
page 226
226
a3
1
0
0
1
31
00
a11
00
11
23
1
0
0a
1
0
1
00
11
1
0
0
1
11
00
00
11
00
11
1
0
0
1
a2
a12
= (x x2 ) sin + (y y2 ) cos ,
such that a2 is the origin and a2 a3 is the - axis. Then v(x, y) can be written as
v(x, y) = v(x(, ), y(, )) = v(, ) = a
00 + a
10 + a
01 + a
20 2 + a
11 + a
02 2 .
Furthermore, under the new coordinates, we have
1 (, ) = + + = ,
2
6= 0,
since 1 (a ) = 1 (a ) = 0. Along the -axis ( = 0), v(, ) has the following form
v(0, ) = a
00 + a
01 + a
02 2 .
Since v(a2 ) = v(a3 ) = v(a23 ) = 0, we get a
00 = 0, a
01 = 0 and a
02 = 0, therefore,
v(, ) = a
10 + a
11 + a
20 2 = (
a10 + a
11 + a
20 )
a
10
a
20
a
11
=
+
+
= 1 (, )(, ) .
Similarly, along the edge a1 a3
1
(a13 ) = 0
2
v(a1 ) = 1 (a1 )(a1 ) = (a1 ) = 0,
2015/3/6
page 227
227
i.e.,
(a13 ) = 0,
(a1 ) = 0 .
1 1
0 = 0 ,
2 2
or
x = ay + b ,
v(x, y) = v(x, ax + b)
or
then
Thus the piecewise quadratic functions defined on two triangles with a common side are
identical on the entire side if they have the same values at the two end points and at the
mid-point of the side.
3
X
i=1
v(ai )i (x, y) 2i (x, y) 1
+
3
X
(9.39)
i,j=1,i<j
Proof: It is easy to verify the vertices if we substitute aj into the right-hand side
of the expression above,
v(aj )j (aj ) 2j (aj ) 1 = v(aj ) ,
2015/3/6
page 228
228
9.6.2
There are several ways to construct cubic basis functions in H 1 C 0 over a triangulation,
but a key consideration is to keep the continuity of the basis functions along the edges
of neighboring triangles. We recall that the degree of freedom of a cubic function in 2D
is 10, and one way is to add two auxiliary points along each side and one auxiliary point
inside the triangle. thus together with the three vertices, we have ten points on a triangle
to match the degree of the freedom (cf. Fig. 9.12). Existence and uniqueness conditions
for such a cubic function are stated in the following theorem.
a3
a331
a332
a113
a223
a1
a112
a221
a2
10, P3 (K), C 0
10, P3 (K), C 0
v(aiij ), i, j = 1, 2, 3, i 6= j
and
v(a123 ) ,
(9.40)
where
a123 =
1 1
a + a2 + a3 ,
3
aiij =
1 i
2a + aj , i, j = 1, 2, 3, i 6= j .
3
(9.41)
2015/3/6
page 229
229
Sketch of the proof: Similar to the quadratic case, we just need to prove that the
cubic function is identically zero if v(ai ) = v(aiij ) = v(a123 ) = 0. Again using local
coordinates where one of the sides of the triangle T is on an axis,
v(x) = C1 (x)2 (x)3 (x) ,
where C is a constant. Since v(a123 ) = C1 (a123 )2 (a123 )3 (a123 ) = C 31 31 13 = 0, we
conclude that C = 0 and hence v(x) 0.
With reference to continuity along the common side of two adjacent triangles, we
note that the polynomial of two variables again becomes a polynomial of one variable there,
since we can substitute either x for y or y for x from the line equations l0 + l10 x + l01 y = 0.
Furthermore, a cubic function of one variable is uniquely determined by the values of four
distinct points.
There is another choice of cubic basis functions, using the first order derivatives at
the vertices, cf. the right diagram in Fig. 9.12. This alternative is stated in the following
theorem.
Theorem 9.16. A cubic function v P3 (K) is uniquely determined by the values of
v(ai ),
v i
(a ), i = 1, 2, 3, j = 1, 2 and i 6= j,
xj
v(a123 ) ,
(9.42)
where v/xj (ai ) represents v/x(ai ) when j = 1 and v/y(ai ) when j = 2, at the
nodal point ai .
At each vertex of the triangle, there are three degrees of freedom, namely, the function value and two first order partial derivatives, so total there are nine degrees of freedom.
An additional degree of freedom is the value at the centroid of the triangle. For the proof
of the continuity, we note that on a common side of two adjacent triangles a cubic polynomial of one variable is uniquely determined by its function values at two distinct points
plus the first order derivatives in Hermite interpolation theory. The first order derivative is
the tangential derivative along the common side defined as v/t = v/x t1 + v/y t2 ,
where t = (t1 , t2 ) such that t21 + t22 = 1 is the unit direction of the common side.
9.6.3
Basis functions in H 2 C 1
Basis functions are also needed for fourth order PDE such as the 2D biharmonic equation
(9.43)
Since second order partial derivatives are involved in the weak form, we need to use
polynomials with degree more than three. On a triangle, if the function values and partial
derivatives up to second order are specified at the three vertices, the degree of freedom
would be at least 18. The closest polynomial would be of degree five, as a polynomial
v(x) P5 has degree of freedom 21, cf. the left diagram in Fig. 9.13.
2015/3/6
page 230
230
Figure 9.13. A diagram of the freedom used to determine two different fifth
order polynomial basis functions in H 2 C 1 . In addition to the previous notation, we
introduce
for values of the second derivatives; / for values of the first derivatives;
and for values of the mixed derivatives .
Theorem 9.17. A quintic function v(x, y) P5 (K) is uniquely determined by the values
of
D v(ai ) , i = 1, 2, 3, || 2,
v ij
(a ) , i, j = 1, 2, 3, i < j ,
n
(9.44)
v
(a23 ) = 0. Here again, t
is the tangential directional derivative. From the five
and n
v
conditions, we have n (x) = 0 along a2 a3 , so we can factor 21 (x) out of v(x) to get
(9.45)
where p3 (x) P3 . Similarly, we can factor out 22 (x) and 23 (x) to get
v(x) = 21 (x) 22 (x) 23 (x) C ,
(9.46)
2015/3/6
page 231
231
on two adjacent triangles are identical along the common side if they have the same values
of v(s), v (s) and v (s) at the two shared vertices. Similarly, for the normal derivative
along a common side of two adjacent triangles, we have a fourth order polynomial of one
variable v/n(s). The polynomials can be uniquely determined by the values v/n(s)
and (d/ds) (v/n) (s) at two distinct points plus the value of a v/n(s) at the mid-point.
Thus the continuity of the normal derivative is also guaranteed.
v
(aij ) at the three mid-points
An alternative approach is to replace the values of n
of the three sides by imposing another three conditions. For example, assuming that along
a2 a3 the normal derivative of the fifth order polynomial has the form
v
2
3
4
= af
f
f
f
f
00 + a
10 + a
20 + a
30 + a
40 ,
n
2 3
we can impose af
40 = 0. In other words, along the side of a a the normal derivative of
v/n becomes a cubic polynomial of one variable. The continuity can again be guaranteed
by the Hermite interpolation theory. Using this approach, the degree of the freedom is
reduced to 18 from the original 21, cf. the right diagram in Fig. 9.13 for an illustration.
9.6.4
While triangular meshes are intensively used, particularly for arbitrary domains, meshes
using quadrilaterals are also popular for rectangular regions. Bilinear functions are often
used as basis functions, and let us first consider a bilinear function space in H 1 C 0 . A
bilinear function space over a quadrilateral K in 2D, as illustrated Fig. 9.14, is defined as
Q1 (K) =
v(x, y),
o
v(x, y) = a00 + a10 x + a01 y + a11 xy ,
(9.47)
where v(x, y) is linear in both x and y. The degree of the freedom of a bilinear function
in Q1 (K) is 4.
Theorem 9.18. A bilinear function v(x, y) Q1 (K) is uniquely determined by its values
at four corners.
Proof: without loss of the generality, assume that the quadrilateral is determined
by the four corners ai : (0, 0), (x1 , 0), (x1 , y1 ) and (0, y1 ). The coefficient matrix of the
linear system of algebraic equations that determines the coefficients aij , i, j = 0, 1 is
A=
1
1
1
1
0
x1
0
x1
0
0
y1
y1
0
0
0
x 1 y1
with determinant det(A) = x21 y12 6= 0 since x1 y1 6= 0. Indeed, we have analytic expressions
2015/3/6
page 232
232
(x1 , y1 )
(0, 0)
(x1 , 0)
y
xy
x
+
,
x1
y1
x 1 y1
(9.48)
2 (x, y) =
x
xy
,
x1
x 1 y1
(9.49)
3 (x, y) =
xy
,
x 1 y1
(9.50)
4 (x, y) =
y
xy
.
y1
x 1 y1
(9.51)
On each side of the rectangle, v(x, y) is a linear function of one variable (either x or y),
and uniquely determined by the values at the two corners. Thus any two basis functions
along one common side of two adjacent rectangles are identical if they have the save values
at the two corners, although it is hard to match the continuity condition if arbitrary
quadrilaterals are used instead of rectangles or cubic boxes.
A bi-quadratic function space over a rectangle is defined by
n
Q2 (K) =
v(x, y), v(x, y) = a00 + a10 x + a01 y+
(9.52)
o
a20 x2 + a11 xy + a20 y 2 + a21 x2 y + a12 xy 2 + a22 x2 y 2 .
X
aij xi y j .
v(x, y), v(x, y) =
(9.53)
Qk (K) =
i,j=0,ik,jk
2015/3/6
page 233
2, P1 (K), C 0
233
3, P2 (K), C 0
4, P3 (K), C 1
2D
3, P1 (K), C 0
6, P2 (K), C 0
10, P3 (K), C 0
10, P3(K), C 0
2D
9, Q2 (K), C 0
4, Q1 (K), C 0
16, Q (K), C
3D
2D
18, P5 (K), C 1
21, P5 (K), C 1
4, P1 (K) C 0
10, P2(K), C
9.6.5
Other FE spaces
The diagrams in Fig. 9.15 illustrate different FE spaces over a line segment in 1D, a
triangle or quadrilateral in 2D and a tetrahedron in 3D. From these diagrams, we can find
the degree of the freedom, the polynomial basis functions and the Sobolev spaces.
9.7
We can use the FE method for time dependent problems, and there are two approaches.
One approach is to discretize the space variables using the FE method while discretizing
the time variable using some FD method. This is possible if the PDE is separable. Another
way is to discretize both the space and time variables using the FE method. In this section,
we briefly explain the first approach, since it is simply and easy to implement.
2015/3/6
page 234
234
(9.54)
(9.55)
(9.56)
where p, q, f and g are given functions with usual regularity assumptions. Multiplying
the PDE by a test function v(x, y) H 1 () on both sides, and then integrating over the
domain, once again leads to the weak form:
ZZ
ZZ
ZZ
ut v dxdy =
(qv pu v) dxdy +
f v dxdy ,
(9.57)
RR
(9.58)
M
X
j (t) j (x, y) .
(9.59)
j=1
i (t)i (x, y) , vh = a
i (t)i (x, y), vh + (f, vh )
j=1
(9.60)
j=1
and then take vh (x, y) = i (x, y) for i = 1, 2, , M to get the linear system of ordinary
differential equations in the j (t):
1 (t)
(1 , 1 )
(1 , 2 ) (1 , M )
( , )
(2 , 2 ) (2 , M )
2
1
2 (t)
..
..
..
..
..
.
.
.
.
.
M (t)
(M , 1 ) (M , 2 ) (M , M )
(f, 1 )
(f, )
2
..
(f, M )
a(1 , 1 )
a( , )
2
1
..
.
a(M , 1 )
a(1 , 2 )
a(2 , 2 )
..
.
..
.
a(M , 2 )
a(1 , M )
a(2 , M )
2 (t)
..
..
.
.
M (t)
a(M , M )
d~
+ A~
= F,
dt
1 (t)
(9.61)
2015/3/6
page 235
235
There are many methods to solve the above problem involving the system of first
order ODE. We can use the ODE Suite in Matlab, but note that the ODE system is known
to be very stiff. We can also use FD methods that march in time, since we know the initial
condition on
~ (0). Thus with the solution
~ k at time tk , we compute the solution
~ k+1
k+1
k
at the time t
= t + t for k = 0, 1, 2, .
~ k+1
~k
+ A~
k = F k ,
t
or
~ k+1 =
~ k + tB 1 F k A~
k .
(9.62)
(9.63)
Since B is a non-singular tridiagonal matrix, its inverse and hence B 1 F k A~
k can
be computed. However, the CFL (Courant-Friedrichs-Lewy) condition
t Ch2 .
(9.64)
must be satisfied to ensure numerical stability. Thus we need to use a rather small time
step.
~ k+1
~k
+ A~
k+1 = F k+1 ,
t
(B + tA)
~ k+1 =
~ k + tF k+1
(9.65)
(9.66)
then there is no constraint on the time step and thus the method is called unconditionally
stable. However, we need to solve a linear system of equations similar to that for an elliptic
PDE at each time step.
~ k+1
~k
1 k+1
1 k+1
F
+ Fk ,
+ A
~
+
~k =
t
2
2
1
1
1
~ k+1 = B tA
~ k + t F k+1 + F k .
or
B + tA
2
2
2
B
(9.67)
(9.68)
This Crank-Nicolson method is second order accurate in both time and space, and it is
unconditionally stable for linear PDE. The challenge is to solve the resulting linear system
of equations efficiently.
2015/3/6
page 236
236
9.8
Exercises
un (x, y)| = 0 .
What kind of basis function do you suggest, to solve this problem numerically?
Hint: Use Greens theorem twice.
3. Consider the problem involving the Poisson equation:
u(x, y) = 1 , (x, y) ,
u(x, y)| = 0 ,
where is the unit square. Using a uniform triangulation, derive the stiffness matrix
and the load vector for N = 2; in particular, take h = 1/3 and consider
(a) the nodal points ordered as (1/3, 1/3), (2/3, 1/3); (1/3, 2/3), and (2/3, 2/3);
and
(b) the nodal points ordered as ((1/3, 2/3), (2/3, 1/3); (1/3, 1/3), and (2/3, 2/3).
Write down each basis function explicitly.
4. Use the Matlab PDE toolbox to solve the following problem involving a parabolic
equation for u(x, y, t), and make relevant plots:
ut = uxx + uyy ,
u(x, y, 0) = 0 .
(x, y) [1 1] [1 1] ,
The geometry and the BC are defined in Fig. 9.16. Show some plots of the solution
(mesh, contour, etc.).
5. Download the Matlab source code f.m, my assemb.m, uexact.m from
http://www4.ncsu.edu/~zhilin/FD\_FEM\_Book.
2015/3/6
page 237
237
u=0
u _n = 0
u_n = - 1
u_n = 1
r = 0.5
(0,0)
u=0
1 2
x + y 4 sin x cos 4y .
4
(9.69)
using a third order quadrature formula. Choose two examples with nonlinear p(x, y)
and u(x, y) to show that your code is bug-free. Plot the solutions and the errors.
9.9
2015/3/6
page 238
238
Test Problems
1. Poisson equation on a unit circle:
u = 1 ,
u| = 0 ,
un | = 1 ,
x2 + y 2 < 1 ,
x 0,
x > 0.
x
,
u(x, y, 0) = arctan cos
2
un = 0 at y = 1 and y = 1 .
u = 0 on .
The domain is the L-shape with corners (0,0) , (1, 0) , (1, 1) , (1, 1) , (1,1) ,
and (0,1).
4. The heat equation:
u
= u .
t
The domain is the rectangle [0.5 0.5] [0.8
[0.05 0.05] [0.4 0.4]; and the BC are:
General Procedure
Draw the geometry;
2015/3/6
page 239
239
2015/3/6
page 240
240
2015/3/6
page 241
Bibliography
[1] J. Adams, P. Swarztrauber, and R. Sweet. Fishpack: Efficient Fortran subprograms for the solution of separable elliptic partial differential equations.
http://www.netlib.org/fishpack/.
[2] D. Braess. Finite Elements. Cambridge University Press, 1997.
[3] S.C. Brenner and L.R. Scott. The Mathematical Theory of Finite Element Methods.
Springer New York, 2002.
[4] R. L. Burden and J. D. Faires. Numerical Analysis. 2010, PWS-Kent Publ. Co. 2006,
Brooks &. Cool, 9 ed, 2010.
[5] D. Calhoun. A Cartesian grid method for solving the streamfunction-vorticity equation in irregular regions. J. Comput. Phys., 176:231275, 2002.
[6] G. F. Carey and J. T. Oden. Finite Element, I-V. Prentice-Hall, Inc, Englewood
Cliffs, 1983.
[7] A. J. Chorin. Numerical solution of the Navier-Stokes equations. Math. Comp.,
22:745762, 1968.
[8] P. G. Ciarlet. The finite element method for elliptic problems. North Holland, 1978,
and SIAM Classic in Applied Mathematics 40, 2002.
[9] D. De Zeeuw. Matrix-dependent prolongations and restrictions in a blackbox multigrid
solver. J. Comput. Appl. Math., 33:127, 1990.
[10] L. C. Evans. Partial Differential Equations. AMS, 1998.
[11] G. Golub and C. Van Loan. Matrix computations. The Johns Hopkins University
Press, 2nd ed., 1989.
[12] A. Iserles. A First Course in the Numerical Analysis of Differential Equations. Cambridge, 2008.
[13] Jr. J. E. Dennis and R. B. Schnabel. Numerical Methods for Unconstrained Optimization and Nonlinear Equations. SIAM, 1996.
[14] C. Johnson. Numerical Solution of Partial Differential Equations by the Finite Element Method. Cambridge University Press, 1987.
[15] R. J. LeVeque. Clawpack and Amrclaw Software for high-resolution Godunov methods. 4-th Intl. Conf. on Wave Propagation, Golden, Colorado, 1998.
241
2015/3/6
page 242
242
Bibliography
[16] R. J. LeVeque. Finite Difference Methods for Ordinary and Partial Differential Equations, Steady State and Time Dependent Problems. SIAM, 2007.
[17] Z. Li and M-C. Lai. The immersed interface method for the Navier-Stokes equations
with singular forces. J. Comput. Phys., 171:822842, 2001.
[18] Z. Li and C. Wang. A fast finite difference method for solving Navier-Stokes equations
on irregular domains. J. of Commu. in Math. Sci., 1:180196, 2003.
[19] M. Minion. A projection method for locally refined grids. J. Comput. Phys., 127:158
178, 1996.
[20] K. W. Morton and D. F. Mayers. Numerical Solution of Partial Differential Equations.
Cambridge press, 1995.
[21] Y. Saad. GMRES: A generalized minimal residual algorithm for solving nonsymmetric
linear systems. SIAM J. Sci. Stat. Comput., 7:856869, 1986.
[22] G. Strang and G. J. Fix. An Analysis of the Finite Element Method. Prentice-Hall,
1973.
[23] J. C. Strikwerda. Finite Difference Scheme and Partial Differential Equations.
Wadsworth & Brooks, 1989.
[24] J. W. Thomas. Numerical Partial Differential Equations: Finite Difference Methods.
Springer New York, 1995.
2015/3/6
page 243
Index
L2 () space, 143
p-th order, 17
243
2015/3/6
page 244
244
forward Eulers method, 72
forward finite difference, 16
forward finite difference, 16
Fourier transform (FT), 78
fourth-order compact scheme, 61, 63
Functional spaces, 141
Galerkin method, 126
Gauss-Seidel iterative method, 58
Gaussian points and weights, 171
Gaussian quadrature formulas, 170
ghost point method, 55
global basis functions, 207
Greens theorem, 199
grid, 11
grid points, 11
grid refinement analysis, 18
growth factor, 84
Index
multi-index notation, 142
natural ordering, 48
neutral stable, 101
nine-point discrete Laplacian, 63
node, 127
numerical boundary condition, 106
numerical dissipation, 103
numerical solutions, 3
ODE, 3
one-sided finite difference, 21
one-way wave equations, 97
PDE, 3
piecewise linear basis function, 203
piecewise linear function, 120
piecewise quadratic function, 225
Poincar
e inequality, 190, 202
2015/3/6
page 245
Index
245
upwinding discretization, 30
von-Neumann stability analysis, 78, 83
wave equations, 97
weak derivative, 146
weak form, 119, 201