Lecture 7
Lecture 7
1
Brian Wetton
July 8, 2018
1
www.math.ubc.ca/~wetton, [email protected]
Lecture 7
for all test functions φ ∈ L2 . The inner products above are in L2 . We can
recognize the terms on the right as the H 1 inner product of u and φ, which we
will denote as hu, φi and so have an even more compact form for (7.1):
1
Figure 7.1: Piecewise linear functions.
In this case, ai are the values U (xi ) so it makes sense to label them as Ui .
However it is not always the case that basis coefficients correspond to values of
the approximating function.
Other choices of elements in 1D are described below, and shown in Figure 7.3.
Piecewise Quadratic: and continuous on N subintervals. This is a 2N dimen-
sional subspace with an additional degree of freedom in each subinterval.
The basis vectors come in two types as shown in Figure 7.3.
Cubic Hermite: and C1 on N subintervals. This is also a 2N dimensional
subspace with two types of basis vectors.
2
Figure 7.2: A basis function for the set of piecewise linear functions.
Figure 7.3: Basis functions for the set of piecewise quadratic functions (left)
and the Cubic Hermite (right).
Aa = F
In Section 7.7 on matrix assembly and quadrature, we will see how the procedure
to construct these matrices and right hand sides can be automated. The values
of Fj will have to be approximated numerically.
If we consider the piecewise linear case on a uniform grid with spacing h,
3
the following results for K:
Rh
2 0 h12 dx = h2 if j = i
R1 1 1
Kij =
− 0 h2 dx = − h if j = i ± 1
0 otherwise
M: Rh
2 0 (1 − hx )2 dx = 2h
3 if j = i
R1 x x h
Mij = − (1 − )dx = if j = i ± 1
0 h h 6
0 otherwise
and F :
Z xj Z xj +1
1 1
Fj = (x − xj − h)f (x)dx + (xj − x + h)f (x)dx.
h xj −h h xj
In summary,
1 h
(−Uj−1 + 2Uj − Uj−1 ) + (Uj−1 + 4Uj + Uj+1 ) = Fj .
h 6
If the solution is sufficiently smooth, we can show that Fj = hf (xj ) + O(h3 )
and the middle term above is u(xj ) + O(h3 ). Dividing by h, we can see this as
a recognizable approximation of the problem.
Consider the matrix A we have constructed using a basis for any subspace
S. There is a simple argument to show that it is always invertible. Suppose
not, then there is a vector a 6= 0 such that Aa = 0. Since {Φj } is a basis,
then the function U defined by (7.4) is not zero. Reversing the process that
constructed A we have hU, Φi = 0 for every Φ ∈ S so since U ∈ S we have
hU, U i = kU k2H 1 = 0, the desired contradiction.
By the Intermediate Value Theorem, the value uave is attained at some point
x∗ in the interval. Now Z x
u(x) = uave + 1 · u0 (7.5)
x∗
4
and again using the L2 CS inequality, this time with the characteristic function
on the interval [x∗ , x], we have
p √
|u(x)| ≤ |uave | + |x∗ − x|ku0 k2 ≤ kuk2 + ku0 k2 ≤ 2kukH 1
which is the desired bound. Returning to the idea in (7.5) we have for every x1
and x2 Z x2 p
|u(x1 ) − u(x2 )| = u0 ≤ |x1 − x2 |ku0 k2
x1
which shows the (uniform) continuity of u.
Note 2. In fact, we have shown that a set of functions with a uniform bound in
H 1 is equicontinuous. This leads to the first compactness theorem in a functional
analysis course.
7.5.2 Optimality of U ∈ S
We have for the exact solution
hu, φi = (f, φ) for all φ ∈ H1
and the approximate solution
hU, φi = (f, φ) for all φ ∈ S ⊂ H1 .
Subtracting we have
hE, φi = 0 for all φ ∈ S. (7.6)
where E = U − u is the error in the approximate solution. Consider now the
size of V − u for any element V ∈ S:
kV − uk2H 1 = kV − U + Ek2H1
= hV − U + E, V − U + Ei now note that E ⊥ (V − U ) from (7.6)
= kEk2H 1 + kV − U k2H 1 .
Thus
kEkH 1 ≤ kV − ukH 1 for all V ∈ S (7.7)
and we have the remarkable result that the computed solution U is the closest
element of S to the exact solution u in the norm induced by the bilinear form
that defines the weak solution, the H 1 norm in this convenient case.
Note 3. If you consider the system in the right way, you can see that U is the
projection (in the inner product that defines the weak form of the problem) of
the exact solution u onto the subspace S and then this result is “obvious”.
Considering (7.7) we see that to proceed with the convergence proof, we just
need to show that kVh − ukH 1 goes to zero with “h” as we consider a sequence
of subspaces Sh with dimension N → ∞. We will take Vh to be a suitable
interpolant of u onto Sh in the next section.
Note 4. In the language of the Lax Equivalence Theorem, (7.7) is the stability
result, and the interpolation results below are the consistency.
5
7.5.3 Approximation in H 1
Here we restrict ourselves to piecewise linear elements as anticipated by the
section title. Let V (x) be the linear interpolation of the exact solution u on the
discrete grid points (remember that to do this, we need u to have values that
are defined pointwise, but this is guaranteed by the Theorem in Section 7.5.1).
Now consider w = u − V . This is what we want to bound and use in (7.7). It
satisfies w(xj ) = 0 at all grid points.
Consider w(x) on each subinterval [xj , xj+1 ] and let h = maxj |xj+1 − xj |.
Since w vanishes at the end points we can use Rollé’s theorem to find a point θ
in the interval for which w0 (θ) = 0. We will use arguments similar to those in
Section 7.5.1 and like there we can assume more smoothness to u as long as we
can pass the limit in H 2 . Now
Z x Z x
w0 (x) = 1 · w00 = 1 · u00 since V is linear
θ θ
Z xj+1
0 2 00 2
|w (x)| ≤ h |u |
xj
Z xj+1 Z xj+1
|w0 (x)|2 ≤ h2 |u00 |2 (7.8)
xj xj
where in the last line above we have used (7.8). Summing over all subintervals
we have
kwk22 ≤ h4 kuk2H 2 . (7.10)
Combining (7.9), (7.10), and the a priori bound (7.2) we have
kwkH1 ≤ Chkf k2
which then in (7.7) shows the first order convergence of the discrete solution
in the H 1 norm. Note that since the derivatives are approximated by constant
value on subintervals, this is the best convergence rate we can expect in H 1 .
However we will observe second order convergence in L2 , as shown below.
6
7.5.4 Approximation in L2
Let v solve the weak form of
−v 00 + v = E.
Dividing by kEk2 and using kEkH 1 ≤ Chkf k2 from the previous section we
have
kEk ≤ Ch2 kf k2
(different C), so second order convergence in L2 .
7
7.6.2 Neumann
Consider now homogeneous Neumann conditions u0 (0) = 0 and u0 (1) = 0. If we
examine the integration by parts that led to the weak form, we have for φ ∈ H 1
(no restrictions)
hu, φi − u0 φ 10 = (f, φ). (7.11)
and the middle term vanishes with the given boundary conditions. Thus, Neu-
mann conditions are “natural” in the weak formulation. The values at u(0)
and u(1) are arbitrary and must have degrees of freedom associated with them.
Because the mass and stiffness matrices will have one sided integrals for the
boundary elements, the coefficients will be modified there to account for the
boundary condition.
7.6.3 Robin
We consider the physically well-posed conditions
Note that the left hand side above defines a new inner product whose induced
norm is equivalent to the H 1 norm. We can implement and analyze the FEM
for this problem in the same way as before, adding some additional terms (near
the boundary) to the mass and stiffness matrices when generating the matrix
A.
8
solution in the norm we used for the analysis in the previous sections. Also
note that (7.13) and (7.14) involve integrals of piecewise polynomials, and so
these can be done analytically. With the ideas below it will be shown that after
transforming to the reference intervals there are only a small number of integrals
to evaluate, and their contributions added together with the appropriate scaling
of the subinterval lengths. Thus, we will concentrate the discussion on (7.12).
In most textbooks on the FEM the discussion of quadrature is quite limited,
but there are some interesting questions here.
Consider a part of the integral of (7.12) over one subinterval, transformed
to the reference interval [-1,1]. On a given subinterval, a basis function Φj (x)
is either identically zero or one of a finite number of shape functions Ψl when
transformed to the reference interval. For example, for piecewise linear elements,
it must be either Ψ1 = (1 − y)/2 or Ψ2 = (1 + y)/2. Thus we can write
Z xm+1
hm 1
Z
f (x)Φj (x)dx = f (x(y))Ψl (y)dy.
xm 2 −1
Consider now the integral on the left approximated with Gaussian quadrature
with n points and so with error proportional to the 2n’th derivative (in y) of the
integrand, g(y) = f (x(y))Ψl (y). Let us consider the case of linear elements for
which Ψl are linear polynomials and the midpoint rule (n = 1) approximation
for which the error is proportional to the second derivative. We evaluate the
second derivative of g below, remembering that dx/dy = hm /2.
dg hm df
= + f (x(y))Ψ0l
dy 2 dx
d2 h2m d2 f df
= + hm Ψ0l
dy 2 4 dx2 dx
where the Ψ00 term you expect is not there because Ψl is linear on the subinterval.
Note that the quadrature error is now O(h) rather that the O(h2 ) normally
expected from midpoint rule. This is because the derivatives of Ψ are not scaled
by h. The same argument can use used to show that with n point Gaussian
quadrature and elements with q order polynomials, the error in
Z 1
f (x(y))Ψl (y)dy
−1
is O(h2n−q ).
To examine the influence of the quadrature error on the solution, consider
modifying the right hand side function f in each subinterval to account for the
error. This is not something to implement, just a theoretical tool. From the dis-
cussion above, we know that if Gm,j is the Gaussian quadrature approximation
of Z xm+1
Im,j = f (x)Φj (x)dx
xm
then
Gm,j = Im,j + hτm,l
9
where τm,l = O(h2n−q ). On each subinterval there will be q +1 different quadra-
ture errors, each associated with one Ψl , l = 1, 2, . . . q + 1. We construct the
function r(y) on each reference interval as follows
q+1
X
r(y) = al Ψl (y)
l=1
7.8.1 Elements
Some examples of conforming elements in 2D are given below. They are pre-
sented as a list of the following:
K̂: the reference element
10
P̂ : the finite dimensional set of functions considered on K̂
Σ̂: the basis {Ψl } for P̂ , often given as the points at which shape functions are
prescribed.
F : allowable maps from K̂ to an element K in the mesh.
A. 1-
p:
K̂: unit equilateral triangle
fofYNv\-
P̂ : first order polynomials, t
P1 = span{1,-yI1 ,-X,
y2 }
Σ̂: shape functions at the three vertices.
F : isoparamteric All
oJ- VWt- of
If the mesh is composed of triangles with no hanging nodes, then the values
v
along each edge will be linear0..<1.
between the vertex values shared between adjacent
-
triangles, making the resulting approximation continuous and conforming in H 1 .
F: first order
For elliptic problems, 0- convergence in H 1 and second (tuL
in L2 results.
,
Piecewise quadratic, conforming elements on triangles
/\Io'tt.' F M x M
o..A
INb
K̂: uniteR !
equilateral 2.
triangle \ l,
t,e.Q.;1I\.J!W\. J XI "'J ' Vf.i\h.y..
P̂ : first"o.ku,
1-
F : P1 × P1 .
7
Σ̂: shape functions t
order polynomials, P2 = span{1, y1 , y2 , y12 , y22 , y1 y2 }
at the three vertices and edge mid-points. WlMf
oj.- _.f) .fr1 X 0 rfl-L
The values along each edge will be the same between adjacent triangles, since
they are quadratic along the edge length and there are three shared nodes. For
elliptic problems, second order convergence in H 1 and third in L2 results.
F; We
&e- ()AA #11 0 P 'iJlll
. CwU2 . CLt oJ1 Ol
I ft.e f\MAM-
fVIA'cL () ,'vI1:d 1:i .TVvirl.fo.1AM.
. . twJtp M L'V\..QAA
Bilinear conforming elements on rectangles
Q..
A Q..
A
F : P1 × P1 . I
The values along each edge will be the same between adjacent triangles, since
they are linear (because of the particular quadratic term that is added) along
the edge length and there are two shared nodes. For elliptic problems, first
order convergence in H 1 and second in L2 results.
I M
Q\A i!,Qo.
7.8.2
cl.M (JrM.f
Quadrature
0 1IAI c.c cJ( aN\. i
r fU'&. oYl
F
".-- k
t I'd" ( '4, j)
{::-
I
F-(y./,;{) lit 1/2 (the area of the triangle) is second order accurate (exact for functions in P1 ).
Finding higher order quadrature rules is one of the Lecture problems below.
12
:: )K ()(/) ( -
7.9 Lecture #7 Problems
Problem 1. Code up the finite element method with basic linear elements for the
problem (7.1) above. Use fourth order (two point Gauss-Legendre) quadrature
for the right hand sides. Implement the following numerical convergence test:
start with a regular grid of N points with spacing h = 1/N . Then move the
points randomly with a uniform distribution on the interval [−h/3, h/3]. This
should give points randomly between h/3 and 5h/3 apart. Compute errors to a
known solution on several resolutions with h → 0, making the grids random in
this way at every resolution. Report the test example you picked and the errors
you observed. Note: this should give you the flavour of what convergence on
unstructured grids is like. Compare the results when second order quadrature
(midpoint rule) is used.
−(b(x)u0 )0 + u = f (x)
where b is a given, smooth function with positive values. Write the weak formu-
lation of this problem and consider its approximation with the basic conforming,
linear finite element method. Identify the subinterval quadrature problem for
the stiffness matrix in this case. What order quadrature should be used here to
maintain the optimal convergence rate?
Problem 3. In the lectures we considered elements in 1D that are piecewise
cubic and C1 across subinterval boundaries. Consider C1 elements in 2D using
a triangular mesh. What is the minimum polynomial degree needed for such
elements? (use a counting argument).
Problem 4. Find the dimension of P4 (polynomials of degree 4) in 2 dimensions
(2D). Describe an element on triangles that is conforming (continuous between
elements if linear mappings from the reference element are used) and spans P4 .
Give points so that a general fourth order polynomial is determined by values at
these points (there is a matrix invertibility question to be checked here).
Problem 5. Find a third order quadrature method on the unit equilateral tri-
angle. That is, find n points (xi , yi ) and weights wi such that
Z n
X
p(x, y) = wi p(xi , yi )
Ω i=1
for all polynomials p(x) of degree 2. Your weights should all be positive. See if
you can also get quadrature of fourth and higher orders.
13