Understanding and Implementing the Finite Element Method
This page intentionally left blank
Understanding and Imple...

Author:
Mark S. Gockenbach

This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!

Understanding and Implementing the Finite Element Method

This page intentionally left blank

Understanding and Implementing the Finite Element Method Mark S. Gockenbach Michigan Technological University Houghton, Michigan

51HJTL Society for Industrial and Applied Mathematics Philadelphia

Copyright © 2006 by the Society for Industrial and Applied Mathematics. 10987654321 All rights reserved. Printed in the United States of America. No part of this book may be reproduced, stored, or transmitted in any manner without the written permission of the publisher. For information, write to the Society for Industrial and Applied Mathematics, 3600 University City Science Center, Philadelphia, PA 19104-2688. Trademarked names may be used in this book without the inclusion of a trademark symbol. These names are used in an editorial context only; no infringement of trademark is intended. Maple is a registered trademark of Waterloo Maple, Inc. Mathematica is a registered trademark of Wolfram Research, Inc. MATLAB is a registered trademark of The Math Works, Inc. and is used with permission. The Math Works does not warrant the accuracy of the text or exercises in this book. This book's use or discussion of MATLAB software or related products does not constitute endorsement or sponsorship by The Math Works of a particular pedagogical approach or particular use of the MATLAB software. For MATLAB information, contact The MathWorks, 3 Apple Hill Drive, Natick, MA 01760-2098 USA, Tel: 508-647-7000, Fax: 508-647-7001, [email protected] com, www. mathworks. com

Library of Congress Cataloging-in-Publication Data Gockenbach, Mark S. Understanding and implementing the finite element method / Mark S. Gockenbach. p. cm. Includes bibliographical references and index. ISBN 0-89871-614-4 (pbk.) 1. Finite element method. 2. Finite element method—Data processing. TA347.F5G63 2006 518'.25—dc22

ZZuOlJ IL is a registered trademark.

I. Title. 2006045012

Dedicated to Joao and all of oa& cbildReo

This page intentionally left blank

Contents Preface

1

xiii

The Basic Framework for Stationary Problems

1

1

Some model PDEs 3 1.1 Laplace's equation; elliptic BVPs 3 1.1.1 Physical experiments modeled by Laplace's equation . . . 5 1.2 Other elliptic BVPs 8 1.2.1 The equations of isotropic elasticity 8 1.2.2 General linear elasticity 10 1.3 Exercises for Chapter 1 11

2

The weak form of a BVP 2.1 Review of vector calculus 2.1.1 The divergence theorem 2.1.2 Green's identity 2.1.3 Other forms of the divergence theorem and Green's identity 2.2 The weak form of a BVP 2.2.1 Minimization of energy 2.2.2 Relaxing the PDE 2.2.3 A few details about Sobolev spaces 2.3 The weak form for other boundary conditions and PDEs 2.3.1 Neumann conditions and the weak form 2.3.2 Mixed boundary conditions 2.3.3 Inhomogeneous boundary conditions 2.3.4 Other elliptic BVPs 2.4 Existence and uniqueness theory for the weak form of a BVP 2.4.1 Vector spaces and inner products 2.4.2 Hilbert spaces 2.4.3 Linear functionals 2.4.4 The Riesz representation theorem . 2.4.5 Variational problems and the Riesz representation theorem vii

15 15 15 17 18 20 21 23 27 29 29 31 31 33 35 35 39 41 42 42

viii

Contents 2.5

2.6 2.7

Examples of ellipticity 2.5.1 The model problem 2.5.2 The equations of isotropic elasticity Variational formulation of nonsymmetric problems Exercises for Chapter 2

45 45 48 51 53

3

The Galerkin method 57 3.1 The projection theorem 57 3.2 The Galerkin method for a variational problem 59 3.2.1 Another interpretation of the Galerkin method 62 3.2.2 The Galerkin method for a nonsymmetric problem . . . . 63 3.3 Exercises for Chapter 3 63

4

Piecewise polynomials and the finite element method 67 4.1 Piecewise linear functions defined on a triangular mesh 67 4.1.1 Using piecewise linear functions in Galerkin's method . . 70 4.1.2 The sparsity of the stiffness matrix 74 4.2 Quadratic Lagrange triangles 77 4.2.1 Continuous piecewise quadratic functions 77 4.2.2 The finite element method with quadratic Lagrange triangles 78 4.3 Cubic Lagrange triangles 80 4.3.1 Continuous piecewise cubic functions 80 4.3.2 The finite element method with cubic Lagrange triangles . 83 4.4 Lagrange triangles of arbitrary degree 84 4.4.1 Hierarchical bases for finite element spaces 85 4.5 Other finite elements: Rectangles and quadrilaterals 86 4.5.1 Rectangular elements 86 4.5.2 General quadrilaterals 87 4.6 Using a reference triangle in finite element calculations 91 4.7 Isoparametric finite element methods 93 4.7.1 Isoparametric quadratic triangles 96 4.7.2 Isoparametric triangles of higher degree 100 4.8 Exercises for Chapter 4 101

5

Convergence of the finite element method 5.1 Approximating smooth functions by continuous piecewise linear functions 5.1.1 The standard refinement of a triangulation 5.1.2 Nondegenerate families of triangulations 5.1.3 Approximation by piecewise linear functions 5.2 Approximation by higher-order piecewise polynomials 5.3 Convergence in the energy norm 5.4 Convergence in the L2-norm 5.5 Variational crimes 5.5.1 Numerical integration

105 105 106 106 107 108 110 115 118 118

Contents

5.6

II

ix 5.5.2 Outline of the analysis of the effect of quadrature 5.5.3 Isoparametric finite elements Exercises for Chapter 5

Data Structures and Implementation

120 121 122

125

6

The mesh data structure 6.1 Programming the finite element method 6.1.1 Assembling the stiffness matrix 6.1.2 Computing the load vector 6.2 The mesh data structure 6.2.1 The list of nodes 6.2.2 The list of edges 6.2.3 The list of elements 6.2.4 The list of free boundary edges 6.2.5 Other fields in the mesh data structure 6.3 The MATLAB implementation 6.3.1 Generating a mesh by refinement 6.3.2 Generating a mesh from a triangle-node list 6.3.3 Assessing the quality of a triangulation 6.3.4 Viewing a mesh 6.3.5 Handling a domain with a curved boundary 6.3.6 Viewing a piecewise linear function 6.3.7 MATLAB functions 6.3.8 A summary of the notation 6.4 Exercises for Chapter 6

7

Programming the finite element method: Linear Lagrange triangles 155 7.1 Quadrature 155 7.1.1 Gaussian quadrature 155 7.1.2 Evaluating the standard basis functions on a triangle . . . 162 7.1.3 Quadrature over a square 165 7.2 Assembling the stiffness matrix 166 7.3 Computing the load vector 168 7.3.1 Inhomogeneous Dirichlet conditions 169 7.3.2 Inhomogeneous Neumann conditions 170 7.4 Examples 171 7.4.1 Homogeneous boundary conditions 173 7.4.2 Inhomogeneous boundary conditions 174 7.4.3 A more realistic example 179 7.5 The MATLAB implementation 182 7.5.1 MATLAB functions 182 7.6 Exercises for Chapter 7 183

127 127 127 131 134 134 135 135 137 137 138 139 140 142 144 147 148 150 151 152

x

Contents

8

Lagrange triangles of arbitrary degree 8.1 Quadrature for higher-order elements 8.2 Assembling the stiffness matrix and load vector 8.3 Implementing the isoparametric method 8.3.1 Placement of nodes in the isoparametric method 8.4 Examples 8.5 The MATLAB implementation 8.5.1 version2 8.5.2 versions 8.6 Exercises for Chapter 8

187 187 192 195 199 200 203 203 205 206

9

The finite element method for general BVPs 9.1 Scalar BVPs 9.1.1 An example 9.2 Isotropic elasticity 9.3 Mesh locking 9.4 The MATLAB implementation 9.5 Exercises for Chapter 9

209 209 212 213 218 220 221

III Solving the Finite Element Equations

223

10

Direct solution of sparse linear systems 10.1 The Cholesky factorization for positive definite matrices 10.1.1 The Cholesky factorization for dense matrices 10.1.2 The Cholesky factorization for banded matrices 10.2 Factoring general sparse matrices 10.3 Exercises for Chapter 10

225 225 226 228 229 233

11

Iterative methods: Conjugate gradients 11.1 The CG method 11.1.1 The CG algorithm 11.1.2 Convergence of the CG algorithm 11.2 Hierarchical bases for finite element spaces 11.2.1 Hierarchical bases for linear Lagrange triangles 11.2.2 Relationship between the stiffness matrices in nodal and hierarchical bases 11.3 The hierarchical basis CG method 11.4 The preconditioned CG method 11.4.1 Alternate derivation of PCG 11.4.2 Preconditioners 11.5 The pure Neumann problem 11.6 The MATLAB implementation 11.6.1 MATLAB functions 11.7 Exercises for Chapter 11

235 235 239 243 244 244 249 250 252 253 254 256 262 262 263

Contents 12

The classical stationary iterations 12.1 Stationary iterations 12.1.1 Matrix norms 12.1.2 Convergence of stationary iterations 12.2 The classical iterations 12.2.1 Jacobi iteration 12.2.2 Gauss-Seidel iteration 12.2.3 SOR iteration 12.2.4 Symmetric SOR 12.2.5 CG with SSOR preconditioning 12.3 TheMATLAB implementation 12.3.1 MATLAB functions 12.4 Exercises for Chapter 12

13

The multigrid method 13.1 Stationary iterations as smoothers 13.1.1 The stiffness matrix for the model problem 13.1.2 Fourier modes and the spectral decomposition of K 13.1.3 Jacobi iteration 13.1.4 Weighted Jacobi iteration 13.2 The coarse grid correction algorithm 13.2.1 Projecting the equation onto a coarser mesh 13.2.2 The projected equation and the Galerkin idea 13.2.3 The two-grid multigrid algorithm 13.3 The multigrid V-cycle 13.3.1 W-cycles and/^-cycles 13.4 Full multigrid 13.4.1 Discretization, algebraic, and total errors 13.5 The MATLAB implementation 13.5.1 MATLAB functions 13.6 Exercises for Chapter 13

xi 267 267 268 270 270 271 272 273 274 275 276 276 276 279 279 279 . . . 281 284 287 291 292 294 295 296 300 300 303 304 304 305

IV Adaptive Methods

307

14

309 311 311 312 315 317 322 324 325

Adaptive mesh generation 14.1 Algorithms for local mesh refinement 14.1.1 Algorithms based on the standard refinement 14.1.2 Algorithms based on bisection 14.2 Selecting triangles for local refinement 14.3 A complete adaptive algorithm 14.4 The MATLAB implementation 14.4.1 MATLAB functions 14.5 Exercises for Chapter 14

xii 15

Contents Error estimators and indicators 15.1 An explicit error indicator based on estimating the curvature of the solution 15.2 An explicit error indicator based on the residual 15.3 The element residual error estimator 15.4 Some final examples 15.4.1 A discontinuous coefficient 15.4.2 A reentrant corner 15.4.3 Transition from Dirichlet to Neumann conditions 15.5 The MATLAB implementation 15.5.1 MATLAB functions 15.6 Exercises for Chapter 15

329 330 334 340 345 346 346 348 349 349 349

Bibliography

353

Index

357

Preface The finite element method is the most popular general purpose technique for computing accurate solutions to partial differential equations (PDEs). Since PDEs form the basis for many mathematical models in the physical sciences and, increasingly, in other fields as well, it would be difficult to overstate the importance of the finite element method. There are a number of excellent books, such as Brenner and Scott [13], Strang and Fix [41], and Ciarlet [16], covering the theory of finite elements, but these books tend to devote little attention to the practical details of programming the algorithms. While the occasional talented student can work out a reasonable scheme without further help, I think most students will benefit from a careful explanation of data structures and specific coding strategies. This book explains how to write a finite element code from scratch. In addition, it comes with a collection of MATLAB® programs implementing the ideas presented in the book. Students can use these codes to experiment with the method and extend them in various ways to learn more about programming finite elements. In addition to a careful explanation of computer implementation (Part II), I have also included, in Part 1, an overview of the theoretical basis of the finite element method. My purpose is to give the reader a good understanding of the "big picture" without getting bogged down in the technical details of the theory. The overview also serves to define the context and notation for discussing computer codes. The finite element method reduces a boundary value problem for a linear PDE to a system of linear equations, written in matrix-vector form as KU — F, that must be solved. Part I derives this system of equations, and the algorithms in Part II show how to compute the matrix K and the vector F. Part III presents algorithms for solving KU = F efficiently even when this system is very large. The final part of the book discusses the related issues of a posteriori error estimation and adaptive error reduction. It is possible to analyze the computed finite element solution so as to estimate the errors present in the solution and to determine the regions of the computational domain where the solution can most profitably be improved. Part IV explains the various aspects of developing an adaptive finite element algorithm. Throughout the book, my goal is to provide students with a practical, working knowledge of finite elements. This knowledge should provide an excellent foundation for those who wish to delve into advanced texts on the subject.

xiii

xiv

Preface

Detailed outline of the book Although I mention the finite element method above, in fact, there are a number of finite element methods, sharing common features but with important differences. I focus my attention on the Galerkin finite element for steady-state boundary value problems (BVPs). The Galerkin method has a strong and elegant theoretical base that is accessible to undergraduate students with some knowledge of linear algebra. In Chapter 1,1 present the PDEs that are the focus of this book and discuss the physical phenomena that they model. As I mentioned in the previous paragraph, these models are steady state, that is, they describe equilibria in various systems. The Galerkin finite element method is based on three important ideas, which are presented in Chapters 2,3, and 4. The first is that a BVP presented in its classical ("strong") form can be recast in weak or variational form, as explained in Chapter 2. The weak form of a BVP is an algebraic formulation of the problem that allows the use of the Galerkin method. The Galerkin method, explained in Chapter 3, is a natural way of projecting the (infinitedimensional) equation onto a finite-dimensional approximating subspace. The result (for a linear BVP) is a (finite-dimensional) system of linear equations whose solution yields an approximate solution to the BVP. In fact, in a certain sense, the approximate solution is the best possible approximation from the given subspace. The finite element method is the use of certain approximating subspaces in Galerkin's method, namely, subspaces of piecewise polynomials. Piecewise polynomials make it (relatively) easy to form and solve the finite element equations. Chapter 4 introduces several spaces of piecewise polynomials that are commonly used in the finite element method. Piecewise polynomials are defined relative to a mesh on the computational domain. A mesh partitions the domain into simple subdomains, called elements. I will concentrate on triangular elements and two-dimensional domains, although I will describe other possibilities, such as quadrilateral elements. Chapter 5 outlines the convergence theory for Galerkin finite elements. I present the technical theorems, such as the necessary interpolation theory for piecewise polynomials, and show how they fit into the convergence theory. However, the proofs and detailed development of these techniques are beyond the scope of this book. The purpose of Chapter 5 is to show the reader what to expect from the finite element method. Part II is about the computer implementation of finite elements. I begin, in Chapter 6, with the strategy for organizing the computations. To make the discussion as concrete as possible, it initially focuses on the common case of piecewise linear functions defined on triangles (linear Lagrange triangles). The strategy described in Section 6.1 determines the information that must be stored to describe the mesh. The mesh data structure (again, restricted to linear Lagrange triangles) is carefully defined in Section 6.2. I have chosen to base the codes for this book on MATLAB, an interactive system that integrates numerical and symbolic computations with graphics and a programming language. I chose MATLAB for several reasons: 1. It is a popular tool in the numerical analysis community. 2. It provides state-of-the-art routines for handling sparse matrices; in particular, it is simple to solve a sparse system of linear equations (such as those produced by the finite element method).

Preface

xv

3. Its graphical capabilities make it easy to visualize meshes and solutions produced by the finite element method. However, the main algorithms are presented in an informal pseudocode that is independent of MATLAB. An excellent way for the student to ensure his or her understanding of these algorithms is to translate the pseudocode into some other high-level programming language, such as Fortran, C, or C++. The MATLAB codes discussed in the text can be downloaded from the following Web page: http://www.math.mtu.edu/"msgocken/fembook The basic computational algorithms are described in Chapter 7. Section 7.2 shows how to compute the stiffness matrix K, which is the finite-dimensional representation of the partial differential operator defining the PDE. Section 7.3 then shows how to compute the load vector F, which represents the right-hand side of the PDE and any nonzero boundary data. An important part of the discussion concerns incorporating various types of boundary conditions into the computations. The algorithms from Chapter 7 are extended in Chapter 8 to allow for piecewise polynomials of degree greater than one. Besides allowing for greater accuracy in approximating the solution, higher-order polynomials also make it possible to approximate a computational domain with a curved boundary with isoparametric elements. The idea of isoparametric finite elements is first presented in Section 4.7, while the implementation details are explained in Section 8.3. Chapters 7 and 8 focus on a simple model problem, because most of the essential ideas can be explained in a fairly simple setting. Chapter 9 shows how to extend the techniques to more complicated problems. Having computed the stiffness matrix and load vector, it remains only to solve the resulting matrix-vector equation and interpret the results. I ignored the issue of solving the system KU — F in Part II, assuming that the built-in solver in MATLAB would be used. However, direct solvers such as the one in MATLAB can use an unacceptably large amount of time and/or computer memory when the system is large. For this reason, iterative methods are often preferred. Part III discusses both direct and iterative algorithms for solving a large system like KU = F. One reason the finite element method is so successful is that piecewise polynomials result in a sparse stiffness matrix K, that is, a matrix in which most of the entries are zero. This makes it possible to solve KU — F even when the number of unknowns is very large. Chapter 10 gives a brief overview of direct methods for solving sparse systems. A direct method produces the exact solution (up to round-off error) in a finite number of steps. I have included Chapter 10 mainly to provide a context for understanding the advantages of iterative methods; a detailed discussion of direct algorithms is beyond the scope of this book. Chapters 11 to 13 describe a number of different iterative algorithms, which compute a sequence of approximate solutions that converges to the exact solution. Although the exact solution of KU = F is computed only in the limit (that is, in an infinite number of steps), a good iterative method can often produce an acceptable solution while using much less time and computer memory than a direct method.

xvi

Preface

Part III includes chapters on conjugate gradients (Chapter 11), Gauss-Seidel and other classical stationary iterations (Chapter 12), and multigrid algorithms (Chapter 13). Multigrid methods use a sequence of increasingly fine meshes to efficiently estimate the solution of KU — F. In the best cases, the time required for a multigrid method to produce an accurate solution is proportional to the number of unknowns. Applying the finite element method requires that a mesh be defined on the computational domain; the accuracy of the computed solution is determined by how well the exact solution can be represented on the chosen mesh. In Part IV, I discuss the various components of an adaptive finite element algorithm, which automatically creates a mesh suited for the problem at hand. Chapter 14 explains algorithms for the local refinement of meshes and a strategy for choosing the elements to be refined. In this chapter, I also present a simple but expensive error estimator and use it to form a complete adaptive algorithm. Several examples show the advantage of the adaptive approach. Many practical error estimators have been proposed. In the final chapter, I describe three such estimators; two of them are explicit and the other is implicit. The explicit estimators are inexpensive to compute and indicate which triangles should be refined to reduce the error in the computed solution. However, they do not provide a quantitative measure of the error, and are more properly called error indicators rather than error estimators. The implicit estimator presented in Section 15.3 is somewhat more expensive but acts as a true estimator. Not only does it indicate where the mesh should be refined, but it also gives an accurate measure of the size of the error. Section 15.4 contains several examples of problems with singular solutions. Adaptive finite element methods are particularly effective on such problems. Exercises are provided at the end of each chapter. Some of these are theoretical, some ask the student to apply the code provided with the text, and others require programming to extend the capabilities of the code. Beyond the given exercises, there is probably no better way to understand the finite element method than to rewrite the MATLAB codes in another programming language. In the process of translating the code into a different syntax, and particularly in testing and debugging, the details must be mastered. The bibliography lists the books and papers that I used directly in writing this manuscript. Babuska and Strouboulis [8] provide extensive reference lists with detailed bibliographical comments. Acknowledgments. I would like to thank the staff at SIAM, particularly my editors Alexa Epstein and Elizabeth Greenspan, for their roles in producing this book. The anonymous reviewers contributed many helpful suggestions, and the final form of the book owes much to their comments. In addition, Dr. A. A. Khan and Dr. B. Jadamba read the entire manuscript carefully and found a number of errors. Their help is gratefully acknowledged. Finally, I am pleased to dedicate this book to my wife Joan and to all of our children: Mary, Mark Jr., Kenric, Lydia, Hope, Nate, Jack, and the newest Gockenbachs, whose arrival is eagerly awaited. MarkS. Gockenbach [email protected]

Parti

The Basic Framework for Stationary Problems

This page intentionally left blank

Chapter 1

Some model PDEs

Finite element methods are flexible and powerful techniques for solving partial differential equations (PDEs). There are actually a number of methods that go under the name of finite elements, so it is somewhat misleading to refer, as I do in the title, to the finite element method. In this book, I describe in some detail the Galerkin finite element method for stationary (equilibrium) problems. In the first part of the book, I derive the Galerkin finite element method, showing it to be the synthesis of three powerful ideas: 1. A boundary value problem (BVP) can be transformed into an equivalent form, called the weak or variational form, that can be approached by different methods, both analytical and computational, than those that apply to the original form of the problem. 2. The Galerkin method produces the best approximation, from a given approximating subspace, to the true solution of a variational problem. Moreover, this best approximation is the solution to a finite-dimensional system of equations. 3. When the approximating subspace in the Galerkin method is chosen to be a subspace of piecewisepolynomial functions, the resulting algorithm is both efficient and effective: The system of equations can be formed and solved efficiently even when the number of unknowns is very large, and the resulting approximate solution can be highly accurate. This chapter describes the classes of PDEs to which the finite element method will be applied.

1.1

Laplace's equation; elliptic BVPs

Laplace's equation is the PDE where the Laplace operator (or the Laplacian), A, is defined by

3

4

Chapter 1. Some model PDEs

in two dimensions, or

in three. Solutions of Laplace's equation are called harmonic functions. Much of the analysis and many aspects of the numerical methods covered in this book are the same whether the equation is posed in two or three spatial dimensions, but for definiteness I will describe the two-dimensional case, with some comments about three-dimensional problems. The inhomogeneous version of Laplace's equation,

where / is a function defined on Q, is called Poisson's equation. Equations (1.1) and (1.2) are most commonly posed on a bounded domain £2 in R 2 . A domain is a connected open set. Connected means that the set consists of only one "piece," or, more precisely, that any two points in the set are joined by a curve lying entirely within the set. Open means that the boundary of the set is not a part of the set. Bounded means that the set is finite in extent, that is, that it can be enclosed by a circle with a finite radius. The boundary of £2 will be denoted by 9 £2, and the closure £2 of £2 is the union of £2 and dQ. The PDEs (1.1) and (1.2), by themselves, are insufficient to determine a unique solution; (1.1) and (1.2) have many solutions. A particular solution can be singled out by adding boundary conditions; as the reader will see, such conditions are natural in many physical problems. For example, if / is a function defined on ST2 and g is a function defined on 9£2, then

is called a Dirichlet BVP, and (1.3b) is referred to as a Dirichlet boundary condition. A Neumann BVP has the form

where du/dn is the normal derivative of u on 9 £2. If the vector n(x, y) is the outwardpointing normal vector to 9 £2 at (jc, y) e 9 £2 and V« is the gradient of u,

then the normal derivative is defined by

Before trying to solve any mathematical problem, it is helpful to determine whether a solution exists and, if so, whether the solution is unique. These are the existence and uniqueness questions. These questions are particularly important when the problem is difficult to solve; one would not want to expend a lot of effort trying to compute something that does not exist!

1.1. Laplace's equation; elliptic BVPs

5

As I explain below, a Dirichlet BVP for Laplace's or Poisson's equation has a unique solution, as long as the functions / and g are reasonable. The situation with the Neumann problem is more subtle, and the existence and uniqueness questions are interrelated: If the functions / and h are compatible, then the Neumann BVP has infinitely many solutions, any two of which differ by a constant. On the other hand, if / and g are not compatible, then there is no solution. So either existence or uniqueness fails in the case of the Neumann problem. I will explain the compatibility condition below on physical grounds and derive it in the next chapter. The implications of the lack of uniqueness for computing solutions are discussed in Section 11.5 (see also Example 7.4).

1.1.1

Physical experiments modeled by Laplace's equation

Steady-state heat flow The first application of Laplace's equation is to a flat metal plate occupying a domain ft in R2. The function u(x, y) represents the temperature at the point (x, y ) e ft. The plate is assumed to be insulated on the top and bottom, so heat can flow only in two dimensions. Such a plate has a third dimension, its thickness, but I will assume that neither the plate nor its temperature varies in the vertical direction, so that a two-dimensional model suffices. Laplace's equation, models the case of steady-state heat flow: The temperature is independent of time and the temperature gradient Vu indicates the flow of heat energy across the plate. Poisson's equation, models steady-state heat flow with heat sources and/or sinks in the plate. If f(x, y) > 0 for some (x, y) € ft, then heat energy is being added at that point at a rate f(x, y) (in appropriate units). If f(x, y) < 0, then energy is being removed at (jc, y). In this context, Dirichlet boundary conditions,

indicate that the temperature of the plate is held fixed at the boundary, specifically, that the temperature at (x, y) e 3ft is held fixed at g(x, y). The Dirichlet BVP

models the following situation: The plate is insulated on the top and bottom, the temperature at each point (x, y) in the boundary is held fixed at the given value of g(x, y), and the plate is allowed to reach equilibrium. The equilibrium temperature distribution is then given by the solution u of the BVP. Neumann boundary conditions,

6

Chapter 1. Some model PDEs

indicate that the heat flux across the boundary is the prescribed value h. The heat flux is the flow of heat energy, in units of energy per time per length. In particular, the homogeneous Neumann condition models the case of no heat flux—the boundary is insulated. Units and physical parameters The equations described above are nondimensional versions of the PDEs; describing actual materials (such as an iron plate, for example) requires physical parameters. In the heat flow problem described above, the relevant parameter is the thermal conductivity K. The thermal conductivity is the constant of proportionality in Fourier's law of heat conduction, which postulates that the heat flux is proportional to the temperature gradient:

The units of K are energy per time per length per temperature. For example, the thermal conductivity of iron near 0 degrees Celsius is K — 0.836W/(cm K). Poisson's equation is then written as From this equation, the units of / can be determined. They must be the same as the units of the left-hand side, which are energy per time per volume (for example, W/cm3). The thermal conductivity K is positive by definition. The sign of K also has an important mathematical significance, as will be shown in the next chapter. In that chapter, it will become apparent why I prefer to include the negative sign explicitly in Laplace's and Poisson's equations. If the material is heterogeneous, then the thermal conductivity varies throughout £2: K = K(X, y). The PDE becomes more complicated:

The divergence operator, denoted V-, is a partial differential operator that takes a vectorvalued function and produces a scalar-valued function as follows: If

then

The divergence of the gradient is the Laplacian:

Therefore, when K is constant,

1.1. Laplace's equation; elliptic BVPs

7

The appropriate form of the Neumann boundary condition, taking into account the physical characteristics of the material, is

Since the heat flux, by Fourier's law, is —KVu and

(1.5) simply says that the heat flux into £2 across dQ is the prescribed value h(x, y}. The Neumann BVP

indicates that heat energy is being added to or taken away from the plate in two ways: in the interior (the effect of the heat source /) and across the boundary (the effect of the heat flux h). If the temperature u is to be in equilibrium, it must be the case that the net amount of heat added is zero. This is expressed by the compatibility condition:

The first integral is the rate at which heat energy is added to the interior, while the second is the rate at which energy enters across the boundary. If the two integrals do not sum to zero, then existence fails—there is no solution—for the above BVP. This will be shown mathematically in Section 2.1.1. On the other hand, if there is a solution u, then it is clear from the equations that u + C is also a solution for any constant C (only derivatives of u appear in the PDE and the boundary condition, so adding a constant to u does not affect the equations). Therefore the solution, if it exists, is not unique. This is easy to understand on physical grounds: The compatibility condition states that no net energy is being added to or taken from the plate, but nothing in the BVP indicates how much total heat energy is in the plate. Adding a constant to the temperature u changes the total amount of heat energy without changing the temperature gradient, on which the heat flux and the BVP depend. Small vertical deflections of a membrane Another experiment modeled by Laplace's or Poisson's equation is the following: A membrane that occupies a domain Q when at rest is fixed along the boundary and subjected to a small transverse pressure. The point on the membrane originally at (x, y, 0), (x, y) e £2, moves to (x, y, u(x, >')) under the influence of the pressure. It is a simplifying assumption that the point moves only in the vertical direction. This is not exactly true, but it will be nearly true if the pressure is small enough. Dirichlet conditions in this application indicate that the boundary of the membrane is fixed. For example,

8

Chapter 1. Some model PDEs

means that the boundary is fixed in the original (horizontal) plane. An inhomogeneous Dirichlet condition, such as means that the membrane is stretched on a frame whose shape is determined by the boundary function g. In this context, a homogeneous Neumann boundary condition indicates that the boundary is free to move in the vertical direction. This condition is not physically plausible when applied to the entire membrane, but the following mixed boundary conditions describe a meaningful experiment:

Here PI and F2 form a partition of the boundary 3 £2, and the boundary conditions indicate that part of the boundary (Fj) is fixed, while the remainder (I~2) is free to move up and down. Again, I have presented the nondimensional version of the equations. When taking into account the physical characteristics of the membrane, the relevant quantity is the tension T in the membrane, and Poisson's equation takes the form

A constant T means that the tension is the same throughout the membrane.

1.2

Other elliptic BVPs

Laplace's equation is the prototypical elliptic PDE. Elliptic PDEs describe certain equilibrium phenomena and have mathematical properties that will be described in the next chapter. Here I will simply give some more examples of elliptic PDEs. 1.2.1

The equations of isotropic elasticity

An elastic membrane is said to be isotropic if its elastic response is the same in every direction. This means that if the membrane is stretched by a certain traction, or rotated about a point and then stretched by the same traction, the response in the two experiments will be the same. In two-dimensional linear elasticity, one models small planar deformations of an elastic membrane, and the unknown is the displacement of the material from a reference position. This displacement is a vector-valued quantity:

The displacement u has the following meaning: Under the applied load, the point of the membrane originally at (jc, y) moves to the location (jc + u\ (x, y), y + u^(x, y)).

1.2. Other elliptic BVPs

9

When the membrane is isotropic, it is described by two scalar quantities called the Lame moduli, n and A. The Lame moduli are constants if the membrane is homogeneous and functions of (jc, y) if it is heterogeneous. Those familiar with engineering mechanics may be accustomed to describing the elastic properties of a material in terms of Young's modulus E and Poisson's ratio v. The relationship between the Lame moduli and E and v is explored in the exercises at the end of this chapter. Since there are two unknown functions, MI and ui, there are two PDEs that together model the stretching of the membrane under an applied load. These are usually written in vector form as follows:

I will now identify each term in these equations. The gradient of a vector-valued function u is

(this is called the Jacobian matrix in other contexts). The quantity 6 is the (linearized) strain tensor, a measure of the local deformation of the membrane. The trace o f f , tr(e), is the sum of the diagonal entries of e:

The tensor a is called the stress tensor. It measures the elastic response of the membrane to the deformation described by the strain. In two dimensions, a has units of force per length; the units become force per area in three dimensions. The divergence of a tensor is the vector whose components are the divergences of the rows of the tensor:

The stress-strain relationship, expressed by (1.6b), is sometimes called the constitutive hypothesis. It is an assumption about the response of the particular material. On the other hand, (1.6a) is the balance law, which is the same for all materials. The function / in (1.6a) is the applied load, in units offeree per area. It might be more natural to express the body force in units offeree per mass, in which case the right-hand side of (1.6a) would be p~] f ( x , >'), where p is the density of the membrane, expressed in mass per area. As an exercise to verify that the notation is understood, the reader can assume that n and A. are constants and check that (1.6a)-(1.6c) are equivalent to the two scalar PDEs

10

Chapter 1. Some model PDEs

However, as I will show in later chapters, it is most convenient to work with the equations in vector form. The right-hand side of PDE (1.6a) represents a body force acting on the interior of the membrane. A body force is a force that acts at a distance, such as gravity or an electromagnetic force. Often, in a membrane problem, there is no body force. Typically the load is introduced by a traction (applied stress) on the boundary, which leads to the boundary condition Frequently the traction is applied to only part of the boundary, while the remainder is fixed (that is, not allowed to move). Therefore, a natural B VP for a membrane has mixed boundary conditions:

(F| and F2 form a partition of d£2). These boundary conditions model a simple experiment, in which part of the boundary is held motionless and the membrane is stretched by a traction applied to the rest of the boundary. It is also natural to consider the pure traction problem, in which a traction is applied to the entire boundary. This is a Neumann problem, and the comments from page 5 apply: either existence or uniqueness fails. More precisely, a solution does not exist unless the traction h satisfies a compatibility condition; if the compatibility condition is satisfied, then there are infinitely many solutions, any two of which differ by a rigid body motion (see Exercise 5). This will be explored in Section 2.5.2. The equations of isotropic elasticity for a three-dimensional elastic solid also take the form (1.6) when written in vector form. In that case, the displacement u has three components and Vw, e, and a are all 3 x 3.

1.2.2

General linear elasticity

For an elastic membrane that is not assumed to be isotropic, the stress-strain relationship is more complicated. Assuming a linear relationship, there exists a 4-tensor A = Aijki such that that is,

In Exercise 3, the reader is asked to show that (1.6b) is a special case of (1.8). The tensor A is assumed to satisfy the symmetry conditions

1.3. Exercises for Chapter 1

11

as well as the condition

where the dot product of two 2-tensors 6, a is defined by

Exercise 4 discusses assumptions (1.9a) and (1.9b). The third symmetry condition, (1.9c), results from the assumption that the material in question is not merely elastic but hyperelastic. For a discussion of hyperelasticity, see Gurtin [24]. Condition (1.10) is natural in many settings; for example, Exercise 9 explores it for isotropic elasticity. Mathematically, it guarantees that the resulting PDE is elliptic, as will be shown in the next chapter. The boundary conditions described above for an isotropic membrane have the same meanings for an anisotropic membrane. Once again, the equations for a three-dimensional elastic body have exactly the same form as for a two-dimensional elastic membrane, with the indices describing the tensors taking the values 1,2,3 instead of just 1,2.

1.3

Exercises for Chapter 1

1. Write the expression V • (K Vw) explicitly in terms of partial derivatives and show that

2. Show that (1 .6) is equivalent to (1 .7) when JJL and X are constant. 3 . Show that ( 1 .6b) can be expressed in the form (1.8). What is the tensor A? (Notice that a general 4-tensor on two-dimensional space is determined by the 24 = 1 6 entries Aiikt. However, the symmetry conditions (1.9) imply that such an A has only six independent entries, namely, 4.

(a) Show that if A is a 4-tensor, then Ae = Ae for all symmetric 2-tensors e, where A is defined by Aijki — (A/;*/ + A ( / /^)/2 for all /, j, k, I. It follows that there is no loss of generality in assuming (1.9a). (b) Show that if (1.9a) holds and a = At is symmetric for each symmetric e, then (1.9b) must hold. (Note: The symmetry of the stress tensor a follows from the principle of conservation of angular momentum; see Gurtin [24, page 101].)

5. The purpose of this exercise is to determine all displacements u with the property that the corresponding strain 6 is zero. Since 6 measures the local deformation of the material, it would appear that rigid displacements, arising from translations and rotations of the membrane, would lead to zero strain. However, e is the linearized strain, or the linear approximation to the actual strain, so this is not quite correct.

12

Chapter 1 . Some model PDEs (a) Show that € is zero if and only if u has the form

where 0. In the language of Section 1.2.1, this means that a — TI, where / is the identity, so that the tension is av = TV in every direction v. (a) Show that if the displacement u is given by

(a pure expansion; see Exercise 6), then a = TI. (b) Show that (1.14) is a solution to the traction problem

9. Show that if and only if JJL > 0 and /z + A. > 0 (that is, if and only if the shear and bulk moduli are positive).

1

The formulas for £ and v in terms of n and X are specific to a two-dimensional model. For a three-dimensional elastic body, the relationships are

This page intentionally left blank

Chapter 2

The weak form of a BVP

In this chapter, I show how to rewrite a BVP in its weak or variational form, from which the finite element method is derived. The first example will be the model problem

where Q. is a bounded domain in R 2 . Later in the chapter, the calculations will be extended to more complicated PDEs and different boundary conditions. Deriving the weak form of (2.1) requires the use of some vector calculus.

2.1 Review of vector calculus 2.1 .1 The divergence theorem The main result from vector calculus that we need is the divergence theorem, which is the multidimensional analogue of the fundamental theorem of calculus. In the following discussion, I describe the results in two dimensions, but the beauty of vector notation is that the results hold without change in three or more dimensions. If £1 is a domain in R2 with a smooth or piecewise smooth boundary and F is a vector field defined on £2, then the divergence theorem states that

where n is the outward-pointing unit normal vector to dQ. (The normal vector is a function of (x, y) € dQ: n = n(x, y).) The integral on the left can also be written as a double integral,

15

16

Chapter 2. The weak form of a BVP

and can also be referred to as an area integral. The integral on the right is an integral over the boundary of £2, which is a curve, and thus can be referred to as a line integral. In order for the divergence theorem to hold, the vector field F must be smooth enough. By taking the vector field F to be of the form

it follows from the divergence theorem that

where n\ is the first component of the outward-pointing unit normal vector. Similarly,

The divergence theorem relates a quantity defined on the boundary to another quantity defined on the interior of the domain. This explains why the divergence operator appears in the PDEs described in the previous chapter. An example is the steady-state heat equation:

It is derived by writing the total amount of heat entering an arbitrary subdomain a> c £2 in two ways: in terms of the heat source or sink /, and in terms of the heat flowing across the boundary, due to the heat flux — KVM. The two must sum to zero, since the temperature is assumed to be in equilibrium:

The divergence theorem is then invoked, yielding

Since this holds for every subdomain a> c £2, a little analysis shows that the PDE

must hold. Although this derivation is sketchy, I hope it illustrates the connection between the divergence theorem and many common PDEs and also explains why the divergence and Laplace operators are fundamental.

2.1. Review of vector calculus

17

The compatibility condition for the Neumann problem In the previous chapter, I described the compatibility condition for the pure Neumann problem

Mathematically, the compatibility condition follows from the divergence theorem. If u is a solution to (2.5), then

Therefore,

which is the compatibility condition given in the previous chapter.

2.1.2

Green's identity

The weak form of a BVP is derived using Green's identity, which is the multidimensional analogue of integration by parts. To understand Green's identity, it is useful to review integration by parts, which is obtained from the product rule for differentiation and the fundamental theorem of calculus:

Green's identity follows from the following product rule in multiple dimensions:

This rule can be derived, using the ordinary product rule, by writing out the left side in coordinates (see Exercise 1.3.1).

18

Chapter 2. The weak form of a BVP

Green's identity is obtained from (2.6) by integrating both sides over £2 and applying the divergence theorem:

Replacing Vw • n with du/dn and rearranging yields Green's (first) identity:

In Section 2.2, I will show how (2.7) is used. As in the case of the divergence theorem, the primary use of Green's identity is not to evaluate specific integrals, but rather to derive useful formulas.

2.1.3

Other forms of the divergence theorem and Green's identity

Equations (2.3) and (2.4) lead to the following identities, which look very much like integration by parts in one dimension:

These formulas will be essential in the next section. The reader will recall from Section 1.2.1 that the divergence of a tensor is computed by taking the divergence of each row of the tensor. Since the integral of a vector-valued function is computed by taking the integral of each component of the function, the following version of the divergence theorem is valid:

In this formula, a is a 2-tensor:

I will need a version of Green's identity that applies to the integral

where v is a vector-valued function. Exercise 3 asks the reader to verify that if a is a 2-tensor and v is a vector, then

2.1. Review of vector calculus

19

When a is symmetric (o\2 — a2i), as is the case when a is a stress tensor, then and

and thus The reader will recall from Section 1.2.1 that €v is the strain tensor associated with the displacement v. The dependence of €v on v is explicitly indicated, because shortly I will refer to two displacements « and v and their associated strain tensors. I can now derive the needed extension of Green's identity (still assuming that a is symmetric):

Since a is assumed to be symmetric, holds, yielding the desired extension of Green's identity:

If a = au is the stress tensor arising in the linear elasticity model, then a,, = A€U holds and the first integral on the right in (2.10) can be written as

This yields

It should be noticed that the 4-tensor A can be either a constant or a function of (x, y); (2.11), written as it is, holds in either case. It will be useful to also write (2.7) in a form that allows for a nonconstant coefficient:

The reader can verify that (2.12) follows from the product rule and the divergence theorem. For more details about the vector calculus reviewed in this section, see Kaplan [26], which gives a straightforward introduction. An alternative at the same level is Greenberg [22]. A more advanced treatment can be found in Marsden and Tromba [30].

20

2.2

Chapter 2. The weak form of a BVP

The weak form of a BVP

This section introduces the weak form of a BVP, one of the key ingredients of the finite element method. I will begin with the following Dirichlet problem:

If / is continuous and u is a solution of (2.13), then it is natural to expect that u and its partial derivatives of orders one and two are all continuous on Q, and, of course, u is zero on dQ. The space Ck(Q) is defined to be the set of all real-valued functions u defined on £2 with the property that u and its partial derivatives up to order k are all continuous on Q. A solution to (2.13) is sought in the subspace

(the subscript "D" stands for "Dirichlet"). If u is a solution to (2.13), then

and therefore, for any function v defined on Q, multiplying both sides of the PDE by v yields Since the two functions —V • (/cVw) v and fv are equal on £2, their integrals over £2 must agree:

In this context, the function v is referred to as a test function. The idea is to check whether the PDE holds in the (weighted) average sense over £2, using the test function v to define the weights in the average. Obviously, just because (2.14) holds for a particular test function v is no reason to think that the PDE (2.13a) holds. However, as I will now explain, if (2.14) holds for all test functions v from a sufficiently large set, then (2.13a) must hold. The ball of radius 8 centered at (JCQ, yo) is denoted BS(XQ, yo):

Suppose (jco, yo) e £2 and 8 > 0 is small enough that B$(XQ, yo) is contained entirely in £2. Consider any function v e C2D(£l) with the following properties:

2.2. The weak form of a BVP

21

It is not difficult to show that many such functions v exist; in fact, I construct such a function in Section 2.2.2. But then

is just a weighted average of/ over the disk BS(XQ, >>o), and similarly

is a weighted average of — V • (K Vw) over the same disk. If 8 is very small, then

and

Moreover, in the limit as 8 -> 0, these become exact equations. Therefore, if the space of test functions contains all such functions v, and (2.14) holds for all test functions, then the original PDE must hold at every (XQ, jo) € £2. By the above reasoning, it is sufficient to take the space of test functions to be C2D(£l) (which contains the above-described test functions, as well as many others). Therefore, (2.14) holds for some u e C2D(£l) and for all v e C^(£2) if and only if u satisfies the BVP (2.13). The next step is to apply Green's identity to the left-hand side of (2.14):

(the boundary integral vanishes because v is zero on 3£2). This leads to the weak form of BVP(2.13):

As 1 have argued above, (2.13) and (2.15) are equivalent: A function u e C2D(Q) satisfies one if and only if it satisfies the other. Problem (2.15) is also referred to as a variationalproblem and as the variationalform of (2.13). Next I want to explain the reasons for using the terms "variational" and "weak" to describe (2.15), since these reasons are quite instructive.

2.2.1

Minimization of energy

When the PDE (2.13a) models a mechanical system in which u is the displacement and / is an external body force, the total potential energy of the system is

22

Chapter 2. The weak form of a BVP

where £Q is some constant. The state of equilibrium of the system corresponds to the displacement u that minimizes the potential energy. This may be a familiar idea, but here it is shown mathematically that the u that minimizes J is the same u that solves (2.15) (and hence the BVP (2.13)). In the physical problem modeled by (2.13), only displacements u that satisfy the boundary condition (2.13b) are admissible. If u and w are two admissible displacements (that is, if u, w e C2D(Q)) and v — w — u (so that w = u + u), then v is also in C2D(£t). Mathematically, this reflects the fact that C2D(Q) is a vector space. Adding or subtracting two vectors in the space produces another vector in the same space. A direct calculation shows that

The parameter K is positive and

provided v is a nonconstant function. Because of the boundary conditions, the only constant function in C2D(£2) is the zero function, so if v is a nonzero displacement (that is, if u; / w), then

Therefore, if and only if

(see Exercise 6). This shows that u minimizes J over C2D(£l) if and only if u satisfies (2.15), the variational form of the equation. This is an interesting result from the physical point of view—mechanical equilibrium corresponds to minimal potential energy. However, I promised to explain the reason for the term "variational form." From basic calculus, the derivative of J ought to be zero at the minimizer. The formula

shows that

is the directional derivative of J at u in the direction of v.2 In somewhat old-fashioned language, this directional derivative is referred to as the (first) variation of J. Thus the variational form of the BVP simply states that, at the solution a, the first variation of the potential energy is zero in every direction—hence the term "variational form." 2

Equation (2.20) expresses J(u + v) as /(«) + (a term linear in v) + (a term quadratic in v). The linear term must be the directional derivative of J.

2.2. The weak form of a BVP

2.2.2

23

Relaxing the PDE

The original PDE, suggests that the solution u should have partial derivatives up to order two—that is, that u should be twice differential)le. On the other hand, the variational form (2.15) refers only to the first derivatives of u. Similarly, in the classical way of looking at things, it is expected that the right-hand-side function / be continuous over £2. However, in the variational form, it is only necessary that / be integrable (or, more precisely, that / times any test function be integrable). For this reason, (2.15) is referred to as the weak form of the original BVP, which can be called the strong form by contrast. When working with the weak form of the BVP, it is natural to make the weakest possible assumptions on the functions involved, so as to include as many cases as possible in the analysis. For this reason, the Sobolev spaces are introduced. Sobolev spaces In classical theory, all necessary partial derivatives are assumed to exist and be continuous, and this assumption leads to the spaces Ck(Q) defined above. The partial derivatives are defined as in calculus; for example,

However, in the weak form of a BVP, it is not necessary that all functions and derivatives be continuous. Moreover, there is another way to define partial derivatives that is actually more natural and useful in the context of the weak form. To explain this other definition of partial derivative, I must introduce some new concepts. First of all, if u is a function, its support is the closure of the set on which u is nonzero: If u is defined on £2 and supp(w) is a compact subset (that is, a closed and bounded subset) of £2, then u is said to be compactly supported in £2. A function compactly supported in £"2 is zero on and near the boundary of £2. The space C£°(£2) is defined to be the set of all functions that are infinitely differentiable on Q and compactly supported in £2. The condition that u e C%°(Q) is quite strong, and the reader might wonder if, in fact, there are any functions in this space at all. Such a function must have the property that it and all of its partial derivatives go to zero as (jc, >') approaches the boundary of supp(w). To settle this question, I will show how to construct a family of functions in CQ°(^). Let (XQ, >'o) e £2 and 8 > 0 be sufficiently small that B$(XQ, >'o) C £2, and define 0 : £2 -> R by

Then, since

24

Chapter 2. The weak form of a BVP

it follows that 0(;c, y) -> 0 as (jc, y) —> dB$(xo, yo). Moreover, each partial derivative of 0, inside B$(XQ, yo), consists of a rational function times the same exponential, which is enough to show that each partial derivative converges to zero as (jc, y) —> dBs(xo, jo). Thus0eC 0 °°(fi). In fact, defining

it follows that and thus y is a test function of the special type described on page 20. Using functions like 0, it is possible to generate lots of elements of CQ°(^) (although I will not show how to do it). In fact, any function u e C(£2) can be approximated arbitrarily well, in a sense to be described below, by functions in C£°(£2). Now I can explain an alternate definition of partial derivative. Suppose for now that u e C1^)- Integrating by parts, that is, applying (2.8a), yields

for all smooth test functions v. If v e C0°(£2), then the boundary integral is zero (since v is identically zero on 3 £2), and thus

In other words, du/dx is that function g satisfying

Although I will not prove it formally, there can be only one such function, and thus, for u e Cl(tt), g - du/dx if and only if (2.22) holds. Therefore, (2.22) can serve as an alternate definition of the partial derivative du/dx of u e Cl(£2). A similar definition is valid for du/dy. The advantage of this alternate definition is that it can be extended to many functions that are not differentiable everywhere in the sense of (2.21). DEFINITION 2.1. Suppose u is a real-valued function defined on a domain £L in R2, and that u is integrable over every compact subset ofQ. (In this case, u is called locally integrable.) If there exists another locally integrable function g defined on £2 such that

holds, then u is said to be weakly differentiable (with respect tox) andg is called the weak partial derivative (with respect to jc) ofu. The weak partial derivative with respect to y is defined similarly. Weak derivatives are denoted by du/dx and du/dy, just as are strong derivatives.

2.2. The weak form of a BVP

25

Here is an example of a function that is not differentiable over all of £2 but has a weak partial derivative. EXAMPLE 2.2. Let £2 be the unit square, Q — (0, 1) x (0, 1), and define

The following argument shows that u is weakly differentiable with respect to x and that

Suppose v e C£°(£2). Then

On the other hand,

This proves that g is a weak partial derivative with respect to x ofu on £1. The previous example may lead the reader to believe that there real ly is not much to the definition of the weak derivative. After all, in Example 2.2, the function u is differentiable (in the classical sense) except on a line segment, and the weak derivative is found by simply computing the derivative of a, where it exists, in the classical manner. However, the following example presents a function that is differentiable except on the same line segment and yet is not weakly differentiable.

26

Chapter 2. The weak form of a BVP

EXAMPLE 2.3. Let Q be the unit square, Q = (0, 1) x (0, 1), and define

Ifv e C°°(Q), then

00000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000 00000000

0000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000

must hold (since a line segment has zero area). (The same formula (2.22) can be used to extend the notion of derivative to functions such as the u in this example; however, such derivatives are not representable by locally integrable functions and are beyond the scope of this book.) The assumptions that must be made on the functions appearing in the variational form can be stated in terms of weak derivatives. Recall that it is desirable to make the weakest assumptions possible, so as to encompass as many cases as possible. For this reason, it is assumed that u and v are only weakly differentiate. Moreover, since only first derivatives appear in (2.15), it is assumed that u and v have weak partial derivatives of the first order. Therefore, whereas in the strong form (2.13) u must have continuous derivatives up to order two, in the weak form (2.15) it need only have weak derivatives of order one. This is indeed a considerable relaxation of the requirements on u. There is one restriction, however, that is necessary. The definition of weak derivative requires only that du/dx and du/dy be (locally) integrable. In the variation equation (2.15), though, it must be possible to integrate the products

2.2. The weak form of a BVP

27

In particular, v = u must be allowed, which shows that du/dx and du/dy must be squareintegrable:

In the same way,

must be finite, which also suggests that / and v should be square-integrable (if v — /, for example). It is therefore convenient to define the space

1 will require that /, the right-hand side of the PDE, belong to L 2 (£2). The solution u of (2.15) must satisfy

and the test functions must satisfy the same conditions. These conditions define the Sobolev space H](Q):

Finally, it is necessary that both the solution u and all of the test functions v satisfy the Dirichlet boundary conditions. For this reason, it is convenient to introduce the following space: The space HQ (Q) is another example of a Sobolev space. In defining the above spaces, 1 have been rather cavalier about some important mathematical details. For the interested reader, I discuss these details in Section 2.2.3. The variational form of (2.13) can now be defined in terms of the Sobolev space //o'(«):

The right-hand-side / is assumed to belong to L 2 (£2). It should now be clear why the variational form is also called the weak form; the requirements of the right-hand-side / and the solution u have been considerably weakened over the classical strong form (2.13).

2.2.3

A few details about Sobolev spaces

In the above explanations, 1 have not attempted to give a rigorous definition of the spaces L 2 (ft), #'(£2), and HQ(&)\ to do so would lead us far afield. For the interested reader, I will sketch a few of the omitted details and give some references for further study.

28

Chapter 2. The weak form of a BVP

First of all, to define L2(£2), it is important to use the correct definition of the integral, though for purely technical reasons. The integral defined in the usual undergraduate calculus course is the Riemann integral. It is the integral of choice in introductory calculus courses because its definition is relatively simple compared to that of its competitors. However, the Riemann integral suffers from some serious technical shortcomings, most notably that it is not difficult to construct a sequence of Riemann integrable functions converging (in a natural sense) to a function that is not Riemann integrable. This property makes the Riemann integral largely useless for constructing a satisfactory theory of PDEs. The Lebesgue integral is preferred over the Riemann integral for precisely these theoretical reasons. I will not explain the definition of the Lebesgue integral, for the following reason: Any function that is Riemann integrable over a bounded domain is also Lebesgue integrable, and its Riemann and Lebesgue integrals are equal. The Lebesgue integral merely allows us to integrate certain singular functions that, for theoretical reasons, must be included. I will explain a bit more about this in Section 2.4. Functions that are regular enough to integrate are called (Lebesgue) measurable. The Lebesgue integral is based on the notion of Lebesgue measure of sets. Lebesgue measure corresponds to the notion of area for subsets of R2 that are regular enough that their areas can be defined. However, Lebesgue measure extends to very complicated sets. As in the case of integrals, this extension is needed mainly to allow for a satisfactory theory. My favorite reference for Lebesgue measure and integration theory is Folland's text on real analysis [20]; another text that is perhaps somewhat more accessible to the beginner is the real analysis text by Roy den [36]. When speaking of the space L 2 (£2), it is important to realize that two functions / and g with the property that /Q \f — g\ — 0 must be regarded as equal. Functions / and g have this property whenever f ( x ) = g(x) except on a set with Lebesgue measure zero. For this reason, when describing a function that belongs to L 2 (£2), it is acceptable to leave the function undefined on a set of measure zero. I did this, in fact, for the weak derivative of the function u in Example 2.2. I left du/dx undefined on the line segment corresponding to x = 1 /2; this line segment clearly has area (and hence measure) zero. Any values could be assigned to du/dx on that line segment without changing the function as an element of L 2 (ft). A corollary of the discussion in the previous paragraph is that a well-defined function u e L2(£l) cannot be unambiguously restricted to a subset of measure zero. This is an important fact in the theory of BVPs, since, for a bounded domain £2 c R2, dQ. is a subset of measure zero. The space Hl(Q) and its subspace HQ(&) are just two examples of Sobolev spaces. For a bounded domain £2 and any positive integer k, the Sobolev space Hk(£2) is defined to be the space of all integrable functions u defined on £2 with the property that u and its partial derivatives up to order k all belong to L 2 (£2). In this context, L 2 (£2) can be called //°(£2). It is also possible to define Hs(£2) for fractional values of s, but there is more than one way to do this, and the development is rather complicated. In developing a rigorous theory of BVPs using weak derivatives, it is necessary to know how much (weak) differentiability is necessary for a function to have well-defined boundary values. The answer to this question is called the trace theorem, which states (in its most refined form) that restricting an HS(Q) function (£2 c R 2 ) to a one-dimensional curve F produces a function in Hs~l/2(r). Therefore, in particular, an Hl (£2) function has

2.3. The weak form for other boundary conditions and PDEs

29

boundary values belonging to H]/2(d£2) c L 2 (9£2), and hence it makes sense to talk about an //'(£2) function as a solution to (2.23) or (2.32). On the other hand, if u e //'(£2), then the components of the gradient Vw belong to L 2 (ft), which implies that du/dn is not well-defined on d£l. In this regard (and others) the analysis of a Neumann problem is more delicate than that of a Dirichlet problem. 1 will have more to say about this in Section 2.5. A comprehensive reference for Sobolev space theory is the book by Adams [1]. Most modern texts on PDEs and finite elements contain a development of this theory; the text by Brenner and Scott [13] is particularly concise and accessible.

2.3 The weak form for other boundary conditions and PDEs 2.3.1

Neumann conditions and the weak form

Next I will derive the weak form of the Neumann problem

There is an interesting distinction between the weak forms of a Dirichlet problem and a Neumann problem: The Dirichlet condition appears explicitly in the weak form (2.23) (in the definition of the space //0'(£2)), but, as I will now show, the Neumann condition does not appear explicitly in the weak form of (2.24). I assume that u satisfies (2.24). This presupposes that u has some extra smoothness beyond the requirement that u e //'(£2), both because the left side of (2.24a) involves second derivatives of u and because du/dn is not well-defined for an arbitrary #'(£2) function. Then

The reader should notice the use of Green's identity in the above calculation, and also the fact that the boundary integral vanishes because of the Neumann boundary condition satisfied by the solution u. (In the Dirichlet case, it was the boundary condition on the test function v that caused the boundary integral to vanish.)

30

Chapter 2. The weak form of a BVP The weak form of (2.24) is thus defined to be the following problem:

As I showed above, any solution of (2.24) is also a solution of (2.25). However, the reader might well question whether the converse is true. After all, (2.25) does not mention the Neumann boundary condition and so it is not obvious that a solution of (2.25) will necessarily satisfy the Neumann condition. It does, though, provided the solution u is smooth enough that Green's identity applies and Vw can be restricted to 3£2. Suppose that u e Hl(Q) is a solution of (2.25). Then, since //J(^) C Hl(Q),

Applying Green's identity to the left side yields

Since v e HQ (£2), the boundary integral vanishes, yielding

Now, applying the reasoning that I sketched in the Dirichlet case, it follows that the PDE (2.24a) must hold (notice that the type of test function that I discussed on page 20—whose support is a disk BS(XQ, yo)—belongs to the space HQ (£2)). To show that the Neumann condition (2.24b) also holds, I return to (2.25) and apply Green's identity once again to obtain

But now I know that

(since — V • (K Vw) and / are equal on Q). Therefore,

must hold. Although the precise argument is rather technical, it should be believable that (2.26) can hold for all v e Hl(£l) only if du/dn is zero on d£l (the reader should bear in mind that K is strictly positive). Since Dirichlet conditions must be explicitly imposed in the weak form, while Neumann conditions are implied even though not explicitly imposed, Dirichlet conditions are often called essential boundary conditions, while Neumann conditions are called natural boundary conditions.

2.3. The weak form for other boundary conditions and PDEs

2.3.2

31

Mixed boundary conditions

A BVP can have both Dirichlet and Neumann boundary conditions, with the two different conditions applied to different parts of the boundary. If 9£2 = r\ U F2 is a partition of 9£2 (so that F| n F2 = 0), then the following BVP is said to have mixed boundary conditions:

According to the above discussion, the Dirichlet condition is essential, while the Neumann condition is natural. The space of test functions is therefore defined to be

The Neumann condition is not mentioned in this definition, since it is a natural boundary condition. The derivation of the weak form follows the now familiar pattern:

The boundary integral can be written as

The first integral on the right vanishes because the test function v is zero on F|, and the second vanishes when u is a solution of (2.27), since du/dn is then zero on F2. The weak form is therefore the same as before,

except that the space of test functions has changed. Exercise 7 asks the reader to show that if u satisfies the weak form, then it also satisfies the strong form (2.27), including the Neumann boundary condition.

2.3.3

Inhomogeneous boundary conditions

In homogeneous Neumann conditions

I will now explain how inhomogeneous boundary conditions affect the weak form of a BVP, beginning with the inhomogeneous Neumann problem

32

Chapter 2. The weak form of a BVP

where h is a given function defined on 912. The derivation of the weak form proceeds as follows:

Thus the weak form of (2.29) is as follows:

The weak form (2.30) is the same as it was for homogeneous Neumann conditions, except that the right-hand side has been changed. Inhomogeneous Dirichlet conditions The case of inhomogeneous Dirichlet conditions is a bit more complicated. The BVP is

where g is a function defined on 9£2. The function g must satisfy some regularity conditions, and I will assume that there is a function G e Hl(£l) such that G = g on d&. It turns out that the correct space of test functions is still HQ (£2); however, since the desired solution u does not satisfy homogeneous Dirichlet conditions, it cannot be the case that u € HQ (£2). Instead, the function w = u — G is zero on 9£2, and thus the solution has the form u = w + G, where G is assumed to be known and it; 6 HQ (£2) is unknown. Here is the derivation of the weak form:

Thus the weak form of (2.31) is the following:

2.3. The weak form for other boundary conditions and PDEs

33

The reader will notice that (2.32) has the same form as (2.23), except that the right-hand side has changed. In general, it might be difficult to find a suitable function G satisfying the Dirichlet condition G — g on 3 £2 (in a BVP, only g is given, not G). However, in the context of the finite element method this is easy. I will show, in Section 4.1.1, how to produce a function G that (approximately) satisfies the inhomogeneous Dirichlet condition. It is left to the reader to derive the weak form of the BVP

with inhomogeneous mixed boundary conditions.

2.3.4

Other elliptic BVPs

The weak form of the other elliptic BVPs presented in Chapter 1 can be derived using the alternate version of Green's identity derived in Section 2.1.3: If R is continuous, then / is certainly in L2(a, b) (since a continuous function on a closed and bounded interval is bounded). The function / can be approximated by a Euclidean vector by means of sampling. Given a positive integer n, a grid a = XQ < x\ < KI < • • • < xn = b is defined on [a, b] by Xj — a + i AJC, AJC = (b — a)/n. The vector F e R" is then defined by

Clearly F can be said to approximate /, as Figure 2.1 shows. If / and g are two such continuous functions and F and G are the corresponding vectors in R", then the dot product of F and G is

Chapter 2. The weak form of a BVP

38

Figure 2.1. Approximating a function f ( x ) by a vector F e R". This cannot define the inner product of/ and g, since F • G depends strongly on the grid. However, as the grid is refined, the Riemann sum

which is just F • G weighted by AJC, converges to a quantity that is independent of the grid, namely,

Therefore, it seems consistent (with the Euclidean dot product) to define the L2(a, b) inner product by

It can be shown that if / and g belong to L2(a, b), then (2.40) is well-defined (even if / and/or g are not continuous). It can also be shown that (2.40) satisfies the definition of an inner product. If £2 is a domain in R2 (or R", in general), then the L2 inner product is defined by

The corresponding L2-norm is defined by

2.4. Existence and uniqueness theory for the weak form of a BVP

39

The Sobolev space //' (Q) is defined in terms

(where the partial derivatives are weak derivatives), and therefore so is its inner product:

The Sobolev space HQ (Q) is a subspace of Hl (£2). The concept of subspace will be very important, particularly in the next chapter, so its definition is given here: DEFINITION 2.6. Suppose V is a vector space. A subset WofV is called a subspace ofV if the following properties hold: 1. The zero vector belongs to W;

The last two properties can be expressed by saying that W is closed under addition and scalar multiplication. A subspace is a vector space in its own right.

2.4.2

Hilbert spaces

My goal in this section is to describe the theory that guarantees that certain variational problems have unique solutions. There is a fundamental property of the spaces H](£2) and HQ (Q) (and other Sobolev spaces) that is needed for this theory: Sobolev spaces are complete. The property of completeness is rather abstract, but I can give an example of it that is easy to understand. The equation jc2 = a can be solved for each a > 0 because the real numbers are complete—there are no holes in the real number line. Thousands of years ago, it was thought that all numbers could be represented as ratios of integers, that is, as rational numbers. However, the Pythagorean theorem suggests that there ought to be a number whose square is 2 (this number is the length of the hypotenuse of a right triangle with two legs of length 1), and it is easy to prove that no rational number jc can satisfy x1 = 2. The set of rational numbers Q is not complete. This example suggests that the concept of completeness might be important for a theory describing when certain equations are guaranteed to have solutions. What does it mean for a space to be complete? Thinking about the previous example leads to the right description. The following sequence of numbers converges to a solution tojc 2 = 2:

40

Chapter 2. The weak form of a BVP

This sequence consists of rational numbers, but the discussion above shows that the sequence cannot converge to a rational number. Therefore, Q is not complete because there is a sequence in the set that "ought" to converge, but there is no limit for the sequence in the set itself. The property of a complete space is that every sequence that ought to converge actually does converge to an element of the space. It remains only to define what is meant by a sequence that ought to converge. The idea is that terms in the sequence get closer and closer together the farther out in the sequence they are. I will give the definition in a normed vector space. DEFINITION 2.7. Let {vn} be a sequence of vectors in a normed vector space V. The sequence is called Cauchy if, given any € > 0 (no matter how small), there exists a positive integer N such that

Here is the related definition of completeness. DEFINITION 2.8. A normed vector space V is said to be complete if every Cauchy sequence in V converges to an element ofV. It can be shown that the inner product spaces mentioned earlier, R n , L 2 (£2), //' (£2), and HQ (£2), are all complete. A complete inner product space is called a Hilbert space. An important notion in the theory of complete spaces is that of a dense subspace. For example, every real number can be approximated arbitrarily well by a rational number. For this reason, Q is said to be dense in R. DEFINITION 2.9. Suppose V is a normed vector space. A subset W is said to be dense in V if, given any v e V and any € > 0 (no matter how small), there exists w e W with

The set R is the completion of the dense subset Q; that is, R is precisely what results when all of the holes in Q are filled. The following theorem identifies some common dense subspaces of the Sobolev spaces. THEOREM 2.10. 1. C(£2) is dense in L2(£2) (that is, L2(Q) is the completion ofC(Q) under the L2 norm). 2. C'(ft) is dense in Hl(Q) (that is, Hl(Q) is the completion ofC}(tt) under the //' norm). 3. C<j(£2) is dense in H^(Q.) (that is, H^(Q) is the completion ofCQ(Q) under the H} norm). Other spaces dense in L2 (ft) are C£° («) and C°° (Q) n L2 (Q). The space C°° (ft) n #' (Q) is also dense in Hl(Q), and the space C0°(£2) is also dense in HQ (£2).

2.4. Existence and uniqueness theory for the weak form of a BVP

41

This theorem shows that the Sobolev spaces arise from "filling the holes" in the classical spaces, in the same way that R arises from Q.

2.4.33Linear functionalsals The Sobolev spaces are infinite-dimensional vector spaces, and the study of linear algebra is considerably more complicated in infinite dimensions than in finite dimensions. Much insight into the nature of infinite-dimensional vector spaces comes from studying the continuous linear functionals that can be defined on a given space. If V is a normed linear space, then a linearfunctional I on V is a real-valued function on V that is linear:

Continuity for a linear functional is defined just as for any other function: £ is continuous at u 6 V if or, equivalently, However, linearity has a couple of important implications for continuity. First of all, if I is continuous at any u in V, then t must be continuous at every u in V. To see this, notice that

where z — UQ + V — u. Since \\u — v\\ —» 0 if and only if \\UQ — z\\ -> 0, it follows that t is continuous at u if and only if it is continuous at MO. Second, it is not difficult to show3 that t is continuous at M = 0 (and hence at every «) if and only if there exists a nonnegative constant M such that

The smallest such bound M is called the norm of the linear functional t, and is denoted \\t\\. 3

\fl is continuous at 0, then there exists 0 such that ||u|| < S implies that

But then, for any u e V, the vector ( ke • e for a certain symmetric 2 x 2 matrix #. Find the eigenvalues of B.)

Chapter 3

The Galerkin method

In the previous chapter, I explained how to transform an elliptic BVP into its weak form. One advantage of the weak form is that it puts much less stringent requirements on the problem functions (such as the right-hand side of the PDE) and the solution, and therefore applies to a larger collection of problems. However, a more important advantage is that the weak form admits new solution techniques—in particular, the Galerkin method. There are several ways to introduce the Galerkin method. I prefer to approach it from the standpoint of linear algebra, because then the most striking feature of the method is clear from the beginning: The Galerkin method computes the best approximation to the true solution from a given finite-dimensional subspace.

3.1

The projection theorem

The projection theorem is a foundational result from linear algebra that provides a method for determining computable approximations to known or (in some contexts) unknown quantities. In its abstract form, it answers the following question: Given a vector u in an inner product space V and a finite-dimensional subspace W, what is the best approximation to u from W? That is, which vector w e W is closest to u in the sense that \\u — w\\ is as small as possible? The projection theorem applies to inner product spaces such as Rn or L 2 (£2) and is based on the notion of orthogonality. DEFINITION 3.1. IfV is an inner product space with inner product (-, •) and u, v are two vectors in V satisfying ( u , v ) — 0, then u and v are said to be orthogonal. In R2 or R3, where vectors can be visualized, orthogonality is equivalent to perpendicularity, since it can be shown that, in R2 or R 3 , two vectors u, v are perpendicular if and only if u • v — 0. However, orthogonality extends to spaces like L 2 (£2), where "two functions are perpendicular" has no apparent geometric meaning. In fact, the implications of orthogonality are pretty much the same, regardless of whether they can be visualized. 57

58

Chapters. The Galerkin method

Since the norm in an inner product space is defined by the inner product, the Pythagorean theorem holds in any inner product space. If vectors u, v in an inner product space V satisfy (u, u) = 0, then

The Pythagorean theorem is the basis for the proof of the projection theorem. THEOREM 3.2. Suppose V is an inner product space, W is a finite-dimensional subspace ofV, andu e V. Then 1 . there is a unique vector w e W satisfying

The vector w is called the best approximation to u from W or the projection of u onto W and is denoted projwu. 2. a vector w is the best approximation to ufrom W if and only if it satisfies the following orthogonality condition:

(see Figure 3. 1). The projection theorem also holds if W is an infinite-dimensional (closed) subspace of V, but in the finite-dimensional case the orthogonality condition makes it possible to derive a system of equations defining the best approximation, as I now show. If W is finite-dimensional, then it has a basis [w], . . . ,wn} and w e W can be represented as

Figure 3.1. Illustration of the projection theorem.

3.2. The Galerkin method for a variational problem

59

If u; also satisfies (3.1), then (taking z — w; ( )

Therefore, u; is determined by a system of n linear equations in the n unknowns a\ ,0.2,... ,ctn. If G e Rnxn and b e R" are defined by

respectively, then the system of equations can be written in matrix-vector form as Got = b. The matrix G is called the Gram matrix and the equations represented by Ga = b are referred to as the normal equations. Therefore, to compute the best approximation to u from W requires, when W is n-dimensional, the solution of an n x n system of linear equations. If it happens that {w], W 2 , . . . , wn} is an orthogonal basis for W, that is, if (Wj, w;/) = 0 for i / y, then the Gram matrix G is diagonal and it is simple to solve Ga = b:

It is not practical in the context of most PDEs to compute an orthogonal basis. However, if G is "nearly" diagonal, in the sense that most of the off-diagonal entries are zero, then Got = b can be solved efficiently even when n is very large. When most of its entries are zero, a matrix is said to be sparse. As shown in the next chapter, the finite element method produces systems with sparse matrices.

3.2

The Galerkin method for a variational problem

As I showed in the previous chapter, the variational form of many BVPs takes the form

where a(-, -) is a symmetric bilinear form on the Hilbert space V and € is a continuous linear functional on V. When the BVP is elliptic, the conditions

hold, and the bilinear form a(-, •) defines an alternate inner product on V.

lj

ghcfgty

Given a finite-dimensional approximating subspace W of V, the best approximation from W to the solution u of (3.2) is computed by solving the system Got — b, where

and { w i , W2, . . . ,wn} is a basis for W. Since the basis [ w \ , w^, . . . , wn] is known, the matrix G is computable. However, the true solution u is unknown, and there is no way of computing the vector b. The Galerkin idea is simple: Compute the best approximation to u using the alternate inner product defined by the bilinear form a(-, •) (the energy inner product). Then the variational equation (3. 2) gives the value of a (u, u)forallv G V (even though u is unknown): a(u, v) = l(v}. To find the best approximation to u in the energy norm, it is necessary to solve the system KU = F, where K is the n x n matrix defined by

and F e R" is defined by

In this context, the Gram matrix K is usually called the stiffness matrix, and the vector F is called the load vector. The vector U e Rn defines the approximate solution:

The load vector is computed by the formula Ft • = i(wt), i = 1 , 2, . . . , n. The reader should recall from the derivation in the previous section that the computed solution w (given by (3.4)) satisfies

or, since {w\ , if 2, . . . , wn} forms a basis for W,

The variational equation (3.5) is the form in which the Galerkin method is usually presented. It is identical to the variational equation (3.2) except that the space V is replaced with the finite-dimensional subspace W. Beginning with (3.5), the usual starting point, it can be shown directly that the approximate solution w is the best approximation to u from W. The solution u satisfies

and hence, since W c V,

3.2. The Galerkin method for a variational problem

61

Similarly, w satisfies Subtracting (3.6) and (3.7) yields

or

This is the orthogonality condition that is necessary and sufficient for w to be the best approximation from W (in the energy norm) to the true solution u. The Galerkin method leads to an approximate solution w satisfying

where u is the true solution to (3.2). While the vector w is not the best approximation in the original norm || • || on V, it cannot be much worse than the best approximation in the V-norm. The derivation is based on properties (3.3) and the following observation: If v e W, then, since W is a subspace of V, v — w is also in W. Since w is the best approximation to u from W in the energy inner product, the orthogonality condition

holds. Therefore, for any v e W,

Now (3.3) is applied as follows: For any v e W,

Dividing both sides by ||w — w\\ yields

This result is called Cea's theorem. While \\u — w\\ need not be as small as possible, it cannot be too much larger than the smallest possible \\u — v\\,veW. This fact is central to the finite element method, which is based on a family of approximating subspaces Wh, with dimension of W/, growing as h —>• 0. The corresponding Galerkin approximations Wh e Wh must improve at the same rate as the best approximations from Wh as h -> 0.

62

Chapters. The Galerkin method

Originally the Galerkin method was used to produce accurate approximate solutions from cleverly chosen low-dimensional subspaces. However, the finite element method is based on making the necessary computations (the computation of K, F, and the solution U of KU — F) efficient even when the dimension of the approximating subspace is large. This is achieved by choosing a special kind of approximating subspace, as explained in the next chapter. The reader is asked to work out some simple examples of the Galerkin method in the exercises at the end of the chapter.

3.2.1

Another interpretation of the Galerkin method

The reader will recall from Section 2.2 that the variational form of a BVP can be viewed as the optimality condition for the optimization problem of minimizing the potential energy of the physical system being modeled. Using the abstract notation from (3.2), the energy is given by

(I will ignore the additive constant, since it does not affect the minimization.) The problem is to find u e V to solve Given that V is infinite-dimensional, making (3.9) intractable in most cases, a natural approach is to choose a finite-dimensional approximating subspace W of V and solve instead

This approach is called the Ritz method. Since W is finite-dimensional with a basis {wi,u)2,.-.,wn}, (3.10) can be expressed in terms of the coordinates in R" defined by the basis for W. If w e W is given by

then

3.3. Exercises for Chapter 3

63

where K and U are the same stifmess matrix and load vector defined above. The problem now is to choose U e R" to minimize

But an easy calculation shows that

and thus the minimizer is found by solving the linear system

Therefore, minimizing J over the subspace W (the Ritz method) is really the same as the Galerkin method. For this reason, the method is sometimes called the Ritz-Galerkin method.

3.2.2

The Galerkin method for a nonsymmetric problem

Although I restrict myself almost entirely to symmetric problems in this book, I want to point out that the Galerkin method is just as applicable to a nonsymmetric elliptic problem. In fact, the norm of the error satisfies Cea's theorem, as in the symmetric case, and for exactly the same reason. (The reader can verify that in the derivation of (3.8) I did not use the symmetry of a(-, •)•) However, it cannot be said that u; is optimal in the energy norm, since the bilinear product a (•, •) does not define an inner product in the nonsymmetric case.

3.3

Exercises for Chapter 3

Note: The following exercises require the computation of a number of definite integrals, and also the solution of systems of linear equations. The reader is encouraged to use a computer algebra system; these computations would be very tedious performed by hand. 1. (Some simple examples of the projection theorem.) Consider the inner product space

with inner product

The function f ( x ) = ex belongs to L 2 (0, 1). The following exercises ask for the best approximation to / from various subspaces, using various inner products. (a) Consider the subspace P^ consisting of all polynomials of degree four or less. Find the best approximation to / from V\. Note that a basis for P^ is

64

Chapters. The Galerkin method (b) Now consider L 2 (0, 1) under the alternate inner product

Find the best approximation, relative to the norm induced by this inner product, to/ from P4. (c) Repeat Exercise 1 (a) with P4 replaced by the subspace spanned by the basis (d) Repeat Exercise l(b) with P^ replaced by F2. By graphing the error in each estimate, compare the four approximations to /. Is one to be preferred over the others? Why? The reader should note that when the vector / to be estimated is known, one may choose any convenient inner product. This should be contrasted with the Galerkin method, in which the vector to be estimated is unknown and the energy inner product must be used. 2. Consider the one-dimensional BVP

where f ( x ) = ex . The weak form of this BVP is

where and

The variational problem (3.1 1) can be written in the usual form, a(u, v) — t(v} for all v e V, by defining V = /^(O, 1) and

(a) Define W to be the subspace of HQ (0, 1) spanned by the basis

Apply the Galerkin method to find the best approximation, in the energy norm, from W to the solution u of (3.1 1).

3.3. Exercises for Chapter 3

65

(b) Repeat Exercise 2(a) with W replaced by

(c) Find the exact solution to the original BVP and compare the two approximate solutions by graphing the errors. 3. Let {w\, W2,. • • , wn] be a basis for a subspace W of an inner product space, and let G be the corresponding Gram matrix: G,; = ( w j t u;/). Notice that G is symmetric: Gtj - Gji for all i,j. (a) Show that G is positive definite: x • Gx > 0 for all x e R", jc ^ 0. (Hint: Let v — Y%=\ xiwi ar|d snow that x • Gx = (v, v).) (b) Use the preceding result to show that G is nonsingular.

This page intentionally left blank

Chapter 4

Piecewise polynomials and the finite element method

I have now presented the two theoretical foundations of the finite element method: the variational form of a B VP and the Galerkin method for producing an approximate solution to a variational equation from a given finite-dimensional subspace. The key practical ingredient of the method is the choice of the approximating subspace. The finite element method is Galerkin's method with a subspace of piecewise polynomial functions. The Galerkin method requires the computation of the stiffness matrix K and the load vector F, and the solution of the system KU = F. For the method to be efficient, it must be possible to compute K and F efficiently and also to solve the system efficiently. For the method to be effective, the approximating subspace must be chosen so that the true solution of the problem can be well-approximated by an element of the subspace. The three requirements described in the previous paragraph can all be met by an approximating subspace consisting of piecewise polynomial functions. It is easy to integrate and differentiate polynomials (the main requirements for computing K and F), and piecewise polynomials lead naturally to a sparse stiffness matrix, allowing KU — F to be solved efficiently. Finally, smooth functions can be well-approximated by piecewise polynomials. I begin by describing the construction of spaces of piecewise polynomials.

4.1

Piecewise linear functions defined on a triangular mesh

A polynomial in jc and y has the form

where aoo, «io, • • • , #o« are constants. To define & piecewise polynomial over a domain f2, the domain must be partitioned into subdomains. A piecewise polynomial is a function that is defined by a polynomial on each subdomain. The collection of subdomains is referred to as a mesh. 67

68

Chapter 4. Piecewise polynomials and the finite element method

Figure 4.1. Two examples of nonconfarming triangulations. In both examples, the intersection of triangles 1 and 2 is a line segment that is not an edge of triangle 1.

Figure 4.2. Triangulations of two polygonal domains.

The most common meshes in two dimensions are triangulations—the domain £l is expressed as the union of triangles.5 The intersection of any two triangles must be a common vertex or a common edge. Situations such as those shown in Figure 4.1 are called nonconforming and are not allowed. If £1 is not polygonal, it is necessary to approximate pieces of 9£2 by line segments or simple curves, which can give rise to triangles having a curved edge. In this section, I will assume that £2 is polygonal, so that a triangulation covers it exactly. Figure 4.2 shows triangulations of a square and a pentagon. Some notation is required to describe a piecewise polynomial relative to a given triangulation. I will assume that a given triangulation consists of Nt triangles T\, T2,..., T^l. The vertices of the triangles will be denoted z\, zi,..., ZNI:, where Zj = (*_/, x/)- As Figure 4.2 illustrates, each vertex is typically a vertex of several triangles. To each triangle is associated three vertices from the list z\,Z2, • •• ,ZNV, which can be identified by their indices in this list. The indices of the vertices of 7} will be denoted «/,i, n/,2, «/,3. That is, the vertices of 7/ are

5 Here I will use a convenient abuse of terminology. Strictly speaking, a triangle is the union of three line segments. However, 1 will denote by T the domain enclosed by a triangle together with the triangle itself, and refer to T as a triangle. In my notation, then, i)T is what one would normally call a triangle.

4.1 . Piecewise linear functions defined on a triangular mesh

69

The mapping from /, j to n,-j maps from local indices (j = 1 , 2, 3) to global indices. When focusing on a single triangle T, it is frequently convenient to use only local indices, in which case the vertices will be denoted z\ , 12, Z3- Strictly speaking, this is an abuse of the notation established above, but it simplifies things considerably. In implementing and analyzing the finite element method, it is necessary to consider a family of triangulations. Each triangulation is usually labeled by its mesh size h, where h is the maximum diameter of any triangle in the triangulation. For this reason, a typical triangulation is denoted by 7/j. The simplest space of continuous piecewise polynomials consists of continuous piecewise linear functions defined relative to a triangulation 7/j of a polygonal domain £2 c R 2 A piecewise linear function p must reduce to a first-degree polynomial a/ + b(x + c/y on each triangle 7} e 77, . The three parameters a, , bt , c/ are uniquely determined by the values of the function at the three vertices of 7)- . A simple way to see this is to realize that the graph of p, restricted to 7], is a piece of a plane. That plane is uniquely determined by the three points

Moreover, since by assumption p is continuous, its value at a vertex is well-defined. If triangles 7] and Tk both have Zj as a vertex, then a/, b, , c, and ak,bk, ck must be such that

Therefore, the 3N, parameters a\ , b\ , c\ , . . . , a^, , £#, , CN, are not all independent. Assuming that 7} and Tk are two triangles sharing an edge e, then

must hold if /? is to be continuous across e. Since the graph of a linear function in two variables, restricted to a line segment in the plane, is a line segment in 3-space, the fact that the linear functions defining p on 7) and Tk agree at the two endpoints of e is enough to show that they agree on all of e. This reasoning shows exactly how many degrees of freedom there are in describing a piecewise linear function on a given triangulation T/, : If 7h contains Nv vertices, then a piecewise linear function on 7~h is determined by the Nv nodal values of the function. Figure 4.3 shows two piecewise linear functions, one defined on each of the meshes shown in Figure 4.2. Thus, if 77, has Nv vertices, then the space P^(1) of all continuous piecewise linear functions defined on T/, is a finite-dimensional vector space with dimension Nv. Each function v e P^} can be identified with a vector a e RN" consisting of the nodal values of v. Moreover, it is easy to find a basis {^i , fa, • • • , ^N,,} f°r PH ^ w ith the property that

Such a basis would have to have the property that, for any a e

Chapter 4. Piecewise polynomials and the finite element method

70

Figure 4.3. Two continuous piecewise linear functions.

Figure 4.4. Standard has is functions for two spaces of continuous piecewise linear functions. that is, that

The condition (4.1) uniquely defines the basis functions Vv, * — 1 , 2 , . . . , Nv. Typical examples, again for the triangulations from Figure 4.2, are shown in Figure 4.4. A basis satisfying (4.1) is called a Lagrange basis or a nodal basis.

4.1.1

Using piecewise linear functions in Galerkin's method

Before I discuss the details of using continuous piecewise linear functions in the Galerkin method, I want to show that it is correct to do so, namely, that a valid approximating subspace can be constructed of continuous piecewise polynomial functions. For example, consider the Neumann problem

4.1 . Piecewise linear functions defined on a triangular mesh

71

where ^2 is assumed to be polygonal. The weak form is

where

To apply Galerkin's method, a subspace V/, of V is needed. To justify the choice V/j = P(h \ it must be shown that P^]) is a subspace of V, that is, that a continuous piecewise linear function belongs to Hl (Q). If u 6 P^\ with u(jc, y) = a-i + b[X + c-,y for ( x , y ) e 7), then, in the classical sense,

Here int(7)) denotes the interior of the set 7}, that is, the triangular region, not including the boundary. In most cases, the classical derivatives of v are undefined on the boundaries of most triangles 7}, since there is no reason to expect the derivatives to be continuous across the boundary between two adjacent triangles. (A linear function is piecewise linear, so in certain special cases the derivatives can be continuous across some or all boundaries between triangles.) I will show that (4.5) defines the weak partial derivatives of v. This is all I need to show, since the functions defined by (4.5) obviously belong to L2(£2). For any 0 e C£°(ft),

where n(l) is the outward-pointing unit normal to 97}. Every edge e of a triangle 7} either belongs to 9£2 or is the edge of one other triangle 7). In the first case, 0 is zero over e, and thus In the second case, n(l) = —n ( / ) on e, and both

72

Chapter 4. Piecewise polynomials and the finite element method

appear in the sum

Since v is continuous, it follows that

and thus these two integrals cancel. The conclusion of this reasoning is that

and thus

where 3u/3jc is defined by (4.5a). This shows that (4.5a) defines the weak partial derivative with respect to jc of v. A similar argument shows that (4.5b) defines the weak partial derivative of v with respect to y, and thus P^ } is a subspace of V. Next I will show how to incorporate Dirichlet boundary conditions into the definition of a space of continuous piecewise linear functions. The following example will be used:

Here FI and F2 form a partition of 3£2, and it is assumed that any points where Fj and F2 meet are nodes in the triangulation, and also that any such nodes belong to Fj. The weak form of (4.6) is

where and a(-, •) and i are defined as before. If e is an edge of a triangle T,• e Th and e lies on dQ, then e will be called a free (boundary) edge if one or both endpoints lie in F2. On the other hand, e is a constrained edge if both endpoints lie in FI . The nodes lying on F2 or in £1 are called free nodes, while those lying in FI are called constrained nodes. The desired approximating subspace of V is

4.1. Piecewise linear functions defined on a triangular mesh

73

The reader should notice that, because v is linear on each edge, v = 0 on r\ if and only if v = 0 at every node contained in PI. The dimension of V/, is the number of free nodes (the nodal values of any v e Vh at constrained nodes are already known). It is necessary to establish some notation to distinguish the free nodes and constrained nodes. The number of free nodes will be denoted by Nf and the number of constrained nodes by Nc. I define a sequence f\, fi,..., //v, so that

are the free nodes, and another sequence c\,C2,..., cNc so that

are the constrained nodes. EXAMPLE 4.1. As an example of the above notation, let £2 be the unit square,

with (so that r\ is the top edge of the square) and Vi = dQ \ PI (so that F2 consists of the left, bottom, and right edges of the square). Figure 4.5 shows a mesh defined on £2, indicating the enumeration of both the triangles and the nodes. In this mesh, Nt = 32 and Nv — 25. Recall that the integers «/. i , n, 2 > «/,3 we the indices of the three vertices of the triangle T[. For example, Figure 4.5 shows that

Since the first 20 nodes are free, Nf = 20 and fk = k, k = 1, 2, . . . , 20. Nodes 21, 22, 23, 24, and 25 are constrained, so Nc — 5 and

Figure 4.5. A triangulation of the unit square. The left graph shows how the 32 triangles are enumerated, while the right graph shows the enumeration of the 25 nodes.

74

Chapter 4. Piecewise polynomials and the finite element method

It is important to note that the enumeration of the triangles and of the nodes is not unique; the same mesh can be enumerated in different ways. If V h is a subspace of P^ \ as described above, then a basis for V/, consists of those standard basis functions \lr\, fa, •.., ^NV corresponding to free nodes. That is, is a basis for Vh. For convenience of notation, 1 will write 0* = tyfk, so that the basis for Vh can be written as

Inhomogeneous Dirichlet conditions

In Section 2.3.3,1 explained how to handle inhomogeneous Dirichlet boundary conditions, at least in principle. The weak form of the BVP

is the following:

where G is any function in Hl(Q) satisfying the boundary condition G = g on F[. It may not be easy to find such a G exactly, but it is easy to define a function G that approximately satisfies the boundary condition. Indeed, the continuous piecewise linear function G defined by

agrees with g at the endpoints of every constrained edge and therefore interpolates g on FI . This function G is a sufficiently good approximation to g for the purposes of the finite element method (see Section 5.3). 4.1.2

The sparsity of the stiffness matrix

I will now discuss why it is advantageous to use Phl} (or a subspace) as the approximating subspace in the Galerkin method. One advantage is that it is easy to work with polynomials (and particularly linear functions). Evaluating, differentiating, and integrating them is simple. The second reason is that when the standard nodal basis is used, the resulting stiffness matrix is sparse, that is, has few nonzero entries. As I showed in Section 3.2, if the approximating subspace V/2 has basis {0i, 0 2 , . . . , 0^}, then the stiffness matrix belongs to RN/*N/ and has entries

4.1. Piecewise linear functions defined on a triangular mesh

75

Figure 4.6. The support of the standard basis functions (j)\ and (fr given in Figure 4.5. In the scalar model problem,

and the reason that K is sparse is simply that each standard basis function 0/ is zero over most of the domain fi. It follows that, for most choices of/ and j, the integral

is zero, since V0(- • V0y- is zero over all Q. This is not true for all pairs i, j, i ^ j, but it holds for most of them. The sparsity of K will be illustrated in detail for the mesh in Example 4.1. Figure 4.6 shows the supports of \$ for the mesh given in Figure 4.5. The free nodes of the mesh are labeled in this graph.

Figure 4.8. The sparsity pattern of the stiffness matrix K corresponding to the mesh given in Figure 4.5. The 20 x 20 matrix K has 82 nonzeros. seven nonzeros). Therefore, the matrix K is fairly sparse. The sparsity pattern of K (for ic(x, y) = 1) is illustrated in Figure 4.8. (The reader will notice only, at most, five nonzeros per row instead of seven as indicated above. Entries like £"13,7 and #13,19 happen to be zero due to the symmetry in the mesh.) It should be noted that as a general rule, when a triangulation is refined the number of nodes adjacent to a given node does not increase. For example, the mesh in Figure 4.9 has four times as many triangles as the mesh in Figure 4.5. Assuming the same boundary conditions, this finer mesh would have 72 free nodes and K would be 72 x 72. However, a node in the center of the mesh would still have at most seven adjacent nodes. Therefore, the degree of sparsity of the stiffness matrix increases as the mesh is refined. For example, for the coarser mesh, the 20 x 20 matrix contains 82 nonzeros, so about 20% of the entries are nonzero (82 out of 400). For the finer mesh, the matrix is 72 x 72 and 326 entries are nonzero, which is about 6%.

4.2. Quadratic Lagrange triangles

77

Figure 4.9. A finer mesh (compare the mesh in Figure 4.5).

4.2

Quadratic Lagrange triangles

I will now discuss the use of higher-order piecewise polynomials, beginning with continuous piecewise quadratics. I will continue to assume that the underlying domain £2 is polygonal and that the piecewise polynomials are defined on a triangular mesh.

4.2.1

Continuous piecewise quadratic functions

A linear function f(x, y ) = a + bx + cy is determined by three parameters, and this fact makes it natural to use piecewise linear functions defined on a triangulation. A quadratic function is of the form

which shows that six parameters are required to define such a function. If a quadratic function is to be determined by the nodal values on a triangle, then it is necessary to add three nodes to the triangle, in addition to the three vertices. For reasons I explain now, these nodes should be the midpoints of the three edges of the triangle. What factors determine the placement of the nodes? First, it is necessary that the six nodes determine a unique quadratic. Second, it must be the case that the quadratics defined on two adjacent triangles necessarily agree on their intersection provided they agree on all common nodes. To satisfy the first condition, it suffices to take one point on each edge, in addition to the three vertices. One could also take the three vertices together with three (properly chosen) interior nodes. However, it would then not be possible to satisfy the second property. By choosing the three additional nodes as the midpoints of the three edges of the triangle, two triangles 7} and 7/ intersecting along an edge e necessarily share three nodes on that edge. Moreover, a quadratic function in two variables, restricted to a line segment e, reduces to a quadratic in one variable when the edge is suitably parametrized. Three points determine a unique quadratic in one variable, so the second condition in the previous paragraph is satisfied.

78

Chapter 4. Piecewise polynomials and the finite element method

The space of all continuous piecewise quadratic functions defined on a given triangulation Th will be denoted P^ \ The particular functions allowed on each triangle are called the shape functions of the element. In the case of P^ \ the shape functions are quadratic polynomials. The additional nodes described above (the midpoints of every triangle edge) are now part of the triangulation, and I must establish some notation to describe this more complicated situation. The nodes of the mesh, including both triangle vertices and edge midpoints, will be denoted by zi, 12, • • . , ZN,,- I define m, y so that the nodes of triangle 7} are

The vertices of 7} are still denoted by

(At certain times, for instance when integrating over a triangle, it is necessary to distinguish the vertices from the other nodes.) As in the case of P^ \ a Lagrange basis {\jf\ , ^2, . . . , V%1 of PH ) is defined by

A triangulation of the type described in this section, suitable for use with continuous piecewise quadratic functions, will be called a mesh consisting of quadratic Lagrange triangles. The simpler mesh described in the preceding section consists of linear Lagrange triangles. Figure 4.10 shows a mesh of quadratic Lagrange triangles, while Figure 4.1 1 shows two examples of the corresponding standard basis functions, ^5 and V^is, respectively. There are two essentially different types of basis functions for the space of continuous piecewise quadratic functions: i/r, looks like one of the functions in Figure 4.11, depending on whether Zi is a triangle vertex or an edge midpoint.

4.2.2

The finite element method with quadratic Lagrange triangles

( it is not much harder to implement the Given the above description of the space hP\ finite element method using quadratic Lagrange triangles than it was with linear Lagrange triangles. The Galerkin method is completely abstract, and the only thing that changes in going from piecewise linear functions to piecewise quadratic functions is the choice of the approximating subspace. As an example, I will consider the BVP with mixed boundary conditions

where T| and F2 form a partition of 9^2. As before, any point where Fj and F2 meet must be a triangle vertex and must belong to Fj .

4.2. Quadratic Lagrange triangles

79

Figure 4.10. A mesh of quadratic Lagrange triangles (the nodes of the mesh are labeled).

Figu re 4.11. The standard basis functions 1/^5 (left) and ty \ 8 (right) for P^ on the mesh from Figure 4.10.

defined

It is necessary, as before, to distinguish between free nodes (those belonging to £2 or F2) and constrained nodes (those belonging to FI). The free nodes will be denoted as Zf\ , Z f 2 , . . . ,ZfN. and the constrained nodes as zC{, zC2 ,••••> zCNi., as before. The weak form of (4.12) is

where The approimating subspace is

80

Chapter 4. Piecewise polynomials and the finite element method

In order that v e P^ satisfy v = 0 on FI, it suffices that v have value zero at every node belonging to Fj. This is sufficient because a triangle edge having a nontrivial intersection with FI lies entirely in F] by assumption. A basis for V^ is therefore

or

where, as before, 0, = ^/; • The stiffness matrix K is now defined by

and the load vector by

In this notation, the formulas are exactly the same as those presented in the case of piecewise linear functions. Of course, the basis function represented by 0, is now different. But, as the reader will see, the implementation of the method in a computer program does not change much when piecewise quadratic functions are substituted for piecewise linear functions. EXAMPLE 4.2. Figure 4.12 shows a mesh (for the unit square) consisting of quadratic Lagrange triangles. The mesh contains 32 triangles, 81 nodes, and 49 free nodes (Dirichlet conditions are imposed on the entire boundary). I computed the stiffness matrix K corresponding to the BVP (4.\2)for this mesh and for K ( x , y ) = 1. The sparsity pattern of the stiffness matrix is also shown in Figure 4.12. The matrix contains 405 nonzeros; since it is 49 x 49, about 17% of the entries are nonzero. The pattern of the nonzeros, though not the number of nonzeros, depends on the order in which the nodes are numbered. A refined meshfor the same domain is shown in Figure 4. 1 3. // contains 128 triangles, 289 nodes, and225free nodes. The stiffness matrix, which is also illustrated in Figure 4.13, contains 2229 nonzeros (about 4% of the entries).

4.3 4.3.1

Cubic Lagrange triangles Continuous piecewise cubic functions

A cubic function in two variables has the form

4.3. Cubic Lagrange triangles

81

Figure 4.12. A mesh for the unit square consisting of quadratic Lagrange triangles (left) and the spars ity pattern of the corresponding stiffness matrix (right).

Figure 4.13. A refined mesh for the unit square consisting of quadratic Lagrange triangles (left) and the sparsity pattern of the corresponding stiffness matrix (right). and is therefore determined by 10 parameters. To define a continuous piecewise cubic function on a triangular mesh, it is necessary to add seven nodes to each triangle, in addition to the three vertices. The placement of these nodes is determined by the following fact: A cubic function in two variables, restricted to a line segment, reduces to a cubic function in a single variable (when the line segment is parametrized). A cubic function of a single

82

Chapter 4. Piecewise polynomials and the finite element method

variable is determined by four nodal values, which means that each triangle edge must contain a total of four nodes. Then cubic functions defined on two adjacent triangles will agree on the common edge provided they agree at the four nodes, making it easy to guarantee the continuity of a piecewise cubic function determined by its nodal values. These four nodes consist of the two vertices (the endpoints of the edge) and the points placed at regular intervals between the two vertices. Thus if the two vertices are (*i, y\) and (x2, ^2), the other two nodes on the edge are

The reader should notice that the regular placement of the nodes on the edges guarantees that two triangles intersecting along an edge share four common nodes. Adding two nodes on each edge yields six additional nodes, or nine total when the vertices are taken into account. The final node must lie in the interior of the triangle, and it is natural to place it at the centroid of the triangle. Therefore, if the three vertices of the triangle are (jti, y\), (x2, y2), and (*3, 373), then the interior node will be

A triangulation consisting of triangles, each having 10 nodes as described above, is said to consist of cubic Lagrange triangles. Figure 4.14 shows a mesh of cubic Lagrange triangles defined on the unit square. It contains 8 triangles, 49 nodes, and 25 free nodes (Dirichlet conditions are imposed on the entire boundary).

Figure 4.14. A mesh for the unit square consisting of cubic Lagrange triangles (left) and the sparsity pattern of the corresponding stiffness matrix (right).

4.3. Cubic Lagrange triangles

83

As in the case of quadratic Lagrange triangles, the nodes of the mesh are denoted z\, Z2, • • • , ZNI:. The 10 nodes of triangle 7) are denoted by

The notation for free and constrained nodes remains the same as before.

4.3.2

The finite element method with cubic Lagrange triangles

Using continuous piecewise cubic functions in the finite element method merely means applying Galerkin's method with the space P^} (or an appropriate subspace taking into account the Dirichlet boundary conditions) as the approximating subspace. Here P^ denotes the space of all continuous piecewise cubic functions defined on a given triangulation ThThe standard basis for P\:) is where t/'/ is defined by

The basis functions corresponding to the free nodes z j \ , z/2,..., z/N

are denoted by

where 0, = \fffi. Since there are three different placements for nodes on cubic Lagrange triangles (centroid, interior of edge, and vertex), the standard basis functions take three different shapes. These are illustrated in Figure 4.15. The formulas for the stiffness matrix and the load vector are the same as before:

Figure 4.15. The standard basis functions ^44, corresponding to a centroidnode (left); 1/O6, corresponding to an edge node (center); and ^5, corresponding to a vertex (right), for P(h } defined on the mesh from Figure 4.14.

84

Chapter 4. Piecewise polynomials and the finite element method

Once again, as I will show in the second part of the book, the algorithm for computing K and F does not change very much in going from piecewise linear or quadratic functions to piecewise cubic functions. EXAMPLE 4.3. / computed the stiffness matrix for (4.12) and the mesh shown in Figure 4.14, taking K(X, y) — 1. The spars ity pattern of the resulting K is shown in Figure 4.14. The matrix K is 25 x 25, and 229 of the 625 entries are nonzero (about 37%). Refining the mesh of Figure 4.14 by replacing each triangle withfour results in a mesh with 32 triangles, 169 nodes, and 121 free nodes. (This finer mesh is not shown.) About 11% (1513 out of1 4 641) of the entries are nonzero.

4.4

Lagrange triangles of arbitrary degree

The constructions of the previous sections can be generalized to the case of continuous piecewise polynomial functions of degree d. As before, the placement of the nodes in a triangular element is determined by two requirements: 1. On each edge there must be d + 1 nodes, since a one-dimensional polynomial of degree d has d + 1 degrees of freedom (that is, d + 1 coefficients). Each edge contains two vertices, and the other d — I nodes will be regularly spaced between them. The total number of nodes on the boundary of the triangular element is therefore 3 + 3(d-}) = 3d. 2. A polynomial of degree d in two variables is determined by

parameters, since there is one constant term, two terms of degree one (jc, _y), three terms of degree two (x2,xy, y2), and so forth, up to d + 1 terms of degree d (xd, xd~ly,..., xyd~}, yd). Since 3d nodes lie on the boundary of the triangle, the remainder must lie in the interior. A simple calculation shows that

For d = 1, d = 2, d — 3, this formula yields 0,0, 1, respectively, for the number of interior nodes. This is consistent with the constructions of linear, quadratic, and cubic Lagrange triangles presented previously. Ford > 3, the interior nodes can be arranged on a triangular lattice, as shown in Figure 4.16 for d = 4, d = 5, and d — 6. Once the Lagrange elements have been defined, the rest of the development proceeds as in the case of quadratic or cubic Lagrange triangles. The Lagrange basis for P^d\ [ty\, V^2. • • • , ^N,}-, is defined by

4.4. Lagrange triangles of arbitrary degree

85

Figure 4.16. Lagrange triangles of degrees d = 4 (left), d = 5 (center), andd — 6 (right).

where z\ , 12, • • • , ZN,, are the nodes in the mesh. Each node on the boundary of the domain £2 is designated as constrained or free, depending on whether a Dirichlet condition is posed there or not. All nodes in the interior of £2 are free. The free nodes are zj\ , z/2 , . . . , ZfN , and the basis functions corresponding to these nodes are written as 0i , fa, . . . , 0#;-, where

The Galerkin method, which, as noted before, is completely abstract, is then applied with the approximating subspace

4.4.1

Hierarchical bases for finite element spaces

One shortcoming of using Lagrange triangles in the finite element method is that the stiffness matrix K tends to become quite ill-conditioned as the mesh is refined. The consequence is that solving KU = F becomes more difficult, in that direct methods are less accurate and iterative methods are less efficient. I will discuss both direct methods and iterative methods for solving KU — F in Part III. I will also define the condition number of a matrix and show the effects of a large condition number on algorithms for solving KU — F. The ill-conditioning of K actually arises from the choice of basis for the approximating subspace V/7, not the choice of the subspace itself. For example, given any subspace Vh, I could choose a basis for V/, that is orthonormal with respect to the energy inner product. Then the stiffness matrix K, which is given by AT,-/ = a (0 7 ,0,-), would be the identity matrix, which is perfectly conditioned. This shows that the ill-conditioning of A' is not intrinsic, but rather arises from the choice of basis. An orthonormal basis may not be practical because of the expense involved in computing the basis. However, there are many other bases that could be used. One possibility is a hierarchical basis (see Yserentant [44]). A hierarchical basis is defined in a natural way when the mesh is obtained by several refinements of an initial, coarse mesh. I will describe the use of hierarchical bases in Section 11.2 in the context of solving KU = F.

86

4.5

Chapter 4. Piecewise polynomials and the finite element method

Other finite elements: Rectangles and quadrilaterals

A triangle is not the only possible shape for element domains. If the computational domain happens to be rectangular (or a union of rectangles), then rectangular elements are a natural choice. For nonrectangular domains, general quadrilateral elements can be used.

4.5.1

Rectangular elements

A rectangle has four vertices, so it is natural to consider a class of polynomials with four degrees of freedom. Since a linear polynomial is determined by three degrees of freedom and a quadratic by six, only certain quadratic polynomials will be allowed, namely, those of the form Since every product (a + fix)(y + Sy) of linear polynomials can be written in the form a + bx + cy + dxy, such polynomials are referred to as bilinear. Given a rectangle aligned with the coordinate axes, say with vertices (x\ , y\ ), (xi , y\ ), (*2, Jz), (x\, ^2), and given any four real numbers u\, HI, «3, « 4 , it is straightforward to show that there is a unique polynomial a + bx + cy + dxy such that

(see Exercise 8). If £2 is a rectangle or a union of rectangles, then a mesh M.h of rectangles can be defined on 12. A bilinear function reduces to a linear function in one variable on any edge of a rectangular element. Therefore, it is easy to see that a collection of real numbers, one for each node in the mesh, determines a unique continuous piecewise bilinear function on M.h- (The reader should notice, however, that this property depends on the assumption that the rectangles are aligned with the coordinate axes; see Exercise 9.) I will denote the space of all such functions by B^\ If the nodes of the mesh are denoted z i , Z 2 , • • • , ZNU, then the standard basis for fi^1} is {^i , fa, • • • , Vfw,J K where

The finite element method can be applied to the BVP

where 3£2 = PI U F2 is a partition of dQ, using the subspace

4.5. Other finite elements: Rectangles and quadrilaterals

87

The free nodes of the mesh are the nodes that do not belong to F|, and are denoted as before by Zft, Zf2, • • • , ZfN.. The basis for B^]) is then {(f>\,4>2, • • • , 4>Nf}, where 0, — ^;. Just as in the case of triangular elements, the result is a matrix-vector equation KU — F, where

and

4.5.2

General quadrilaterals

Rectangular elements are useful when the domain £2 is very simple, but a more general domain cannot be well-approximated by a mesh of rectangles. A mesh of general quadrilaterals can be used; however, it is not so straightforward to define a space of piecewise polynomials. As Exercise 9 shows, nodal values do not determine continuous piecewise bilinear functions on a mesh of general quadrilaterals. The usual way to define shape functions on a mesh of quadrilaterals is to view each quadrilateral Q as the image of a reference square SR under a mapping of the form

The reference square SR is taken to be the square with vertices (—1, —!),(!, —!),(!, 1), and (- 1 , 1 ). If the vertices of Q are (jci , y\ ), (JQ, ^2), C*3, >'3), and (jc4, >'4) (in that order as the 9 Q is traversed), then the mapping (4. 1 5) is determined by the conditions that (— 1 , — 1 ) be mapped to (x\, y\), (1, — 1 ) be mapped to (xi , 3/2 )» (1,1) be mapped to (x^ , j3),and(— 1, 1) be mapped to (^4, >'4). These conditions yield two 4 x 4 linear systems that determine a\,a2,ai,ci4 andb\, bi, bj, b$:

and

The coefficient matrix in the two systems is the same,

88

Chapter 4. Piecewise polynomials and the finite element method

and the two systems can be written

where

The inverse of M is

so explicit formulas for a and b are easily derived. The bilinear shape functions on SR are then mapped to Q, defining the shape functions for that element. The shape functions on SR are represented by the basis functions

(see Exercise 10). As the following example shows, the shape functions on Q are usually not bilinear. EXAMPLE 4.4. Consider the trapezoid Q with vertices (0, 0), (3,0), (2, 1), and (I, 1). Using the reasoning given above, the mapping from SR to Q is

and the inverse of this mapping is

The basis functions on Q are then defined by

4.5. Other finite elements: Rectangles and quadrilaterals

89

Direct calculation then shows that

The shape functions on Q are therefore rational functions. In the previous example, the nodal basis functions <j>\, fa, $3, $4 are linear on the edges of Q, as is easily verified (see Exercise 11). This property is true in general: Although the nodal basis functions, generated by the above technique for an arbitrary quadrilateral Q, are rational functions, each reduces to a linear function on the edges of Q. This fact can be used to prove that, on a mesh of quadrilaterals, the nodal values determine a unique continuous and piecewise rational function (see Exercise 12). I now assume that a mesh Mh of quadrilaterals is defined on a polygonal domain Q. As usual, the nodes of the mesh are denoted by z\, 22, • • • , Zjv,,- The space of continuous piecewise functions on M.h, constructed from bilinear functions on SR as described above, is denoted by B(h]\ The nodal basis for B(h } is {i/o, fa, • • • , ^N,}, where ^/ is defined by

for j = 1 , 2 , . . . , Nv. The free nodes are denoted Zf\, z / 2 , . . . , ZfN , and the approximating subspace V/j has basis {0i, 02, • • • , 0jv,K where 0/ — \fffi. To compute the finite element solution, the stiffness matrix K and the load vector F must be formed. These are defined by

and Since each basis function 0, has support consisting of a few elements (four quadrilaterals, to be precise, unless the corresponding node is on the boundary), the basic calculations that must be performed are of the integrals

and

90

Chapter 4. Piecewise polynomials and the finite element method

where Q is a typical quadrilateral in the mesh. In practice, the basis functions are not computed on Q; rather, each integral is transformed into the reference square SR so that the relatively simple bilinear functions y\, y2, y?, y* can be used instead. Given a quadrilateral Q, I will write z — (x, y) for a typical point in Q and u — (s, ?) for a typical point in SR. The transformation from SR to Q is denoted z — F(w),

The Jacobian matrix for this transformation is

According to the rule for changing variables in a multiple integral,

This can be applied directly to the formula for F/. In the following formulas, it is convenient to use local indices: For a given quadrilateral Q, the vertices are denoted by (jcj, >>]), (jc2, J2), C*3, ys), C*4, ^4) and the corresponding basis functions (the only ones that are nonzero on Q) are denoted by 0i, 02, 03, 04. Then, under the transformation F, 0, is transformed to y,: Here is the formula needed for assembling the load vector:

To change variables in the integral

it is necessary to know the relationship between V0, on Q and Vy/ on SR. This follows from the chain rule:

Therefore,

4.6. Using a reference triangle in finite element calculations

4.6

91

Using a reference triangle in finite element calculations

In the previous section I showed how to use a reference element to extend piecewise bilinear functions from meshes of rectangles to meshes of general quadrilaterals. By defining a oneto-one transformation from the reference element to an arbitrary quadrilateral, the necessary computations could be carried out over the reference element instead of the quadrilateral. The reader will recall that this was necessary because bilinear functions do not extend continuously across element boundaries when the elements are general quadrilaterals as opposed to rectangles. Although it is not necessary to use a reference element when the elements are triangles, it is advantageous to do so. This is because the basis functions and their gradients can be computed once on the reference triangle and then used, by means of a transformation, on each triangle in the mesh. In this section I will show how this affects the computations. The reference triangle TR is the triangle with vertices (s\, t\) — (0,0), (s2, t2) = (1,0), and (53, rO = (0, 1) (see Figure 4.17). I denote an arbitrary point in TR by (s, t) or, in vector notation, u — (s, t). Given an arbitrary triangle T with vertices z\ — (x\ , y\), z2 = (x2, y2), zi — (xi, yti, an arbitrary point in T will be denoted by (jt, y) or z = (x,y). The reference triangle TR is mapped to T by the following transformation, which sends (0, 0) to ( x { , y\), (1,0) to (x2, y2), and (0, 1) to (*3, y3):

In vector form, the transformation is

or

Figure 4.17. The reference triangle TR.

92

Chapter 4. Piecewise polynomials and the finite element method

where

Given any function / defined on T, there is a corresponding function on TR defined

by or The function g has the same values as / does, in the sense that if u e TR corresponds to ze T,theng(u) = f ( z ) . The three standard Lagrange basis functions that are nonzero on T will be written (using local indices) as 0,, i = 1,2,3; they are defined by

Corresponding to 0, on T is y/ on TR:

Since the vertices of TR are mapped to the vertices of T, y/ satisfies

Moreover, a little algebra shows that each y, is linear in (s, t). If

then

Since each y/ is linear over TR, it follows that y\, xz, K? are just the standard Lagrange basis functions that are nonzero over TR. The following formulas are easily derived from condition (4.18):

The same functions y\,yi, K? correspond to \, fa, 03 over any triangle T. This is the efficiency gain I mentioned earlier: y\,y2, Y3 can be computed once instead of computing 0i, 02, 03 on each triangle in the mesh.

4.7. Isoparametric finite element methods

93

The formula for a change of variables in a multiple integral gives

where g is defined by

The Jacobian factor is

Since the transformation from TR to T is linear,6 J and its determinant are constant. Therefore,

This result applies directly to the problem of computing the load vector:

To compute the stiffness matrix, it is necessary to evaluate integrals of the form

As in the previous section, the relationship between V0, and Vy, follows from the chain rule: Therefore,

Here K is the function on TR corresponding to K on T. In the piecewise linear case, both V0, and Vy, are constant. Although (4.21) might look a little complicated, it should be noticed that J is just a 2 x 2 matrix, and therefore computing J ~T Vy/ is a simple matter.

4.7

Isoparametric finite element methods

To this point, I have assumed that the domain Q is polygonal, so that it can be triangulated exactly. If £2 has a curved boundary, then a triangulation ?/; can only approximately cover !T2, introducing a new source of error. I will denote by £2/, the polygonal domain triangulated by 7/i and begin with an example of the effect of approximating Q by £2/?. 6 The proper term is affine, not linear; the mapping u \-> Ju is linear, and affine means "linear plus a constant." But it is a common abuse of terminology to refer to an affine transformation as linear.

94

Chapter 4. Piecewise polynomials and the finite element method

EXAMPLE 4.5. Consider the BVP

where £2 is the unit circle and f is chosen so that the solution is

/ will apply the finite element method with four increasingly finer triangulations; Figure 4.18 shows part of the first two meshes near the boundary. The meshes will be denoted by 7i, ?2, 7s, ?4 (7i the coarsest, ?4 the finest), the corresponding polygonal domains by £l\, ^2, ^3 > &4> dnd the corresponding finite element solutions by u \, «2, «3, "4- Since £2 is convex, £2* C ^2 holds, andu^ will be defined to be identically zero on£l\£ik. The error u — Uk then reduces to u — Uk = u on Q \ £2*. Piecewise linear finite elements yield the results shown in the following table:

k

1

2 3 4

Error on Q/t 1

3.433 • KT 1.877- KT1 9.630 • 1C-2 4.848- 1C-2

Error onQ\&k 1

1.927 • ID" 9.941 • ID"2

5.010- 10~2 2.510- JO" 2

Error on Q 3.937 • 10-1 2.124- 10"1 1.086- 10-1 5.460 • JO"2

Here the errors are measured in the energy norm; the error on Q^ is

and the errors on ^2 \ ^ and £2 are defined similarly. The reader should notice that the error on &k is decreasing by about a factor of two each time the mesh is refined. The error on £1 \ £2* shows the same pattern, and so does the total error.

Figure 4.18. The first (left) and second (right) meshes from Example 4.5. The boundary of£l is the dashed curve.

95

4.7. Isoparametric finite element methods

The above results are satisfactory in the sense that the error due to approximating £2 by £l[, does not change the rate at which the total error goes to zero. Suppose, though, that quadratic elements are used in hopes of obtaining a more accurate solution. Here are the corresponding results:

k

1

2 3 4

Error on Q/< 2

7.737 • 10~ 2.573 • 1(T2 8.597- 1(T3 2.179- 1(T3

Error onQ\Qk 1

1.927- KT 9.941 • 1(T2 5.010- 10~2 2.510- 10~2

Error on Q 2.076- 10-' 1.027- 10-' 5.049- 10~2 2.519 -10" 2

The error on £2k is smaller than it was in the case of linear elements, and it also decreases faster. However, the error onQ\£2k is not affected by the increased order of the elements. The improvement in going from linear to quadratic elements is therefore modest, and there would be almost no additional improvement in going to cubic elements. The preceding example shows that approximating a domain with a curved boundary by a polygonal domain makes it difficult to obtain a highly accurate solution, at least when a uniform mesh is used. There are at least two ways around this difficulty. One is to use a nonuniform mesh, with smaller elements near the boundary. This is illustrated in the following example. EXAMPLE 4.6. Figure 4.19 shows a nonuniform mesh defined on the unit circle £17 It has approximately the same number of triangles as the mesh Tifrom the previous example (245 versus 256). Using piecewise quadratic polynomials on this mesh leads to a finite element solution «2 with the following errors:

k 2

Error on Qk 1.722- 10~

2

Error on£2\Qk 2

3.930 - 1C"

Error on £1

4.291 • 10~2

As this example shows, concentrating the triangles near the boundary leads to a smaller total error for the same computational effort. The drawback to the method of the previous example is that it is more difficult to create a sequence of meshes that are properly refined near the boundary so as to attain the accuracy that would be possible for a polygonal domain. I will discuss nonuniform meshes further in Part IV, but now I will turn to the second method of treating curved boundaries. The isoparametric method allows elements with curved edges, so that a curved boundary can be better approximated. The meaning of the word isoparametric is that the elements are parametrized as images of a reference element, with the parametrization given by polynomials of the same degree as the shape functions themselves. 1 will now explain carefully how this works for quadratic elements, and later extend it to higher-order elements. 7

This mesh was created using the mesh generator described in [33].

96

Chapter 4. Piecewise polynomials and the finite element method

Figure 4.19. A nonuniform mesh on the unit circle.

Figure 4.20. A subregion u> with a curved edge (left), and a quadratic Lagrange triangle approximating co (right).

4.7.1

Isoparametric quadratic triangles

For convenience, it is usual to consider elements with only one curved edge. Figure 4.20 shows a subregion CD that could arise in creating a triangular mesh on a circle. If ordinary quadratic triangles are used, as in the above examples, then co would be approximated by the triangle shown on the right in Figure 4.20. To get a better approximation, the midpoint node nearest the boundary could be moved to the curve, as in Figure 4.2 1 . Of course, the six nodes in Figure 4.21 do not lie on a triangle, but, as 1 will now show, the reference triangle TR can be mapped (approximately) onto u> by a quadratic mapping

4.7. Isoparametric finite element methods

97

Figure 4.21. An isoparametric quadratic Lagrange triangle T approximating the subregion a>. The curved edge of the isoparametric triangle is lying right on top of the (dashed) curve of the boundary and cannot be distinguished at this scale. This mapping, which will also be denoted (x, y) — F(s,t)orz = F(u), is determined by 12 parameters: a\,..., «6, b\, • • • , ^6- These 12 parameters are uniquely determined by the condition that the six nodes,

from TR be mapped onto the corresponding six nodes on o>,

These conditions take the form

a system of 12 linear equations determining the 12 unknowns. The subregion a> is then approximated by T, the image of TR under F. For this example, T is shown in Figure 4.21, where it is essentially indistinguishable from CD. The shape functions on T are determined by the standard Lagrange basis functions on TR. This works just as it did in the previous section. The standard basis on TR will be denoted [y\ , . . . , ye}', it is defined by the conditions

The basis on T consists of 0 i , . . . , 06 defined by

98

Chapter 4. Piecewise polynomials and the finite element method

or

In the setting of Section 4.6 the mapping F was linear, so each 0/ was a polynomial of the same degree as y/; in fact, { 0 i , . . . , x\ and yi > y\- Show that, for any «i , «2> "3, "4> there is a unique bilinear polynomial p(x, y) such that

9. Show by example that bilinear functions on neighboring quadrilaterals can agree at the two common vertices and yet not agree on the edge determined by the two vertices, provided the quadrilaterals are not rectangles aligned with the coordinate axes. 10. Let the vertices of SR be numbered from 1 to 4 in the order (-1, —1), (1, —1), (1, 1), and (—1, 1). Show that the corresponding nodal basis functions for the space of bilinear functions on SR are given by (4. 1 6). 1 1 . Show that the basis functions 0, a\ + «2 = 1 , a\ (s\ J\) + 012(32,12) is mapped to ct\ (x\ , ~y}) + ot2(x2, J2). (b) Use the previous result to show that each 0, is linear on each edge of Q. (Hint: 0, is linear on an edge e if

whenever

4.8.

Exercises for Chapter 4

1 03

(c) Suppose two quadrilaterals Q\ and Q^ share an edge e, and suppose r\, r-i are shape functions on Q\, Q^ respectively, constructed by the method described in Section 4.5. Show that if r\ and r2 agree at the endpoints of e, then they agree on the entire edge e. 13. Let TR be the usual reference triangle, suppose y(s, t) is a polynomial on TR, and suppose TR is mapped onto a region T by a one-to-one mapping F, where F(s, t) — ( p ( s , t ) , q ( s , 0) and p and q are both polynomials. Define 0 on T by 0 (x , y) — y(s, f), where ( x , y ) — F(s, t). Assuming that the Jacobian J of F is nonsingular for each (s, t) e TR, prove that

has components that are rational functions of (s, t). 14. Let y\, yi, X3, given by (4.19), be the three linear basis functions on the reference triangle. Compute the integrals

and

15. Let y\,..., y^ be the six quadratic basis functions on the reference triangle. Find the formula for each y { ( s , t ) , i — I , . . . , 6. 16. Show that (4.28) and (4.29) imply that F{ is given by (4.30). 17. Suppose the function K satisfies 0 < &o < K(X, y) < k\ for all (x, >') e Q and for some constants ko, k\. Suppose further that the function b satisfies 0 < b(x, y) < b\ for all (x, y) e Q and for some constant b\. Consider the BVP

The weak form of this BVP was derived in Exercise 2.7.12. Suppose Galerkin's method is applied, with a basis {w\,wj,... ,wn} for the approximating subspace. Show that this leads to the system

where

are defined by

1 04

Chapter 4. Piecewise polynomials and the finite element method The matrix K and the vector F are the usual stiffness matrix and load vector, respectively. The matrix M is called the mass matrix.

18. Suppose £2 is apolygonal domain, TH is a triangulation of £2, and / belongs to L 2 (fi). If

is the best approximation to / from PA(1) in the L2(£2)-norm, what are the normal equations that determine the vector a of coefficients? (cf. the previous exercise)

Chapter 5

Convergence of the finite element method

The convergence theory of the Galerkin finite element method is fairly straightforward in outline, although the details can be quite complicated. I have already shown how the method produces the best approximation, in the energy norm, to the true solution of the given BVP. To prove that the approximations converge to the true solution as the mesh is refined requires understanding how well a given function can be approximated by piecewise polynomials. The purpose of this chapter is to discuss this approximation theory, without, however, going too far into detail or proving the theorems. Since the Galerkin method is directly tied to the energy norm, convergence in the energy norm is obtained if the true solution is regular enough. It is sometimes desirable to know the rate of convergence in other norms, particularly the L2-norm. After I present the basic theory, I will show how to extend the results from the energy norm to the L 2 -norm.

5.1

Approximating smooth functions by continuous piecewise linear functions

The purpose of this section is to discuss how well a function can be approximated by a continuous piecewise linear function. Before proceeding, I want to discuss the nature of the error bounds presented below. First of all, the theory states that the finite element method yields the best approximation to the true solution when the error is measured in the energy norm, which is related to the Sobolev norms. It is therefore reasonable to try to bound the error of approximation in terms of the L 2 - and //'-norms. Second, as the reader will notice below, the bounds given here are asymptotic, not absolute. This means that the bounds will not tell how small the error is when the solution is approximated on a particular mesh. Instead, the bounds show how the error decreases as the mesh is refined. These bounds can also be characterized as a priori error estimates, in that the bounds do not involve the computed solution—indeed, the bounds are given before any approximate solution is computed. An a priori, asymptotic error bound of this type is useful, but it leaves some unanswered questions, such as how fine the grid must be in order to attain a certain accuracy. In 105

106

Chapter 5. Convergence of the finite element method

Part IV, I discuss how to form a posteriori error estimates that use the computed solution to estimate the actual error in that computed solution. Since the theory presented below describes how the error decreases as the mesh is refined, it is not surprising that there are limitations on how the mesh is refined. The fundamental rule is that the triangles cannot be allowed to get arbitrarily "skinny."

5.1.1 The standard refinement of a triangulation Beginning with any triangulation of £2, a finer triangulation is formed by placing a new node at the midpoint of every edge of every triangle and joining these new nodes with new edges. This replaces each triangle in the initial triangulation with four smaller triangles, as in Figure 5.1. The resulting mesh is called the standard refinement of the original mesh. It is easy to show that each triangle in the refined mesh is similar to (that is, has the same angles as) its "parent" triangle in the original mesh (see Exercise 3). This property is important to the convergence theory, as I discuss below. Also, each triangle in the refined mesh is half the size of its parent triangle, so the mesh size of the refined mesh is half that of the original mesh. There are several other ways to refine a mesh. The standard refinement is the method of choice when the goal is a uniform refinement, that is, when all of the triangles in the mesh are to be refined. However, as I discuss in Part IV, it is often desirable to refine only some of the triangles in the mesh, in which case other methods have some advantages over the standard refinement.

5.1.2

Nondegenerate families of triangulations

One way to describe the shape of a triangle T is to compare the largest circle contained in T to the diameter of T. The diameter of a set S is defined to be

For a triangle T, diam(T) is simply the length of the longest side of T.

Figure 5.1. Standard refinement of a triangle.

5.1. Approximating smooth functions by continuous piecewise linear functions 107 For each triangle T, d? is defined by

The ratio dr/diam(T) is then a measure of how skinny the triangle T is. If this ratio is very small, then T is long and thin, whereas if the ratio is close to 1 /\/3 (the maximum possible value—see Exercise 1), then T is close to an isosceles triangle. Now consider a family of triangulations with an individual triangulation denoted Th, where h is the maximum diameter of any triangle in T/,. The family {Th} is called nondegenerate if there exists a constant p > 0 such that

Repeated application of the standard refinement procedure produces a nondegenerate family of meshes. The reader is asked for a proof of this in Exercise 4.

5.1.3

Approximation by piecewise linear functions

I begin by considering the use of continuous piecewise linear functions, so the approximating subspace in the finite element method is P^l) (or a subspace of /^(l)). The simplest way to produce an estimate on the smallest error in approximating u from P(h } is to compare the best approximation with the piecewise linear interpolant «/ of a:

The function M/ has the same nodal values as does u itself, which is why a/ is called the interpolant of M. If u/, is the best approximation to u from P^\ it follows that

Therefore, it suffices to bound the error in u / . The following theorem is proved in Chapter 4 of Brenner and Scott [13]. THEOREM 5.1. Suppose {Th} is a nondegenerate family of triangulations of a polygonal domain £2 C R2, and suppose u e H2(£l). Then there exists a constant C depending on Q and the value p from the definition of nondegenerate (but not on u or h) such that

and Here \u\Hi

is the seminorm

and uj e Ph

denotes the piecewise linear interpolant ofu.

108

Chapter 5. Convergence of the finite element method

I hope this theorem will strike the reader as reasonable. The energy norm measures the derivatives of the function. In order to estimate how different the derivatives of a can be from those of its linear interpolant, it is necessary to know how fast the derivatives of u can change. This information is provided by the size of the second derivatives of u (the second derivatives measure the rates of change of the first derivatives), and therefore \u \ # 2 ( Q, appears in the upper bounds. A similar result holds if V is a subspace of Hl(Q), such as HQ(&), instead of Hl(&) itself and Vh is the corresponding subspace of P^ \ The energy norm,

is bounded by a multiple of the Hl(Q) error, and so the above result provides an upper bound on the energy norm error in approximating u. In this context, the error \\u — w/ |U is said to be O(h), meaning bounded by a constant times h, as h goes to zero. In the next section, I will show that by using higher-degree polynomials, convergence rates of O(h2), O(/z3), and so forth can be obtained. First, though, I will give an example of piecewise linear approximation. EXAMPLE 5.2. This example illustrates the accuracy, in both the L2- and H1-norms, of piecewise linear interpolation for the function u(x, y) = x(\ — x) sin (ny). The domain is £2 — (0, 1) x (0, 1), the unit square, and the meshes comprise a sequence of regular triangulations of the type shown in Figures 4.5 and 4.9. The first mesh has a total of& triangles, each an isosceles right triangle with legs of length 1 /2 andh = \/2/2. Successive meshes are obtained by the standard refinement described earlier (the second mesh is the one shown in Figure 4.5). The results are as follows:

5.0000 • IP"1 2.5000 • IP"1 1.250Q.1Q-1 6.2500 • 10-2

5.6484 • IP"2 1.6022 • 10~2 4.1305-IP"3 1.0405 • 10~3

4.1361 • IP"1 2.2448 • IP"1 1.1450-IP'1 5.7536 • 10~2

The reader should notice that \\ u — u /1|L2 (Q) is decreasing approximately ash2 (that is, when h is divided by 2, the error is divided by approximately 4) and ||« — w/ ||//I(Q) is decreasing approximately as h (when h is divided by 2, so is \\u — «/ \\H[(&))-

5.2

Approximation by higher-order piecewise polynomials

The theory in the case of Lagrange triangles of degree d is similar to that described in the previous section. The main result is that increasing the degree of the piecewise polynomials increases the order of approximation in both the L 2 - and //'-norms, provided that the

5.2. Approximation by higher-order piecewise polynomials

109

function being approximated is smooth enough. The reader will recall that P^} is the space of continuous piecewise polynomials of degree d relative to a given mesh Th • The piecewise polynomial interpolant of degree d of a function u is

where

is the standard Lagrange basis for

THEOREM 5.3. Suppose {Th} is a nondegenerate family of triangulations of a polygonal domain Q c R2, and suppose u e Hd+^ (£2). Then there exists a constant C depending on £2 and the value pfrom the definition of nondegenerate (but not on u or h) such that

and Here |M|#/,, and a, Uh satisfy

and

The results of Section 3.2 imply that «/, satisfies

and

In particular, since the piecewise polynomial interpolant «/ of u belongs to V/,,

and

Assuming that Lagrange triangles of degree d are used, the approximation results of the previous section yield and

where C is a positive constant that is independent of u and h, and C" = Cfi/a. 1 now want to show that estimates (5.9) and (5.10) can be extended to the case of inhomogeneous Dirichlet conditions. To obtain the full rate of convergence using piecewise polynomials of degree d, the Dirichlet data must be smooth enough. It is assumed that there is a function G e Hd+[ (£2) such that G = g on PI , where g is the Dirichlet data, and that (5.6) is solved with Gh = G/, the interpolant of G. Then u = w + G, w/, = wh + G/, and (in either norm)

11 2

Chapter 5. Convergence of the finite element method

The bounds (5.9) and (5.10) apply to the term \\w - wh\\, since wh is the finite element solution of a variational problem of the same form as (5.5). Thus

Theorem 5.3 applies directly to the term ||G — G/1|, and thus

Therefore,

If G is chosen so that it is orthogonal to V in the Hd+] (£1) inner product,8 then, by the Cauchy-Schwarz inequality,

Since w and G are orthogonal,

and thus

This yields the estimate

In practice, G/, is not chosen to be G/ (since typically G, and hence G/, are unknown). Instead, G/, is defined to be the piecewise polynomial defined by the following nodal values:

However, any continuous piecewise polynomial interpolating g at the constrained nodes (including G/) yields the same computed solution uh as does Gh. To prove this, I assume that GJ,I} e P(hd) agrees with g at the constrained nodes, that w^ e V/, satisfies

and that u(hl) = w(^ + GJ^. I need to show that wj,0 = uh. 8 Any G e //'/+1 (Q) satisfying G = g on r\ can be replaced by G - VG, where DC is the orthogonal projection onto V of G in the //'/+l(£2)-norm. Then, since VG — 0 on PI, G — DC = g on PI, and G — VG is orthogonal to V by the definition of orthogonal projection.

5.3. Convergence in the energy norm

1 13

Let g ( l ) e RN" be the vector of nodal values of GJ^. Then

where G/, is the piecewise polynomial whose nodal values agree with g at the constrained nodes and are zero elsewhere, and g ( l ) e RNf is defined by g(k } = g^\ Then, writing [/(i) e R/V/ f or me vector of (free) nodal values of u(h * and similarly for W(l\ it follows thatt/ ( 1 ) = W ( I ) + £ ( l ) . Now, for any i = 1 , 2, . . . , N/, the load vector F ( l ) is defined by

Therefore, F ( l ) — F — Kg(l\ where F is the load vector corresponding to G/,, and thus

This shows that the computed finite element solution w/, is the same no matter which interpolant Gh is used, and therefore (5.11) holds. The following theorem summarizes the results of this section. THEOREM 5.5. Suppose £2 is a polygonal domain in R2 and let {Th} be a nondegenerate family of meshes on £2 consisting ofLagrange triangles of degree d. Assume K is defined on £2 and there exist constants ko, k\ such that 0 < ko < K < k\ on £1 Finally, assume that the solution u of (5.5) satisfies u e Hd+*(Q), and let UK be the finite element solution of the BVP relative to the mesh Th. Then there exist constants C, C', both independent ofu and h, such that

Chapter 5. Convergence of the finite element method

114

and The following example illustrates Theorem 5.5. EXAMPLE 5.6. Suppose £1 is the unit square, and consider the BVP

where K(X, y) = 1 + xy2 and f is chosen so that the exact solution is

Using linear Lagrange triangles on a sequence of regular meshes, the following errors are obtained: 5.0000-IP"1 2.5000 • IP"1 1.2500-1Q-1 6.2500 • 10-2

4.0757 • IP"1 2.2369 • IP"1 1.1441-10"1 5.7524 • 10~2

The function u and the meshes are the same as in Example 5.2, which examined the error in the piecewise linear interpolant u\. Comparing the results from these examples shows that \\u —uh \\Hi(Q) and \\u-uj ||//I(Q) are very similar. The following tables give the errors in the finite element solution using piecewise quadratic, cubic, and quartic polynomials. They can be compared with the interpolation errors from Example 5.4. Quadratic Lagrange triangles:

5.0000 • KT1 2.5000-IP" 1 1.2500-1Q- 1 6.2500-10- 2

1.2337 • IP"1 3.3035-IP" 2 8.4222-IP" 3 2.1165-10- 3

5.0000-IP' 1 2.5000-IP" 1 1.2500-1Q- 1 6.2500 • 10-2

2.1926-KT 2 2.7850 • 1(T3 3.4686-IP" 4 4.3184-1Q- 5

Cubic Lagrange triangles:

5.4. Convergence in the L2-norm

115

Quartic Lagrange triangles:

5.0000-1Q- 1 2.5000-10-' 1.2500-10-' 6.2500 • 10~2

2.9626-1Q- 3 1.9044-Kr 4 1.1961-1Q- 5 7.4744-1Q- 7

// is also of interest to examine the error in the energy norm defined by the coefficient K, since the basis of finite element Galerkin theory is that \\ u — w/, ||E is as small as possible. To confirm this, the following table compares (for the linear triangles) the energy norm error n to the same error inu\.

5.0000 • IP"1 2.5000 • 10-' 1.2500 • IP"1 6.2500 • 1(T2

4.3468 • IP"1 2.3953 • IP"1 1.2262-KT1 6.1672- 1(T2

4.2675 - 10"' 2.3781 • IP"1 1.2238-IP"1 6.1640 • 10~2

Although the differences are not large, the results show that uh does indeed have a smaller energy norm error than «/.

5.4

Convergence in the L2-norm

There is a standard trick, called a duality argument, for deriving an L2-estimate from an energy norm estimate. This argument requires that solutions of the BVP under consideration have the elliptic regularity property, namely, that the solution has two degrees more of smoothness (in the weak sense) than the right-hand side of the PDE. The elliptic regularity property is not difficult to understand. Consider a one-dimensional BVP of the form

The solution can be obtained directly by integrating twice:

From this formula and the fundamental theorem of calculus, it is obvious that if / is continuous, then u is twice continuously differentiable. It is not at all obvious that such a property would extend to BVPs in multiple dimensions, since solutions cannot be obtained by direct integration. However, if the

116

Chapter 5. Convergence of the finite element method

geometry of Q is not too complicated and if any coefficients appearing in the PDE are smooth enough, then elliptic regularity holds. The usual model problem,

will be used for illustration. For example, in two-dimensional problems, if / € L2(Q), K is smooth, and • either FI or F2 is empty (that is, the boundary conditions are either pure Dirichlet or pure Neumann), and • either dQ is smooth or Q is convex, then the solution u is guaranteed to belong to //2(£7). Moreover, there is a constant C such that Proofs can be found in Rauch [34] or, for the case of a nonsmooth 9£2, in Grisvard [23]. Elliptic regularity can be used to derive an L2-estimate on the error u — w/,, where u is the solution to the variational form of (5.12) and Uh is the piecewise linear finite element solution for a corresponding approximating subspace V/,. Here is the duality trick: Writing a(-, •) for the usual energy inner product for (5.12) and (•, •) for the L2 inner product, w e V is defined to be the solution to the variational problem

where V is the appropriate variational space (V = HQ (£2) for a Dirichlet problem or V — V for a Neumann problem, where V is defined as in Section 2.5). Since u — uh e L 2 (£2), the solution u; belongs to H2(£2). Then

Since the interpolant w{ belongs to V/,,

and which imply that

By the elliptic regularity assumption, w e H2(Q) and therefore, by the interpolation results given in Section 5.2, there is a constant C such that

5.4. Convergence in the L 2 -norm

11 7

It follows that By the elliptic regularity assumption, there is another constant C such that Combining ft and the two constants denoted above by C into a new constant, also denoted by C, yields

or Finally, applying the estimate derived in the previous section for \\u — «/j||//i(Q) yields (with a new value for the constant C). This should be compared with the estimate In the L 2 (£2)-norm, another factor of h is obtained; the error is O(h2) instead of O(h) in the energy or //' (£2)-norms. EXAMPLE 5.7. This is a continuation of Example 5.6. Here the errors in the L2-norm are recorded: Linear Lagrange triangles:

5.0000-10"' 2.5000-10-' 1.2500-10-' 6.2500-10-2

7.0613 • 10~2 2.2713 • 10~2 6.0681 • IP"3 1.5429-10-3

Quadratic Lagrange triangles: 5.0000-Kr 1 2.5000 • 1Q-1 1.2500-10-'" 6.2500 • 10~2

9.4421 • 10~3 1.1035-1Q- 3 1.3429-ICF^ 1.6663-KT 5

5.0000-10-' 2.5000-IP' 1 1.2500-1Q- 1 6.2500- 1(T2

1.1370-1Q- 3 6.7872-IP" 5 4.0669-lO" 6 2.4862 • KT7

Cubic Lagrange triangles:

Chapter 5. Convergence of the finite element method

118

Quartic Lagrange triangles:

5.0000. 10-1 1.2326.10-4 2.5000. 10-1 3.9821. 10-6 1.2500.10 -1 1.2552. 10-7 6.2500.10-2 3.9273. 10-9

The reader can verify that the expected asymptotic rates of convergence are observed. For example, in the quartic case, the L1-error should be O(h5), so reducing h by a factor of 2 should reduce the error by a factor of approximately 32. Here are the actual results: Decrease in 5.0000. 10-1 2.50000.10-1 30.954 1.25000.10-1 31.725 6.2500. 10-2 31.961

5.5

Variational crimes

The title of this section is a phrase coined by Strang [40] to describe violations of the variational framework, whose theory has been described in the preceding sections of this chapter. Two examples of variational crimes are the use of numerical integration (quadrature) and the use of isoparametric finite elements to approximate curved boundaries. When quadrature is used, the stiffiiess matrix K and the load vector F are not computed exactly, so the theory as presented above does not apply directly. On the other hand, when £2 is not polygonal, the finite element method solves a problem on an approximate domain £2/,. In this case also, the theory developed in the preceding sections does not apply. In this section I will briefly summarize extensions of the theory covering these variational crimes. I will use the model problem

to illustrate the ideas. The results described here can be extended to inhomogeneous boundary conditions and other PDEs.

5.5.1

Numerical integration

In assembling K and F, integrals of the form

5.5. Variational crimes

119

must be computed, where T is a triangle in the mesh and 0,, 4>j are basis functions that reduce to polynomials when restricted to T. These integrals may be difficult or impossible to compute exactly, depending on the form of K and /. To estimate the above integrals, a quadrature rule of the form

can be used. Here (jc|r), y(jT)), j — 1, 2, . . . , n, are the quadrature nodes on T and w(j \ j — 1 , 2, . . . , n, are the corresponding quadrature weights. Specific quadrature rules will be presented in Part II. For this discussion, the specific rules are not important; only the concept of degree of precision is needed to analyze the effect of quadrature on the finite element method. A quadrature rule has degree of precision p if it integrates polynomials of degree p or less exactly. Since the finite element method is based on piecewise polynomials, it is natural to classify quadrature rules by their degrees of precision. However, since the coefficient K and the forcing function / need not be polynomial, the integrals (5.14) may not be computed exactly regardless of how high the degree of precision of the quadrature rule. Some kind of analysis is therefore required to prove that K and F are computed accurately enough that convergence is still obtained. Furthermore, mere convergence is probably not acceptable; it would be desirable to compute the integrals accurately enough that the rate of convergence, as presented in the previous sections, is unchanged. The effect of quadrature is to replace the variational problem

by where a/, (-, •) and if, are defined by the quadrature rules (applied element by element) rather than by the usual integrals. There are then three functions to consider: the exact solution u of (5.13), the solution w/, of (5.15) (analyzed in the previous sections), and the solution uh of (5.16). By the triangle inequality,

If, for example, Lagrange triangles of degree d are used, then, by Theorem 5.5,

It would be desirable, then, that

also hold. It is easy to guarantee (5.17), although the proof is quite involved. The entries in the stiffness matrix K are assembled from the integrals

120

Chapter 5. Convergence of the finite element method

If the coefficient function K happens to be constant, then the integrands are polynomials of degree 2d — 2, and hence the integrals will be computed exactly by a quadrature rule having degree of precision 2d — 2. It turns out that such a quadrature rule, although not exact if K is nonconstant, nevertheless leads to a solution uh satisfying (5.17). The analysis, which I briefly outline below, assumes that the same quadrature rule is used for all integrals (those that contribute to K and those that contribute to F).

5.5.2

Outline of the analysis of the effect of quadrature

The proof of the above conclusion is based on the following two results: LEMMA 5.8. Let V be a Hilbert space, Vh a finite-dimensional subspace ofV, «(-,-) a symmetric, bounded, V-elliptic bilinear form, and t a bounded linear functional on V. Further, letah(-,-} be a symmetric, bounded, Vh-elliptic bilinear form andlh be abounded linear functional on Vh. Ifuf, is the unique solution to

and Uh is the unique solution to

then

Proof. Since

and Therefore,

This completes the proof. The preceding lemma is completely elementary, but has the following consequence. THEOREM 5.9.

and

be as in the preceding lemma. Suppose

5.5. Variational crimes

121

and there exists a constant C > 0 such that

Then

Proof. By the preceding lemma,

Applying the V^-ellipticity to bound the left-hand side below and the hypothesis to bound the right-hand side above yields

or

as desired. As discussed above, it is desired that

so p should be d in the preceding theorem. Therefore, it is first necessary to show that when a quadrature rule having degree of precision 2d — 2 is used, the approximate bilinear forms «/,(-, •) are uniformly Vh-elliptic:

This is straightforward if the quadrature weights are assumed to be positive, as is true for many common quadrature rules (cf. Sections 7.1 and 8.1). It is then necessary to show that a quadrature rule having degree of precision 2d - 2 results in and

The proofs of these results are quite involved and will not be given here; probably the best source is Ciarlet [16, Section 4.1].

5.5.3

Isoparametric finite elements

When Q, has a curved boundary and isoparametric finite elements are used, an approximate domain £2h is involved. This has several implications: Essential boundary conditions will not, in general, be satisfied exactly as they are in the case of a polygonal domain. The domain Q^ may extend outside of Q in places, and the problem functions K, / may not be defined on Qh\Q. The shape functions on elements with a curved boundary will not be polynomials, raising the question of whether a quadrature scheme based on integrating polynomials exactly will be adequate.

122

Chapter 5. Convergence of the finite element method

The issues raised in the previous paragraph can all be surmounted by an analysis that is very similar in outline to that given above. One begins by establishing bounds on the interpolation error for isoparametric elements. This is possible only if the elements in the meshes Th are not too distorted from triangles, which imposes certain constraints on the construction of the meshes (similar to the definition of a nondegenerate family of meshes). These constraints impose conditions on how far the nodes on the curved boundary can be from the corresponding nodes on the ordinary (nonisoparametric) triangle, and also on the placement of the interior nodes (if d > 2)—conditions which can be satisfied if the boundary of £2 is smooth or piecewise smooth. Next, an error bound analogous to Theorem 5.9 is established, the uniform V/jellipticity of the approximate bilinear form is verified, and finally, bounds analogous to (5.23) and (5.24) are established. All of this is carried out in detail for the case of quadratic Lagrange triangles in Ciarlet [16, Sections 4.3 and 4.4]. The result of all this analysis (see page 269 of [16]) is that the error using isoparametric finite elements goes to zero at the same rate as if ordinary Lagrange triangles were used on a polygonal domain. Moreover, this conclusion is valid when the same quadrature rule is used as for ordinary triangles (degree of precision 2d — 2).

5.6

Exercises for Chapter 5

1. Show that if T is an isosceles triangle, then

2. Suppose (jcj, y\), (x2, yi), (x^, ^3) are the vertices of a triangle T. The barycentric coordinates (a\, 0.2, oti,) of (x, y) e T are defined by

Let di denote the distance from (jc, y) to the side of T opposite (jc,-, >>/) and let h, denote the distance from (jc/, yt) to the opposite side of T. (a) Show that (Hint: i. First show that the line L(a^) defined by

(e*3 e (0, 1) fixed) is parallel to the edge of T joining (x\, y\) and te, ^2) ii. Find the distance between the line L(a^) and the line through (jci, >>]) and (*2, yi) and show that it equals ^3/13. (The proofs for d\ and di are then exactly analogous.))

5.6. Exercises for Chapter 5

123

(b) A circle is inscribed in T if and only if its center (a\, ct2, o^) satisfies d\ = d2 — d-\,. Using this condition, show by direct calculation that the center of the inscribed circle is given by

and the radius of the circle is

(c) Now let b\ be the length of T opposite (^3, ^3), b^ the length of the side opposite (jci, >'i), and £3 the length of the side opposite (x2, ^2). Show that the radius of the inscribed circle can be written

where |T| denotes the area of T. (d) Let dT be the diameter of the largest circle contained in a triangle T, as defined in Section 5.1.2. Prove that

for all triangles T. 3. Let T be any triangle and suppose T is refined to four triangles by joining the midpoints of the edges of T, as in Figure 5.1. Prove the four new triangles are each similar toT. 4. Suppose a sequence of triangulations To, T\, T2,... is formed by standard refinement: Each 71- is the refinement of Tk-\ • Prove that these meshes form a nondegenerate family: There exists p > 0 such that

(Hint: Use the preceding exercise.) 5. Let £2 be a polygonal domain in R2 and let To, T\,... be a sequence of triangulations of £2 formed by standard refinement. Let P(k]) be the space of continuous piecewise linear functions relative to 7*. Assume that u e H] (£2) (but u is not necessarily in

124

Chapter 5. Convergence of the finite element method

H2(Q)), and let u(k) be the best approximation to u from P(kl) in the //1(^)-norm. Prove that (Hint: The space // 2 (fi) is dense in Hl(&), so there is a sequence {u/} in H2(£2) converging to u in the Hl(Q)-norm. Let vj} be the best approximation to Vj from T^. Use the fact that, for each j,

Part II

Data Structures and Implementation

This page intentionally left blank

Chapter 6

The mesh data structure

This part of the book discusses the implementation of the finite element algorithm in computer programs. In order to make the discussion as straightforward as possible, this chapter and the next will focus on the implementation of linear Lagrange triangles for the model problem

where £2 is a polygonal domain and dQ = F] U ["Y After carefully developing programs to handle the above problem, 1 will extend them in Chapter 8 to handle higher-order Lagrange triangles on polygonal domains and then to handle curved boundaries using the isoparametric method. Finally, in Chapter 9, BVPs more general than (6.1) will be treated. In Section 6.1,1 discuss the important issues that must be resolved in order to write a program implementing the finite element method, and outline the overall strategy. Then, in Section 6.2, a data structure for storing the mesh is presented.

6.1 Programming the finite element method 6.1.1 Assembling the stiffness matrix The finite element method, applied to (6.1), produces a matrix-vector equation KU — F, whose solution vector U contains the nodal values of the approximate solution function. There are three important steps in applying the finite element method: • Creating a mesh on the computational domain £1. • Computing the stiffness matrix K and the load vector F. • Solving the linear system KU — F. 127

128

Chapter 6. The mesh data structure

In this part of the book, I will mostly concentrate on the second step. Section 6.3 gives examples of several different ways to generate a mesh on a given domain. Part IV presents algorithms for local refinement of meshes; these algorithms are intended to produce a mesh that is custom designed for a given problem. I defer the discussion of the solution of KU = F to Part III. For examples in this part of the book, the linear systems will be solved by the direct solver for sparse systems in MATLAB. Throughout the following discussion, Th is a triangulation of the polygonal domain Q and PA(1) is the space of continuous piecewise linear functions defined on Th- The stiffness matrix K corresponding to the BVP (6.1) is defined by

where {], 0 2 > • • • > Nf} is the basis for the approximating subspace Vh and

In the case of linear Lagrange triangles, the subspace V/, is the following subspace of P^ \ as described in Section 4.1.1:

The basis {Nf} consists of the standard basis functions for P^ } that correspond to the Nf free nodes in the mesh. The reader should recall the following requirement on the triangulation: Any point where F] and F2 meet must be a node in the mesh, and this node is considered to belong to F]. Most entries Ky of the stiffness matrix are zero, since the corresponding integrand K V0y • V0, is zero throughout £2. For those entries KJJ that are not zero, the support of KV(f>j • V0/ consists of a few triangles. One strategy for computing K is to loop over all i, j pairs, determine if KJJ is nonzero, and, if it is, compute the integral that defines it. If KIJ is nonzero and the support of K V0y • V0/ is

then

To compute these integrals, it is necessary to compute the basis functions / and 07 (or, actually, their gradients) on each of the triangles T r { , Tr2,..., Tfl. Algorithm 6.1 expresses this approach to computing K. This algorithm can be described as node-oriented, since it involves looping over the nodes in the mesh. The reader will notice that only the upper triangle of K is computed directly, since the matrix is known to be symmetric (Kji = K^).

6.1. Programming the finite element method

129

Initialize K to the zero matrix for for Determine if K is nonzero if Determine the triangles support of Set for

Compute Compute

and

forming the

on and add it to

Set

Algorithm 6.1. Node-oriented algorithm for computing the stiffness matrix K.

Figure 6.1. The support 0/013 in a certain mesh. The triangles are labeled in the left graph, while the free nodes are labeled in the right graph. One problem with Algorithm 6.1 is that the value of any given V, on any particular Tk will contribute to Kfj for several (usually three) values of j. For example, for the mesh illustrated in Figure 6.1, the value of V0!3 on T2o contributes to #13,12, #13,13, and #13,18 (and, by symmetry, #12.13, #18.13). Therefore, it must be computed repeatedly (at the cost of some inefficiency) or stored after it is computed (at the cost of some inconvenience). It would be preferable, if possible, to compute V0, just once on each triangle in its support, use its value, and then discard it. The simplest data structure describing a triangulation is the triangle-node list. This consists of two arrays: The node array contains the coordinates of the nodes, and the triangle array contains three indices for each triangle, identifying the nodes (from the nodes array) that are the vertices of the given triangle. When Algorithm 6.1 is executed, it is necessary to loop over the vertices of the triangles and to know, for a given vertex, which other vertices are adjacent to it. This implies storing the "connectivity" information of the mesh (that is, storing, for each vertex, the indices of the adjacent nodes). This connectivity information is contained in the triangle-node list, but only implicitly. It would be inefficient

130

Chapter 6. The mesh data structure

to search through the list of triangles and vertices to determine the connectivity of the vertices. Algorithm 6.1 therefore requires that both the triangle-node list and the connectivity information be stored explicitly. It turns out that by adopting a different strategy for computing K, both of the above problems can be circumvented: 0, on Tk need be computed only once, and the connectivity information need not be stored explicitly. The idea is to loop over the triangles in the mesh and, for each triangle, compute the contributions to all entries KJJ that are affected by the given triangle. This is actually quite easy to do. Given a triangle Tk, the only basis functions whose support has a nontrivial intersection with Tk are those corresponding to the vertices of 7^. There are at most three such basis functions (fewer if one or more vertices are constrained). If all three vertices of Tk are free and the corresponding basis functions are then the following entries of K are affected:

The contribution to KI ^ is

To be precise,

where "H " represents integrals of KV<j>ep • V4>tr/ over the other triangles that form its support. The integrals computed over Tk are often collected in a 3 x 3 matrix called the element stiffness matrix (over Tk):

This matrix need not be formed explicitly (except possibly as a programming convenience); rather, its entries are added to the corresponding entries of K. When computing the entries of the element stiffness matrix, it may be advantageous to compute the integrals by transforming to the reference triangle, as described in Section 4.6. The advantages of using a reference triangle will be discussed in Chapters 7 and 8. As always, the symmetry of A' should not be ignored. It is necessary to compute only six of the nine entries of the element matrix, namely, those in the upper triangle. If one of the three vertices of Tk is constrained, then Tk contributes to only four entries of K, while if two of the vertices are constrained, then Tk contributes to a single entry in K. It is possible that all three vertices of Tk can be constrained, but this could hold for only a few triangles in a given mesh, for example, those lying at the corner of a rectangle.

6.1. Programming the finite element method

131

Algorithm 6.2 incorporates the above ideas. The reader should recall that the vertices of

are Initialize k to the zero matrix for for for if and are both free Find the indices Compute

and

of

and

in the list of free nodes

and add it to

and to

Algorithm 6.2. Element-oriented algorithm for computing K. To implement this algorithm, it is necessary to know, for each triangle Tk, the nodes z , j — 1, 2, 3. This information is required by any conceivable scheme, since integrals over Tk must be computed, and is contained in the triangle-node list. In addition, it must be possible to determine if a given vertex z« is free or not. If it is free, its index in the list of all free nodes must be known. I have already established the following notation: The free nodes are enumerated 1 , 2, . . . , Nf and the vertices are enumerated \,2, . . . , Nv. Free node j is vertex z /,. . That is, I have established a mapping from j e {1, 2, . . . , N/} to /) e { 1 , 2 , . . . , Nv}. This mapping is necessarily one-to-one, so it has an inverse mapping defined by /?/ = j if and only if j e {1, 2, . . . , Nf} and i = f j . Except in the case that every node is free, the quantity /?, is not defined for some i e { 1 , 2, . . . , Nv}. For each node zn, it is necessary to store pn or a flag indicating that zn is constrained. I will present a convenient way to do this in the next section. For now I just point out that, given this information, the above algorithm is efficient and easy to implement. Since I will need it later, I will also define

This page intentionally left blank

Understanding and Implementing the Finite Element Method Mark S. Gockenbach Michigan Technological University Houghton, Michigan

51HJTL Society for Industrial and Applied Mathematics Philadelphia

Copyright © 2006 by the Society for Industrial and Applied Mathematics. 10987654321 All rights reserved. Printed in the United States of America. No part of this book may be reproduced, stored, or transmitted in any manner without the written permission of the publisher. For information, write to the Society for Industrial and Applied Mathematics, 3600 University City Science Center, Philadelphia, PA 19104-2688. Trademarked names may be used in this book without the inclusion of a trademark symbol. These names are used in an editorial context only; no infringement of trademark is intended. Maple is a registered trademark of Waterloo Maple, Inc. Mathematica is a registered trademark of Wolfram Research, Inc. MATLAB is a registered trademark of The Math Works, Inc. and is used with permission. The Math Works does not warrant the accuracy of the text or exercises in this book. This book's use or discussion of MATLAB software or related products does not constitute endorsement or sponsorship by The Math Works of a particular pedagogical approach or particular use of the MATLAB software. For MATLAB information, contact The MathWorks, 3 Apple Hill Drive, Natick, MA 01760-2098 USA, Tel: 508-647-7000, Fax: 508-647-7001, [email protected] com, www. mathworks. com

Library of Congress Cataloging-in-Publication Data Gockenbach, Mark S. Understanding and implementing the finite element method / Mark S. Gockenbach. p. cm. Includes bibliographical references and index. ISBN 0-89871-614-4 (pbk.) 1. Finite element method. 2. Finite element method—Data processing. TA347.F5G63 2006 518'.25—dc22

ZZuOlJ IL is a registered trademark.

I. Title. 2006045012

Dedicated to Joao and all of oa& cbildReo

This page intentionally left blank

Contents Preface

1

xiii

The Basic Framework for Stationary Problems

1

1

Some model PDEs 3 1.1 Laplace's equation; elliptic BVPs 3 1.1.1 Physical experiments modeled by Laplace's equation . . . 5 1.2 Other elliptic BVPs 8 1.2.1 The equations of isotropic elasticity 8 1.2.2 General linear elasticity 10 1.3 Exercises for Chapter 1 11

2

The weak form of a BVP 2.1 Review of vector calculus 2.1.1 The divergence theorem 2.1.2 Green's identity 2.1.3 Other forms of the divergence theorem and Green's identity 2.2 The weak form of a BVP 2.2.1 Minimization of energy 2.2.2 Relaxing the PDE 2.2.3 A few details about Sobolev spaces 2.3 The weak form for other boundary conditions and PDEs 2.3.1 Neumann conditions and the weak form 2.3.2 Mixed boundary conditions 2.3.3 Inhomogeneous boundary conditions 2.3.4 Other elliptic BVPs 2.4 Existence and uniqueness theory for the weak form of a BVP 2.4.1 Vector spaces and inner products 2.4.2 Hilbert spaces 2.4.3 Linear functionals 2.4.4 The Riesz representation theorem . 2.4.5 Variational problems and the Riesz representation theorem vii

15 15 15 17 18 20 21 23 27 29 29 31 31 33 35 35 39 41 42 42

viii

Contents 2.5

2.6 2.7

Examples of ellipticity 2.5.1 The model problem 2.5.2 The equations of isotropic elasticity Variational formulation of nonsymmetric problems Exercises for Chapter 2

45 45 48 51 53

3

The Galerkin method 57 3.1 The projection theorem 57 3.2 The Galerkin method for a variational problem 59 3.2.1 Another interpretation of the Galerkin method 62 3.2.2 The Galerkin method for a nonsymmetric problem . . . . 63 3.3 Exercises for Chapter 3 63

4

Piecewise polynomials and the finite element method 67 4.1 Piecewise linear functions defined on a triangular mesh 67 4.1.1 Using piecewise linear functions in Galerkin's method . . 70 4.1.2 The sparsity of the stiffness matrix 74 4.2 Quadratic Lagrange triangles 77 4.2.1 Continuous piecewise quadratic functions 77 4.2.2 The finite element method with quadratic Lagrange triangles 78 4.3 Cubic Lagrange triangles 80 4.3.1 Continuous piecewise cubic functions 80 4.3.2 The finite element method with cubic Lagrange triangles . 83 4.4 Lagrange triangles of arbitrary degree 84 4.4.1 Hierarchical bases for finite element spaces 85 4.5 Other finite elements: Rectangles and quadrilaterals 86 4.5.1 Rectangular elements 86 4.5.2 General quadrilaterals 87 4.6 Using a reference triangle in finite element calculations 91 4.7 Isoparametric finite element methods 93 4.7.1 Isoparametric quadratic triangles 96 4.7.2 Isoparametric triangles of higher degree 100 4.8 Exercises for Chapter 4 101

5

Convergence of the finite element method 5.1 Approximating smooth functions by continuous piecewise linear functions 5.1.1 The standard refinement of a triangulation 5.1.2 Nondegenerate families of triangulations 5.1.3 Approximation by piecewise linear functions 5.2 Approximation by higher-order piecewise polynomials 5.3 Convergence in the energy norm 5.4 Convergence in the L2-norm 5.5 Variational crimes 5.5.1 Numerical integration

105 105 106 106 107 108 110 115 118 118

Contents

5.6

II

ix 5.5.2 Outline of the analysis of the effect of quadrature 5.5.3 Isoparametric finite elements Exercises for Chapter 5

Data Structures and Implementation

120 121 122

125

6

The mesh data structure 6.1 Programming the finite element method 6.1.1 Assembling the stiffness matrix 6.1.2 Computing the load vector 6.2 The mesh data structure 6.2.1 The list of nodes 6.2.2 The list of edges 6.2.3 The list of elements 6.2.4 The list of free boundary edges 6.2.5 Other fields in the mesh data structure 6.3 The MATLAB implementation 6.3.1 Generating a mesh by refinement 6.3.2 Generating a mesh from a triangle-node list 6.3.3 Assessing the quality of a triangulation 6.3.4 Viewing a mesh 6.3.5 Handling a domain with a curved boundary 6.3.6 Viewing a piecewise linear function 6.3.7 MATLAB functions 6.3.8 A summary of the notation 6.4 Exercises for Chapter 6

7

Programming the finite element method: Linear Lagrange triangles 155 7.1 Quadrature 155 7.1.1 Gaussian quadrature 155 7.1.2 Evaluating the standard basis functions on a triangle . . . 162 7.1.3 Quadrature over a square 165 7.2 Assembling the stiffness matrix 166 7.3 Computing the load vector 168 7.3.1 Inhomogeneous Dirichlet conditions 169 7.3.2 Inhomogeneous Neumann conditions 170 7.4 Examples 171 7.4.1 Homogeneous boundary conditions 173 7.4.2 Inhomogeneous boundary conditions 174 7.4.3 A more realistic example 179 7.5 The MATLAB implementation 182 7.5.1 MATLAB functions 182 7.6 Exercises for Chapter 7 183

127 127 127 131 134 134 135 135 137 137 138 139 140 142 144 147 148 150 151 152

x

Contents

8

Lagrange triangles of arbitrary degree 8.1 Quadrature for higher-order elements 8.2 Assembling the stiffness matrix and load vector 8.3 Implementing the isoparametric method 8.3.1 Placement of nodes in the isoparametric method 8.4 Examples 8.5 The MATLAB implementation 8.5.1 version2 8.5.2 versions 8.6 Exercises for Chapter 8

187 187 192 195 199 200 203 203 205 206

9

The finite element method for general BVPs 9.1 Scalar BVPs 9.1.1 An example 9.2 Isotropic elasticity 9.3 Mesh locking 9.4 The MATLAB implementation 9.5 Exercises for Chapter 9

209 209 212 213 218 220 221

III Solving the Finite Element Equations

223

10

Direct solution of sparse linear systems 10.1 The Cholesky factorization for positive definite matrices 10.1.1 The Cholesky factorization for dense matrices 10.1.2 The Cholesky factorization for banded matrices 10.2 Factoring general sparse matrices 10.3 Exercises for Chapter 10

225 225 226 228 229 233

11

Iterative methods: Conjugate gradients 11.1 The CG method 11.1.1 The CG algorithm 11.1.2 Convergence of the CG algorithm 11.2 Hierarchical bases for finite element spaces 11.2.1 Hierarchical bases for linear Lagrange triangles 11.2.2 Relationship between the stiffness matrices in nodal and hierarchical bases 11.3 The hierarchical basis CG method 11.4 The preconditioned CG method 11.4.1 Alternate derivation of PCG 11.4.2 Preconditioners 11.5 The pure Neumann problem 11.6 The MATLAB implementation 11.6.1 MATLAB functions 11.7 Exercises for Chapter 11

235 235 239 243 244 244 249 250 252 253 254 256 262 262 263

Contents 12

The classical stationary iterations 12.1 Stationary iterations 12.1.1 Matrix norms 12.1.2 Convergence of stationary iterations 12.2 The classical iterations 12.2.1 Jacobi iteration 12.2.2 Gauss-Seidel iteration 12.2.3 SOR iteration 12.2.4 Symmetric SOR 12.2.5 CG with SSOR preconditioning 12.3 TheMATLAB implementation 12.3.1 MATLAB functions 12.4 Exercises for Chapter 12

13

The multigrid method 13.1 Stationary iterations as smoothers 13.1.1 The stiffness matrix for the model problem 13.1.2 Fourier modes and the spectral decomposition of K 13.1.3 Jacobi iteration 13.1.4 Weighted Jacobi iteration 13.2 The coarse grid correction algorithm 13.2.1 Projecting the equation onto a coarser mesh 13.2.2 The projected equation and the Galerkin idea 13.2.3 The two-grid multigrid algorithm 13.3 The multigrid V-cycle 13.3.1 W-cycles and/^-cycles 13.4 Full multigrid 13.4.1 Discretization, algebraic, and total errors 13.5 The MATLAB implementation 13.5.1 MATLAB functions 13.6 Exercises for Chapter 13

xi 267 267 268 270 270 271 272 273 274 275 276 276 276 279 279 279 . . . 281 284 287 291 292 294 295 296 300 300 303 304 304 305

IV Adaptive Methods

307

14

309 311 311 312 315 317 322 324 325

Adaptive mesh generation 14.1 Algorithms for local mesh refinement 14.1.1 Algorithms based on the standard refinement 14.1.2 Algorithms based on bisection 14.2 Selecting triangles for local refinement 14.3 A complete adaptive algorithm 14.4 The MATLAB implementation 14.4.1 MATLAB functions 14.5 Exercises for Chapter 14

xii 15

Contents Error estimators and indicators 15.1 An explicit error indicator based on estimating the curvature of the solution 15.2 An explicit error indicator based on the residual 15.3 The element residual error estimator 15.4 Some final examples 15.4.1 A discontinuous coefficient 15.4.2 A reentrant corner 15.4.3 Transition from Dirichlet to Neumann conditions 15.5 The MATLAB implementation 15.5.1 MATLAB functions 15.6 Exercises for Chapter 15

329 330 334 340 345 346 346 348 349 349 349

Bibliography

353

Index

357

Preface The finite element method is the most popular general purpose technique for computing accurate solutions to partial differential equations (PDEs). Since PDEs form the basis for many mathematical models in the physical sciences and, increasingly, in other fields as well, it would be difficult to overstate the importance of the finite element method. There are a number of excellent books, such as Brenner and Scott [13], Strang and Fix [41], and Ciarlet [16], covering the theory of finite elements, but these books tend to devote little attention to the practical details of programming the algorithms. While the occasional talented student can work out a reasonable scheme without further help, I think most students will benefit from a careful explanation of data structures and specific coding strategies. This book explains how to write a finite element code from scratch. In addition, it comes with a collection of MATLAB® programs implementing the ideas presented in the book. Students can use these codes to experiment with the method and extend them in various ways to learn more about programming finite elements. In addition to a careful explanation of computer implementation (Part II), I have also included, in Part 1, an overview of the theoretical basis of the finite element method. My purpose is to give the reader a good understanding of the "big picture" without getting bogged down in the technical details of the theory. The overview also serves to define the context and notation for discussing computer codes. The finite element method reduces a boundary value problem for a linear PDE to a system of linear equations, written in matrix-vector form as KU — F, that must be solved. Part I derives this system of equations, and the algorithms in Part II show how to compute the matrix K and the vector F. Part III presents algorithms for solving KU = F efficiently even when this system is very large. The final part of the book discusses the related issues of a posteriori error estimation and adaptive error reduction. It is possible to analyze the computed finite element solution so as to estimate the errors present in the solution and to determine the regions of the computational domain where the solution can most profitably be improved. Part IV explains the various aspects of developing an adaptive finite element algorithm. Throughout the book, my goal is to provide students with a practical, working knowledge of finite elements. This knowledge should provide an excellent foundation for those who wish to delve into advanced texts on the subject.

xiii

xiv

Preface

Detailed outline of the book Although I mention the finite element method above, in fact, there are a number of finite element methods, sharing common features but with important differences. I focus my attention on the Galerkin finite element for steady-state boundary value problems (BVPs). The Galerkin method has a strong and elegant theoretical base that is accessible to undergraduate students with some knowledge of linear algebra. In Chapter 1,1 present the PDEs that are the focus of this book and discuss the physical phenomena that they model. As I mentioned in the previous paragraph, these models are steady state, that is, they describe equilibria in various systems. The Galerkin finite element method is based on three important ideas, which are presented in Chapters 2,3, and 4. The first is that a BVP presented in its classical ("strong") form can be recast in weak or variational form, as explained in Chapter 2. The weak form of a BVP is an algebraic formulation of the problem that allows the use of the Galerkin method. The Galerkin method, explained in Chapter 3, is a natural way of projecting the (infinitedimensional) equation onto a finite-dimensional approximating subspace. The result (for a linear BVP) is a (finite-dimensional) system of linear equations whose solution yields an approximate solution to the BVP. In fact, in a certain sense, the approximate solution is the best possible approximation from the given subspace. The finite element method is the use of certain approximating subspaces in Galerkin's method, namely, subspaces of piecewise polynomials. Piecewise polynomials make it (relatively) easy to form and solve the finite element equations. Chapter 4 introduces several spaces of piecewise polynomials that are commonly used in the finite element method. Piecewise polynomials are defined relative to a mesh on the computational domain. A mesh partitions the domain into simple subdomains, called elements. I will concentrate on triangular elements and two-dimensional domains, although I will describe other possibilities, such as quadrilateral elements. Chapter 5 outlines the convergence theory for Galerkin finite elements. I present the technical theorems, such as the necessary interpolation theory for piecewise polynomials, and show how they fit into the convergence theory. However, the proofs and detailed development of these techniques are beyond the scope of this book. The purpose of Chapter 5 is to show the reader what to expect from the finite element method. Part II is about the computer implementation of finite elements. I begin, in Chapter 6, with the strategy for organizing the computations. To make the discussion as concrete as possible, it initially focuses on the common case of piecewise linear functions defined on triangles (linear Lagrange triangles). The strategy described in Section 6.1 determines the information that must be stored to describe the mesh. The mesh data structure (again, restricted to linear Lagrange triangles) is carefully defined in Section 6.2. I have chosen to base the codes for this book on MATLAB, an interactive system that integrates numerical and symbolic computations with graphics and a programming language. I chose MATLAB for several reasons: 1. It is a popular tool in the numerical analysis community. 2. It provides state-of-the-art routines for handling sparse matrices; in particular, it is simple to solve a sparse system of linear equations (such as those produced by the finite element method).

Preface

xv

3. Its graphical capabilities make it easy to visualize meshes and solutions produced by the finite element method. However, the main algorithms are presented in an informal pseudocode that is independent of MATLAB. An excellent way for the student to ensure his or her understanding of these algorithms is to translate the pseudocode into some other high-level programming language, such as Fortran, C, or C++. The MATLAB codes discussed in the text can be downloaded from the following Web page: http://www.math.mtu.edu/"msgocken/fembook The basic computational algorithms are described in Chapter 7. Section 7.2 shows how to compute the stiffness matrix K, which is the finite-dimensional representation of the partial differential operator defining the PDE. Section 7.3 then shows how to compute the load vector F, which represents the right-hand side of the PDE and any nonzero boundary data. An important part of the discussion concerns incorporating various types of boundary conditions into the computations. The algorithms from Chapter 7 are extended in Chapter 8 to allow for piecewise polynomials of degree greater than one. Besides allowing for greater accuracy in approximating the solution, higher-order polynomials also make it possible to approximate a computational domain with a curved boundary with isoparametric elements. The idea of isoparametric finite elements is first presented in Section 4.7, while the implementation details are explained in Section 8.3. Chapters 7 and 8 focus on a simple model problem, because most of the essential ideas can be explained in a fairly simple setting. Chapter 9 shows how to extend the techniques to more complicated problems. Having computed the stiffness matrix and load vector, it remains only to solve the resulting matrix-vector equation and interpret the results. I ignored the issue of solving the system KU — F in Part II, assuming that the built-in solver in MATLAB would be used. However, direct solvers such as the one in MATLAB can use an unacceptably large amount of time and/or computer memory when the system is large. For this reason, iterative methods are often preferred. Part III discusses both direct and iterative algorithms for solving a large system like KU = F. One reason the finite element method is so successful is that piecewise polynomials result in a sparse stiffness matrix K, that is, a matrix in which most of the entries are zero. This makes it possible to solve KU — F even when the number of unknowns is very large. Chapter 10 gives a brief overview of direct methods for solving sparse systems. A direct method produces the exact solution (up to round-off error) in a finite number of steps. I have included Chapter 10 mainly to provide a context for understanding the advantages of iterative methods; a detailed discussion of direct algorithms is beyond the scope of this book. Chapters 11 to 13 describe a number of different iterative algorithms, which compute a sequence of approximate solutions that converges to the exact solution. Although the exact solution of KU = F is computed only in the limit (that is, in an infinite number of steps), a good iterative method can often produce an acceptable solution while using much less time and computer memory than a direct method.

xvi

Preface

Part III includes chapters on conjugate gradients (Chapter 11), Gauss-Seidel and other classical stationary iterations (Chapter 12), and multigrid algorithms (Chapter 13). Multigrid methods use a sequence of increasingly fine meshes to efficiently estimate the solution of KU — F. In the best cases, the time required for a multigrid method to produce an accurate solution is proportional to the number of unknowns. Applying the finite element method requires that a mesh be defined on the computational domain; the accuracy of the computed solution is determined by how well the exact solution can be represented on the chosen mesh. In Part IV, I discuss the various components of an adaptive finite element algorithm, which automatically creates a mesh suited for the problem at hand. Chapter 14 explains algorithms for the local refinement of meshes and a strategy for choosing the elements to be refined. In this chapter, I also present a simple but expensive error estimator and use it to form a complete adaptive algorithm. Several examples show the advantage of the adaptive approach. Many practical error estimators have been proposed. In the final chapter, I describe three such estimators; two of them are explicit and the other is implicit. The explicit estimators are inexpensive to compute and indicate which triangles should be refined to reduce the error in the computed solution. However, they do not provide a quantitative measure of the error, and are more properly called error indicators rather than error estimators. The implicit estimator presented in Section 15.3 is somewhat more expensive but acts as a true estimator. Not only does it indicate where the mesh should be refined, but it also gives an accurate measure of the size of the error. Section 15.4 contains several examples of problems with singular solutions. Adaptive finite element methods are particularly effective on such problems. Exercises are provided at the end of each chapter. Some of these are theoretical, some ask the student to apply the code provided with the text, and others require programming to extend the capabilities of the code. Beyond the given exercises, there is probably no better way to understand the finite element method than to rewrite the MATLAB codes in another programming language. In the process of translating the code into a different syntax, and particularly in testing and debugging, the details must be mastered. The bibliography lists the books and papers that I used directly in writing this manuscript. Babuska and Strouboulis [8] provide extensive reference lists with detailed bibliographical comments. Acknowledgments. I would like to thank the staff at SIAM, particularly my editors Alexa Epstein and Elizabeth Greenspan, for their roles in producing this book. The anonymous reviewers contributed many helpful suggestions, and the final form of the book owes much to their comments. In addition, Dr. A. A. Khan and Dr. B. Jadamba read the entire manuscript carefully and found a number of errors. Their help is gratefully acknowledged. Finally, I am pleased to dedicate this book to my wife Joan and to all of our children: Mary, Mark Jr., Kenric, Lydia, Hope, Nate, Jack, and the newest Gockenbachs, whose arrival is eagerly awaited. MarkS. Gockenbach [email protected]

Parti

The Basic Framework for Stationary Problems

This page intentionally left blank

Chapter 1

Some model PDEs

Finite element methods are flexible and powerful techniques for solving partial differential equations (PDEs). There are actually a number of methods that go under the name of finite elements, so it is somewhat misleading to refer, as I do in the title, to the finite element method. In this book, I describe in some detail the Galerkin finite element method for stationary (equilibrium) problems. In the first part of the book, I derive the Galerkin finite element method, showing it to be the synthesis of three powerful ideas: 1. A boundary value problem (BVP) can be transformed into an equivalent form, called the weak or variational form, that can be approached by different methods, both analytical and computational, than those that apply to the original form of the problem. 2. The Galerkin method produces the best approximation, from a given approximating subspace, to the true solution of a variational problem. Moreover, this best approximation is the solution to a finite-dimensional system of equations. 3. When the approximating subspace in the Galerkin method is chosen to be a subspace of piecewisepolynomial functions, the resulting algorithm is both efficient and effective: The system of equations can be formed and solved efficiently even when the number of unknowns is very large, and the resulting approximate solution can be highly accurate. This chapter describes the classes of PDEs to which the finite element method will be applied.

1.1

Laplace's equation; elliptic BVPs

Laplace's equation is the PDE where the Laplace operator (or the Laplacian), A, is defined by

3

4

Chapter 1. Some model PDEs

in two dimensions, or

in three. Solutions of Laplace's equation are called harmonic functions. Much of the analysis and many aspects of the numerical methods covered in this book are the same whether the equation is posed in two or three spatial dimensions, but for definiteness I will describe the two-dimensional case, with some comments about three-dimensional problems. The inhomogeneous version of Laplace's equation,

where / is a function defined on Q, is called Poisson's equation. Equations (1.1) and (1.2) are most commonly posed on a bounded domain £2 in R 2 . A domain is a connected open set. Connected means that the set consists of only one "piece," or, more precisely, that any two points in the set are joined by a curve lying entirely within the set. Open means that the boundary of the set is not a part of the set. Bounded means that the set is finite in extent, that is, that it can be enclosed by a circle with a finite radius. The boundary of £2 will be denoted by 9 £2, and the closure £2 of £2 is the union of £2 and dQ. The PDEs (1.1) and (1.2), by themselves, are insufficient to determine a unique solution; (1.1) and (1.2) have many solutions. A particular solution can be singled out by adding boundary conditions; as the reader will see, such conditions are natural in many physical problems. For example, if / is a function defined on ST2 and g is a function defined on 9£2, then

is called a Dirichlet BVP, and (1.3b) is referred to as a Dirichlet boundary condition. A Neumann BVP has the form

where du/dn is the normal derivative of u on 9 £2. If the vector n(x, y) is the outwardpointing normal vector to 9 £2 at (jc, y) e 9 £2 and V« is the gradient of u,

then the normal derivative is defined by

Before trying to solve any mathematical problem, it is helpful to determine whether a solution exists and, if so, whether the solution is unique. These are the existence and uniqueness questions. These questions are particularly important when the problem is difficult to solve; one would not want to expend a lot of effort trying to compute something that does not exist!

1.1. Laplace's equation; elliptic BVPs

5

As I explain below, a Dirichlet BVP for Laplace's or Poisson's equation has a unique solution, as long as the functions / and g are reasonable. The situation with the Neumann problem is more subtle, and the existence and uniqueness questions are interrelated: If the functions / and h are compatible, then the Neumann BVP has infinitely many solutions, any two of which differ by a constant. On the other hand, if / and g are not compatible, then there is no solution. So either existence or uniqueness fails in the case of the Neumann problem. I will explain the compatibility condition below on physical grounds and derive it in the next chapter. The implications of the lack of uniqueness for computing solutions are discussed in Section 11.5 (see also Example 7.4).

1.1.1

Physical experiments modeled by Laplace's equation

Steady-state heat flow The first application of Laplace's equation is to a flat metal plate occupying a domain ft in R2. The function u(x, y) represents the temperature at the point (x, y ) e ft. The plate is assumed to be insulated on the top and bottom, so heat can flow only in two dimensions. Such a plate has a third dimension, its thickness, but I will assume that neither the plate nor its temperature varies in the vertical direction, so that a two-dimensional model suffices. Laplace's equation, models the case of steady-state heat flow: The temperature is independent of time and the temperature gradient Vu indicates the flow of heat energy across the plate. Poisson's equation, models steady-state heat flow with heat sources and/or sinks in the plate. If f(x, y) > 0 for some (x, y) € ft, then heat energy is being added at that point at a rate f(x, y) (in appropriate units). If f(x, y) < 0, then energy is being removed at (jc, y). In this context, Dirichlet boundary conditions,

indicate that the temperature of the plate is held fixed at the boundary, specifically, that the temperature at (x, y) e 3ft is held fixed at g(x, y). The Dirichlet BVP

models the following situation: The plate is insulated on the top and bottom, the temperature at each point (x, y) in the boundary is held fixed at the given value of g(x, y), and the plate is allowed to reach equilibrium. The equilibrium temperature distribution is then given by the solution u of the BVP. Neumann boundary conditions,

6

Chapter 1. Some model PDEs

indicate that the heat flux across the boundary is the prescribed value h. The heat flux is the flow of heat energy, in units of energy per time per length. In particular, the homogeneous Neumann condition models the case of no heat flux—the boundary is insulated. Units and physical parameters The equations described above are nondimensional versions of the PDEs; describing actual materials (such as an iron plate, for example) requires physical parameters. In the heat flow problem described above, the relevant parameter is the thermal conductivity K. The thermal conductivity is the constant of proportionality in Fourier's law of heat conduction, which postulates that the heat flux is proportional to the temperature gradient:

The units of K are energy per time per length per temperature. For example, the thermal conductivity of iron near 0 degrees Celsius is K — 0.836W/(cm K). Poisson's equation is then written as From this equation, the units of / can be determined. They must be the same as the units of the left-hand side, which are energy per time per volume (for example, W/cm3). The thermal conductivity K is positive by definition. The sign of K also has an important mathematical significance, as will be shown in the next chapter. In that chapter, it will become apparent why I prefer to include the negative sign explicitly in Laplace's and Poisson's equations. If the material is heterogeneous, then the thermal conductivity varies throughout £2: K = K(X, y). The PDE becomes more complicated:

The divergence operator, denoted V-, is a partial differential operator that takes a vectorvalued function and produces a scalar-valued function as follows: If

then

The divergence of the gradient is the Laplacian:

Therefore, when K is constant,

1.1. Laplace's equation; elliptic BVPs

7

The appropriate form of the Neumann boundary condition, taking into account the physical characteristics of the material, is

Since the heat flux, by Fourier's law, is —KVu and

(1.5) simply says that the heat flux into £2 across dQ is the prescribed value h(x, y}. The Neumann BVP

indicates that heat energy is being added to or taken away from the plate in two ways: in the interior (the effect of the heat source /) and across the boundary (the effect of the heat flux h). If the temperature u is to be in equilibrium, it must be the case that the net amount of heat added is zero. This is expressed by the compatibility condition:

The first integral is the rate at which heat energy is added to the interior, while the second is the rate at which energy enters across the boundary. If the two integrals do not sum to zero, then existence fails—there is no solution—for the above BVP. This will be shown mathematically in Section 2.1.1. On the other hand, if there is a solution u, then it is clear from the equations that u + C is also a solution for any constant C (only derivatives of u appear in the PDE and the boundary condition, so adding a constant to u does not affect the equations). Therefore the solution, if it exists, is not unique. This is easy to understand on physical grounds: The compatibility condition states that no net energy is being added to or taken from the plate, but nothing in the BVP indicates how much total heat energy is in the plate. Adding a constant to the temperature u changes the total amount of heat energy without changing the temperature gradient, on which the heat flux and the BVP depend. Small vertical deflections of a membrane Another experiment modeled by Laplace's or Poisson's equation is the following: A membrane that occupies a domain Q when at rest is fixed along the boundary and subjected to a small transverse pressure. The point on the membrane originally at (x, y, 0), (x, y) e £2, moves to (x, y, u(x, >')) under the influence of the pressure. It is a simplifying assumption that the point moves only in the vertical direction. This is not exactly true, but it will be nearly true if the pressure is small enough. Dirichlet conditions in this application indicate that the boundary of the membrane is fixed. For example,

8

Chapter 1. Some model PDEs

means that the boundary is fixed in the original (horizontal) plane. An inhomogeneous Dirichlet condition, such as means that the membrane is stretched on a frame whose shape is determined by the boundary function g. In this context, a homogeneous Neumann boundary condition indicates that the boundary is free to move in the vertical direction. This condition is not physically plausible when applied to the entire membrane, but the following mixed boundary conditions describe a meaningful experiment:

Here PI and F2 form a partition of the boundary 3 £2, and the boundary conditions indicate that part of the boundary (Fj) is fixed, while the remainder (I~2) is free to move up and down. Again, I have presented the nondimensional version of the equations. When taking into account the physical characteristics of the membrane, the relevant quantity is the tension T in the membrane, and Poisson's equation takes the form

A constant T means that the tension is the same throughout the membrane.

1.2

Other elliptic BVPs

Laplace's equation is the prototypical elliptic PDE. Elliptic PDEs describe certain equilibrium phenomena and have mathematical properties that will be described in the next chapter. Here I will simply give some more examples of elliptic PDEs. 1.2.1

The equations of isotropic elasticity

An elastic membrane is said to be isotropic if its elastic response is the same in every direction. This means that if the membrane is stretched by a certain traction, or rotated about a point and then stretched by the same traction, the response in the two experiments will be the same. In two-dimensional linear elasticity, one models small planar deformations of an elastic membrane, and the unknown is the displacement of the material from a reference position. This displacement is a vector-valued quantity:

The displacement u has the following meaning: Under the applied load, the point of the membrane originally at (jc, y) moves to the location (jc + u\ (x, y), y + u^(x, y)).

1.2. Other elliptic BVPs

9

When the membrane is isotropic, it is described by two scalar quantities called the Lame moduli, n and A. The Lame moduli are constants if the membrane is homogeneous and functions of (jc, y) if it is heterogeneous. Those familiar with engineering mechanics may be accustomed to describing the elastic properties of a material in terms of Young's modulus E and Poisson's ratio v. The relationship between the Lame moduli and E and v is explored in the exercises at the end of this chapter. Since there are two unknown functions, MI and ui, there are two PDEs that together model the stretching of the membrane under an applied load. These are usually written in vector form as follows:

I will now identify each term in these equations. The gradient of a vector-valued function u is

(this is called the Jacobian matrix in other contexts). The quantity 6 is the (linearized) strain tensor, a measure of the local deformation of the membrane. The trace o f f , tr(e), is the sum of the diagonal entries of e:

The tensor a is called the stress tensor. It measures the elastic response of the membrane to the deformation described by the strain. In two dimensions, a has units of force per length; the units become force per area in three dimensions. The divergence of a tensor is the vector whose components are the divergences of the rows of the tensor:

The stress-strain relationship, expressed by (1.6b), is sometimes called the constitutive hypothesis. It is an assumption about the response of the particular material. On the other hand, (1.6a) is the balance law, which is the same for all materials. The function / in (1.6a) is the applied load, in units offeree per area. It might be more natural to express the body force in units offeree per mass, in which case the right-hand side of (1.6a) would be p~] f ( x , >'), where p is the density of the membrane, expressed in mass per area. As an exercise to verify that the notation is understood, the reader can assume that n and A. are constants and check that (1.6a)-(1.6c) are equivalent to the two scalar PDEs

10

Chapter 1. Some model PDEs

However, as I will show in later chapters, it is most convenient to work with the equations in vector form. The right-hand side of PDE (1.6a) represents a body force acting on the interior of the membrane. A body force is a force that acts at a distance, such as gravity or an electromagnetic force. Often, in a membrane problem, there is no body force. Typically the load is introduced by a traction (applied stress) on the boundary, which leads to the boundary condition Frequently the traction is applied to only part of the boundary, while the remainder is fixed (that is, not allowed to move). Therefore, a natural B VP for a membrane has mixed boundary conditions:

(F| and F2 form a partition of d£2). These boundary conditions model a simple experiment, in which part of the boundary is held motionless and the membrane is stretched by a traction applied to the rest of the boundary. It is also natural to consider the pure traction problem, in which a traction is applied to the entire boundary. This is a Neumann problem, and the comments from page 5 apply: either existence or uniqueness fails. More precisely, a solution does not exist unless the traction h satisfies a compatibility condition; if the compatibility condition is satisfied, then there are infinitely many solutions, any two of which differ by a rigid body motion (see Exercise 5). This will be explored in Section 2.5.2. The equations of isotropic elasticity for a three-dimensional elastic solid also take the form (1.6) when written in vector form. In that case, the displacement u has three components and Vw, e, and a are all 3 x 3.

1.2.2

General linear elasticity

For an elastic membrane that is not assumed to be isotropic, the stress-strain relationship is more complicated. Assuming a linear relationship, there exists a 4-tensor A = Aijki such that that is,

In Exercise 3, the reader is asked to show that (1.6b) is a special case of (1.8). The tensor A is assumed to satisfy the symmetry conditions

1.3. Exercises for Chapter 1

11

as well as the condition

where the dot product of two 2-tensors 6, a is defined by

Exercise 4 discusses assumptions (1.9a) and (1.9b). The third symmetry condition, (1.9c), results from the assumption that the material in question is not merely elastic but hyperelastic. For a discussion of hyperelasticity, see Gurtin [24]. Condition (1.10) is natural in many settings; for example, Exercise 9 explores it for isotropic elasticity. Mathematically, it guarantees that the resulting PDE is elliptic, as will be shown in the next chapter. The boundary conditions described above for an isotropic membrane have the same meanings for an anisotropic membrane. Once again, the equations for a three-dimensional elastic body have exactly the same form as for a two-dimensional elastic membrane, with the indices describing the tensors taking the values 1,2,3 instead of just 1,2.

1.3

Exercises for Chapter 1

1. Write the expression V • (K Vw) explicitly in terms of partial derivatives and show that

2. Show that (1 .6) is equivalent to (1 .7) when JJL and X are constant. 3 . Show that ( 1 .6b) can be expressed in the form (1.8). What is the tensor A? (Notice that a general 4-tensor on two-dimensional space is determined by the 24 = 1 6 entries Aiikt. However, the symmetry conditions (1.9) imply that such an A has only six independent entries, namely, 4.

(a) Show that if A is a 4-tensor, then Ae = Ae for all symmetric 2-tensors e, where A is defined by Aijki — (A/;*/ + A ( / /^)/2 for all /, j, k, I. It follows that there is no loss of generality in assuming (1.9a). (b) Show that if (1.9a) holds and a = At is symmetric for each symmetric e, then (1.9b) must hold. (Note: The symmetry of the stress tensor a follows from the principle of conservation of angular momentum; see Gurtin [24, page 101].)

5. The purpose of this exercise is to determine all displacements u with the property that the corresponding strain 6 is zero. Since 6 measures the local deformation of the material, it would appear that rigid displacements, arising from translations and rotations of the membrane, would lead to zero strain. However, e is the linearized strain, or the linear approximation to the actual strain, so this is not quite correct.

12

Chapter 1 . Some model PDEs (a) Show that € is zero if and only if u has the form

where 0. In the language of Section 1.2.1, this means that a — TI, where / is the identity, so that the tension is av = TV in every direction v. (a) Show that if the displacement u is given by

(a pure expansion; see Exercise 6), then a = TI. (b) Show that (1.14) is a solution to the traction problem

9. Show that if and only if JJL > 0 and /z + A. > 0 (that is, if and only if the shear and bulk moduli are positive).

1

The formulas for £ and v in terms of n and X are specific to a two-dimensional model. For a three-dimensional elastic body, the relationships are

This page intentionally left blank

Chapter 2

The weak form of a BVP

In this chapter, I show how to rewrite a BVP in its weak or variational form, from which the finite element method is derived. The first example will be the model problem

where Q. is a bounded domain in R 2 . Later in the chapter, the calculations will be extended to more complicated PDEs and different boundary conditions. Deriving the weak form of (2.1) requires the use of some vector calculus.

2.1 Review of vector calculus 2.1 .1 The divergence theorem The main result from vector calculus that we need is the divergence theorem, which is the multidimensional analogue of the fundamental theorem of calculus. In the following discussion, I describe the results in two dimensions, but the beauty of vector notation is that the results hold without change in three or more dimensions. If £1 is a domain in R2 with a smooth or piecewise smooth boundary and F is a vector field defined on £2, then the divergence theorem states that

where n is the outward-pointing unit normal vector to dQ. (The normal vector is a function of (x, y) € dQ: n = n(x, y).) The integral on the left can also be written as a double integral,

15

16

Chapter 2. The weak form of a BVP

and can also be referred to as an area integral. The integral on the right is an integral over the boundary of £2, which is a curve, and thus can be referred to as a line integral. In order for the divergence theorem to hold, the vector field F must be smooth enough. By taking the vector field F to be of the form

it follows from the divergence theorem that

where n\ is the first component of the outward-pointing unit normal vector. Similarly,

The divergence theorem relates a quantity defined on the boundary to another quantity defined on the interior of the domain. This explains why the divergence operator appears in the PDEs described in the previous chapter. An example is the steady-state heat equation:

It is derived by writing the total amount of heat entering an arbitrary subdomain a> c £2 in two ways: in terms of the heat source or sink /, and in terms of the heat flowing across the boundary, due to the heat flux — KVM. The two must sum to zero, since the temperature is assumed to be in equilibrium:

The divergence theorem is then invoked, yielding

Since this holds for every subdomain a> c £2, a little analysis shows that the PDE

must hold. Although this derivation is sketchy, I hope it illustrates the connection between the divergence theorem and many common PDEs and also explains why the divergence and Laplace operators are fundamental.

2.1. Review of vector calculus

17

The compatibility condition for the Neumann problem In the previous chapter, I described the compatibility condition for the pure Neumann problem

Mathematically, the compatibility condition follows from the divergence theorem. If u is a solution to (2.5), then

Therefore,

which is the compatibility condition given in the previous chapter.

2.1.2

Green's identity

The weak form of a BVP is derived using Green's identity, which is the multidimensional analogue of integration by parts. To understand Green's identity, it is useful to review integration by parts, which is obtained from the product rule for differentiation and the fundamental theorem of calculus:

Green's identity follows from the following product rule in multiple dimensions:

This rule can be derived, using the ordinary product rule, by writing out the left side in coordinates (see Exercise 1.3.1).

18

Chapter 2. The weak form of a BVP

Green's identity is obtained from (2.6) by integrating both sides over £2 and applying the divergence theorem:

Replacing Vw • n with du/dn and rearranging yields Green's (first) identity:

In Section 2.2, I will show how (2.7) is used. As in the case of the divergence theorem, the primary use of Green's identity is not to evaluate specific integrals, but rather to derive useful formulas.

2.1.3

Other forms of the divergence theorem and Green's identity

Equations (2.3) and (2.4) lead to the following identities, which look very much like integration by parts in one dimension:

These formulas will be essential in the next section. The reader will recall from Section 1.2.1 that the divergence of a tensor is computed by taking the divergence of each row of the tensor. Since the integral of a vector-valued function is computed by taking the integral of each component of the function, the following version of the divergence theorem is valid:

In this formula, a is a 2-tensor:

I will need a version of Green's identity that applies to the integral

where v is a vector-valued function. Exercise 3 asks the reader to verify that if a is a 2-tensor and v is a vector, then

2.1. Review of vector calculus

19

When a is symmetric (o\2 — a2i), as is the case when a is a stress tensor, then and

and thus The reader will recall from Section 1.2.1 that €v is the strain tensor associated with the displacement v. The dependence of €v on v is explicitly indicated, because shortly I will refer to two displacements « and v and their associated strain tensors. I can now derive the needed extension of Green's identity (still assuming that a is symmetric):

Since a is assumed to be symmetric, holds, yielding the desired extension of Green's identity:

If a = au is the stress tensor arising in the linear elasticity model, then a,, = A€U holds and the first integral on the right in (2.10) can be written as

This yields

It should be noticed that the 4-tensor A can be either a constant or a function of (x, y); (2.11), written as it is, holds in either case. It will be useful to also write (2.7) in a form that allows for a nonconstant coefficient:

The reader can verify that (2.12) follows from the product rule and the divergence theorem. For more details about the vector calculus reviewed in this section, see Kaplan [26], which gives a straightforward introduction. An alternative at the same level is Greenberg [22]. A more advanced treatment can be found in Marsden and Tromba [30].

20

2.2

Chapter 2. The weak form of a BVP

The weak form of a BVP

This section introduces the weak form of a BVP, one of the key ingredients of the finite element method. I will begin with the following Dirichlet problem:

If / is continuous and u is a solution of (2.13), then it is natural to expect that u and its partial derivatives of orders one and two are all continuous on Q, and, of course, u is zero on dQ. The space Ck(Q) is defined to be the set of all real-valued functions u defined on £2 with the property that u and its partial derivatives up to order k are all continuous on Q. A solution to (2.13) is sought in the subspace

(the subscript "D" stands for "Dirichlet"). If u is a solution to (2.13), then

and therefore, for any function v defined on Q, multiplying both sides of the PDE by v yields Since the two functions —V • (/cVw) v and fv are equal on £2, their integrals over £2 must agree:

In this context, the function v is referred to as a test function. The idea is to check whether the PDE holds in the (weighted) average sense over £2, using the test function v to define the weights in the average. Obviously, just because (2.14) holds for a particular test function v is no reason to think that the PDE (2.13a) holds. However, as I will now explain, if (2.14) holds for all test functions v from a sufficiently large set, then (2.13a) must hold. The ball of radius 8 centered at (JCQ, yo) is denoted BS(XQ, yo):

Suppose (jco, yo) e £2 and 8 > 0 is small enough that B$(XQ, yo) is contained entirely in £2. Consider any function v e C2D(£l) with the following properties:

2.2. The weak form of a BVP

21

It is not difficult to show that many such functions v exist; in fact, I construct such a function in Section 2.2.2. But then

is just a weighted average of/ over the disk BS(XQ, >>o), and similarly

is a weighted average of — V • (K Vw) over the same disk. If 8 is very small, then

and

Moreover, in the limit as 8 -> 0, these become exact equations. Therefore, if the space of test functions contains all such functions v, and (2.14) holds for all test functions, then the original PDE must hold at every (XQ, jo) € £2. By the above reasoning, it is sufficient to take the space of test functions to be C2D(£l) (which contains the above-described test functions, as well as many others). Therefore, (2.14) holds for some u e C2D(£l) and for all v e C^(£2) if and only if u satisfies the BVP (2.13). The next step is to apply Green's identity to the left-hand side of (2.14):

(the boundary integral vanishes because v is zero on 3£2). This leads to the weak form of BVP(2.13):

As 1 have argued above, (2.13) and (2.15) are equivalent: A function u e C2D(Q) satisfies one if and only if it satisfies the other. Problem (2.15) is also referred to as a variationalproblem and as the variationalform of (2.13). Next I want to explain the reasons for using the terms "variational" and "weak" to describe (2.15), since these reasons are quite instructive.

2.2.1

Minimization of energy

When the PDE (2.13a) models a mechanical system in which u is the displacement and / is an external body force, the total potential energy of the system is

22

Chapter 2. The weak form of a BVP

where £Q is some constant. The state of equilibrium of the system corresponds to the displacement u that minimizes the potential energy. This may be a familiar idea, but here it is shown mathematically that the u that minimizes J is the same u that solves (2.15) (and hence the BVP (2.13)). In the physical problem modeled by (2.13), only displacements u that satisfy the boundary condition (2.13b) are admissible. If u and w are two admissible displacements (that is, if u, w e C2D(Q)) and v — w — u (so that w = u + u), then v is also in C2D(£t). Mathematically, this reflects the fact that C2D(Q) is a vector space. Adding or subtracting two vectors in the space produces another vector in the same space. A direct calculation shows that

The parameter K is positive and

provided v is a nonconstant function. Because of the boundary conditions, the only constant function in C2D(£2) is the zero function, so if v is a nonzero displacement (that is, if u; / w), then

Therefore, if and only if

(see Exercise 6). This shows that u minimizes J over C2D(£l) if and only if u satisfies (2.15), the variational form of the equation. This is an interesting result from the physical point of view—mechanical equilibrium corresponds to minimal potential energy. However, I promised to explain the reason for the term "variational form." From basic calculus, the derivative of J ought to be zero at the minimizer. The formula

shows that

is the directional derivative of J at u in the direction of v.2 In somewhat old-fashioned language, this directional derivative is referred to as the (first) variation of J. Thus the variational form of the BVP simply states that, at the solution a, the first variation of the potential energy is zero in every direction—hence the term "variational form." 2

Equation (2.20) expresses J(u + v) as /(«) + (a term linear in v) + (a term quadratic in v). The linear term must be the directional derivative of J.

2.2. The weak form of a BVP

2.2.2

23

Relaxing the PDE

The original PDE, suggests that the solution u should have partial derivatives up to order two—that is, that u should be twice differential)le. On the other hand, the variational form (2.15) refers only to the first derivatives of u. Similarly, in the classical way of looking at things, it is expected that the right-hand-side function / be continuous over £2. However, in the variational form, it is only necessary that / be integrable (or, more precisely, that / times any test function be integrable). For this reason, (2.15) is referred to as the weak form of the original BVP, which can be called the strong form by contrast. When working with the weak form of the BVP, it is natural to make the weakest possible assumptions on the functions involved, so as to include as many cases as possible in the analysis. For this reason, the Sobolev spaces are introduced. Sobolev spaces In classical theory, all necessary partial derivatives are assumed to exist and be continuous, and this assumption leads to the spaces Ck(Q) defined above. The partial derivatives are defined as in calculus; for example,

However, in the weak form of a BVP, it is not necessary that all functions and derivatives be continuous. Moreover, there is another way to define partial derivatives that is actually more natural and useful in the context of the weak form. To explain this other definition of partial derivative, I must introduce some new concepts. First of all, if u is a function, its support is the closure of the set on which u is nonzero: If u is defined on £2 and supp(w) is a compact subset (that is, a closed and bounded subset) of £2, then u is said to be compactly supported in £2. A function compactly supported in £"2 is zero on and near the boundary of £2. The space C£°(£2) is defined to be the set of all functions that are infinitely differentiable on Q and compactly supported in £2. The condition that u e C%°(Q) is quite strong, and the reader might wonder if, in fact, there are any functions in this space at all. Such a function must have the property that it and all of its partial derivatives go to zero as (jc, >') approaches the boundary of supp(w). To settle this question, I will show how to construct a family of functions in CQ°(^). Let (XQ, >'o) e £2 and 8 > 0 be sufficiently small that B$(XQ, >'o) C £2, and define 0 : £2 -> R by

Then, since

24

Chapter 2. The weak form of a BVP

it follows that 0(;c, y) -> 0 as (jc, y) —> dB$(xo, yo). Moreover, each partial derivative of 0, inside B$(XQ, yo), consists of a rational function times the same exponential, which is enough to show that each partial derivative converges to zero as (jc, y) —> dBs(xo, jo). Thus0eC 0 °°(fi). In fact, defining

it follows that and thus y is a test function of the special type described on page 20. Using functions like 0, it is possible to generate lots of elements of CQ°(^) (although I will not show how to do it). In fact, any function u e C(£2) can be approximated arbitrarily well, in a sense to be described below, by functions in C£°(£2). Now I can explain an alternate definition of partial derivative. Suppose for now that u e C1^)- Integrating by parts, that is, applying (2.8a), yields

for all smooth test functions v. If v e C0°(£2), then the boundary integral is zero (since v is identically zero on 3 £2), and thus

In other words, du/dx is that function g satisfying

Although I will not prove it formally, there can be only one such function, and thus, for u e Cl(tt), g - du/dx if and only if (2.22) holds. Therefore, (2.22) can serve as an alternate definition of the partial derivative du/dx of u e Cl(£2). A similar definition is valid for du/dy. The advantage of this alternate definition is that it can be extended to many functions that are not differentiable everywhere in the sense of (2.21). DEFINITION 2.1. Suppose u is a real-valued function defined on a domain £L in R2, and that u is integrable over every compact subset ofQ. (In this case, u is called locally integrable.) If there exists another locally integrable function g defined on £2 such that

holds, then u is said to be weakly differentiable (with respect tox) andg is called the weak partial derivative (with respect to jc) ofu. The weak partial derivative with respect to y is defined similarly. Weak derivatives are denoted by du/dx and du/dy, just as are strong derivatives.

2.2. The weak form of a BVP

25

Here is an example of a function that is not differentiable over all of £2 but has a weak partial derivative. EXAMPLE 2.2. Let £2 be the unit square, Q — (0, 1) x (0, 1), and define

The following argument shows that u is weakly differentiable with respect to x and that

Suppose v e C£°(£2). Then

On the other hand,

This proves that g is a weak partial derivative with respect to x ofu on £1. The previous example may lead the reader to believe that there real ly is not much to the definition of the weak derivative. After all, in Example 2.2, the function u is differentiable (in the classical sense) except on a line segment, and the weak derivative is found by simply computing the derivative of a, where it exists, in the classical manner. However, the following example presents a function that is differentiable except on the same line segment and yet is not weakly differentiable.

26

Chapter 2. The weak form of a BVP

EXAMPLE 2.3. Let Q be the unit square, Q = (0, 1) x (0, 1), and define

Ifv e C°°(Q), then

00000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000 00000000

0000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000

must hold (since a line segment has zero area). (The same formula (2.22) can be used to extend the notion of derivative to functions such as the u in this example; however, such derivatives are not representable by locally integrable functions and are beyond the scope of this book.) The assumptions that must be made on the functions appearing in the variational form can be stated in terms of weak derivatives. Recall that it is desirable to make the weakest assumptions possible, so as to encompass as many cases as possible. For this reason, it is assumed that u and v are only weakly differentiate. Moreover, since only first derivatives appear in (2.15), it is assumed that u and v have weak partial derivatives of the first order. Therefore, whereas in the strong form (2.13) u must have continuous derivatives up to order two, in the weak form (2.15) it need only have weak derivatives of order one. This is indeed a considerable relaxation of the requirements on u. There is one restriction, however, that is necessary. The definition of weak derivative requires only that du/dx and du/dy be (locally) integrable. In the variation equation (2.15), though, it must be possible to integrate the products

2.2. The weak form of a BVP

27

In particular, v = u must be allowed, which shows that du/dx and du/dy must be squareintegrable:

In the same way,

must be finite, which also suggests that / and v should be square-integrable (if v — /, for example). It is therefore convenient to define the space

1 will require that /, the right-hand side of the PDE, belong to L 2 (£2). The solution u of (2.15) must satisfy

and the test functions must satisfy the same conditions. These conditions define the Sobolev space H](Q):

Finally, it is necessary that both the solution u and all of the test functions v satisfy the Dirichlet boundary conditions. For this reason, it is convenient to introduce the following space: The space HQ (Q) is another example of a Sobolev space. In defining the above spaces, 1 have been rather cavalier about some important mathematical details. For the interested reader, I discuss these details in Section 2.2.3. The variational form of (2.13) can now be defined in terms of the Sobolev space //o'(«):

The right-hand-side / is assumed to belong to L 2 (£2). It should now be clear why the variational form is also called the weak form; the requirements of the right-hand-side / and the solution u have been considerably weakened over the classical strong form (2.13).

2.2.3

A few details about Sobolev spaces

In the above explanations, 1 have not attempted to give a rigorous definition of the spaces L 2 (ft), #'(£2), and HQ(&)\ to do so would lead us far afield. For the interested reader, I will sketch a few of the omitted details and give some references for further study.

28

Chapter 2. The weak form of a BVP

First of all, to define L2(£2), it is important to use the correct definition of the integral, though for purely technical reasons. The integral defined in the usual undergraduate calculus course is the Riemann integral. It is the integral of choice in introductory calculus courses because its definition is relatively simple compared to that of its competitors. However, the Riemann integral suffers from some serious technical shortcomings, most notably that it is not difficult to construct a sequence of Riemann integrable functions converging (in a natural sense) to a function that is not Riemann integrable. This property makes the Riemann integral largely useless for constructing a satisfactory theory of PDEs. The Lebesgue integral is preferred over the Riemann integral for precisely these theoretical reasons. I will not explain the definition of the Lebesgue integral, for the following reason: Any function that is Riemann integrable over a bounded domain is also Lebesgue integrable, and its Riemann and Lebesgue integrals are equal. The Lebesgue integral merely allows us to integrate certain singular functions that, for theoretical reasons, must be included. I will explain a bit more about this in Section 2.4. Functions that are regular enough to integrate are called (Lebesgue) measurable. The Lebesgue integral is based on the notion of Lebesgue measure of sets. Lebesgue measure corresponds to the notion of area for subsets of R2 that are regular enough that their areas can be defined. However, Lebesgue measure extends to very complicated sets. As in the case of integrals, this extension is needed mainly to allow for a satisfactory theory. My favorite reference for Lebesgue measure and integration theory is Folland's text on real analysis [20]; another text that is perhaps somewhat more accessible to the beginner is the real analysis text by Roy den [36]. When speaking of the space L 2 (£2), it is important to realize that two functions / and g with the property that /Q \f — g\ — 0 must be regarded as equal. Functions / and g have this property whenever f ( x ) = g(x) except on a set with Lebesgue measure zero. For this reason, when describing a function that belongs to L 2 (£2), it is acceptable to leave the function undefined on a set of measure zero. I did this, in fact, for the weak derivative of the function u in Example 2.2. I left du/dx undefined on the line segment corresponding to x = 1 /2; this line segment clearly has area (and hence measure) zero. Any values could be assigned to du/dx on that line segment without changing the function as an element of L 2 (ft). A corollary of the discussion in the previous paragraph is that a well-defined function u e L2(£l) cannot be unambiguously restricted to a subset of measure zero. This is an important fact in the theory of BVPs, since, for a bounded domain £2 c R2, dQ. is a subset of measure zero. The space Hl(Q) and its subspace HQ(&) are just two examples of Sobolev spaces. For a bounded domain £2 and any positive integer k, the Sobolev space Hk(£2) is defined to be the space of all integrable functions u defined on £2 with the property that u and its partial derivatives up to order k all belong to L 2 (£2). In this context, L 2 (£2) can be called //°(£2). It is also possible to define Hs(£2) for fractional values of s, but there is more than one way to do this, and the development is rather complicated. In developing a rigorous theory of BVPs using weak derivatives, it is necessary to know how much (weak) differentiability is necessary for a function to have well-defined boundary values. The answer to this question is called the trace theorem, which states (in its most refined form) that restricting an HS(Q) function (£2 c R 2 ) to a one-dimensional curve F produces a function in Hs~l/2(r). Therefore, in particular, an Hl (£2) function has

2.3. The weak form for other boundary conditions and PDEs

29

boundary values belonging to H]/2(d£2) c L 2 (9£2), and hence it makes sense to talk about an //'(£2) function as a solution to (2.23) or (2.32). On the other hand, if u e //'(£2), then the components of the gradient Vw belong to L 2 (ft), which implies that du/dn is not well-defined on d£l. In this regard (and others) the analysis of a Neumann problem is more delicate than that of a Dirichlet problem. 1 will have more to say about this in Section 2.5. A comprehensive reference for Sobolev space theory is the book by Adams [1]. Most modern texts on PDEs and finite elements contain a development of this theory; the text by Brenner and Scott [13] is particularly concise and accessible.

2.3 The weak form for other boundary conditions and PDEs 2.3.1

Neumann conditions and the weak form

Next I will derive the weak form of the Neumann problem

There is an interesting distinction between the weak forms of a Dirichlet problem and a Neumann problem: The Dirichlet condition appears explicitly in the weak form (2.23) (in the definition of the space //0'(£2)), but, as I will now show, the Neumann condition does not appear explicitly in the weak form of (2.24). I assume that u satisfies (2.24). This presupposes that u has some extra smoothness beyond the requirement that u e //'(£2), both because the left side of (2.24a) involves second derivatives of u and because du/dn is not well-defined for an arbitrary #'(£2) function. Then

The reader should notice the use of Green's identity in the above calculation, and also the fact that the boundary integral vanishes because of the Neumann boundary condition satisfied by the solution u. (In the Dirichlet case, it was the boundary condition on the test function v that caused the boundary integral to vanish.)

30

Chapter 2. The weak form of a BVP The weak form of (2.24) is thus defined to be the following problem:

As I showed above, any solution of (2.24) is also a solution of (2.25). However, the reader might well question whether the converse is true. After all, (2.25) does not mention the Neumann boundary condition and so it is not obvious that a solution of (2.25) will necessarily satisfy the Neumann condition. It does, though, provided the solution u is smooth enough that Green's identity applies and Vw can be restricted to 3£2. Suppose that u e Hl(Q) is a solution of (2.25). Then, since //J(^) C Hl(Q),

Applying Green's identity to the left side yields

Since v e HQ (£2), the boundary integral vanishes, yielding

Now, applying the reasoning that I sketched in the Dirichlet case, it follows that the PDE (2.24a) must hold (notice that the type of test function that I discussed on page 20—whose support is a disk BS(XQ, yo)—belongs to the space HQ (£2)). To show that the Neumann condition (2.24b) also holds, I return to (2.25) and apply Green's identity once again to obtain

But now I know that

(since — V • (K Vw) and / are equal on Q). Therefore,

must hold. Although the precise argument is rather technical, it should be believable that (2.26) can hold for all v e Hl(£l) only if du/dn is zero on d£l (the reader should bear in mind that K is strictly positive). Since Dirichlet conditions must be explicitly imposed in the weak form, while Neumann conditions are implied even though not explicitly imposed, Dirichlet conditions are often called essential boundary conditions, while Neumann conditions are called natural boundary conditions.

2.3. The weak form for other boundary conditions and PDEs

2.3.2

31

Mixed boundary conditions

A BVP can have both Dirichlet and Neumann boundary conditions, with the two different conditions applied to different parts of the boundary. If 9£2 = r\ U F2 is a partition of 9£2 (so that F| n F2 = 0), then the following BVP is said to have mixed boundary conditions:

According to the above discussion, the Dirichlet condition is essential, while the Neumann condition is natural. The space of test functions is therefore defined to be

The Neumann condition is not mentioned in this definition, since it is a natural boundary condition. The derivation of the weak form follows the now familiar pattern:

The boundary integral can be written as

The first integral on the right vanishes because the test function v is zero on F|, and the second vanishes when u is a solution of (2.27), since du/dn is then zero on F2. The weak form is therefore the same as before,

except that the space of test functions has changed. Exercise 7 asks the reader to show that if u satisfies the weak form, then it also satisfies the strong form (2.27), including the Neumann boundary condition.

2.3.3

Inhomogeneous boundary conditions

In homogeneous Neumann conditions

I will now explain how inhomogeneous boundary conditions affect the weak form of a BVP, beginning with the inhomogeneous Neumann problem

32

Chapter 2. The weak form of a BVP

where h is a given function defined on 912. The derivation of the weak form proceeds as follows:

Thus the weak form of (2.29) is as follows:

The weak form (2.30) is the same as it was for homogeneous Neumann conditions, except that the right-hand side has been changed. Inhomogeneous Dirichlet conditions The case of inhomogeneous Dirichlet conditions is a bit more complicated. The BVP is

where g is a function defined on 9£2. The function g must satisfy some regularity conditions, and I will assume that there is a function G e Hl(£l) such that G = g on d&. It turns out that the correct space of test functions is still HQ (£2); however, since the desired solution u does not satisfy homogeneous Dirichlet conditions, it cannot be the case that u € HQ (£2). Instead, the function w = u — G is zero on 9£2, and thus the solution has the form u = w + G, where G is assumed to be known and it; 6 HQ (£2) is unknown. Here is the derivation of the weak form:

Thus the weak form of (2.31) is the following:

2.3. The weak form for other boundary conditions and PDEs

33

The reader will notice that (2.32) has the same form as (2.23), except that the right-hand side has changed. In general, it might be difficult to find a suitable function G satisfying the Dirichlet condition G — g on 3 £2 (in a BVP, only g is given, not G). However, in the context of the finite element method this is easy. I will show, in Section 4.1.1, how to produce a function G that (approximately) satisfies the inhomogeneous Dirichlet condition. It is left to the reader to derive the weak form of the BVP

with inhomogeneous mixed boundary conditions.

2.3.4

Other elliptic BVPs

The weak form of the other elliptic BVPs presented in Chapter 1 can be derived using the alternate version of Green's identity derived in Section 2.1.3: If R is continuous, then / is certainly in L2(a, b) (since a continuous function on a closed and bounded interval is bounded). The function / can be approximated by a Euclidean vector by means of sampling. Given a positive integer n, a grid a = XQ < x\ < KI < • • • < xn = b is defined on [a, b] by Xj — a + i AJC, AJC = (b — a)/n. The vector F e R" is then defined by

Clearly F can be said to approximate /, as Figure 2.1 shows. If / and g are two such continuous functions and F and G are the corresponding vectors in R", then the dot product of F and G is

Chapter 2. The weak form of a BVP

38

Figure 2.1. Approximating a function f ( x ) by a vector F e R". This cannot define the inner product of/ and g, since F • G depends strongly on the grid. However, as the grid is refined, the Riemann sum

which is just F • G weighted by AJC, converges to a quantity that is independent of the grid, namely,

Therefore, it seems consistent (with the Euclidean dot product) to define the L2(a, b) inner product by

It can be shown that if / and g belong to L2(a, b), then (2.40) is well-defined (even if / and/or g are not continuous). It can also be shown that (2.40) satisfies the definition of an inner product. If £2 is a domain in R2 (or R", in general), then the L2 inner product is defined by

The corresponding L2-norm is defined by

2.4. Existence and uniqueness theory for the weak form of a BVP

39

The Sobolev space //' (Q) is defined in terms

(where the partial derivatives are weak derivatives), and therefore so is its inner product:

The Sobolev space HQ (Q) is a subspace of Hl (£2). The concept of subspace will be very important, particularly in the next chapter, so its definition is given here: DEFINITION 2.6. Suppose V is a vector space. A subset WofV is called a subspace ofV if the following properties hold: 1. The zero vector belongs to W;

The last two properties can be expressed by saying that W is closed under addition and scalar multiplication. A subspace is a vector space in its own right.

2.4.2

Hilbert spaces

My goal in this section is to describe the theory that guarantees that certain variational problems have unique solutions. There is a fundamental property of the spaces H](£2) and HQ (Q) (and other Sobolev spaces) that is needed for this theory: Sobolev spaces are complete. The property of completeness is rather abstract, but I can give an example of it that is easy to understand. The equation jc2 = a can be solved for each a > 0 because the real numbers are complete—there are no holes in the real number line. Thousands of years ago, it was thought that all numbers could be represented as ratios of integers, that is, as rational numbers. However, the Pythagorean theorem suggests that there ought to be a number whose square is 2 (this number is the length of the hypotenuse of a right triangle with two legs of length 1), and it is easy to prove that no rational number jc can satisfy x1 = 2. The set of rational numbers Q is not complete. This example suggests that the concept of completeness might be important for a theory describing when certain equations are guaranteed to have solutions. What does it mean for a space to be complete? Thinking about the previous example leads to the right description. The following sequence of numbers converges to a solution tojc 2 = 2:

40

Chapter 2. The weak form of a BVP

This sequence consists of rational numbers, but the discussion above shows that the sequence cannot converge to a rational number. Therefore, Q is not complete because there is a sequence in the set that "ought" to converge, but there is no limit for the sequence in the set itself. The property of a complete space is that every sequence that ought to converge actually does converge to an element of the space. It remains only to define what is meant by a sequence that ought to converge. The idea is that terms in the sequence get closer and closer together the farther out in the sequence they are. I will give the definition in a normed vector space. DEFINITION 2.7. Let {vn} be a sequence of vectors in a normed vector space V. The sequence is called Cauchy if, given any € > 0 (no matter how small), there exists a positive integer N such that

Here is the related definition of completeness. DEFINITION 2.8. A normed vector space V is said to be complete if every Cauchy sequence in V converges to an element ofV. It can be shown that the inner product spaces mentioned earlier, R n , L 2 (£2), //' (£2), and HQ (£2), are all complete. A complete inner product space is called a Hilbert space. An important notion in the theory of complete spaces is that of a dense subspace. For example, every real number can be approximated arbitrarily well by a rational number. For this reason, Q is said to be dense in R. DEFINITION 2.9. Suppose V is a normed vector space. A subset W is said to be dense in V if, given any v e V and any € > 0 (no matter how small), there exists w e W with

The set R is the completion of the dense subset Q; that is, R is precisely what results when all of the holes in Q are filled. The following theorem identifies some common dense subspaces of the Sobolev spaces. THEOREM 2.10. 1. C(£2) is dense in L2(£2) (that is, L2(Q) is the completion ofC(Q) under the L2 norm). 2. C'(ft) is dense in Hl(Q) (that is, Hl(Q) is the completion ofC}(tt) under the //' norm). 3. C<j(£2) is dense in H^(Q.) (that is, H^(Q) is the completion ofCQ(Q) under the H} norm). Other spaces dense in L2 (ft) are C£° («) and C°° (Q) n L2 (Q). The space C°° (ft) n #' (Q) is also dense in Hl(Q), and the space C0°(£2) is also dense in HQ (£2).

2.4. Existence and uniqueness theory for the weak form of a BVP

41

This theorem shows that the Sobolev spaces arise from "filling the holes" in the classical spaces, in the same way that R arises from Q.

2.4.33Linear functionalsals The Sobolev spaces are infinite-dimensional vector spaces, and the study of linear algebra is considerably more complicated in infinite dimensions than in finite dimensions. Much insight into the nature of infinite-dimensional vector spaces comes from studying the continuous linear functionals that can be defined on a given space. If V is a normed linear space, then a linearfunctional I on V is a real-valued function on V that is linear:

Continuity for a linear functional is defined just as for any other function: £ is continuous at u 6 V if or, equivalently, However, linearity has a couple of important implications for continuity. First of all, if I is continuous at any u in V, then t must be continuous at every u in V. To see this, notice that

where z — UQ + V — u. Since \\u — v\\ —» 0 if and only if \\UQ — z\\ -> 0, it follows that t is continuous at u if and only if it is continuous at MO. Second, it is not difficult to show3 that t is continuous at M = 0 (and hence at every «) if and only if there exists a nonnegative constant M such that

The smallest such bound M is called the norm of the linear functional t, and is denoted \\t\\. 3

\fl is continuous at 0, then there exists 0 such that ||u|| < S implies that

But then, for any u e V, the vector ( ke • e for a certain symmetric 2 x 2 matrix #. Find the eigenvalues of B.)

Chapter 3

The Galerkin method

In the previous chapter, I explained how to transform an elliptic BVP into its weak form. One advantage of the weak form is that it puts much less stringent requirements on the problem functions (such as the right-hand side of the PDE) and the solution, and therefore applies to a larger collection of problems. However, a more important advantage is that the weak form admits new solution techniques—in particular, the Galerkin method. There are several ways to introduce the Galerkin method. I prefer to approach it from the standpoint of linear algebra, because then the most striking feature of the method is clear from the beginning: The Galerkin method computes the best approximation to the true solution from a given finite-dimensional subspace.

3.1

The projection theorem

The projection theorem is a foundational result from linear algebra that provides a method for determining computable approximations to known or (in some contexts) unknown quantities. In its abstract form, it answers the following question: Given a vector u in an inner product space V and a finite-dimensional subspace W, what is the best approximation to u from W? That is, which vector w e W is closest to u in the sense that \\u — w\\ is as small as possible? The projection theorem applies to inner product spaces such as Rn or L 2 (£2) and is based on the notion of orthogonality. DEFINITION 3.1. IfV is an inner product space with inner product (-, •) and u, v are two vectors in V satisfying ( u , v ) — 0, then u and v are said to be orthogonal. In R2 or R3, where vectors can be visualized, orthogonality is equivalent to perpendicularity, since it can be shown that, in R2 or R 3 , two vectors u, v are perpendicular if and only if u • v — 0. However, orthogonality extends to spaces like L 2 (£2), where "two functions are perpendicular" has no apparent geometric meaning. In fact, the implications of orthogonality are pretty much the same, regardless of whether they can be visualized. 57

58

Chapters. The Galerkin method

Since the norm in an inner product space is defined by the inner product, the Pythagorean theorem holds in any inner product space. If vectors u, v in an inner product space V satisfy (u, u) = 0, then

The Pythagorean theorem is the basis for the proof of the projection theorem. THEOREM 3.2. Suppose V is an inner product space, W is a finite-dimensional subspace ofV, andu e V. Then 1 . there is a unique vector w e W satisfying

The vector w is called the best approximation to u from W or the projection of u onto W and is denoted projwu. 2. a vector w is the best approximation to ufrom W if and only if it satisfies the following orthogonality condition:

(see Figure 3. 1). The projection theorem also holds if W is an infinite-dimensional (closed) subspace of V, but in the finite-dimensional case the orthogonality condition makes it possible to derive a system of equations defining the best approximation, as I now show. If W is finite-dimensional, then it has a basis [w], . . . ,wn} and w e W can be represented as

Figure 3.1. Illustration of the projection theorem.

3.2. The Galerkin method for a variational problem

59

If u; also satisfies (3.1), then (taking z — w; ( )

Therefore, u; is determined by a system of n linear equations in the n unknowns a\ ,0.2,... ,ctn. If G e Rnxn and b e R" are defined by

respectively, then the system of equations can be written in matrix-vector form as Got = b. The matrix G is called the Gram matrix and the equations represented by Ga = b are referred to as the normal equations. Therefore, to compute the best approximation to u from W requires, when W is n-dimensional, the solution of an n x n system of linear equations. If it happens that {w], W 2 , . . . , wn} is an orthogonal basis for W, that is, if (Wj, w;/) = 0 for i / y, then the Gram matrix G is diagonal and it is simple to solve Ga = b:

It is not practical in the context of most PDEs to compute an orthogonal basis. However, if G is "nearly" diagonal, in the sense that most of the off-diagonal entries are zero, then Got = b can be solved efficiently even when n is very large. When most of its entries are zero, a matrix is said to be sparse. As shown in the next chapter, the finite element method produces systems with sparse matrices.

3.2

The Galerkin method for a variational problem

As I showed in the previous chapter, the variational form of many BVPs takes the form

where a(-, -) is a symmetric bilinear form on the Hilbert space V and € is a continuous linear functional on V. When the BVP is elliptic, the conditions

hold, and the bilinear form a(-, •) defines an alternate inner product on V.

lj

ghcfgty

Given a finite-dimensional approximating subspace W of V, the best approximation from W to the solution u of (3.2) is computed by solving the system Got — b, where

and { w i , W2, . . . ,wn} is a basis for W. Since the basis [ w \ , w^, . . . , wn] is known, the matrix G is computable. However, the true solution u is unknown, and there is no way of computing the vector b. The Galerkin idea is simple: Compute the best approximation to u using the alternate inner product defined by the bilinear form a(-, •) (the energy inner product). Then the variational equation (3. 2) gives the value of a (u, u)forallv G V (even though u is unknown): a(u, v) = l(v}. To find the best approximation to u in the energy norm, it is necessary to solve the system KU = F, where K is the n x n matrix defined by

and F e R" is defined by

In this context, the Gram matrix K is usually called the stiffness matrix, and the vector F is called the load vector. The vector U e Rn defines the approximate solution:

The load vector is computed by the formula Ft • = i(wt), i = 1 , 2, . . . , n. The reader should recall from the derivation in the previous section that the computed solution w (given by (3.4)) satisfies

or, since {w\ , if 2, . . . , wn} forms a basis for W,

The variational equation (3.5) is the form in which the Galerkin method is usually presented. It is identical to the variational equation (3.2) except that the space V is replaced with the finite-dimensional subspace W. Beginning with (3.5), the usual starting point, it can be shown directly that the approximate solution w is the best approximation to u from W. The solution u satisfies

and hence, since W c V,

3.2. The Galerkin method for a variational problem

61

Similarly, w satisfies Subtracting (3.6) and (3.7) yields

or

This is the orthogonality condition that is necessary and sufficient for w to be the best approximation from W (in the energy norm) to the true solution u. The Galerkin method leads to an approximate solution w satisfying

where u is the true solution to (3.2). While the vector w is not the best approximation in the original norm || • || on V, it cannot be much worse than the best approximation in the V-norm. The derivation is based on properties (3.3) and the following observation: If v e W, then, since W is a subspace of V, v — w is also in W. Since w is the best approximation to u from W in the energy inner product, the orthogonality condition

holds. Therefore, for any v e W,

Now (3.3) is applied as follows: For any v e W,

Dividing both sides by ||w — w\\ yields

This result is called Cea's theorem. While \\u — w\\ need not be as small as possible, it cannot be too much larger than the smallest possible \\u — v\\,veW. This fact is central to the finite element method, which is based on a family of approximating subspaces Wh, with dimension of W/, growing as h —>• 0. The corresponding Galerkin approximations Wh e Wh must improve at the same rate as the best approximations from Wh as h -> 0.

62

Chapters. The Galerkin method

Originally the Galerkin method was used to produce accurate approximate solutions from cleverly chosen low-dimensional subspaces. However, the finite element method is based on making the necessary computations (the computation of K, F, and the solution U of KU — F) efficient even when the dimension of the approximating subspace is large. This is achieved by choosing a special kind of approximating subspace, as explained in the next chapter. The reader is asked to work out some simple examples of the Galerkin method in the exercises at the end of the chapter.

3.2.1

Another interpretation of the Galerkin method

The reader will recall from Section 2.2 that the variational form of a BVP can be viewed as the optimality condition for the optimization problem of minimizing the potential energy of the physical system being modeled. Using the abstract notation from (3.2), the energy is given by

(I will ignore the additive constant, since it does not affect the minimization.) The problem is to find u e V to solve Given that V is infinite-dimensional, making (3.9) intractable in most cases, a natural approach is to choose a finite-dimensional approximating subspace W of V and solve instead

This approach is called the Ritz method. Since W is finite-dimensional with a basis {wi,u)2,.-.,wn}, (3.10) can be expressed in terms of the coordinates in R" defined by the basis for W. If w e W is given by

then

3.3. Exercises for Chapter 3

63

where K and U are the same stifmess matrix and load vector defined above. The problem now is to choose U e R" to minimize

But an easy calculation shows that

and thus the minimizer is found by solving the linear system

Therefore, minimizing J over the subspace W (the Ritz method) is really the same as the Galerkin method. For this reason, the method is sometimes called the Ritz-Galerkin method.

3.2.2

The Galerkin method for a nonsymmetric problem

Although I restrict myself almost entirely to symmetric problems in this book, I want to point out that the Galerkin method is just as applicable to a nonsymmetric elliptic problem. In fact, the norm of the error satisfies Cea's theorem, as in the symmetric case, and for exactly the same reason. (The reader can verify that in the derivation of (3.8) I did not use the symmetry of a(-, •)•) However, it cannot be said that u; is optimal in the energy norm, since the bilinear product a (•, •) does not define an inner product in the nonsymmetric case.

3.3

Exercises for Chapter 3

Note: The following exercises require the computation of a number of definite integrals, and also the solution of systems of linear equations. The reader is encouraged to use a computer algebra system; these computations would be very tedious performed by hand. 1. (Some simple examples of the projection theorem.) Consider the inner product space

with inner product

The function f ( x ) = ex belongs to L 2 (0, 1). The following exercises ask for the best approximation to / from various subspaces, using various inner products. (a) Consider the subspace P^ consisting of all polynomials of degree four or less. Find the best approximation to / from V\. Note that a basis for P^ is

64

Chapters. The Galerkin method (b) Now consider L 2 (0, 1) under the alternate inner product

Find the best approximation, relative to the norm induced by this inner product, to/ from P4. (c) Repeat Exercise 1 (a) with P4 replaced by the subspace spanned by the basis (d) Repeat Exercise l(b) with P^ replaced by F2. By graphing the error in each estimate, compare the four approximations to /. Is one to be preferred over the others? Why? The reader should note that when the vector / to be estimated is known, one may choose any convenient inner product. This should be contrasted with the Galerkin method, in which the vector to be estimated is unknown and the energy inner product must be used. 2. Consider the one-dimensional BVP

where f ( x ) = ex . The weak form of this BVP is

where and

The variational problem (3.1 1) can be written in the usual form, a(u, v) — t(v} for all v e V, by defining V = /^(O, 1) and

(a) Define W to be the subspace of HQ (0, 1) spanned by the basis

Apply the Galerkin method to find the best approximation, in the energy norm, from W to the solution u of (3.1 1).

3.3. Exercises for Chapter 3

65

(b) Repeat Exercise 2(a) with W replaced by

(c) Find the exact solution to the original BVP and compare the two approximate solutions by graphing the errors. 3. Let {w\, W2,. • • , wn] be a basis for a subspace W of an inner product space, and let G be the corresponding Gram matrix: G,; = ( w j t u;/). Notice that G is symmetric: Gtj - Gji for all i,j. (a) Show that G is positive definite: x • Gx > 0 for all x e R", jc ^ 0. (Hint: Let v — Y%=\ xiwi ar|d snow that x • Gx = (v, v).) (b) Use the preceding result to show that G is nonsingular.

This page intentionally left blank

Chapter 4

Piecewise polynomials and the finite element method

I have now presented the two theoretical foundations of the finite element method: the variational form of a B VP and the Galerkin method for producing an approximate solution to a variational equation from a given finite-dimensional subspace. The key practical ingredient of the method is the choice of the approximating subspace. The finite element method is Galerkin's method with a subspace of piecewise polynomial functions. The Galerkin method requires the computation of the stiffness matrix K and the load vector F, and the solution of the system KU = F. For the method to be efficient, it must be possible to compute K and F efficiently and also to solve the system efficiently. For the method to be effective, the approximating subspace must be chosen so that the true solution of the problem can be well-approximated by an element of the subspace. The three requirements described in the previous paragraph can all be met by an approximating subspace consisting of piecewise polynomial functions. It is easy to integrate and differentiate polynomials (the main requirements for computing K and F), and piecewise polynomials lead naturally to a sparse stiffness matrix, allowing KU — F to be solved efficiently. Finally, smooth functions can be well-approximated by piecewise polynomials. I begin by describing the construction of spaces of piecewise polynomials.

4.1

Piecewise linear functions defined on a triangular mesh

A polynomial in jc and y has the form

where aoo, «io, • • • , #o« are constants. To define & piecewise polynomial over a domain f2, the domain must be partitioned into subdomains. A piecewise polynomial is a function that is defined by a polynomial on each subdomain. The collection of subdomains is referred to as a mesh. 67

68

Chapter 4. Piecewise polynomials and the finite element method

Figure 4.1. Two examples of nonconfarming triangulations. In both examples, the intersection of triangles 1 and 2 is a line segment that is not an edge of triangle 1.

Figure 4.2. Triangulations of two polygonal domains.

The most common meshes in two dimensions are triangulations—the domain £l is expressed as the union of triangles.5 The intersection of any two triangles must be a common vertex or a common edge. Situations such as those shown in Figure 4.1 are called nonconforming and are not allowed. If £1 is not polygonal, it is necessary to approximate pieces of 9£2 by line segments or simple curves, which can give rise to triangles having a curved edge. In this section, I will assume that £2 is polygonal, so that a triangulation covers it exactly. Figure 4.2 shows triangulations of a square and a pentagon. Some notation is required to describe a piecewise polynomial relative to a given triangulation. I will assume that a given triangulation consists of Nt triangles T\, T2,..., T^l. The vertices of the triangles will be denoted z\, zi,..., ZNI:, where Zj = (*_/, x/)- As Figure 4.2 illustrates, each vertex is typically a vertex of several triangles. To each triangle is associated three vertices from the list z\,Z2, • •• ,ZNV, which can be identified by their indices in this list. The indices of the vertices of 7} will be denoted «/,i, n/,2, «/,3. That is, the vertices of 7/ are

5 Here I will use a convenient abuse of terminology. Strictly speaking, a triangle is the union of three line segments. However, 1 will denote by T the domain enclosed by a triangle together with the triangle itself, and refer to T as a triangle. In my notation, then, i)T is what one would normally call a triangle.

4.1 . Piecewise linear functions defined on a triangular mesh

69

The mapping from /, j to n,-j maps from local indices (j = 1 , 2, 3) to global indices. When focusing on a single triangle T, it is frequently convenient to use only local indices, in which case the vertices will be denoted z\ , 12, Z3- Strictly speaking, this is an abuse of the notation established above, but it simplifies things considerably. In implementing and analyzing the finite element method, it is necessary to consider a family of triangulations. Each triangulation is usually labeled by its mesh size h, where h is the maximum diameter of any triangle in the triangulation. For this reason, a typical triangulation is denoted by 7/j. The simplest space of continuous piecewise polynomials consists of continuous piecewise linear functions defined relative to a triangulation 7/j of a polygonal domain £2 c R 2 A piecewise linear function p must reduce to a first-degree polynomial a/ + b(x + c/y on each triangle 7} e 77, . The three parameters a, , bt , c/ are uniquely determined by the values of the function at the three vertices of 7)- . A simple way to see this is to realize that the graph of p, restricted to 7], is a piece of a plane. That plane is uniquely determined by the three points

Moreover, since by assumption p is continuous, its value at a vertex is well-defined. If triangles 7] and Tk both have Zj as a vertex, then a/, b, , c, and ak,bk, ck must be such that

Therefore, the 3N, parameters a\ , b\ , c\ , . . . , a^, , £#, , CN, are not all independent. Assuming that 7} and Tk are two triangles sharing an edge e, then

must hold if /? is to be continuous across e. Since the graph of a linear function in two variables, restricted to a line segment in the plane, is a line segment in 3-space, the fact that the linear functions defining p on 7) and Tk agree at the two endpoints of e is enough to show that they agree on all of e. This reasoning shows exactly how many degrees of freedom there are in describing a piecewise linear function on a given triangulation T/, : If 7h contains Nv vertices, then a piecewise linear function on 7~h is determined by the Nv nodal values of the function. Figure 4.3 shows two piecewise linear functions, one defined on each of the meshes shown in Figure 4.2. Thus, if 77, has Nv vertices, then the space P^(1) of all continuous piecewise linear functions defined on T/, is a finite-dimensional vector space with dimension Nv. Each function v e P^} can be identified with a vector a e RN" consisting of the nodal values of v. Moreover, it is easy to find a basis {^i , fa, • • • , ^N,,} f°r PH ^ w ith the property that

Such a basis would have to have the property that, for any a e

Chapter 4. Piecewise polynomials and the finite element method

70

Figure 4.3. Two continuous piecewise linear functions.

Figure 4.4. Standard has is functions for two spaces of continuous piecewise linear functions. that is, that

The condition (4.1) uniquely defines the basis functions Vv, * — 1 , 2 , . . . , Nv. Typical examples, again for the triangulations from Figure 4.2, are shown in Figure 4.4. A basis satisfying (4.1) is called a Lagrange basis or a nodal basis.

4.1.1

Using piecewise linear functions in Galerkin's method

Before I discuss the details of using continuous piecewise linear functions in the Galerkin method, I want to show that it is correct to do so, namely, that a valid approximating subspace can be constructed of continuous piecewise polynomial functions. For example, consider the Neumann problem

4.1 . Piecewise linear functions defined on a triangular mesh

71

where ^2 is assumed to be polygonal. The weak form is

where

To apply Galerkin's method, a subspace V/, of V is needed. To justify the choice V/j = P(h \ it must be shown that P^]) is a subspace of V, that is, that a continuous piecewise linear function belongs to Hl (Q). If u 6 P^\ with u(jc, y) = a-i + b[X + c-,y for ( x , y ) e 7), then, in the classical sense,

Here int(7)) denotes the interior of the set 7}, that is, the triangular region, not including the boundary. In most cases, the classical derivatives of v are undefined on the boundaries of most triangles 7}, since there is no reason to expect the derivatives to be continuous across the boundary between two adjacent triangles. (A linear function is piecewise linear, so in certain special cases the derivatives can be continuous across some or all boundaries between triangles.) I will show that (4.5) defines the weak partial derivatives of v. This is all I need to show, since the functions defined by (4.5) obviously belong to L2(£2). For any 0 e C£°(ft),

where n(l) is the outward-pointing unit normal to 97}. Every edge e of a triangle 7} either belongs to 9£2 or is the edge of one other triangle 7). In the first case, 0 is zero over e, and thus In the second case, n(l) = —n ( / ) on e, and both

72

Chapter 4. Piecewise polynomials and the finite element method

appear in the sum

Since v is continuous, it follows that

and thus these two integrals cancel. The conclusion of this reasoning is that

and thus

where 3u/3jc is defined by (4.5a). This shows that (4.5a) defines the weak partial derivative with respect to jc of v. A similar argument shows that (4.5b) defines the weak partial derivative of v with respect to y, and thus P^ } is a subspace of V. Next I will show how to incorporate Dirichlet boundary conditions into the definition of a space of continuous piecewise linear functions. The following example will be used:

Here FI and F2 form a partition of 3£2, and it is assumed that any points where Fj and F2 meet are nodes in the triangulation, and also that any such nodes belong to Fj. The weak form of (4.6) is

where and a(-, •) and i are defined as before. If e is an edge of a triangle T,• e Th and e lies on dQ, then e will be called a free (boundary) edge if one or both endpoints lie in F2. On the other hand, e is a constrained edge if both endpoints lie in FI . The nodes lying on F2 or in £1 are called free nodes, while those lying in FI are called constrained nodes. The desired approximating subspace of V is

4.1. Piecewise linear functions defined on a triangular mesh

73

The reader should notice that, because v is linear on each edge, v = 0 on r\ if and only if v = 0 at every node contained in PI. The dimension of V/, is the number of free nodes (the nodal values of any v e Vh at constrained nodes are already known). It is necessary to establish some notation to distinguish the free nodes and constrained nodes. The number of free nodes will be denoted by Nf and the number of constrained nodes by Nc. I define a sequence f\, fi,..., //v, so that

are the free nodes, and another sequence c\,C2,..., cNc so that

are the constrained nodes. EXAMPLE 4.1. As an example of the above notation, let £2 be the unit square,

with (so that r\ is the top edge of the square) and Vi = dQ \ PI (so that F2 consists of the left, bottom, and right edges of the square). Figure 4.5 shows a mesh defined on £2, indicating the enumeration of both the triangles and the nodes. In this mesh, Nt = 32 and Nv — 25. Recall that the integers «/. i , n, 2 > «/,3 we the indices of the three vertices of the triangle T[. For example, Figure 4.5 shows that

Since the first 20 nodes are free, Nf = 20 and fk = k, k = 1, 2, . . . , 20. Nodes 21, 22, 23, 24, and 25 are constrained, so Nc — 5 and

Figure 4.5. A triangulation of the unit square. The left graph shows how the 32 triangles are enumerated, while the right graph shows the enumeration of the 25 nodes.

74

Chapter 4. Piecewise polynomials and the finite element method

It is important to note that the enumeration of the triangles and of the nodes is not unique; the same mesh can be enumerated in different ways. If V h is a subspace of P^ \ as described above, then a basis for V/, consists of those standard basis functions \lr\, fa, •.., ^NV corresponding to free nodes. That is, is a basis for Vh. For convenience of notation, 1 will write 0* = tyfk, so that the basis for Vh can be written as

Inhomogeneous Dirichlet conditions

In Section 2.3.3,1 explained how to handle inhomogeneous Dirichlet boundary conditions, at least in principle. The weak form of the BVP

is the following:

where G is any function in Hl(Q) satisfying the boundary condition G = g on F[. It may not be easy to find such a G exactly, but it is easy to define a function G that approximately satisfies the boundary condition. Indeed, the continuous piecewise linear function G defined by

agrees with g at the endpoints of every constrained edge and therefore interpolates g on FI . This function G is a sufficiently good approximation to g for the purposes of the finite element method (see Section 5.3). 4.1.2

The sparsity of the stiffness matrix

I will now discuss why it is advantageous to use Phl} (or a subspace) as the approximating subspace in the Galerkin method. One advantage is that it is easy to work with polynomials (and particularly linear functions). Evaluating, differentiating, and integrating them is simple. The second reason is that when the standard nodal basis is used, the resulting stiffness matrix is sparse, that is, has few nonzero entries. As I showed in Section 3.2, if the approximating subspace V/2 has basis {0i, 0 2 , . . . , 0^}, then the stiffness matrix belongs to RN/*N/ and has entries

4.1. Piecewise linear functions defined on a triangular mesh

75

Figure 4.6. The support of the standard basis functions (j)\ and (fr given in Figure 4.5. In the scalar model problem,

and the reason that K is sparse is simply that each standard basis function 0/ is zero over most of the domain fi. It follows that, for most choices of/ and j, the integral

is zero, since V0(- • V0y- is zero over all Q. This is not true for all pairs i, j, i ^ j, but it holds for most of them. The sparsity of K will be illustrated in detail for the mesh in Example 4.1. Figure 4.6 shows the supports of \$ for the mesh given in Figure 4.5. The free nodes of the mesh are labeled in this graph.

Figure 4.8. The sparsity pattern of the stiffness matrix K corresponding to the mesh given in Figure 4.5. The 20 x 20 matrix K has 82 nonzeros. seven nonzeros). Therefore, the matrix K is fairly sparse. The sparsity pattern of K (for ic(x, y) = 1) is illustrated in Figure 4.8. (The reader will notice only, at most, five nonzeros per row instead of seven as indicated above. Entries like £"13,7 and #13,19 happen to be zero due to the symmetry in the mesh.) It should be noted that as a general rule, when a triangulation is refined the number of nodes adjacent to a given node does not increase. For example, the mesh in Figure 4.9 has four times as many triangles as the mesh in Figure 4.5. Assuming the same boundary conditions, this finer mesh would have 72 free nodes and K would be 72 x 72. However, a node in the center of the mesh would still have at most seven adjacent nodes. Therefore, the degree of sparsity of the stiffness matrix increases as the mesh is refined. For example, for the coarser mesh, the 20 x 20 matrix contains 82 nonzeros, so about 20% of the entries are nonzero (82 out of 400). For the finer mesh, the matrix is 72 x 72 and 326 entries are nonzero, which is about 6%.

4.2. Quadratic Lagrange triangles

77

Figure 4.9. A finer mesh (compare the mesh in Figure 4.5).

4.2

Quadratic Lagrange triangles

I will now discuss the use of higher-order piecewise polynomials, beginning with continuous piecewise quadratics. I will continue to assume that the underlying domain £2 is polygonal and that the piecewise polynomials are defined on a triangular mesh.

4.2.1

Continuous piecewise quadratic functions

A linear function f(x, y ) = a + bx + cy is determined by three parameters, and this fact makes it natural to use piecewise linear functions defined on a triangulation. A quadratic function is of the form

which shows that six parameters are required to define such a function. If a quadratic function is to be determined by the nodal values on a triangle, then it is necessary to add three nodes to the triangle, in addition to the three vertices. For reasons I explain now, these nodes should be the midpoints of the three edges of the triangle. What factors determine the placement of the nodes? First, it is necessary that the six nodes determine a unique quadratic. Second, it must be the case that the quadratics defined on two adjacent triangles necessarily agree on their intersection provided they agree on all common nodes. To satisfy the first condition, it suffices to take one point on each edge, in addition to the three vertices. One could also take the three vertices together with three (properly chosen) interior nodes. However, it would then not be possible to satisfy the second property. By choosing the three additional nodes as the midpoints of the three edges of the triangle, two triangles 7} and 7/ intersecting along an edge e necessarily share three nodes on that edge. Moreover, a quadratic function in two variables, restricted to a line segment e, reduces to a quadratic in one variable when the edge is suitably parametrized. Three points determine a unique quadratic in one variable, so the second condition in the previous paragraph is satisfied.

78

Chapter 4. Piecewise polynomials and the finite element method

The space of all continuous piecewise quadratic functions defined on a given triangulation Th will be denoted P^ \ The particular functions allowed on each triangle are called the shape functions of the element. In the case of P^ \ the shape functions are quadratic polynomials. The additional nodes described above (the midpoints of every triangle edge) are now part of the triangulation, and I must establish some notation to describe this more complicated situation. The nodes of the mesh, including both triangle vertices and edge midpoints, will be denoted by zi, 12, • • . , ZN,,- I define m, y so that the nodes of triangle 7} are

The vertices of 7} are still denoted by

(At certain times, for instance when integrating over a triangle, it is necessary to distinguish the vertices from the other nodes.) As in the case of P^ \ a Lagrange basis {\jf\ , ^2, . . . , V%1 of PH ) is defined by

A triangulation of the type described in this section, suitable for use with continuous piecewise quadratic functions, will be called a mesh consisting of quadratic Lagrange triangles. The simpler mesh described in the preceding section consists of linear Lagrange triangles. Figure 4.10 shows a mesh of quadratic Lagrange triangles, while Figure 4.1 1 shows two examples of the corresponding standard basis functions, ^5 and V^is, respectively. There are two essentially different types of basis functions for the space of continuous piecewise quadratic functions: i/r, looks like one of the functions in Figure 4.11, depending on whether Zi is a triangle vertex or an edge midpoint.

4.2.2

The finite element method with quadratic Lagrange triangles

( it is not much harder to implement the Given the above description of the space hP\ finite element method using quadratic Lagrange triangles than it was with linear Lagrange triangles. The Galerkin method is completely abstract, and the only thing that changes in going from piecewise linear functions to piecewise quadratic functions is the choice of the approximating subspace. As an example, I will consider the BVP with mixed boundary conditions

where T| and F2 form a partition of 9^2. As before, any point where Fj and F2 meet must be a triangle vertex and must belong to Fj .

4.2. Quadratic Lagrange triangles

79

Figure 4.10. A mesh of quadratic Lagrange triangles (the nodes of the mesh are labeled).

Figu re 4.11. The standard basis functions 1/^5 (left) and ty \ 8 (right) for P^ on the mesh from Figure 4.10.

defined

It is necessary, as before, to distinguish between free nodes (those belonging to £2 or F2) and constrained nodes (those belonging to FI). The free nodes will be denoted as Zf\ , Z f 2 , . . . ,ZfN. and the constrained nodes as zC{, zC2 ,••••> zCNi., as before. The weak form of (4.12) is

where The approimating subspace is

80

Chapter 4. Piecewise polynomials and the finite element method

In order that v e P^ satisfy v = 0 on FI, it suffices that v have value zero at every node belonging to Fj. This is sufficient because a triangle edge having a nontrivial intersection with FI lies entirely in F] by assumption. A basis for V^ is therefore

or

where, as before, 0, = ^/; • The stiffness matrix K is now defined by

and the load vector by

In this notation, the formulas are exactly the same as those presented in the case of piecewise linear functions. Of course, the basis function represented by 0, is now different. But, as the reader will see, the implementation of the method in a computer program does not change much when piecewise quadratic functions are substituted for piecewise linear functions. EXAMPLE 4.2. Figure 4.12 shows a mesh (for the unit square) consisting of quadratic Lagrange triangles. The mesh contains 32 triangles, 81 nodes, and 49 free nodes (Dirichlet conditions are imposed on the entire boundary). I computed the stiffness matrix K corresponding to the BVP (4.\2)for this mesh and for K ( x , y ) = 1. The sparsity pattern of the stiffness matrix is also shown in Figure 4.12. The matrix contains 405 nonzeros; since it is 49 x 49, about 17% of the entries are nonzero. The pattern of the nonzeros, though not the number of nonzeros, depends on the order in which the nodes are numbered. A refined meshfor the same domain is shown in Figure 4. 1 3. // contains 128 triangles, 289 nodes, and225free nodes. The stiffness matrix, which is also illustrated in Figure 4.13, contains 2229 nonzeros (about 4% of the entries).

4.3 4.3.1

Cubic Lagrange triangles Continuous piecewise cubic functions

A cubic function in two variables has the form

4.3. Cubic Lagrange triangles

81

Figure 4.12. A mesh for the unit square consisting of quadratic Lagrange triangles (left) and the spars ity pattern of the corresponding stiffness matrix (right).

Figure 4.13. A refined mesh for the unit square consisting of quadratic Lagrange triangles (left) and the sparsity pattern of the corresponding stiffness matrix (right). and is therefore determined by 10 parameters. To define a continuous piecewise cubic function on a triangular mesh, it is necessary to add seven nodes to each triangle, in addition to the three vertices. The placement of these nodes is determined by the following fact: A cubic function in two variables, restricted to a line segment, reduces to a cubic function in a single variable (when the line segment is parametrized). A cubic function of a single

82

Chapter 4. Piecewise polynomials and the finite element method

variable is determined by four nodal values, which means that each triangle edge must contain a total of four nodes. Then cubic functions defined on two adjacent triangles will agree on the common edge provided they agree at the four nodes, making it easy to guarantee the continuity of a piecewise cubic function determined by its nodal values. These four nodes consist of the two vertices (the endpoints of the edge) and the points placed at regular intervals between the two vertices. Thus if the two vertices are (*i, y\) and (x2, ^2), the other two nodes on the edge are

The reader should notice that the regular placement of the nodes on the edges guarantees that two triangles intersecting along an edge share four common nodes. Adding two nodes on each edge yields six additional nodes, or nine total when the vertices are taken into account. The final node must lie in the interior of the triangle, and it is natural to place it at the centroid of the triangle. Therefore, if the three vertices of the triangle are (jti, y\), (x2, y2), and (*3, 373), then the interior node will be

A triangulation consisting of triangles, each having 10 nodes as described above, is said to consist of cubic Lagrange triangles. Figure 4.14 shows a mesh of cubic Lagrange triangles defined on the unit square. It contains 8 triangles, 49 nodes, and 25 free nodes (Dirichlet conditions are imposed on the entire boundary).

Figure 4.14. A mesh for the unit square consisting of cubic Lagrange triangles (left) and the sparsity pattern of the corresponding stiffness matrix (right).

4.3. Cubic Lagrange triangles

83

As in the case of quadratic Lagrange triangles, the nodes of the mesh are denoted z\, Z2, • • • , ZNI:. The 10 nodes of triangle 7) are denoted by

The notation for free and constrained nodes remains the same as before.

4.3.2

The finite element method with cubic Lagrange triangles

Using continuous piecewise cubic functions in the finite element method merely means applying Galerkin's method with the space P^} (or an appropriate subspace taking into account the Dirichlet boundary conditions) as the approximating subspace. Here P^ denotes the space of all continuous piecewise cubic functions defined on a given triangulation ThThe standard basis for P\:) is where t/'/ is defined by

The basis functions corresponding to the free nodes z j \ , z/2,..., z/N

are denoted by

where 0, = \fffi. Since there are three different placements for nodes on cubic Lagrange triangles (centroid, interior of edge, and vertex), the standard basis functions take three different shapes. These are illustrated in Figure 4.15. The formulas for the stiffness matrix and the load vector are the same as before:

Figure 4.15. The standard basis functions ^44, corresponding to a centroidnode (left); 1/O6, corresponding to an edge node (center); and ^5, corresponding to a vertex (right), for P(h } defined on the mesh from Figure 4.14.

84

Chapter 4. Piecewise polynomials and the finite element method

Once again, as I will show in the second part of the book, the algorithm for computing K and F does not change very much in going from piecewise linear or quadratic functions to piecewise cubic functions. EXAMPLE 4.3. / computed the stiffness matrix for (4.12) and the mesh shown in Figure 4.14, taking K(X, y) — 1. The spars ity pattern of the resulting K is shown in Figure 4.14. The matrix K is 25 x 25, and 229 of the 625 entries are nonzero (about 37%). Refining the mesh of Figure 4.14 by replacing each triangle withfour results in a mesh with 32 triangles, 169 nodes, and 121 free nodes. (This finer mesh is not shown.) About 11% (1513 out of1 4 641) of the entries are nonzero.

4.4

Lagrange triangles of arbitrary degree

The constructions of the previous sections can be generalized to the case of continuous piecewise polynomial functions of degree d. As before, the placement of the nodes in a triangular element is determined by two requirements: 1. On each edge there must be d + 1 nodes, since a one-dimensional polynomial of degree d has d + 1 degrees of freedom (that is, d + 1 coefficients). Each edge contains two vertices, and the other d — I nodes will be regularly spaced between them. The total number of nodes on the boundary of the triangular element is therefore 3 + 3(d-}) = 3d. 2. A polynomial of degree d in two variables is determined by

parameters, since there is one constant term, two terms of degree one (jc, _y), three terms of degree two (x2,xy, y2), and so forth, up to d + 1 terms of degree d (xd, xd~ly,..., xyd~}, yd). Since 3d nodes lie on the boundary of the triangle, the remainder must lie in the interior. A simple calculation shows that

For d = 1, d = 2, d — 3, this formula yields 0,0, 1, respectively, for the number of interior nodes. This is consistent with the constructions of linear, quadratic, and cubic Lagrange triangles presented previously. Ford > 3, the interior nodes can be arranged on a triangular lattice, as shown in Figure 4.16 for d = 4, d = 5, and d — 6. Once the Lagrange elements have been defined, the rest of the development proceeds as in the case of quadratic or cubic Lagrange triangles. The Lagrange basis for P^d\ [ty\, V^2. • • • , ^N,}-, is defined by

4.4. Lagrange triangles of arbitrary degree

85

Figure 4.16. Lagrange triangles of degrees d = 4 (left), d = 5 (center), andd — 6 (right).

where z\ , 12, • • • , ZN,, are the nodes in the mesh. Each node on the boundary of the domain £2 is designated as constrained or free, depending on whether a Dirichlet condition is posed there or not. All nodes in the interior of £2 are free. The free nodes are zj\ , z/2 , . . . , ZfN , and the basis functions corresponding to these nodes are written as 0i , fa, . . . , 0#;-, where

The Galerkin method, which, as noted before, is completely abstract, is then applied with the approximating subspace

4.4.1

Hierarchical bases for finite element spaces

One shortcoming of using Lagrange triangles in the finite element method is that the stiffness matrix K tends to become quite ill-conditioned as the mesh is refined. The consequence is that solving KU = F becomes more difficult, in that direct methods are less accurate and iterative methods are less efficient. I will discuss both direct methods and iterative methods for solving KU — F in Part III. I will also define the condition number of a matrix and show the effects of a large condition number on algorithms for solving KU — F. The ill-conditioning of K actually arises from the choice of basis for the approximating subspace V/7, not the choice of the subspace itself. For example, given any subspace Vh, I could choose a basis for V/, that is orthonormal with respect to the energy inner product. Then the stiffness matrix K, which is given by AT,-/ = a (0 7 ,0,-), would be the identity matrix, which is perfectly conditioned. This shows that the ill-conditioning of A' is not intrinsic, but rather arises from the choice of basis. An orthonormal basis may not be practical because of the expense involved in computing the basis. However, there are many other bases that could be used. One possibility is a hierarchical basis (see Yserentant [44]). A hierarchical basis is defined in a natural way when the mesh is obtained by several refinements of an initial, coarse mesh. I will describe the use of hierarchical bases in Section 11.2 in the context of solving KU = F.

86

4.5

Chapter 4. Piecewise polynomials and the finite element method

Other finite elements: Rectangles and quadrilaterals

A triangle is not the only possible shape for element domains. If the computational domain happens to be rectangular (or a union of rectangles), then rectangular elements are a natural choice. For nonrectangular domains, general quadrilateral elements can be used.

4.5.1

Rectangular elements

A rectangle has four vertices, so it is natural to consider a class of polynomials with four degrees of freedom. Since a linear polynomial is determined by three degrees of freedom and a quadratic by six, only certain quadratic polynomials will be allowed, namely, those of the form Since every product (a + fix)(y + Sy) of linear polynomials can be written in the form a + bx + cy + dxy, such polynomials are referred to as bilinear. Given a rectangle aligned with the coordinate axes, say with vertices (x\ , y\ ), (xi , y\ ), (*2, Jz), (x\, ^2), and given any four real numbers u\, HI, «3, « 4 , it is straightforward to show that there is a unique polynomial a + bx + cy + dxy such that

(see Exercise 8). If £2 is a rectangle or a union of rectangles, then a mesh M.h of rectangles can be defined on 12. A bilinear function reduces to a linear function in one variable on any edge of a rectangular element. Therefore, it is easy to see that a collection of real numbers, one for each node in the mesh, determines a unique continuous piecewise bilinear function on M.h- (The reader should notice, however, that this property depends on the assumption that the rectangles are aligned with the coordinate axes; see Exercise 9.) I will denote the space of all such functions by B^\ If the nodes of the mesh are denoted z i , Z 2 , • • • , ZNU, then the standard basis for fi^1} is {^i , fa, • • • , Vfw,J K where

The finite element method can be applied to the BVP

where 3£2 = PI U F2 is a partition of dQ, using the subspace

4.5. Other finite elements: Rectangles and quadrilaterals

87

The free nodes of the mesh are the nodes that do not belong to F|, and are denoted as before by Zft, Zf2, • • • , ZfN.. The basis for B^]) is then {(f>\,4>2, • • • , 4>Nf}, where 0, — ^;. Just as in the case of triangular elements, the result is a matrix-vector equation KU — F, where

and

4.5.2

General quadrilaterals

Rectangular elements are useful when the domain £2 is very simple, but a more general domain cannot be well-approximated by a mesh of rectangles. A mesh of general quadrilaterals can be used; however, it is not so straightforward to define a space of piecewise polynomials. As Exercise 9 shows, nodal values do not determine continuous piecewise bilinear functions on a mesh of general quadrilaterals. The usual way to define shape functions on a mesh of quadrilaterals is to view each quadrilateral Q as the image of a reference square SR under a mapping of the form

The reference square SR is taken to be the square with vertices (—1, —!),(!, —!),(!, 1), and (- 1 , 1 ). If the vertices of Q are (jci , y\ ), (JQ, ^2), C*3, >'3), and (jc4, >'4) (in that order as the 9 Q is traversed), then the mapping (4. 1 5) is determined by the conditions that (— 1 , — 1 ) be mapped to (x\, y\), (1, — 1 ) be mapped to (xi , 3/2 )» (1,1) be mapped to (x^ , j3),and(— 1, 1) be mapped to (^4, >'4). These conditions yield two 4 x 4 linear systems that determine a\,a2,ai,ci4 andb\, bi, bj, b$:

and

The coefficient matrix in the two systems is the same,

88

Chapter 4. Piecewise polynomials and the finite element method

and the two systems can be written

where

The inverse of M is

so explicit formulas for a and b are easily derived. The bilinear shape functions on SR are then mapped to Q, defining the shape functions for that element. The shape functions on SR are represented by the basis functions

(see Exercise 10). As the following example shows, the shape functions on Q are usually not bilinear. EXAMPLE 4.4. Consider the trapezoid Q with vertices (0, 0), (3,0), (2, 1), and (I, 1). Using the reasoning given above, the mapping from SR to Q is

and the inverse of this mapping is

The basis functions on Q are then defined by

4.5. Other finite elements: Rectangles and quadrilaterals

89

Direct calculation then shows that

The shape functions on Q are therefore rational functions. In the previous example, the nodal basis functions <j>\, fa, $3, $4 are linear on the edges of Q, as is easily verified (see Exercise 11). This property is true in general: Although the nodal basis functions, generated by the above technique for an arbitrary quadrilateral Q, are rational functions, each reduces to a linear function on the edges of Q. This fact can be used to prove that, on a mesh of quadrilaterals, the nodal values determine a unique continuous and piecewise rational function (see Exercise 12). I now assume that a mesh Mh of quadrilaterals is defined on a polygonal domain Q. As usual, the nodes of the mesh are denoted by z\, 22, • • • , Zjv,,- The space of continuous piecewise functions on M.h, constructed from bilinear functions on SR as described above, is denoted by B(h]\ The nodal basis for B(h } is {i/o, fa, • • • , ^N,}, where ^/ is defined by

for j = 1 , 2 , . . . , Nv. The free nodes are denoted Zf\, z / 2 , . . . , ZfN , and the approximating subspace V/j has basis {0i, 02, • • • , 0jv,K where 0/ — \fffi. To compute the finite element solution, the stiffness matrix K and the load vector F must be formed. These are defined by

and Since each basis function 0, has support consisting of a few elements (four quadrilaterals, to be precise, unless the corresponding node is on the boundary), the basic calculations that must be performed are of the integrals

and

90

Chapter 4. Piecewise polynomials and the finite element method

where Q is a typical quadrilateral in the mesh. In practice, the basis functions are not computed on Q; rather, each integral is transformed into the reference square SR so that the relatively simple bilinear functions y\, y2, y?, y* can be used instead. Given a quadrilateral Q, I will write z — (x, y) for a typical point in Q and u — (s, ?) for a typical point in SR. The transformation from SR to Q is denoted z — F(w),

The Jacobian matrix for this transformation is

According to the rule for changing variables in a multiple integral,

This can be applied directly to the formula for F/. In the following formulas, it is convenient to use local indices: For a given quadrilateral Q, the vertices are denoted by (jcj, >>]), (jc2, J2), C*3, ys), C*4, ^4) and the corresponding basis functions (the only ones that are nonzero on Q) are denoted by 0i, 02, 03, 04. Then, under the transformation F, 0, is transformed to y,: Here is the formula needed for assembling the load vector:

To change variables in the integral

it is necessary to know the relationship between V0, on Q and Vy/ on SR. This follows from the chain rule:

Therefore,

4.6. Using a reference triangle in finite element calculations

4.6

91

Using a reference triangle in finite element calculations

In the previous section I showed how to use a reference element to extend piecewise bilinear functions from meshes of rectangles to meshes of general quadrilaterals. By defining a oneto-one transformation from the reference element to an arbitrary quadrilateral, the necessary computations could be carried out over the reference element instead of the quadrilateral. The reader will recall that this was necessary because bilinear functions do not extend continuously across element boundaries when the elements are general quadrilaterals as opposed to rectangles. Although it is not necessary to use a reference element when the elements are triangles, it is advantageous to do so. This is because the basis functions and their gradients can be computed once on the reference triangle and then used, by means of a transformation, on each triangle in the mesh. In this section I will show how this affects the computations. The reference triangle TR is the triangle with vertices (s\, t\) — (0,0), (s2, t2) = (1,0), and (53, rO = (0, 1) (see Figure 4.17). I denote an arbitrary point in TR by (s, t) or, in vector notation, u — (s, t). Given an arbitrary triangle T with vertices z\ — (x\ , y\), z2 = (x2, y2), zi — (xi, yti, an arbitrary point in T will be denoted by (jt, y) or z = (x,y). The reference triangle TR is mapped to T by the following transformation, which sends (0, 0) to ( x { , y\), (1,0) to (x2, y2), and (0, 1) to (*3, y3):

In vector form, the transformation is

or

Figure 4.17. The reference triangle TR.

92

Chapter 4. Piecewise polynomials and the finite element method

where

Given any function / defined on T, there is a corresponding function on TR defined

by or The function g has the same values as / does, in the sense that if u e TR corresponds to ze T,theng(u) = f ( z ) . The three standard Lagrange basis functions that are nonzero on T will be written (using local indices) as 0,, i = 1,2,3; they are defined by

Corresponding to 0, on T is y/ on TR:

Since the vertices of TR are mapped to the vertices of T, y/ satisfies

Moreover, a little algebra shows that each y, is linear in (s, t). If

then

Since each y/ is linear over TR, it follows that y\, xz, K? are just the standard Lagrange basis functions that are nonzero over TR. The following formulas are easily derived from condition (4.18):

The same functions y\,yi, K? correspond to \, fa, 03 over any triangle T. This is the efficiency gain I mentioned earlier: y\,y2, Y3 can be computed once instead of computing 0i, 02, 03 on each triangle in the mesh.

4.7. Isoparametric finite element methods

93

The formula for a change of variables in a multiple integral gives

where g is defined by

The Jacobian factor is

Since the transformation from TR to T is linear,6 J and its determinant are constant. Therefore,

This result applies directly to the problem of computing the load vector:

To compute the stiffness matrix, it is necessary to evaluate integrals of the form

As in the previous section, the relationship between V0, and Vy, follows from the chain rule: Therefore,

Here K is the function on TR corresponding to K on T. In the piecewise linear case, both V0, and Vy, are constant. Although (4.21) might look a little complicated, it should be noticed that J is just a 2 x 2 matrix, and therefore computing J ~T Vy/ is a simple matter.

4.7

Isoparametric finite element methods

To this point, I have assumed that the domain Q is polygonal, so that it can be triangulated exactly. If £2 has a curved boundary, then a triangulation ?/; can only approximately cover !T2, introducing a new source of error. I will denote by £2/, the polygonal domain triangulated by 7/i and begin with an example of the effect of approximating Q by £2/?. 6 The proper term is affine, not linear; the mapping u \-> Ju is linear, and affine means "linear plus a constant." But it is a common abuse of terminology to refer to an affine transformation as linear.

94

Chapter 4. Piecewise polynomials and the finite element method

EXAMPLE 4.5. Consider the BVP

where £2 is the unit circle and f is chosen so that the solution is

/ will apply the finite element method with four increasingly finer triangulations; Figure 4.18 shows part of the first two meshes near the boundary. The meshes will be denoted by 7i, ?2, 7s, ?4 (7i the coarsest, ?4 the finest), the corresponding polygonal domains by £l\, ^2, ^3 > &4> dnd the corresponding finite element solutions by u \, «2, «3, "4- Since £2 is convex, £2* C ^2 holds, andu^ will be defined to be identically zero on£l\£ik. The error u — Uk then reduces to u — Uk = u on Q \ £2*. Piecewise linear finite elements yield the results shown in the following table:

k

1

2 3 4

Error on Q/t 1

3.433 • KT 1.877- KT1 9.630 • 1C-2 4.848- 1C-2

Error onQ\&k 1

1.927 • ID" 9.941 • ID"2

5.010- 10~2 2.510- JO" 2

Error on Q 3.937 • 10-1 2.124- 10"1 1.086- 10-1 5.460 • JO"2

Here the errors are measured in the energy norm; the error on Q^ is

and the errors on ^2 \ ^ and £2 are defined similarly. The reader should notice that the error on &k is decreasing by about a factor of two each time the mesh is refined. The error on £1 \ £2* shows the same pattern, and so does the total error.

Figure 4.18. The first (left) and second (right) meshes from Example 4.5. The boundary of£l is the dashed curve.

95

4.7. Isoparametric finite element methods

The above results are satisfactory in the sense that the error due to approximating £2 by £l[, does not change the rate at which the total error goes to zero. Suppose, though, that quadratic elements are used in hopes of obtaining a more accurate solution. Here are the corresponding results:

k

1

2 3 4

Error on Q/< 2

7.737 • 10~ 2.573 • 1(T2 8.597- 1(T3 2.179- 1(T3

Error onQ\Qk 1

1.927- KT 9.941 • 1(T2 5.010- 10~2 2.510- 10~2

Error on Q 2.076- 10-' 1.027- 10-' 5.049- 10~2 2.519 -10" 2

The error on £2k is smaller than it was in the case of linear elements, and it also decreases faster. However, the error onQ\£2k is not affected by the increased order of the elements. The improvement in going from linear to quadratic elements is therefore modest, and there would be almost no additional improvement in going to cubic elements. The preceding example shows that approximating a domain with a curved boundary by a polygonal domain makes it difficult to obtain a highly accurate solution, at least when a uniform mesh is used. There are at least two ways around this difficulty. One is to use a nonuniform mesh, with smaller elements near the boundary. This is illustrated in the following example. EXAMPLE 4.6. Figure 4.19 shows a nonuniform mesh defined on the unit circle £17 It has approximately the same number of triangles as the mesh Tifrom the previous example (245 versus 256). Using piecewise quadratic polynomials on this mesh leads to a finite element solution «2 with the following errors:

k 2

Error on Qk 1.722- 10~

2

Error on£2\Qk 2

3.930 - 1C"

Error on £1

4.291 • 10~2

As this example shows, concentrating the triangles near the boundary leads to a smaller total error for the same computational effort. The drawback to the method of the previous example is that it is more difficult to create a sequence of meshes that are properly refined near the boundary so as to attain the accuracy that would be possible for a polygonal domain. I will discuss nonuniform meshes further in Part IV, but now I will turn to the second method of treating curved boundaries. The isoparametric method allows elements with curved edges, so that a curved boundary can be better approximated. The meaning of the word isoparametric is that the elements are parametrized as images of a reference element, with the parametrization given by polynomials of the same degree as the shape functions themselves. 1 will now explain carefully how this works for quadratic elements, and later extend it to higher-order elements. 7

This mesh was created using the mesh generator described in [33].

96

Chapter 4. Piecewise polynomials and the finite element method

Figure 4.19. A nonuniform mesh on the unit circle.

Figure 4.20. A subregion u> with a curved edge (left), and a quadratic Lagrange triangle approximating co (right).

4.7.1

Isoparametric quadratic triangles

For convenience, it is usual to consider elements with only one curved edge. Figure 4.20 shows a subregion CD that could arise in creating a triangular mesh on a circle. If ordinary quadratic triangles are used, as in the above examples, then co would be approximated by the triangle shown on the right in Figure 4.20. To get a better approximation, the midpoint node nearest the boundary could be moved to the curve, as in Figure 4.2 1 . Of course, the six nodes in Figure 4.21 do not lie on a triangle, but, as 1 will now show, the reference triangle TR can be mapped (approximately) onto u> by a quadratic mapping

4.7. Isoparametric finite element methods

97

Figure 4.21. An isoparametric quadratic Lagrange triangle T approximating the subregion a>. The curved edge of the isoparametric triangle is lying right on top of the (dashed) curve of the boundary and cannot be distinguished at this scale. This mapping, which will also be denoted (x, y) — F(s,t)orz = F(u), is determined by 12 parameters: a\,..., «6, b\, • • • , ^6- These 12 parameters are uniquely determined by the condition that the six nodes,

from TR be mapped onto the corresponding six nodes on o>,

These conditions take the form

a system of 12 linear equations determining the 12 unknowns. The subregion a> is then approximated by T, the image of TR under F. For this example, T is shown in Figure 4.21, where it is essentially indistinguishable from CD. The shape functions on T are determined by the standard Lagrange basis functions on TR. This works just as it did in the previous section. The standard basis on TR will be denoted [y\ , . . . , ye}', it is defined by the conditions

The basis on T consists of 0 i , . . . , 06 defined by

98

Chapter 4. Piecewise polynomials and the finite element method

or

In the setting of Section 4.6 the mapping F was linear, so each 0/ was a polynomial of the same degree as y/; in fact, { 0 i , . . . , x\ and yi > y\- Show that, for any «i , «2> "3, "4> there is a unique bilinear polynomial p(x, y) such that

9. Show by example that bilinear functions on neighboring quadrilaterals can agree at the two common vertices and yet not agree on the edge determined by the two vertices, provided the quadrilaterals are not rectangles aligned with the coordinate axes. 10. Let the vertices of SR be numbered from 1 to 4 in the order (-1, —1), (1, —1), (1, 1), and (—1, 1). Show that the corresponding nodal basis functions for the space of bilinear functions on SR are given by (4. 1 6). 1 1 . Show that the basis functions 0, a\ + «2 = 1 , a\ (s\ J\) + 012(32,12) is mapped to ct\ (x\ , ~y}) + ot2(x2, J2). (b) Use the previous result to show that each 0, is linear on each edge of Q. (Hint: 0, is linear on an edge e if

whenever

4.8.

Exercises for Chapter 4

1 03

(c) Suppose two quadrilaterals Q\ and Q^ share an edge e, and suppose r\, r-i are shape functions on Q\, Q^ respectively, constructed by the method described in Section 4.5. Show that if r\ and r2 agree at the endpoints of e, then they agree on the entire edge e. 13. Let TR be the usual reference triangle, suppose y(s, t) is a polynomial on TR, and suppose TR is mapped onto a region T by a one-to-one mapping F, where F(s, t) — ( p ( s , t ) , q ( s , 0) and p and q are both polynomials. Define 0 on T by 0 (x , y) — y(s, f), where ( x , y ) — F(s, t). Assuming that the Jacobian J of F is nonsingular for each (s, t) e TR, prove that

has components that are rational functions of (s, t). 14. Let y\, yi, X3, given by (4.19), be the three linear basis functions on the reference triangle. Compute the integrals

and

15. Let y\,..., y^ be the six quadratic basis functions on the reference triangle. Find the formula for each y { ( s , t ) , i — I , . . . , 6. 16. Show that (4.28) and (4.29) imply that F{ is given by (4.30). 17. Suppose the function K satisfies 0 < &o < K(X, y) < k\ for all (x, >') e Q and for some constants ko, k\. Suppose further that the function b satisfies 0 < b(x, y) < b\ for all (x, y) e Q and for some constant b\. Consider the BVP

The weak form of this BVP was derived in Exercise 2.7.12. Suppose Galerkin's method is applied, with a basis {w\,wj,... ,wn} for the approximating subspace. Show that this leads to the system

where

are defined by

1 04

Chapter 4. Piecewise polynomials and the finite element method The matrix K and the vector F are the usual stiffness matrix and load vector, respectively. The matrix M is called the mass matrix.

18. Suppose £2 is apolygonal domain, TH is a triangulation of £2, and / belongs to L 2 (fi). If

is the best approximation to / from PA(1) in the L2(£2)-norm, what are the normal equations that determine the vector a of coefficients? (cf. the previous exercise)

Chapter 5

Convergence of the finite element method

The convergence theory of the Galerkin finite element method is fairly straightforward in outline, although the details can be quite complicated. I have already shown how the method produces the best approximation, in the energy norm, to the true solution of the given BVP. To prove that the approximations converge to the true solution as the mesh is refined requires understanding how well a given function can be approximated by piecewise polynomials. The purpose of this chapter is to discuss this approximation theory, without, however, going too far into detail or proving the theorems. Since the Galerkin method is directly tied to the energy norm, convergence in the energy norm is obtained if the true solution is regular enough. It is sometimes desirable to know the rate of convergence in other norms, particularly the L2-norm. After I present the basic theory, I will show how to extend the results from the energy norm to the L 2 -norm.

5.1

Approximating smooth functions by continuous piecewise linear functions

The purpose of this section is to discuss how well a function can be approximated by a continuous piecewise linear function. Before proceeding, I want to discuss the nature of the error bounds presented below. First of all, the theory states that the finite element method yields the best approximation to the true solution when the error is measured in the energy norm, which is related to the Sobolev norms. It is therefore reasonable to try to bound the error of approximation in terms of the L 2 - and //'-norms. Second, as the reader will notice below, the bounds given here are asymptotic, not absolute. This means that the bounds will not tell how small the error is when the solution is approximated on a particular mesh. Instead, the bounds show how the error decreases as the mesh is refined. These bounds can also be characterized as a priori error estimates, in that the bounds do not involve the computed solution—indeed, the bounds are given before any approximate solution is computed. An a priori, asymptotic error bound of this type is useful, but it leaves some unanswered questions, such as how fine the grid must be in order to attain a certain accuracy. In 105

106

Chapter 5. Convergence of the finite element method

Part IV, I discuss how to form a posteriori error estimates that use the computed solution to estimate the actual error in that computed solution. Since the theory presented below describes how the error decreases as the mesh is refined, it is not surprising that there are limitations on how the mesh is refined. The fundamental rule is that the triangles cannot be allowed to get arbitrarily "skinny."

5.1.1 The standard refinement of a triangulation Beginning with any triangulation of £2, a finer triangulation is formed by placing a new node at the midpoint of every edge of every triangle and joining these new nodes with new edges. This replaces each triangle in the initial triangulation with four smaller triangles, as in Figure 5.1. The resulting mesh is called the standard refinement of the original mesh. It is easy to show that each triangle in the refined mesh is similar to (that is, has the same angles as) its "parent" triangle in the original mesh (see Exercise 3). This property is important to the convergence theory, as I discuss below. Also, each triangle in the refined mesh is half the size of its parent triangle, so the mesh size of the refined mesh is half that of the original mesh. There are several other ways to refine a mesh. The standard refinement is the method of choice when the goal is a uniform refinement, that is, when all of the triangles in the mesh are to be refined. However, as I discuss in Part IV, it is often desirable to refine only some of the triangles in the mesh, in which case other methods have some advantages over the standard refinement.

5.1.2

Nondegenerate families of triangulations

One way to describe the shape of a triangle T is to compare the largest circle contained in T to the diameter of T. The diameter of a set S is defined to be

For a triangle T, diam(T) is simply the length of the longest side of T.

Figure 5.1. Standard refinement of a triangle.

5.1. Approximating smooth functions by continuous piecewise linear functions 107 For each triangle T, d? is defined by

The ratio dr/diam(T) is then a measure of how skinny the triangle T is. If this ratio is very small, then T is long and thin, whereas if the ratio is close to 1 /\/3 (the maximum possible value—see Exercise 1), then T is close to an isosceles triangle. Now consider a family of triangulations with an individual triangulation denoted Th, where h is the maximum diameter of any triangle in T/,. The family {Th} is called nondegenerate if there exists a constant p > 0 such that

Repeated application of the standard refinement procedure produces a nondegenerate family of meshes. The reader is asked for a proof of this in Exercise 4.

5.1.3

Approximation by piecewise linear functions

I begin by considering the use of continuous piecewise linear functions, so the approximating subspace in the finite element method is P^l) (or a subspace of /^(l)). The simplest way to produce an estimate on the smallest error in approximating u from P(h } is to compare the best approximation with the piecewise linear interpolant «/ of a:

The function M/ has the same nodal values as does u itself, which is why a/ is called the interpolant of M. If u/, is the best approximation to u from P^\ it follows that

Therefore, it suffices to bound the error in u / . The following theorem is proved in Chapter 4 of Brenner and Scott [13]. THEOREM 5.1. Suppose {Th} is a nondegenerate family of triangulations of a polygonal domain £2 C R2, and suppose u e H2(£l). Then there exists a constant C depending on Q and the value p from the definition of nondegenerate (but not on u or h) such that

and Here \u\Hi

is the seminorm

and uj e Ph

denotes the piecewise linear interpolant ofu.

108

Chapter 5. Convergence of the finite element method

I hope this theorem will strike the reader as reasonable. The energy norm measures the derivatives of the function. In order to estimate how different the derivatives of a can be from those of its linear interpolant, it is necessary to know how fast the derivatives of u can change. This information is provided by the size of the second derivatives of u (the second derivatives measure the rates of change of the first derivatives), and therefore \u \ # 2 ( Q, appears in the upper bounds. A similar result holds if V is a subspace of Hl(Q), such as HQ(&), instead of Hl(&) itself and Vh is the corresponding subspace of P^ \ The energy norm,

is bounded by a multiple of the Hl(Q) error, and so the above result provides an upper bound on the energy norm error in approximating u. In this context, the error \\u — w/ |U is said to be O(h), meaning bounded by a constant times h, as h goes to zero. In the next section, I will show that by using higher-degree polynomials, convergence rates of O(h2), O(/z3), and so forth can be obtained. First, though, I will give an example of piecewise linear approximation. EXAMPLE 5.2. This example illustrates the accuracy, in both the L2- and H1-norms, of piecewise linear interpolation for the function u(x, y) = x(\ — x) sin (ny). The domain is £2 — (0, 1) x (0, 1), the unit square, and the meshes comprise a sequence of regular triangulations of the type shown in Figures 4.5 and 4.9. The first mesh has a total of& triangles, each an isosceles right triangle with legs of length 1 /2 andh = \/2/2. Successive meshes are obtained by the standard refinement described earlier (the second mesh is the one shown in Figure 4.5). The results are as follows:

5.0000 • IP"1 2.5000 • IP"1 1.250Q.1Q-1 6.2500 • 10-2

5.6484 • IP"2 1.6022 • 10~2 4.1305-IP"3 1.0405 • 10~3

4.1361 • IP"1 2.2448 • IP"1 1.1450-IP'1 5.7536 • 10~2

The reader should notice that \\ u — u /1|L2 (Q) is decreasing approximately ash2 (that is, when h is divided by 2, the error is divided by approximately 4) and ||« — w/ ||//I(Q) is decreasing approximately as h (when h is divided by 2, so is \\u — «/ \\H[(&))-

5.2

Approximation by higher-order piecewise polynomials

The theory in the case of Lagrange triangles of degree d is similar to that described in the previous section. The main result is that increasing the degree of the piecewise polynomials increases the order of approximation in both the L 2 - and //'-norms, provided that the

5.2. Approximation by higher-order piecewise polynomials

109

function being approximated is smooth enough. The reader will recall that P^} is the space of continuous piecewise polynomials of degree d relative to a given mesh Th • The piecewise polynomial interpolant of degree d of a function u is

where

is the standard Lagrange basis for

THEOREM 5.3. Suppose {Th} is a nondegenerate family of triangulations of a polygonal domain Q c R2, and suppose u e Hd+^ (£2). Then there exists a constant C depending on £2 and the value pfrom the definition of nondegenerate (but not on u or h) such that

and Here |M|#/,, and a, Uh satisfy

and

The results of Section 3.2 imply that «/, satisfies

and

In particular, since the piecewise polynomial interpolant «/ of u belongs to V/,,

and

Assuming that Lagrange triangles of degree d are used, the approximation results of the previous section yield and

where C is a positive constant that is independent of u and h, and C" = Cfi/a. 1 now want to show that estimates (5.9) and (5.10) can be extended to the case of inhomogeneous Dirichlet conditions. To obtain the full rate of convergence using piecewise polynomials of degree d, the Dirichlet data must be smooth enough. It is assumed that there is a function G e Hd+[ (£2) such that G = g on PI , where g is the Dirichlet data, and that (5.6) is solved with Gh = G/, the interpolant of G. Then u = w + G, w/, = wh + G/, and (in either norm)

11 2

Chapter 5. Convergence of the finite element method

The bounds (5.9) and (5.10) apply to the term \\w - wh\\, since wh is the finite element solution of a variational problem of the same form as (5.5). Thus

Theorem 5.3 applies directly to the term ||G — G/1|, and thus

Therefore,

If G is chosen so that it is orthogonal to V in the Hd+] (£1) inner product,8 then, by the Cauchy-Schwarz inequality,

Since w and G are orthogonal,

and thus

This yields the estimate

In practice, G/, is not chosen to be G/ (since typically G, and hence G/, are unknown). Instead, G/, is defined to be the piecewise polynomial defined by the following nodal values:

However, any continuous piecewise polynomial interpolating g at the constrained nodes (including G/) yields the same computed solution uh as does Gh. To prove this, I assume that GJ,I} e P(hd) agrees with g at the constrained nodes, that w^ e V/, satisfies

and that u(hl) = w(^ + GJ^. I need to show that wj,0 = uh. 8 Any G e //'/+1 (Q) satisfying G = g on r\ can be replaced by G - VG, where DC is the orthogonal projection onto V of G in the //'/+l(£2)-norm. Then, since VG — 0 on PI, G — DC = g on PI, and G — VG is orthogonal to V by the definition of orthogonal projection.

5.3. Convergence in the energy norm

1 13

Let g ( l ) e RN" be the vector of nodal values of GJ^. Then

where G/, is the piecewise polynomial whose nodal values agree with g at the constrained nodes and are zero elsewhere, and g ( l ) e RNf is defined by g(k } = g^\ Then, writing [/(i) e R/V/ f or me vector of (free) nodal values of u(h * and similarly for W(l\ it follows thatt/ ( 1 ) = W ( I ) + £ ( l ) . Now, for any i = 1 , 2, . . . , N/, the load vector F ( l ) is defined by

Therefore, F ( l ) — F — Kg(l\ where F is the load vector corresponding to G/,, and thus

This shows that the computed finite element solution w/, is the same no matter which interpolant Gh is used, and therefore (5.11) holds. The following theorem summarizes the results of this section. THEOREM 5.5. Suppose £2 is a polygonal domain in R2 and let {Th} be a nondegenerate family of meshes on £2 consisting ofLagrange triangles of degree d. Assume K is defined on £2 and there exist constants ko, k\ such that 0 < ko < K < k\ on £1 Finally, assume that the solution u of (5.5) satisfies u e Hd+*(Q), and let UK be the finite element solution of the BVP relative to the mesh Th. Then there exist constants C, C', both independent ofu and h, such that

Chapter 5. Convergence of the finite element method

114

and The following example illustrates Theorem 5.5. EXAMPLE 5.6. Suppose £1 is the unit square, and consider the BVP

where K(X, y) = 1 + xy2 and f is chosen so that the exact solution is

Using linear Lagrange triangles on a sequence of regular meshes, the following errors are obtained: 5.0000-IP"1 2.5000 • IP"1 1.2500-1Q-1 6.2500 • 10-2

4.0757 • IP"1 2.2369 • IP"1 1.1441-10"1 5.7524 • 10~2

The function u and the meshes are the same as in Example 5.2, which examined the error in the piecewise linear interpolant u\. Comparing the results from these examples shows that \\u —uh \\Hi(Q) and \\u-uj ||//I(Q) are very similar. The following tables give the errors in the finite element solution using piecewise quadratic, cubic, and quartic polynomials. They can be compared with the interpolation errors from Example 5.4. Quadratic Lagrange triangles:

5.0000 • KT1 2.5000-IP" 1 1.2500-1Q- 1 6.2500-10- 2

1.2337 • IP"1 3.3035-IP" 2 8.4222-IP" 3 2.1165-10- 3

5.0000-IP' 1 2.5000-IP" 1 1.2500-1Q- 1 6.2500 • 10-2

2.1926-KT 2 2.7850 • 1(T3 3.4686-IP" 4 4.3184-1Q- 5

Cubic Lagrange triangles:

5.4. Convergence in the L2-norm

115

Quartic Lagrange triangles:

5.0000-1Q- 1 2.5000-10-' 1.2500-10-' 6.2500 • 10~2

2.9626-1Q- 3 1.9044-Kr 4 1.1961-1Q- 5 7.4744-1Q- 7

// is also of interest to examine the error in the energy norm defined by the coefficient K, since the basis of finite element Galerkin theory is that \\ u — w/, ||E is as small as possible. To confirm this, the following table compares (for the linear triangles) the energy norm error n to the same error inu\.

5.0000 • IP"1 2.5000 • 10-' 1.2500 • IP"1 6.2500 • 1(T2

4.3468 • IP"1 2.3953 • IP"1 1.2262-KT1 6.1672- 1(T2

4.2675 - 10"' 2.3781 • IP"1 1.2238-IP"1 6.1640 • 10~2

Although the differences are not large, the results show that uh does indeed have a smaller energy norm error than «/.

5.4

Convergence in the L2-norm

There is a standard trick, called a duality argument, for deriving an L2-estimate from an energy norm estimate. This argument requires that solutions of the BVP under consideration have the elliptic regularity property, namely, that the solution has two degrees more of smoothness (in the weak sense) than the right-hand side of the PDE. The elliptic regularity property is not difficult to understand. Consider a one-dimensional BVP of the form

The solution can be obtained directly by integrating twice:

From this formula and the fundamental theorem of calculus, it is obvious that if / is continuous, then u is twice continuously differentiable. It is not at all obvious that such a property would extend to BVPs in multiple dimensions, since solutions cannot be obtained by direct integration. However, if the

116

Chapter 5. Convergence of the finite element method

geometry of Q is not too complicated and if any coefficients appearing in the PDE are smooth enough, then elliptic regularity holds. The usual model problem,

will be used for illustration. For example, in two-dimensional problems, if / € L2(Q), K is smooth, and • either FI or F2 is empty (that is, the boundary conditions are either pure Dirichlet or pure Neumann), and • either dQ is smooth or Q is convex, then the solution u is guaranteed to belong to //2(£7). Moreover, there is a constant C such that Proofs can be found in Rauch [34] or, for the case of a nonsmooth 9£2, in Grisvard [23]. Elliptic regularity can be used to derive an L2-estimate on the error u — w/,, where u is the solution to the variational form of (5.12) and Uh is the piecewise linear finite element solution for a corresponding approximating subspace V/,. Here is the duality trick: Writing a(-, •) for the usual energy inner product for (5.12) and (•, •) for the L2 inner product, w e V is defined to be the solution to the variational problem

where V is the appropriate variational space (V = HQ (£2) for a Dirichlet problem or V — V for a Neumann problem, where V is defined as in Section 2.5). Since u — uh e L 2 (£2), the solution u; belongs to H2(£2). Then

Since the interpolant w{ belongs to V/,,

and which imply that

By the elliptic regularity assumption, w e H2(Q) and therefore, by the interpolation results given in Section 5.2, there is a constant C such that

5.4. Convergence in the L 2 -norm

11 7

It follows that By the elliptic regularity assumption, there is another constant C such that Combining ft and the two constants denoted above by C into a new constant, also denoted by C, yields

or Finally, applying the estimate derived in the previous section for \\u — «/j||//i(Q) yields (with a new value for the constant C). This should be compared with the estimate In the L 2 (£2)-norm, another factor of h is obtained; the error is O(h2) instead of O(h) in the energy or //' (£2)-norms. EXAMPLE 5.7. This is a continuation of Example 5.6. Here the errors in the L2-norm are recorded: Linear Lagrange triangles:

5.0000-10"' 2.5000-10-' 1.2500-10-' 6.2500-10-2

7.0613 • 10~2 2.2713 • 10~2 6.0681 • IP"3 1.5429-10-3

Quadratic Lagrange triangles: 5.0000-Kr 1 2.5000 • 1Q-1 1.2500-10-'" 6.2500 • 10~2

9.4421 • 10~3 1.1035-1Q- 3 1.3429-ICF^ 1.6663-KT 5

5.0000-10-' 2.5000-IP' 1 1.2500-1Q- 1 6.2500- 1(T2

1.1370-1Q- 3 6.7872-IP" 5 4.0669-lO" 6 2.4862 • KT7

Cubic Lagrange triangles:

Chapter 5. Convergence of the finite element method

118

Quartic Lagrange triangles:

5.0000. 10-1 1.2326.10-4 2.5000. 10-1 3.9821. 10-6 1.2500.10 -1 1.2552. 10-7 6.2500.10-2 3.9273. 10-9

The reader can verify that the expected asymptotic rates of convergence are observed. For example, in the quartic case, the L1-error should be O(h5), so reducing h by a factor of 2 should reduce the error by a factor of approximately 32. Here are the actual results: Decrease in 5.0000. 10-1 2.50000.10-1 30.954 1.25000.10-1 31.725 6.2500. 10-2 31.961

5.5

Variational crimes

The title of this section is a phrase coined by Strang [40] to describe violations of the variational framework, whose theory has been described in the preceding sections of this chapter. Two examples of variational crimes are the use of numerical integration (quadrature) and the use of isoparametric finite elements to approximate curved boundaries. When quadrature is used, the stiffiiess matrix K and the load vector F are not computed exactly, so the theory as presented above does not apply directly. On the other hand, when £2 is not polygonal, the finite element method solves a problem on an approximate domain £2/,. In this case also, the theory developed in the preceding sections does not apply. In this section I will briefly summarize extensions of the theory covering these variational crimes. I will use the model problem

to illustrate the ideas. The results described here can be extended to inhomogeneous boundary conditions and other PDEs.

5.5.1

Numerical integration

In assembling K and F, integrals of the form

5.5. Variational crimes

119

must be computed, where T is a triangle in the mesh and 0,, 4>j are basis functions that reduce to polynomials when restricted to T. These integrals may be difficult or impossible to compute exactly, depending on the form of K and /. To estimate the above integrals, a quadrature rule of the form

can be used. Here (jc|r), y(jT)), j — 1, 2, . . . , n, are the quadrature nodes on T and w(j \ j — 1 , 2, . . . , n, are the corresponding quadrature weights. Specific quadrature rules will be presented in Part II. For this discussion, the specific rules are not important; only the concept of degree of precision is needed to analyze the effect of quadrature on the finite element method. A quadrature rule has degree of precision p if it integrates polynomials of degree p or less exactly. Since the finite element method is based on piecewise polynomials, it is natural to classify quadrature rules by their degrees of precision. However, since the coefficient K and the forcing function / need not be polynomial, the integrals (5.14) may not be computed exactly regardless of how high the degree of precision of the quadrature rule. Some kind of analysis is therefore required to prove that K and F are computed accurately enough that convergence is still obtained. Furthermore, mere convergence is probably not acceptable; it would be desirable to compute the integrals accurately enough that the rate of convergence, as presented in the previous sections, is unchanged. The effect of quadrature is to replace the variational problem

by where a/, (-, •) and if, are defined by the quadrature rules (applied element by element) rather than by the usual integrals. There are then three functions to consider: the exact solution u of (5.13), the solution w/, of (5.15) (analyzed in the previous sections), and the solution uh of (5.16). By the triangle inequality,

If, for example, Lagrange triangles of degree d are used, then, by Theorem 5.5,

It would be desirable, then, that

also hold. It is easy to guarantee (5.17), although the proof is quite involved. The entries in the stiffness matrix K are assembled from the integrals

120

Chapter 5. Convergence of the finite element method

If the coefficient function K happens to be constant, then the integrands are polynomials of degree 2d — 2, and hence the integrals will be computed exactly by a quadrature rule having degree of precision 2d — 2. It turns out that such a quadrature rule, although not exact if K is nonconstant, nevertheless leads to a solution uh satisfying (5.17). The analysis, which I briefly outline below, assumes that the same quadrature rule is used for all integrals (those that contribute to K and those that contribute to F).

5.5.2

Outline of the analysis of the effect of quadrature

The proof of the above conclusion is based on the following two results: LEMMA 5.8. Let V be a Hilbert space, Vh a finite-dimensional subspace ofV, «(-,-) a symmetric, bounded, V-elliptic bilinear form, and t a bounded linear functional on V. Further, letah(-,-} be a symmetric, bounded, Vh-elliptic bilinear form andlh be abounded linear functional on Vh. Ifuf, is the unique solution to

and Uh is the unique solution to

then

Proof. Since

and Therefore,

This completes the proof. The preceding lemma is completely elementary, but has the following consequence. THEOREM 5.9.

and

be as in the preceding lemma. Suppose

5.5. Variational crimes

121

and there exists a constant C > 0 such that

Then

Proof. By the preceding lemma,

Applying the V^-ellipticity to bound the left-hand side below and the hypothesis to bound the right-hand side above yields

or

as desired. As discussed above, it is desired that

so p should be d in the preceding theorem. Therefore, it is first necessary to show that when a quadrature rule having degree of precision 2d — 2 is used, the approximate bilinear forms «/,(-, •) are uniformly Vh-elliptic:

This is straightforward if the quadrature weights are assumed to be positive, as is true for many common quadrature rules (cf. Sections 7.1 and 8.1). It is then necessary to show that a quadrature rule having degree of precision 2d - 2 results in and

The proofs of these results are quite involved and will not be given here; probably the best source is Ciarlet [16, Section 4.1].

5.5.3

Isoparametric finite elements

When Q, has a curved boundary and isoparametric finite elements are used, an approximate domain £2h is involved. This has several implications: Essential boundary conditions will not, in general, be satisfied exactly as they are in the case of a polygonal domain. The domain Q^ may extend outside of Q in places, and the problem functions K, / may not be defined on Qh\Q. The shape functions on elements with a curved boundary will not be polynomials, raising the question of whether a quadrature scheme based on integrating polynomials exactly will be adequate.

122

Chapter 5. Convergence of the finite element method

The issues raised in the previous paragraph can all be surmounted by an analysis that is very similar in outline to that given above. One begins by establishing bounds on the interpolation error for isoparametric elements. This is possible only if the elements in the meshes Th are not too distorted from triangles, which imposes certain constraints on the construction of the meshes (similar to the definition of a nondegenerate family of meshes). These constraints impose conditions on how far the nodes on the curved boundary can be from the corresponding nodes on the ordinary (nonisoparametric) triangle, and also on the placement of the interior nodes (if d > 2)—conditions which can be satisfied if the boundary of £2 is smooth or piecewise smooth. Next, an error bound analogous to Theorem 5.9 is established, the uniform V/jellipticity of the approximate bilinear form is verified, and finally, bounds analogous to (5.23) and (5.24) are established. All of this is carried out in detail for the case of quadratic Lagrange triangles in Ciarlet [16, Sections 4.3 and 4.4]. The result of all this analysis (see page 269 of [16]) is that the error using isoparametric finite elements goes to zero at the same rate as if ordinary Lagrange triangles were used on a polygonal domain. Moreover, this conclusion is valid when the same quadrature rule is used as for ordinary triangles (degree of precision 2d — 2).

5.6

Exercises for Chapter 5

1. Show that if T is an isosceles triangle, then

2. Suppose (jcj, y\), (x2, yi), (x^, ^3) are the vertices of a triangle T. The barycentric coordinates (a\, 0.2, oti,) of (x, y) e T are defined by

Let di denote the distance from (jc, y) to the side of T opposite (jc,-, >>/) and let h, denote the distance from (jc/, yt) to the opposite side of T. (a) Show that (Hint: i. First show that the line L(a^) defined by

(e*3 e (0, 1) fixed) is parallel to the edge of T joining (x\, y\) and te, ^2) ii. Find the distance between the line L(a^) and the line through (jci, >>]) and (*2, yi) and show that it equals ^3/13. (The proofs for d\ and di are then exactly analogous.))

5.6. Exercises for Chapter 5

123

(b) A circle is inscribed in T if and only if its center (a\, ct2, o^) satisfies d\ = d2 — d-\,. Using this condition, show by direct calculation that the center of the inscribed circle is given by

and the radius of the circle is

(c) Now let b\ be the length of T opposite (^3, ^3), b^ the length of the side opposite (jci, >'i), and £3 the length of the side opposite (x2, ^2). Show that the radius of the inscribed circle can be written

where |T| denotes the area of T. (d) Let dT be the diameter of the largest circle contained in a triangle T, as defined in Section 5.1.2. Prove that

for all triangles T. 3. Let T be any triangle and suppose T is refined to four triangles by joining the midpoints of the edges of T, as in Figure 5.1. Prove the four new triangles are each similar toT. 4. Suppose a sequence of triangulations To, T\, T2,... is formed by standard refinement: Each 71- is the refinement of Tk-\ • Prove that these meshes form a nondegenerate family: There exists p > 0 such that

(Hint: Use the preceding exercise.) 5. Let £2 be a polygonal domain in R2 and let To, T\,... be a sequence of triangulations of £2 formed by standard refinement. Let P(k]) be the space of continuous piecewise linear functions relative to 7*. Assume that u e H] (£2) (but u is not necessarily in

124

Chapter 5. Convergence of the finite element method

H2(Q)), and let u(k) be the best approximation to u from P(kl) in the //1(^)-norm. Prove that (Hint: The space // 2 (fi) is dense in Hl(&), so there is a sequence {u/} in H2(£2) converging to u in the Hl(Q)-norm. Let vj} be the best approximation to Vj from T^. Use the fact that, for each j,

Part II

Data Structures and Implementation

This page intentionally left blank

Chapter 6

The mesh data structure

This part of the book discusses the implementation of the finite element algorithm in computer programs. In order to make the discussion as straightforward as possible, this chapter and the next will focus on the implementation of linear Lagrange triangles for the model problem

where £2 is a polygonal domain and dQ = F] U ["Y After carefully developing programs to handle the above problem, 1 will extend them in Chapter 8 to handle higher-order Lagrange triangles on polygonal domains and then to handle curved boundaries using the isoparametric method. Finally, in Chapter 9, BVPs more general than (6.1) will be treated. In Section 6.1,1 discuss the important issues that must be resolved in order to write a program implementing the finite element method, and outline the overall strategy. Then, in Section 6.2, a data structure for storing the mesh is presented.

6.1 Programming the finite element method 6.1.1 Assembling the stiffness matrix The finite element method, applied to (6.1), produces a matrix-vector equation KU — F, whose solution vector U contains the nodal values of the approximate solution function. There are three important steps in applying the finite element method: • Creating a mesh on the computational domain £1. • Computing the stiffness matrix K and the load vector F. • Solving the linear system KU — F. 127

128

Chapter 6. The mesh data structure

In this part of the book, I will mostly concentrate on the second step. Section 6.3 gives examples of several different ways to generate a mesh on a given domain. Part IV presents algorithms for local refinement of meshes; these algorithms are intended to produce a mesh that is custom designed for a given problem. I defer the discussion of the solution of KU = F to Part III. For examples in this part of the book, the linear systems will be solved by the direct solver for sparse systems in MATLAB. Throughout the following discussion, Th is a triangulation of the polygonal domain Q and PA(1) is the space of continuous piecewise linear functions defined on Th- The stiffness matrix K corresponding to the BVP (6.1) is defined by

where {], 0 2 > • • • > Nf} is the basis for the approximating subspace Vh and

In the case of linear Lagrange triangles, the subspace V/, is the following subspace of P^ \ as described in Section 4.1.1:

The basis {Nf} consists of the standard basis functions for P^ } that correspond to the Nf free nodes in the mesh. The reader should recall the following requirement on the triangulation: Any point where F] and F2 meet must be a node in the mesh, and this node is considered to belong to F]. Most entries Ky of the stiffness matrix are zero, since the corresponding integrand K V0y • V0, is zero throughout £2. For those entries KJJ that are not zero, the support of KV(f>j • V0/ consists of a few triangles. One strategy for computing K is to loop over all i, j pairs, determine if KJJ is nonzero, and, if it is, compute the integral that defines it. If KIJ is nonzero and the support of K V0y • V0/ is

then

To compute these integrals, it is necessary to compute the basis functions / and 07 (or, actually, their gradients) on each of the triangles T r { , Tr2,..., Tfl. Algorithm 6.1 expresses this approach to computing K. This algorithm can be described as node-oriented, since it involves looping over the nodes in the mesh. The reader will notice that only the upper triangle of K is computed directly, since the matrix is known to be symmetric (Kji = K^).

6.1. Programming the finite element method

129

Initialize K to the zero matrix for for Determine if K is nonzero if Determine the triangles support of Set for

Compute Compute

and

forming the

on and add it to

Set

Algorithm 6.1. Node-oriented algorithm for computing the stiffness matrix K.

Figure 6.1. The support 0/013 in a certain mesh. The triangles are labeled in the left graph, while the free nodes are labeled in the right graph. One problem with Algorithm 6.1 is that the value of any given V, on any particular Tk will contribute to Kfj for several (usually three) values of j. For example, for the mesh illustrated in Figure 6.1, the value of V0!3 on T2o contributes to #13,12, #13,13, and #13,18 (and, by symmetry, #12.13, #18.13). Therefore, it must be computed repeatedly (at the cost of some inefficiency) or stored after it is computed (at the cost of some inconvenience). It would be preferable, if possible, to compute V0, just once on each triangle in its support, use its value, and then discard it. The simplest data structure describing a triangulation is the triangle-node list. This consists of two arrays: The node array contains the coordinates of the nodes, and the triangle array contains three indices for each triangle, identifying the nodes (from the nodes array) that are the vertices of the given triangle. When Algorithm 6.1 is executed, it is necessary to loop over the vertices of the triangles and to know, for a given vertex, which other vertices are adjacent to it. This implies storing the "connectivity" information of the mesh (that is, storing, for each vertex, the indices of the adjacent nodes). This connectivity information is contained in the triangle-node list, but only implicitly. It would be inefficient

130

Chapter 6. The mesh data structure

to search through the list of triangles and vertices to determine the connectivity of the vertices. Algorithm 6.1 therefore requires that both the triangle-node list and the connectivity information be stored explicitly. It turns out that by adopting a different strategy for computing K, both of the above problems can be circumvented: 0, on Tk need be computed only once, and the connectivity information need not be stored explicitly. The idea is to loop over the triangles in the mesh and, for each triangle, compute the contributions to all entries KJJ that are affected by the given triangle. This is actually quite easy to do. Given a triangle Tk, the only basis functions whose support has a nontrivial intersection with Tk are those corresponding to the vertices of 7^. There are at most three such basis functions (fewer if one or more vertices are constrained). If all three vertices of Tk are free and the corresponding basis functions are then the following entries of K are affected:

The contribution to KI ^ is

To be precise,

where "H " represents integrals of KV<j>ep • V4>tr/ over the other triangles that form its support. The integrals computed over Tk are often collected in a 3 x 3 matrix called the element stiffness matrix (over Tk):

This matrix need not be formed explicitly (except possibly as a programming convenience); rather, its entries are added to the corresponding entries of K. When computing the entries of the element stiffness matrix, it may be advantageous to compute the integrals by transforming to the reference triangle, as described in Section 4.6. The advantages of using a reference triangle will be discussed in Chapters 7 and 8. As always, the symmetry of A' should not be ignored. It is necessary to compute only six of the nine entries of the element matrix, namely, those in the upper triangle. If one of the three vertices of Tk is constrained, then Tk contributes to only four entries of K, while if two of the vertices are constrained, then Tk contributes to a single entry in K. It is possible that all three vertices of Tk can be constrained, but this could hold for only a few triangles in a given mesh, for example, those lying at the corner of a rectangle.

6.1. Programming the finite element method

131

Algorithm 6.2 incorporates the above ideas. The reader should recall that the vertices of

are Initialize k to the zero matrix for for for if and are both free Find the indices Compute

and

of

and

in the list of free nodes

and add it to

and to

Algorithm 6.2. Element-oriented algorithm for computing K. To implement this algorithm, it is necessary to know, for each triangle Tk, the nodes z , j — 1, 2, 3. This information is required by any conceivable scheme, since integrals over Tk must be computed, and is contained in the triangle-node list. In addition, it must be possible to determine if a given vertex z« is free or not. If it is free, its index in the list of all free nodes must be known. I have already established the following notation: The free nodes are enumerated 1 , 2, . . . , Nf and the vertices are enumerated \,2, . . . , Nv. Free node j is vertex z /,. . That is, I have established a mapping from j e {1, 2, . . . , N/} to /) e { 1 , 2 , . . . , Nv}. This mapping is necessarily one-to-one, so it has an inverse mapping defined by /?/ = j if and only if j e {1, 2, . . . , Nf} and i = f j . Except in the case that every node is free, the quantity /?, is not defined for some i e { 1 , 2, . . . , Nv}. For each node zn, it is necessary to store pn or a flag indicating that zn is constrained. I will present a convenient way to do this in the next section. For now I just point out that, given this information, the above algorithm is efficient and easy to implement. Since I will need it later, I will also define

Our partners will collect data and use cookies for ad personalization and measurement. Learn how we and our ad partner Google, collect and use data. Agree & close