376

Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

  • Upload
    others

  • View
    41

  • Download
    6

Embed Size (px)

Citation preview

Page 1: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 2: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Computational Partial Differential Equations

Using MATLAB®

Page 3: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND NONLINEAR SCIENCE SERIESSeries Editors Goong Chen and Thomas J. Bridges

Published Titles

Computing with hp-ADAPTIVE FINITE ELEMENTS, Volume 1, One and Two Dimensional Elliptic and Maxwell Problems, Leszek DemkowiczComputing with hp-ADAPTIVE FINITE ELEMENTS, Volume 2, Frontiers: Three Dimensional Elliptic and Maxwell Problems with Applications, Leszek Demkowicz, Jason Kurtz, David Pardo, Maciej Paszynski, Waldemar Rachowicz, and Adam ZdunekCRC Standard Curves and Surfaces with Mathematica®: Second Edition, David H. von SeggernExact Solutions and Invariant Subspaces of Nonlinear Partial Differential Equations in Mechanics and Physics, Victor A. Galaktionov and Sergey R. SvirshchevskiiGeometric Sturmian Theory of Nonlinear Parabolic Equations and Applications, Victor A. Galaktionov Introduction to Fuzzy Systems, Guanrong Chen and Trung Tat PhamIntroduction to non-Kerr Law Optical Solitons, Anjan Biswas and Swapan KonarIntroduction to Partial Differential Equations with MATLAB®, Matthew P. ColemanIntroduction to Quantum Control and Dynamics, Domenico D’AlessandroMathematical Methods in Physics and Engineering with Mathematica, Ferdinand F. CapMathematical Theory of Quantum Computation, Goong Chen and Zijian DiaoMathematics of Quantum Computation and Quantum Technology, Goong Chen, Louis Kauffman, and Samuel J. LomonacoMixed Boundary Value Problems, Dean G. DuffyMulti-Resolution Methods for Modeling and Control of Dynamical Systems, Puneet Singla and John L. Junkins Optimal Estimation of Dynamic Systems, John L. Crassidis and John L. JunkinsQuantum Computing Devices: Principles, Designs, and Analysis, Goong Chen, David A. Church, Berthold-Georg Englert, Carsten Henkel, Bernd Rohwedder, Marlan O. Scully, and M. Suhail ZubairyStochastic Partial Differential Equations, Pao-Liu Chow

Page 4: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Computational Partial Differential Equations

Using MATLAB®

CHAPMAN & HALL/CRC APPLIED MATHEMATICS

AND NONLINEAR SCIENCE SERIES

Jichun LiUniversity of Nevada

Las Vegas, NV, U.S.A.

Yi-Tung ChenUniversity of Nevada

Las Vegas, NV, U.S.A.

Page 5: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

MATLAB® and Simulink® are trademarks of the Math Works, Inc. and are 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® and Simulink® 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® and Simulink® software.

CRC PressTaylor & Francis Group6000 Broken Sound Parkway NW, Suite 300Boca Raton, FL 33487-2742

© 2008 by Taylor & Francis Group, LLCCRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government worksVersion Date: 20131121

International Standard Book Number-13: 978-1-4200-8905-9 (eBook - PDF)

This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmit-ted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe.

Visit the Taylor & Francis Web site athttp://www.taylorandfrancis.com

and the CRC Press Web site athttp://www.crcpress.com

Page 6: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Contents

Preface xi

Acknowledgments xiii

1 Brief Overview of Partial Differential Equations 11.1 The parabolic equations . . . . . . . . . . . . . . . . . . . . . 11.2 The wave equations . . . . . . . . . . . . . . . . . . . . . . . . 21.3 The elliptic equations . . . . . . . . . . . . . . . . . . . . . . 31.4 Differential equations in broader areas . . . . . . . . . . . . . 3

1.4.1 Electromagnetics . . . . . . . . . . . . . . . . . . . . . 31.4.2 Fluid mechanics . . . . . . . . . . . . . . . . . . . . . . 41.4.3 Ground water contamination . . . . . . . . . . . . . . 51.4.4 Petroleum reservoir simulation . . . . . . . . . . . . . 61.4.5 Finance modeling . . . . . . . . . . . . . . . . . . . . . 71.4.6 Image processing . . . . . . . . . . . . . . . . . . . . . 7

1.5 A quick review of numerical methods for PDEs . . . . . . . . 8

References 10

2 Finite Difference Methods for Parabolic Equations 132.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.2 Theoretical issues: stability, consistence, and convergence . . 152.3 1-D parabolic equations . . . . . . . . . . . . . . . . . . . . . 16

2.3.1 The θ-method . . . . . . . . . . . . . . . . . . . . . . . 162.3.2 Some extensions . . . . . . . . . . . . . . . . . . . . . 19

2.4 2-D and 3-D parabolic equations . . . . . . . . . . . . . . . . 232.4.1 Standard explicit and implicit methods . . . . . . . . . 232.4.2 The ADI methods for 2-D problems . . . . . . . . . . 252.4.3 The ADI methods for 3-D problems . . . . . . . . . . 28

2.5 Numerical examples with MATLAB codes . . . . . . . . . . . 302.6 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 332.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

References 36

v

Page 7: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

vi Computational Partial Differential Equations Using MATLAB

3 Finite Difference Methods for Hyperbolic Equations 393.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393.2 Some basic difference schemes . . . . . . . . . . . . . . . . . . 403.3 Dissipation and dispersion errors . . . . . . . . . . . . . . . . 423.4 Extensions to conservation laws . . . . . . . . . . . . . . . . . 443.5 The second-order hyperbolic PDEs . . . . . . . . . . . . . . . 453.6 Numerical examples with MATLAB codes . . . . . . . . . . . 493.7 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 523.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

References 54

4 Finite Difference Methods for Elliptic Equations 574.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574.2 Numerical solution of linear systems . . . . . . . . . . . . . . 59

4.2.1 Direct methods . . . . . . . . . . . . . . . . . . . . . . 594.2.2 Simple iterative methods . . . . . . . . . . . . . . . . . 614.2.3 Modern iterative methods . . . . . . . . . . . . . . . . 64

4.3 Error analysis with a maximum principle . . . . . . . . . . . . 664.4 Some extensions . . . . . . . . . . . . . . . . . . . . . . . . . 68

4.4.1 Mixed boundary conditions . . . . . . . . . . . . . . . 684.4.2 Self-adjoint problems . . . . . . . . . . . . . . . . . . . 694.4.3 A fourth-order scheme . . . . . . . . . . . . . . . . . . 70

4.5 Numerical examples with MATLAB codes . . . . . . . . . . . 734.6 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 754.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

References 78

5 High-Order Compact Difference Methods 795.1 One-dimensional problems . . . . . . . . . . . . . . . . . . . . 79

5.1.1 Spatial discretization . . . . . . . . . . . . . . . . . . . 795.1.2 Approximations of high-order derivatives . . . . . . . . 835.1.3 Temporal discretization . . . . . . . . . . . . . . . . . 925.1.4 Low-pass spatial filter . . . . . . . . . . . . . . . . . . 925.1.5 Numerical examples with MATLAB codes . . . . . . . 93

5.2 High-dimensional problems . . . . . . . . . . . . . . . . . . . 1105.2.1 Temporal discretization for 2-D problems . . . . . . . 1105.2.2 Stability analysis . . . . . . . . . . . . . . . . . . . . . 1125.2.3 Extensions to 3-D compact ADI schemes . . . . . . . . 1135.2.4 Numerical examples with MATLAB codes . . . . . . . 114

5.3 Other high-order compact schemes . . . . . . . . . . . . . . . 1225.3.1 One-dimensional problems . . . . . . . . . . . . . . . . 1225.3.2 Two-dimensional problems . . . . . . . . . . . . . . . . 124

5.4 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 127

Page 8: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Table of Contents vii

5.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

References 130

6 Finite Element Methods: Basic Theory 1336.1 Introduction to one-dimensional problems . . . . . . . . . . . 133

6.1.1 The second-order equation . . . . . . . . . . . . . . . . 1336.1.2 The fourth-order equation . . . . . . . . . . . . . . . . 136

6.2 Introduction to two-dimensional problems . . . . . . . . . . . 1406.2.1 The Poisson’s equation . . . . . . . . . . . . . . . . . . 1406.2.2 The biharmonic problem . . . . . . . . . . . . . . . . . 142

6.3 Abstract finite element theory . . . . . . . . . . . . . . . . . . 1436.3.1 Existence and uniqueness . . . . . . . . . . . . . . . . 1436.3.2 Stability and convergence . . . . . . . . . . . . . . . . 145

6.4 Examples of conforming finite element spaces . . . . . . . . . 1466.4.1 Triangular finite elements . . . . . . . . . . . . . . . . 1476.4.2 Rectangular finite elements . . . . . . . . . . . . . . . 149

6.5 Examples of nonconforming finite elements . . . . . . . . . . 1506.5.1 Nonconforming triangular elements . . . . . . . . . . . 1506.5.2 Nonconforming rectangular elements . . . . . . . . . . 151

6.6 Finite element interpolation theory . . . . . . . . . . . . . . . 1536.6.1 Sobolev spaces . . . . . . . . . . . . . . . . . . . . . . 1546.6.2 Interpolation theory . . . . . . . . . . . . . . . . . . . 155

6.7 Finite element analysis of elliptic problems . . . . . . . . . . . 1596.7.1 Analysis of conforming finite elements . . . . . . . . . 1596.7.2 Analysis of nonconforming finite elements . . . . . . . 161

6.8 Finite element analysis of time-dependent problems . . . . . . 1636.8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 1636.8.2 FEM for parabolic equations . . . . . . . . . . . . . . 164

6.9 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 1676.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

References 169

7 Finite Element Methods: Programming 1737.1 FEM mesh generation . . . . . . . . . . . . . . . . . . . . . . 1737.2 Forming FEM equations . . . . . . . . . . . . . . . . . . . . . 1787.3 Calculation of element matrices . . . . . . . . . . . . . . . . . 1797.4 Assembly and implementation of boundary conditions . . . . 1847.5 The MATLAB code for P1 element . . . . . . . . . . . . . . . 1857.6 The MATLAB code for the Q1 element . . . . . . . . . . . . 1887.7 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 1937.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

References 197

Page 9: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

viii Computational Partial Differential Equations Using MATLAB

8 Mixed Finite Element Methods 1998.1 An abstract formulation . . . . . . . . . . . . . . . . . . . . . 1998.2 Mixed methods for elliptic problems . . . . . . . . . . . . . . 203

8.2.1 The mixed variational formulation . . . . . . . . . . . 2038.2.2 The mixed finite element spaces . . . . . . . . . . . . . 2058.2.3 The error estimates . . . . . . . . . . . . . . . . . . . . 208

8.3 Mixed methods for the Stokes problem . . . . . . . . . . . . . 2118.3.1 The mixed variational formulation . . . . . . . . . . . 2118.3.2 Mixed finite element spaces . . . . . . . . . . . . . . . 212

8.4 An example MATLAB code for the Stokes problem . . . . . . 2178.5 Mixed methods for viscous incompressible flows . . . . . . . . 231

8.5.1 The steady Navier-Stokes problem . . . . . . . . . . . 2318.5.2 The unsteady Navier-Stokes problem . . . . . . . . . . 233

8.6 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 2348.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

References 237

9 Finite Element Methods for Electromagnetics 2419.1 Introduction to Maxwell’s equations . . . . . . . . . . . . . . 2419.2 The time-domain finite element method . . . . . . . . . . . . 243

9.2.1 The mixed method . . . . . . . . . . . . . . . . . . . . 2439.2.2 The standard Galerkin method . . . . . . . . . . . . . 2489.2.3 The discontinuous Galerkin method . . . . . . . . . . 251

9.3 The frequency-domain finite element method . . . . . . . . . 2569.3.1 The standard Galerkin method . . . . . . . . . . . . . 2569.3.2 The discontinuous Galerkin method . . . . . . . . . . 2579.3.3 The mixed DG method . . . . . . . . . . . . . . . . . 261

9.4 The Maxwell’s equations in dispersive media . . . . . . . . . . 2639.4.1 Isotropic cold plasma . . . . . . . . . . . . . . . . . . . 2649.4.2 Debye medium . . . . . . . . . . . . . . . . . . . . . . 2689.4.3 Lorentz medium . . . . . . . . . . . . . . . . . . . . . 2709.4.4 Double-negative metamaterials . . . . . . . . . . . . . 273

9.5 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 2819.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

References 283

10 Meshless Methods with Radial Basis Functions 28710.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28710.2 The radial basis functions . . . . . . . . . . . . . . . . . . . . 28810.3 The MFS-DRM . . . . . . . . . . . . . . . . . . . . . . . . . . 291

10.3.1 The fundamental solution of PDEs . . . . . . . . . . . 29110.3.2 The MFS for Laplace’s equation . . . . . . . . . . . . 29410.3.3 The MFS-DRM for elliptic equations . . . . . . . . . . 297

Page 10: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Table of Contents ix

10.3.4 Computing particular solutions using RBFs . . . . . . 30010.3.5 The RBF-MFS . . . . . . . . . . . . . . . . . . . . . . 30210.3.6 The MFS-DRM for the parabolic equations . . . . . . 302

10.4 Kansa’s method . . . . . . . . . . . . . . . . . . . . . . . . . . 30410.4.1 Kansa’s method for elliptic problems . . . . . . . . . . 30410.4.2 Kansa’s method for parabolic equations . . . . . . . . 30510.4.3 The Hermite-Birkhoff collocation method . . . . . . . 306

10.5 Numerical examples with MATLAB codes . . . . . . . . . . . 30810.5.1 Elliptic problems . . . . . . . . . . . . . . . . . . . . . 30810.5.2 Biharmonic problems . . . . . . . . . . . . . . . . . . . 315

10.6 Coupling RBF meshless methods with DDM . . . . . . . . . . 32210.6.1 Overlapping DDM . . . . . . . . . . . . . . . . . . . . 32310.6.2 Non-overlapping DDM . . . . . . . . . . . . . . . . . . 32410.6.3 One numerical example . . . . . . . . . . . . . . . . . 325

10.7 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 32710.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

References 329

11 Other Meshless Methods 33511.1 Construction of meshless shape functions . . . . . . . . . . . . 335

11.1.1 The smooth particle hydrodynamics method . . . . . . 33511.1.2 The moving least-square approximation . . . . . . . . 33711.1.3 The partition of unity method . . . . . . . . . . . . . . 338

11.2 The element-free Galerkin method . . . . . . . . . . . . . . . 34011.3 The meshless local Petrov-Galerkin method . . . . . . . . . . 34211.4 Bibliographical remarks . . . . . . . . . . . . . . . . . . . . . 34511.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345

References 346

Appendix A Answers to Selected Problems 349

Index 361

Page 11: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 12: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Preface

The purpose of this book is to provide a quick but solid introduction toadvanced numerical methods for solving various partial differential equations(PDEs) in sciences and engineering. The numerical methods covered in thisbook include not only the classic finite difference and finite element meth-ods, but also some recently developed meshless methods, high-order compactdifference methods, and finite element methods for Maxwell’s equations incomplex media.

This book is based on the material that we have taught in our numericalanalysis courses MAT 665/666 and MAT 765/766 at the University of NevadaLas Vegas since 2003. The emphasis of the text is on both mathematicaltheory and practical implementation of the numerical methods. We have triedto keep the mathematics accessible for a broad audience while still presentingthe results as rigorously as possible.

This book covers three types of numerical methods for PDEs: the finitedifference method, the finite element method, and the meshless method. InChapter 1, we provide a brief overview of some interesting PDEs coming fromdifferent areas and a short review of numerical methods for PDEs. Then weintroduce the finite difference methods for solving parabolic, hyperbolic, andelliptic equations in Chapters 2, 3, and 4, respectively. Chapter 5 presentsthe high-order compact difference method, which is quite popular for solvingtime-dependent wave propagation problems. Chapters 6 through 9 cover thefinite element method. In Chapter 6, fundamental finite element theory isintroduced, while in Chapter 7, basic finite element programming techniquesare presented. Then in Chapter 8, we extend the discussion to the mixed finiteelement method. Here both theoretical analysis and programming implemen-tation are introduced. In Chapter 9, we focus on some special finite elementmethods for solving Maxwell’s equations, where some newly developed algo-rithms and Maxwell’s equations in dispersive media are presented. Chapter 10is devoted to the radial basis function meshless methods developed in recentyears. Some Galerkin-type meshless methods are introduced in Chapter 11.

The book is intended to be an advanced textbook on numerical methodsapplied to diverse PDEs such as elliptic, parabolic, and hyperbolic equations.Each chapter includes about 10 exercises for readers to practice and enhancetheir understanding of the materials. This book supplies many MATLAB R©source codes, which hopefully will help readers better understand the pre-sented numerical methods. We want to emphasize that our goal is to providereaders with simple and clear implementations instead of sophisticated usages

xi

Page 13: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

of MATLAB functions. The skilled reader should be able to easily modify orimprove the codes to solve similar problems of his/her interest.

This book can be used for a two-semester graduate course that providesan introduction to numerical methods for partial differential equations. Thefirst semester can cover the elementary chapters such as Chapters 1 through5. This part can also be used at the undergraduate level as a one-semesterintroductory course on numerical methods or scientific computing. The restof the chapters are more advanced and can be used for the second semesteror a stand-alone advanced numerical analysis course.

For product information, please contact:The MathWorks, Inc.3 Apple Hill DriveNatick, MA 01760-2098 USATel: 508-647-7000Fax: 508-647-7001Email: [email protected]: www.mathworks.com

Page 14: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Acknowledgments

First, we would like to thank Professor Goong Chen for his kind support toaccept our book into this book series. We also want to thank Shashi Kumar,Karen Simon, and Bob Stern for their always kind help during the productionprocess. Then we have to thank the many students who suffered from ourinaccurate and incomplete lecture notes. Without their input the book wouldnot be as good. We are very grateful for the Mathematics Department’s kindsupport for our numerical analysis courses over the years, which made thisbook possible. This work has benefited greatly from many collaborationswith our colleagues over the years. Very special thanks from Jichun Li go toProfessor Qun Lin who introduced him to the finite element superconvergenceworld; to Professor Mary Wheeler who led him to the wonderful parallelcomputing and multidisciplinary research world; to Professors C.S. Chen andBenny Hon who enlightened him on the meshless method; and to Dr. MiguelVisbal who directed him to the compact difference method.

Last, but not least, we want to express our gratitude to our families fortheir support and understanding (why dads always hide at the office duringweekends) especially during the last months of writing.

Jichun LiYi-Tung Chen

Las Vegas, Nevada

xiii

Page 15: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 16: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

1

Brief Overview of Partial DifferentialEquations

Generally speaking, partial differential equations (PDEs) are equations con-taining some partial derivatives of an unknown function u with respect tospatial variables such as x = (x1, · · · , xd)′ ∈ Rd, d ≥ 1, and sometimes withrespect to time variable t.

It turns out that many problems can be modeled by PDEs from variousscience and engineering applications. Furthermore, most problems cannot besolved analytically, hence finding good approximate solutions using numericalmethods will be very helpful. Learning various numerical methods for solvingPDEs becomes more and more important for students majoring in scienceand engineering. These days we are immersed with many “computational”words such as “computational mathematics,” “computational physics,” “com-putational chemistry,” “computational biology,” “computational geosciences,”“computational fluid mechanics,” “computational electromagnetics,” etc. Inthis chapter, we first review some interesting PDEs to motivate our readers.Then we provide a very quick review of several popular numerical methodsfor solving differential equations.

1.1 The parabolic equations

The one-dimensional (1-D) differential equation

∂u

∂t= α2 ∂

2u

∂x2or ut = α2uxx, 0 < x < L, (1.1)

is a standard 1-D parabolic equation. This equation can be used to modelmany physical phenomena such as heat distribution in a rod, in which caseu(x, t) represents the temperature at point x and time t, and α2 is the thermaldiffusivity of the material. Hence (1.1) is also called heat/diffusion equation.Furthermore, if there is an additional source/sink along the rod, given byf(x, t), then we end up with an inhomogeneous heat equation

ut = α2uxx + f(x, t). (1.2)

1

Page 17: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

2 Computational Partial Differential Equations Using MATLAB

If the material property is not uniform along the rod (e.g., density or specificheat depends on the location x), then the coefficient α will be a function ofx. In the case that the thermal conductivity K depends on x, then the heatequation becomes

ut =∂

∂x(K(x)ux). (1.3)

Of course, to make the heat equation well posed, we must supply an initialcondition and proper boundary conditions at both ends of the rod. Similarly,2-D and 3-D heat equations can be derived, which are often written as

ut = α2(uxx + uyy + uzz) + f, (1.4)

andut = (aux)x + (buy)y + (cuz)z + f. (1.5)

1.2 The wave equations

The second-order hyperbolic differential equation

utt = c2uxx, 0 < x < L, (1.6)

is often called the wave equation. Equation (1.6) can be used to describe thevibration of a perfectly flexible string when it is nailed down at both ends,pulled, and let go. In that case, u denotes the displacement of the string.

If some vertical force f is imposed at point x, then we have the inhomoge-neous wave equation

utt = c2uxx + f(x, t). (1.7)

If the string has non-uniform density, then the coefficient c2 becomes a func-tion of x. To make the wave equation well posed, we need boundary conditionsat each end of the string and initial conditions for both u and ut at each pointof the string.

The two-dimensional wave equation

utt = c2(uxx + uyy) + f(x, y, t) (1.8)

can be used to describe the vibration of a membrane, where u(x, y, t) is theheight of the membrane at point (x, y) at time t, and f(x, y, t) represents theload effect.

The three-dimensional wave equation

utt = c2(uxx + uyy + uzz) + f(x, y, z, t) (1.9)

can be obtained when we model the propagation of waves in 3-D media. Ex-amples include the propagation of elastic waves in solids and electromagneticwaves.

Page 18: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Brief Overview of Partial Differential Equations 3

1.3 The elliptic equations

The second-order elliptic equations are obtained as the steady state solutions(as t → ∞) of the parabolic and wave equations. For example, a generalPoisson’s equation results in electrostatics

(εux)x + (εuy)y = −ρ, (1.10)

where the permittivity ε may vary with position and the given charge distri-bution ρ can vary with position too. When ε is a constant, we get the so-calledPoisson’s equation

uxx + uyy = −f(x, y). (1.11)

A further simplified form of Poisson’s equation with homogenous right-handside (i.e., f = 0) is the so-called Laplace’s equation

uxx + uyy = 0. (1.12)

Solutions of (1.10) are important in many fields of science, such as electro-magnetics, astronomy, heat transfer, and fluid mechanics, because they mayrepresent a temperature, electric or magnetic potential, and displacement foran elastic membrane. In three dimensions, we have the corresponding Pois-son’s and Laplace’s equations.

1.4 Differential equations in broader areas

In this section, we show readers a few more interesting PDEs from differentdisciplines.

1.4.1 Electromagnetics

With the advancement of modern technology, we live in a world surroundedby electromagnetic waves. For example, the TV programs we watch daily aregenerated and broadcast by waves propagating in the air; we warm our foodusing a microwave oven, which warms the food by generating microwaves;ultrasound wave propagation plays a very important role in medical applica-tions, such as hypothermia therapy, detection of tumors and bond density;we talk to our friends by mobile phones, whose signals are transported asultra-short wave pulses through optical fibers; we build “invisible planes” byabsorbing the detecting waves sent by enemies. Hence the study of electromag-netic waves interacting with different materials is an unavoidable importantissue in our daily life and in national defense.

Page 19: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

4 Computational Partial Differential Equations Using MATLAB

The fundamental equations in describing the electromagnetic phenomenaare the Maxwell’s equations:

Faraday’s law: ∇×E = −∂B∂t

,

Maxwell-Ampere law: ∇×H =∂D

∂t,

Gauss’s law: ∇ ·D = ρ,

Gauss’s law - magnetic: ∇ ·B = 0,

where E(x, t) and H(x, t) are the electric and magnetic fields, D(x, t) andB(x, t) are the corresponding electric and magnetic flux densities, ρ is theelectric charge density. Furthermore, D and B are related to E and Hthrough the constitutive relations

D = εE, B = μH,

where ε and μ denote the permittivity and permeability of the medium, re-spectively. Here we use the conventional notation for the curl operator ∇×and the divergence operator ∇·, i.e., for any vector φ = (φ1, φ2, φ3)′, we have

∇× φ = i(∂φ3

∂y− ∂φ2

∂z) − j(

∂φ3

∂x− ∂φ1

∂z) + k(

∂φ2

∂x− ∂φ1

∂y),

and ∇ · φ = ∂φ1∂x + ∂φ2

∂y + ∂φ3∂z .

For more detailed discussions on Maxwell’s equations in electromagnetics,readers can consult books by Chew [7] and Kong [17], and references citedtherein.

1.4.2 Fluid mechanics

In modeling fluid flow, we will come across the Navier-Stokes (N-S) equations.Consider laminar flows of viscous, incompressible fluids; the two-dimensionalN-S equations in dimensionless form are given by:

Momentum equations:

∂u

∂t+∂p

∂x=

1Re

(∂2u

∂x2+∂2u

∂y2) − ∂u2

∂x− ∂uv

∂y+ gx,

∂v

∂t+∂p

∂y=

1Re

(∂2v

∂x2+∂2v

∂y2) − ∂uv

∂x− ∂v2

∂y+ gy,

Continuity equation:∂u

∂x+∂v

∂y= 0,

where Re is the dimensionless Reynolds number, gx and gy denote the bodyforces, u and v are the velocity fields in the x- and y-directions, respectively,and p is the pressure.

Page 20: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Brief Overview of Partial Differential Equations 5

In the three-dimensional case, the N-S equations are given as follows.Momentum equations:

∂u

∂t+∂p

∂x=

1Re

(∂2u

∂x2+∂2u

∂y2+∂2u

∂z2) − ∂u2

∂x− ∂uv

∂y− ∂uw

∂z+ gx,

∂v

∂t+∂p

∂y=

1Re

(∂2v

∂x2+∂2v

∂y2+∂2v

∂z2) − ∂uv

∂x− ∂v2

∂y− ∂vw

∂z+ gy,

∂w

∂t+∂p

∂z=

1Re

(∂2w

∂x2+∂2w

∂y2+∂2w

∂z2) − ∂uw

∂x− ∂vw

∂y− ∂w2

∂z+ gz.

Continuity equation:∂u

∂x+∂v

∂y+∂w

∂z= 0.

Here w denotes the velocity component in the z-direction, and gz the z-component of the body forces.

1.4.3 Ground water contamination

Ground water contamination and soil pollution have been recognized as impor-tant environmental problems over the past three decades. Very often, groundwater is an important pathway for wastes found below the land subsurface.Contaminants leak from the waste, move forward through the unsaturatedzone to the water table, and then migrate in the saturated ground water sys-tem. The contaminants may discharge ultimately to well water or surfacewater, which threaten our living environments. Hence better understandingof ground water flow and contaminant transport are essential to the nationaland global economies, people’s health and safety, and billions of dollars forfuture environmental remediation and crisis management.

The governing equations for ground water flow and contaminant transportcan be classified into two big categories: saturated and unsaturated.

The saturated ground water flow in three dimensions can be modeled bythe equation

Ss∂h

∂t=

∂x(Kx

∂h

∂x) +

∂y(Ky

∂h

∂y) +

∂z(Kz

∂h

∂z) +Q,

where h is the water head, Kx,Ky and Kz denote the hydraulic conductivityin the x-, y-, and z-directions, respectively. Ss is the specific storage, and Qis a source or sink term.

In an unsaturated zone, the ground water flow is governed by the equation

c(ψ)∂ψ

∂t=

∂x(Kx(ψ)

∂ψ

∂x) +

∂y(Ky(ψ)

∂ψ

∂y) +

∂z(Kz(ψ)

∂ψ

∂z) +Q, (1.13)

where we denote ψ the pressure head, Kx(ψ),Ky(ψ) and Kz(ψ) the unsatu-rated hydraulic conductivity in the x-, y-, and z-directions, respectively, c(ψ)

Page 21: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

6 Computational Partial Differential Equations Using MATLAB

is the specific moisture capacity, and Q is a source or sink term. Equation(1.13) is the multidimensional form of the well-known Richards equation.

The contaminant transport equation in an unsaturated zone is given by

∂t(θwRC) =

3∑

i,j=1

∂xi(θwDij

∂C

∂xj) −

3∑

i=1

∂xi(viC) + qs, (1.14)

where both the moisture content θw and the retardation factor R are functionsof time, and Dij is the dispersion coefficient. We use qs to describe theaddition or removal of the contaminant due to chemical and/or biologicalreactions. The velocity vi is related to the pressure head by Darcy’s law:

vx = −Kx(ψ)∂ψ

∂x, vy = −Ky(ψ)

∂ψ

∂y, vz = −Kz(ψ)

∂ψ

∂z.

While the transport in a saturated zone is the same as (1.14) except thatθw is replaced by the porosity θ, which is the fraction of a representativeelementary volume for the fluid. In this case the porous medium reaches itsfull saturation, which represents the fraction of the void volume filled by thisphase in a porous medium.

More details on ground water flow and contaminant transport modeling canbe found in books such as [25, 26].

1.4.4 Petroleum reservoir simulation

A petroleum reservoir is a porous medium which contains hydrocarbons. Sim-ulation of petroleum reservoirs helps us in predicting the performance of areservoir and optimizing the oil recovery. The so-called two-phase immiscibleflow is used to model the simultaneous flow of two fluid phases such as waterand oil in a porous medium. We assume that the two phases are immisci-ble and there is no mass transfer between them. Hence we have the massconservation for each phase, which is given by

∂(φραSα)∂t

+ ∇ · (ραuα) = qα, α = w, o,

where w and o denote the water phase and oil phase, respectively. Here wedenote φ the porosity of the porous medium, ρα the density of each phase, qαthe mass flow rate, and Sα the saturation. The Darcy velocity uα is describedby Darcy’s law

uα = − 1μαkα(∇pα − ραg∇z), α = w, o,

where kα is the effective permeability, pα is the pressure, μα is the viscosityfor each phase α, g is the magnitude of the gravitation acceleration, z is the

Page 22: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Brief Overview of Partial Differential Equations 7

depth of the reservoir, and ∇z = (0, 0, 1)′. Note that both phases occupy thewhole void space, hence we have Sw + So = 1.

Thorough discussions on reservoir simulation can be found in books suchas [13, 9].

1.4.5 Finance modeling

The celebrated Black-Scholes differential equation is

∂u

∂t+

12σ2S2 ∂

2u

∂S2+ rS

∂u

∂S− ru = 0. (1.15)

Here u(S(t), t) denotes the price of an option on a stock, S(t) is the priceof the stock at time t, σ is the volatility of the stock, and r is the risk-freeinterest rate.

Note that (1.15) is a backward parabolic equation, which needs a finalcondition at time T . For a vanilla European call, we have the condition

u(S, T ) = max{S −X, 0},while for a put option, we have

u(S, T ) = max{X − S, 0},where X is the exercise price at the expiration date T . We want to remarkthat the call option means the right to buy the stock, while the put optiongives the right to sell the stock.

More details on mathematical finance can be found in books such as [11, 16].

1.4.6 Image processing

In recent years, PDEs have become popular and useful tools for image denois-ing, image segmentation, and image restoration. Such PDE-based methodol-ogy has been successfully applied to many problems in image processing andcomputer vision. Examples include image denoising, segmentation of texturesand remotely sensed data, object detection, optical flow, stereo, and enhanc-ing textures such as fingerprints, image sharpening, and target tracking.

For example, the homogeneous linear diffusion equation

ut = �u ≡ ∂2u

∂x2+∂2u

∂y2(1.16)

can be used to reduce noise, where u denotes the image value. But this simplemodel can blur important features such as edges. Hence the inhomogeneouslinear diffusion

ut = div(g(|∇u0|2)∇u) (1.17)

Page 23: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

8 Computational Partial Differential Equations Using MATLAB

was proposed, where u0 is a given image, g : R+ → R+ is a decreasingfunction with g(0) = 1, lims→∞ g(s) = 0 and g(s) is smooth, e.g., g(s2) =(1 + s2

λ2 )−1, λ > 0 is a constant. Using the model (1.17), edges remain betterlocalized and their blurring is reduced. But for large t the filtered imagereveals some artifacts which reflect the differential structure of the initialimage. To reduce the artifacts of inhomogeneous linear diffusion filtering, afeedback can be introduced in the process by adapting the diffusivity g to thegradient of the actual image u(x, t), which leads to the nonlinear isotropicdiffusion model

ut = div(g(|∇u|2)∇u). (1.18)

Model (1.18) can increase the edge localization and reduce the blurring atedges, but the absolute contrast at edges becomes smaller. To overcome thisshortcoming, the orthonormal system of eigenvectors v1 and v2 of the diffu-sion tensor D can be constructed such that v1 is parallel to ∇uσ, and v2 isperpendicular to ∇uσ. If we want to smooth the image along the edge insteadof across the edge, we can choose the eigenvalues λ1 and λ2 as

λ1 = g(|∇uσ|2), λ2 = 1,

which creates fairly realistic segments.To circumvent the stopping time problem caused by the diffusion filters with

a constant steady state, an additional reaction term can be added to keep thesteady-state solution close to the original image, which gives us another model

ut = div(g(|∇u|2)∇u) + β(u0 − u), β > 0.

For more discussions on PDEs in image processing, readers can consultbooks such as [1, 4, 19].

1.5 A quick review of numerical methods for PDEs

Due to the ubiquitousness of partial differential equations, there are manydifferent numerical methods for solving them. Generally speaking, we canclassify the numerical methods into six big categories: finite difference, spec-tral method, finite element, finite volume, boundary element, and meshless ormeshfree methods.

The finite difference method seems to be the easiest understandable tech-nique to solve a differential equation. The basic idea is to use finite differencesto approximate those differentials in the PDEs. Due to its simplicity, the dif-ference method is often the first choice for those who are interested in numer-ical solutions of PDEs. One disadvantage of this method is that it becomes

Page 24: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Brief Overview of Partial Differential Equations 9

quite complex when solving PDEs on irregular domains. Another disadvan-tage is that it is not easy to carry out the mathematical analysis (such assolvability, stability, and convergence) for the difference methods especiallyfor PDEs with variable coefficients, and nonlinear PDEs. Considering thatthe finite difference method serves as a basis for other numerical methods, wewill cover it in more detail in future chapters.

Spectral methods are powerful technologies for solving PDEs if the physicaldomain is simple and the solution is smooth. Early literature on spectralmethods are the short book by Gottlieb and Orszag [13] and the monographby Canuto, Hussaini, Quarteroni and Zang [3]. More recent advances canbe found in books by Fornberg [10], Trefethen [23], Tang and Shen [21], andHesthaven et al. [14]. Due to our lack of training and experience in this area,we will not cover the spectral methods in this book. Interested readers canconsult the above books for more details.

The finite element method is arguably the most popular method for solvingvarious PDEs. Compared to other methods, it has well-established mathe-matical theory for various PDEs and is a good choice for solving PDEs overcomplex domains (like cars and airplanes). The finite element method worksby rewriting the governing PDE into an equivalent variational problem, mesh-ing the modeled domain into smaller elements and looking for approximatesolutions at the mesh nodes when using a linear basis function over each ele-ment. But the implementation of the finite element method may be the mostcomplicated compared to other numerical methods. Due to its popularity,there are many commercial finite element packages and some free packagestoo. We will discuss both the mathematical theory and implementation ofthe finite element method in later chapters.

The boundary element method is used to solve those PDEs which can beformulated as integral equations. The boundary element method attemptsto use the given boundary conditions to fit boundary values into the integralequation, rather than values throughout the space defined by the PDE. Con-ceptually, the boundary element method can be thought of as a finite elementmethod over the modeled surface (i.e., meshing over the surface) instead ofover the modeled physical domain [15]. Hence the boundary element methodis often more efficient than other methods in terms of computational resourcesfor problems when the surface-to-volume ratio is small. However, boundaryelement formulations typically yield fully populated matrices, which makesthe storage requirements and computational time increase in the square or-der of the problem size. While matrices from finite element methods areoften sparse and banded, the storage requirements only grow linearly withthe problem size. Therefore, for many problems boundary element methodsare significantly less efficient than those volume-based methods such as fi-nite element methods. Another problem for the boundary element methodis that not many problems, such as nonlinear problems, can be written asintegral equations, which restricts the applicability of the boundary elementmethod. For detailed mathematical theory on the boundary element method,

Page 25: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

10 Computational Partial Differential Equations Using MATLAB

the reader can consult books such as [6, 8] and references cited therein. Forengineering applications and implementation, details can be found in books[2, 20] and references cited therein.

The finite volume method is another method for solving PDEs. This methodis very popular in computational fluid dynamics. The basic idea of the finitevolume method is to integrate the differential equation over a finite-sized con-trol volume surrounding each nodal point on a mesh, then changing the volumeintegrals (those involving the divergence term) to surface integrals which canbe evaluated as fluxes at the surfaces of each finite volume. Hence the finitevolume method is conservative locally on each volume. Another advantage ofthe finite volume method is that it can be easily used for irregularly shapeddomains. Detailed discussions about the finite volume method can be foundin books such as [18, 24] and references cited therein.

The meshless or meshfree method is a more recently developed techniquefor solving PDEs. The mesh-based methods (the finite element, boundaryelement and finite volume methods) share the drawbacks such as the tediousmeshing and re-meshing in crack propagation problem, the melting of a solidor the freezing process, large deformations, etc. The meshless method aimsto overcome those drawbacks by getting rid of meshing or re-meshing theentire modeled domain and only adding or deleting nodes, instead. The initialidea dates back to the smooth partical hydrodynamics method developed byGingold and Monaghan in 1977 [12] for modeling astrophysical phenomena.Since the 1990’s, the research into meshless methods has become very activeand many meshfree methods have been developed: e.g., Element Free GalerkinMethod; Reproducing Kernel Particle Method; Partition of Unity Method;hp-Cloud Method; Radial Basis Function Method; Meshless Local Petrov-Galerkin method, etc. We will introduce them in more detail in later chapters.

References

[1] G. Aubert and P. Kornprobst. Mathematical Problems in Image Pro-cessing: Partial Differential Equations and the Calculus of Variations.Springer, New York, NY, 2nd edition, 2006.

[2] C. A. Brebbia and L. C. Wrobel. Boundary Element Techniques: Theoryand Applications in Engineering. WIT Press, Southampton, UK, 2ndedition, 1996.

[3] C. Canuto, M.Y. Hussaini, A. Quarteroni and T.A. Zang. Spectral Meth-ods in Fluid Dynamics. Springer-Verlag, Berlin, 1988.

[4] T. Chan and J. Shen. Image Processing and Analysis: Variational, PDE,Wavelet, and Stochastic Methods. SIAM, Philadelphia, PA, 2005.

Page 26: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Brief Overview of Partial Differential Equations 11

[5] Z. Chen, G. Huan and Y. Ma. Computational Methods for MultiphaseFlows in Porous Media. SIAM, Philadelphia, PA, 2006.

[6] G. Chen and J. Zhou. Boundary Element Methods. Academic Press,New York, NY, 1992.

[7] W.C. Chew. Waves and Fields in Inhomogenous Media. Wiley-IEEEPress, New York, NY, 1999.

[8] D. Colton and R. Kress. Integral Equation Methods in Scattering Theory.John Wiley and Sons, New York, NY, 1983.

[9] R.E. Ewing (ed.). The Mathematics of Reservoir Simulation. SIAM,Philadelphia, PA, 1987.

[10] B. Fornberg. A Practical Guide to Pseudospectral Methods. CambridgeUniversity Press, Cambridge, UK, 1996.

[11] J.-P. Fouque, G. Papanicolaou and K.R. Sircar. Derivatives in FinancialMarkets with Stochastic Volatility. Cambridge University Press, Cam-bridge, UK, 2000.

[12] R.A. Gingold and J.J. Monaghan. Smoothed particle hydrodynamics:theory and application to non-spherical stars. Mon. Not. Roy. Astron.Soc., 181:375–389, 1977.

[13] D. Gottlieb and S.A. Orszag. Numerical Analysis of Spectral Methods:Theory and Applications. SIAM, Philadelphia, PA, 1977.

[14] J.S. Hesthaven, S. Gottlieb and D. Gottlieb. Spectral Methods for Time-Dependent Problems. Cambridge University Press, Cambridge, UK,2007.

[15] C. Johnson. Numerical Solution of Partial Differential Equations by theFinite Element Method. Cambridge University Press, Cambridge, UK,1987.

[16] I. Karatzas and S.E. Shreve. Methods of Mathematical Finance.Springer, New York, NY, 1998.

[17] J.A. Kong. Electromagnetic Wave Theory. Wiley-Interscience, NewYork, NY, 1990.

[18] R.J. LeVeque. Finite Volume Methods for Hyperbolic Problems. Cam-bridge University Press, Cambridge, UK, 2002.

[19] S.J. Osher and R.P. Fedkiw. Level Set Methods and Dynamic ImplicitSurfaces. Springer, New York, NY, 2002.

[20] C. Pozrikidis. A Practical Guide to Boundary Element Methods with theSoftware Library BEMLIB. CRC Press, Boca Raton, FL, 2002.

Page 27: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

12 Computational Partial Differential Equations Using MATLAB

[21] J. Shen and T. Tang. Spectral and High-Order Methods with Applica-tions. Science Press, Beijing, 2007.

[22] J.C. Tannehill, D.A. Anderson and R.H. Pletcher. Computational FluidMechanics and Heat Transfer. Taylor & Francis, Philadelphia, PA, 2ndedition, 1997.

[23] L.N. Trefethen. Spectral Methods in MATLAB. SIAM, Philadelphia,PA, 2000.

[24] H. Versteeg and W. Malalasekra. An Introduction to ComputationalFluid Dynamics: The Finite Volume Method. Prentice Hall, Upper Sad-dle River, NJ, 2nd edition, 2007.

[25] D. Zhang. Stochastic Methods for Flow in Porous Media: Coping withUncertainties. Academic Press, New York, NY, 2001.

[26] C. Zheng. Applied Contaminant Transport Modeling. Wiley-Interscience,New York, NY, 2nd edition, 2002.

Page 28: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

2

Finite Difference Methods for ParabolicEquations

The finite difference method (FDM) seems to be the simplest approach for thenumerical solution of PDEs. It proceeds by replacing those derivatives in thegoverning equations by finite differences. In this chapter, we will introducevarious difference methods for parabolic equations. In Sec. 2.1, we presentboth the explicit and implicit schemes for a simple heat equation. Thenwe introduce some important concepts (such as stability, consistence, andconvergence) used in analyzing finite difference methods in Sec. 2.2. Then inSec. 2.3, we demonstrate a few examples for using those concepts. In Sec. 2.4,we extend the discussion to two-dimensional and three-dimensional parabolicequations. Here we cover the standard difference methods and the AlternateDirection Implicit (ADI) method. Finally, in Sec. 2.5, we present a MATLABcode to show readers how to solve a parabolic equation.

2.1 Introduction

We start with a simple heat equation model: find u(x, t) such that

ut = uxx, ∀ (t, x) ∈ (0, tF ) × (0, 1), (2.1)u(0, t) = u(1, t) = 0, ∀ t ∈ (0, tF ) (2.2)u(x, 0) = u0(x), ∀ x ∈ [0, 1], (2.3)

where tF denotes the terminal time for the model. Here without loss ofgenerality, we assume that the spatial domain is [0, 1].

To solve the problem (2.1)–(2.3) by FDM, we first divide the physical do-main (0, tF ) × (0, 1) by N × J uniform grid points

tn = n�t,�t =tFN,n = 0, 1, · · · , N,

xj = j�x,�x =1J, j = 0, 1, · · · , J.

We denote the approximate solution unj ≈ u(xj , tn) at an arbitrary point(xj , tn). To obtain a finite difference scheme, we need to approximate the

13

Page 29: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

14 Computational Partial Differential Equations Using MATLAB

derivatives in (2.1) by some finite differences. Below we demonstrate twosimple finite difference schemes for solving (2.1)-(2.3).

Example 2.1(Explicit scheme)

Substituting

ut(xj , tn) ≈ (un+1j − unj )/�t,

uxx(xj , tn) ≈ (unj+1 − 2unj + unj−1)/(�x)2,into (2.1), we obtain the explicit scheme for (2.1):

un+1j = unj + μ(unj+1 − 2unj + unj−1), 1 ≤ j ≤ J − 1, 0 ≤ n ≤ N − 1, (2.4)

where we denoteμ =

�t(�x)2 . (2.5)

The boundary condition (2.2) can be approximated directly as

un0 = unJ = 0, 0 ≤ n ≤ N − 1,

and the initial condition (2.3) can be approximated as

u0j = u0(j�x), 0 ≤ j ≤ J. (2.6)

Note that with the scheme (2.4), the approximate solution un+1j at any

interior points can be obtained by a simple marching in time.

Example 2.2(Implicit scheme)

Similarly, by substituting

ut(xj , tn) ≈ (unj − un−1j )/�t,

uxx(xj , tn) ≈ (unj+1 − 2unj + unj−1)/(�x)2,into (2.1), another difference scheme for (2.1) can be constructed as:

unj − un−1j

�t =unj+1 − 2unj + unj−1

(�x)2 , 1 ≤ j ≤ J − 1, 1 ≤ n ≤ N. (2.7)

In which case, we obtain an implicit scheme

−μunj−1 + (1 + 2μ)unj − μunj+1 = un−1j , 1 ≤ j ≤ J − 1. (2.8)

Note that in this case, we have to solve a linear system at each time stepin order to obtain the approximate solutions unj at all interior points. Thatis why the scheme (2.8) is called implicit in order to distinguish it from theexplicit scheme (2.4).

Page 30: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 15

2.2 Theoretical issues: stability, consistence, and con-vergence

From the previous section, we see that constructing a finite difference schemeseems quite simple, but how do we know which scheme is better and howdo we compare different schemes? To answer these questions, we need tointroduce some important concepts in FDM analysis.

DEFINITION 2.1 (Truncation error)The truncation error of the scheme (2.4) is defined as

TE(x, t) =Dt

+u(x, t)�t − Dx

+Dx−u(x, t)

(�x)2 ,

where we denote the backward and forward difference operators Dx− and Dx+

in variable x as follows:

Dx−v(x, t) = v(x, t) − v(x−�x, t),

Dx+v(x, t) = v(x + �x, t) − v(x, t).

Similarly, we can define the forward difference operator Dt+ in variable t as

Dt+v(x, t) = v(x, t + �t) − v(x, t).

DEFINITION 2.2 (Consistence)If TE(x, t) → 0 as �t,�x→ 0 for any (t, x) ∈ (0, tF )× (0, 1), then we say

that the scheme is consistent with the differential equation (2.1).

DEFINITION 2.3 (Convergence)If for any point (t, x) ∈ (0, tF ) × (0, 1),

xj → x, tn → t implies unj → u(x, t),

i.e., the numerical solution at node (xj , tn) approximates the exact solutionu(x, t) as (xj , tn) gets close to the point (x, t), then we say that the scheme isconvergent.

DEFINITION 2.4 (Order of accuracy)If for a sufficiently smooth solution u,

TE(x, t) ≤ C[(�t)p + (�x)q], as �t,�x→ 0,

where p and q are the largest possible integers, then we say that the schemehas pth order of accuracy in �t and qth order of accuracy in �x.

Page 31: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

16 Computational Partial Differential Equations Using MATLAB

DEFINITION 2.5 (Well-posedness)A partial differential equation (PDE) is well-posed if the solution of the

PDE exists, and depends continuously on the initial condition and boundaryconditions.

DEFINITION 2.6 (Stability)For a time-dependent PDE, the corresponding difference scheme is stable

in a norm ‖ · ‖ if there exists a constant M such that

‖un‖ ≤M‖u0‖, ∀ n�t ≤ tF ,

where M is independent of �t,�x and the initial condition u0.

There are two fundamental approaches for proving stability: the Fourieranalysis (also called von Neumann stability analysis), and the energy method.Generally speaking, the Fourier analysis applies only to linear constant co-efficient problems, while the energy method can be used for more generalproblems with variable coefficients and nonlinear terms. However, the energymethod can become quite complicated and the proof is problem dependent.We will demonstrate both methods in following sections.

The following theorem connects the stability, consistence, and convergenceconcepts altogether, which proof can be found in many classic finite differencebooks (e.g.,[1, 5, 8, 12]).

THEOREM 2.1

(Lax-Richtmyer lemma) For a consistent difference approximation to a well-posed linear time-dependent problem, the stability of the scheme is necessaryand sufficient for convergence.

2.3 1-D parabolic equations

2.3.1 The θ-method

For the model problem (2.1), we can construct the so-called θ-scheme:

un+1j − unj

�t =θDx

+Dx−u

n+1j + (1 − θ)Dx

+Dx−unj

(�x)2 , 0 ≤ θ ≤ 1, 1 ≤ j ≤ J − 1,

(2.9)or

−θμun+1j−1 + (1 + 2θμ)un+1

j − θμun+1j+1 = [1 + (1 − θ)μDx

+Dx−]unj . (2.10)

Page 32: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 17

Note that the special case θ = 0 is just the explicit scheme (2.4). θ = 1corresponds to the implicit scheme (2.7), while θ = 1

2 corresponds to theso-called Crank-Nicolson scheme.

To study the stability of (2.9), we can use the Fourier analysis technique.This technique is motivated by the fact that the exact solution of a parabolicequation can be expressed as a Fourier series. For example, by the method ofseparation of variables, we can prove that the exact solution of the problem(2.1)-(2.3) can be written as

u(x, t) =∞∑

n=1

ane−(nπ)2t sinnπx, an = 2

∫ 1

0

u0(x) sinnπxdx,

i.e., the exact solution is a linear combination of all Fourier modes. Hence wecan assume that a similar Fourier mode should be an exact numerical solutionof the difference scheme. Substituting

unj = λneik(j�x), (2.11)

into (2.9), and dividing by unj , we obtain

λ− 1 = μ[θλ+ (1 − θ)](eik�x − 2 + e−ik�x)

= μ[θλ+ (1 − θ)](−4 sin2 12k�x). (2.12)

Here λ = λ(k) is called the amplification factor corresponding to the wavenum-ber k.

Solving (2.12) for λ gives

λ =1 − 4(1 − θ)μ sin2 1

2k�x1 + 4θμ sin2 1

2k�x. (2.13)

When θ = 0, we see that 0 < 2μ ≤ 1 implies 1 ≥ 1 − 4μ sin2 12k�x ≥ −1,

i.e., |λ(k)| ≤ 1 for all k, so that the scheme is stable. When θ = 1, thenλ = 1

1+4μ sin2 12k�x

≤ 1 for all k, in which case, the scheme is said to beunconditionally stable, i.e., there is no constraint on the time step size �tand the mesh size �x.

To see how energy method can be used for stability analysis, let us considerthe explicit scheme (2.4). Denote the discrete maximum norm

||un||∞ = max0≤i≤J

|uni |.

Under the condition 0 < 2μ ≤ 1, we see that

|un+1j | = |(1 − 2μ)unj + μunj+1 + μunj−1|

≤ (1 − 2μ)|unj | + μ|unj+1| + μ|unj−1| ≤ ||un||∞.

Page 33: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

18 Computational Partial Differential Equations Using MATLAB

Taking the maximum of both sides with respect to j, and using the inductionmethod, we obtain

||un+1||∞ ≤ ||un||∞ ≤ · · · ≤ ||u0||∞,i.e., the explicit scheme is stable under the condition 0 < 2μ ≤ 1.

Below we want to study the truncation error of (2.9). Since the scheme(2.9) is symmetric about the point (xj , tn+ 1

2), we can consider the truncation

error

TEn+ 1

2j ≡ u(xj , tn+1) − u(xj , tn)

�t−θD

x+D

x−u(xj , tn+1) + (1 − θ)Dx+D

x−u(xj , tn)(�x)2 . (2.14)

By the Taylor expansion, we obtain

u(xj , tn+1) − u(xj , tn) = [�tut +(�t)3

24ut3 + · · ·](xj , tn+ 1

2),

and

θDx+D

x−u(xj , tn+1) + (1 − θ)Dx

+Dx−u(xj , tn)

= [(�x)2ux2 +(�x)4

12ux4 + · · ·]|n+ 1

2j

+(θ − 12)�t[(�x)2ux2t +

(�x)412

ux4t + · · ·]|n+ 12

j

+[18(�t)2(�x)2ux2t2 + · · ·]|n+ 1

2j .

Substituting the above expansions into (2.14), we obtain

TEn+ 1

2j = −[(θ − 1

2)�tux2t +

(�x)212

ux4]|n+ 12

j + [(�t)2

24ut3 − (�t)2

8ux2t2 ]|n+ 1

2j

+[112

(12− θ)�t(�x)2ux4t]|n+ 1

2j + higher-order-terms, (2.15)

which shows that TEn+ 12

j goes to zero as �t and �x go to zero. Hence thescheme (2.9) is consistent for any θ,�t and �x. Furthermore, for any θ �= 1

2 ,the scheme has 1st-order accuracy in �t and 2nd-order accuracy in �x, sinceTE

n+ 12

j can be simply written as

TEn+ 1

2j = O(�t+ (�x)2) when θ �= 1

2.

When θ = 12 , (2.15) can be simplified to

TEn+ 1

2j = −[

(�x)212

ux4 +(�t)2

12ut3 ]

n+ 12

j + higher-order-terms

= O((�t)2 + (�x)2).

Page 34: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 19

Before we end this section, we would like to mention an interesting schemefor solving (2.1):

un+1j − un−1

j

2�t =unj+1 − 2unj + unj−1

(�x)2 , 1 ≤ n ≤ N − 1, 1 ≤ j ≤ J − 1, (2.16)

which is obtained by approximations

ut(xj , tn) ≈ (un+1j − un−1

j )/(2�t),uxx(xj , tn) ≈ (unj+1 − 2unj + unj−1)/(�x)2.

To study its stability, we substitute unj = λneik(j�x) into (2.16), and weobtain

λ− 1λ

2�t =eik�x − 2 + e−ik�x

(�x)2 =−4 sin2 1

2k�x(�x)2

orλ2 + (8μ sin2 1

2k�x)λ− 1 = 0,

from which we see that the two real roots λ1 and λ2 should satisfy

λ1 · λ2 = −1.

Hence the magnitude of one root must be greater than one no matter howyou pick �t and �x, in which case we say that the scheme is unconditionallyunstable! This warns us that we need be careful when we develop a finitedifference scheme. It is not just simply putting any combinations of differenceapproximations together.

2.3.2 Some extensions

2.3.2.1 Influence of lower-order terms

First let us consider the governing equation (2.1) augmented by some lower-order terms:

ut = uxx + aux + bu, (2.17)

where a and b are constants.We can construct an explicit scheme

un+1j − unj

�t =unj+1 − 2unj + unj−1

(�x)2 + aunj+1 − unj−1

2�x + bunj . (2.18)

Using the same stability analysis as in previous examples, we can obtainthe amplification factor

λ = 1 − 4μ sin2 12k�x+

a�t�x i sin k�x+ b�t,

Page 35: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

20 Computational Partial Differential Equations Using MATLAB

which gives

|λ|2 = (1 − 4μ sin2 12k�x+ b�t)2 + (

a�t�x )2 sin2 k�x.

For model problems with lower-order term u such as (2.17), we need torelax the stability condition |λ| ≤ 1 to

|λ(k)| ≤ 1 +M�t, for any wavenumber k, (2.19)

where the positive constant M is independent of �t and k. Equation (2.19)is often called the von Neumann condition [10, p. 144]. Hence under thecondition 0 < 2μ ≤ 1, we have

|λ|2 = (1 − 4μ sin2 12k�x)2 + 2(1 − 4μ sin2 1

2k�x)b�t

+b2(�t)2 + aμ�t sin2 k�x≤ 1 + 2|b|�t+ b2(�t)2 +

12|a|�t,

which yields (2.19). Hence, lower-order terms do not change the stabilitycondition.

It is easy to check that the truncation error of (2.18) is

TEnj =Dt

+u(xj , tn)�t − Dx

+Dx−u(xj , tn)(�x)2 + a

u(xj+1, tn) − u(xj−1, tn)2�x + bu(xj , tn)

= O(�t+ (�x)2).

2.3.2.2 General boundary conditions

Next let us see how to deal with a general boundary condition such as

ux = a(t)u + b(t), at x = 0. (2.20)

One simple scheme for discretizing (2.20) is:

un1 − un0�x = anun0 + bn, an ≡ a(tn), bn ≡ b(tn), (2.21)

which coupling with a difference scheme such as (2.4) or (2.8) yields all thenumerical solutions uni .

Another popular way to discretize (2.20) is the so-called ghost point tech-nique:

un1 − un−1

2�x = anun0 + bn, (2.22)

where un−1 denotes the approximate solution at the grid point to the left ofx = 0, which is outside of the physical domain. In this case, we need toassume that the scheme (2.4) or (2.8) holds true for j = 0, then solve ittogether with (2.22) for the numerical solution. Note that the scheme (2.22)is more accurate than (2.21).

Page 36: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 21

2.3.2.3 Variable coefficients

A general parabolic equation in self-adjoint form is

ut = (a(x, t)ux)x, (x, t) ∈ (0, 1)× (0, tF ), (2.23)

where the function a(x, t) > 0. A nice way to discretize (2.23) is to use centraldifference twice to approximate the derivative with respect to x, i.e.,

(aux)x|nj ≈(aux)nj+ 1

2− (aux)nj− 1

2

�x ≈anj+ 1

2· u

nj+1−un

j

�x − anj− 1

2· u

nj −un

j−1�x

�x ,

from which we obtain the explicit scheme

un+1j − unj

�t =1

(�x)2 [anj+ 12(unj+1 − unj ) − anj− 1

2(unj − unj−1)], 1 ≤ j ≤ J − 1,

(2.24)where we denote an

j± 12

= a((j ± 12 )�x, n�t). It is easy to see that the scheme

(2.24) is stable under the condition

amax · �t(�x)2 ≤ 1

2, amax = max

(x,t)∈[0,1]×[0,tF ]a(x, t). (2.25)

A more general linear parabolic equation is represented as

ut = a(x, t)uxx + b(x, t)ux + c(x, t)u+ d(x, t), (2.26)

where we assume that a > 0 and b > 0. For the convection-dominatedproblem (i.e., b � a), to avoid numerical oscillation, the upwind differencingis preferred: when b > 0, use forward difference for the ux term; otherwise, usebackward difference for ux. For (2.26), the upwind difference scheme becomes:

un+1j − unj

�t = anjunj+1 − 2unj + unj−1

(�x)2 + bnjunj+1 − unj

�x + cnj unj + dnj , (2.27)

where we denote anj ≡ a(xj , tn). Similar notation is used for other functions.It is easy to check that the truncation error of scheme (2.27) is

TEnj ≡ Dt+u(xj , tn)

�t − anjDx

+Dx−u(xj , tn)

(�x)2 − bnju(xj+1, tn) − u(xj , tn)

�x−cnj u(xj , tn) − dnj

= O(�t+ �x). (2.28)

Finally, let us perform a convergence analysis for the scheme (2.27) withsimple boundary condition (2.2) and the initial condition (2.3). Denote the

Page 37: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

22 Computational Partial Differential Equations Using MATLAB

error at point (xj , tn) as enj = unj − u(xj , tn). Using (2.27) and (2.28), weobtain

en+1j = enj + μanj (e

nj+1 − 2enj + enj−1) + bnj

�t�x (enj+1 − enj ) + �tcnj enj −�t · TEnj

= (μanj + bnj�t�x)enj+1

+(1 − 2μanj − bnj�t�x + �tcnj )enj + μanj e

nj−1 −�t · TEnj . (2.29)

Under the constraint

2anj�t

(�x)2 + bnj�t�x − cnj�t ≤ 1, (2.30)

all the coefficients on the right-hand side of (2.29) are non-negative. Hencewe have

|en+1j | ≤ (1 + �t|cnj |)max{|enj+1|, |enj |, |enj−1|} + �t ·M(�t+ �x), (2.31)

where we used the estimate (2.28).Let en = max0≤j≤J |enj | and c = max0≤j≤J |cnj |. Choosing the maximum of

both sides of (2.31) with respect to j, we obtain

en+1 ≤ (1 + c�t)en +M�t(�t+ �x),which yields

en ≤ (1 + c�t)2en−2 + [(1 + c�t) + 1]M�t(�t+ �x) ≤ · · ·≤ (1 + c�t)ne0 + [(1 + c�t)n−1 + · · · (1 + c�t) + 1]M�t(�t+ �x),

from which, along with the fact e0 = 0 and the identity

1 + x+ · · · + xn−1 =xn − 1x− 1

,

we obtain

en ≤ (1 + c�t)n − 1c�t M�t(�t+�x) ≤ enc�t·M(�t+�x) ≤ cctF ·M(�t+�x),

i.e., the maximum pointwise error of the scheme (2.27) is O(�t+ �x).

2.3.2.4 Nonlinear parabolic PDEs

For nonlinear PDEs, we can construct the finite difference schemes by simplyfreezing those nonlinear terms. But it is difficult to prove stability and con-vergence. Here we just provide one example. More discussions of nonlinearPDEs can be found in other books (e.g., [1, 6]).

Page 38: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 23

Let us consider the problem

ut = (u3)xx = (3u2ux)x. (2.32)

A simple explicit scheme can be constructed as

un+1j − unj

�t = 3(u2)njunj+1 − 2unj + unj−1

(�x)2 . (2.33)

An implicit scheme can be developed as

un+1j − unj

�t ≈(3u2ux)|n+1

j+ 12− (3u2ux)|n+1

j− 12

�x

≈ [(3u2)|nj+ 12

un+1j+1 − un+1

j

�x − (3u2)|nj− 12

un+1j − un+1

j−1

�x ]/�x

=(3u2)n

j+ 12(un+1j+1 − un+1

j ) − (3u2)nj− 1

2(un+1j − un+1

j−1 )

(�x)2 .

2.4 2-D and 3-D parabolic equations

2.4.1 Standard explicit and implicit methods

Let us consider a 2-D parabolic differential equation

ut = uxx + uyy, (x, y, t) ∈ (0, 1)2 × (0, tF ), (2.34)

with proper boundary conditions and initial condition.To construct a difference scheme, we assume that the domain (0, 1)2 is

partitioned into a uniform rectangular grid, with a spacing �x in the x-direction and �y in the y-direction, i.e.,

0 = x0 < x1 · · · < xJx = 1, �x =1Jx,

0 = y0 < y1 · · · < yJy = 1, �y =1Jy.

For the time domain (0, tF ), we can use a uniform grid tn = n�t, 0 ≤ n ≤N, where �t = tF

N . We denote the approximate solution

unr,s ≈ u(xr, ys, tn), 0 ≤ r ≤ Jx, 0 ≤ s ≤ Jy, 0 ≤ n ≤ N.

Below we will use quite often the second-order difference operator δ2x, whichis defined as

δ2xunr,s =

unr+1,s − 2unr,s + unr−1,s

(�x)2 .

Page 39: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

24 Computational Partial Differential Equations Using MATLAB

Using the operator δ2x, we can obtain an explicit scheme for (2.34):

un+1r,s − unr,s

�t =δ2xu

nr,s

(�x)2 +δ2yu

nr,s

(�y)2 . (2.35)

It is easy to see that the truncation error is

TEnr,s = [Dt

+u

�t − (δ2xu

(�x)2 +δ2yu

(�y)2 )](xr , ys, tn) = O(�t+ (�x)2 + (�y)2).

The stability of the scheme (2.35) can be obtained by the von Neumanntechnique. Substituting

unr,s = λnei(kxr�x+kys�y)

into (2.35), we obtain the amplification factor

λ = 1 − 4�t

(�x)2 sin2 12kx�x− 4

�t(�y)2 sin2 1

2ky�y.

It is not difficult to see that the condition

�t(�x)2 +

�t(�y)2 ≤ 1

2, (2.36)

guarantees that |λ| ≤ 1 for all wavenumbers kx and ky. Hence (2.36) guaran-tees that the scheme (2.35) is stable.

Similarly, we can obtain the Crank-Nicolson (CN) scheme for (2.34):

un+1r,s − unr,s

�t =12[δ2x(unr,s + un+1

r,s )(�x)2 +

δ2y(unr,s + un+1r,s )

(�y)2 ]. (2.37)

Denote μx = �t(�x)2 , μy = �t

(�y)2 . The CN scheme can be rewritten as

(1 − 12μxδ

2x −

12μyδ

2y)u

n+1r,s = (1 +

12μxδ

2x +

12μyδ

2y)u

nr,s. (2.38)

The truncation error of the scheme (2.37) can be easily obtained as

TEnr,s = O((�t)2 + (�x)2 + (�y)2).

As for the stability, we can easily obtain the amplification factor

λ(k) =1 − 2μx sin2 1

2kx�x− 2μy sin2 12ky�y

1 + 2μx sin2 12kx�x+ 2μy sin2 1

2ky�y,

whose amplitude is always less than or equal to one for any mesh sizes �xand �y. Hence the CN scheme is unconditionally stable.

Page 40: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 25

Note that at each time step, the CN scheme requires the solution of a(Jx − 1) × (Jy − 1) pentadiagonal matrix, which is not a feasible approachunless the mesh points are very small.

Now let us consider the 3-D parabolic equation

ut = uxx + uyy + uzz, (2.39)

with proper initial and boundary conditions.The explicit difference scheme can be obtained by simple extensions of 2-D

problems:un+1 − un

�t =δ2xu

n

(�x)2 +δ2yu

n

(�y)2 +δ2zu

n

(�z)2 , (2.40)

where for simplicity we skipped the explicit dependence on nodal indices. Tostudy its stability condition, we substitute

un = λnei(kxr�x+kys�y+kzj�z)

into (2.40) and obtain the amplification factor

λ = 1 − 4�t

(�x)2 sin2 12kx�x− 4

�t(�y)2 sin2 1

2ky�y − 4

�t(�z)2 sin2 1

2kz�z.

(2.41)To satisfy the stability condition |λ| ≤ 1 for all wavenumbers, �t must obey

the condition �t(�x)2 +

�t(�y)2 +

�t(�z)2 ≤ 1

2. (2.42)

We want to remark that the condition (2.42) is quite strigent by comparingit to the corresponding 1-D problem. Let �x = �y = �z = h, then (2.42) isequivalent to

�th2

≤ 16,

which implies that in 3-D �t must be three times smaller than in the 1-Dproblem. This is one major reason that the explicit method is rarely used for3-D parabolic problems.

2.4.2 The ADI methods for 2-D problems

For the Crank-Nicolson scheme (2.38), we see that at each time step, we haveto solve a system of (Jx − 1) × (Jy − 1) linear equations for unknowns un+1

r,s .Solving such a system is quite laborious if we consider that first it is not easyto form the coefficient matrix, and second it is quite expensive to store andsolve the matrix directly. More details will be discussed when we come to theelliptic problems in a later chapter.

A simple and efficient method, the so-called Alternate Direction Implicit(ADI) method, for solving 2-D parabolic problems was first proposed by

Page 41: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

26 Computational Partial Differential Equations Using MATLAB

Peaceman and Rachford in 1955 [11]. The basic idea is to break a 2-D prob-lem into two 1-D problems solved by implicit schemes without sacrificing thestability constraint.

Let us start with the Peaceman-Rachford scheme [11]:

u∗r,s − unr,s12�t

=δ2xu

∗r,s

(�x)2 +δ2yu

nr,s

(�y)2 , (2.43)

un+1r,s − u∗r,s

12�t

=δ2xu

∗r,s

(�x)2 +δ2yu

n+1r,s

(�y)2 . (2.44)

We can rewrite this scheme as

(1 − 12μxδ

2x)u

∗r,s = (1 +

12μyδ

2y)u

nr,s, (2.45)

(1 − 12μyδ

2y)u

n+1r,s = (1 +

12μxδ

2x)u

∗r,s. (2.46)

The stability of the Peaceman-Rachford (PR) scheme (2.43)-(2.44) can beobtained using the von Neumann technique. The amplification factor for(2.45) is

λ1 = (1 − 2μy sin2 12ky�y)/(1 + 2μx sin2 1

2kx�x),

while for (2.46) the amplification factor is

λ2 = (1 − 2μx sin2 12kx�x)/(1 + 2μy sin2 1

2ky�y).

Hence, the combined two-step scheme has an amplification factor

λ = λ1 · λ2 =(1 − 2μy sin2 1

2ky�y)(1 − 2μx sin2 12kx�x)

(1 + 2μx sin2 12kx�x)(1 + 2μy sin2 1

2ky�y),

whose magnitude is always less than or equal to one. Hence the PR schemeis unconditionally stable.

We can eliminate u∗ from (2.45)-(2.46) to obtain a single step algorithm

(1 − 12μxδ

2x)(1 − 1

2μyδ

2y)u

n+1r,s = (1 +

12μxδ

2x)(1 +

12μyδ

2y)u

nr,s, (2.47)

which is a perturbation of the CN scheme (2.38). Hence the truncation erroris O((�t)2 + (�x)2 + (�y)2). Furthermore, the PR scheme (2.45)-(2.46) iseasy to implement, since at each step we only need to solve two tridiagonalequations.

To implement the PR scheme, we need boundary conditions for u∗. Forexample, let us assume that the original problem imposes the simple Dirichletboundary condition

u(x, y, t) = g(x, y, t) on x = 0, 1.

Page 42: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 27

Subtracting (2.44) from (2.43), we obtain

u∗r,s =12(unr,s + un+1

r,s ) +�t

4(�y)2 δ2y(u

nr,s − un+1

r,s ),

which yields the boundary condition for u∗ as follows:

u∗ =12(1 +

12μyδ

2y)g

n +12(1 − 1

2μyδ

2y)g

n+1 on x = 0, 1.

Douglas and Rachford [3] proposed another ADI scheme

(1 − μxδ2x)u

∗r,s = (1 + μyδ

2y)u

nr,s, (2.48)

(1 − μyδ2y)u

n+1r,s = u∗r,s − μyδ

2yu

nr,s. (2.49)

Eliminating the intermediate variable u∗, the Douglas-Rachford (DR) methodleads to the formula

(1 − μxδ2x)(1 − μyδ

2y)u

n+1r,s = (1 + μxδ

2xμyδ

2y)u

nr,s,

from which it is easy to prove that the DR method is unconditionally stable.Furthermore, the truncation error can be proved to be O((�t)2 +�t · (�x)2).The boundary condition for u∗ can be obtained from (2.49), i.e.,

u∗ = (1 − μyδ2y)g

n+1 + μyδ2ygn on x = 0, 1.

Mitchell and Fairweather [9] proposed a high-order ADI scheme:

[1 − 12(μx − 1

6)δ2x]u

∗r,s = [1 +

12(μy +

16)δ2y ]u

nr,s, (2.50)

[1 − 12(μy − 1

6)δ2y ]u

n+1r,s = [1 +

12(μx +

16)δ2x]u

∗r,s. (2.51)

Eliminating the intermediate variable u∗, we obtain

[1 − 12(μx − 1

6)δ2x][1 − 1

2(μy − 1

6)δ2y ]u

n+1r,s

= [1 +12(μx +

16)δ2x][1 +

12(μy +

16)δ2y ]u

nr,s,

which gives the amplification factor

λ =[1 − 2(μx + 1

6 ) sin2 12kx�x][1 − 2(μy + 1

6 ) sin2 12ky�y]

[1 + 2(μx − 16 ) sin2 1

2kx�x][1 + 2(μy − 16 ) sin2 1

2ky�y],

which guarantees that |λ| ≤ 1 for any μx and μy. Thus this ADI scheme isalso unconditionally stable. It is not difficult to check that the truncationerror is O((�t)2 + (�x)4 + (�y)4).

Page 43: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

28 Computational Partial Differential Equations Using MATLAB

2.4.3 The ADI methods for 3-D problems

Similar ADI ideas developed for 2-D problems can be extended to 3-D parabolicequations. The Douglas-Rachford (DR) ADI method for 3-D problems makesone dimension implicit each time while leaving the other two dimensions ex-plicit:

un+ 13 − un

�t =δ2xu

n+ 13

(�x)2 +δ2yu

n

(�y)2 +δ2zu

n

(�z)2 , (2.52)

un+ 23 − u+ 1

3

�t =δ2y(un+ 2

3 − un)(�y)2 , (2.53)

un+1 − u+ 23

�t =δ2z(un+1 − un)

(�z)2 , (2.54)

where we skipped the explicit dependence on mesh points. We can rewrite(2.52)-(2.54) as

(1 − μxδ2x)u

n+ 13 = (1 + μyδ

2y + μzδ

2z)u

n,

(1 − μyδ2y)u

n+ 23 = un+ 1

3 − μyδ2yu

n,

(1 − μzδ2z)u

n+1 = un+ 23 − μzδ

2zu

n,

which can be simplified further to

(1 − μxδ2x)(1 − μyδ

2y)(1 − μzδ

2z)u

n+1 = (1 + μxδ2xμyδ

2y

+ μxδ2xμzδ

2z + μyδ

2yμzδ

2z − μxδ

2xμyδ

2yμzδ

2z)u

n. (2.55)

Equation (2.55) can also be written in the form

un+1 = un + (μxδ2x + μyδ2y + μzδ

2z)u

n+1

− [(μxδ2xμyδ2y + μxδ

2xμzδ

2z + μyδ

2yμzδ

2z) − μxδ

2xμyδ

2yμzδ

2z ](u

n+1 − un),

which is a perturbation of backward implicit approximation to (2.39). Hencethe truncation error is O(�t + (�x)2 + (�y)2 + (�z)2).

The standard von Neumann stability analysis leads to the amplificationfactor

λ =1 + axay + axaz + ayaz + axayaz

(1 + ax)(1 + ay)(1 + az), (2.56)

where ax = 4μx sin2 12kx�x. Similar notations are used for ay and az . From

(2.56), we see that |λ| ≤ 1 without any constraints, i.e., the algorithm isunconditionally stable.

Douglas [2] developed a more accurate ADI scheme, which is also a pertur-bation of the Crank-Nicolson scheme:

u∗ − un

�t =1h2

[12δ2x(u

∗ + un) + δ2yun + δ2zu

n], (2.57)

Page 44: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 29

u∗∗ − un

�t =1h2

[12δ2x(u

∗ + un) +12δ2y(u

∗∗ + un) + δ2zun], (2.58)

un+1 − un

�t =1

2h2[δ2x(u

∗ + un) + δ2y(u∗∗ + un) + δ2z(u

n+1 + un)],(2.59)

where for simplicity we assume that �x = �y = �z = h. When the meshsizes are different, similar schemes can be built up easily.

Let μ = �th2 . We can rewrite (2.57)-(2.59) as

(1 − 12μδ2x)u

∗ = (1 +12μδ2x + μδ2y + μδ2z)u

n, (2.60)

(1 − 12μδ2y)u

∗∗ = u∗ − 12μδ2yu

n, (2.61)

(1 − 12μδ2z)u

n+1 = u∗∗ − 12μδ2zu

n. (2.62)

Eliminating the intermediate variables u∗ and u∗∗, (2.60)-(2.62) can besimplified to

(1 − 12μδ2x)(1 − 1

2μδ2y)(1 − 1

2μδ2z)u

n+1 = [1 +μ

2(δ2x + δ2y + δ2z)

+μ2

4(δ2xδ

2y + δ2xδ

2z + δ2yδ

2z) −

μ3

8δ2xδ

2yδ

2z ]u

n, (2.63)

or

un+1 − un =μ

2(δ2x + δ2y + δ2z)(u

n+1 + un)

+ [μ2

4(δ2xδ

2y + δ2xδ

2z + δ2yδ

2z) −

μ3

8δ2xδ

2yδ

2z ](u

n+1 − un),

which is a perturbation of the Crank-Nicolson scheme to (2.39). Thus thetruncation error of the scheme (2.57)-(2.59) is O((�t)2 + h2).

From (2.63), the amplification factor of the Douglas ADI scheme can befound as

λ =1 − (ax + ay + az) + (axay + axaz + ayaz) + axayaz

(1 + ax)(1 + ay)(1 + az)

from which we see that |λ| ≤ 1 always holds true, i.e., the scheme is uncondi-tionally stable. Here we denote

ax = 2 sin2 12kx�x, ay = 2 sin2 1

2ky�y, az = 2 sin2 1

2kz�z.

Fairweather and Mitchell [4] constructed a number of high-order ADI schemeswhich are unconditionally stable. For example, a direct extension of (2.50)-(2.51) gives the following ADI scheme:

[1 − 12(μx − 1

6)δ2x]u

∗ = [1 +12(μy +

16)δ2y ]u

n, (2.64)

Page 45: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

30 Computational Partial Differential Equations Using MATLAB

[1 − 12(μy − 1

6)δ2y ]u

∗∗ = [1 +12(μz +

16)δ2z ]u

∗, (2.65)

[1 − 12(μz − 1

6)δ2z ]u

n+1 = [1 +12(μx +

16)δ2x]u

∗∗. (2.66)

We can eliminate the intermediate variables u∗ and u∗∗ of (2.64)-(2.66) toobtain

[1 − 12(μx − 1

6)δ2x][1 − 1

2(μy − 1

6)δ2y ][1 − 1

2(μz − 1

6)δ2z ]u

n+1

= [1 +12(μx +

16)δ2x][1 +

12(μy +

16)δ2y ][1 +

12(μz +

16)δ2z ]u

n,

from which the unconditional stability can be proved easily.

2.5 Numerical examples with MATLAB codes

Here we provide a MATLAB code for solving a general parabolic equation

ut(x, t) = uxx(x, t), xl < x < xr, 0 < t < tF

u(x, t)|t=0 = f(x), xl ≤ x ≤ xr

u(x, t)|x=0 = gl(t), u(x, t)|x=1 = gr(t) 0 ≤ t ≤ tF .

The code solves the above problem with xl = 0, xr = 1, tF = 0.1 by theexplicit scheme. The boundary and initial conditions are chosen properly suchthat our problem has the analytic solution

u(x, t) = sin(πx)e−π2t + sin(2πx)e−4π2t.

With a 11 × 51 mesh grid for the domain (x, t) ≡ (0, 1) × (0, 0.1), thenumerical solution (cf., Fig. 2.1) looks no different from the analytic solution.Of course detailed pointwise errors can be calculated by modifying the code.

%---------------------------------------------------------------% para1d.m:% use the explicit scheme to solve the parabolic equation% u_t(x,t) = u_{xx}(x,t), xl < x < xr, 0 < t < tf% u(x,0) = f(x), xl < x < xr% u(0,t) = gl(t), u(1,t) = gr(t), 0 < t < tf%% A special case is choosing f and g properly such that the% analytic solution is:% u(x,t)= sin(pi*x)*e^(-pi^2*t) + sin(2*pi*x)*e^(-4*pi^2*t)%

Page 46: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 31

00.2

0.40.6

0.81

0

0.02

0.04

0.06

0.08

0.1−0.5

0

0.5

1

1.5

2

x

Numerical solution of 1−D parabolic equation by explicit scheme

t

u

FIGURE 2.1The numerical solution for the 1-D parabolic problem.

% we solve this program by the explicit scheme:% u(j,n+1) = u(j,n) + v*(u(j+1,n) - 2*u(j,n) + u(j-1,n))%---------------------------------------------------------------clear all; % clear all variables in memory

xl=0; xr=1; % x domain [xl,xr]J = 10; % J: number of division for xdx = (xr-xl) / J; % dx: mesh sizetf = 0.1; % final simulation timeNt = 50; % Nt: number of time stepsdt = tf/Nt;

mu = dt/(dx)^2;

if mu > 0.5 % make sure dt satisy stability conditionerror(’mu should < 0.5!’)

end

% Evaluate the initial conditionsx = xl : dx : xr; % generate the grid point% f(1:J+1) since array index starts from 1f = sin(pi*x) + sin(2*pi*x);

% store the solution at all grid points for all time stepsu = zeros(J+1,Nt);

Page 47: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

32 Computational Partial Differential Equations Using MATLAB

% Find the approximate solution at each time stepfor n = 1:Nt

t = n*dt; % current time% boundary condition at left sidegl = sin(pi*xl)*exp(-pi*pi*t)+sin(2*pi*xl)*exp(-4*pi*pi*t);% boundary condition at right sidegr = sin(pi*xr)*exp(-pi*pi*t)+sin(2*pi*xr)*exp(-4*pi*pi*t);if n==1 % first time step

for j=2:J % interior nodesu(j,n) = f(j) + mu*(f(j+1)-2*f(j)+f(j-1));endu(1,n) = gl; % the left-end pointu(J+1,n) = gr; % the right-end point

elsefor j=2:J % interior nodes

u(j,n)=u(j,n-1)+mu*(u(j+1,n-1)-2*u(j,n-1)+u(j-1,n-1));endu(1,n) = gl; % the left-end pointu(J+1,n) = gr; % the right-end point

end

% calculate the analytic solutionfor j=1:J+1

xj = xl + (j-1)*dx;u_ex(j,n)=sin(pi*xj)*exp(-pi*pi*t) ...

+sin(2*pi*xj)*exp(-4*pi*pi*t);end

end

% Plot the resultstt = dt : dt : Nt*dt;figure(1)colormap(gray); % draw gray figuresurf(x,tt, u’); % 3-D surface plotxlabel(’x’)ylabel(’t’)zlabel(’u’)title(’Numerical solution of 1-D parabolic equation’)

figure(2)surf(x,tt, u_ex’); % 3-D surface plotxlabel(’x’)ylabel(’t’)zlabel(’u’)

Page 48: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 33

title(’Analytic solution of 1-D parabolic equation’)

2.6 Bibliographical remarks

In this chapter, we only describe some classic difference schemes for linearparabolic equations on rectangular domains. For discussions on irregular do-mains, nonlinear problems, and more advanced schemes, readers are encour-aged to consult other books [1, 5, 7, 8, 12, 13].

2.7 Exercises

1. For the θ-scheme (2.9), prove that: when 0 ≤ θ < 12 , it is stable if

μ ≤ 12(1−2θ) ; when 1

2 ≤ θ ≤ 1, it is stable for all μ.2. For the θ-scheme (2.10), the coefficient matrix is a tridiagonal matrix,

which can be solved very efficiently by the Thomas algorithm (e.g., [10]). Fora nonsingular tridiagonal matrix

A =

⎢⎢⎢⎢⎢⎢⎢⎢⎣

a1 c1 0b2 a2 c2

. . .. . .. . .bn−1 an−1 cn−1

0 bn an

⎥⎥⎥⎥⎥⎥⎥⎥⎦

we have its LU factorization, i.e., A = LU , where

L =

⎢⎢⎢⎢⎢⎢⎢⎢⎣

1 0 0β2 1 0

. . .. . .. . .βn−1 1 0

0 βn 1

⎥⎥⎥⎥⎥⎥⎥⎥⎦

, U =

⎢⎢⎢⎢⎢⎢⎢⎢⎣

α1 c1 00 α2 c2

. . .. . .. . .0 αn−1 cn−1

0 0 αn

⎥⎥⎥⎥⎥⎥⎥⎥⎦

.

Prove that the αi and βi can be computed by the relations

α1 = a1, βi = bi/αi−1, αi = ai − βici−1, i = 2, · · · , n.

Page 49: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

34 Computational Partial Differential Equations Using MATLAB

Hence solving a tridiagonal system A�x = �f is equivalent to solving L�y = �fand U�x = �y, i.e.,

y1 = f1, yi = fi − βiyi−1, i = 2, · · · , n,xn = yn/αn, xi = (yi − cixi+1)/αi, i = n− 1, · · · , 1.

Prove that the total number of multiplication/division is 5n− 4.3. Use the method (2.21) and modify the code para1d.m to solve the prob-

lem

ut = uxx, 0 < x < 1, 0 < t < 0.1,u(x, 0) = x, 0 < x < 1,ux(0, t) = ux(1, t) = 0, 0 < t < 0.1.

Plot the numerical solution at t = 0.1 on a 31 × 51 grid for (x, t) domain.Compare the numerical solution to its analytical solution:

u(x, t) =12−

∞∑

k=1

4(2k − 1)2π2

e−(2k−1)2π2t cos(2k − 1)πx.

Try to solve the problem using various grids to see the convergence rate.4. Consider the nonlinear heat equation

ut = (a(u)ux)x, x ∈ (0, 1), t ∈ (0, T ), (2.67)u(0, t) = u(1, t) = 0, (2.68)u(x, 0) = f(x), (2.69)

where we assume that there exist constants a∗ and a∗ such that

0 < a∗ ≤ a(u) ≤ a∗

for all u. Derive the following explicit scheme for this problem

un+1j − unj

�t =anj+ 1

2(unj+1 − unj ) − an

j− 12(unj − unj−1)

(�x)2 , (2.70)

where anj+ 1

2= 1

2 (a(unj+1) + a(unj )). The stability condition can be found byfreezing the nonlinear coefficient and using the von Neumann method. Recallthat when a(u) = a0 is a constant, we require that a0

�t(�x)2 ≤ 1

2 . Hence forour nonlinear problem, we need to require that the time step

�t ≤ (�x)22a∗

. (2.71)

Program the scheme (2.70) and solve the problem with

a(u) =1 + 2u2

1 + u2, f(x) = sin(2πx), �x = 0.02, T = 0.1.

Page 50: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 35

Try different time steps �t to see what happens if the condition (2.71) is notsatisfied.

5. Prove that under the condition (2.71), the scheme (2.70) satisfies theestimate

min0≤j≤J

unj ≤ un+1j ≤ max

0≤j≤Junj ,

where we assume that the spatial grid points are 0 = x0 ≤ x1 ≤ · · · ≤ xJ = 1.6. Douglas et al. [3] designed another ADI scheme for solving 2-D parabolic

equation ut = uxx + uyy as follows:

(1 − 12μxδ

2x)u

∗r,s = (1 +

12μxδ

2x + μyδ

2y)u

nr,s, (2.72)

(1 − 12μyδ

2y)u

n+1r,s = u∗r,s −

12μyδ

2yu

nr,s. (2.73)

Find the leading term of its truncation error. Prove further that this schemeis unconditionally stable.

7. Let Ω = (0, 1)2. Implement the Douglas method (2.72)-(2.73) with �x =�y = h to solve the 2-D parabolic problem

ut = uxx + uyy ∀ (x, y, t) ∈ Ω × (0, tF ), tF = 0.1,

subject to the initial condition

u|t=0 = sinπx sinπy, ∀ (x, y) ∈ Ω

and proper Dirichlet boundary condition such that the analytic solution tothe problem is given by

u(x, y, t) = e−2π2t sinπx sinπy.

Solve the problem using different grids to confirm that the convergence rateis O(h2 + (�t)2).

8. Consider the convection-diffusion equation

ut + aux − uxx = 0, (2.74)

with Dirichlet boundary conditions and a ≥ 0 is a constant. Show that

u(x, t) = e−(ikπa+(kπ)2)teikπx (2.75)

is a set of particular solutions of the problem, i.e., (2.75) satisfies the PDE(2.74). Use the von Neumann technique to derive the stability condition forthe upwind scheme

un+1j − unj

�t + aun+1j − un+1

j−1

�x =un+1j+1 − 2un+1

j + un+1j−1

(�x)2 .

Page 51: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

36 Computational Partial Differential Equations Using MATLAB

9. Consider the following problem

ut = uxx + u(1 − u), (x, t) ∈ (0, 1) × (0, tF ), (2.76)ux(0, t) = ux(1, t) = 0, t ∈ [0, tF ], (2.77)u(x, 0) = f(x), x ∈ [0, 1]. (2.78)

Note that this problem comes from the population growth model and (2.76)is called Fisher’s equation. Develop an explicit scheme to solve this problemwith

f(x) = sin2(πx), �x = 0.02, �t = 0.001, tF = 5.

What do you observe for tF → ∞?

References

[1] W.F. Ames. Numerical Methods for Partial Differential Equations. Aca-demic Press, New York, NY, 3rd edition, 1992.

[2] J. Douglas. Alternating direction methods for three space variables.Numer. Math., 4:41–63, 1962.

[3] J. Douglas and H.H. Rachford. On the numerical solution of heat con-duction problems in two and three space variables. Trans. Amer. Math.Soc., 82:421–439, 1956.

[4] G. Fairweather and A.R. Mitchell. A new computational procedure forA.D.I. methods. SIAM J. Numer. Anal., 4:163–170, 1967.

[5] B. Gustafsson, H.-O. Kreiss and J. Oliger. Time Dependent Problemsand Difference Methods. Wiley-Interscience, New York, NY, 1996.

[6] L. Lapidus and G.F. Pinder. Numerical Solution of Partial DifferentialEquations in Science and Engineering. Wiley-Interscience, New York,NY, 1999.

[7] R.J. LeVeque. Finite Difference Methods for Ordinary and Partial Dif-ferential Equations: Steady-State and Time-Dependent Problems. SIAM,Philadelphia, PA, 2007.

[8] A.R. Mitchell and D.F. Griffiths. The Finite Difference Method in Par-tial Differential Equations. John Wiley & Sons, Chichester, 1980.

[9] A.R. Mitchell and G. Fairweather. Improved forms of the alternat-ing direction methods of Douglas, Peaceman and Rachford for solvingparabolic and elliptic equations. Numer. Math., 6:285–292, 1964.

Page 52: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Parabolic Equations 37

[10] K.W. Morton and D.F. Mayers. Numerical Solution of Partial Differ-ential Equations: An Introduction. Cambridge University Press, Cam-bridge, UK, 1995.

[11] D.W. Peaceman and H.H. Rachford. The numerical solution of parabolicand elliptic differential equations. J. Soc. Indust. App. Math., 3:28–41,1955.

[12] J. Strikwerda. Finite Difference Schemes and Partial Differential Equa-tions. SIAM, Philadelphia, PA, 2nd edition, 2004.

[13] A. Tveito and R. Winther. Introduction to Partial Differential Equa-tions: A Computational Approach. Springer, New York, NY, 1998.

Page 53: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 54: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

3

Finite Difference Methods for HyperbolicEquations

In this chapter, we will continue our discussion on finite difference methods.In Sec. 3.1, we briefly introduce the hyperbolic problems. Then in Sec. 3.2,we present some basic finite difference schemes for the convection problemand review the von Neumann stability analysis technique. We introduce theimportant concepts on dissipation and dispersion errors in Sec. 3.3. We extendthe development of various finite difference schemes to conservation laws andthe second-order hyperbolic problems in Sec. 3.4 and Sec. 3.5, respectively.In Sec. 3.6, we present a MATLAB code to solve the convection problemusing the Lax-Wendroff scheme.

3.1 Introduction

Consider the initial value problem

ut +Aux = 0 (3.1)u|t=0 = u0(x) (3.2)

where A = (aij) is an m × m matrix and u is a vector function with mcomponents, respectively. The problem (3.1)-(3.2) is well-posed if and onlyif all eigenvalues of A are real and there is a complete set of eigenvectors[3, §4.3]. Such a system is called strongly hyperbolic [3, §4.3]. Here we willrestrict our discussions to such hyperbolic problems.

Assume that the complete set of eigenvectors is φ1, · · · , φm. Let matrixS = [φ1, · · · , φm]. From linear algebra theory, we know

S−1AS = Λ = diag(λ1, · · · , λm),

using which we can change the problem (3.1)-(3.2) to m scalar equations

u(i)t + λiu

(i) = 0, i = 1, 2, · · · ,m, (3.3)u(i)|t=0 = (S−1u0)(i) = u0(x), (3.4)

39

Page 55: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

40 Computational Partial Differential Equations Using MATLAB

where u(i) is the ith component of the vector S−1u. Hence we will concentrateon the discussion of the scalar equation:

ut + aux = 0, ∀ (x, t) ∈ (0, 1) × (0, tF ), (3.5)u|t=0 = u0(x). (3.6)

For the hyperbolic equation (3.5), the solutions of

dx

dt= a(x, t)

are called the characteristics. Along a characteristic curve, the solution isa constant since

du

dt=∂u

∂t+∂u

∂x

dx

dt= 0.

It is easy to check that the solution to (3.5)-(3.6) with constant a can beexpressed as u(x, t) = u0(x− at).

3.2 Some basic difference schemes

In this section, we shall develop some simple schemes for (3.5)-(3.6). Weassume that uniform grid points are used, i.e.,

xj = j�x, 0 ≤ j ≤ J,�x = 1/J,tn = n�t, 0 ≤ n ≤ N,�x = tF /N.

First let us consider a central difference scheme:

un+1j − unj

�t + aunj+1 − unj−1

2�x = 0. (3.7)

Applying von Neumann technique to (3.7), we obtain the amplificationfactor

λ ≡ λ(k) = 1 − a�t

2�x(eik�x − e−ik�x) = 1 − a�t�xi sink�x,

which gives

|λ|2 = 1 + (a�t�x)2 > 1,

i.e., the scheme (3.7) is unconditionally unstable. Hence we have to be verycareful in choosing proper difference approximations.

Page 56: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 41

A popular scheme for (3.5)-(3.6) is the so-called upwind scheme:

un+1j = unj − a

�t�x(unj − unj−1), if a > 0, (3.8)

i.e., when a > 0, we approximate ux|nj by backward difference. When a < 0,

we approximate ux|nj by unj+1−un

j

�x , i.e., in this case by forward difference.To check its stability, let us denote μ = a�t

�x . Substituting

unj = λneik(j�x) (3.9)

into (3.8), we see that the amplification factor

λ(k) = 1 − μ(1 − e−ik�x) = 1 − μ+ μ cos k�x− iμ sink�x. (3.10)

Hence we have

|λ(k)|2 = (1 − μ)2 + 2μ(1 − μ) cos k�x+ μ2 cos2 k�x+ μ2 sin2 k�x= (1 − μ)2 + 2μ(1 − μ) cos k�x+ μ2. (3.11)

If 0 ≤ μ ≤ 1, then

|λ(k)|2 ≤ (1 − μ)2 + 2μ(1 − μ) + μ2 = (1 − μ+ μ)2 = 1,

i.e., the scheme is stable provided that 0 ≤ μ ≤ 1. By Taylor expansion, it iseasy to see that the truncation error of (3.8) is O(�t+ �x).

Now we want to derive a more accurate scheme. Using (3.5) in the Taylorexpansion, we obtain

u(x, t+ �t) = u(x, t) + �tut(x, t) +(�t)2

2utt(x, t) +O(�t)3 (3.12)

= u(x, t) − a�tux(x, t) +(�t)2

2a2uxx(x, t) +O(�t)3.(3.13)

Then approximating those x-derivatives by central difference, we obtain theso-called Lax-Wendroff scheme:

un+1j = unj − μ

2(unj+1 − unj−1) +

μ2

2(unj+1 − 2unj + unj−1). (3.14)

Using von Neumann stability analysis, we obtain the amplification factor

λ(k) = 1 − μ

2(eik�x − e−ik�x) +

μ2

2(eik�x − 2 + e−ik�x)

= 1 − iμ sink�x− 2μ2 sin2 12k�x, (3.15)

from which we have

|λ(k)|2 = 1 − 4μ2(1 − μ2) sin4 12k�x. (3.16)

Page 57: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

42 Computational Partial Differential Equations Using MATLAB

Hence the Lax-Wendroff scheme is stable whenever |μ| ≤ 1. It is easy to seethat the truncation error is O((�t)2 + (�x)2).

Another classic method for (3.5) is the leap-frog scheme:

un+1j − un−1

j

2�t + aunj+1 − unj−1

2�x = 0, (3.17)

whose truncation error is O((�t)2 + (�x)2). Substituting

unj = λneik(j�x)

into (3.17), we obtain

λ2 + (i2μ sink�x)λ− 1 = 0,

solving which gives

λ(k) = −iμ sink�x± (1 − μ2 sin2 k�x)1/2. (3.18)

Hence the roots λ(k) are complex for all k if and only if |μ| ≤ 1, in which case|λ(k)|2 = 1, i.e., the scheme is stable provided that |μ| ≤ 1.

From the above several examples, we see that a necessary condition for theabove difference schemes to be stable is |μ| = |a�t

�x | ≤ 1, which is the so-calledCourant-Friedrich-Levy (CFL) condition: the domain of dependence of thedifference scheme must include the domain of dependence of the differentialequation. Recall that for the Lax-Wendroff scheme (3.14), the value of un+1

j

depends on unj−1, unj , and unj+1, which then depend on some values at time level

n−1, i.e., un−1i , j−2 ≤ i ≤ j+2, and so on. Hence the domain of dependence

of un+1j is formed by the function values inside the triangle, whose bottom

side includes those values u0i , j − (n+ 1) ≤ i ≤ j + (n+ 1). Note that for the

continuous problem (3.5)-(3.6), its exact solution is u(x, t) = u0(x−at). Hencethe analytic solution at point (xj , tn+1) is obtained by tracing this point backalong the characteristic to the point (xj − atn+1, 0), where it meets the initialtime line. To satisfy the CFL condition, we need xj−(n+1)�x ≤ xj−atn+1,or a�t

�x ≤ 1.

3.3 Dissipation and dispersion errors

Considering that the solutions of hyperbolic equations are waves, we have tostudy some properties associated with waves, such as the amplitude and thephase of the waves. The corresponding errors introduced by the numericalschemes are called the dissipation (or amplitude) error, and the dispersion (orphase) error. Furthermore, if the amplitude factor λ satisfies

|λ(k)| ≤ 1 − C · (k�x)r ∀ |k�x| ≤ π,

Page 58: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 43

for some positive constant C and positive integer r, then the correspondingdifference method is said to be dissipative of order r.

Let us first look at the upwind scheme for a > 0. Consider a special solutionof (3.5)

u(x, t) = ei(kx+ωt), ω = −ka, (3.19)

at x = j�x, t = n�t. From (3.19) and representing λ = |λ|eiargλ, the phaseof the numerical mode is given by

argλ = − tan−1 μ sin k�x1 − μ+ μ cos k�x. (3.20)

Let ξ = k�x. Expanding (3.20) and using the following expansions:

11 − z

= 1 + z + z2 + · · · , ∀ |z| < 1, (3.21)

sin z = z − z3

3!+z5

5!− + · · · , ∀ |z| < 1, (3.22)

cos z = 1 − z2

2!+z4

4!− + · · · , ∀ |z| < 1, (3.23)

tan−1 z = z − z3

3+z5

5− + · · · , ∀ |z| < 1, (3.24)

we obtain: for ξ � 1,

argλ = − tan−1 μ(ξ − ξ3

6 + · · ·)1 − μ+ μ(1 − ξ2

2 + ξ4

24 − · · ·)

= − tan−1{μ(ξ − ξ3

6+ · · ·)[1 + μ(

ξ2

2− ξ4

24+ · · ·) + μ2(

ξ4

4− · · ·)]}

= − tan−1[μ(ξ − ξ3

6+ · · ·) + μ2(

ξ3

2+ · · ·)]

= −[μ(ξ − ξ3

6) + μ2(

ξ3

2+ · · ·) − 1

3μ3ξ3 + · · ·]

= −μξ[1 + (−16

2− 1

3μ2)ξ2 + · · ·]

= −μξ[1 − 16(1 − μ)(1 − 2μ)ξ2 + · · ·]. (3.25)

From (3.19), at each time step, the phase increases by

ω�t = −ka�t = −k · �x · a�t�x = −ξμ,

from which, along with (3.25), we see that the relative phase error is

argλ− (−μξ)−μξ = −1

6(1 − μ)(1 − 2μ)ξ2 + · · · ,

Page 59: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

44 Computational Partial Differential Equations Using MATLAB

i.e., the relative phase error is O(ξ2).From (3.25) and (3.23), we have

|λ(k)|2 = 1 − μ(1 − μ)[ξ2 − ξ4

12+ · · ·],

which implies that the amplitude error of the upwind scheme is O(ξ2) in onetime step.

Now let us study the behavior of the Lax-Wendroff scheme. From (3.16),we see that the amplitude error in one time step is O(ξ4), which means thatthe solution from the Lax-Wendroff scheme shall have much less amplitudedamping compared to the upwind scheme.

From (3.15) and expansions (3.22) and (3.24), we have

argλ = − tan−1 μ sin k�x1 − 2μ2 sin2 1

2k�x= −μξ[1 − 1

6(1 − μ2)ξ2 + · · ·],

which gives the relative phase error − 16 (1−μ2)ξ2. Note that this corresponds

to a phase lag, since the sign is always negative.Finally, let us look at the leap-frog scheme. For all modes k, we have

|λ(k)| = 1, which means that the leap-frog scheme is non-dissipative (i.e.,no damping). But there is a problem with this scheme: it has a parasiticsolution (i.e., non-physical solution), which oscillates rapidly and travels in theopposite direction to the true solution. The positive root of (3.18) correspondsto the true mode, in which case,

argλ = − sin−1(μ sink�x)= −μξ[1 − 1

6(1 − μ2)ξ2 + · · ·],

i.e., the relative phase error is − 16 (1−μ2)ξ2, same as the Lax-Wendroff scheme.

Here we used the expansion

sin−1 z = z +12z3

3+ (

1 · 32 · 4)

z5

5+ (

1 · 3 · 52 · 4 · 6)

z7

7+ · · · , ∀ |z| ≤ 1.

3.4 Extensions to conservation laws

In many practical applications, the hyperbolic equation often appears in theconservation form

∂u

∂t+∂f(u)∂x

= 0. (3.26)

Page 60: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 45

We can derive the Lax-Wendroff scheme directly for (3.26), in which case

utt = −(fx)t = −(∂f

∂u

∂u

∂t)x = (a(u)fx)x, a(u) ≡ ∂f

∂u,

substituting this into the Taylor expansion (3.12) yields

u(x, t+ �t) = u(x, t) −�t∂f∂x

+12(�t)2(a(u)

∂f

∂x)x +O((�t)3).

Approximating those x-derivatives by central differences, we obtain theLax-Wendroff scheme

un+1j = unj − �t

2�x [f(unj+1) − f(unj−1)] +12(�t�x )2

[a(unj+ 12)(f(unj+1) − f(unj )) − a(unj− 1

2)(f(unj ) − f(unj−1))],(3.27)

where we can set a(unj± 1

2) = a(1

2 (unj±1 + unj )).Note that the special case f(u) = au (where a is a constant) reduces to the

scheme (3.14) we obtained earlier. The vector form of scheme (3.27) can beextended directly to systems of equations

∂u

∂t+∂f(u)∂x

= 0. (3.28)

A more convenient variant of the Lax-Wendroff scheme (3.27) is imple-mented in a two-step procedure (e.g., [7, p. 108] or [3, p. 237]):

un+ 1

2j+ 1

2=

12(unj + unj+1) −

�t2�x [f(unj+1) − f(unj )], (3.29)

un+1j = unj − �t

�x [f(un+ 12

j+ 12) − f(un+ 1

2j− 1

2)]. (3.30)

The leap-frog scheme for (3.26) can be easily constructed:

un+1j − un−1

j

2�t +f(unj+1) − f(unj−1)

2�x = 0. (3.31)

Finally, we want to mention that similar schemes can be developed forconservation laws in two and three space dimensions (cf. [7] or [3]).

3.5 The second-order hyperbolic PDEs

Let us consider the second-order hyperbolic equation in one space dimension

utt = a2uxx, ∀ (x, t) ∈ (0, 1) × (0, tF ), (3.32)u(x, 0) = f(x), ut(x, 0) = g(x), ∀ 0 ≤ x ≤ 1, (3.33)u(0, t) = uL(t), u(1, t) = uR(t), ∀ t ∈ (0, tF ), (3.34)

Page 61: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

46 Computational Partial Differential Equations Using MATLAB

where the constant a > 0.Let ζ = x+ at, η = x− at. By simple calculus, (3.32) can be reduced to

φζη = 0, (3.35)

where φ(ζ, η) = u(x, t). Integrating (3.35) twice gives

u(x, t) = ψ1(x+ at) + ψ2(x− at),

where ψ1 and ψ2 are arbitrary twice differentiable functions. The lines

x± at = constant

are the characteristics of (3.32).For an arbitrary point p(x∗, t∗), the two characteristics passing through it

aret− t∗ = ±1

a(x− x∗),

which intersect the x-axis (i.e., the t = 0 line) at points x = x∗ ∓ at∗. Thesetwo points along with the point p form a triangle, which is called the do-main of dependence for the solution u(x∗, t∗). The domain of dependenceof numerical difference solution can be defined as we did previously for thefirst-order hyperbolic equation. We want to emphasize that the domain ofdependence of the difference scheme must include the domain of dependenceof the corresponding PDE.

If we define v = ut and w = aux, we can rewrite (3.32) as

∂t

[vw

]+[

0 −a−a 0

]∂

∂x

[vw

]= 0,

i.e, (3.32) can be reduced to a system of first-order hyperbolic equations wediscussed previously. But we shall discuss numerical schemes for solving (3.32)directly.

First we consider the simple explicit scheme: for any interior nodal points(i.e., 1 ≤ j ≤ J − 1, 1 ≤ n ≤ N − 1),

un+1j − 2unj + un−1

j

(�t)2 = a2unj+1 − 2unj + unj−1

(�x)2 , (3.36)

which needs two level initial conditions.Approximating the first equation of (3.33), we obtain

u0j = f(xj), ∀0 ≤ j ≤ J. (3.37)

The second initial condition of (3.33) can be approximated as

u1j − 1

2 (u0j+1 + u0

j−1)�t = g(xj), ∀1 ≤ j ≤ J − 1,

Page 62: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 47

or

u1j =

12(u0j+1 + u0

j−1) + �tg(xj), ∀1 ≤ j ≤ J − 1. (3.38)

The truncation error of the explicit scheme (3.36)-(3.38) is O((�t)2 +(�x)2). As for the stability of (3.36), denoting μ = a�t

�x and using thevon Neumann technique, we obtain

λ− 2 +1λ

= μ2(e−ik�x − 2 + eik�x)

or

λ2 + (−2 + 4μ2 sin2 12k�x)λ+ 1 = 0, (3.39)

where λ is the amplification factor. Solving (3.39), we obtain

λ = (1 − 2μ2 sin2 12k�x) ±

√(1 − 2μ2 sin2 1

2k�x)2 − 1.

In order for |λ| ≤ 1, it is necessary that

−1 ≤ 1 − 2μ2 sin2 12k�x ≤ 1,

or |μ| ≤ 1, under which condition the scheme is stable.For (3.32), the Crank-Nicolson scheme can be written as

un+1j − 2unj + un−1

j

(�t)2 =1

2(�x)2 [(un+1j+1 −2un+1

j +un+1j−1 )+(un−1

j+1 −2un−1j +un−1

j−1 )],

(3.40)whose truncation error is O((�t)2 + (�x)2). As for stability, using the vonNeumann technique, we obtain

λ− 2 +1λ

=12μ2[−4λ sin2 1

2k�x− 4

λsin2 1

2k�x]

or

(1 + 2μ2 sin2 12k�x)λ2 − 2λ+ (1 + 2μ2 sin2 1

2k�x) = 0. (3.41)

Solving (3.41), we have

λ = (1 ± i

√(1 + 2μ2 sin2 1

2k�x)2 − 1)/(1 + 2μ2 sin2 1

2k�x)

from which we obtain|λ|2 = 1

for any k and μ, i.e., the scheme (3.40) is unconditionally stable.

Page 63: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

48 Computational Partial Differential Equations Using MATLAB

Finally, let us consider a 2-D hyperbolic equation

utt = uxx + uyy, (3.42)u(x, y, 0) = f(x, y), ut(x, y, 0) = g(x, y), (3.43)u(0, y, t) = uL(y, t), u(1, y, t) = uR(y, t), (3.44)u(x, 0, t) = uB(x, t), u(x, 1, t) = uT (x, t), (3.45)

which holds true for any (x, y, t) ∈ (0, 1)2 × (0, tF ).The explicit scheme and Crank-Nicolson scheme developed for 1-D hyper-

bolic problems can be extended straightforward to (3.42)-(3.45). For example,the 2-D explicit scheme can be written as

un+1i,j − 2uni,j + un−1

i,j

(�t)2 =1h2

[(uni+1,j − 2uni,j +uni−1,j)+ (uni,j+1 − 2uni,j +uni,j−1)],

(3.46)where for simplicity we assume that �x = �y = h. Denote μ = �t

h . By vonNeumann stability analysis, the amplification factor λ satisfies the equation

λ2 − 2λ+ 1 = μ2[−4λ sin2 12kx�x− 4λ sin2 1

2ky�y]

orλ2 − 2[1 − 2μ2(sin2 1

2kx�x+ sin2 1

2ky�y)]λ+ 1 = 0.

Under the condition

−1 ≤ c ≡ 1 − 2μ2(sin2 12kx�x+ sin2 1

2ky�y) ≤ 1,

or |μ| ≤ 1√2, we have

|λ| = |(2c±√

4c2 − 4)/2| = |c± i√

1 − c2| = 1,

i.e., the scheme is stable for �th ≤ 1√

2, which is identical to the CFL condition

for the 2-D hyperbolic problem (3.42).Similar ADI schemes as those of parabolic equations have been developed

by many researchers (see [5] and references therein). Here we just mentiona sixth-order accurate (in space) ADI scheme developed by Fairweather andMitchell [1]:

u∗ij = 2unij − un−1ij − 1

12(1 − μ2)δ2x[u

∗ij −

2(1 + 5μ2)1 − μ2

unij + un−1ij ]

−μ2 · 1 + μ2

1 − μ2δ2yu

nij , (3.47)

un+1ij = u∗ij −

1 − μ2

12δ2y[u

n+1ij − 2(1 + 10μ2 + μ4)

(1 − μ2)2unij + un−1

ij ], (3.48)

Page 64: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 49

if μ �= 1. Furthermore, Fairweather and Mitchell [1] proved that the localtruncation error is

− 1180

h6μ2[(μ4 − 34)(ux6 + uy6) +

74(μ4 − 29

21)(ux4y2 + ux2y4)] = O(h6)

and the scheme is stability under the condition [1, Eq. (4.2)]

μ =�th

≤√

3 − 1.

3.6 Numerical examples with MATLAB codes

Here we show an example using the Lax-Wendroff scheme to solve the hyper-bolic equation

ut + ux = 0 0 ≤ x ≤ 1, 0 < t < 0.5,

with proper boundary condition at x = 0 and initial condition:

u(x, 0) = exp(−c(x− 0.5)2), 0 ≤ x ≤ 1,

such that the analytic solution is a smooth Gaussian wave

u(x, t) = exp(−c(x− t− 0.5)2),

where c > 0 is a constant determining the narrowness of the wave. The largerc is, the narrower the wave will be.

Examplary numerical and analytic solutions are presented in Fig. 3.1 forc = 50 solved by different numbers of grid points: the left graphs are obtainedon the 20 × 50 grid; the right graphs are obtained on the 40× 50 grid.

From Fig. 3.1, we can see that when the grid is not fine enough, thenumerical solution cannot approximate the analytic solution well. Use offiner mesh has reduced both the amplitude and phase errors significantly.Furthermore, we can see that the numerical wave always lags behind theanalytic wave, which is consistent with our theoretical phase error analysiscarried out earlier.

The MATLAB source code hyper1d.m is attached below.

%---------------------------------------------------------------% hyper1d.m:% use Lax-Wendroff scheme to solve the hyperbolic equation% u_t(x,t) + u_x(x,t) = 0, xl < x < xr, 0 < t < tf% u(x, 0) = f(x), xl < x < xr% u(0, t) = g(t), 0 < t < tf%

Page 65: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

50 Computational Partial Differential Equations Using MATLAB

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−0.2

0

0.2

0.4

0.6

0.8

1

1.2Numerical and Analytic Solutions at t=0.1, 0.3, 0.5

Numerical t=0.1Analytic t=0.1Numerical t=0.3Analytic t=0.3Numerical t=0.5Analytic t=0.5

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−0.2

0

0.2

0.4

0.6

0.8

1

1.2Numerical and Analytic Solutions at t=0.1, 0.3, 0.5

Numerical t=0.1Analytic t=0.1Numerical t=0.3Analytic t=0.3Numerical t=0.5Analytic t=0.5

FIGURE 3.1Solutions for the 1-D hyperbolic problem.

% A special case is choosing f and g properly such that the% The analytic solution is:% u(x,t)= f(x-t)=e^(-10(x-t-0.2)^2)%---------------------------------------------------------------clear all; % clear all variables in memory

xl=0; xr=1; % x domain [xl,xr]J = 40; % J: number of division for xdx = (xr-xl) / J; % dx: mesh sizetf = 0.5; % final simulation timeNt = 50; % Nt: number of time stepsdt = tf/Nt;c = 50; % parameter for the solution

mu = dt/dx;

if mu > 1.0 % make sure dt satisy stability conditionerror(’mu should < 1.0!’)

end

% Evaluate the initial conditionsx = xl : dx : xr; % generate the grid pointf = exp(-c*(x-0.2).^2); % dimension f(1:J+1)

% store the solution at all grid points for all time stepsu = zeros(J+1,Nt);

Page 66: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 51

% Find the approximate solution at each time stepfor n = 1:Nt

t = n*dt; % current timegl = exp(-c*(xl-t-0.2)^2); % BC at left sidegr = exp(-c*(xr-t-0.2)^2); % BC at right sideif n==1 % first time step

for j=2:J % interior nodesu(j,n) = f(j) - 0.5*mu*(f(j+1)-f(j-1)) + ...

0.5*mu^2*(f(j+1)-2*f(j)+f(j-1));endu(1,n) = gl; % the left-end pointu(J+1,n) = gr; % the right-end point

elsefor j=2:J % interior nodes

u(j,n) = u(j,n-1) - 0.5*mu*(u(j+1,n-1)-u(j-1,n-1)) + ...0.5*mu^2*(u(j+1,n-1)-2*u(j,n-1)+u(j-1,n-1));

endu(1,n) = gl; % the left-end pointu(J+1,n) = gr; % the right-end point

end

% calculate the analytic solutionfor j=1:J+1

xj = xl + (j-1)*dx;u_ex(j,n)=exp(-c*(xj-t-0.2)^2);

end

end

% plot the analytic and numerical solution at different timesfigure;hold on;n=10;plot(x,u(:,n),’r.’,x,u_ex(:,n),’r-’); % r for redn=30;plot(x,u(:,n),’g.’,x,u_ex(:,n),’g-’);n=50;plot(x,u(:,n),’b.’,x,u_ex(:,n),’b-’);

legend(’Numerical t=0.1’,’Analytic t=0.1’,...’Numerical t=0.3’,’Analytic t=0.3’,...’Numerical t=0.5’,’Analytic t=0.5’);

title(’Numerical and Analytic Solutions at t=0.1, 0.3, 0.5’);

Page 67: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

52 Computational Partial Differential Equations Using MATLAB

3.7 Bibliographical remarks

In this chapter we introduced some classic methods for solving hyperbolicequations including conservation laws. More advanced numerical methodssuch as the finite volume methods can be found in other more focused bookssuch as [2, 4, 6, 8].

3.8 Exercises

1. For the hyperbolic equation

ut + aux = 0, a = constant > 0,

we can construct an implicit scheme

un+1j − unj

�t + aun+1j+1 − un+1

j−1

2�x = 0. (3.49)

Use the von Neumann technique to prove that the amplification factor forthe scheme (3.49) is λ = 1/(1+iμ sink�x), where μ = a�t

�x . Hence the schemeis unconditionally stable. Study the corresponding dissipation and dispersionerrors for the scheme.

2. Modify the code hyper1d.m and investigate what happens with increas-ingly larger C (say C = 100)? What do you observe for non-smooth solutioncases such as if the initial condition is a sequence pause:

u(x, 0) = 1, if 0.1 ≤ x ≤ 0.3; 0, elsewhere.

3. Consider a system of conservation laws in two space dimensions

∂u

∂t+∂f(u)∂x

+∂g(u)∂x

= 0. (3.50)

The unstaggered leap-frog scheme can be obtained immediately

un+1ij − un−1

ij

2�t +f(uni+1,j) − f(uni−1,j)

2�x +g(uni,j+1) − g(uni,j−1)

2�y = 0. (3.51)

Show that for the scalar case f(u) = au, g(u) = bu, the von Neumann tech-nique leads to

λ2 + i(2μx sinkx�x+ 2μy sin ky�y)λ− 1 = 0, (3.52)

Page 68: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 53

for the amplification factor λ, where μx = a�t�x , μy = b�t

�y . Hence the scheme(3.51) is stable under the condition |a�t

�x | + |b�t�y | ≤ 1.

4. Implement the explicit scheme (3.46) for solving the problem (3.42)-(3.45) with corrsponding initial and boundary conditions such that the ana-lytic solution is

u(x, y, t) = sinπx sinπy cos√

2πt.

Let h = 110 and tF = 0.5. Solve the problem with �t = 0.5h and �t = 0.8h.

Plot the numerical and analytic solutions at tF . What do you observe? Whathappens if you try a smaller mesh size, say h = 1

20?5. For the hyperbolic problem

utt = a2uxx, ∀ (x, t) ∈ (0, 1) × (0, tF ),u(x, 0) = f(x), ut(x, 0) = g(x), ∀ 0 ≤ x ≤ 1,u(0, t) = u(1, t) = 0, ∀ t ∈ (0, tF ),

where a > 0 is a constant. Prove that the energy

E(t) =∫ 1

0

(a2u2x(x, t) + u2

t (x, t))dx

is conserved for all time if u is a smooth solution. Hint: prove that dE(t)dt = 0.

6. For the damped wave equation

utt + ut = a2uxx, ∀ (x, t) ∈ (0, 1) × (0, tF ),u(x, 0) = f(x), ut(x, 0) = g(x), ∀ 0 ≤ x ≤ 1,u(0, t) = u(1, t) = 0, ∀ t ∈ (0, tF ).

Prove that the energy is decreasing, i.e.,

E(t) ≤ E(0) for any t ≥ 0,

where

E(t) =∫ 1

0

(a2u2x(x, t) + u2

t (x, t))dx.

Use the von Neumann method to perform a stability analysis for the scheme

un+1j − 2unj + un−1

j

(�t)2 +un+1j − un−1

j

2�t = a2unj+1 − 2unj + unj−1

(�x)2 .

7. Let u be a sufficiently smooth solution to the initial value problem

vt + f ′(v)vx = 0, x ∈ R, t > 0,v(x, 0) = v0(x), x ∈ R.

Page 69: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

54 Computational Partial Differential Equations Using MATLAB

Prove that v satisfies

v(x, t) = v0(x− f ′(v(x, t))t), x ∈ R, t > 0.

8. For the conservation law

ut + (f(u))x = 0, (3.53)

the so-called three-point conservative difference scheme [8, Ch. 9] is in theform

un+1k = unk − �t

�x (hnk+ 12− hnk− 1

2), (3.54)

where the numerical flux

hnk+ 12

= h(unk , unk+1), hnk− 1

2= h(unk−1, u

nk ).

To make sure the difference scheme (3.54) is consistent with the conservationlaw (3.53), the flux h must satisfy

h(u, u) = f(u). (3.55)

Prove that the Lax-Wendroff scheme (3.27) can be written as (3.54) with

hnk+ 12

=12[f(unk+1) + f(unk)] −

�t2�xa(u

nk+ 1

2)(f(unk+1) − f(unk ))

where a(unk+ 1

2) = f ′(1

2 (unk + unk+1)). Hence the Lax-Wendroff scheme is aconsistent conservative scheme.

9. Prove that the Lax-Friedrichs scheme

un+1k =

12(unk−1 + unk+1) −

�t2�x(f(unk+1) − f(unk−1))

is also consistent and conservative for (3.53) by setting

hnk+ 12

=12(f(unk ) + f(unk+1)) −

�x2�t(u

nk+1 − unk ).

References

[1] G. Fairweather and A.R. Mitchell. A high accuracy alternating directionmethod for the wave equation. J. Inst. Math. Appl., 1:309–316, 1965.

[2] E. Godlewski and P.-A. Raviart. Numerical Approximation of HyperbolicSystems of Conservation Laws. Springer, New York, NY, 1996.

Page 70: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Hyperbolic Equations 55

[3] B. Gustafsson, H.-O. Kreiss and J. Oliger. Time Dependent Problemsand Difference Methods. Wiley, New York, NY, 1995.

[4] D. Kroner. Numerical Schemes for Conservation Laws. Wiley, Teubner,1997.

[5] L. Lapidus and G.F. Pinder. Numerical Solution of Partial DifferentialEquations in Science and Engineering. John Wiley & Sons, New York,NY, 1982.

[6] R.J. LeVeque. Numerical Methods for Conservation Laws. Birkhauser,Basel, 2nd Edition, 2006.

[7] K.W. Morton and D.F. Mayers. Numerical Solution of Partial Differen-tial Equations. Cambridge University Press, Cambridge, UK, 1994.

[8] J.W. Thomas. Numerical Partial Differential Equations: ConservationLaws and Elliptic Equations. Springer, New York, NY, 1999.

Page 71: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 72: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

4

Finite Difference Methods for EllipticEquations

In this chapter, we switch the discussion of finite difference method (FDM) totime-independent problems. In Sec. 4.1, we construct a difference scheme forsolving the two-dimensional Poisson’s equation. Then in Sec. 4.2, we brieflyintroduce both direct methods and iterative methods for solving a generalsystem of linear equations, such as that resulting from the difference schemefor the Poisson’s equation. Sec. 4.3 is devoted to the error analysis of thedifference method for solving elliptic equations. In Sec. 4.4, we extend theconstruction of difference methods to some other elliptic problems. Finally,we present an examplary MATLAB code for solving the Poisson’s equation.

4.1 Introduction

Suppose that Ω is a bounded domain of R2 with boundary ∂Ω. The equation

a(x, y)∂2u

∂x2+ 2b(x, y)

∂2u

∂x∂y+ c(x, y)

∂2u

∂y2= f(x, y, u,

∂u

∂x,∂u

∂y), (4.1)

is said to be elliptic if b2 − ac < 0 for all points (x, y) ∈ Ω. Proper boundaryconditions (such as Dirichlet, Neumann, or Robin type) are needed for (4.1).

To illustrate how difference methods can be used to solve elliptic equations,let us start with the Poisson’s equation

−(uxx + uyy) = f(x, y) ∀ (x, y) ∈ Ω ≡ (0, 1)2, (4.2)u|∂Ω = g(x, y) ∀ (x, y) ∈ ∂Ω. (4.3)

As before, we assume that Ω is covered by a uniform grid

xi = ih, yj = jh, 0 ≤ i, j ≤ J, h =1J.

The approximate solution at point (xi, yj) is denoted by uij . Using thesecond-order central difference

δ2xuij =ui+1,j − 2uij + ui−1,j

h2, δ2yuij =

ui,j+1 − 2uij + ui,j−1

h2

57

Page 73: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

58 Computational Partial Differential Equations Using MATLAB

to approximate the derivatives uxx and uyy in (4.2), respectively, we obtainthe five-point difference scheme:

ui+1,j − 2uij + ui−1,j

h2+ui,j+1 − 2uij + ui,j−1

h2+ fij = 0, 1 ≤ i, j ≤ J − 1,

(4.4)or

ui+1,j + ui−1,j + ui,j+1 + ui,j−1 − 4uij = −h2fij . (4.5)

The boundary condition (4.3) is approximated directly. For example, onboundary y = 0, we have

ui0 = g(xi, 0) ≡ gi0, ∀ 0 ≤ i ≤ J.

Define the local truncation error

Tij ≡ 1h2

[u(xi+1, yj) + u(xi−1, yj) + u(xi, yj+1) + u(xi, yj−1) − 4u(xi, yj)]

+f(xi, yj). (4.6)

By Taylor expansion, we find that

Tij = (uxx + uyy)(xi, yj) +h2

12(ux4 + uy4)(x, y) + f(xi, yj),

from which we obtain

|Tij | ≤ h2

12max

(x,y)∈[0,1]2(|ux4 | + |uy4 |) ≡ T, (4.7)

i.e., the truncation error is O(h2) when the derivatives of u are continuous upto order four in both x and y.

Denote the (J − 1)2 dimensional vector

U = [u1,1 · · ·uJ−1,1;u1,2 · · ·uJ−1,2; · · · ;u1,J−1 · · ·uJ−1,J−1]T ,

where T means the transpose. With this notation, the scheme (4.5) ends upwith a linear system

AU = F, (4.8)

where A is a matrix of order (J − 1)2 given by

A =

⎢⎢⎢⎢⎢⎢⎢⎢⎣

B −I 0−I B −I

. . .. . .. . .−I B −I

0 −I B

⎥⎥⎥⎥⎥⎥⎥⎥⎦

Page 74: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 59

with I being the identity matrix of order J−1, and B being a matrix of orderJ − 1 given by

B =

⎢⎢⎢⎢⎢⎢⎢⎢⎣

4 −1 0−1 4 −1

. . .. . .. . .−1 4 −1

0 −1 4

⎥⎥⎥⎥⎥⎥⎥⎥⎦

(4.9)

Furthermore, F is a (J − 1)2 dimensional vector. Detailed elements arelisted below:

F1,1 = h2f1,1 + g1,0 + g0,1,

Fi,1 = h2fi,1 + gi,0, 2 ≤ i ≤ J − 2,FJ−1,1 = h2fJ−1,1 + gJ−1,0 + gJ,1,

F1,2 = h2f1,2 + g0,2,

Fi,2 = h2fi,2, 2 ≤ i ≤ J − 2,FJ−1,2 = h2fJ−1,2 + gJ,2,

· · ·F1,J−1 = h2f1,J−1 + g1,J + g0,J−1,

Fi,J−1 = h2fi,J−1 + gi,J , 2 ≤ i ≤ J − 2,FJ−1,J−1 = h2fJ−1,J−1 + gJ−1,J + gJ,J−1.

4.2 Numerical solution of linear systems

4.2.1 Direct methods

We have seen that application of the finite difference method to a linear ellipticproblem leads to a linear system of equations

Ax = b, (4.10)

where A = (aij) is a non-singular n× n matrix, and b ∈ Rn.The basic direct method for solving (4.10) is the Gaussian elimination

method, which is equivalent to decomposing the matrix A into the so-calledLU-factorization:

A = LU, (4.11)

where L = (lij) is a lower triangular n× n matrix (i.e., lij = 0 if j > i), andU = (uij) is an upper triangular matrix (i.e., uij = 0 if j < i). With the

Page 75: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

60 Computational Partial Differential Equations Using MATLAB

factorization (4.11), we can easily solve the system (4.10) by using forwardand backward substitution to solve the triangular systems:

Ly = b, Ux = y. (4.12)

Note that the LU decomposition is achieved through the n-step procedure

A = A(1) → A(2) → · · · → A(n) = U = L−1A.

The basic step from A(k) to A(k+1) is to transform the matrix A(k) suchthat the elements of the kth column under the diagonal of the new matrixA(k+1) become zero.

The Gaussian elimination algorithm can be described as follows:

A(1) = A;For k = 1 : n− 1

For i = k + 1 : nlik = −a(k)

ik /a(k)kk

For j = k + 1 : n

a(k+1)ij = a

(k)ij + lika

(k)kj

End jEnd i

End k

The elements of matrix L = (lij) are given as follows:

lii = 1, i = 1, · · · , n,lik = −a(k)

ik /a(k)kk , i = k + 1, · · · , n, k = 1, · · · , n,

lik = 0, if i < k.

The Gaussian elimination method can terminate prematurely if one of thepivots a(k)

kk becomes zero. Fortunately, it is proven [4] that for a positivedefinite matrix A, all a(k)

kk > 0, i.e., A has a unique LU -factorization.When A is symmetric positive definite, we have the Cholesky decomposition

A = LLT , (4.13)

where L is a lower triangular matrix with positive diagonal entries. Theelements of L can be obtained as follows:

For k = 1 : n

lkk = (akk −k−1∑

j=1

l2kj)1/2

Page 76: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 61

For i = k + 1 : n

lik = (aik −k−1∑

j=1

lij lkj)/lkk

End iEnd k

Note that both the Gaussian elimination method and the Cholesky decom-position require O(n3) operations. Fortunately, in many practical applica-tions, the matrix A is sparse (i.e., with many zero elements), in which case, itis possible to greatly reduce the number of operations. A special case is thatif the matrix A is a band matrix, i.e., there is an integer d (the bandwidth),such that

aij = 0 if |i− j| > d.

For such a band matrix, both the Gaussian elimination algorithm and Choleskydecomposition only require O(nd2) operations.

4.2.2 Simple iterative methods

In this subsection, we will introduce some classical iterative methods. Let thematrix A be represented as

A = L+D + U, (4.14)

where D is the diagonal of A, and L,U are its lower and upper triangularparts.

The Jacobi method is obtained as follows:

Dxk+1 = −(L+ U)xk + b

orxk+1 = −D−1(L + U)xk +D−1b. (4.15)

Componentwise, the algorithm becomes

xk+1i = (bi −

n∑

j=1,j =iaijx

kj )/aii, i = 1, · · · , n. (4.16)

Let the error vector ek = x− xk. Hence we have the error equation

ek+1 = BJek, BJ = −D−1(L+ U). (4.17)

Note that the iterates xk converge to the exact solution x of (4.10) for anyinitial vector x0 if and only if the spectral radius of the iteration matrix BJsatisfies

ρ(BJ ) < 1. (4.18)

Page 77: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

62 Computational Partial Differential Equations Using MATLAB

The condition (4.18) is satisfied for a strictly diagonally dominant matrixA, i.e.,

|aii| >n∑

j=1,j =i|aij | for i = 1, · · · , n. (4.19)

We like to remark that the Jacobi method can be divergent even if A issymmetric positive definite [12, p. 111].

The Gauss-Seidel method is formulated as follows:

(L +D)xk+1 = −Uxk + b,

orxk+1 = −(L+D)−1Uxk + (L+D)−1b, (4.20)

i.e., the corresponding iteration matrix is BGS = −(L+D)−1U. The iteration(4.20) can be written componentwisely as

xk+1i = (bi −

i−1∑

j=1

aijxk+1j −

n∑

j=i+1

aijxkj )/aii, i = 1, · · · , n.

The Gauss-Seidel method is proved to be convergent either if A is symmetricpositive definite or A is strictly diagonally dominant. Furthermore, when Ais a tridiagonal matrix, we have [10, 12]

ρ(BGS) = (ρ(BJ))2,

which yields that the Gauss-Seidel method converges if and only if the Jacobimethod converges.

To speed up the Gauss-Seidel method, we can construct the so-called Suc-cessive over Relaxation (SOR) method:

xk+1i = (1−ω)xki +ω(bi−

i−1∑

j=1

aijxk+1j −

n∑

j=i+1

aijxkj )/aii, i = 1, · · · , n, (4.21)

where ω is a positive parameter.Note that the SOR method (4.21) can be written in vector form

(D + ωL)xk+1 = [(1 − ω)D − ωU ]xk + ωb, (4.22)

which has the iteration matrix

BSOR = (D + ωL)−1[(1 − ω)D − ωU ], (4.23)

and coincides with BGS when ω = 1.From (4.23), we have

|det(BSOR)| = Πni=1|λi| = |det(D|−1 · |1 − ω|n · |det(D)| ≤ (ρ(BSOR))n,

Page 78: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 63

which yields thatρ(BSOR) ≥ |ω − 1|. (4.24)

Therefore, a necessary condition for convergence of the SOR method is

0 < ω < 2. (4.25)

Actually, it can be proved that (4.25) becomes a sufficient condition if A issymmetric positive definite.

Now we want to give a simple example for applying these classical iterationmethods to our difference equation (4.5), in which case, the Jacobi iterativemethod becomes:

un+1ij =

14(uni+1,j + uni−1,j + uni,j+1 + uni,j−1) +

h2

4fij , (4.26)

where un+1ij denotes the (n+1)th estimate of the solution at point (xi, yj). To

start the process, we need an initial guess u0ij , which usually takes the average

of the boundary values, i.e.,

u0ij =

1(J + 1)2

J∑

i=0

J∑

j=0

gij .

To terminate the iteration, we need a stop criterion such as the changebetween successive estimates at all interior points falls below an error toleranceε > 0, e.g.,

max1≤i,j≤J−1

|un+1ij − unij | ≤ ε.

We can improve the convergence speed by using the new values of uij onthe right-hand side of (4.26) as soon as they become available, which resultsthe Gauss-Seidel iterative method

un+1ij =

14(uni+1,j + un+1

i−1,j + un+1i,j+1 + uni,j−1) +

h2

4fij , (4.27)

Faster convergence can be realized by using the successive over-relaxation(SOR) method:

un+1ij = (1 − ω)uni,j + ωu∗ij, (4.28)

where

u∗ij =14(uni+1,j + un+1

i−1,j + un+1i,j+1 + uni,j−1) +

h2

4fij . (4.29)

Here the parameter ω lies in the range 0 < ω < 2. The optimal choice for ω isbased on the study of eigenvalues of the iteration matrix and is given by theformula

ωopt =2

1 +√

1 − cos2 πJ

(4.30)

for the case of a rectangular region and Dirichlet boundary condition.

Page 79: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

64 Computational Partial Differential Equations Using MATLAB

4.2.3 Modern iterative methods

Here we first consider two iterative methods for solving (4.10) when A issymmetric positive definite. The first one is the simple gradient method:Given an initial approximation x0 ∈ Rn, find successive approximations xk ∈Rn of the form

xk+1 = xk + αdk, k = 0, 1, · · · , (4.31)

where the search direction dk = −(Axk−b) and the step length α is a suitablychosen positive constant.

Using (4.10) and (4.31), we obtain the error equation

ek+1 = (I − αA)ek, k = 0, 1, · · · , (4.32)

which leads to|ek+1| ≤ |I − αA| · |ek|. (4.33)

Here we denote |η| for the usual Euclidean norm |η| = (∑ni=1 η

2i )

1/2 for anyvector η ∈ Rn, and the matrix norm

|B| = max0=η∈Rn

|Bη||η| . (4.34)

From linear algebra, if B is symmetric with eigenvalues λ1, · · · , λn, then wehave

|B| = maxi

|λi|. (4.35)

To guarantee the convergence of the gradient method, we like to have that

|I − αA| ≡ γ < 1, (4.36)

i.e., the error will be reduced by a factor γ at each iterative step. Note thatthe smaller γ is, the more rapid is the convergence. Since our matrix A ispositive definite, we have

|I − αA| = maxi

|1 − αλi|.

Hence |I − αA| < 1 is equivalent to

−1 < 1 − αλi < 1, i = 1, · · · , n,

i.e., α has to be chosen such that

αλmax < 2. (4.37)

A common choice is α = 1/λmax, in which case we have

|I − αA| = 1 − λminλmax

= 1 − 1K(A)

, (4.38)

Page 80: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 65

where K(A) = λmax

λminis the condition number for a symmetric matrix A.

From (4.33) and (4.38), we obtain

|ek| ≤ (1 − 1K(A)

)|ek−1| ≤ · · · ≤ (1 − 1K(A)

)k|e0|, k = 1, 2, · · · .

Hence to reduce the error by a factor ε > 0, the number of iteration step kneeds to satisfy the inequality

(1 − 1K(A)

)k ≤ ε,

which leads tok ≥ K(A) log

1ε. (4.39)

A more efficient iterative method for (4.10) is the conjugate gradient method,whose step size α is chosen to be optimal and the search directions dk are con-jugate, i.e.,

di · Adj = 0, i �= j. (4.40)

The conjugate gradient method can be stated as follows: Given x0 ∈ Rn

and d0 = −r0, find xk and dk, k = 1, 2, · · · , such that

xk+1 = xk + αkdk, (4.41)

αk = − rk · dkdk · Adk , (4.42)

dk+1 = −rk+1 + βkdk, (4.43)

βk =rk+1 · Adkdk · Adk , (4.44)

where we denote rk = Axk − b.It can be shown that the conjugate gradient algorithm gives, in the ab-

sence of round-off error, the exact solution after at most n steps [6, p. 133].Furthermore, for a given error tolerance ε > 0, in order to satisfy

(x− xk, A(x− xk)) ≤ ε(x− x0, A(x − x0)),

it is sufficient to choose the iteration step k such that [6]

k ≥ 12

√K(A) · log

2ε. (4.45)

Compared to (4.39), for large K(A), the conjugate gradient method is muchmore efficient than the gradient method.

For non-symmetric matrices, there are many interesting iterative algorithmsdeveloped since 1980s. Examples include the Generalized Minimal Residual(GRMES) method, the Bi-Conjugate Gradient (Bi-CG) method, the Conju-gate Gradient-Squared (CGS) method, and the Bi-Conjugate Gradient Stabi-lized method (Bi-CGSTAB) method et al. Details about these methods and

Page 81: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

66 Computational Partial Differential Equations Using MATLAB

their implementation in C/C++, Fortran 77 and MATLAB can be consultedin the book [1]. The most efficient method for solving a linear system of equa-tions (4.10) may be the so-called multigrid method, whose required numberof operations is of the order O(n). Due to its complexity, interested readerscan consult special books on the multigrid method [5, 3, 11] and referencestherein.

4.3 Error analysis with a maximum principle

Assume that a general elliptic equation

Lu = f

is approximated by a difference scheme

LhUp ≡ αpUp −k∑

i=1

αiUi = fp, ∀ p ∈ JΩ,

where i = 1, · · · , k denotes the neighbors of point p, fp is the value of functionf evaluated at point p, and JΩ denotes the set of interior points of Ω.

We assume that the coefficients satisfy the following conditions:(i) For all points p ∈ JΩ, αp > 0, αi ≥ 0, i = 1, · · · , k.(ii) For all points p ∈ JΩ,

∑ki=1 αi ≤ αp. Strict inequality must be true for at

least one p.

LEMMA 4.1

(Maximum Principle) Suppose that the difference operator Lh satisfy theconditions (i) and (ii). If

LhVp ≤ 0

for all interior points p of Ω, then V cannot achieve its non-negative maximumat an interior point, i.e.,

maxp∈JΩ

Vp ≤ max{0, maxQ∈J∂Ω

VQ},

where J∂Ω denotes the boundary points of Ω.

Proof. Suppose that the non-negative maximum of V occurs at some interiorpoint p, i.e.,

Vp = maxp∈JΩ

Vp and Vp > maxQ∈J∂Ω

VQ. (4.46)

Page 82: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 67

LhVp ≤ 0 and conditions (i) and (ii) lead to

αpVp ≤k∑

i=1

αiVi ≤ (k∑

i=1

αi)Vp ≤ αpVp,

which implies that all Vi = Vp (including boundary points), which contradictsthe assumption (4.46).

In the following, we shall use the Maximum Principle to derive the errorestimate for our model problem (4.2)-(4.3). For any interior point p(xi, yj),we denote the difference operator

Lhuij ≡ 4h2uij − 1

h2(ui−1,j + ui+1,j + ui,j−1 + ui,j+1).

It is easy to see that

Lhuij = fij ∀ 1 ≤ i, j ≤ J − 1,

and conditions (i) and (ii) are satisfied. The strict inequality of (ii) holds truefor those interior points with some neighboring boundary points.

Denote the pointwise error

eij = uij − u(xi, yj),

which along with (4.6) leads to the error equation

Lheij = fij − Lhu(xi, yj) = Tij . (4.47)

Let us introduce the grid function

ψij = eij +12Tφij , (4.48)

where T is the maximum truncation error defined by (4.7), and φij is definedas φij = x2

i .By the definitions of Lh and φij , we have

Lhφij =4h2x2i −

1h2

[(xi − h)2 + (xi + h)2 + x2i + x2

i ] = −2,

from which, (4.47), and the definition of T , we obtain

Lhψij = Lheij +12TLhφij = Tij − T ≤ 0, ∀ 1 ≤ i, j ≤ J − 1.

Furthermore, the maximum of ψij on the boundary points are

max(i,j)∈J∂Ω

ψij = 0 +12T max

(i,j)∈J∂Ω

φij =12T.

Page 83: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

68 Computational Partial Differential Equations Using MATLAB

Hence, by Lemma 4.1, we see that

max(i,j)∈JΩ

ψij ≤ 12T =

h2

24max

(x,y)∈[0,1]2(|ux4 | + |uy4 |),

which, along with the fact φij ≥ 0, leads to

eij ≤ h2

24max

(x,y)∈[0,1]2(|ux4 | + |uy4 |). (4.49)

Repeating the above analysis with the function

ψij = −eij +12Tφij

shows that

−eij ≤ h2

24max

(x,y)∈[0,1]2(|ux4 | + |uy4 |), (4.50)

which combining with (4.49) proves that

|uij − u(xi, yj)| ≤ h2

24max

(x,y)∈[0,1]2(|ux4 | + |uy4 |).

In conclusion, the solution of the five-point scheme (4.4) converges to theexact solution (4.2)-(4.3) in order of O(h2).

4.4 Some extensions

4.4.1 Mixed boundary conditions

Now let us consider the Poisson’s equation with mixed boundary conditions:

−(uxx + uyy) = f(x, y) ∀ (x, y) ∈ Ω ≡ (0, 1)2, (4.51)u(0, y) = uL(y), u(1, y) = uR(y) ∀ y ∈ (0, 1), (4.52)uy(x, 0) = gB(x), uy(x, 1) = gT (x) ∀ x ∈ (0, 1), (4.53)

where some corner compatibility conditions are implied in order to guaranteethat the solution has enough regularity. For example, at corner (0, 0), we have∂uL

∂y (0) = gB(0).We discretize (4.51) by the five-point scheme (4.4), i.e.,

ui+1,j+ui−1,j+ui,j+1 +ui,j−1−4ui,j = −h2fi,j , ∀ 1 ≤ i, j ≤ J−1. (4.54)

Approximating (4.52) directly gives

u0,j = uLj , uJ,j = uRj , 0 ≤ j ≤ J. (4.55)

Page 84: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 69

Approximating (4.53) by central difference, we have

ui,1 − ui,−1 = 2hgBi , ui,J+1 − ui,J−1 = 2hgTi , 0 ≤ i ≤ J. (4.56)

Eliminating ui,−1 from (4.56) and (4.54) with j = 0, we obtain

ui+1,0 + ui−1,0 + 2ui,1 − 4ui,0 = 2hgBi − h2fi,0. ∀ 1 ≤ i, j ≤ J − 1. (4.57)

Similarly, eliminating ui,J+1 from (4.56) and (4.54) with j = J , we obtain

ui+1,J+ui−1,J+2ui,J−1−4ui,J = −2hgTi −h2fi,J . ∀ 1 ≤ i, j ≤ J−1. (4.58)

Define the vector

U = [u1,0 · · ·uJ−1,0;u1,1 · · ·uJ−1,1; · · · ;u1,J · · ·uJ−1,J ]T ,

which forms the unknown approximate solution for the model problem (4.51)-(4.53).

Combining (4.54), (4.55), (4.57) and (4.58), we obtain the linear system

AU = F, (4.59)

where the matrix A is of order ((J − 1)(J + 1))2 or (J2 − 1)2, the vector Fhas J2−1 elements which is composed of functions values of f, uL, uR, gB andgT .

By careful calculation, the coefficient matrix A is formed by (J+1)×(J+1)blocks of (J − 1) × (J − 1) submatrices:

A =

⎢⎢⎢⎢⎢⎢⎢⎢⎣

−B 2I 0I −B I

. . .. . .. . .I −B I

0 2I −B

⎥⎥⎥⎥⎥⎥⎥⎥⎦

where the matrix B is presented by (4.9).

4.4.2 Self-adjoint problems

Now we consider a self-adjoint elliptic equation

−[(aux)x + (buy)y] + cu = f(x, y), ∀ (x, y) ∈ (0, 1)2, (4.60)

where a(x, y), b(x, y) > 0, c(x, y) ≥ 0.Approximating

(aux)x|i,j ≈ (ai+ 12 ,j

ui+1,j − ui,jh

− ai− 12 ,j

ui,j − ui−1,j

h)/h

Page 85: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

70 Computational Partial Differential Equations Using MATLAB

1

2

3

4 5

67

8

0

FIGURE 4.1Grid point location.

and(buy)y|i,j ≈ (bi,j+ 1

2

ui,j+1 − ui,jh

− bi,j− 12

ui,j − ui,j−1

h)/h,

we obtain the difference scheme for (4.60):

α1ui+1,j + α2ui,j+1 + α3ui−1,j + α4ui,j−1 − α0ui,j = −h2fi,j , (4.61)

where we denoted

α1 = ai+ 12 ,j, α2 = bi,j+ 1

2, α3 = ai− 1

2 ,j, α4 = bi,j− 1

2, α0 =

4∑

i=1

αi − h2ci,j .

4.4.3 A fourth-order scheme

Finally, we like to mention how to construct a fourth-order scheme for (4.2)-(4.3) using nine points (cf., Fig. 4.1). For simplicity, we assume a uniformmesh �x = �y = h. To construct the scheme, we approximate

(uxx+uyy)(x0, y0) ≈ α0u0 +α1(u1 +u3)+α2(u2 +u4)+α3(u5 +u6 +u7 +u8),(4.62)

andf(x0, y0) ≈ β0f0 + β1(f1 + f2 + f3 + f4), (4.63)

where ui represents the approximate solution of u at point i, while αi and βiare unknown coefficients.

By Taylor expansion, we have

u1 = u0 + h∂u0

∂x+h2

2!∂2u0

∂x2+h3

3!∂3u0

∂x3+h4

4!∂4u0

∂x4+h5

5!∂5u0

∂x5+O(h6),

u3 = u0 − h∂u0

∂x+h2

2!∂2u0

∂x2− h3

3!∂3u0

∂x3+h4

4!∂4u0

∂x4− h5

5!∂5u0

∂x5+O(h6),

Page 86: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 71

u2 = u0 + h∂u0

∂y+h2

2!∂2u0

∂y2+h3

3!∂3u0

∂y3+h4

4!∂4u0

∂y4+h5

5!∂5u0

∂y5+O(h6),

u4 = u0 − h∂u0

∂y+h2

2!∂2u0

∂y2− h3

3!∂3u0

∂y3+h4

4!∂4u0

∂y4− h5

5!∂5u0

∂y5+O(h6),

which lead to

α1(u1 + u3) = α1[2u0 + h2 ∂2u0

∂x2+h4

12∂4u0

∂x4] +O(h6), (4.64)

α2(u2 + u4) = α2[2u0 + h2 ∂2u0

∂y2+h4

12∂4u0

∂y4] +O(h6). (4.65)

On the other hand, we have the Taylor expansion

u6 = u0 + h(∂u0

∂x+∂u0

∂y) +

h2

2!(∂2u0

∂x2+ 2

∂2u0

∂x∂y+∂2u0

∂y2)

+h3

3!(∂3u0

∂x3+ 3

∂3u0

∂x2∂y+ 3

∂3u0

∂x∂y2+∂3u0

∂y3)

+h4

4!(∂4u0

∂x4+ 4

∂4u0

∂x3∂y+ 6

∂4u0

∂x2∂y2+ 4

∂4u0

∂x∂y3+∂4u0

∂y4)

+h5

5!(∂5u0

∂x5+ 5

∂5u0

∂x4∂y+ 10

∂5u0

∂x3∂y2+ 10

∂5u0

∂x2∂y3+ 5

∂5u0

∂x∂y4+∂5u0

∂y5).

Similar Taylor expansions for u5, u7 and u8 can be obtained. It is not difficultto see that

α3(u5 + u6 + u7 + u8)

= α3[4u0 +h2

2!· 4(

∂2u0

∂x2+∂2u0

∂y2)

+h4

4!· 4(

∂4u0

∂x4+ 6

∂4u0

∂x2∂y2+∂4u0

∂y4)] +O(h6). (4.66)

From (4.2), we have

f0 = −(∂2u0

∂x2+∂2u0

∂y2),

which leads further to

∂2f0∂x2

= −(∂4u0

∂x4+

∂4u0

∂x2∂y2),

∂2f0∂y2

= −(∂4u0

∂x2∂y2+∂4u0

∂y4).

Hence, we can obtain

β0f0 = β0[−(∂2u0

∂x2+∂2u0

∂y2)], (4.67)

Page 87: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

72 Computational Partial Differential Equations Using MATLAB

and

β1(f1 + f2 + f3 + f4)

= β1{4f0 +h2

2!· 2(

∂2f0∂x2

+∂2f0∂y2

) +O(h4)}

= −β1[4(∂2u0

∂x2+∂2u0

∂y2) + h2(

∂4u0

∂x4+ 2

∂4u0

∂x2∂y2+∂4u0

∂y4)] + O(h4).(4.68)

Substituting (4.64)-(4.66) into (4.62), (4.67)-(4.68) into (4.63), and com-paring the same order for (4.62) and (4.63), we obtain

u0 : α0 + 2α1 + 2α2 + 4α3 = 0,∂2u0

∂x2: h2(α1 + 2α3) = −β0 − 4β1,

∂2u0

∂y2: h2(α2 + 2α3) = −β0 − 4β1,

∂4u0

∂x4: h2(α1 + 2α3) = −12β1,

∂4u0

∂y4: h2(α2 + 2α3) = −12β1,

∂4u0

∂x2∂y2: h2α3 = −2β1.

Solving the above linear system, we have

α1 = α2 = −8β1/h2, α3 = −2β1/h

2, α0 = −40β1/h2, β0 = 8β1,

substituting which into (4.62) and (4.63), we obtain an O(h4) differencescheme:

4(u1 +u2 +u3 +u4)+(u5 +u6 +u7 +u8)−20u0 = −h2

2(8f0 +f1 +f2 +f3 +f4)

i.e., for any interior points 1 ≤ i, j ≤ J − 1, the difference scheme becomes:

4(ui+1,j + ui,j+1 + ui−1,j + ui,j−1)+(ui+1,j−1 + ui+1,j+1 + ui−1,j+1 + ui−1,j−1) − 20ui,j

= −h2

2(8fi,j + fi+1,j + fi,j+1 + fi−1,j + fi,j−1). (4.69)

It is shown [2] that on a square mesh, no other 9-point scheme for theLaplace equation can have greater order of accuracy than (4.69). More high-order schemes can be found in [8].

Page 88: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 73

00.2

0.40.6

0.81

0

0.2

0.4

0.6

0.8

10

0.2

0.4

0.6

0.8

1

1.2

1.4

Numerical solution

FIGURE 4.2The numercal solution for the 2-D elliptic problem.

4.5 Numerical examples with MATLAB codes

Here we demonstrate a MATLAB code for solving (4.2) with a homogeneousDirichlet boundary condition over the domain Ω = (0, 1)2. The right-handside function f is chosen as f(x, y) = 2π2 sin(πx) sin(πy) such that the exactsolution is given by

u(x, y) = sin(πx) sin(πy).

The attached code ellip2d.m solves the problem (4.2) using the five-pointdifference scheme (4.5). We solve the problem using various mesh sizes, andthe results justify the second-order convergence rate. With the number ofdivision J = 5, 10, 20, 40, the maximum errors are as follows

0.0304, 0.0083, 0.0021, 5.1420e− 004.

An examplary numerical solution obtained with J = 20 is shown is Fig.4.2.

The main function ellip2d.m is attached below:

%----------------------------------------------------------% ellip2d.m: solve the Poisson’s equation on unit rectangle.%% Need 2 functions: exU.m, srcF.m.%% O(h^2) convergence rate is observed by using J=5,10,20,40,

Page 89: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

74 Computational Partial Differential Equations Using MATLAB

% which gives max errors as follows:% 0.0304, 0.0083, 0.0021, 5.1420e-004.%-----------------------------------------------------------clear all;

xl=0; xr=1; % x domainyl=0; yr=1; % y domain

J=20; % number of points in both x- and y-directionsh = (xr-xl)/J; % mesh size

% build up the coefficient matrixnr = (J-1)^2; % order of the matrixmatA = zeros(nr,nr);

% can set J=3,4,5 etc to check the coefficient matrixfor i=1:nr

matA(i,i)=4;if i+1 <= nr & mod(i,J-1) ~= 0

matA(i,i+1)=-1;endif i+J-1 <= nr

matA(i,i+J-1)=-1;endif i-1 >= 1 & mod(i-1,J-1) ~= 0

matA(i,i-1)=-1;endif i-(J-1) >= 1

matA(i,i-(J-1))=-1;end

end

% build up the right-hand side vectorfor j=1:J-1

y(j) = j*h;for i=1:J-1

x(i) = i*h;[fij]=feval(@srcF,x(i),y(j)); % evaluate f(xi,yj)vecF((J-1)*(j-1)+i)=h^2*fij;[uij]=feval(@exU,x(i),y(j)); % evaluate exact solutionExU(i,j)=uij;

endend

Page 90: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 75

% solve the systemvecU = matA\vecF’; % vecU is of order (J-1)^2

for j=1:J-1for i=1:J-1U2d(i,j)=vecU((J-1)*(j-1)+i); % change into 2-D array

endend

% display max error so that we can check convergence ratedisp(’Max error =’), max(max(U2d-ExU)),

figure(1);surf(x,y,U2d);title(’Numerical solution’);figure(2);surf(x,y,ExU);title(’Exact solution’);

The two auxiliary functions exU.m and srcF.m are as follows:

% The exact solution of the governing PDEfunction uu=exU(x,y)

uu=sin(pi*x)*sin(pi*y);

% The RHS function f for the governing PDEfunction uu=srcF(x,y)

uu=2*pi^2*sin(pi*x)*sin(pi*y);

4.6 Bibliographical remarks

In this chapter, we introduced some classic difference schemes for solvingelliptic problems. More schemes and detailed discussions on elliptic problemscan be found in other books such as [7, 8, 9].

Page 91: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

76 Computational Partial Differential Equations Using MATLAB

4.7 Exercises

1. For the three-dimensional Poisson’s problem

−(uxx + uyy + uzz) = f(x, y, z) in Ω = (0, 1)3, (4.70)u|∂Ω = 0. (4.71)

We can derive the seven-point scheme

6h2uijk− 1

h2(ui+1,j,k+ui−1,j,k+ui,j+1,k+ui,j−1,k+ui,j,k+1 +ui,j,k−1) = fijk.

(4.72)Show that the Maximum Principle still applies and we have the convergenceresult

|uijk − u(xi, yj , zk)| ≤ h2

24max

(x,y,z)∈[0,1]3(|ux4 | + |uy4 | + |uz4 |).

2. Implement the SOR method (4.28)-(4.30) and solve the same problem asellip2d.m. Compare your SOR implementation with ellip2d.m using J = 20and 40. Which method is more efficient? In this case, you can use the followingstop criterion

max1≤i,j≤J−1

|un+1ij − u(xi, yj)| ≤ ε,

where u(xi, yj) is the exact solution at point (xi, yj).3. Modify the code ellip2d.m to solve the self-adjoint elliptic problem

−[(1 + x2 + y2)ux)x + (exyuy)y] + u = f(x, y) ∀ (x, y) ∈ Ω = (0, 1)2,u|∂Ω = 0,

where f(x, y) is chosen accordingly such that the exact solution

u(x, y) = x(1 − x)y(1 − y).

Estimate the convergence rate by running different mesh sizes.4. Assume that u is harmonic in Ω (i.e., uxx + uyy = 0). Then prove that

min(x,y)∈∂Ω

u(x, y) ≤ max(x,y)∈Ω

u(x, y) ≤ max(x,y)∈∂Ω

u(x, y).

Hint: Consider vε = u± ε(x2 + y2) and use the contradiction technique.5. Consider the eigenvalue problem

−�u = λu, in Ω ≡ (0, 1)2,u = 0 on ∂Ω,

Page 92: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Difference Methods for Elliptic Equations 77

where the eigenfunction u �= 0. Prove that the eigenvalues and the corre-sponding eigenfunctions are

λjk = (jπ)2 + (kπ)2, ujk(x, y) = sin(jπx) sin(kπy), j, k = 1, 2, · · · .Develop the five-point scheme to solve this eigenvalue problem.

6. Consider the Poisson’s equation in the first quadrant of the unit circleΩ = {(r, θ) : 0 < r < 1, 0 < θ < π

2 }:1r

∂r(r∂u

∂r) +

1r2∂2u

∂θ2= f(r, θ), (r, θ) ∈ Ω,

∂u

∂θ= 0 for θ = 0 and θ =

π

2,

u = g(θ) for r = 1.

Use uniform grid r = i�r, θ = j�θ, 0 ≤ i, j ≤ J, where �r = 1J ,�θ = π

2J .Derive a five-point scheme to solve the problem. Implement the scheme andsolve the problem with the exact solution u = 1

4r4 sin2 2θ, in which case,

f(r, θ) = 2r2, g(θ) =14

sin2 2θ.

Run your code with J = 5, 10, 20 to estimate the convergence rate.7. Develop a second-order difference scheme to solve the biharmonic prob-

lem∂4u

∂x4+ 2

∂4u

∂x2∂y2+∂4u

∂y4= 0, (x, y) ∈ Ω = (0, 1)2,

u = f(x, y),∂u

∂n= g(x, y), on ∂Ω.

Implement your scheme and test it with proper f and g such that the exactsolution u = x3y3.

8. Consider the problem

auxx − 2buxy + cuyy = f(x, y), (x, y) ∈ (0, 1)2,u(x, 0) = g1(x), u(x, 1) = g2(x), x ∈ (0, 1),u(0, y) = g3(y), u(1, y) = g4(y), y ∈ (0, 1),

solved by the following difference schemea

(�x)2 δ2xuij −

2b4�x�y δxδyuij +

c

(�y)2 δ2yuij = fij ,

1 ≤ i ≤ Jx − 1, 1 ≤ j ≤ Jy − 1,ui0 = g1(i�x), ui,Jy = g2(i�x), 0 ≤ i ≤ Jx,

u0j = g3(j�y), uJx,j = g4(j�y), 0 ≤ j ≤ Jy.

Here a, b, c are constants satisfying ac > b2, and δx denotes the central dif-ference operator. Use the SOR iteration with Jx = 10, Jy = 20 to solve theproblem with a = c = 1, b = 0.5 and proper f and g such that the exactsolution u = x2y2.

Page 93: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

78 Computational Partial Differential Equations Using MATLAB

References

[1] R. Barrett, M.W. Berry, T.F. Chan, J. Demmel, J. Donato, J. Dongarra,V. Eijkhout, R. Pozo, C. Romine and H. van der Vorst. Templates forthe Solution of Linear Systems: Building Blocks for Iterative Methods.SIAM, Philadelphia, PA, 1993.

[2] G. Birkhoff and S. Gulati. Optimal few-point discretizations of linearsource problems. SIAM J. Numer. Anal., 11:700–728, 1974.

[3] J.H. Bramble. Multigrid Methods. Longman Scientific & Technical,Harlow, 1993.

[4] G.H. Golub and C.F. Van Loan. Matrix Computations. Johns HopkinsUniversity Press, 1996.

[5] W. Hackbusch. Multi-Grid Methods and Applications. Springer-Verlag,New York, NY, 1985.

[6] C. Johnson. Numerical Solution of Partial Differential Equations by theFinite Element Method. Cambridge University Press, Cambridge, UK,1987.

[7] P. Knabner and L. Angerman. Numerical Methods for Elliptic andParabolic Partial Differential Equations. Springer, New York, NY, 2003.

[8] L. Lapidus and G.F. Pinder. Numerical Solution of Partial DifferentialEquations in Science and Engineering. Wiley-Interscience, New York,NY, 1999.

[9] S. Larsson and V. Thomee. Partial Differential Equations with Numer-ical Methods. Springer, New York, NY, 2003.

[10] R.S. Varga. Matrix Iterative Analysis. Prentice-Hall, Englewood Cliffs,NJ, 1962.

[11] J. Xu. Iterative methods by space decomposition and subspace correc-tion. SIAM Review, 34:581–613, 1992.

[12] D.M. Young. Iterative Solution of Large Linear Systems. AcademicPress, New York, NY, 1971.

Page 94: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

5

High-Order Compact Difference Methods

In many application areas, such as aeroacoustics [12, 13, 26, 30] and elec-tromagnetics [24], the propagation of acoustic and electromagnetic wavesneeds to be accurately simulated over very long periods of time and fardistances. To reduce the accumulation of errors, the numerical algorithmmust be highly accurate. To accomplish this goal, high-order compact finitedifference schemes have been developed for wave propagation applications[2, 12, 15, 24, 25, 29, 30] and surface water modeling [21, 22].

High-order finite difference schemes can be classified into two main cate-gories: explicit schemes and Pade-type or compact schemes. Explicit schemescompute the numerical derivatives directly at each grid by using large stencils,while compact schemes obtain all the numerical derivatives along a grid lineusing smaller stencils and solving a linear system of equations. Experience hasshown that compact schemes are much more accurate than the correspondingexplicit scheme of the same order.

In this chapter, we first introduce the basic idea for developing compactdifference schemes in Sec. 5.1, where detailed construction of the scheme andMATLAB examplary code are presented. Then we extend the discussion tohigh-dimensional problems in Sec. 5.2. Finally, in Sec. 5.3, we introducesome other ways of constructing compact difference schemes.

5.1 One-dimensional problems

5.1.1 Spatial discretization

In the high-order compact difference methods, the spatial derivatives in thegoverning PDEs are not approximated directly by some finite differences.They are evaluated by some compact difference schemes. More specifically,given scalar pointwise values f , the derivatives of f are obtained by solving atridiagonal or pentadiagonal system.

For simplicity, let us consider a uniform 1-D mesh with mesh size h =xi+1 − xi, which consists of N points:

x1 < x2 < · · · < xi−1 < xi < xi+1 < · · · < xN .

79

Page 95: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

80 Computational Partial Differential Equations Using MATLAB

To evaluate the first derivatives at interior nodes, we assume that they canbe obtained by solving the following tridiagonal system

αf ′i−1 + f ′

i + αf ′i+1 = b

fi+2 − fi−2

4h+ a

fi+1 − fi−1

2h, i = 2, · · · , N − 1, (5.1)

where the unknown coefficients α, a and b are obtained by matching the Taylorexpansion up to O(h4).

By Taylor expansion, we can have

f(xi+1) − f(xi−1)

= 2[hf ′(xi) +h3

3!f

(3)i +

h5

5!f

(5)i ] +O(h7), (5.2)

f(xi+2) − f(xi−2)

= 2[2hf ′(xi) +(2h)3

3!f

(3)i +

(2h)5

5!f

(5)i ] +O(h7), (5.3)

and

f ′(xi+1) + f ′(xi−1)

= 2[f ′(xi) +h2

2!f

(3)i +

h4

4!f

(5)i ] +O(h6). (5.4)

Let us denote the truncation error for the scheme (5.1)

R ≡ α(f ′(xi+1) + f ′(xi−1)) + f ′(xi)

− b

4h(f(xi+2) − f(xi−2)) − a

2h(f(xi+1) − f(xi−1)). (5.5)

Substituting (5.2)-(5.4) into (5.5), we obtain

R = 2αf ′(xi) + αh2f(3)i +

αh4

12f

(5)i

+ f ′(xi) − b[f ′(xi) +4h2

6f

(3)i +

16h4

5!f

(5)i ]

− a[f ′(xi) +h2

6f

(3)i +

h4

5!f

(5)i ] +O(h6)

= (2α+ 1 − a− b)f ′(xi) + (α− 4b6

− a

6)h2f

(3)i

+ (10α− 16b− a)h4

5!f

(5)i +O(h6). (5.6)

Letting the coefficients of f ′(xi) and f (3)i be zero, we obtain an α-family of

fourth-order tridiagonal schemes (5.1) with

a =23(α+ 2), b =

13(4α− 1).

Page 96: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 81

Also, the truncation error of (5.1) is − 45! (3α − 1)h4f (5). Note that α = 0

gives the explicit fourth-order scheme for the first derivative. When α = 13 ,

the scheme becomes sixth-order accurate, in which case

a =149, b =

19.

Similarly, to evaluate the second derivatives at interior nodes, we can derivethe formula [15]

αf′′i−1 + f

′′i + αf

′′i+1 = b

fi+2 − 2fi + fi−2

4h2+ a

fi+1 − 2fi + fi−1

h2, (5.7)

which provides a α-family of fourth-order tridiagonal schemes with

a =43(1 − α), b =

13(−1 + 10α).

The special case α = 0 gives the explicit fourth-order scheme for the secondderivative. The truncation error of (5.7) is −4

6! (11α − 2)h4f (6) [15, p. 19].When α = 2

11 , the scheme becomes sixth-order accurate, in which case

a =1211, b =

311.

For the third derivatives at interior nodes, we have the formula [15]

αf′′′i−1 + f

′′′i + αf

′′′i+1

= bfi+3 − 3fi+1 + 3fi−1 − fi−3

8h3+ a

fi+2 − 2fi+1 + 2fi−1 − fi−2

2h3, (5.8)

which provides a α-family of fourth-order tridiagonal schemes with

a = 2, b = 2α− 1.

α = 0 gives the explicit fourth-order scheme for the third derivative. A simplesixth-order tridiagonal scheme is given by the coefficients

α =716, a = 2, b = −1

8.

For near boundary nodes, approximation formulas for the derivatives of non-periodic problems can be derived by one-sided schemes. There are detailedlistings for the first and second derivatives in [15, 9].

For example, at boundary point 1, a sixth-order formula is [9]

f ′1 + αf ′

2 = (c1f1 + c2f2 + c3f3 + c4f4 + c5f5 + c6f6 + c7f7)/h,

where

α = 5, c1 =−19760

, c2 =−512, c3 = 5, c4 =

−53, c5 =

512, c6 =

−120, c7 = 0.

Page 97: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

82 Computational Partial Differential Equations Using MATLAB

At boundary point 2, the sixth-order formula is [9]

αf ′1 + f ′

2 + αf ′3 = (c1f1 + c2f2 + c3f3 + c4f4 + c5f5 + c6f6 + c7f7)/h,

where

α =211, c1 =

−2033

, c2 =−35132

, c3 =3433, c4 =

−733, c5 =

233, c6 =

−1132

, c7 = 0.

At boundary point N − 1, the sixth-order formula is [9]

αf ′N−2 + f ′

N−1 + αf ′N

= (c1fN + c2fN−1 + c3fN−2 + c4fN−3 + c5fN−4 + c6fN−5 + c7fN−6)/h,

where α = 211 . The remaining coefficients are the opposite of those given for

point 2 (i.e., the signs are reversed).At boundary point N , the sixth-order formula is [9]

αf ′N−1 + f ′

N

= (c1fN + c2fN−1 + c3fN−2 + c4fN−3 + c5fN−4 + c6fN−5 + c7fN−6)/h,

where α = 5. The remaining coefficients are the opposite of those given forpoint 1 (i.e., the signs are reversed).

For those near-boundary points, Lele [15] has presented the third-ordercompact scheme for the second derivatives. Below we show the reader how toderive some sixth-order compact formulas at those near-boundary points.

At boundary point 1, we construct the sixth-order formula

f′′1 + αf

′′2 = (c1f1 + c2f2 + c3f3 + c4f4 + c5f5 + c6f6 + c7f7)/h2,

where the coefficients can be found by matching the Taylor series expansionsup to the order of h7, which gives us the following linear system

c1 + c2 + c3 + c4 + c5 + c6 + c7 = 0c2 + 2c3 + 3c4 + 4c5 + 5c6 + 6c7 = 0c2 + 22c3 + 32c4 + 42c5 + 52c6 + 62c7 = (2!)(1 + α)c2 + 23c3 + 33c4 + 43c5 + 53c6 + 63c7 = (3!)α

c2 + 24c3 + 34c4 + 44c5 + 54c6 + 64c7 =4!2!α

c2 + 25c3 + 35c4 + 45c5 + 55c6 + 65c7 =5!3!α

c2 + 26c3 + 36c4 + 46c5 + 56c6 + 66c7 =6!4!α

c2 + 27c3 + 37c4 + 47c5 + 57c6 + 67c7 =7!5!α

Page 98: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 83

The solution to the above system is

c1 = 2077/157, c2 = −2943/110, c3 = 573/44, c4 = 167/99, (5.9)c5 = −18/11, c6 = 57/110, c7 = −131/1980, α= 126/11. (5.10)

At boundary point 2, we can construct the sixth-order formula

αf′′1 + f

′′2 + αf

′′3 = (c1f1 + c2f2 + c3f3 + c4f4 + c5f5 + c6f6 + c7f7)/h2.

Matching the Taylor series expansions up to the order of h7 gives us thefollowing linear system

c1 + c2 + c3 + c4 + c5 + c6 + c7 = 0c2 + 2c3 + 3c4 + 4c5 + 5c6 + 6c7 = 0c2 + 22c3 + 32c4 + 42c5 + 52c6 + 62c7 = (2!)(1 + 2α)c2 + 23c3 + 33c4 + 43c5 + 53c6 + 63c7 = (3!)(1 + 2α)

c2 + 24c3 + 34c4 + 44c5 + 54c6 + 64c7 =4!2!

(1 + 22α)

c2 + 25c3 + 35c4 + 45c5 + 55c6 + 65c7 =5!3!

(1 + 23α)

c2 + 26c3 + 36c4 + 46c5 + 56c6 + 66c7 =6!4!

(1 + 24α)

c2 + 27c3 + 37c4 + 47c5 + 57c6 + 67c7 =7!5!

(1 + 25α)

which has the solution

c1 = 585/512, c2 = −141/64, c3 = 459/512, c4 = 9/32, (5.11)c5 = −81/512, c6 = 3/64, c7 = −3/512, α = 11/128. (5.12)

Similarly, at boundary point N − 1, the sixth-order formula is

αf′′N−2 + f

′′N−1 + αf

′′N

= (c1fN + c2fN−1 + c3fN−2 + c4fN−3 + c5fN−4 + c6fN−5 + c7fN−6)/h2,

where the coefficients are given by (5.11)-(5.12). And at boundary point N ,the sixth-order formula is

αf′′N−1 + f

′′N

= (c1fN + c2fN−1 + c3fN−2 + c4fN−3 + c5fN−4 + c6fN−5 + c7fN−6)/h2,

where the coefficients are given by (5.9)-(5.10).

5.1.2 Approximations of high-order derivatives

In many real applications, the governing PDEs often contain some secondor higher derivatives. How to approximate those derivatives accurately and

Page 99: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

84 Computational Partial Differential Equations Using MATLAB

efficiently becomes quite interesting. For example, we can approximate thesecond derivatives directly by formula (5.7) or by applying the first derivativeformula (5.1) twice (see Visbal et al. [29, 30, 31]). To approximate a thirdderivative, there are more choices: using formula (5.8) directly; using the firstderivative operator (5.1) three times; using the first derivative operator (5.1)twice, followed by the second derivative operator (5.7) once.

To compare the dispersive errors introduced by different approximationmethods, let us consider a periodic function f(x) over the domain [0, 2π], i.e.,f(0) = f(2π). Furthermore, we let N be an even positive integer and denoteh = 2π/N .

By Fourier analysis, f can be approximated by its truncated Fourier series

f(x) ≈N2∑

k=− N2

fkeikx, (5.13)

where the Fourier coefficients

fk =12π

∫ 2π

0

f(x)e−ikxdx =12π

∫ 2π

0

f(x)(cos kx− i sinkx)dx.

Since we assume that f is a real-valued function,

f−k = fk∗

0 ≤ k ≤ N

2,

where fk∗

is the complex conjugate of fk.For convenience, we introduce a scaled wavenumber ωk = kh = 2πk

N and ascaled coordinate s = x

h . Hence the domain of the scaled wavenumber ωk ∈[0, π], and (5.13) can be written as

f(x(s)) ≈N2∑

k=−N2

fkeiωks. (5.14)

Taking the derivative of (5.14) with respect to s twice generates the exactFourier coefficients

f′′k = (iωk)2fk = −ω2

kfk (5.15)

for the second derivative function.On the other hand, we can assume that a truncated Fourier series for f

′′(x)

be represented as

f′′(x(s)) ≈

N2∑

k=−N2

fk′′eiωks,

where fk′′

can be obtained from a difference scheme such as (5.7).

Page 100: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 85

If considering just one specific mode ωk, and substituting

f |xi = fkeiωksi

andd2f

dx2|xi =

1h2

d2f

ds2|si =

1h2fk

′′eiωksi

into (5.7), then we obtain the left-hand side of (5.7) as

LHS =1h2fk

′′eiωksi [αe−iωk + 1 + αeiωk ]

=1h2fk

′′eiωksi [2α cosωk + 1],

and

RHS = fkeiωksi [

b

4h2(ei2ωk − 2 + e−i2ωk) +

a

h2(eiωk − 2 + e−iωk)]

= fkeiωksi [

b

4h2(2 cos 2ωk − 2) +

a

h2(2 cosωk − 2)],

which leads to

fk′′

= fk · [ b2(cos 2ωk − 1) + 2a(cosωk − 1)]/(2α cosωk + 1). (5.16)

Comparing (5.16) with (5.15), we obtain

w′′ex(ω) = ω2, (5.17)

w′′appr(ω) = [

b

2(1 − cos 2ω) + 2a(1 − cosω)]/(1 + 2α cosω), (5.18)

where we dropped the subscript k.Hence for the second derivative, the resolution formula of (5.7) is:

w′′dir2(ω) =

2a(1 − cos(ω)) + (b/2)(1 − cos(2ω))1 + 2α cos(ω)

.

The resolution characteristics of exact differentiation for the second derivativeis given by

w′′ex2(ω) = ω2.

Similar analysis can be carried out for the first derivative. Taking thederivative of (5.14) with respect to S generates the exact Fourier coefficients

f ′k = iωkfk (5.19)

for the first derivative function.

Page 101: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

86 Computational Partial Differential Equations Using MATLAB

On the other hand, we can assume that a truncated Fourier series for f′(x)

is represented as

f′(x(s)) ≈

N2∑

k=−N2

fk′eiωks,

where fk′can be obtained from a difference scheme such as (5.1).

Substituting one specific mode ωk solution

f |xi = fkeiωksi

anddf

dx|xi =

1h

df

ds|si =

1hfk

′eiωksi

into (5.1), then we obtain the left-hand side of (5.1) as

LHS =1hfk

′eiωksi [αe−iωk + 1 + αeiωk ]

=1hfk

′eiωksi [2α cosωk + 1],

and

RHS = fkeiωksi [

b

4h(ei2ωk − e−i2ωk) +

a

2h(eiωk − e−iωk)]

= fkeiωksi [

b

4h2i sin 2ωk +

a

2h(2i sinωk)],

which leads to

fk′= ifk · [ b2 sin 2ωk + a sinωk]/(2α cosωk + 1). (5.20)

Comparing (5.20) with (5.19), we obtain

w′ex(ω) = ω, (5.21)

w′appr(ω) = [

b

2sin 2ω + a sinω]/(1 + 2α cosω), (5.22)

where we dropped the subscript k.Hence two consecutive applications of the first derivative operator (5.1)

gives

w′′ind2(ω) = (

a sin(ω) + (b/2) sin(2ω)1 + 2α cos(ω)

)2.

By the same technique, the resolution characteristics of the third derivativescheme (5.8) can be derived:

w′′′dir3(ω) =

a(2 sin(ω) − sin(2ω)) + (b/4)(3 sin(ω) − sin(3ω))1 + 2α cos(ω)

,

Page 102: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 87

where the corresponding coefficients are given in Section 2.1. While threeconsecutive applications of the first derivative operator (5.1) gives

w′′′ind3(ω) = (

a sin(ω) + (b/2) sin(2ω)1 + 2α cos(ω)

)3.

Note that the resolution characteristics of exact differentiation for the thirdderivative is given by

w′′′ex3(ω) = ω3.

For completeness, we present the resolution characteristics for the sixth-order explicit scheme for approximating the third derivatives. We constructthe sixth-order explicit scheme as

h3f′′′i = a(fi+1−fi−1)+b(fi+2−fi−2)+c(fi+3−fi−3)+d(fi+4−fi−4). (5.23)

By matching the Taylor series coefficients of various orders, we obtain thefollowing linear system

a+ 2b+ 3c+ 4d = 0,a+ 23b+ 33c+ 43d = 3,a+ 25b+ 35c+ 45d = 0,a+ 27b+ 37c+ 47d = 0,

which gives the solution

a = −488/240, b = 338/240, c = −72/240, d = 7/240. (5.24)

The truncation error is 29! (a + 29b + 39c + 49d)h6f (9) ≈ 0.0136h6f (9). Note

that the truncation error for the sixth-order tridiagonal scheme [15, p. 35] is369! h

6f (9) ≈ 0.0000992h6f (9), which is much smaller than the correspondingsixth-order explicit scheme. By performing the similar Fourier error analysisas above, we can obtain the resolution characteristics for (5.23)

w′′′ex6(ω) = −2[a sin(ω) + b sin(2ω) + c sin(3ω) + d sin(4ω)],

where a, b, c, and d are given by (5.24).Plots of the above modified wavenumbers w

′′and w

′′′against wavenumber

ω for a variety of schemes are presented in Figs. 5.1 and 5.2, respectively.From Figs. 5.1 and 5.2, it is not difficult to see that using the direct wayto obtain the approximations of the second and third derivatives should bebetter than using the indirect way.

An example for reconstruction of the third derivatives of a given functionu(x) = cos(2πx) + cos(4πx) is carried out by using both direct and indirectways. The approximated third derivatives and the corresponding errors areplotted in Figs. 5.3 through 5.4 for N = 50 and N = 100 uniform intervalsover x ∈ [0, 1], respectively. These figures show clearly that reconstruction bythe direct way always performs better than the indirect way: the direct wayis at least one order of magnitude better than the indirect way.

Page 103: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

88 Computational Partial Differential Equations Using MATLAB

0 0.5 1 1.5 2 2.5 30

1

2

3

4

5

6

7

8

9 .... 4th−order tridiagonal scheme for 2nd derivative

−.−. 6th−order tridiagonal scheme for 2nd derivative

−−−− 2 times usage of 1st derivative scheme (6th−order tridiagonal)

oooo 2 times usage of 1st derivative scheme (4th−order tridiagonal)

Wavenumber

Modifie

d w

avenum

ber

FIGURE 5.1Differencing error for second derivative vs. wavenumber by different

algorithms: the solid line is for the exact differentiation. (From Fig. 1 of [17]with kind permission of Springer Science and Business Media.)

Page 104: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 89

0 0.5 1 1.5 2 2.5 30

5

10

15

20

25

30 .... 4th−order tridiagonal scheme for 3rd derivative

−.−. 6th−order tridiagonal scheme 3rd derivative

−−−− 3 times usage of 1st derivative scheme (6th−order tridiagonal)

oooo 3 times usage of 1st derivative scheme (4th−order tridiagonal)

^^^^ 6th−order explicit scheme

Wavenumber

Modifie

d w

avenum

ber

FIGURE 5.2Differencing error for third derivative vs. wavenumber by different

algorithms: the solid line is for the exact differentiation. (From Fig. 2 of [17]with kind permission of Springer Science and Business Media.)

Page 105: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

90 Computational Partial Differential Equations Using MATLAB

0 0.2 0.4 0.6 0.8 1−3000

−2000

−1000

0

1000

2000

3000

0 0.2 0.4 0.6 0.8 10

2

4

6

8x 10

−4

0 0.2 0.4 0.6 0.8 10

0.5

1

1.5

2

2.5

3x 10

−5

0 0.2 0.4 0.6 0.8 1−3000

−2000

−1000

0

1000

2000

3000

FIGURE 5.3The reconstructed third derivative (row one) and the pointwise error (row

two) with 50 intervals. Columns 1 are obtained by three consecutiveapplications of the sixth-order implicit first derivative scheme; Columns 2are obtained by the sixth-order implicit third derivative scheme. (From

Fig. 4 of [17] with kind permission of Springer Science and Business Media.)

Page 106: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 91

0 0.2 0.4 0.6 0.8 1−3000

−2000

−1000

0

1000

2000

3000

0 0.2 0.4 0.6 0.8 1−3000

−2000

−1000

0

1000

2000

3000

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

1.2x 10

−5

0 0.2 0.4 0.6 0.8 10

1

2

3

4

5x 10

−7

FIGURE 5.4The reconstructed third derivative (row one) and the pointwise error (row

two) with 100 intervals. Columns 1 are obtained by three consecutiveapplications of the sixth-order implicit first derivative scheme; Columns 2are obtained by the sixth-order implicit third derivative scheme. (From

Fig. 4 of [17] with kind permission of Springer Science and Business Media.)

Page 107: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

92 Computational Partial Differential Equations Using MATLAB

5.1.3 Temporal discretization

In our implementation, the governing PDEs are often integrated in timewith the classical second-order two-stage Runge-Kutta (RK2) method or thefourth-order four-stage Runge-Kutta (RK4) method. Assuming that the gov-erning equation is

∂U

∂t= R(U),

where R(U) denotes the residual.The classical RK4 method integrates from time t0 (step n) to t0 +�t (step

n+ 1) through the operations

U0 = u(x, t0), k0 = �tR(U0),U1 = U0 + k0/2, k1 = �tR(U1),U2 = U0 + k1/2, k2 = �tR(U2),U3 = U0 + k2, k3 = �tR(U3),

Un+1 = U0 +16(k0 + 2k1 + 2k2 + k3).

In order to save computational cost, sometimes the low-order accurate RK2scheme is prefered. The classical RK2 method integrates from time t0 (stepn) to t0 + �t (step n+ 1) through the operations

U0 = u(x, t0), k0 = �tR(U0), (5.25)U1 = U0 + k0, k1 = �tR(U1), (5.26)U2 = U1 + k1, (5.27)

Un+1 =12(U0 + U2). (5.28)

5.1.4 Low-pass spatial filter

Like other centered schemes, compact difference discretizations are nondissi-pative and are therefore susceptible to numerical instabilities originating froma variety of sources, such as mesh nonuniformity, truncated boundaries, andnonlinearity. Previous experiences [15, 29, 30, 31] show that a low-pass fil-ter [28] is ideal for suppressing the amplitude of undesirable high-frequencycomponents and does not affect the remaining components of the solution.

A high-order tridiagonal filter can be formulated as [15, 9]

αf φi−1 + φi + αf φi+1 =N∑

n=0

an2

(φi+n + φi−n), (5.29)

where φi denotes the given value at point i, and φi denotes the value after

Page 108: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 93

filtering. The spectral function (or frequency response) of the operator is [9]

SF(ω) = (N∑

n=0

an cos(nω))/(1 + 2αf cos(ω)).

To obtain the unknown coefficients, we insist that the highest frequency modebe eliminated by enforcing the condition SF(π) = 0. For flexibility, we retainαf as a free parameter. Then the remaining N equations can be derivedby matching Taylor series coefficients of the left and right sides. By doingthis, (5.29) provides a 2N -th order formula on a 2N + 1 point stencil. Notethat SF(ω) is real, hence the filter only modifies the amplitude of each wavecomponent without affecting the phase.

Coefficients of a family of tenth-order filters are derived in [9], which are

a0 =193 + 126αf

256, a1 =

105 + 302αf256

, a2 =15(−1 + 2αf )

64, (5.30)

a3 =45(1 − 2αf )

512, a4 =

5(−1 + 2αf )256

, a5 =1 − 2αf

512. (5.31)

Here αf is a free parameter which satisfies the inequality −0.5 < αf ≤ 0.5.Extensive numerical experience [29, 30, 31] suggests that values between 0.3and 0.5 for αf are appropriate.

Special formulas are needed at near boundary points due to the large stencilof the filter. Very detailed high-order one-sided formulas are provided in [9].Readers can find many specific formulas there.

5.1.5 Numerical examples with MATLAB codes

In this section, two numerical examples with MATLAB source codes are pro-vided to show the superior performance of high-order compact schemes. Weuse the sixth-order tridiagonal scheme and the classic explicit fourth-orderRunge-Kutta method in all our examples. Below we denote �x as the gridsize, and �t as the time step size.

Example 1. First we compute the solution of the linear dispersive equation

ut + c−2uxxx = 0 (5.32)

with an initial condition u(x, 0) = sin(cx) and a periodic boundary conditionsuch that the exact solution is given by u(x, t) = sin(c(x + t)) for x ∈ [0, 2π]and t ∈ [0, 1]. This example is a generalized problem presented in [32], whereonly c = 1 is discussed. Note that the exact solution is a left-moving wave.

To show the superior performance of compact schemes compared to thesame order explicit scheme, we first solved the problem (5.32) with c = 8using fourth-order explicit and compact schemes (with α = 15/32), and sixth-order explicit and compact schemes (with α = 7/32). This problem is solvedwith 41 uniformly distributed points (i.e., �x = 2π/40) and time step size

Page 109: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

94 Computational Partial Differential Equations Using MATLAB

0 1 2 3 4 5 6 7−1

−0.5

0

0.5

1

x

u(x

,t)

0 1 2 3 4 5 6 70

0.05

0.1

0.15

0.2

0.25

0.3

0.35

x

inf

err

or

0 1 2 3 4 5 6 7−1

−0.5

0

0.5

1

x

u(x

,t)

0 1 2 3 4 5 6 70

2

4

6x 10

−4

xin

f e

rro

r

FIGURE 5.5Linear dispersive wave with c = 8 at t = 0.3, 0.7, 1.The left column is obtainedby the 6th-order explicit scheme, while the right column is obtained by the 6th-order compact scheme. Top row: ∗, ◦,� represents the numerical solutions att = 0.3, 0.7, 1, respectively. Bottom row: −·,−−, · · · represents the pointwiseerrors at t = 0.3, 0.7, 1, respectively. (From Fig. 6 of [17] with kind permissionof Springer Science and Business Media.)

�t = a(dx)3, a = 0.125. We want to remark that c = 8 is a challengingproblem, where we use only five points per wavelength and the total timesteps are 2064.

The obtained solution and pointwise error at time t = 0.3, 0.7 and 1 aregraphed in Fig. 5.5, from which we see that the L∞ errors for the sixth-order explicit scheme and the sixth-order compact scheme are 0.35 and 6 ×10−4, respectively, i.e., the compact scheme is much more accurate than thecorresponding same order explicit scheme.

Next we solved (5.32) with c = 1 using both the sixth-order explicit andcompact schemes. The obtained solution and L∞ error are shown in Fig. 5.6at t = 0, 0.25, 0.5, 0.75, and 1. Due to the nice property of the solution, thistime all schemes solve the problem very well. But the compact scheme stillachieves better accuracy than the corresponding same order explicit scheme asshown by the fact that the errors obtained for the sixth-order compact schemeand the sixth-order explicit scheme are 8×10−10 and 2.5×10−7, respectively.Note that these results are much better than the best L∞ error 7.2362×10−7

achieved by the third-order LDG with the same number of points N = 41[32, Table 1.1]. We want to emphasize that no filters are used in any of thecomputations for this example.

Page 110: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 95

0 1 2 3 4 5 6 7−1

−0.5

0

0.5

1

x

u(x

,t)

0 1 2 3 4 5 6 70

0.5

1

1.5

2

2.5x 10

−7

x

inf

err

or

0 1 2 3 4 5 6 7−1

−0.5

0

0.5

1

x

u(x

,t)

0 1 2 3 4 5 6 70

2

4

6

8x 10

−10

x

inf

err

or

FIGURE 5.6Linear dispersive wave with c = 1.The left column is obtained by the 6th-orderexplicit scheme, while the right column is obtained by the 6th-order compactscheme. Top row shows the calculated (dotted) and exact (solid line) leftmoving wave at t = 0, 0.25, 0.5, 0.75, 1. Bottom row shows the correspondingerrors increasing with time. (From Fig. 8 of [17] with kind permission ofSpringer Science and Business Media.)

Page 111: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

96 Computational Partial Differential Equations Using MATLAB

The MATLAB source code disp1d.m and its auxiliary codes JSC1.m, resJSC1.m,reconuxxxp.m are listed below.

%---------------------------------------------------------------% disp1d.m: solve the linear dispersive equation% u_t + c^{-2}u_{xxx}=0% by high order compact difference method.%% Used functions:% JSC1.m: the analytic solution% reconuxxxp.m: reconstrcution u_{xxx} from u% resJSC1.m: the residual function%---------------------------------------------------------------clear all%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% generate 1D mesh

Nx=41; XL=0; XR=2*pi;dx=(XR-XL)/(Nx-1);

for i=1:NxXX(i)=XL+(i-1)*dx;

end

%%%%%%%%%march-in-time%%%%%%%%%%%%% cfl has to be small!cfl=0.125; dt=cfl*dx^3; tlast=1;Nstep=tlast/dt;cc=1; % the bigger, the larger frequency

IRK=4;

% get initial condition[u0ex]=feval(@JSC1,XX,0,cc);uold=u0ex;

subplot(2,1,1), plot(XX,u0ex, ’y-’);hold on

% we use 4th-order RK scheme:IRK=2,4for k=1:Nstepif IRK==4

u0x=reconuxxxp(uold,Nx,dx); % reconstruct ux from u_nk0=dt*resJSC1(uold,u0x,cc); % k0=dt*R(dummy,uxxx,dummy)u1=uold+k0/2;

Page 112: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 97

u1x=reconuxxxp(u1,Nx,dx);k1=dt*resJSC1(uold,u1x,cc);u2=uold+k1/2;

u2x=reconuxxxp(u2,Nx,dx);k2=dt*resJSC1(uold,u2x,cc);u3=uold+k2;

u3x=reconuxxxp(u3,Nx,dx);k3=dt*resJSC1(uold,u3x,cc);

unew=uold+(k0+2*k1+2*k2+k3)/6.; % finish one-time stepelseif IRK==2

u0x=reconuxp(uold,Nx,dx); % reconstruct ux from u_nu0xx=reconuxp(u0x,Nx,dx);u0xxx=reconuxp(u0xx,Nx,dx); % obtain u_xxxu2x=reconuxp(uold.^2,Nx,dx); % reconstruct u^2k0=dt*resJSC1(u2x,u0xxx,cc); % k0=dt*R((u_n)_x)u1=uold+k0;

u1x=reconuxp(u1,Nx,dx);uxx=reconuxp(u1x,Nx,dx);uxxx=reconuxp(uxx,Nx,dx); % obtain u_xxxu2x=reconuxp(u1.^2,Nx,dx); % reconstruct u^2k1=dt*resJSC1(u2x,uxxx,cc);u2=u1+k1;

unew=(uold+u2)/2;end

uold=unew; % update for next time stepeps=0.3*dt; % error tolerance% plot the solution at some specific timesif abs(k*dt-0.25) < eps | abs(k*dt-0.5) < eps ...

| abs(k*dt-0.75) < eps | abs(k*dt-1) < epsdisp(k),

[u0ex]=feval(@JSC1,XX,k*dt,cc);subplot(2,1,1),plot(XX,unew, ’y-’,XX,u0ex,’g.’);xlabel(’x’); ylabel(’u(x,t)’);hold onsubplot(2,1,2),if abs(k*dt-0.25) < eps, plot(XX,abs(u0ex-unew), ’r-’); endif abs(k*dt-0.5) < eps, plot(XX,abs(u0ex-unew), ’r-.’); endif abs(k*dt-0.75) < eps, plot(XX,abs(u0ex-unew), ’r--’); end

Page 113: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

98 Computational Partial Differential Equations Using MATLAB

if abs(k*dt-1) < eps, plot(XX,abs(u0ex-unew), ’r:’); end

xlabel(’x’); ylabel(’inf error’);hold on

end

end

%-----------------------------------------------------% The analytic solutionfunction uu=JSC1(x,ap,cc)uu=sin(cc*(x+ap));

%------------------------------------------------% the residual R=-0.5*(u^2)_x-cc*(u_xxx)% i.e., u1=(u^2)_x, u2=u_xxxfunction uu=resJSC1(u1,u2,cc)uu=-cc*u2;

%---------------------------------------------------------% reconstruction the 3rd derivative for periodic function%---------------------------------------------------------function ux=reconuxxxp(u,N,h)

IEX=0; % 4 means explicte 4th-order reconstructionif IEX==4a=2; b=-1;for i=1:N

if i==1tmp = b*(u(i+3)-3*u(i+1)+3*u(N-1)-u(N-3))/4 ...

+ a*(u(i+2)-2*u(i+1)+2*u(N-1)-u(N-2));elseif i==2tmp = b*(u(i+3)-3*u(i+1)+3*u(i-1)-u(N-2))/4 ...

+ a*(u(i+2)-2*u(i+1)+2*u(i-1)-u(N-1));elseif i==3tmp = b*(u(i+3)-3*u(i+1)+3*u(i-1)-u(N-1))/4 ...

+ a*(u(i+2)-2*u(i+1)+2*u(i-1)-u(i-2));elseif i== (N-2)tmp = b*(u(2)-3*u(i+1)+3*u(i-1)-u(i-3))/4 ...

+ a*(u(i+2)-2*u(i+1)+2*u(i-1)-u(i-2));elseif i== (N-1)

Page 114: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 99

tmp = b*(u(3)-3*u(i+1)+3*u(i-1)-u(i-3))/4 ...+ a*(u(2)-2*u(i+1)+2*u(i-1)-u(i-2));

elseif i==Ntmp = b*(u(4)-3*u(2)+3*u(i-1)-u(i-3))/4 ...

+ a*(u(3)-2*u(2)+2*u(i-1)-u(i-2));elsetmp = b*(u(i+3)-3*u(i+1)+3*u(i-1)-u(i-3))/4 ...

+ a*(u(i+2)-2*u(i+1)+2*u(i-1)-u(i-2));endux(i)=tmp/(2*h^3);

endreturn

end

% 6 means explict 6th-order reconstructionif IEX==6a=-488/240; b=338/240; c=-72/240; d=7/240;for i=1:N

if i==1tmp = a*(u(i+1)-u(N-1))+b*(u(i+2)-u(N-2)) ...

+ c*(u(i+3)-u(N-3))+d*(u(i+4)-u(N-4));elseif i==2tmp = a*(u(i+1)-u(i-1))+b*(u(i+2)-u(N-1)) ...

+ c*(u(i+3)-u(N-2))+d*(u(i+4)-u(N-3));elseif i==3tmp = a*(u(i+1)-u(i-1))+b*(u(i+2)-u(i-2)) ...

+ c*(u(i+3)-u(N-1))+d*(u(i+4)-u(N-2));elseif i==4tmp = a*(u(i+1)-u(i-1))+b*(u(i+2)-u(i-2)) ...

+ c*(u(i+3)-u(i-3))+d*(u(i+4)-u(N-1));elseif i==(N-3)tmp = a*(u(i+1)-u(i-1))+b*(u(i+2)-u(i-2)) ...

+ c*(u(i+3)-u(i-3))+d*(u(2)-u(i-4));elseif i== (N-2)tmp = a*(u(i+1)-u(i-1))+b*(u(i+2)-u(i-2)) ...

+ c*(u(2)-u(i-3))+d*(u(3)-u(i-4));elseif i== (N-1)tmp = a*(u(i+1)-u(i-1))+b*(u(2)-u(i-2)) ...

+ c*(u(3)-u(i-3))+d*(u(4)-u(i-4));elseif i==Ntmp = a*(u(2)-u(i-1))+b*(u(3)-u(i-2)) ...

+ c*(u(4)-u(i-3))+d*(u(5)-u(i-4));elsetmp = a*(u(i+1)-u(i-1))+b*(u(i+2)-u(i-2)) ...

+ c*(u(i+3)-u(i-3))+d*(u(i+4)-u(i-4));

Page 115: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

100 Computational Partial Differential Equations Using MATLAB

endux(i)=tmp/(h^3);

endreturn

end

% below are implicit reconstruction

ISC=6; % order of the scheme% for 4th-order compact scheme: alfa cannot be 1/2if ISC==4

alfa=15/32; aa=2; bb=2*alfa-1;% for 6th-order compact schemeelseif ISC==6

alfa=7/16; aa=2; bb=-1.0/8;end

amat=zeros(N,N);B=zeros(N,1);

for i=1:Nif i==1

amat(1,1)=1; amat(1,2)=alfa; amat(1,N-1)=alfa;B(i)=bb*(u(i+3)-3*u(i+1)+3*u(N-1)-u(N-3))/4 ...

+aa*(u(i+2)-2*u(i+1)+2*u(N-1)-u(N-2));elseif i==2

amat(2,1)=alfa; amat(2,2)=1; amat(2,3)=alfa;B(i)=bb*(u(i+3)-3*u(i+1)+3*u(i-1)-u(N-2))/4 ...

+aa*(u(i+2)-2*u(i+1)+2*u(i-1)-u(N-1));elseif i==3

amat(i,i-1)=alfa; amat(i,i)=1; amat(i,i+1)=alfa;B(i)=bb*(u(i+3)-3*u(i+1)+3*u(i-1)-u(N-1))/4 ...

+aa*(u(i+2)-2*u(i+1)+2*u(i-1)-u(i-2));elseif i==N-2

amat(i,i-1)=alfa; amat(i,i)=1; amat(i,i+1)=alfa;B(i)=bb*(u(2)-3*u(i+1)+3*u(i-1)-u(i-3))/4 ...

+aa*(u(i+2)-2*u(i+1)+2*u(i-1)-u(i-2));elseif i==N-1

amat(i,i-1)=alfa; amat(i,i)=1; amat(i,i+1)=alfa;B(i)=bb*(u(3)-3*u(i+1)+3*u(i-1)-u(i-3))/4 ...

+aa*(u(2)-2*u(i+1)+2*u(i-1)-u(i-2));elseif i==N

amat(N,1)=-1; amat(N,N)=1;B(i)=0;

else % i>=4 & i <=N-3

Page 116: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 101

amat(i,i-1)=alfa; amat(i,i)=1; amat(i,i+1)=alfa;B(i)=bb*(u(i+3)-3*u(i+1)+3*u(i-1)-u(i-3))/4 ...

+aa*(u(i+2)-2*u(i+1)+2*u(i-1)-u(i-2));endB(i)=B(i)/(2*h^3);

end

% call trisys.mux=(amat\B)’;

Example 2. In order to see how our method works for a nonlinear problemwith a small coefficient for the third derivative term, we compute the classicalsoliton solutions of the KdV equation [32]

ut + 0.5(u2)x + εuxxx = 0.

Here we present the MATLAB code for the interesting double soliton colli-sion case, which has the initial condition

u0(x) = 3c1sech2(k1(x− x1)) + 3c2sech2(k2(x− x2))

with c1 = 0.3, c2 = 0.1, x1 = 0.4, x2 = 0.8, ki = 0.5√ci/ε for i = 1, 2, and

ε = 4.84 × 10−4. The solution is modeled for x ∈ [0, 2]and t ∈ [0, 4] withperiodic boundary conditions and 101 uniform points. Fig. 5.7 and Fig.5.8 show the result obtained with �t = 0.5(�x)2 (so the total time stepsare 20,000) with and without the tenth-order filter (using α = 0.4 every1000 steps), respectively. Fig. 5.7 is obtained without filter, and we seesome numerical oscillations. But the tenth-order filter eliminates those high-frequency components very well (see Fig. 5.8).

By simple modification of the code soliton.m, we can solve for the triplesoliton splitting problem, which has the initial condition

u0(x) =23sech2(

x− 1√108ε

)

with ε = 10−4. The solution is computed for x ∈ [0, 3] and t ∈ [0, 4] withperiodic boundary conditions, 151 uniform points and �t = 0.5(�x)2. Thecomputed solutions at t = 0, 1, 2 and the solution contour up to t = 4 isshown in Fig. 5.9. Here to eliminate the high-frequency oscillations, we usethe tenth-order periodic filter with α = 0.4 every 100 steps. Note that ourtests showed that filtering every 1000 steps would not eliminate the smalloscillations very well. More examples can be found in our paper [17].

Page 117: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

102 Computational Partial Differential Equations Using MATLAB

0 0.5 1 1.5 2

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

0)

0 0.5 1 1.5 2

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

1)

0 0.5 1 1.5 2

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

2)

0 0.5 1 1.5 20

2

4

0

0.5

1

xt

FIGURE 5.7Double soliton collision obtained without filter. (From Fig. 12 of [17] with

kind permission of Springer Science and Business Media.)

Page 118: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 103

0 0.5 1 1.5 2

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

0)

0 0.5 1 1.5 2

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

1)

0 0.5 1 1.5 2

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

2)

0 0.5 1 1.5 20

2

4

0

0.5

1

xt

FIGURE 5.8Double soliton collision obtained with the 10th-order filter. (From Fig. 12 of

[17] with kind permission of Springer Science and Business Media.)

Page 119: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

104 Computational Partial Differential Equations Using MATLAB

0 1 2 3

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

0)

0 1 2 3

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

1)

0 1 2 3

0

0.2

0.4

0.6

0.8

1

x

u(x

,t=

2)

01

23

0

1

2

3

4

0

0.5

1

x

t

FIGURE 5.9Triple soliton splitting obtained with 10th-order filter. (From Fig. 13 of [17]

with kind permission of Springer Science and Business Media.)

Page 120: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 105

The MATLAB source code soliton.m and its auxiliary codes ushu51.m,resshu5.m, reconuxp.m, and filterLI.m are listed below.

%-----------------------------------------------------% soliton.m: solve the double solition problem%% Functions used:% ushu51.m: the exact solution% resshu5.m: define the residual function% reconuxxxp.m: reconstruct u_{xxx} from u% reconuxp.m: reconstruct u_x from u% filterLI.m: our 10th order filter%-----------------------------------------------------clear all%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% generate 1D mesh% for ex 4.5 (4.9) & (4.10)Nx=101; XL=0; XR=2;% for ex 4.5 (4.11)%Nx=151; XL=0; XR=3;dx=(XR-XL)/(Nx-1);

for i=1:NxXX(i)=XL+(i-1)*dx;

end

%%%%%%%%%march-in-time%%%%%%%%%%%%% cfl has to be small!cfl=0.5; dt=cfl*dx^2; tlast=4;Nstep=tlast/dt;IRK=2;%ap=5*10^(-4); % coefficient eps for the PDE, (4.9)ap=4.84*10^(-4); % for (4.10) of Shu%ap=10^(-4); % for (4.11)

% calculate init cond.: stored at u0ex[u0ex]=feval(@ushu51,XX,ap);% for ex.4.1., ap likes t%[u0ex]=feval(@ushu51,XX,0);uold=u0ex;

IT=1; % indicator for storing solution uall(1:Nx,1:NT)uall(:,1)=u0ex(:); % for contour plot

% we use 4th-order RK scheme:IRK=2,4

Page 121: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

106 Computational Partial Differential Equations Using MATLAB

for k=1:Nstepif IRK==4% u0x=reconux(uold,Nx,dx); % reconstruct ux from u_n% k0=dt*resshu5(u0x); % k0=dt*R((u_n)_x)% u1=uold+k0/2;

% u1x=reconux(u1,Nx,dx);% k1=dt*resshu5(u1x);% u2=u1+k1/2;

% u2x=reconux(u2,Nx,dx);% k2=dt*resshu5(u2x);% u3=u2+k2;

% u3x=reconux(u3,Nx,dx);% k3=dt*resshu5(u3x);

% unew=uold+(k0+2*k1+2*k2+k3)/6.; % finish one-time stepelseif IRK==2

% method 1: use 1st derivative construction three times%u0x=reconuxp(uold,Nx,dx); % reconstruct ux from u_n%u0xx=reconuxp(u0x,Nx,dx);%u0xxx=reconuxp(u0xx,Nx,dx); % obtain u_xxx% method 2: construct directlyu0xxx=reconuxxxp(uold,Nx,dx);u2x=reconuxp(uold.^2,Nx,dx); % reconstruct u^2k0=dt*resshu5(u2x,u0xxx,ap); % k0=dt*R((u_n)_x)u1=uold+k0;

%u1x=reconuxp(u1,Nx,dx);%uxx=reconuxp(u1x,Nx,dx);%uxxx=reconuxp(uxx,Nx,dx); % obtain u_xxxuxxx=reconuxxxp(u1,Nx,dx);u2x=reconuxp(u1.^2,Nx,dx); % reconstruct u^2k1=dt*resshu5(u2x,uxxx,ap);u2=u1+k1;

unew=(uold+u2)/2;end

uold=unew; % update for next time step

% for (4.11)subplot(2,2,1), plot(XX,u0ex,’g-’);axis([XL XR -0.1 1]); xlabel(’x’); ylabel(’u(x,t=0)’);if abs(k*dt-1) < eps

Page 122: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 107

subplot(2,2,2),unew=filterLI(unew,Nx);plot(XX,unew,’g-’); % plot t=1axis([XL XR -0.1 1]); xlabel(’x’); ylabel(’u(x,t=1)’);

elseif abs(k*dt-2) < epssubplot(2,2,3),unew=filterLI(unew,Nx);plot(XX,unew,’g-’); % plot t=2axis([XL XR -0.1 1]); xlabel(’x’); ylabel(’u(x,t=2)’);

end

% save some vaules for contour plotif mod(k,500)==0

disp(k), IT=IT+1;uall(:,IT)=unew(:);

endend

% do contour plotht=tlast/(IT-1);[X,Y]=meshgrid(XL:dx:XR, 0:ht:tlast);subplot(2,2,4), mesh(X,Y,uall’);xlabel(’x’); ylabel(’t’);axis([XL XR 0 tlast -0.1 1]);

%-----------------------------------------------------------

function uu=ushu51(x,ap)% ex 4.5.: single solition%c=0.3; x0=0.5; k=sqrt(c/ap)/2;%uu=3*c*(sech(k*(x-x0))).^2;

% ex 4.5: double solitionc1=0.3; c2=0.1;x1=0.4;x2=0.8;k1=0.5*sqrt(c1/ap); k2=0.5*sqrt(c2/ap);uu=3*c1*(sech(k1*(x-x1))).^2+3*c2*(sech(k2*(x-x2))).^2;% ex 4.5: triple soliton%tmp=sqrt(108*ap);%uu=2/3*(sech((x-1)/tmp)).^2; %.^ array power% below for ex4.1. of Shu, so ap serves as t%uu=sin(x+ap);

% work on kdv equ of Shu’s ex4.5% the residual R=-0.5*(u^2)_x-ap*(u_xxx)

Page 123: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

108 Computational Partial Differential Equations Using MATLAB

% i.e., u1=(u^2)_x, u2=u_xxxfunction uu=resshu5(u1,u2,ap)uu=-0.5*u1-ap*u2;

% Reconstruction for periodic function

function ux=reconuxp(u,N,h)

IEX=0; % 1 for explicit 4th-order schemeif IEX==1alfa=0; aa=2/3*(alfa+2); bb=(4*alfa-1)/3;for i=1:N

if i==1tmp =bb*(u(i+2)-u(N-2))/2+aa*(u(i+1)-u(N-1));

elseif i==2tmp =bb*(u(i+2)-u(N-1))/2+aa*(u(i+1)-u(i-1));

elseif i==(N-1)tmp=bb*(u(2)-u(i-2))/2+aa*(u(i+1)-u(i-1));

elseif i==Ntmp=bb*(u(3)-u(i-2))/2+aa*(u(2)-u(i-1));

elsetmp=bb*(u(i+2)-u(i-2))/2+aa*(u(i+1)-u(i-1));

endux(i)=tmp/(2*h);

endreturn

end

% below are implicit schemeISC=6; % order of the scheme% for C4 schemeif ISC==4

alfa=1.0/4.0; aa=3.0/2; bb=0;% for C6 schemeelseif ISC==6

alfa=1.0/3; aa=14.0/9; bb=1.0/9;end

amat=zeros(N,N);B=zeros(N,1);

for i=1:Nif i==1

Page 124: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 109

amat(1,1)=1; amat(1,2)=alfa; amat(1,N-1)=alfa;B(i)=bb*(u(3)-u(N-2))/4+aa*(u(2)-u(N-1))/2;

elseif i==2amat(2,1)=alfa; amat(2,2)=1; amat(2,3)=alfa;B(i)=bb*(u(4)-u(N-1))/4+aa*(u(3)-u(1))/2;

elseif i==N-1amat(i,i-1)=alfa; amat(i,i)=1; amat(i,i+1)=alfa;B(i)=bb*(u(2)-u(N-3))/4+aa*(u(N)-u(N-2))/2;

elseif i==Namat(N,1)=-1; amat(N,N)=1;B(i)=0;

else % i>=3 & i <=N-2amat(i,i-1)=alfa; amat(i,i)=1; amat(i,i+1)=alfa;B(i)=bb*(u(i+2)-u(i-2))/4+aa*(u(i+1)-u(i-1))/2;

endB(i)=B(i)/h;

end

% call trisys.mux=(amat\B)’;

%---------------------------------------------------------% implement 10th order filter for periodic function%---------------------------------------------------------function uf=filterLI(u,N)

ID=5; %10th-order filteraf=0.1;

a(1)=(193+126*af)/256;a(2)=(105+302*af)/256;a(3)=15*(-1+2*af)/64;a(4)=45*(1-2*af)/512;a(5)=5*(-1+2*af)/256;a(6)=(1-2*af)/512;

amat=zeros(N,N);B=zeros(N,1);

for i=1:Nif i==1

amat(1,1)=1; amat(1,2)=af; amat(1,N-1)=af;elseif i==N

amat(N,1)=-1; amat(N,N)=1;

Page 125: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

110 Computational Partial Differential Equations Using MATLAB

else % special for the 1st and last rowsamat(i,i-1)=af; amat(i,i)=1; amat(i,i+1)=af;

endB(i)=0;for k=0:ID

% try to keep i+k and i-k into the range of [1,N]k1=i+k;if k1 > N

k1=mod(k1,N-1);endk2=i-k;if k2 <=0

k2=k2+(N-1);end%disp(k1), disp(k2),B(i)=B(i)+a(k+1)*(u(k1)+u(k2));

end%disp(’----------’);

B(i)=B(i)/2;end

B(N)=0; % the last row is special% call linear system solveruf=(amat\B)’;

5.2 High-dimensional problems

Here we consider sixth-order compact schemes coupled with Alternating Di-rection Implicit (ADI) methods and apply it to 2-D and 3-D parabolic prob-lems ∗.

5.2.1 Temporal discretization for 2-D problems

Considering the efficiency of Alternating Direction Implicit (ADI) methodsfor solving 2-D or 3-D problems, we will use the ADI method in our im-plementation. Though ADI coupled with fourth-order compact schemes havebeen investigated in [1, 18, 6, 14], our derivations are quite different and much

∗This section is reprinted from Computers & Mathematics with Application, Vol.52, JichunLi, Yitung Chen and Guoqing Liu, High-order compact ADI methods for parabolic equa-tions, pp. 1343-1356, Copyright(2006), with permission from Elsevier.

Page 126: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 111

simpler as shown below. For clarity and generality, we present the algorithmfor the following 2-D parabolic equation:

ut = ν(uxx + uyy) + F (x, y, t), (x, y, t) ∈ Ω × (0, T ], (5.33)u(x, y, 0) = G(x, y), (x, y) ∈ Ω, (5.34)u(x, y, t)|∂Ω = H(x, y), t ∈ [0, T ], (5.35)

where the diffusion coefficient ν is a positive constant, Ω ≡ [0, 1]2, and ∂Ω isthe boundary of the domain.

To develop our high-order compact scheme, Ω is divided into a uniformmesh in each direction, i.e.,

xi = (i− 1)�x, i = 1, · · · , Nx; yj = (j − 1)�y, j = 1, · · · , Ny,where �x,�y are the mesh sizes in the x- and y-direction, respectively. Wedenote unij the approximate solution of u(i�x, j�y, n�t), where �t is thetime step.

By applying the Peaceman-Rachford ADI method [23] to (5.33), we have

un+1/2ij − unij

0.5�t = ν[(uxx)n+1/2ij + (uyy)nij ] + (F )n+1/2

ij , (5.36)

un+1ij − u

n+1/2ij

0.5�t = ν[(uxx)n+1/2ij + (uyy)n+1

ij ] + (F )n+1/2ij , (5.37)

where (F )n+1/2ij = F (xi, yj , (n + 1

2 )�t). Then all the derivatives in (5.36)-(5.37) are approximated by the sixth-order compact formulas developed in§2.1. For example, we can write

(uxx),j =1

(�x)2A−1Bu,j , (5.38)

where A and B are the corresponding Nx×Nx triangular and sparse matrices,u,j = (u1,j , u2,j, · · · , uNx,j)′ is the solution vector at the j-th row. Substituting(5.38) into (5.36) gives us

(Ix − 12ν

�t(�x)2A

−1B)un+1/2,j = un,j +

12�t[ν(uyy)n,j + F

n+1/2,j ], (5.39)

where Ix denotes the Nx ×Nx identity matrix.Similarly for the equation (5.37) in the y-direction, we can obtain

(Iy − 12ν

�t(�y)2C

−1D)un+1i, = u

n+1/2i, +

12�t[ν(uxx)n+1/2

i, + Fn+1/2i, ], (5.40)

by using

(uyy)i, =1

(�y)2C−1Dui,

Page 127: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

112 Computational Partial Differential Equations Using MATLAB

where C and D are the corresponding Ny×Ny triangular and sparse matrices,ui, = (ui,1, ui,2, · · · , ui,Ny)′ is the solution vector at the i-th column, and Iydenotes the Ny ×Ny identity matrix.

We like to mention that the above scheme has a truncation errorO((�t)2, (�x)6, (�y)6). Note that the coefficient matrices of (5.39) and (5.40)are time-independent, hence we can store the inverse of those coefficient ma-trices before the time-marching in the implementation for computational effi-ciency.

5.2.2 Stability analysis

To study the stability of our scheme, we use the von Neumann stability anal-ysis. For simplicity, we assume F ≡ 0 in (5.36)-(5.37), and u is periodic inboth x and y.

For the sixth-order compact scheme (5.7) for a periodic problem, the ma-trices A and B have the property

Aui = αui−1+ui+αui+1, Bui =b

4(ui+2−2ui+ui−2)+a(ui+1−2ui+ui−1).

Letunij = ξneI(wxi+wyj), I =

√−1

be the solution of (5.36)-(5.37), where wx = 2π�xlx

and wy = 2π�yly

are phaseangles with wavelengths lx and ly, respectively. It is easy to verify that

AeIwxi = eIwxi(αeIwx + 1 + αe−Iwx) = eIwxi(2α coswx + 1),

BeIwxi = eIwxi[b

4(eI2wx − 2 + e−I2wx) + a(eIwx − 2 + e−Iwx)]

= eIwxi[−b sin2 wx − 4a sin2 wx2

)].

Therefore, we have

(uxx)n+1/2ij =

1(�x)2A

−1Bun+1/2ij

=un+1/2ij

(�x)2(−b sin2 wx − 4a sin2 wx

2 )(2α coswx + 1)

. (5.41)

We denote

mx =12ν�t

(�x)2 , my =12ν�t

(�y)2 ,

and

γx =(−b sin2 wx − 4a sin2 wx

2 )(2α coswx + 1)

, γy =(−b sin2 wy − 4a sin2 wy

2 )(2α coswy + 1)

.

Page 128: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 113

Hence (5.41) can be written as

(uxx)n+1/2ij =

1(�x)2A

−1Bun+1/2ij =

1(�x)2 γxu

n+1/2ij . (5.42)

Similarly, it is easy to find that

(uyy)n+1ij =

1(�y)2C

−1Dun+1ij =

1(�y)2 γyu

n+1ij . (5.43)

Substituting (5.41) and (5.42) into (5.36) with F = 0, we obtain

(1 −mxγx)un+1/2ij = (1 +myγy)unij . (5.44)

In the same way, from (5.37) we can easily obtain

(1 −myγy)un+1ij = (1 +mxγx)u

n+1/2ij . (5.45)

From (5.44)-(5.45), we see that the amplification factor is

|ξ| = | un+1ij

un+1/2ij

| · |un+1/2ij

unij| = |1 +mxγx

1 −myγy· 1 +myγy1 −mxγx

| ≤ 1

whenever γx ≤ 0 and γy ≤ 0 hold true. It is easy to see that for our specialsixth-order scheme (5.7) with

α =211, a =

1211, b =

311, (5.46)

γx ≤ 0 and γy ≤ 0 hold true, which means that our scheme (5.36)-(5.37) isunconditionally stable in this case.

5.2.3 Extensions to 3-D compact ADI schemes

The above compact ADI scheme can be extended directly to the 3-D case,such as

ut = ν(uxx + uyy + uzz) + F (x, y, z, t), (x, y, z, t) ∈ Ω × (0, T ]. (5.47)

By applying the Douglas ADI method [7] to (5.47), we have

un+1/3ijk − unijk

�t = ν[12((uxx)

n+1/3ijk + (uxx)nijk) + (uyy)nijk + (uzz)nijk ]

+(F )n+1/2ijk , (5.48)

un+2/3ijk − u

n+1/3ijk

0.5�t = ν[(uyy)n+2/3ijk − (uyy)nijk ], (5.49)

un+1ijk − u

n+2/3ijk

0.5�t = ν[(uzz)n+1ijk − (uzz)nijk ], (5.50)

Page 129: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

114 Computational Partial Differential Equations Using MATLAB

where (F )n+1/2ijk = F (xi, yj, zk, (n + 1

2 )�t), and unijk denotes the approxi-mate solution of u(xi, yj , zk, tn). We approximate all the second derivatives in(5.48)-(5.50) by those sixth-order compact formulas developed previously.

Applying the similar technique used for 2-D, we can prove unconditionalstability of our scheme (5.48)-(5.50) with periodic boundary conditions. De-tails can be found in our paper [16]. Similar analysis can be carried out forother ADI schemes (e.g. [8]), and references can be found in books such as[11]. The stability for non-periodic cases can be pursued using other methodssuch as [3, 20], which is much more complicated and shall be further studied.

5.2.4 Numerical examples with MATLAB codes

Here we solve the 2-D diffusion problem

ut = uxx + uyy + f(x, y, t) (x, y) ∈ Ω ≡ (0, 1)2, 0 < t < 1 (5.51)

with periodic boundary conditions in both x and y directions, f = (16π2 −1)e−t(sin(4πx) + sin(4πy)) and properly selected initial condition so that theexact solution is given by

u(x, y, t) = e−t(sin(4πx) + sin(4πy)). (5.52)

This problem was solved by the ADI method (5.36)-(5.37) using the sixth-order scheme (5.7) to approximate those derivatives. The theoretical accuracyO((�t)2, (�x)6, (�y)6) was confirmed by solving the problem with variousmesh sizes and time step sizes. The results presented in Table 5.1 (witha fixed mesh size) show the convergence rate of O((�t)2) very well. Theresults presented in Table 5.2 (with a fixed small time step) demonstrate theconvergence rate of O((�x)6) very well. An examplary numerical solutionand maximum error are plotted in Fig. 5.14 for T = 1 solved by the attachedMATLAB code hoc2d.m with Nx = Ny = 51, dt = 1

80 . The computation wasperformed under MATLAB 6.0 installed on a laptop with Intel Pentium 3processor at 533MHz and 224MB RAM.

Page 130: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 115

00.2 0.4 0.6 0.8

1

00.2

0.40.6

0.81

−1

0

1

xy

u(x

,y,t

)

00.2 0.4 0.6 0.8

1

00.2

0.40.6

0.81

−1

0

1

x 10−3

xy

err

or=

u−

uexact

FIGURE 5.10The numerical solutions (Left) and pointwise errors (Right) at t = 1.0.

Page 131: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

116 Computational Partial Differential Equations Using MATLAB

TABLE 5.1

Maximum error at t = 1 with fixed mesh size �x = �y = 1/50

Time step size Maximum error Convergence rate CPU timeO((�t)r) (seconds)

�t = 1/10 7.2469e-4 4.90s�t = 1/20 3.1364e-4 1.2083 9.45s�t = 1/40 5.7551e-5 2.4462 17.40s�t = 1/80 1.4346e-5 2.0042 33.95s�t = 1/160 3.5438e-6 2.0173 67.05s�t = 1/320 8.4330e-7 2.0712 133.80s

TABLE 5.2

Maximum error at t = 1 with fixed time step size �t = 10−4

Mesh size Maximum error Convergence rate CPU timeO((�x)k) (seconds)

�x = �y = 1/10 9.2351e-4 218.90s�x = �y = 1/20 1.3497e-5 5.9470 746.02s�x = �y = 1/40 2.1695e-7 5.9591 2695.10s

Page 132: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 117

The MATLAB source code hoc2d.m and its auxiliary functions F2dconeF.m,F2dcone.m, reconux2p.m are attached below.

%--------------------------------------------------------------% hoc2d.m: solve 2D parabolic equ:% u_t=u_{xx}+u_{yy}+F(x,y,t), (x,y)\in (0,1)^2% by high-order compact ADI scheme.%% Other functions needed:% F2dconeF.m: source term F% F2dcone.m: the exact solution u% reconux2p.m: generate the matrix used by reconstruction%--------------------------------------------------------------clear all;

T=1; %hrXL=0; XR=1; % left and right end pointsNx=51; % total number of pointsdx=(XR-XL)/(Nx-1);YL=0; YR=1; % left and right end pointsNy=51; % total number of pointsdy=(YR-YL)/(Ny-1);

dt=1/80;uold=zeros(Nx,Ny);

Nstep=round(T/dt);

dtx=dt/dx; dty=dt/dy;

for i=1:NxXX(i)=XL+(i-1)*dx;

endfor i=1:Ny

YY(i)=YL+(i-1)*dy;end

% set up initial condfor i=1:Nx

for j=1:Nyuold(i,j)=F2dcone(XX(i),YY(j),0);

endend

%%%%%%%%%march-in-time%%%%%%%%%%%%

Page 133: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

118 Computational Partial Differential Equations Using MATLAB

matx=zeros(Nx,Nx); % define matrix for reconstructing u_xxmaty=zeros(Ny,Ny); % define matrix for reconstructing u_yy

matx=reconux2p(Nx,dx); % reconstruction in x-directionmaty=reconux2p(Ny,dy); % reconstruction in y-direction

t1=cputime;

Ainv=inv(eye(Nx,Nx)-0.5*dt*matx);Binv=inv(eye(Ny,Ny)-0.5*dt*maty);

for k=1:Nstep% reconstruct u_{yy}for i=1:Nx

tmp=(uold(i,1:Ny))’; % has to transposetmp2=maty*tmp; % construct u_yyuyy(i,1:Ny)=tmp2’;

end

% start ADI schemefor j=1:Ny

for i=1:NxTMPF(i,j)=0.5*dt*F2dconeF(XX(i),YY(j),(k-0.5)*dt);rhs(i)=uold(i,j)+0.5*dt*uyy(i,j)+TMPF(i,j);

enduHaf(1:Nx,j)=Ainv*rhs’;

end

% reconstruct u_{xx}for j=1:Ny

uxx(1:Nx,j)=matx*uHaf(1:Nx,j); % reconstruct u_{xx}end

for i=1:Nxfor j=1:Ny

rhs(j)=uHaf(i,j)+0.5*dt*uxx(i,j)+TMPF(i,j);endunew(i,1:Ny)=(Binv*rhs’)’;

end

uold=unew; % update for next time stepend

% draw numerical solution and max errorsif k == Nstep

Page 134: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 119

disp(’k=’), kerrL2=0;for i=1:Nx

for j=1:Ny% get the exact solutionu2d(i,j)=feval(@F2dcone,XX(i),YY(j),dt*k);errL2=errL2+(u2d(i,j)-unew(i,j))^2;

endenderrL2=sqrt(errL2/(Nx*Ny));

subplot(2,1,1), surf(XX,YY,unew’);xlabel(’x’); ylabel(’y’); zlabel(’u(x,y,t)’);subplot(2,1,2), surf(XX,YY,(unew-u2d)’);xlabel(’x’); ylabel(’y’); zlabel(’error=u-u_{exact}’);err=max(max(abs(unew-u2d)));disp(’L2 error=’),errL2,disp(’absolute max error=’), err,disp(’relative max error=’), err/max(max(abs(u2d))),

end

t_used=cputime-t1; % get time CPU time used in secondsdisp(’CPU time used=’), disp(t_used),

% Calculate the RHS function

function rhsF=F2dconeF(x,y,t)ID=4;if ID==1 % rotating cone model

rt=(2+sin(pi*t))/4;st=(2+cos(pi*t))/4;tmp=exp(-80*((x-rt)^2+(y-st)^2));ut=0.8*tmp*40*pi*((x-rt)*cos(pi*t)-(y-st)*sin(pi*t));uxx=0.8*tmp*(160^2*(x-rt)^2-160);uyy=0.8*tmp*(160^2*(y-st)^2-160);rhsF=ut-uxx-uyy;

elseif ID==2 % periodic function modelrhsF=0;

elseif ID==4rhsF=(-1+16*pi*pi)*exp(-t)*(sin(4*pi*x)+sin(4*pi*y));

end

%------------------------------------------------------% Calculate the exact solution of the given PDE

Page 135: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

120 Computational Partial Differential Equations Using MATLAB

function u2d=F2dcone(x,y,t)ID=4;if ID==1rt=(2+sin(pi*t))/4;st=(2+cos(pi*t))/4;u2d=0.8*exp(-80*((x-rt)^2+(y-st)^2));

elseif ID==2u2d=exp(-8*pi*pi*t)*sin(2*pi*x)*sin(2*pi*y);elseif ID==3u2d=exp(-t)*sin(4*pi*x)*sin(4*pi*y);elseif ID==4u2d=exp(-t)*(sin(4*pi*x)+sin(4*pi*y));

end

%-------------------------------------------------------% Ref to S.K. Lele’s 1992 paper% Reconstruct the 2nd derivative of a periodic function%-------------------------------------------------------function matAB=reconux2p(N,h)

matA=zeros(N,N); matB=zeros(N,N);% for interior point% for 6th-order scheme (2.2.7)alfa=2.0/11.0; aa=4./3.*(1-alfa); bb=1./3.*(-1+10*alfa);

for i=3:N-2matA(i,i)=1;matA(i,i+1)=alfa;matA(i,i-1)=alfa;matB(i,i-2)=bb/4;matB(i,i-1)=aa;matB(i,i)=-bb/2-2*aa;matB(i,i+1)=aa;matB(i,i+2)=bb/4;

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for boundary point 1: 6th-order at boundary nodes!!for i=1:1

matA(i,i)=1;matA(i,i+1)=alfa;matA(i,N-1)=alfa;

matB(i,N-2)=bb/4;

Page 136: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 121

matB(i,N-1)=aa;matB(i,i)=-bb/2-2*aa;matB(i,i+1)=aa;matB(i,i+2)=bb/4;

end%%%%%%%%%%%%%%%%%%%%%%%%%%%

% for boundry point 2for i=2:2

matA(i,i)=1;matA(i,i+1)=alfa;matA(i,i-1)=alfa;

matB(i,N-1)=bb/4;matB(i,i-1)=aa;matB(i,i)=-bb/2-2*aa;matB(i,i+1)=aa;matB(i,i+2)=bb/4;

end%%%%%%%%%%%%%%%%%%%%%%%%%%%% for boundary point N-1for i=N-1:N-1

matA(i,i)=1;matA(i,i+1)=alfa;matA(i,i-1)=alfa;

matB(i,i-2)=bb/4;matB(i,i-1)=aa;matB(i,i)=-bb/2-2*aa;matB(i,i+1)=aa;matB(i,2)=bb/4;

end%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for boundary point Nfor i=N:N

matA(i,i)=1;matA(i,2)=alfa;matA(i,i-1)=alfa;

matB(i,i-2)=bb/4;matB(i,i-1)=aa;matB(i,i)=-bb/2-2*aa;matB(i,2)=aa;matB(i,3)=bb/4;

end%%%%%%%%%%%%%%%%%%%%%%%

Page 137: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

122 Computational Partial Differential Equations Using MATLAB

matB=matB./(h*h);

%matA, matB,

matAB=inv(matA)*matB; % the matrix for u_xx=A^(-1)B*u

5.3 Other high-order compact schemes

Here we discuss another popular way to construct high-order compact differ-ence schemes (e.g., [25] and references cited therein). The basic idea is toapply central differences to the governing PDE and then repeatedly replacethose higher-order derivatives in the truncation error by low-order derivativesusing the PDE.

5.3.1 One-dimensional problems

To demonstrate the technique, let us start with a one-dimensional steady-stateproblem

−ad2u

dx2+ b

du

dx= s(x), x ∈ Ω, (5.53)

with corresponding Dirichlet boundary conditions. For simplicity, we assumethat a and b are constants, and a uniform mesh of Ω is used, which has aconstant mesh size h.

From Taylor expansions

ui+1 = ui + hu′i +h2

2u

′′i +

h3

6u

(3)i +

h4

24u

(4)i +

h5

120u

(5)i +O(h6),

and

ui−1 = ui − hu′i +h2

2u

′′i − h3

6u

(3)i +

h4

24u

(4)i − h5

120u

(5)i +O(h6),

we have

u′i = δxui − h2

6u

(3)i − h4

120u

(5)i +O(h6), (5.54)

u′′i = δ2xui −

h2

12u

(4)i − h4

360u

(6)i +O(h6), (5.55)

where we denote the standard first and second central difference operators

δxui =ui+1 − ui−1

2h, δ2xui =

ui+1 − 2ui + ui−1

h2. (5.56)

Page 138: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 123

Substituting (5.54) and (5.55) into (5.53), we obtain

−a(δ2xui −h2

12u

(4)i ) + b(δxui − h2

6u

(3)i ) = si +O(h4). (5.57)

Differentiating (5.53) with respect to x once and twice, respectively, we have

u(3) =1a(bu

′′ − s′) =b

au

′′ − 1as′, (5.58)

u(4) =1a(bu(3) − s

′′) =

b2

a2u

′′ − b

a2s′ − 1

as′′. (5.59)

Then replacing the second derivative u′′

in (5.58) and (5.59) by (5.55) andsubstituting into (5.57), we obtain

−a[δ2xui −h2

12(b2

a2u

′′i − b

a2s′i −

1as′′i )]

+b[δxui − h2

6(b

au

′′i − 1

as′i)] = si +O(h4),

which leads to a fourth-order compact difference scheme for (5.53):

−a(1 +b2h2

12a2)δ2xui + bδxui = si − bh2

12as′i +

h2

12s′′i . (5.60)

The above technique can be easily extended to the transient convection-diffusion equation

∂u

∂t+ b

∂u

∂x− a

∂2u

∂x2= s(x), x ∈ Ω, (5.61)

with proper initial condition and Dirichlet boundary conditions. Replacing sby s− ∂u

∂t in (5.60), we have

∂u

∂t|i +

h2

12a∂

∂t(au

′′i − bu′i) − a(1 +

b2h2

12a2)δ2xui + bδxui = si − bh2

12as′i +

h2

12s′′i ,

which, along with (5.54) and (5.55), leads to the fourth-order compact semi-discrete scheme for (5.61):

∂u

∂t|i + h2

12a∂

∂t(aδ2xui− bδxui)− a(1 +

b2h2

12a2)δ2xui+ bδxui = si− bh2

12as′i+

h2

12s′′i .

(5.62)Note that (5.62) is a tridiagonal semi-discrete system at each grid point

i. To get a fully discrete scheme, we can consider either the Runge-Kuttascheme or θ-scheme used for time-dependent problems. For example, theCrank-Nicolson scheme at point i at time level n for (5.62) can be written as

un+1i − uni

�t +h2

12a�t [aδ2x(u

n+1i − uni ) − bδx(un+1

i − uni )]

Page 139: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

124 Computational Partial Differential Equations Using MATLAB

−a(1 +b2h2

12a2) · 1

2δ2x(u

n+1i + uni ) + b · 1

2δx(un+1

i + uni )

=12(sn+1i + sni ) −

bh2

24a· ∂∂x

(sn+1i + sni ) +

h2

24· ∂

2

∂x2(sn+1i + sni ). (5.63)

By the von Neumann stability technique, it is easy to see that this scheme isunconditionally stable.

5.3.2 Two-dimensional problems

The above approach can be used for problems in higher spatial dimensions.For example, let us consider the 2-D transient diffusion problem:

∂u

∂t− a(

∂2u

∂x2+∂2u

∂y2) = s(x, y) in Ω, (5.64)

u|t=0 = f(x, y), in Ω, (5.65)u|∂Ω = g(x, y, t). (5.66)

Repeating the above procedure for b = 0, it is easy to obtain the fourth-order compact Crank-Nicolson scheme for (5.64):

un+1ij − unij

�t +h2

12�t [δ2x(u

n+1ij − unij) + δ2y(u

n+1ij − unij)]

−a2[δ2x(u

n+1ij + unij) + δ2y(u

n+1ij + unij) +

h2

6δ2xδ

2y(u

n+1i + uni )]

=12(sn+1ij + snij) +

h2

24∂2

∂x2(sn+1ij + snij) +

h2

24∂2

∂y2(sn+1ij + snij). (5.67)

Substituting snij = λne√−1kxihe

√−1kyjh into (5.67) with s = 0, we obtainthe amplification factor

λ =1 + ( 1

12 + a�t2h2 )(−4 sin2 1

2kxh− 4 sin2 12kyh) + a�t

12h2 (4 sin2 12kxh)(4 sin2 1

2kyh)

1 + ( 112 − a�t

2h2 )(−4 sin2 12kxh− 4 sin2 1

2kyh) − a�t12h2 (4 sin2 1

2kxh)(4 sin2 12kyh)

which is equivalent to

λ =1 − 1

3 (μx + μy) − a�th2 (2μx + 2μy − 4

3μxμy)

1 − 13 (μx + μy) + a�t

h2 (2μx + 2μy + 43μxμy)

where we denote μx = sin2 12kxh and μy = sin2 1

2kyh.It is easy to check that

−1 ≤ λ ≤ 1

holds true for any μx, μy,�t and h. Hence the scheme (5.67) is also uncondi-tionally stable.

Page 140: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 125

Finally, let us consider a variable coefficient problem such as the 2-D convection-diffusion equation

−(∂2u

∂x2+∂2u

∂y2) + a(x, y)

∂u

∂x+ b(x, y)

∂u

∂y= s(x, y) (5.68)

with Dirichlet boundary condition. For simplicity, we assume that mesh sizesin both x- and y-directions are h.

Using (5.54) and (5.55) for (5.68), we have

−(δ2xuij + δ2yuij) +h2

12(∂4uij∂x4

+∂4uij∂y4

) + aij(δxuij − h2

6∂3uij∂x3

)

+bij(δyuij − h2

6∂3uij∂y3

) = sij +O(h4). (5.69)

To obtain a fourth-order compact scheme, we need to replace those thirdand fourth derivatives in (5.69) by first and second central differences. Differ-entiating (5.68) with respect to x once and twice, respectively, we obtain

−∂3u

∂x3=

∂3u

∂x∂y2− ∂a

∂x

∂u

∂x− a

∂2u

∂x2− ∂b

∂x

∂u

∂y− b

∂2u

∂x∂y+∂s

∂x, (5.70)

and

∂4u

∂x4= − ∂4u

∂x2∂y2+∂2a

∂x2

∂u

∂x+ 2

∂a

∂x

∂2u

∂x2+ a

∂3u

∂x3

+∂2b

∂x2

∂u

∂y+ 2

∂b

∂x

∂2u

∂x∂y+ b

∂3u

∂x2∂y+∂2s

∂x2. (5.71)

Combining (5.70) and (5.71), and using (5.54) and (5.55) again, we have

(∂4u

∂x4− 2a

∂3u

∂x3)ij = [− ∂4u

∂x2∂y2+∂2a

∂x2

∂u

∂x+ 2

∂a

∂x

∂2u

∂x2+∂2b

∂x2

∂u

∂y

+2∂b

∂x

∂2u

∂x∂y+ b

∂3u

∂x2∂y+∂2s

∂x2+ a

∂3u

∂x∂y2− a

∂a

∂x

∂u

∂x

−a2∂2u

∂x2− a

∂b

∂x

∂u

∂y− ab

∂2u

∂x∂y+ a

∂s

∂x]ij

= −δ2xδ2yuij +∂2aij∂x2

δxuij + 2∂aij∂x

δ2xuij +∂2bij∂x2

δyuij

+2∂bij∂x2

δxδyuij + bijδ2xδyuij +

∂2sij∂x2

+ aijδxδ2yuij

−aij ∂aij∂x

δxuij − a2ijδ

2xuij − aij

∂bij∂x

δyuij

−aijbijδxδyuij + aij∂sij∂x

+O(h2). (5.72)

Page 141: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

126 Computational Partial Differential Equations Using MATLAB

Similarly, we have

−∂3u

∂y3=

∂3u

∂y∂x2− ∂a

∂y

∂u

∂x− a

∂2u

∂y∂x− ∂b

∂y

∂u

∂y− b

∂2u

∂y2+∂s

∂y,

∂4u

∂y4= − ∂4u

∂x2∂y2+∂2a

∂y2

∂u

∂x+ 2

∂a

∂y

∂2u

∂y∂x+ a

∂3u

∂y2∂x

+∂2b

∂y2

∂u

∂y+ 2

∂b

∂y

∂2u

∂y2+ b

∂3u

∂y3+∂2s

∂y2,

and

(∂4u

∂y4− 2b

∂3u

∂y3)ij = [− ∂4u

∂x2∂y2+∂2a

∂y2

∂u

∂x+ 2

∂a

∂y

∂2u

∂y∂x+ a

∂3u

∂y2∂x

+∂2b

∂y2

∂u

∂y+ 2

∂b

∂y

∂2u

∂y2+∂2s

∂y2+ b

∂3u

∂y∂x2

−b∂a∂y

∂u

∂x− ba

∂2u

∂y∂x− b

∂b

∂y

∂u

∂y− b2

∂2u

∂y2+ b

∂s

∂y]ij

= −δ2xδ2yuij +∂2aij∂y2

δxuij + 2∂aij∂y

δyδxuij + aijδ2yδxuij

+∂2bij∂y2

δyuij + 2∂bij∂y

δ2yuij +∂2sij∂y2

+ bijδyδ2xuij

−bij ∂aij∂y

δxuij − bijaijδyδxuij

−bij ∂bij∂y

δyuij − b2ijδ2yuij + bij

∂sij∂y

+O(h2). (5.73)

Substituting (5.72) and (5.73) into (5.69) gives us a fourth-order compactscheme for (5.68). This scheme only involves 9 points.

In the special case of a = b = constant, the fourth-order compact scheme(5.73) can be simplified to

−(1 +h2a2

12)δ2xuij − (1 +

h2b2

12)δ2yuij

+h2

6[−δ2xδ2yuij + aδxδ

2yuij + bδyδ

2xuij − abδxδyuij ] + aδxuij + bδyuij

= sij − h2

12[∂2sij∂x2

+∂2sij∂y2

+ a∂sij∂x

+ b∂sij∂y

]. (5.74)

For the special case of a = b = 0 (i.e., the diffusion problem), the scheme(5.74) can be reduced further to

−(δ2xuij + δ2yuij +h2

6δ2xδ

2yuij) = sij − h2

12(∂2sij∂x2

+∂2sij∂y2

). (5.75)

Page 142: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 127

Multiplying both sides of (5.75) by 6h2 and expanding it, we see that (5.75)becomes

−[6(ui+1,j − 2uij + ui−1,j) + 6(ui,j+1 − 2uij + ui,j−1)+(ui+1,j+1 − 2ui,j+1 + ui−1,j+1) − 2(ui+1,j − 2uij + ui−1,j)+(ui+1,j−1 − 2ui,j−1 + ui−1,j−1)]

= 6h2sij − h2

2[(si+1,j − 2sij + si−1,j) + (si,j+1 − 2sij + si,j−1)],

which can be simplified to the 9-point fourth-order scheme (4.69) obtained inChapter 4.

5.4 Bibliographical remarks

Extensions of compact schemes to nonuniform mesh is trivial but very tech-nical, and interested readers can find more details in papers such as [10, 33]and references cited therein. To increase accuracy, the so-called combinedcompact difference scheme was proposed [4, 19], which solves for first andsecond derivatives synchronously. To our best knowledge, books specificallycovering high-order difference methods are not many [5, 11, 27]. Gustafssonet al. [11] provide solid mathematical theory on both the Fourier methodand the energy method for building stable difference schemes. Some fourth-order schemes are analyzed for hyperbolic and parabolic equations. Cohen[5] introduces some classical fourth-order schemes in time and space for thewave equations. Detailed numerical analysis on dispersion and stability ofthe schemes is provided in his book. Tolstykh introduces high-order schemesusing compact upwind differencing in his book [27], where arbitrary odd (e.g.,third, fifth, seventh) order schemes are constructed and used for hyperbolicsystems and convection-diffusion equations.

5.5 Exercises

1. Using the Taylor expansion, prove that with a = 23 (α+2) and b = 1

3 (4α−1),the scheme (5.1) is fourth-order accurate. Find out the leading two terms forthe truncation error.

2. Use the Taylor expansion to prove that with coefficients (5.30)-(5.31),the filter (5.29) is indeed tenth–order.

Page 143: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

128 Computational Partial Differential Equations Using MATLAB

3. Modify the code hoc2d.m and its auxiliary functions to solve the problem

ut = uxx + uyy + f(x, y, t) (x, y) ∈ Ω ≡ (0, 1)2, 0 < t < 2 (5.76)

with properly selected initial condition and Dirichlet boundary condition sothat the exact solution is given by

u(x, y, t) = 0.8 exp(−80[(x− r(t))2 + (y − s(t))2]) (5.77)

wherer(t) =

14(2 + sinπt), s(t) =

14(2 + cosπt).

Note that the solution is a cone that is initially centered at (12 ,

34 ) and rotates

around the center of the domain Ω in a clockwise direction.4. Consider the wave equation

∂2u

∂t2− c2

∂2u

∂x2= 0, (x, t) ∈ (0, 1) × (0, tF ), (5.78)

where c > 0 is a constant. Prove that the semi-discrete scheme

1c2d2ujdt2

− 43uj+1 − 2uj + uj−1

h2+

13uj+2 − 2uj + uj−2

4h2= 0, (5.79)

has truncation error O(h4), where uj is the approximate solution of u(xj , t)at points xj = jh, 0 ≤ j ≤ J, h = 1

J . Then use the Taylor expansion and thegoverning equation (5.78) to derive the following fourth-order scheme (in bothtime and space):

un+1j − 2unj + un−1

j

τ2− 4c2

3unj+1 − 2unj + unj−1

h2+c2

3unj+2 − 2unj + unj−2

4h2

−c4τ2

12unj+2 − 4unj+1 + 6unj − 4unj−1 + unj−2

h4= 0,

where τ is the time step. Hint: Start with the Taylor expansion

un+1j − 2unj + un−1

j

τ2=∂2u

∂t2(xj , nτ) +

τ2

12∂4u

∂t4(xj , nτ) +O(τ4).

5. Extend the idea of Exercise 4 to the wave equation in an inhomogeneousmedium

∂2u

∂t2− ∂

∂x(μ(x)

∂u

∂x) = 0

by developing a five-point fourth-order scheme in both time and space.6. Show that the two-stage Runge-Kutta (RK2) method (5.25)-(5.28) can

be written as

Un+1 = Un +�t2

[R(Un) +R(Un + �tR(Un))].

Page 144: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 129

Then use the Taylor expansion to prove that its truncation error is O(�t2).7. To approximate the fourth derivatives, we can construct the difference

scheme

αf(4)i−1 + f

(4)i + αf

(4)i+1

=a

h4(fi+2 − 4fi+1 + 6fi − 4fi−1 + fi−2)

+b

6h4(fi+3 − 9fi+1 + 16fi − 9fi−1 + fi−3). (5.80)

Prove that a family of fourth-order schemes can be defined by

a = 2(1 − α), b = 4α− 1,

and the truncation error of this scheme is 7−26α240 h4f (8).

8. Prove that the resolution characteristics of the scheme (5.80) is

ω(4)appr = [2a(cos 2ω − 4 cosω + 3)

+b

3(cos 3ω − 9 cosω + 8)]/(1 + 2α cosω).

9. Derivatives can be evaluated using staggered grids on which the functionvalues are prescribed. For example, we can construct the following scheme

αf′i−1 + f

′i + αf

′i+1

=a

h(fi+ 1

2− fi− 1

2) +

b

3h(fi+ 3

2− fi− 3

2).

Prove that a family of fourth-order schemes can be obtained by

a =38(3 − 2α), b =

18(22α− 1),

and the truncation error of this scheme is 9−62α1920 h4f (5).

10. Prove that the following combined compact difference schemes

7f′i−1 + 16f

′i + 7f

′i+1 + h(f

′′i−1 − f

′′i+1) =

15h

(fi+1 − fi−1)

and

−f ′′i−1 + 8f

′′i − f

′′i+1 +

9h

(f′i+1 − f

′i−1) =

24h2

(fi+1 − 2fi + fi−1)

are six-order accurate. Find the leading term for the truncation error of eachscheme.

Page 145: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

130 Computational Partial Differential Equations Using MATLAB

References

[1] Y. Adam. Highly accurate compact implicit methods and boundaryconditions. J. Comp. Phys., 24:10–22, 1977.

[2] M.H. Carpenter, D. Gottlieb and S. Abarbanel. Time-stable bound-ary conditions for finite-difference schemes solving hyperbolic systems:methodology and application to high-order compact system. J. Comp.Phys., 111:220–236, 1994.

[3] M.H. Carpenter, D. Gottlieb and S. Abarbanel. Stable and accurateboundary treatments for compact high order finite difference schemes.Appl. Numer. Math., 12:55–87, 1993.

[4] P.C. Chu and C. Fan. A three-point combined compact differencescheme. J. Comp. Phys., 140:370–399, 1998.

[5] G.C. Cohen. Higher-Order Numerical Methods for Transient WaveEquations. Springer-Verlag, Berlin, 2002.

[6] W. Dai and R. Nassar. Compact ADI method for solving parabolic dif-ferential equations. Numer. Methods for Partial Differential Equations,18:129–142, 2002.

[7] J. Douglas. Alternating direction methods for three space variables.Numer. Math., 4:41–63, 1962.

[8] J. Douglas and J.E. Gunn. A general formulation of alternating directionmethods – Part I. parabolic and hyperbolic problems. Numer. Math.,6:428–453, 1964.

[9] D.V. Gaitonde and M.R. Visbal. High-order schemes for Navier-Stokesequations: algorithms and implementation into FDL3DI. TechnicalReport AFRL-VA-WP-TR-1998-3060, Air Force Research Laboratory,Wright-Patterson AFB, Ohio, 1998.

[10] W.J. Goedheer and J.H.M. Potters. A compact finite difference schemeon a nonequidistance mesh. J. Comp. Phys., 61:269–279, 1985.

[11] B. Gustafsson, H.-O. Kreiss and J. Oliger. Time Dependent Problemsand Difference Methods. Wiley, New York, 1995.

[12] R. Hixon and E. Turkel. Compact implicit MacCormack-type schemeswith high accuracy. J. Comp. Phys., 158:51–70, 2000.

[13] F.Q. Hu, M.Y. Hussaini and J.L. Manthey. Low-dissipation and low-dispersion Runge-Kutta schemes for computational acoustics. J. Comp.Phys., 124:177–191, 1996.

Page 146: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

High-Order Compact Difference Methods 131

[14] S. Karaa and J. Zhang. High order ADI method for solving unsteadyconvection-diffusion problems. J. Comp. Phys., 198:1–9, 2004.

[15] S.K. Lele. Compact finite difference schemes with spectral-like solution.J. Comp. Phys., 103:16–42, 1992.

[16] J. Li, Y. Chen and G. Liu. High-order compact ADI methods forparabolic equations. Comp. Math. Appl., 52:1343–1356, 2006.

[17] J. Li and M.R. Visbal. High-order compact schemes for nonlinear dis-persive waves. J. Sci. Comput., 26(1):1–23, 2006.

[18] W. Liao, J. Zhu and A.Q.M. Khaliq. An efficient high-order algorithmfor solving systems of reaction-diffusion equations. Numer. Methods forPartial Differential Equations, 18:340–354, 2002.

[19] K. Mahesh. A family of high order finite difference schemes with goodspectral resolution. J. Comp. Phys., 145:332–358, 1998.

[20] K. Mattsson and J. Nordstrom. Summation by parts operators for fi-nite difference approximations of second derivatives. J. Comp. Phys.,199:503–540, 2004.

[21] I.M. Navon and H.A. Riphagen. An implicit compact fourth order algo-rithm for solving the shallow-water equations in conservation-law form.Monthly Weather Review, 107:1107–1127, 1979.

[22] I.M. Navon and H.A. Riphagen. SHALL4 – An implicit compactfourth-order Fortran program for solving the shallow-water equationsin conservation-law form. Computers & Geosciences, 12:129–150, 1986.

[23] D.W. Peaceman and H.H. Rachford. The numerical solution of parabolicand elliptic differential equations. J. Soc. Indust. Appl. Math., 3:28–41,1955.

[24] J.S. Shang. High-order compact-difference schemes for time-dependentMaxwell equations. J. Comp. Phys., 153:312–333, 1999.

[25] W.F. Spotz and G.F. Carey. Extension of high order compact schemesto time dependent problems. Numer. Methods for Partial DifferentialEquations, 17:657–672, 2001.

[26] C.K.W. Tam and J.C. Webb. Dispersion-relation-preserving finite differ-ence schemes for computational acoustics. J. Comp. Phys., 107:262–281,1993.

[27] A.I. Tolstykh. High Accuracy Non-Centered Compact DifferenceSchemes for Fluid Dynamics Applications. World Scientific, Hacken-sack, NJ, 1994.

[28] R. Vichnevetsky and J.B. Bowles. Fourier Analysis of Numerical Ap-proximations of Hyperbolic Equations. SIAM, Philadelphia, 1982.

Page 147: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

132 Computational Partial Differential Equations Using MATLAB

[29] M.R. Visbal and D.V. Gaitonde. High-order-accurate methods for com-plex unsteady subsonic flows. AIAA J., 37:1231–1239, 1999.

[30] M.R. Visbal and D.V. Gaitonde. Very high-order spatially implicitschemes for computational acoustics on curvilinear meshes. J. Comput.Acoustics, 9:1259–1286, 2001.

[31] M.R. Visbal and D.V. Gaitonde. On the use of higher-order finite-difference schemes on curvilinear and deforming meshes. J. Comp. Phys.,181:155–185, 2002.

[32] J. Yan and C.-W. Shu. A local discontinuous Galerkin method for KdVtype equations. SIAM J. Numer. Anal., 40:769–791, 2002.

[33] X. Zhong and M. Tatineni. High-order non-uniform grid schemes for nu-merical simulation of hypersonic boundary-layer stability and transition.J. Comp. Phys., 190:419–458, 2003.

Page 148: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

6

Finite Element Methods: Basic Theory

It is known that finite difference methods are not very good at handling irreg-ularly shaped domains. The finite element method can overcome this disad-vantage. It is arguably that the most robust and popular method for solvingdifferential equations is the finite element method (FEM), which was first con-ceived by Courant [17], who used a group of triangular elements to study theSt. Venant torsion problem. Then engineers independently re-invented themethod in the early 1950s. The early contributions are attributed to Argyris[5], and Turner, Clough, Martin and Topp [42], etc. The term “finite element”was proposed by Clough [16]. Today, FEMs have become the mainstream nu-merical methods for solving all kinds of PDEs as evidenced by the wide useof many advanced commercial packages.

In this chapter, we will introduce the finite element method and relatedfundamental theory. In Sec. 6.1 and Sec. 6.2, we illustrate the finite elementmethod through some 1-D and 2-D examples, respectively. Then we discusssome fundamental theory needed for analyzing the finite element method inSec. 6.3. In Sec. 6.4 and Sec. 6.5, we present some commonly used conformingand nonconforming finite element spaces, respectively. Basic finite elementinterpolation theory is introduced in Sec. 6.6. Sec. 6.7 is devoted to the erroranalysis for elliptic problems. Both conforming and nonconforming elementsare discussed. Finally, in Sec. 6.8 we discuss the finite element method forparabolic equations. Practical programming of the finite element method willbe introduced in the next chapter.

6.1 Introduction to one-dimensional problems

6.1.1 The second-order equation

As an introduction, we start with a two-point boundary value problem

−d2u

dx2= f(x), 0 < x < 1, (6.1)

u(0) = u(1) = 0, (6.2)

where f is a given real-valued piecewise continuous bounded function.

133

Page 149: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

134 Computational Partial Differential Equations Using MATLAB

Before we introduce FEM, we need to define the notation

(v, w) =∫ 1

0

v(x)w(x)dx,

for real-valued piecewise continuous bounded functions. We also need thelinear space

V = {v : v is a continuous function on [0,1],dv

dxis piecewise continuous and bounded, and v(0) = v(1) = 0}. (6.3)

Multiplying (6.1) by an arbitrary function v ∈ V , a so-called test function,and integrating over the interval (0, 1), we have

−(d2u

dx2, v) = (f, v).

Then integrating by parts and using the fact that v(0) = v(1) = 0, we obtaina variational problem

(du

dx,dv

dx) = (f, v) ∀ v ∈ V. (6.4)

Equation (6.4) is called a weak form of (6.1)-(6.2). On the other hand, ifwe assume that d2u

dx2 exists and is piecewise continuous, then we can integratethe left-hand side by parts and use the fact that v(0) = v(1) = 0, we have

−(d2u

dx2+ f, v) = 0 ∀ v ∈ V,

which yields

(d2u

dx2+ f)(x) = 0, 0 < x < 1,

under the assumption that d2udx2 and f are piecewise continuous and bounded

on [0, 1]. Hence the original problem (6.1)-(6.2) is equivalent to the variationalproblem (6.4) under proper regularity assumptions.

Since the space V is of infinite dimension, we want to approximate it by afinite dimensional subspace Vh. To that end, we divide the interval [0, 1] intosubintervals

Ij = [xj−1, xj ], 1 ≤ j ≤ N + 1,

with length hj = xj − xj−1, where N is a positive integer, and

0 = x0 < x1 < · · · < xN < xN+1 = 1. (6.5)

We denote h = max1≤j≤N+1 hj. Note that the mesh size h is used tomeasure how fine the partition is.

Page 150: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 135

FIGURE 6.1The hat function: p1 basis function in 1-D.

Now we can define the finite element space

Vh = {v : v is a continuous function on [0,1],v is linear on each subinterval Ij , and v(0) = v(1) = 0}. (6.6)

Comparing (6.3) and (6.6), we see that Vh ⊂ V , i.e., Vh is indeed a subspaceof V . Let us now introduce the linear basis function φj(x) ∈ Vh, 1 ≤ j ≤ N ,which satisfies the property

φj(xi) ={

1 if i = j,0 if i �= j,

i.e., φj(x) is piecewise continuous on [0, 1] and its value is one at node j andzero at other nodes. More specifically, φj(x) is given by

φj(x) =

⎧⎪⎨

⎪⎩

x−xj−1hj

, if x ∈ [xj−1, xj ],xj+1−xhj+1

, if x ∈ [xj , xj+1],0 elsewhere.

(6.7)

Since the shape of φj looks like a hat, φj(x) is often called a hat function (seeFigure 6.1).

Note that any function v ∈ Vh has a unique representation

v(x) =N∑

j=1

vjφj(x), x ∈ [0, 1], (6.8)

where vi = v(xi), i.e., Vh is a linear space of dimension N with basis function{φj}Nj=1.

With all the above preparations, we can now formulate the finite elementmethod for the problem (6.1)-(6.2) as follows: Find uh ∈ Vh such that

(duhdx

,dv

dx) = (f, v) ∀ v ∈ Vh. (6.9)

Page 151: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

136 Computational Partial Differential Equations Using MATLAB

From the unique representation (6.8), we can set the finite element solutionuh of (6.9) as

uh(x) =N∑

j=1

ujφj(x), uj = uh(xj).

Substituting uh(x) into (6.9) and choosing v = φi(x) in (6.9) for each i, weobtain

N∑

j=1

(dφjdx

,dφidx

)uj = (f, φi) 1 ≤ i ≤ N, (6.10)

which is a linear system of N equations in N unknowns uj. The system canbe written in matrix form

Au = F, (6.11)

where A = (aij) is an N × N matrix with elements aij = (dφj

dx ,dφi

dx ), u =(u1, · · · , uN)T is an N -dimensional vector, and F = (F1, · · · , FN )T is an N -dimensional vector with elements Fi = (f, φi).

The matrix A is called the stiffness matrix and F the load vector. From(6.7), we can explicitly calculate the matrix A. From (6.7), we easily have

(dφjdx

,dφjdx

) =∫ xj

xj−1

1h2j

dx+∫ xj+1

xj

1h2j+1

dx =1hj

+1

hj+1, 1 ≤ j ≤ N,

(dφjdx

,dφj−1

dx) = (

dφj−1

dx,dφjdx

) =∫ xj

xj−1

−1h2j

dx = − 1hj, 2 ≤ j ≤ N,

(dφjdx

,dφidx

) = 0 if |j − i| > 1.

Thus the matrix A is tri-diagonal, i.e., only elements in the main diagonaland the two adjacent diagonals to the main diagonal are non-zero.

Note thatN∑

i,j=1

vj(dφjdx

,dφidx

)vi = (N∑

j=1

vjdφjdx

,

N∑

i=1

vidφidx

) ≥ 0,

and the equality holds only if dvdx ≡ 0, where we denote v(x) =

∑Nj=1 vjφj(x).

Noting that v(0) = 0, hence dvdx ≡ 0 is equivalent to v(x) ≡ 0, or vj = 0 for

all j = 1, · · · , N. Therefore the matrix A is symmetric and positive definite,which guarantees that A is non-singular, i.e., the linear system (6.11) has aunique solution.

6.1.2 The fourth-order equation

In this subsection, we consider a fourth-order problem

d4u

dx4= f(x), 0 < x < 1, (6.12)

Page 152: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 137

u(0) = u(1) =du

dx(0) =

du

dx(1) = 0, (6.13)

where f is a given real-valued piecewise continuous bounded function. Forthis problem, we need the linear space

V = {v : v anddv

dxare continuous on [0,1],

d2v

dx2is piecewise continuous,

and v(0) = v(1) =dv

dx(0) =

dv

dx(1) = 0}. (6.14)

Multiplying (6.12) by a test function v ∈ V , integrating over the interval(0, 1) and using the boundary condition (6.13), we can obtain

(d2u

dx2,d2v

dx2) = (f, v) ∀ v ∈ V. (6.15)

Similar to the previous subsection, it can be proved that (6.12)-(6.13) isequivalent to the weak form (6.15).

Using the same partition (6.5) as in the previous subsection, we can definethe finite element space

Vh = {v : v anddv

dxare continuous on [0,1],

v is a polynomial of degree 3 on each subinterval Ij ,

and v(0) = v(1) =dv

dx(0) =

dv

dx(1) = 0}, (6.16)

which is a subspace of V , i.e., we have Vh ⊂ V .On each subinterval Ij = [xj−1, xj ], any polynomial of degree 3 (i.e., v(x) ∈

P3(Ij)) can be uniquely determined by the values

v(xj−1), v(xj),dv

dx(xj−1),

dv

dx(xj).

The basis function corresponding to the value v(xj−1) is a cubic polynomialv such that

v(xj−1) = 1, v(xj) =dv

dx(xj−1) =

dv

dx(xj) = 0. (6.17)

It is easy to see that this basis function can be represented as

φj−1(x) = (x − xj)2(ax+ b). (6.18)

Letting φj−1(xj−1) = 1 and dφj−1dx (xj−1) = 0, we obtain

h2j(axj−1 + b) = 1,

−2hj(axj−1 + b) + ah2j = 0,

Page 153: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

138 Computational Partial Differential Equations Using MATLAB

which lead to a = 2h3

j, b = 1

h3j(hj − 2xj−1). Substituting a and b into (6.18),

we obtain the basis function

φj−1(x) =1h3j

(x− xj)2[hj + 2(x− xj−1)], xj−1 ≤ x ≤ xj . (6.19)

Similarly, the basis function corresponding to the value v(xj) must satisfy

v(xj) = 1, v(xj−1) =dv

dx(xj−1) =

dv

dx(xj) = 0. (6.20)

Skipping the details, we can derive the basis function as

φj(x) =1h3j

(x− xj−1)2[hj − 2(x− xj)], xj−1 ≤ x ≤ xj . (6.21)

In the same way, the basis function corresponding to the value dvdx(xj−1)

must satisfy

dv

dx(xj−1) = 1, v(xj−1) = v(xj) =

dv

dx(xj) = 0.

It can be checked that this basis function is given by

ψj−1(x) =1h2j

(x − xj)2(x − xj−1). (6.22)

Finally, the basis function corresponding to the value dvdx(xj) must satisfy

dv

dx(xj) = 1, v(xj−1) = v(xj) =

dv

dx(xj−1) = 0.

This basis function can be derived similarly as above and is given by

ψj(x) =1h2j

(x− xj−1)2(x− xj), xj−1 ≤ x ≤ xj . (6.23)

From the definition (6.16), we know that any v ∈ Vh can be uniquelyrepresented as

v(x) =N∑

j=1

[vjφj(x) + v′jψj(x)], vj = v(xj), v′j(x) =dv

dx(xj). (6.24)

Now we can formulate the finite element method for the problem (6.12)-(6.13): Find uh ∈ Vh such that

(d2uhdx2

,d2v

dx2) = (f, v) ∀ v ∈ Vh. (6.25)

Page 154: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 139

Substituting the finite element solution uh of (6.25)

uh(x) =N∑

j=1

[ujφj(x) + u′jψj(x)], (6.26)

into (6.25) and choosing v = φi(x) and ψi(x), respectively, in (6.25), we obtain

N∑

j=1

(d2φjdx2

,d2φidx2

)uj +N∑

j=1

(d2ψjdx2

,d2φidx2

)u′j = (f, φi), 1 ≤ i ≤ N, (6.27)

N∑

j=1

(d2φjdx2

,d2ψidx2

)uj +N∑

j=1

(d2ψjdx2

,d2ψidx2

)u′j = (f, ψi), 1 ≤ i ≤ N, (6.28)

which is a linear system of 2N equations in unknowns uj and u′j .The above system can be written in matrix form

(A BBT C

)(uu′

)=(FφFψ

), (6.29)

where A = (aij) is an N × N matrix with element aij = (d2φj

dx2 ,d2φi

dx2 ), B =

(bij) is an N × N matrix with element bij = (d2ψj

dx2 ,d2φi

dx2 ), C = (cij) is an

N × N matrix with element cij = (d2ψj

dx2 ,d2ψi

dx2 ), BT is the transpose of B.Furthermore, we denote the N -dimensional vectors

u = (u1, · · · , uN)T , u′ = (u′1, · · · , u′N)T ,

andFφ = ((f, φ1), · · · , (f, φN ))T , Fψ = ((f, ψ1), · · · , (f, ψN ))T .

The coefficient matrix of (6.29) can be proved to be symmetric and positivedefinite, which guarantees that the solution of our finite element method (6.25)exists and is unique. To prove the positive definiteness, multiplying the left-hand side of (6.27) by ui and sum up i, multiplying the left-hand side of (6.28)by u′i and sum up i, and adding them together, we have

(u, u′) ·(A BBT C

)(uu′

)= (

d2uh(x)dx2

,d2uh(x)dx2

) ≥ 0,

with equality only if d2uh(x)dx2 ≡ 0.Considering the boundary conditions duh

dx (0) =duh

dx (1) = 0, we see thatduh(x)dx

≡ 0,

which, along with the boundary conditions uh(0) = uh(1) = 0, yields uh(x) ≡0. Hence the positive definiteness of matrix

(A BBT C

)is proved.

Page 155: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

140 Computational Partial Differential Equations Using MATLAB

6.2 Introduction to two-dimensional problems

6.2.1 The Poisson’s equation

In this subsection, we consider the Poisson’s equation:

−�u = f(x1, x2) in Ω, (6.30)u = 0 on ∂Ω, (6.31)

where Ω is a bounded domain in the plane with boundary ∂Ω, f is a givenreal-values piecewise continuous bounded function in Ω, and the Laplacianoperator � is defined as

�u =∂2u

∂x21

+∂2u

∂x22

.

Recall that in two dimensions, we have the divergence theorem∫

Ω

∇ · bdx =∫

∂Ω

b · nds, (6.32)

where b = (b1, b2) is a vector-valued function defined in Ω, the divergenceoperator

∇ · b =∂b1∂x1

+∂b2∂x2

,

and n = (n1, n2) is the outward unit normal to ∂Ω. Here dx denotes theelement of area, and ds the element of arc length along ∂Ω.

If we apply the divergence theorem to b = (w ∂v∂x1

, 0) and b = (0, w ∂v∂x2

),respectively, we find that

Ω

(w∂2v

∂x21

+∂v

∂x1

∂w

∂x1)dx =

∂Ω

w∂v

∂x1n1ds, (6.33)

and ∫

Ω

(w∂2v

∂x22

+∂v

∂x2

∂w

∂x2)dx =

∂Ω

w∂v

∂x2n2ds. (6.34)

Denote by ∇v the gradient of v, i.e., ∇v = ( ∂v∂x1, ∂v∂x2

). Adding (6.33) and(6.34) together, we obtain the following Green’s formula:

Ω

(w�v + ∇v · ∇w)dx =∫

∂Ω

w · ∂v∂nds, (6.35)

where we denote by ∂v∂n the normal derivative

∂v

∂n=

∂v

∂x1n1 +

∂v

∂x2n2.

Page 156: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 141

FIGURE 6.2An exemplary finite element triangulation.

Before continuing, we introduce the linear space

V = {v : v is continuous on, Ω,∂v

∂x1and

∂v

∂x2

are piecewise continuous on Ω, and v = 0 on ∂Ω}. (6.36)

Multiplying (6.30) by a test function v ∈ V , integrating over Ω, and usingthe Green’s formula (6.35) and the homogeneous boundary condition, we ob-tain the variational formulation of problem (6.30)-(6.31): Find u ∈ V suchthat

a(u, v) = (f, v) ∀ v ∈ V, (6.37)

where

a(u, v) =∫

Ω

∇u · ∇vdx, (f, v) =∫

Ω

fvdx.

As in the 1-D case, we can prove that variational problem (6.37) is equiva-lent to the original problem (6.30)-(6.31).

We now construct a finite dimensional subspace Vh of V . For simplicity, weassume that Ω is a polygonal domain (i.e., ∂Ω is a polygonal curve). Let usnow make a partition of Ω, called a triangulation, by subdividing Ω into a setTh of non-overlapping triangles Ki, i.e.,

Ω = ∪K∈ThK = K1 ∪K2 ∪ · · · ∪Km,

such that no vertex of one triangle lies in the interior of the edge of anothertriangle (cf. Fig. 6.2).

We introduce the mesh notation

h = maxK∈Th

diam(K), diam(K) = longest side of K,

Page 157: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

142 Computational Partial Differential Equations Using MATLAB

and the finite element space

Vh = {v : v is continuous on, Ω, vis linear on each triangle K ∈ Th, and v = 0 on ∂Ω}, (6.38)

from which and (6.36), we see that Vh ⊂ V .Assume that Th contains N interior vertices xi, 1 ≤ i ≤ N ; then we can

define a basis function φj ∈ Vh for each interior vertex satisfying

φj(xi) = δij ≡{

1 if i = j,0 if i �= j.

Notice that the support of φj (the set of point x such that φj(x) �= 0) con-sists of the triangles with the common vertex xj . Furthermore, any functionv ∈ Vh has the unique representation

v(x) =N∑

j=1

vjφj(x), vj = v(xj). (6.39)

With all the above preparations, now we can formulate the finite elementmethod for (6.30)-(6.31): Find uh ∈ Vh such that

a(uh, v) = (f, v) ∀ v ∈ Vh. (6.40)

Exactly as in the 1-D case, we can show that (6.40) is equivalent to a linearsystem

Au = F,

where A = (aij) is an N × N matrix with element aij = (∇φj ,∇φi), andF = (Fi) is an N -dimensional vector with element Fi = (F, φi). Furthermore,the matrix A is symmetric positive definite so that the solution uh of (6.40)exists and is unique.

6.2.2 The biharmonic problem

Let us now consider a fourth-order problem in 2-D, namely the biharmonicproblem

�2u = f(x1, x2) in Ω, (6.41)

u =∂u

∂n= 0 on ∂Ω, (6.42)

where ∂∂n denotes the normal derivative. For this problem, we introduce the

linear space

V = {v : v,∂v

∂x1,∂v

∂x2are continuous on Ω,

∂2v

∂x21

,∂2v

∂x22

,∂2v

∂x1∂x2

are piecewise continuous, and v =∂v

∂n= 0 on ∂Ω}. (6.43)

Page 158: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 143

Multiplying (6.41) by a test function v ∈ V , integrating over Ω, and usingGreen’s formula (6.35) twice with v = ∂v

∂n =) on ∂Ω, we obtain

Ω

fvdx =∫

Ω

��u · vdx

=∫

∂Ω

v · ∂∂n

(�u)ds−∫

Ω

∇�u · ∇vdx

= −∫

Ω

∇�u · ∇vdx = −∫

∂Ω

�u · ∂v∂n

ds+∫

Ω

�u · �vdx,

which leads to the variational problem of the biharmonic problem (6.41)-(6.42): Find u ∈ V such that

a(u, v) = (f, v) ∀ v ∈ V, (6.44)

where

a(u, v) =∫

Ω

�u · �vdx, (f, v) =∫

Ω

fvdx.

Let Th be a triangulation of Ω into triangles as in the last subsection. Nowwe can define the finite element space

Vh = {v : v,∇v are continuous on Ω, v is a polynomial

of degree 5 on each triangle, and v =∂v

∂n= 0 on ∂Ω}. (6.45)

The elements in this space are known as the Argyris triangles, and it is truethat Vh ⊂ V .

The finite element method for the biharmonic problem (6.41)-(6.42) can beformulated as: Find uh ∈ Vh such that

a(uh, v) = (f, v) ∀ v ∈ Vh. (6.46)

The existence and uniqueness of the solution for (6.46) can be proved similarto the 1-D case.

6.3 Abstract finite element theory

6.3.1 Existence and uniqueness

Consider the abstract variational problem: Find u ∈ V such that

A(u, v) = F (v) ∀ v ∈ V, (6.47)

Page 159: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

144 Computational Partial Differential Equations Using MATLAB

where V denotes a real Hilbert space and F ∈ V ′. The following lemmaprovides the existence and uniqueness theory for this problem. Detailed proofcan be found in many books (e.g., [15, p. 8]).

THEOREM 6.1(Lax-Milgram lemma) Let V be a real Hilbert space with norm || · ||V , A(·, ·) :V ×V → R a bilinear form, and F (·) : V → R a linear continuous functional.Furthermore, suppose that A(·, ·) is bounded, i.e.,

∃β > 0 : |A(w, v)| ≤ β||w||V ||v||V for all w, v ∈ V,

and coercive, i.e.,

∃α > 0 : |A(v, v)| ≥ α||v||2V for all v ∈ V.

Then, there exists a unique solution u ∈ V to (6.47) and

||u||V ≤ 1α||F ||V ′ ,

where V ′ denotes the dual space of V .

Similar results hold true for a more general problem: Find u ∈ W such that

A(u, v) = F (v) ∀ v ∈ V, (6.48)

where W can be different from V .

THEOREM 6.2(Generalized Lax-Milgram lemma) Let W and V be two real Hilbert spaces

with norms || · ||W and || · ||V respectively, A(·, ·) : W ×V → R a bilinear form,and F (·) : V → R a linear continuous functional. Furthermore, assume that

(i) ∃β > 0 : |A(w, v)| ≤ β||w||W ||v||V for all w ∈ W, v ∈ V,

(ii) ∃α > 0 : infw∈W,||w||W =1

supv∈V,||v||V ≤1

|A(w, v)| ≥ α,

(iii) supw∈W

|A(w, v)| > 0 for every 0 �= v ∈ V.

Then, there exists a unique solution u ∈ W to (6.48) and

||u||W ≤ 1α||F ||V ′ .

For a detailed proof of this lemma, readers can consult Babuska and Aziz’sclassic paper [6].

Page 160: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 145

6.3.2 Stability and convergence

Now we assume that a family of finite dimensional subspaces Vh is constructedto approximate the infinite dimensional space V , i.e.,

infvh∈Vh

||v − vh||V → 0 as h→ 0, for all v ∈ V.

The Galerkin FEM for solving (6.47) is: Find uh ∈ Vh such that

A(uh, vh) = F (vh) ∀ vh ∈ Vh. (6.49)

We have the following proven stability and convergence theory.

THEOREM 6.3(Cea lemma) Under the assumption of Theorem 6.1, there exists a unique

solution uh to (6.49) and

||uh||V ≤ 1α||F ||V ′ .

Furthermore, if u denotes the solution to (6.47), then

||u− uh||V ≤ β

αinf

vh∈Vh

||u− vh||V ,

i.e., uh converges to u as h→ 0.

Proof. From (6.47) and (6.49), we obtain

A(u− uh, vh) = 0 ∀ vh ∈ Vh, (6.50)

which, along with the coercivity and continuity of A(·, ·) yields

α||u−uh||2V ≤ A(u−uh, u−uh) = A(u−uh, u−vh) ≤ β||u−uh||V ||u−vh||V ,which concludes the proof.

A more general technique than the Galerkin FEM is the so-called Petrov-Galerkin method for (6.47): Find uh ∈ Wh such that

Ah(uh, vh) = Fh(vh) ∀ vh ∈ Vh, (6.51)

where Wh and Vh are two families of finite dimensional subspaces of W and V ,respectively. In general, Wh �= Vh but dimWh = dimVh. Here Ah : Wh×Vh →R and Fh : Vh → R are some approximations to A and F , respectively. Forproblem (6.51), we have the following result (e.g., [6]).

THEOREM 6.4Under the assumptions of Theorem 6.2 and the same properties as Theorem

6.2 for the discrete functional Fh and bilinear form Ah with W replaced by

Page 161: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

146 Computational Partial Differential Equations Using MATLAB

Wh, V replaced by Vh, and the constants β and α replaced by βh and αh,respectively. Then, there exists a unique solution uh to (6.51) and

||uh||W ≤ 1αh

supvh∈Vh,vh =0

|Fh(vh)|||vh||V .

Furthermore, if u denotes the solution to (6.49), then

||u− uh||W≤ 1αh

supvh∈Vh,vh =0

|F (vh) − Fh(vh)|||vh||V

+ infwh∈Wh

[(1 +βhαh

)||u− wh||W +1αh

supvh∈Vh,vh =0

|A(u, vh) −Ah(uh, vh)|||vh||V ].

Proof. Let a function wh ∈ W h. By the coercivity and continuity of Ah,we have

||u− uh||W≤ ||u− wh||W + ||wh − uh||W≤ ||u− wh||W +

1αh

supvh∈Vh{0}

|Ah(wh − uh, vh)|||vh||V

≤ ||u− wh||W +1αh

supvh∈Vh{0}

|Ah(wh − u, vh) +Ah(u− uh, vh)|||vh||V

≤ ||u− wh||W +βhαh

||wh − u||W +1αh

supvh∈Vh{0}

|Ah(u − uh, vh)|||vh||V . (6.52)

Using the definitions of A and Ah, we obtain

Ah(u− uh, vh) = Ah(u, vh) −Ah(uh, vh)= Ah(u, vh) −A(u, vh) +A(u, vh) −Ah(uh, vh)= Fh(vh) − F (vh) +A(u, vh) −Ah(uh, vh),

substituting which into (6.52), we complete the proof.

6.4 Examples of conforming finite element spaces

For simplicity, we assume that the physical domain Ω ⊂ Rd(d = 2, 3) is apolygonal domain, which is triangulated by d-simplex (i.e., triangle in 2-D, ortetrahedron in 3-D) or d-rectangles, i.e., Ω = ∪K∈Th

K.

Page 162: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 147

Denote Pk (k ≥ 0) as the space of polynomials of degree less than or equalto k in variables x1, · · · , xd, and Qk as the space of polynomials of degree lessthan or equal to k in each variable x1, · · · , xd, i.e.,

Pk(x) =∑

0≤αi,α1+···+αd≤kcα1α2···αd

xα11 xα2

2 · · ·xαd

d

andQk(x) =

0≤α1,···,αd≤kcα1α2···αd

xα11 xα2

2 · · ·xαd

d

for proper coefficients cα1α2···αd. Furthermore, the dimensions of the spaces

Pk and Qk are given by

dim Pk =(k + d) · · · (k + 1)

d!= Ckk+d, dim Qk = (k + 1)d.

According to Ciarlet [15], a finite element space Vh is composed of threeparts (K,PK ,

∑K), where K defines the element domain/type (e.g., a tri-

angle or tetrahedron), PK defines the shape functions on each finite elementK ∈ Ω,

∑K denotes the set of degrees of freedom (i.e., the parameters which

uniquely define the function PK on each element K). Below we will discusssome widely used finite element spaces.

6.4.1 Triangular finite elements

Let us first look at the triangle element. Consider a triangle K with threevertices ai(xi, yi), i = 1, 2, 3, ordered in a counterclockwise direction. Let thelocal basis function of P1(K) at each vertex ai be λi, which are defined by

λi(aj) = δij , 1 ≤ i, j ≤ 3.

It is not difficult to check that

λi =1

2A(αi + βix+ γiy), i = 1, 2, 3,

where A is the area of the triangle, i.e.,

A =12

∣∣∣∣∣∣

1 x1 y11 x2 y21 x3 y3

∣∣∣∣∣∣.

Furthermore, the constants αi, βi and γi are defined as

αi = xjyk − xkyj, βi = yj − yk, γi = −(xj − xk),

where i �= j �= k, and i, j and k permute naturally.

Page 163: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

148 Computational Partial Differential Equations Using MATLAB

FIGURE 6.3P2 element.

Note that λi are often called the barycentric coordinates of the triangle.Now any function v ∈ P1(K) can be uniquely represented by

v(x, y) =3∑

i=1

v(ai)λi ∀ (x, y) ∈ K.

Hence the degrees of freedom∑K consist of the function values at the vertices.

It is easy to see that for any v such that v|K ∈ P1(K),K ∈ Th, if it iscontinuous at all internal vertices, then v ∈ C0(Ω). Therefore, we can definethe continuous piecewise linear finite element space

Vh = {v ∈ C0(Ω) : v|K ∈ P1(K), ∀ K ∈ Th}.Similarly, we can define the continuous piecewise quadratic finite element

spaceVh = {v ∈ C0(Ω) : v|K ∈ P2(K), ∀ K ∈ Th},

where the degrees of freedom on each triangle K consists of the values of v atthe vertices ai and the midpoints aij of edges (cf. Fig. 6.3).

LEMMA 6.1A function v ∈ P2(K) is uniquely determined by the values of v(ai), 1 ≤ i ≤ 3,and v(aij), 1 ≤ i < j ≤ 3.

Proof. Since the number of degrees of freedom is equal to the dimensionof P2(K), we have only to show that if v(ai) = v(aij) = 0, then v ≡ 0. Notethat the restriction of v ∈ P2(K) to edge a2a3 is a quadratic function of onevariable vanishing at three distinct points, hence v(x) must be zero over thatedge, i.e., v(x) should include a factor λ1(x).

Page 164: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 149

FIGURE 6.4Q1 and Q2 elements.

By the same argument, v must be zero over edges a1a2 and a1a3, i.e., v(x)also contains factors λ2(x) and λ3(x). Hence we can write

v(x) = cλ1(x)λ2(x)λ3(x).

But v(x) ∈ P2, it follows that c = 0, which concludes the proof.Let us remark that this choice of degrees of freedom guarantees that v ∈

C0(Ω) since each side of the element uniquely identifies the restriction of v onthat side. More specifically, any v ∈ P2(K) has the representation [15, p. 47]

v(x) =3∑

i=1

v(ai)λi(2λi − 1) +3∑

i<j,i,j=1

4v(aij)λiλj .

Similarly, continuous higher-order finite element spaces on triangular ele-ment can be defined. More examples can be found in [15].

6.4.2 Rectangular finite elements

Without loss of generality, we assume that the rectangular elementK = [0, 1]2.We can define the continuous rectangular finite element spaces

Vh = {v ∈ C0(Ω) : v|K ∈ Qq(K), K ∈ Th}, ∀ r ≥ 1,

where r = 1 and r = 2 correspond to the so-called bilinear and biquardraticfinite element spaces, respectively.

It will be shown in Lemma 6.2 that for r = 1 the degrees of freedom arethe values at the vertices of the rectangle; for r = 2 the degrees of freedomare the values at the vertices, midpoints of each side, and at the center of therectangle. We plot the degrees of freedom in Fig. 6.4.

LEMMA 6.2If v ∈ Qr(K), r = 1, 2, vanishes at the nodes shown in Fig. 6.4, then v = 0.

Page 165: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

150 Computational Partial Differential Equations Using MATLAB

Proof. For r = 1, the restriction of v to each side of K = [0, 1]2 is alinear function of one variable. Hence v vanishes on each side, i.e., v can berepresented as

v = cx(1 − x)y(1 − y), (6.53)

following which c = 0, since v ∈ Q1(K).Similarly, when r = 2, v also vanishes on each side, i.e., v still has the form

(6.53), from which we obtain the value at the center of K as

v(12,12) =

c

16.

But by assumption v(12 ,

12 ) = 0, we see that c = 0, therefore v ≡ 0, which

concludes the proof for r = 2.

6.5 Examples of nonconforming finite elements

In a previous section, we develop finite element space V h, which is a subspaceof V ≡ H1(Ω) for a second-order elliptic problem. In practice, we can releasethis constraint so that V h should not be a subspace of V . Here we willintroduce some classic nonconforming finite elements.

6.5.1 Nonconforming triangular elements

Let Ω be a polygonal domain in the plane, and Th be the triangulation of Ω.Consider an arbitrary triangle K ∈ Th with vertices ai and midpoints of edgesaij (see Fig. 6.3).

We claim that a linear function v on each K is uniquely determined bythe function values at the three midpoints of the edges. In fact, let the basisfunction at a23 be

φ1(x) = c1λ1(x) + c2λ2(x) + c3λ3(x), (6.54)

where λi(x) are the barycentric coordinates defined in a previous section. Theunknown coefficients c1, c2, and c3 are determined by the following conditions

1 = φ1(a23), i.e.,12c2 +

12c3 = 1,

0 = φ1(a12), i.e.,12c1 +

12c2 = 0,

0 = φ1(a13), i.e.,12c1 +

12c3 = 0,

which leads to the solution c1 = −1, c2 = c3 = 1. Hence the basis functionat node a23 is

φ1 = −λ1 + λ2 + λ3 = 1 − 2λ1,

Page 166: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 151

where we used the fact that λ1 + λ2 + λ3 = 1. Similarly, we can derive thebasis functions at nodes a13 and a12.

Therefore any linear function v on K can be uniquely represented by

v(x, y) = v(a23)(1 − 2λ1) + v(a13)(1 − 2λ2) + v(a12)(1 − 2λ3), ∀ (x, y) ∈ K.

Now we can define the nonconforming P1 space on triangles

V h = {v ∈ L2(Ω) : v|K is linear for all K ∈ Th, v

is continuous at the midpoints of the interior edges},which is the linear Crouzeix-Raviart element. Note that the function v ∈ V h

is continuous only at the midpoints of interior edges, so V h �⊂ V ≡ H1(Ω).General high-order nonconforming elements on triangles are discussed in [4].

For a fourth-order problem, the conforming finite elements are C1 elements(i.e., we need continuity of derivatives). Constructions of such elements arequite complicated, an example is the Argyris finite element, which is a fifth-degree polynomial involving 21 degrees of freedom. To reduce this burden,nonconforming elements are especially popular for fourth-order problems. Oneclassic example is the Morley element on triangles (cf. Fig. 6.5), which isdefined by

V h = {v ∈ L2(Ω) : v|K ∈ P2(K) for all K ∈ Th, v

is continuous at the interior vertices, the normal derivative∂v

∂nis continuous at the midpoints of interior edges},

i.e., on each triangle, v ∈ V h is uniquely defined by 6 degrees of freedom(function values at the vertices, and the values of the first normal derivativesat the midpoints of the edges). Hence the Morley element uses much fewerdegrees of freedom compared to the Argyris element. Note that the Morleyelement is not even of C0, thus V h �⊂ V ≡ H2(Ω). Detailed error estimatesfor the Morley element can consult the paper by Shi [37].

6.5.2 Nonconforming rectangular elements

We now consider the case where the partition Th of Ω is formed by rectanglessuch that edges of the rectangles are parallel to the x- and y- axes, respectively.

The simplest nonconforming rectangular element space is the so-called ro-tated Q1 element [34], which can be defined as

V h = {v ∈ L2(Ω) : v|K = a1 + a2x+ a3y + a4(x2 − y2) for all rectangles K ∈ Th,

v is continuous at the midpoints of interior vertices, ai ∈ R},i.e., the degrees of freedom are the function values at the midpoints of edges(cf. Fig. 6.6).

Page 167: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

152 Computational Partial Differential Equations Using MATLAB

FIGURE 6.5The degrees of freedom for the Morley element.

FIGURE 6.6The degrees of freedom for the rotated Q1 element.

Page 168: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 153

FIGURE 6.7The degrees of freedom for the Adini element.

Another popular element is the Wilson’s rectangle, which is defined by

V h = {v ∈ L2(Ω) : v|K ∈ P2(K) for all rectanlges K ∈ Th,

v is determined by its values at the vertices of K and the mean values of

its second derivatives overK :1|K|

K

∂2v

∂x2dx and

1|K|

K

∂2v

∂y2dx}.

The nonconforming quadrilateral Wilson element is discussed in [38].For a fourth-order problem, the Adini element is often used, which is defined

by

V h = {v ∈ L2(Ω) : v|K ∈ P3(K) ⊕ span{x3y, xy3} for all rectanlges K ∈ Th,

v,∂v

∂xand

∂v

∂yare continuous at the interior vertices}.

Hence the function in the Adini element are C0(Ω), but not C1(Ω). Thedegrees of freedom of the Adini element are the function values and the firstderivatives with respect to x and y at the vertices of the rectangle (cf. Fig.6.7).

6.6 Finite element interpolation theory

Before we discuss the finite element interpolation theory, we need to introducesome important spaces for theoretical analysis of partial differential equations.

Page 169: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

154 Computational Partial Differential Equations Using MATLAB

6.6.1 Sobolev spaces

Since its introduction around 1950 by S.L. Sobolev, Sobolev spaces have be-come a cornerstone for analyzing partial differential equations. For a compre-hensive discussion, see the book by Adams [1].

Let Ω be an open bounded domain in Rd with a boundary ∂Ω. We definethe Lebesgue spaces

Lp(Ω) = {v : ||v||Lp(Ω) <∞},where the associated norm is

||v||Lp(Ω) = (∫

Ω

|v(x)|pdx)1/p for 1 ≤ p <∞,

or||v||L∞(Ω) = sup{|v(x)| : x ∈ Ω} for p = ∞.

Note that L2(Ω) is a Hilbert space (i.e., a complete inner product space),endowed with scalar product (u, v) =

∫Ωu(x)v(x)dx. Recall that a vector

space endowed with a norm || · || is called a normed linear space. Whilea normed linear space V with norm || · || is called a Banach space if it iscomplete with respect to || · ||, i.e., any Cauchy sequence {vj} of V has a limitv ∈ V.

It is known that [9, p. 23]: For any 1 ≤ p ≤ ∞, Lp(Ω) is a Banach space.Let C∞

0 (Ω) (or D(Ω)) be the space of infinitely differentiable functions withcompact support in Ω. We usually use the multi-index notation to representthe derivatives of v, i.e., let α = (α1, · · · , αd) be an d-tuple of nonnegativeintegers and denote the length of α by |α| =

∑di=1 αi. Then the α-th partial

derivative of v is defined by

Dαv =∂α1+α2+···+αdv

∂xα11 ∂xα2

2 · · · ∂xαd

d

=∂|α|v

∂xα11 ∂xα2

2 · · · ∂xαd

d

.

Now we will define derivatives for a class of not-so-smooth functions. Todo that, let us first consider the set of locally integrable functions

L1loc(Ω) = {v : v ∈ L1(K), any compact K ⊂ interior Ω}.

If for a given v ∈ L1loc(Ω), there is a function w ∈ L1

loc(Ω) such that

(w, φ) = (−1)|α|(v,Dαφ) ∀ φ ∈ D(Ω),

then we say w is the weak derivative of v, denoted as Dαv = w. It is easy tocheck that for any v ∈ C|α|(Ω), the weak derivative Dαv exists and equals theordinary pointwise derivative.

With all the above preparations, we are ready to define the Sobolev spaces

W k,p(Ω) = {v ∈ L1loc(Ω) : ||v||Wk,p(Ω) <∞},

Page 170: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 155

equipped with the corresponding Sobolev norm

||v||Wk,p(Ω) = (∑

|α|≤k||Dαv||pLp(Ω))

1/p ∀ 1 ≤ p <∞,

and||v||Wk,∞(Ω) = max

|α|≤k||Dαv||L∞(Ω).

It is proved that W k,p(Ω) is a Banach space (see e.g., [9, p. 28]). Further-more, we denote W k,p

0 (Ω) as the closure of C∞0 (Ω) with respect to the norm

|| · ||Wk,p(Ω). When p = 2, we write Hk(Ω) (or Hk0 (Ω)) instead of W k,2(Ω) or

(W k,20 (Ω)). Similarly, we can define the seminorms

|v|Wk,p(Ω) = (∑

|α|=k||Dαv||pLp(Ω))

1/p, |v|Wk,∞(Ω) = max|α|=k

||Dαv||L∞(Ω).

Sobolev spaces provide a way for quantifying the degree of smoothness offunctions. Before we do that, we have to explain the word “embedding.” Anormed space U is said to be embedded in a normed space V , denoted asU ↪→ V , if

(i) U is a linear subspace of V ;(ii) the injection of U into V is continuous, i.e., there exists a constant

C > 0 such that ||u||V ≤ C||u||U ∀ u ∈ U.

THEOREM 6.5(Sobolev embedding theorem) Suppose that Ω is an open set of Rd with a Lip-schitz continuous boundary, and 1 ≤ p < ∞. Then the following embeddingsexist:

(i) If 0 ≤ kp < d, then W k,p(Ω) ↪→ Lp∗ for p∗ = dpd−kp .

(ii) If kp = d, then W k,p(Ω) ↪→ Lq for any q such that p ≤ q <∞.(iii) If kp > d, then W k,p(Ω) ↪→ C0(Ω).

6.6.2 Interpolation theory

First we define a local k-th order interpolation operator in a finite element K:

ΠkK(v) =

i

v(ai)φi ∀ v ∈ C0(K),

where ai are the nodes in K, φi are the shape functions. Then we can definea corresponding global interpolation operator

Πkh(v)|K = Πk

K(v|K) ∀ v ∈ C0(Ω),K ∈ Th.

We assume further that each element K of Th can be obtained as an affinemapping of a reference element K, i.e.,

K = FK(K), FK(x) = BK x+ bK ,

Page 171: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

156 Computational Partial Differential Equations Using MATLAB

where BK is a d× d non-singular matrix. The estimate of interpolation errorwill be obtained by the following four lemmas.

LEMMA 6.3Denote v = v(FK(x)) for any v ∈ Hm(K),m ≥ 0. Then v ∈ Hm(K), and

there exists a constant C = C(m, d) such that

|v|m,K ≤ C||B−1K ||m|detBK |1/2|v|m,K , ∀ v ∈ Hm(K), (6.55)

and

|v|m,K ≤ C||BK ||m|detBK |−1/2|v|m,K , ∀ v ∈ Hm(K), (6.56)

where || · || denotes the matrix norm associated to the Euclidean norm in Rd.

Proof. Since C∞(K) is dense in Hm(K), it is sufficient to prove (6.55) fora smooth v. By definition, we have

|v|2m,K =∑

|α|=m

K

|Dαv|2. (6.57)

Using the chain rule and the mapping FK , we have

||Dαv||20,K ≤ C||B−1K ||2m

|β|=m||Dβ v||20,K

≤ C||B−1K ||2m

|β|=m||Dβ v||2

0,K· (detBK), (6.58)

which along with (6.57) completes the proof of (6.55). The other proof canbe pursued similarly.

For any element K, we denote

hK = diam(K), ρK = sup{diam(S) : S is a sphere inscribed in K}.Similarly, hK and ρK can be defined on the reference element K.

LEMMA 6.4The following estimates hold

||B−1K || ≤ hK

ρK, ||BK || ≤ hK

ρK.

Proof. By definition, we have

||B−1K || =

1ρK

sup|ξ|=ρK

|B−1K ξ|. (6.59)

Page 172: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 157

For any ξ satisfying |ξ| = ρK , we can always find two points x, y ∈ K suchthat x− y = ξ. Note that |B−1

K ξ| = |B−1K (x− y)| = |x− y| ≤ hK , substituting

which into (6.59) completes the proof of the first inequality. The other onecan be proved in a similar way.

LEMMA 6.5(Bramble-Hilbert lemma) Let the linear continuous mapping

L ∈ L(Hs(K);Hm(K)),m ≥ 0, s ≥ 0,

such thatL(p) = 0 for all p ∈ Pl, l ≥ 0.

Then|L(v)|m,K ≤ ||L||L(Hs;Hm) inf

p∈Pl

||v + p||s,K , ∀ v ∈ Hs(K).

Proof. The proof follows from

|L(v)|m,K = |L(v + p)|m,K ≤ ||L||L(Hs;Hm)||v + p||s,K .

LEMMA 6.6[33, p. 88] There exists a constant C(K) such that

infp∈Pk(K)

||v + p||k+1,K ≤ C(K)|v|k+1,K ∀ v ∈ Hk+1(K).

THEOREM 6.6Let m = 0, 1, l = min(k, s− 1) ≥ 1. Then there exists a constant C such that

|v − ΠkKv|m,K ≤ C

hl+1K

ρmK|v|l+1,K ∀ v ∈ Hs(K).

Proof. Denote ΠkKv = Πk

Kv ◦ FK . Noting that the shape functions φi in Kare given by φi = φ ◦ FK , we obtain

ΠkKv = Πk

hv ◦ FK =∑

i

v(ai)(φi ◦ FK) =∑

i

v(FK(ai))φi = ΠkKv,

from which and Lemmas 6.3-6.6, we have

|v − ΠkKv|m,K ≤ C · 1

ρmK|detBK |1/2|v − Πk

Kv|m,K

≤ C

ρmK|detBK |1/2|v − Πk

Kv|m,K

≤ C

ρmK|detBK |1/2||I − Πk

K||L(Hs;Hm) inf

p∈Pl

||v + p||s,K .(6.60)

Page 173: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

158 Computational Partial Differential Equations Using MATLAB

If s− 1 < k, then l = s− 1, i.e.,s = l+ 1. Therefore by Lemmas 6.3-6.4, wehave

infp∈Pl

||v + p||s,K ≤ C|v|l+1,K ≤ C||BK ||l+1| detBK |−1/2|v|l+1,K

≤ Chl+1K |detBK |−1/2|v|l+1,K ,

substituting which into (6.60) yields

|v − ΠkKv|m,K ≤ C

hl+1K

ρmK|v|l+1,K .

If s− 1 ≥ k, then l = k, in which case the proof completes by noting that

|v − ΠkKv|m,K ≤ C||I − Πk

K||L(Hk+1;Hk) inf

p∈Pl

||v + p||k+1,K ≤ C|v|k+1,K .

In order to consider the global interpolation error over Ω, we assume thatthe triangulation Th of Ω is regular, i.e., there exists a constant σ ≥ 1 suchthat

hKρK

≤ σ for any K ∈ Th.

Noting that |v−Πkhv|2m,Ω =

∑K∈Th

|v−Πkhv|2m,K , which along with Theorem

6.6, and the regularity assumption, we have the following global interpolationerror estimate.

THEOREM 6.7

Let m = 0, 1, l = min(k, s−1) ≥ 1, and Th be a regular family of triangulationsof Ω. Then there exists a constant C, independent of h = maxK∈Th

hK , suchthat

|v − Πkhv|m,Ω ≤ Chl+1−m|v|l+1,Ω ∀ v ∈ Hs(Ω).

REMARK 6.1 By performing a similar proof as above (cf. [15]), wehave both local and global L∞ interpolation error estimates: for m = 0, 1, l =min(k, s− 1) ≥ 1,

|v − ΠkKv|m,∞,K ≤ C

hl+1K

ρmK|v|l+1,∞,K ∀ v ∈W s,∞(K),

and|v − Πk

hv|m,∞,Ω ≤ Chl+1−m|v|l+1,∞,Ω ∀ v ∈W s,∞(Ω).

Page 174: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 159

6.7 Finite element analysis of elliptic problems

In this section, we will present the basic finite element error analysis for ellipticproblems. First we will consider the conforming finite elements, then weextend the analysis to nonconforming finite elements.

Without loss of generality, we consider the Dirichlet problem for the Laplaceequation

−�u = f in Ω, (6.61)u = 0 on ∂Ω. (6.62)

6.7.1 Analysis of conforming finite elements

Multiplying (6.61) by a test function v ∈ H10 (Ω) and using the Green’s formula

−∫

Ω

�uvdx = −∫

∂Ω

∂u

∂nvds+

Ω

d∑

i=1

∂u

∂xi

∂v

∂xi, ∀ u ∈ H2(Ω), v ∈ H1(Ω),

(6.63)where ∂

∂n =∑d

i=1 ni∂∂xi

is the normal derivative operator, we obtain thevariational problem: Find u ∈ H1

0 (Ω) such that

A(u, v) ≡ (∇u,∇v) = (f, v), ∀ v ∈ H10 (Ω). (6.64)

Application of the Cauchy-Schwarz inequality shows that

|(∇u,∇v)| ≤ ||∇u||0||∇v||0 ≤ ||u||1||v||1,

which reveals that A(·, ·) is continuous on H10 (Ω) ×H1

0 (Ω).Using the Poincare inequality [15, p. 12]

Ω

v2(x)dx ≤ CΩ

Ω

|∇v(x)|2dx, ∀ v ∈ H10 (Ω), (6.65)

we obtainA(v, v) = ||∇v||20 ≥ 1

1 + CΩ||v||21,

which proves the coercivity of A. Therefore, by the Lax-Milgram lemma, thevariational problem (6.64) has a unique solution u ∈ H1

0 (Ω).To solve (6.64) by the finite element method, we construct a finite dimen-

sional subspace Vh of H10 (Ω) using continuous piecewise basis functions, i.e.,

Vh = {vh ∈ C0(Ω) : vh|K ∈ Pk, ∀ K ∈ Th}, (6.66)

where Th is a regular family of triangulations of Ω.

Page 175: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

160 Computational Partial Differential Equations Using MATLAB

The finite element approximation uh ∈ Vh of (6.63) is: Find uh ∈ Vh suchthat

(∇uh,∇vh) = (f, vh), ∀ vh ∈ Vh.

By the Cea lemma, for any u ∈ Hs(Ω) ∪H10 (Ω), s ≥ 2, we have

||u− uh||1 ≤ (1 + CΩ) infvh∈Vh

||u− vh||1 ≤ (1 + CΩ)||u− Πhu||1 ≤ Chl||u||l+1,

where l = min(k, s− 1).Hence if u is very smooth, then the rate of convergence in the H1-norm

will be O(hk), k = 1, 2, · · · , which is optimal in the sense that it is the highestpossible rate of convergence allowed by the polynomial degree k.

To derive error estimates in the L2-norm, we need to use a duality argument(also called the Aubin-Nitsche technique ). Let the error e = u − uh, and wbe the solution of

−�w = e in Ω, w = 0 on ∂Ω, (6.67)

whose variational formulation is: Find w ∈ H10 (Ω) such that

A(v, w) = (e, v) ∀ v ∈ H10 (Ω). (6.68)

Hence, we have

||u− uh||20 = (u− uh, u− uh) = A(u− uh, w) = A(u − uh, w − Πhw)≤ ||u− uh||1||w − Πhw||1 ≤ Chl||u||l+1 · h||w||2. (6.69)

Note that the adjoint problem (6.67) satisfies the property

||w||2 ≤ C||e||0, (6.70)

substituting which into (6.69), we have

||u− uh||0 ≤ Chl+1||u||l+1,

which is optimal in the L2-norm.To summarize, we have the following convergence results for the Laplace

problem (6.61)-(6.62).

THEOREM 6.8

Let Ω be a polygonal domain of Rd, d = 2, 3, with Lipschitz boundary, and Thbe a regular family of triangulations of Ω. Let Vh be defined in (6.66). If theexact solution u ∈ Hs(Ω) ∩H1

0 (Ω), s ≥ 2, the error estimate holds

||u− uh||1 ≤ Chl||u||l+1, l = min(k, s− 1), k ≥ 1.

Page 176: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 161

Suppose, furthermore, for each e ∈ L2(Ω), the solution w of (6.68) belongs toH2(Ω) and satisfies

||w||2 ≤ C||e||0 ∀ e ∈ L2(Ω).

Then we have

||u− uh||0 ≤ Chl+1||u||l+1, l = min(k, s− 1), k ≥ 1.

Using more sophsticated weighted-norm techniques, the following L∞-errorestimates hold true [15, p. 165].

THEOREM 6.9

Under the assumption of u ∈ H10 (Ω) ∩W k+1,∞(Ω), k ≥ 1, we have

||u− uh||∞,Ω + h||∇(u− uh)||∞,Ω ≤ Ch2| lnh||u|2,∞,Ω, for k = 1,

and

||u− uh||∞,Ω + h||∇(u− uh)||∞,Ω ≤ Chk+1|u|k+1,∞,Ω, for k ≥ 2.

6.7.2 Analysis of nonconforming finite elements

Here we consider the error analysis for the nonconforming finite elementmethod for solving the Laplace problem (6.61)-(6.62). For simplicity, we con-sider the linear Crouzeix-Raviart element

V h = {v ∈ L2(Ω) : v|K is linear for all K ∈ Th, v

is continuous at the midpoints of the interior edges,and v = 0 at the midpoints of ∂Ω},

in which case the discrete problem becomes: Find uh ∈ V h such that

Ah(uh, v) = (f, v) ∀ v ∈ V h, (6.71)

where the bilinear form Ah(·, ·) is defined by

Ah(v, w) =∑

K∈Th

K

∇v · ∇wdx =∑

K∈Th

(∇v,∇w)K , v, w ∈ V h,

with associated norm ||v||h ≡ √Ah(v, v).

Note that ||v||h is indeed a norm, since Ah(v, v) = 0 implies that v ispiecewise constant, which leads to v ≡ 0 due to the zero boundary conditionand the continuity at midpoints.

Page 177: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

162 Computational Partial Differential Equations Using MATLAB

THEOREM 6.10Suppose that Ω is a convex polygonal domain. Let f ∈ L2(Ω), u and uh are thesolutions to (6.64) and (6.71), respectively. Then the following error estimateholds

||u− uh||h ≤ Ch|u|H2(Ω).

Proof. It is easy to see that

|Ah(vh, wh) ≤ ||vh||h||wh||hand Ah(vh, vh) = ||vh||2h. Hence we can use Theorem 6.4.

Note that

Ah(u− uh, v) =∑

K∈Th

K

∇u · ∇vdx−∫

Ω

fvdx

=∑

K∈Th

(∫

∂K

∂u

∂nvds−

K

�u · vdx) −∫

Ω

fvdx

=∑

K∈Th

∂K

∂u

∂nvds. (6.72)

For each edge e ∈ ∂K, we define the mean value of v on e

v =1|e|

e

v|Kds.

Note that each interior edge appears twice, hence we can rewrite (6.72) as

Ah(u − uh, v) =∑

K∈Th

e∈∂K

e

(∂u

∂nK− ∂u

∂nK)(v − v)ds. (6.73)

Consider a reference triangle K, for an edge e ∈ ∂K, we have

||w − w||L2(e) ≤ C|w|H1(K),

from which and the standard scaling argument, we obtain

||w − w||L2(e) ≤ Ch1/2|w|H1(K). (6.74)

Applying (6.74) to (6.73), we have

|Ah(u− uh, v)| ≤∑

K∈Th

e∈∂KCh|∂u

∂n|H1(K)|v|H1(K)

≤ Ch|u|H2(Ω)||v||h,which along with (6.52) and the standard interpolation estimate

||u − Πu||h ≤ Ch|u|H2(Ω),

completes the proof.

Page 178: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 163

6.8 Finite element analysis of time-dependent problems

6.8.1 Introduction

For time-dependent problems, we will consider the space-time functions v(x, t),(x, t) ∈ Ω × (0, T ), for which we need the space

Lq(0, T ;W k,p(Ω))

= {v : (0, T ) →W k,p(Ω) :∫ T

0

||v(t)||qWk,p(Ω)

dt <∞}, 1 ≤ q <∞,

endowed with norm

||v||Lq(0,T ;Wk,p(Ω)) = (∫ T

0

||v(t)||qWk,p(Ω)

dt)1/q.

Similarly, when q = ∞, we can define the space L∞(0, T ;W k,p(Ω)) withnorm

||v||L∞(0,T ;Wk,p(Ω)) = max0≤t≤T

||v(·, t)||Wk,p(Ω).

Another popular Sobolev space for time-dependent problems is

H1(0, T ;V ) = {v ∈ L2(0, T ;V ) :∂v

∂t∈ L2(0, T ;V )}

where V can be any Banach space such as W k,p(Ω).Let us consider an abstract time-dependent problem

∂u

∂t+ Lu = f in (0, T )× Ω,

u(x, t) = 0 on (0, T )× ∂Ω, (6.75)u(x, 0) = u0(x) on Ω,

where L is a linear differential operator.The weak formulation of (6.75) is: Find u ∈ L2(0, T ;V )∩C0(0, T ;H) such

thatd

dt(u(t), v) +A(u(t), v) = (f(t), v) ∀ v ∈ V, (6.76)

and u = u0 at t = 0. Here the continuous bilinear form A(·, ·) is defined onV × V , and V and H are two Hilbert spaces.

The problem (6.76) needs to be discretized with respect to both time andspace variables. If the discretization is carried out only for the space variable,we obtain the so-called semi-discrete approximation. For example, the semi-discretization of (6.76) is: For each t ∈ [0, T ], find uh(·, t) ∈ Vh ⊂ V suchthat

d

dt(uh(t), vh) +A(uh(t), vh) = (f(t), vh) ∀ vh ∈ Vh, (6.77)

Page 179: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

164 Computational Partial Differential Equations Using MATLAB

with uh(0) = u0,h where u0,h usually is the interpolant or L2-projection of u0.In semi-discrete approximation, the solution uh is sought as

uh(x, t) =N∑

j=1

uj(t)φj(x), (6.78)

where φj are the basis functions of Vh. Substituting (6.78) into (6.77), weend up with a system of ordinary differential equations for unknown vectors�u = (u1, · · · , uN )T :

Mdu(t)dt

+Au(t) = F (t), u(0) = u0, (6.79)

where

M = (Mij) = ((φj , φi)), A = (Aij) = (A(φj , φi)), F = (Fi) = (f(t), φi).

Note that (6.79) is not fully solved, hence we need to further discrete itwith respect to the time variable. To this purpose, we partition the timeinterval [0, T ] into N equal subintervals [tk, tk+1] of length �t = T

N . A simplefully-discrete scheme is the θ-scheme:

1�t (u

k+1h − ukh, vh) +A(θuk+1

h + (1 − θ)ukh, vh)

= θ(f(ttk+1), vh) + (1 − θ)(f(ttk ), vh), ∀ vh ∈ Vh, (6.80)

for k = 0, 1, · · · , N−1. Here ukh is the approximation to u(t) at time tk = k·�t.Note that θ = 0 refers to the forward Euler scheme, θ = 1 refers to thebackward Euler scheme, θ = 1

2 corresponds to the Crank-Nicolson scheme.

6.8.2 FEM for parabolic equations

Here we consider the parabolic equation

ut −∇ · (a(x)∇u) = f(x, t) (x, t) ∈ Ω × (0, T ], (6.81)u(x, 0) = u0(x) x ∈ Ω, (6.82)u(x, t) = 0 (x, t) ∈ ∂Ω × (0, T ] (6.83)

where we assume that0 < a0 ≤ a(x) ≤ a1. (6.84)

The weak formulation of (6.81)-(6.83) is: Find u ∈ H10 (Ω) such that

(ut, v) + (a∇u,∇v) = (f, v) ∀ v ∈ H10 (Ω), t ∈ (0, T ], (6.85)

u(x, 0) = u0(x) x ∈ Ω. (6.86)

Page 180: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 165

Let the finite dimensional space Vh ⊂ H10 (Ω) be defined by (6.66). Then

we can define the semi-discrete finite element method for (6.85)-(6.86): Finduh : [0, T ] → Vh such that

(uh,t, v) + (a∇uh,∇v) = (f, v) ∀ v ∈ Vh, (6.87)uh(·, 0) = Πhu0, (6.88)

where Πh is the elliptic projection operator [45] into Vh, i.e., for any w ∈H1(Ω), Πhw ∈ Vh satisfies the equation

(a∇(w − Πhw),∇v) = 0 ∀ v ∈ Vh. (6.89)

Furthermore, if Th is a regular family of triangulations and for each r ∈L2(Ω) the adjoint problem

(a∇v,∇φ(r)) = (r, v) ∀ v ∈ H1(Ω) (6.90)

has a solution φ(r) ∈ H2(Ω), then we have ([45], see also [33, p. 376])

||v − Πhv||0 + h||v − Πhv||1 ≤ Chk+1|v|k+1, ∀ v ∈ Hk+1(Ω). (6.91)

To obtain error estimates for time-dependent problems, we need the follow-ing Gronwall’s inequality.

LEMMA 6.7Let f and g be piecewise continuous nonnegative functions defined on 0 ≤t ≤ T, g being non-decreasing. If for each t ∈ [0, T ],

f(t) ≤ g(t) +∫ t

0

f(τ)dτ, (6.92)

then f(t) ≤ etg(t).

THEOREM 6.11Let u and uh be the solutions to (6.85)-(6.86) and (6.87)-(6.88), respectively,where the finite element space Vh ⊂ H1

0 (Ω) contains piecewise polynomials ofdegree less than or equal to k. Then the following error estimate holds true

||u− uh||L∞(0,T ;L2(Ω))

≤ Chk+1(||u||L∞(0,T ;Hk+1(Ω)) + ||ut||L2(0,T ;Hk+1(Ω))), (6.93)

where the constant C > 0 is independent of h.

Proof. Subtracting (6.87) from (6.85) with v = vh ∈ Vh, we have

((Πhu− uh)t, v) + (a∇(Πhu− uh),∇v)= ((Πhu− u)t, v) + (a∇(Πhu− u),∇v). (6.94)

Page 181: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

166 Computational Partial Differential Equations Using MATLAB

Choosing v = Πhu− uh and using (6.84) and (6.89), we can reduce (6.94) to

12d

dt||Πhu− uh||20 + a0||∇(Πhu− uh)||20

≤ ||(Πhu− u)t||0||Πhu− uh||0≤ Chk+1|ut|k+1||Πhu− uh||0. (6.95)

Dropping the a0 term, integrating both sides of (6.95) with respect to t andusing (6.88), we obtain

12||(Πhu− uh)(t)||20

≤ Ch2(k+1)

∫ t

0

|ut(τ)|2k+1dτ +12

∫ t

0

||(Πhu− uh)(τ)||20dτ. (6.96)

By the Gronwall’s inequality, we have

||(Πhu− uh)(t)||20 ≤ Ch2(k+1)(∫ t

0

|ut(τ)|2k+1dτ)et,

which reduces to

||(Πhu− uh)(t)||0 ≤ Chk+1

∫ t

0

||ut(τ)||2k+1dτ)1/2, ∀ t ∈ [0, T ],

where we observed the dependence on T into the generic constant C.Using the triangle inequality and the estimate (6.91), we obtain

||(u − uh)(t)||0 ≤ Chk+1(||u(t)||k+1 + (∫ t

0

||ut(τ)||2k+1dτ)1/2),

which concludes the proof of (6.93).The fully-discrete finite element method, such as the Crank-Nicolson scheme,

for (6.85)-(6.86) can be defined as: For any v ∈ Vh, find un+1h ∈ Vh, n =

0, 1, · · · , N − 1, such that

(un+1h − unh

�t , v) + (a∇un+1h + unh

2,∇v) = (

fn+1 + fn

2, v), (6.97)

(u0h − u0, v) = 0. (6.98)

Taking v = un+1h +un

h

2 in (6.97), one can show that the Crank-Nicolson schemeis unconditionally stable. Careful analysis leads to the optimal error estimate

max0≤n≤N

||unh − u(tn)||0 ≤ C(hk+1 + (�t)2),

where tn = n · �t and the constant C > 0 is independent of �t and h. Theproof is lengthy, so we skip the proof. Interested readers can find the proof inbooks such as [20, 33, 41].

Page 182: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 167

6.9 Bibliographical remarks

Here we only present the very basic theory for analyzing a finite elementmethod. More complete and advanced theory can be consulted in many clas-sic books in this area (e.g., [8, 9, 15, 19, 20, 22, 25, 32, 40]). There are othermore specialized books on different areas of finite element methods. For ex-ample, readers can find detailed discussions on mixed finite element methodsin [10, 21]; finite elements on anisotropic meshes [3]; hp finite element meth-ods in [18, 30, 36, 39]; analysis for time-dependent problems in [20, 41]; finiteelement superconvergence theory in [12, 27, 28, 29, 44]; adaptive finite ele-ment methods in [2, 7, 43]; finite element methods for singularly perturbedproblems [30, 35]; finite element applications in fluids and eletromagnetics[13, 23, 24, 31]; and finite elements for reservoir simulation [14, 11].

6.10 Exercises

1. Let Ω ⊂ R2 be a bounded polygonal domain. Use the definition of theSobolev space to prove that

|v|2H2(Ω) =∫

Ω

{|∂2v

∂x21

|2 + |∂2v

∂x22

|2 + 2| ∂2v

∂x1∂x2|2}dx1dx2, ∀ v ∈ H2(Ω).

Furthermore, for any v ∈ H20 (Ω) ≡ {w ∈ H2(Ω) : w = ∂w

∂n = 0 on ∂Ω},where ∂

∂n is the outward normal derivative, prove the relation [15, p. 15]:

|�v|L2(Ω) = |v|H2(Ω),

where we denote �v = ∂2v∂x2

1+ ∂2v

∂x22.

2. Assume that f(x) ∈ C1[a, b], and f(a) = 0. Prove the one-dimensionalPoincare inequality:

||f ||L2 ≤ b− a√2

||f ′||L2 .

3. Let Ω be a bounded domain which has a Lipschitz boundary. It is knownthat the so-called trace theorem holds true [15, p. 13]:

||v||L2(∂Ω) ≤ CΩ||v||H1(Ω), ∀ v ∈ H1(Ω), (6.99)

where CΩ > 0 is a constant depending on the domain Ω. Prove that (6.99) istrue for u ∈ C1(Ω), where Ω is the unit disk in R2:

Ω = {(x, y) : x2 + y2 = 1} = {(r, θ) : 0 ≤ r < 1, 0 ≤ θ < 2π}.

Page 183: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

168 Computational Partial Differential Equations Using MATLAB

FIGURE 6.8P3 element.

Hint: Use ||v||L2(∂Ω) = (∫ 2π

0 |v(1, θ)|2dθ)1/2, and start with

v(1, θ)2 =∫ 1

0

∂r(r2v(r, θ)2)dr.

4. For the boundary value problem

−u′′+ u

′+ u = f in (0, 1),

u′(0) = u

′(1) = 0,

we can form the following variational problem: find u ∈ H1(0, 1) such that

A(u, v) = (f, v) ∀ v ∈ H1(0, 1),

where A(u, v) =∫ 1

0(u

′v

′+ u

′v + uv)dx. Show that A(·, ·) is continuous and

coercive.5. Derive the variational formulation for the problem

−�u+ au = f in Ω,∂u

∂n= g on ∂Ω,

where a(x) ≥ a∗ > 0 on Ω, and f ∈ L2(Ω), g ∈ L2(Ω). Check if the conditionsof the Lax-Milgram lemma are satisfied.

6. For a triangle K (see Fig. 6.8). Prove that a function v ∈ P3(K) isuniquely determined by the values v(ai), v(ai,j) and v(a0), 1 ≤ i, j ≤ 3, i �= j.

7. Prove that the problem (6.64) is equivalent to the minimization in H10 (Ω)

of the energy functional

J(v) =12A(v, v) − (f, v),

Page 184: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 169

i.e., u = minv∈H10 (Ω) J(v).

8. Let Vh be the finite element space (6.66), P kh is the projection operatorfrom L2(Ω) → Vh, i.e., for any v ∈ L2(Ω),

(P kh v − v, wh) = 0, ∀ wh ∈ Vh.

Prove that

||P kh v − v||L2(Ω) ≤ Chl+1|v|Hl+1(Ω), 1 ≤ l ≤ k, ∀ v ∈ H l+1(Ω).

9. Prove the Gronwall’s inequality stated in Lemma 6.7. Hint: Let F (t) =∫ t0f(τ)dτ and rewrite (6.92) as d

dt [e−tF (t)] ≤ g(t)e−t.

10. Prove that the Crank-Nicolson scheme (6.97)-(6.98) is unconditionallystable.

References

[1] R.A. Adams. Sobolev Spaces. Academic Press, New York, NY, 1975.

[2] M. Ainsworth and J.T. Oden. A Posteriori Error Estimation in FiniteElement Analysis. Wiley-Interscience, New York, NY, 2000.

[3] T. Apel. Anisotropic Finite Elements: Local Estimates and Applications.Teubner, Stuttgart, 1999.

[4] T. Arbogast and Z. Chen. On the implementation of mixed methodsas nonconforming methods for second-order elliptic problems. Math.Comp., 64(211):943–972, 1995.

[5] J.H. Argyris. Energy theorems and structural analysis. Aircraft Engi-neering, 26:347–356, 1954.

[6] I. Babuska and A.K. Aziz. Survey lectures on the mathematical foun-dations of the finite element method, in The Mathematical Foundationsof the Finite Element Method with Applications to Partial DifferentialEquations, A.K. Aziz (ed.), Academic Press, New York, NY, 3–359,1972.

[7] W. Bangerth and R. Rannacher. Adaptive Finite Element Methods forSolving Differential Equations. Birkhauser, Basel, 2003.

[8] D. Braess. Finite Elements. Cambridge University Press, 3rd Edition,Cambridge, UK, 2007.

[9] S.C. Brenner and L.R. Scott. The Mathematical Theory of Finite Ele-ment Methods. Springer-Verlag, Berlin/Heidelberg, 1994.

Page 185: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

170 Computational Partial Differential Equations Using MATLAB

[10] F. Brezzi and M. Fortin. Mixed and Hybrid Finite Element Methods.Springer-Verlag, Berlin/Heidelberg, 1991.

[11] G. Chavent and J. Jaffre. Mathematical Models and Finite Elements forReservoir Simulation. North-Holland, Amsterdam, 1978.

[12] C.M. Chen and Y.Q. Huang, High Accuracy Theory of Finite ElementMethods (in Chinese). Hunan Science Press, China, 1995.

[13] Z. Chen. Finite Element Methods and Their Applications. Springer-Verlag, Berlin, 2005.

[14] Z. Chen, G. Huan and Yuanle Ma. Computational Methods for Multi-phase Flows in Porous Media. SIAM, Philadelphia, PA, 2006.

[15] P.G. Ciarlet. The Finite Element Method for Elliptic Problems. North-Holland, Amsterdam, 1978.

[16] R.W. Clough. The finite element method in plane stress analysis, inProceedings of the Second ASCE Conference on Electronic Computation.Pittsburgh, Pennsylvania, 1960.

[17] R. Courant. Variational methods for the solution of problems of equi-librium and vibrations. Bull. Amer. Math. Soc., 49:1–23, 1943.

[18] L. Demkowicz. Computing with hp-Adaptive Finite Elements. Chapman& Hall/CRC, Boca Raton, FL, 2006.

[19] K. Eriksson, D. Estep, P. Hansbo, C. Johnson. Computational Differ-ential Equations. Cambridge University Press, Cambridge, UK, 1996.

[20] G. Fairweather. Finite Element Galerkin Methods for Differential Equa-tions. Marcel Dekker, New York-Basel, 1978.

[21] V. Girault and P.A. Raviart. Finite Element Methods for Navier-StokesEquations – Theory and Algorithms. Springer-Verlag, Berlin, 1986.

[22] J.-L. Guermond and A. Ern. Theory and Practice of Finite Elements.Springer-Verlag, New York, 2004.

[23] Max D. Gunzburger. Finite Element Methods for Viscous IncompressibleFlows: A Guide to Theory, Practice, and Algorithms. Academic Press,San Diego, CA, 1989.

[24] B.N. Jiang. The Least-Squares Finite Element Method: Theory andApplications in Fluid Dynamics and Electromagnetics. Springer-Verlag,Berlin, 1998.

[25] C. Johnson. Numerical Solution of Partial Differential Equations by theFinite Element Method. Cambridge University Press, New York, 1988.

[26] M. Krizek, P. Neittaanmaki and R. Stenberg (eds.). Finite ElementMethods: Fifty Years of the Courant Element. Marcel Dekker, NewYork, 1994.

Page 186: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Basic Theory 171

[27] M. Krizek, P. Neittaanmaki and R. Stenberg (eds.). Finite ElementMethods: Superconvergence, Post-Processing A Posteriori Estimates.Marcel Dekker, New York, 1998.

[28] Q. Lin and J. Lin. Finite Element Methods: Accuracy and Improvement.Science Press, Beijing, 2007.

[29] Q. Lin and N. Yan. The Construction and Analysis of High AccurateFinite Element Methods (in Chinese). Hebei University Press, Hebei,China, 1996.

[30] J.M. Melenk. hp-Finite Element Methods for Singular Perturbations.Springer, New York, NY, 2002.

[31] P. Monk. Finite Element Methods for Maxwell’s Equations. OxfordUniversity Press, Oxford, UK, 2003.

[32] J.T. Oden and G.F. Carey. Finite Elements – Mathematical Aspects,Vol. IV. Prentice-Hall, Englewood Cliffs, NJ, 1983.

[33] A. Quarteroni and A. Valli. Numerical Approximation of Partial Differ-ential Equations. Springer-Verlag, Berlin, 1994.

[34] R. Rannacher and S. Turek. Simple nonconforming quadrilateral Stokeselement. Numer. Methods Partial Differential Equations, 8(2):97–111,1992.

[35] H.-G. Roos, M. Stynes and L. Tobiska. Numerical Methods for Singu-larly Perturbed Differential Equations: Convection-Diffusion and FlowProblems. Springer-Verlag, Berlin, 1996.

[36] C. Schwab. p- and hp- Finite Element Methods, Theory and Applicationsto Solid and Fluid Mechanics. Oxford University Press, New York, NY,1998.

[37] Z.C. Shi. Error estimates of Morley element. Chinese J. Numer. Math.& Appl., 12:102–108, 1990.

[38] Z.C. Shi. A convergence condition for the quadrilateral Wilson element.Numer. Math., 44(3):349–361, 1984.

[39] P. Solin, K. Segeth and I. Dolezel. Higher-Order Finite Element Methods.Chapman & Hall/CRC Press, Boca Raton, FL, 2003.

[40] G. Strang and G.J. Fix. An Analysis of the Finite Element Method.Prentice-Hall, Englewood Cliffs, NJ, 1973.

[41] V. Thomee. Galerkin Finite Element Methods for Parabolic Problems.Springer-Verlag, Berlin/New York, 1997.

[42] M.J. Turner, R.W. Clough, H.C. Martin and L.J. Topp. Stiffness anddeflection analysis of complex structures. J. Aero. Sci., 23:805–823,1956.

Page 187: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

172 Computational Partial Differential Equations Using MATLAB

[43] R. Verfurth. A Review of a Posteriori Error Estimation and AdaptiveMesh-Refinement Techniques. Wiley, Teubner, 1996.

[44] L. Wahlbin. Superconvergence in Galerkin Finite Element Methods.Springer-Verlag, Berlin/Heidelberg, 1995.

[45] M.F. Wheeler. A priori L2 error estimates for Galerkin approxima-tions to parabolic partial differential equations. SIAM J. Numer. Anal.,10:723–759, 1973.

Page 188: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

7

Finite Element Methods: Programming

In this chapter, we will demonstrate the practical implementation of finiteelement methods for a 2-D convection-diffusion problem:

−�u+ �v · ∇u = s in Ω, (7.1)u = uexact on ∂Ω. (7.2)

The basic procedure for solving partial differential equations (PDE) is asfollows:

1. Discretize the physical domain into finite elements;2. Rewrite the PDE in its weak formulation;3. Calculate element matrices for each finite element;4. Assemble element matrices to form a global linear system;5. Implement the boundary conditions by modifying the global linear sys-

tem;6. Solve the linear system and postprocess the solution.In the rest of this chapter, we will discuss details of implementation of

the above steps. More specifically, in Sec. 7.1, we present a simple grid-generation algorithm and its implementation. Sec. 7.2 formulates the finiteelement equation for the convection-diffusion model. In Sec. 7.3, we discusshow to calculate those elementary matrices. Then we discuss the finite elementassembly procedure and how to implement the Dirichlet boundary conditionin Sec. 7.4. In Sec. 7.5, we present the complete MATLAB code for the P1

element and an example problem solved by our code. Finally, we present aMATLAB code for the Q1 element and demonstrate how to use it to solve anelliptic problem.

7.1 FEM mesh generation

For simplicity, we assume that the physical domain Ω is a polygon, whichcan be discretized into NE triangular elements Th. Here we describe a simplealgorithm: implementation starting with a very coarse mesh, then generatingdifferent levels of finer meshes by uniform subdivision, i.e., each triangle issubdivided into four smaller triangles [12].

173

Page 189: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

174 Computational Partial Differential Equations Using MATLAB

FIGURE 7.1Uniform refinement of a given triangle 123.

For example (see Fig. 7.1), a triangle 123 is subdivided into four smallertriangles 146, 425, 653 and 456, which are labeled as subtriangle 1, 2, 3, and 4,respectively. Note that vertices of each triangle are labeled counterclockwise.

An FEM mesh generally contains much more information than the finitedifference method. First, we generate the nodal coordinates (xi, yi), 1 ≤ i ≤NG, where NG denotes the total number of nodes in the mesh. Then we need aconnectivity matrix conn(i, j) to describe the relation between local nodes andglobal nodes. For a linear triangular grid, conn(i, j), j = 1, 2, 3, i = 1, · · · , NE ,denotes the global label of the jth node of the ith element, where NE is thetotal number of elements.

To implement boundary conditions, we need to know which nodes are onthe boundary, and what types of boundary conditions are there. In our imple-mentation, we introduce a global boundary condition indicator gbc(i, j), 1 ≤i ≤ NG, 1 ≤ j ≤ 2. For the ith global node, we define

gbc(i, 1) ={ 0 if it is an interior node

1 if it is a Dirichlet node2 if it is an Neumann node

Furthermore, when gbc(i, 1) �= 0, we use gbc(i, 2) to specify the correspondingboundary value.

In order to generate gbc(i, j) easily, we let gbc(i, j) inherit directly from theelement boundary condition indicator efl(i, j), 1 ≤ i ≤ NE , 1 ≤ j ≤ 3. Notethat efl(i, j) can be generated from the initial coarse mesh as follows: whenthe jth local node is a midpoint generated from two vertices of the previouslevel, it will be an interior node if either of the two vertices is an interior

Page 190: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 175

1

2

4 3

5

1

2

3

4

FIGURE 7.2The initial mesh and the one after one refinement.

node; it will be a Dirichlet (or Neumann) node if both vertices are Dirichlet(or Neumann) nodes; it will be an Neumann node if one is Dirichlet and theother one is Neumann; when the jth local node is a vertex from the previouslevel, it will have the same type as that vertex.

An example initial coarse mesh and the mesh after one refinement are givenin Fig. 7.2, where we label all the nodes and elements for the initial mesh.The connectivity matrix for the initial mesh is:

conn(1, 1 : 3) = 1, 2, 3, conn(2, 1 : 3) = 1, 3, 4,conn(3, 1 : 3) = 1, 4, 5, conn(4, 1 : 3) = 1, 5, 2.

The MATLAB source code for generating the triangular grid is attached asfollows:

%---------------------------------------------------------% generate a triangular grid by uniform refinement.%% ne: total number of elements% np: total number of nodes% p: the x- and y-coordinates of all nodes% conn: connectivity matrix% gbc: boundary condition indicator for all nodes% nref>=1: number of refinement level%---------------------------------------------------------function [ne,np,p,conn,gbc] = gen_p1grid(nref)

% define an initial coarse meshne = 4;

Page 191: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

176 Computational Partial Differential Equations Using MATLAB

x(1,1)= 0.5; y(1,1)= 0.5; efl(1,1)=0; % 0 for inner nodex(1,2)= 1.0; y(1,2)= 0.0; efl(1,2)=1; % 1 for Dirichlet nodex(1,3)= 1.0; y(1,3)= 1.0; efl(1,3)=1;

x(2,1)= 0.5; y(2,1)= 0.5; efl(2,1)=0; % second elementx(2,2)= 1.0; y(2,2)= 1.0; efl(2,2)=1;x(2,3)= 0.0; y(2,3)= 1.0; efl(2,3)=1;

x(3,1)= 0.5; y(3,1)= 0.5; efl(3,1)=0; % third elementx(3,2)= 0.0; y(3,2)= 1.0; efl(3,2)=1;x(3,3)= 0.0; y(3,3)= 0.0; efl(3,3)=1;

x(4,1)= 0.5; y(4,1)= 0.5; efl(4,1)=0; % fourth elementx(4,2)= 0.0; y(4,2)= 0.0; efl(4,2)=1;x(4,3)= 1.0; y(4,3)= 0.0; efl(4,3)=1;

% generate finer mesh based on the given coarse meshfor i=1:nrefnm = 0; % count the elements generated by each refinement

for j=1:ne% mid-edge nodes of each triangle become new nodesx(j,4)=0.5*(x(j,1)+x(j,2)); y(j,4)=0.5*(y(j,1)+y(j,2));x(j,5)=0.5*(x(j,2)+x(j,3)); y(j,5)=0.5*(y(j,2)+y(j,3));x(j,6)=0.5*(x(j,3)+x(j,1)); y(j,6)=0.5*(y(j,3)+y(j,1));

% generate mid-node BC indicatior from its parentif (efl(j,1)==1 & efl(j,2)==1)

efl(j,4) = 1;else

efl(j,4)=0;endif (efl(j,2)==1 & efl(j,3)==1)

efl(j,5) = 1;else

efl(j,5)=0;endif (efl(j,3)==1 & efl(j,1)==1)

efl(j,6) = 1;else

efl(j,6)=0;end

% generate four sub-elements

Page 192: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 177

nm = nm+1; % 1st sub-elementxn(nm,1)=x(j,1); yn(nm,1)=y(j,1); efln(nm,1)=efl(j,1);xn(nm,2)=x(j,4); yn(nm,2)=y(j,4); efln(nm,2)=efl(j,4);xn(nm,3)=x(j,6); yn(nm,3)=y(j,6); efln(nm,3)=efl(j,6);

nm = nm+1; % 2nd sub-elementxn(nm,1)=x(j,4); yn(nm,1)=y(j,4); efln(nm,1)=efl(j,4);xn(nm,2)=x(j,2); yn(nm,2)=y(j,2); efln(nm,2)=efl(j,2);xn(nm,3)=x(j,5); yn(nm,3)=y(j,5); efln(nm,3)=efl(j,5);

nm = nm+1; % 3rd sub-elementxn(nm,1)=x(j,6); yn(nm,1)=y(j,6); efln(nm,1)=efl(j,6);xn(nm,2)=x(j,5); yn(nm,2)=y(j,5); efln(nm,2)=efl(j,5);xn(nm,3)=x(j,3); yn(nm,3)=y(j,3); efln(nm,3)=efl(j,3);

nm = nm+1; % 4th sub-elementxn(nm,1)=x(j,4); yn(nm,1)=y(j,4); efln(nm,1)=efl(j,4);xn(nm,2)=x(j,5); yn(nm,2)=y(j,5); efln(nm,2)=efl(j,5);xn(nm,3)=x(j,6); yn(nm,3)=y(j,6); efln(nm,3)=efl(j,6);

end % end of loop over current elements

ne = 4*ne; % increase the number of elements by a factor of fourfor k=1:ne % relabel the new points

for l=1:3x(k,l)= xn(k,l); y(k,l)= yn(k,l);efl(k,l)=efln(k,l);

endend

end % end of refinement loop

% get rid of redundant mid-edge nodes:% fix the first element, then loop the rest elementsp(1,1)=x(1,1); p(1,2)=y(1,1); gbc(1,1)=efl(1,1);p(2,1)=x(1,2); p(2,2)=y(1,2); gbc(2,1)=efl(1,2);p(3,1)=x(1,3); p(3,2)=y(1,3); gbc(3,1)=efl(1,3);conn(1,1)=1; conn(1,2)=2; conn(1,3)=3;

np=3; % we already has 3 nodes from 1st element!% loop over rest elements: Id=0 means a new nodeeps = 1.0e-8;for i=2:ne % loop over elementsfor j=1:3 % loop over element nodes

Id=0;for k=1:np

Page 193: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

178 Computational Partial Differential Equations Using MATLAB

if(abs(x(i,j)-p(k,1)) < eps & abs(y(i,j)-p(k,2)) < eps)Id = 1; % indicate this node has already been usedconn(i,j) = k; % jth node of element i = kth global node

endend

if(Id==0) % record the new nodenp = np+1;p(np,1)=x(i,j); p(np,2)=y(i,j);gbc(np,1) = efl(i,j); conn(i,j)=np;

end

endend % end of loop over elements

return;

7.2 Forming FEM equations

The weak formulation of (7.1)-(7.2) is: Find u ∈ H1(Ω) such that

(∇u,∇φ) + (�v · ∇u, φ) = (s, φ), ∀ φ ∈ H10 (Ω) (7.3)

The corrsponding finite element method is: Find uh ∈ Vh ⊂ H1(Ω) suchthat

(∇uh,∇φh) + (�v · ∇uh, φh) = (s, φh), ∀ φh ∈ Vh, (7.4)

where the finite element space

Vh = {v : v is continuous on Ω and v|E ∈ P1(E), E ∈ Th}.

Suppose that u is approximated over a finite element E (here it is a triangle)by

u(x, y) ≈ uEh (x, y) =3∑

j=1

uEj ψEj (x, y), (7.5)

where uEj is the value of uh at the jth node of the element, and ψEj is theLagrange interpolation function, which satisfies

ψEj (xi, yi) = δij .

Over each element E, we need to calculate some element matrices as follows.Substituting (7.5) into (7.4) with test function φ = ψEi , i = 1, 2, 3, respectively,

Page 194: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 179

and approximating the source function s by

s(x, y) ≈3∑

j=1

sjψEj (x, y), sj = s(xj , yj),

we obtain the element diffusion matrix (stiffness matrix)

Aij ≡∫

E

∇ψEj · ∇ψEi dxdy, i, j = 1, 2, 3, (7.6)

the element convection matrix

Bij ≡∫

E

(�v · ∇ψEj )ψEi dxdy, i, j = 1, 2, 3, (7.7)

and the element mass matrix

Mij ≡∫

E

ψEj ψEi dxdy, i, j = 1, 2, 3. (7.8)

Summing up all elements En, 1 ≤ n ≤ NE , of the mesh Th, we obtain asystem of linear equations for the unknown numerical solution uj at all nodes:

NE∑

n=1

(Aij +Bij)uj =NE∑

n=1

Mijsj . (7.9)

7.3 Calculation of element matrices

The element matrices are often computed on a reference element. The map-ping from an arbitrary triangular element with vertices (xi, yi), 1 ≤ i ≤ 3, toa reference element with vertices

(ξ1, η1) = (0, 0), (ξ2, η2) = (1, 0), (ξ3, η3) = (0, 1)

is given by

x = x1 + (x2 − x1)ξ + (x3 − x1)η =3∑

j=1

xj ψj(ξ, η), (7.10)

y = y1 + (y2 − y1)ξ + (y3 − y1)η =3∑

j=1

yjψj(ξ, η), (7.11)

whereψ1(ξ, η) = ζ = 1 − ξ − η, ψ2(ξ, η) = ξ, ψ3(ξ, η) = η.

Page 195: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

180 Computational Partial Differential Equations Using MATLAB

Note that (ξ, η, ζ) are the triangle barycentric coordinates.The Jacobi matrix of the mapping is denoted as

J ≡[∂x∂ξ

∂x∂η

∂y∂ξ

∂y∂η

],

which determinant is det(J) =∣∣∣∣x2 − x1 x3 − x1

y2 − y1 y3 − y1

∣∣∣∣ = 2A, where A denotes the

area of the triangle.The interpolation function ψj(x, y) over the physical triangle is defined as

ψj(x, y) = ψj(ξ(x, y), η(x, y)),

from which we have

∂ψj∂ξ

=∂ψj∂x

∂x

∂ξ+∂ψj∂y

∂y

∂ξ, (7.12)

∂ψj∂η

=∂ψj∂x

∂x

∂η+∂ψj∂y

∂y

∂η, (7.13)

i.e.,

JT · ∇ψj =

[∂ψj

∂ξ∂ψj

∂η

], j = 1, 2, 3,

where we denote the gradient

∇ψj =

[∂ψj

∂x∂ψj

∂y

].

In particular,

JT · ∇ψ1 = −[

11

], JT · ∇ψ2 =

[10

], JT · ∇ψ3 =

[01

]. (7.14)

By linear algebra, it is easy to prove the following lemma:

LEMMA 7.1

For any 2 × 2 non-singular matrix M =[a bc d

],

its inverse M−1 = 1

det(M)

[d −b−c a

].

Using Lemma 7.1, we obtain

(JT )−1 =1

2A

[y3 − y1 −(y2 − y1)

−(x3 − x1) x2 − x1

],

Page 196: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 181

substituting which into (7.14) gives us

∇ψ1 =1

2A

[−(y3 − y2)x3 − x2

],∇ψ2 =

12A

[−(y1 − y3)x1 − x3

],∇ψ3 =

12A

[−(y2 − y1)x2 − x1

].

Hence the element diffusion matrix

Aij =∫

E

∇ψj · ∇ψidxdy = 2A∫

E

∇ψj · ∇ψidξdη

can be obtained without any numerical integration, since ∇ψj are independentof ξ and η.

LEMMA 7.2

A11 =1

4A[(y3 − y2)2 + (x3 − x2)2], (7.15)

A12 =1

4A[(y3 − y2)(y1 − y3) + (x3 − x2)(x1 − x3)], (7.16)

A13 =1

4A[(y3 − y2)(y2 − y1) + (x3 − x2)(x2 − x1)], (7.17)

A23 =1

4A[(y1 − y3)(y2 − y1) + (x1 − x3)(x2 − x1)], (7.18)

A22 =1

4A[(y1 − y3)2 + (x1 − x3)2], (7.19)

A33 =1

4A[(y2 − y1)2 + (x2 − x1)2]. (7.20)

LEMMA 7.3[4, p. 201] ∫

E

ζlξmηndξdη =l!m!n!

(l +m+ n+ 2)!,

where l,m, and n are non-negative integers.

Assume that the velocity �v = (vx, vy) is constant, then the element convec-tion matrix can be simplified as

Bij =∫

E

(�v · ∇ψj)ψidxdy (7.21)

= (�v · ∇ψj)∫

E

ψi(ξ, η) · 2Adξdη =A

3(�v · ∇ψj), (7.22)

where we used the fact∫

E

ξdξdη =∫

E

ηdξdη =∫

E

ζdξdη =16,

Page 197: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

182 Computational Partial Differential Equations Using MATLAB

which is obtained by Lemma 7.3.

LEMMA 7.4

B11 =16[vy · (x3 − x2) − vx · (y3 − y2)], B21 = B31 = B11, (7.23)

B12 =16[vy · (x1 − x3) − vx · (y1 − y3)], B22 = B32 = B12, (7.24)

B13 =16[vy · (x2 − x1) − vx · (y2 − y1)], B23 = B33 = B13. (7.25)

Similarly, the element mass matrix can be calculated

Mij =∫

E

ψEj ψEi dxdy = 2A

E

ψjψidξdη,

from which and Lemma 7.3, we have

LEMMA 7.5

M = 2A∫

E

⎣ζ2 ζξ ζηξζ ξ2 ξηηζ ηξ η2

⎦ dξη =A

12

⎣2 1 11 2 11 1 2

⎦ .

Below are the MATLAB functions for calculating the element diffusion,advection and mass matrices.

%-------------------------------------------------------% evaluate the element diffusion matrix for P1 element%-------------------------------------------------------function [elmA] = locA(x1,y1,x2,y2,x3,y3)

dx23 = x2-x3; dy23 = y2-y3;dx31 = x3-x1; dy31 = y3-y1;dx12 = x1-x2; dy12 = y1-y2;

A = 0.5*(dx31*dy12 - dy31*dx12); % triangle area

elmA(1,1) = 0.25*(dx23*dx23 + dy23*dy23)/A;elmA(1,2) = 0.25*(dx23*dx31 + dy23*dy31)/A;elmA(1,3) = 0.25*(dx23*dx12 + dy23*dy12)/A;

elmA(2,1) = 0.25*(dx31*dx23 + dy31*dy23)/A;elmA(2,2) = 0.25*(dx31*dx31 + dy31*dy31)/A;elmA(2,3) = 0.25*(dx31*dx12 + dy31*dy12)/A;

Page 198: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 183

elmA(3,1) = 0.25*(dx12*dx23 + dy12*dy23)/A;elmA(3,2) = 0.25*(dx12*dx31 + dy12*dy31)/A;elmA(3,3) = 0.25*(dx12*dx12 + dy12*dy12)/A;

return;

%----------------------------------------------------% calculate the element matrix from convection term%----------------------------------------------------function [elmB] = locB(vx,vy,x1,y1,x2,y2,x3,y3)

dx32 = x3-x2; dy32 = y3-y2;dx13 = x1-x3; dy13 = y1-y3;dx21 = x2-x1; dy21 = y2-y1;

elmB(1,1) = (-vx*dy32 + vy*dx32)/6.0;elmB(1,2) = (-vx*dy13 + vy*dx13)/6.0;elmB(1,3) = (-vx*dy21 + vy*dx21)/6.0;

elmB(2,1) = elmB(1,1); elmB(3,1) = elmB(1,1);elmB(2,2) = elmB(1,2); elmB(3,2) = elmB(1,2);elmB(2,3) = elmB(1,3); elmB(3,3) = elmB(1,3);

return;

%-------------------------------------------------------------% calculate the element mass matrix for P1 element%-------------------------------------------------------------function [elmM] = locM(x1,y1,x2,y2,x3,y3)

dx23 = x2-x3; dy23 = y2-y3;dx31 = x3-x1; dy31 = y3-y1;dx12 = x1-x2; dy12 = y1-y2;

A = 0.5*(dx31*dy12 - dy31*dx12);c_diag = A/6; % diagnonal constantc_off = A/12; % off-diagnonal constant

for j=1:3for i=1:3

if(i==j)elmM(i,j) = c_diag;

else

Page 199: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

184 Computational Partial Differential Equations Using MATLAB

elmM(i,j) = c_off;end

endend

return;

7.4 Assembly and implementation of boundary condi-tions

To obtain the global coefficient matrix by assembling the contributions fromeach element coefficient matrix, we just need to loop through all elements inthe mesh, find the corresponding global nodal label for each local node, andput them in the right locations of the global coefficient matrix. A pseudo codeis listed below:

for n=1:NE % loop through all elementscomputer element coefficient matrixfor i=1:3 % loop through all nodes in the element

i1 = conn(n,i)for j=1:3

j1=conn(n,j)Ag(i1,j1)=Ag(i1,j1)+Aloc(i,j)

EndEnd

End

The implementation of the Dirichlet boundary condition can be done afterassembly, i.e., we have a linear system

Ag · u = b (7.26)

Suppose we have to specify u = u(xk, yk) at the kth global node. We canimpose this Dirichlet boundary condition as follows:

1. Replace each entry bi of b with bi −Agikuk.2. Reset all entries in the kth row and kth column of Ag to zero, then the

diagonal entry Agkk to one.3. Replace the kth entry bk of b with uk.A pseudo code is listed below:

for k=1:NG % loop through all global nodesIf (gbc(k,1) = 1) then % find a Dirichlet node

for i=1:NGb(i) = b(i) - Ag(i,k)*gbc(k,2)

Page 200: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 185

00.2

0.40.6

0.81

0

0.2

0.4

0.6

0.8

1−0.2

0

0.2

0.4

0.6

0.8

1

1.2

FIGURE 7.3Numerical solutions obtained with nref = 3.

Ag(i,k) = 0Ag(k,i) = 0

EndAg(k,k) = 1b(k) = gbc(k,2)

EndEnd

7.5 The MATLAB code for P1 element

Here we provide our implementation for solving (7.1)-(7.2) with �v = (1, 1),and s = −2y2 − 2x2 + 2xy2 + 2yx2 such that the exact solution is given byu = x2y2 over the domain Ω = [0, 1]2.

We solved this problem using the P1 element using several levels of meshes;the maximum errors are

0.0044, 0.0014, 4.1030e− 004, 1.2032e− 004,

for nref = 2, 3, 4, 5 in the MATLAB function ellip P1.m. This assures us thatthe accuracy of the method is O(h2), which is consistent with our theoreticalresult.

An examplary numerical solution with nref = 3 is shown in Fig. 7.3.The MATLAB function ellip P1.m and its auxiliary functions EXACT.m

and SRC.m are shown below.

Page 201: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

186 Computational Partial Differential Equations Using MATLAB

%-------------------------------------------------------% ellip.m: finite element code for solving a 2nd-order% convecton-diffusion problem using p1 element.%% Functions used:% get_p1grid.m: generate a triangular grid% locA.m, locB.m, locM.m: evaluate element matrices% EXACT.m, SRC.m: exact solution and RHS function of the PDE%% nref=2,3,4,5 give max error as follows:% 0.0044, 0.0014, 4.1030e-004, 1.2032e-004.%-------------------------------------------------------clear all;

% velocity components in the governing equationVx=1.0; Vy=1.0;

% generate a triangular grid by uniformly refining a coarse gridnref = 3; % level of refinement[ne,np,p,conn,gbc] = gen_p1grid(nref);

% plot the mesh to see if it is rightfigure(1);trimesh(conn,p(:,1),p(:,2));

pause(2);

% specify the exact solution and use it for Dirichlet BCfor i=1:np

u_ex(i)=feval(@EXACT,p(i,1),p(i,2));if(gbc(i,1)==1) % indicator for Dirichlet BC

gbc(i,2) = u_ex(i);end

end

% initialize those arraysAg = zeros(np,np);b = zeros(np,1);

% loop over the elementsfor l=1:ne

j=conn(l,1); x1=p(j,1); y1=p(j,2);j=conn(l,2); x2=p(j,1); y2=p(j,2);j=conn(l,3); x3=p(j,1); y3=p(j,2);

Page 202: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 187

% compute local element matrices[elmA] = locA(x1,y1,x2,y2,x3,y3);[elmB] = locB(Vx,Vy,x1,y1,x2,y2,x3,y3);[elmM] = locM(x1,y1,x2,y2,x3,y3);

for i=1:3i1 = conn(l,i);for j=1:3j1 = conn(l,j);% assemble into the global coefficient matrixAg(i1,j1) = Ag(i1,j1) + elmA(i,j) + elmB(i,j);% form the RHS of the FEM equationb(i1) = b(i1) + elmM(i,j)*feval(@SRC,p(j1,1),p(j1,2));

endend

end

% impose the Dirichlet BCfor m=1:npif(gbc(m,1)==1)for i=1:npb(i) = b(i) - Ag(i,m) * gbc(m,2);Ag(i,m) = 0; Ag(m,i) = 0;

endAg(m,m) = 1.0; b(m) = gbc(m,2);

endend

% solve the linear systemu_fem=Ag\b;

% plot the numerical solutionfigure(2);trisurf(conn,p(:,1),p(:,2),u_fem);

% compare with exact solutiondisp(’max err=’), max(abs(u_fem-u_ex’)),

%-----------------------------------------------------% exact solution for our model

function val=EXACT (x,y)

val = x^2*y^2;

Page 203: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

188 Computational Partial Differential Equations Using MATLAB

%---------------------------------------------% source function at the rhs of the equation% -(u_xx+u_yy)+v_vec*grad u = src% u=x^2*y^2, v_vec=(1,1),

function val=SRC (x,y)

val = -2*y^2-2*x^2+2*x*y^2+2*y*x^2;

7.6 The MATLAB code for the Q1 element

In this section we present a MATLAB code for solving the elliptic problem

−�u+ u = f in Ω = (0, 1)2, (7.27)∂u

∂n= 0 on ∂Ω, (7.28)

using the Q1 element.Here we describe some important implementation procedures, since we have

already discussed most steps for the triangular P1 element in previous sections.First we need to generate a rectangular mesh, which is much easier com-

pared to unstructured triangular mesh. The MATLAB code getQ1mesh.m isshown below.

% Generate Q1 mesh on rectangle [0, length]x[0, height]% nx,ny: number of elements in each direction% x,y: 1-D array for nodal coordinates% conn(1:ne,1:4): connectivity matrix% ne, np: total numbers of elements, nodes generated

function[x,y,conn,ne,np] = getQ1mesh(length,height,nx,ny)

ne = nx*ny;np = (nx+1)*(ny+1);

% create nodal coordinatesdx=length/nx; dy=height/ny;for i = 1:(nx+1)

for j=1:(ny+1)x((ny+1)*(i-1)+j) = dx*(i-1);y((ny+1)*(i-1)+j) = dy*(j-1);

Page 204: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 189

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

1

2

3

4

5

6

7

8

9

FIGURE 7.4Example Q1 element: node and element labelings.

endend

% connectivity matrix: countclockwise start at low-left cornerfor j=1:nx

for i=1:nyele = (j-1)*ny + i;conn(ele,1) = ele + (j-1);conn(ele,2) = conn(ele,1) + ny + 1;conn(ele,3) = conn(ele,2) + 1;conn(ele,4) = conn(ele,1) + 1;

endend

A simple 3 × 3 rectangular mesh generated with this code is shown in Fig.7.4, where the nodal numbers and element numbers are provided. Note thatthe nodes of each element are oriented in a counterclockwise manner. Forexample, the connectivity matrices for element 1 and element 2 are given by:

conn(1, 1 : 4) = 1, 5, 6, 2, conn(2, 1 : 4) = 2, 6, 7, 3.

The finite element method for solving (7.27)-(7.28) is: Find uh ∈ V h ⊂H1(Ω) such that

(∇uh,∇φh) + (uh, φh) = (f, φh) ∀ φh ∈ V h, (7.29)

where the Q1 conforming finite element space

V h = {v : vis continuous onΩandv|E ∈ Q1(E), E ∈ Th}.

Page 205: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

190 Computational Partial Differential Equations Using MATLAB

On each rectangular element E, u is approximated by

uEh (x, y) =4∑

j=1

uEj ψEj (x, y), (7.30)

which leads to the element coefficient matrix of (7.29) as

Aij ≡∫

E

∇ψEj · ∇ψEi dxdy +∫

E

ψEj ψEi dxdy, i, j = 1, · · · , 4. (7.31)

The calculation of Aij is often carried out on a reference rectangle withvertices

(ξ1, η1) = (−1,−1), (ξ2, η2) = (1,−1), (ξ3, η3) = (1, 1), (ξ4, η4) = (−1, 1),

whose corresponding shape functions

ψi(ξ, η) =14(1 + ξiξ)(1 + ηiη), i = 1, · · · , 4. (7.32)

The mapping between an arbitrary rectangular element with vertices (xi, yi), 1 ≤i ≤ 4, and the reference element is given by

x =4∑

j=1

xjψj(ξ, η), y =4∑

j=1

yjψj(ξ, η). (7.33)

From (7.12)-(7.13), we see that

∇ψj = (JT )−1

[∂ψj

∂ξ∂ψj

∂η

]=

1det(J)

[∂y∂η −∂y

∂ξ

−∂x∂η

∂x∂ξ

][∂ψj

∂ξ∂ψj

∂η

](7.34)

=1

det(J)

[(∑4

j=1 yj∂ψj

∂η )∂ψj

∂ξ − (∑4

j=1 yj∂ψj

∂ξ )∂ψj

∂η

−(∑4j=1 xj

∂ψj

∂η )∂ψj

∂ξ + (∑4

j=1 xj∂ψj

∂ξ )∂ψj

∂η

]. (7.35)

Note that Aij cannot be evaluated exactly as for the P1 element. Hence wewill use Gaussian quadrature over the reference rectangle. For example,

E

G(x, y)dxdy =∫

E

G(x, y)|J |dξdη

≈N∑

m=1

(N∑

n=1

G(ξm, ηn)|J |ωn)ωm,

where ξm and ωm (ηm and ωn) are the one-dimensional quadrature points andweights, respectively. In our implementation, we use the Gaussian quadraturerule of order 2, in which case

ξ1 = − 1√3, ξ2 =

1√3, ω1 = ω2 = 1.

Page 206: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 191

Below is the MATLAB code elemA.m, which is used to calculate the elementmatrix and right-hand side vector

(f, φi) ≈ (14

4∑

j=1

fj , φi), i = 1, 2, 3, 4.

function [ke,rhse] = elemA(conn,x,y,gauss,rhs,e);

% 2d Q1 element stiffness matrixke = zeros(4,4);rhse=zeros(4,1);one = ones(1,4);psiJ = [-1, +1, +1, -1]; etaJ = [-1, -1, +1, +1];

% get coordinates of element nodesfor j=1:4

je = conn(e,j); xe(j) = x(je); ye(j) = y(je);end

for i=1:2 % loop over gauss points in etafor j=1:2 % loop over gauss points in psi

eta = gauss(i); psi = gauss(j);% shape function: countcockwise starting at left-low corner

NJ=0.25*(one + psi*psiJ).*(one + eta*etaJ);% derivatives of shape functions in reference coordinatesNJpsi = 0.25*psiJ.*(one + eta*etaJ); % 1x4 arrayNJeta = 0.25*etaJ.*(one + psi*psiJ); % 1x4 array% derivatives of x and y wrt psi and etaxpsi = NJpsi*xe’; ypsi = NJpsi*ye’;xeta = NJeta*xe’; yeta = NJeta*ye’;Jinv = [yeta, -xeta; -ypsi, xpsi]; % 2x2 arrayjcob = xpsi*yeta - xeta*ypsi;% derivatives of shape functions in element coordinatesNJdpsieta = [NJpsi; NJeta]; % 2x4 arrayNJdxy = Jinv*NJdpsieta; % 2x4 array% assemble element stiffness matrix ke: 4x4 arrayke = ke + (NJdxy(1,:))’*(NJdxy(1,:))/jcob ...

+ (NJdxy(2,:))’*(NJdxy(2,:))/jcob ...+ NJ(1,:)’*NJ(1,:)*jcob;

rhse = rhse + rhs*NJ’*jcob;end

end

Page 207: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

192 Computational Partial Differential Equations Using MATLAB

00.2

0.40.6

0.81

0

0.2

0.4

0.6

0.8

1−1

−0.5

0

0.5

1

FIGURE 7.5Numerical solutions obtained with nx = ny = 20.

The assembly procedure is all the same as the triangular element case. Inour test, we solve the problem (7.27)-(7.28) with the exact solution

u = cosπx cos πy

which leads to f = (2π2 + 1)u.The problem is solved with different levels of refinement and convergence

rate of O(h2) in the L∞-norm is observed. More specifically, the maximumerrors for nx = 10, 20, 40 are 0.0242, 0.0061, 0.0015, respectively.

An examplary numerical solution with nx = ny = 20 is shown in Fig. 7.5.The MATLAB code ellip Q1.m is shown below:

%-------------------------------------------------------% 2D Q1 FEM for solving% -Lap*u + u = f(x,y), on (0,length)x(0,height)% Neum BC=0% Max err=0.0242,0.0061,0.0015 when nx=10,20,40% so we did see O(h^2) convergence rate!%--------------------------------------------------------

clear all;length = 1.0;height = 1.0;nx=20;ny=20;gauss = [-1/sqrt(3), 1/sqrt(3)]; % Gaussian quadrature point

Page 208: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 193

% construct Q1 mesh[x,y,conn,ne,np] = getQ1mesh(length,height,nx,ny);

Ag = zeros(np);bg=zeros(np,1);

nloc = 4; % number of nodes per elementfor ie = 1:ne % loop over all elements

rhs= (feval(@SRC,x(conn(ie,1)),y(conn(ie,1)))...+ feval(@SRC,x(conn(ie,2)),y(conn(ie,2)))...+ feval(@SRC,x(conn(ie,3)),y(conn(ie,3)))...+ feval(@SRC,x(conn(ie,4)),y(conn(ie,4))))/nloc;

[A_loc,rhse] = elemA(conn,x,y,gauss,rhs,ie);% assemble local matrices into the global matrixfor i=1:nloc;

irow = conn(ie,i); % global row indexbg(irow)=bg(irow) + rhse(i);for j=1:nloc;

icol = conn(ie,j); %global column indexAg(irow, icol) = Ag(irow, icol) + A_loc(i,j);

end;end;

end;

%solve the equationu_fem = Ag\bg;

u_ex=cos(pi*x).*cos(pi*y); % get the exact solution

disp(’Max error=’),max(u_fem-u_ex’), % find the max error

% plot the FEM solutiontri = delaunay(x,y);trisurf(tri,x,y,u_fem);

7.7 Bibliographical remarks

In this chapter, we introduced the basic procedure for programming a fi-nite element method for solving the second-order elliptic equation. Herewe emphasize the simple and clear implementation instead of sophisticated

Page 209: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

194 Computational Partial Differential Equations Using MATLAB

FIGURE 7.6The initial grid.

usage of MATLAB functions. Finite element programming is a quite chal-lenging task and can be written in a single book. Readers can find moreadvanced and sophisticated programming algorithms in other books (e.g.,[1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 15, 16]). For example, [16] details how to pro-gram FEM for solving the Navier-Stokes equations in Fortran; [2] presentsthe package PLTMG, which solves elliptic problems using adaptive FEMin MATLAB; [10] introduces Diffpack, a sophisticated toolbox for solvingPDEs based on C++; [14] elaborates the adaptive finite element softwareALBERTA written in ANSI-C; [6] introduces an open-source Matlab packageIFISS, which can be used to solve convection-diffusion, Stokes, and Navier-Stokes equations. Recently, Persson and Strang [11] developed a very niceand simple MATLAB mesh generator called DistMesh, which can gener-ate unstructured triangular and tetrahedral meshes. Interested readers candownload it from http : //www − math.mit.edu/ persson/mesh/. Readersalso can download some nice finite element codes written in MATLAB athttp : //matlabdb.mathematik.uni− stuttgart.de/.

7.8 Exercises

1. Modify the function gen p1grid.m to resolve the same problem as ellip.mon Ω = [0, 1]2 starting with the initial grid as shown in Fig. 7.6. Check theaccuracy by solving the problem with different nref, say nref = 2, 3, 4, 5.

2. Let K be a triangle with vertices a1, a2, a3, edge midpoints aij , 1 ≤ i <j ≤ 3, and |K| be the area of K. Then the quadrature scheme

K

φ(x)dx1dx2 ≈ |K|3

1≤i<j≤3

φ(aij)

is exact for polynomials of degree ≤ 2. Furthermore, if we denote a123 for the

Page 210: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods: Programming 195

(-0.2, 0.3)

(-0.4, 0)(0, 0)

(0, -0.2)

(0.4, 0)

(0.2, 0.3)

FIGURE 7.7The initial grid for an irregular domain.

barycenter of K, then the quadrature scheme∫

K

φ(x)dx1dx2 ≈ |K|φ(a123)

is exact for polynomials of degree ≤ 1. Moreover, the quadrature scheme

K

φ(x)dx1dx2 ≈ |K|60

(33∑

i=1

φ(ai) + 8∑

1≤i<j≤3

φ(aij) + 27φ(a123))

is exact for polynomials of degree ≤ 3.3. Modify the codes gen p1grid.m and ellip.m to solve the same problem as

ellip.m on an irregular domain as shown in Fig. 7.7. Check the accuracy bysolving the problem with nref = 2, 3, 4, 5.

4. Let Ω be a circle with radius r and Γh be an inscribed polygon approxi-mating ∂Ω. The polygon has side length h. Prove that the maximum distancebetween ∂Ω and Γh is about h2

8r .5. Let K be the reference triangle with vertices ai, 1 ≤ i ≤ 3, and mid-points

aij of the side aiaj of K. For simplicity, we assume that

a1 = (0, 0), a2 = (1, 0), a3 = (0, 1).

Suppose that a general triangle in the (x, y)-plane has vertices ai, 1 ≤ i ≤ 3,and mid-points aij as follows

a1 = (0, 0), a2 = (2, 0), a3 = (0, 2), a12 = (1, 0), a13 = (1, 1), a23 = (0, 1).

Page 211: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

196 Computational Partial Differential Equations Using MATLAB

Let us define the isoparametric mapping F given by

F (x) =3∑

i=1

λi(x)(2λi(x) − 1)ai +∑

1≤i<j≤3

4λi(x)λj(x)aij , ∀ x ∈ K.

Prove that the mapping F is not invertible. Hint: Prove that the determinantof the Jacobi

J =

[∂F1∂x1

∂F1∂x2

∂F2∂x1

∂F2∂x2

]

of F can be zero.6. Let K be the unit square with vertices ai, 1 ≤ i ≤ 4, given by

a1 = (0, 0), a2 = (1, 0), a3 = (1, 1), a4 = (0, 1).

A convex quadrilateral K is defined by its four vertices ai as follows

a1 = (0, 0), a2 = (2, 0), a3 = (2, 3), a4 = (0, 5).

Consider the mapping

F (x) = (1 − x1)(1 − x2)a1 + x1(1 − x2)a2 + x1x2a3 + (1 − x1)x2a4.

Prove that the Jacobian of F is given by

J = 2(5 − 2x1).

Therefore, the mapping F is invertible.7. Consider a non-convex quadrilateral K, whose four vertices are given by

a1 = (2, 0), a2 = (3, 2), a3 = (5, 3), a4 = (2, 3).

Show that in this case, the above mapping F is not invertible.8. Modify the code ellip Q1.m to solve the problem (7.27) with Dirichlet

boundary condition such that the exact solution is still u = cosπx cos πy.Hint: The Dirichlet boundary condition can be simply imposed as follows:

for m=1:npif(x(m)==0 | y(m)==0 | x(m)==1 | y(m)==1)

for i=1:npbg(i) = bg(i) - Ag(i,m) * cos(pi*x(m))*cos(pi*y(m));Ag(i,m) = 0; Ag(m,i) = 0;

endAg(m,m) = 1.0; bg(m) = cos(pi*x(m))*cos(pi*y(m));

endend

Page 212: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 197

References

[1] J.E. Akin. Application and Implementation of Finite Element Methods.Academic Press, London, 1982.

[2] R.E. Bank. PLTMG: A Software Package for Solving Elliptic PartialDifferential Equations: Users’ Guide 8.0. SIAM, Philadelphia, PA, 1998.

[3] G.F. Carey and J.T. Oden. Finite Elements: Computational Aspects.Prentice-Hall, Englewood Cliffs, NJ, 1983.

[4] P.G. Ciarlet. The Finite Element Method for Elliptic Problems. North-Holland, Amsterdam, 1978.

[5] L. Demkowicz. Computing with hp-Adaptive Finite Elements. Chapman& Hall/CRC, Boca Raton, FL, 2006.

[6] H.C. Elman, D.J. Silvester and A.J. Wathen. Finite Elements and FastIterative Solvers with Applications in Incompressible Fluid Dynamics.Oxford University Press, Oxford, UK, 2005.

[7] A. Ern and J.-L. Guermond. Theory and Practice of Finite Elements.Springer, New York, NY, 2004.

[8] J.C. Heinrich and D.W. Pepper. The Finite Element Method: AdvancedConcepts. Taylor & Francis, Bristol, PA, 1996.

[9] T.J.R. Hughes. Finite Element Method – Linear Static and DynamicFinite Element Analysis. Prentice-Hall, Englewood Cliffs, NJ, 1987.

[10] H.P. Langtangen. Computational Partial Differential Equations: Nu-merical Methods and Diffpack Programming. Springer-Verlag, Berlin,2nd Edition, 2003.

[11] P.-O. Persson and G. Strang. A simple mesh generator in MATLAB.SIAM Review, 46(2):329–345, 2004.

[12] C. Pozrikidis. Introduction to Finite and Spectral Element Methods Us-ing MATLAB. Chapman & Hall/CRC, Boca Raton, FL, 2005.

[13] J.N. Reddy. An Introduction to the Finite Element Method. McGraw-Hill, Boston, 1993.

[14] A. Schmidt and K. G. Siebert. Design of Adaptive Finite Element Soft-ware: The Finite Element Toolbox ALBERTA. Springer, Berlin, 2005.

[15] I.M. Smith and D.V. Griffiths. Programming the Finite Element Method.John Wiley & Sons, 4th Edition, Hoboken, NJ, 2004.

[16] C. Taylor and T.G. Hughes. Finite Element Programming of the Navier-Stokes Equations. Pineridge Press, Swansea, UK, 1981.

Page 213: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 214: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

8

Mixed Finite Element Methods

In many applications, the governing PDEs include several variables (which arephysically interesting) such as the velocities and pressure for fluid modelingusing Navier-Stokes equations. The mixed finite element method is developedto approximate those variables simultaneously. One of the main issues inmixed methods is how to choose those finite element spaces such that themixed methods will be more efficient and stable. In this chapter, we willintroduce the basic theory and practical implementation for such methods.

In Sec. 8.1, we introduce an abstract framework for analyzing the mixedfinite element method. Then in Sec. 8.2, we apply the framework to thesecond-order elliptic problem. Here we introduce some popular mixed finiteelement spaces and carry out the error estimate. By following similar ideas,we extend the discussion to the Stokes problem in Sec. 8.3, where some classicmixed spaces for the Stokes problem are introduced. Then in Sec. 8.4, weshow the reader how to implement a mixed finite element method to solve theStokes problem. Detailed implementation in MATLAB is discussed. Finally,in Sec. 8.5, we briefly introduce some mixed methods for both the steady andunsteady Navier-Stokes problem.

8.1 An abstract formulation

In this section we want to present an abstract theory for mixed finite elementmethods.

Let U and V be two Hilbert spaces, equipped with norms || · ||U and || · ||V ,respectively. Furthermore, let U ′ and V ′ be the corresponding dual spaces,i.e., the spaces of linear and continuous functional on U and V , respectively.

We consider the following problem: Given the linear functionals F ∈ U ′

and G ∈ V ′, find (u, p) ∈ U × V such that

a(u, v) + b(v, p) = F (v) ∀ v ∈ U, (8.1)b(u, q) = G(q) ∀ q ∈ V, (8.2)

where a(·, ·) : U × U → R, b(·, ·) : U × V → R are two bilinear forms, which

199

Page 215: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

200 Computational Partial Differential Equations Using MATLAB

satisfy the conditions:

|a(v1, v2)| ≤ a∗||v1||U ||v2||U ∀ v1, v2 ∈ U, (8.3)|b(v, q)| ≤ b∗||v||U ||q||V ∀ v ∈ U, q ∈ V. (8.4)

Also we define the linear space

UG = {v ∈ U : b(v, q) = G(q), ∀ q ∈ V }, (8.5)

and the compatibility condition: there exists a constant β∗ > 0 such that

∀ q ∈ V, ∃0 �= v ∈ U such that b(v, q) ≥ β∗||v||U ||q||V . (8.6)

Note that the compatibility condition (8.6) is often called the inf-sup orLadyzhenskaya-Babuska-Brezzi condition, since (8.6) is equivalent to

infq∈V

supv∈U

b(v, q)||v||U ||q||V ≥ β∗. (8.7)

The following theorem assures the existence and uniqueness of the solutionto the problem (8.1)-(8.2). Considering that the proof is too technical, weskip the proof here. Interested readers can consult books by Brezzi et al. [7]or Quarteroni et al. [18].

THEOREM 8.1Assume that the bilinear form a(·, ·) and b(·, ·) satisfy (8.3) and (8.4). As-

sume, moreover, that a(·, ·) is coercive on U0 (the subspace of UG with G = 0),i.e., there exists a constant α > 0 such that

a(v, v) ≥ α||v||2U ∀ v ∈ U0, (8.8)

and b(·, ·) satisfies the inf-sup condition (8.7). Then, for each F ∈ U ′, G ∈ V ′

there exists a unique solution (u, p) ∈ U × V to (8.1)-(8.2). Moreover, themap (F,G) → (u, p) is an isomorphism from U ′ × V ′ onto U × V , and

||u||U ≤ 1α

[||F ||U ′ +α+ a∗

β∗||G||V ′ ], (8.9)

||p||V ≤ 1β

[(1 +a∗

α)||F ||U ′ +

a∗(α+ a∗)αβ∗

||G||V ′ ]. (8.10)

Recall that a linear mapping is an isomorphism if it is bijective and itsinverse mapping is bounded.

Now we can consider the mixed finite element method for approximatingthe problem (8.1)-(8.2). Let Uh and Vh be the respective finite dimensionalsubspaces of U and V . The discrete counterpart of (8.1)-(8.2) is: Find uh ∈ Uhand ph ∈ Vh such that

a(uh, v) + b(v, ph) = F (v) ∀ v ∈ Uh, (8.11)b(uh, q) = G(q) ∀ q ∈ Vh. (8.12)

Page 216: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 201

The existence and uniqueness of the solution (uh, ph) ∈ Uh × Vh to thediscrete problem (8.11) and (8.12) is guaranteed under the discrete inf-supcondition: there exists a constant βh > 0 such that

infqh∈Vh

supvh∈Uh

b(vh, qh)||vh||U ||qh||V ≥ βh (8.13)

and the discrete coercivity assumption: there exists a constant αh > 0 suchthat

a(vh, vh) ≥ αh||vh||2U ∀ v ∈ U0h , (8.14)

where U0h is the subspace of UGh with G = 0, where the space

UGh = {vh ∈ Uh : b(vh, qh) = G(qh), ∀ qh ∈ Vh}. (8.15)

Furthermore, we have the following stability results:

||uh||U ≤ 1αh

[||F ||U ′ +αh + a∗

βh||G||V ′ ], (8.16)

||ph||V ≤ 1βh

[(1 +a∗

αh)||F ||U ′ +

a∗(αh + a∗)αhβh

||G||V ′ ]. (8.17)

Now we can prove the main theorem of this section.

THEOREM 8.2Let the assumptions of Theorem 8.1 be satisfied. Moreover, we assume that

the discrete inf-sup condition (8.13) and the coercive condition (8.14) holdtrue. Hence the respective solutions (u, p) and (uh, ph) of (8.1)-(8.2) and(8.11)-(8.12) satisfy the error estimates

(i) ||u− uh||U≤ (1 +

a∗

αh) infu∗

h∈UGh

||u− u∗h||U +b∗

αhinf

p∗h∈Vh

||p− p∗h||V , (8.18)

(ii) ||p− ph||V ≤ a∗

βh(1 +

a∗

αh) infu∗

h∈UGh

||u − u∗h||U

+(1 +b∗

βh+a∗b∗

αhβh) infp∗h∈Vh

||p− p∗h||V , (8.19)

(iii) infu∗

h∈UGh

||u − u∗h||U ≤ (1 +b∗

βh) infuh∈Uh

||u− uh||U . (8.20)

Proof. (i) Subtracting (8.11) from (8.1) with v = vh ∈ Uh, we obtain

a(uh − u∗h, vh) + b(vh, ph − p∗h) = a(u− u∗h, vh) + b(vh, p− p∗h), (8.21)

for any u∗h ∈ UGh and p∗h ∈ Vh.

Page 217: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

202 Computational Partial Differential Equations Using MATLAB

From (8.12) and (8.15), we see that

b(uh − u∗h, qh) = 0 ∀ q ∈ Vh, (8.22)

i.e., uh − u∗h ∈ U0h .

Applying (8.14) and (8.22) to (8.21) with vh = uh − u∗h, and using theboundedness of (8.3)-(8.4), we have

αh||uh − u∗h||2U ≤ a∗||u− u∗h||U ||uh − u∗h||U + b∗||uh − u∗h||U ||p− p∗h||Vi.e.,

||uh − u∗h||U ≤ a∗

αh||u− u∗h||U +

b∗

αh||p− p∗h||V ,

which, along with the triangle inequality

||u− uh||U ≤ ||u− u∗h||U + ||uh − u∗h||U ,completes the proof of (8.18).

(ii) Applying the discrete inf-sup condition (8.13), we obtain

||ph − p∗h||V ≤ 1βh

supvh∈Uh

b(vh, ph − p∗h)||vh||U , ∀ p∗h ∈ Vh. (8.23)

We can rewrite (8.21) as

b(vh, ph − p∗h) = a(u− uh, vh) + b(vh, p− p∗h),

which along with (8.3)-(8.4) yields

b(vh, ph − p∗h) ≤ a∗||u− uh||U ||vh||U + b∗||vh||U ||p− ph||V . (8.24)

Substituting (8.24) into (8.23), we obtain

||ph − p∗h||V ≤ 1βh

(a∗||u− uh||U + b∗||p− ph||V ),

which, along with (8.18) and the triangle inequality, completes the proof of(8.19).

(iii) By the discrete inf-sup condition (8.13), for each uh ∈ Uh, there existsa unique rh ∈ (U0

h)⊥ such that (cf. [7, p. 55] or [18, p. 252])

b(rh, qh) = b(u− uh, qh) ∀ qh ∈ Vh

and||rh||U ≤ b∗

βh||u− uh||U .

Let u∗h = rh + uh, so b(u∗h, qh) = b(u, qh) = G(qh), i.e., u∗h ∈ UGh .Hence

||u− u∗h||U ≤ ||u− uh||U + ||rh||U ≤ (1 +b∗

βh)||u − uh||U ,

which concludes the proof of (8.20).

Page 218: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 203

8.2 Mixed methods for elliptic problems

8.2.1 The mixed variational formulation

We consider the model problem

−∇ · (a∇p) = g in Ω (8.25)p = 0 on Γ (8.26)

where Ω ⊂ Rd (d = 2 or 3) is a bounded domain with boundary Γ, a is ad× d matrix and satisfies

0 < a∗|ξ|2 ≤d∑

i,j=1

aij(x)ξiξj ≤ a∗|ξ|2 <∞, ∀ x ∈ Ω, ξ �= 0 ∈ Rd, (8.27)

where we denote |ξ|2 =∑d

i=1 ξ2i .

We define the space

L2(Ω) = {v : v is defined on Ω and∫

Ω

v2dx <∞} (8.28)

and

H(div; Ω) = {v ∈ (L2(Ω))d : ∇ · v ∈ L2(Ω)}, ∇ · v =d∑

i=1

∂vi∂xi

, (8.29)

with norm ||v||H(div;Ω) = (||v||2L2(Ω)+||∇·v||2L2(Ω))1/2. Furthermore, we define

U = H(div; Ω), V = L2(Ω).Introduce the new variable

u = a∇p. (8.30)

Then equation (8.25) can be written as

∇ · u = −g in Ω. (8.31)

Multiplying (8.30) by v ∈ U and integrating over Ω, then applying Green’sformula

(∇p,v) =< v · n, p >∂Ω −(p,∇ · v)and boundary condition (8.26), we have

(a−1u,v) + (p,∇ · v) = 0. ∀ v ∈ U. (8.32)

Multiplying (8.31) by any q ∈ V , we obtain

(∇ · u, q) = −(g, q) ∀ q ∈ V. (8.33)

Page 219: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

204 Computational Partial Differential Equations Using MATLAB

Hence the problem (8.25)-(8.26) can be recast as a mixed variational prob-lem: Find u ∈ U and p ∈ V such that

(a−1u,v) + (∇ · v, p) = 0. ∀ v ∈ U, (8.34)(∇ · u, q) = −(g, q) ∀ q ∈ V. (8.35)

Define

a(u,v) = (a−1u,v), ∀ u,v ∈ U,

b(v, p) = (∇ · v, p), ∀ v ∈ U, p ∈ V.

Then (8.34)-(8.35) is in the form of (8.1)-(8.2) with

F (v) = 0, G(q) = −(g, q).

It is easy to check that the bilinear forms a(·, ·) and b(·, ·) satisfy the continu-ity conditions (8.3) and (8.4) by using the assumption (8.27). Correspondingto (8.34)-(8.35), the subspace U0 of UG defined by (8.5) becomes

U0 = {v ∈ H(div; Ω) : (∇ · v, q) = 0 ∀ q ∈ L2(Ω)}. (8.36)

Note that for any given 0 �= q ∈ L2(Ω), we can find v ∈ H(div; Ω),v �= 0such that divv = q. This can be assured by choosing v = ∇φ, where φ is thesolution to

�φ = q in Ω, (8.37)φ = 0 on Γ. (8.38)

Hence, for any v ∈ U0 we see that ∇ · v = 0. From (8.27), we have

a(v,v) = (a−1v,v) ≥ 1a∗

||v||2L2(Ω) =1a∗

||v||2H(div;Ω)

, ∀ v ∈ U0,

i.e., a(·, ·) satisfies the condition (8.8).Finally, we want to prove that the formulation (8.34)-(8.35) also satisfies

the inf-sup condition (8.7). From above, for any 0 �= q ∈ L2(Ω), there exists0 �= v ∈ H(div; Ω). Hence

||v||L2(Ω) = ||∇φ||0 ≤ CΩ||q||0, (8.39)

where in the last step we used φmultiplying (8.37) and the Poincare-Friedrichsinequality [8, p. 12]

||φ||L2(Ω) ≤ CΩ||∇φ||0, ∀ φ ∈ H10 (Ω). (8.40)

From (8.39) and ∇ · v = q, we have

||v||H(div;Ω) ≡√||v||20 + ||∇ · v||20 ≤

√1 + C2

Ω||q||0.

Page 220: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 205

Consequently, we see that

b(v, q)||v||U =

(q, q)||v||H(div;Ω)

≥ 1√1 + C2

Ω

||q||0,

i.e., b(·, ·) satisfies the inf-sup condition (8.7). Thus all the conditions ofTheorem 8.1 are satisfied, which guarantee the existence and uniqueness ofthe solution to the problem (8.34)-(8.35).

8.2.2 The mixed finite element spaces

From (8.34)-(8.35), we can consider the discrete problem: Find uh ∈ Uh andph ∈ Vh such that

(a−1uh,vh) + (∇ · vh, ph) = 0 ∀ vh ∈ Uh, (8.41)(∇ · uh, qh) = −(g, qh) ∀ qh ∈ Vh, (8.42)

where Uh ⊂ H(div; Ω) and Vh ⊂ L2(Ω) are suitable finite dimensional spaces.From Theorem 8.2, we need to choose Uh and Vh properly such that both

the discrete inf-sup condition (8.13) and discrete coercivity condition (8.14)hold true, i.e., there exist constant βh > 0 and αh > 0 such that

infqh∈Vh

supvh∈Uh

(∇ · vh, qh)||vh||H(div;Ω)||q||0

≥ βh, (8.43)

anda(vh,vh) ≥ αh||vh||2H(div;Ω)

∀ vh ∈ U0h , (8.44)

whereU0h = {vh ∈ Uh : (∇ · vh, qh) = 0 ∀ qh ∈ Vh}. (8.45)

Moreover, under the conditions (8.43) and (8.44), Theorem 8.2 leads to thefollowing error estimate

||u− uh||H(div;Ω) + ||p− ph||0≤ C[ inf

vh∈Uh

||u− vh||H(div;Ω) + infqh∈Vh

||p− qh||0]. (8.46)

For simplicity, here we only discuss the widely used Raviart-Thomas-Nedelec(RTN) spaces [19, 16]. Let us assume that Ω ⊂ Rd (d = 2 or 3) is a polygonaldomain with Lipschitz boundary, and Th is a regular family of triangulationsof Ω.

Let K ∈ Th be a d-simplicial (i.e., triangular for d = 2 or tetrahedral ford = 3) element. Then we define

RTr(K) = (Pr(K))d ⊕ xPr(K) ∀ r ≥ 0.

Page 221: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

206 Computational Partial Differential Equations Using MATLAB

It is not difficult to check that the dimension of RTr(K) is

dimRTr(K) = (r + 1)(r + 3) for d = 2,

dimRTr(K) =12(r + 1)(r + 2)(r + 4) for d = 3.

The RTN spaces on the d-dimensional element are defined for each r ≥ 0by

Uh = {v ∈ H(div; Ω) : v|K ∈ RTr(K) ∀ K ∈ Th}, (8.47)Vh = {q ∈ L2(Ω) : q|K ∈ Pr(K) ∀ K ∈ Th}. (8.48)

Since the finite element spaces Uh and Vh are defined locally on each elementK ∈ Kh, we simply denote

Uh(K) = Uh|K , Vh(K) = Vh|K .For a triangle or tetrahedron, the degrees of freedom for v ∈ Uh(K) are givenby [19]:

< v · n, w >e, ∀ w ∈ Pr(e), e ∈ ∂K,

(v,w)K , ∀ w ∈ (Pr−1(K))d, d = 2 or 3,

where n is the outward unit normal to e ∈ ∂K. It is remarked that a functionv ∈ Uh is uniquely determined by these degrees of freedom. More specifically,we have

LEMMA 8.1For r ≥ 0, the following conditions imply v = 0 on K:

< v · n, w >e= 0, ∀ w ∈ Pr(e), e ∈ ∂K, (8.49)(v,w)K = 0, ∀ w ∈ (Pr−1(K))d, d = 2 or 3. (8.50)

Proof. Due to the technicality, we leave the proof as an exercise for inter-ested readers.

The lowest-order (i.e., r = 0) basis function of Uh on triangles has the form

v|K =(akck

)+ bk

(x1

x2

), ak, bk, ck ∈ R, (8.51)

while the lowest-order Uh basis function on tetrahedra has the form

v|K =

⎝akckdk

⎠+ bk

⎝x1

x2

x3

⎠ , ak, bk, ck, dk ∈ R. (8.52)

Here the unknowns ak, bk and ck of (8.51) can be determined by the trace< v · n, 1 >e along three edges of the triangle; while the unknowns ak, bk, ck

Page 222: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 207

and dk of (8.52) can be determined by the trace < v ·n, 1 >e along four facesof the tetrahedron.

The RTN spaces on rectangles are defined by

Uh(K) = Qr+1,r(K) ×Qr,r+1(K), Vh(K) = Qr,r(K) ∀ r ≥ 0. (8.53)

It is easy to check that the dimensions of Uh(K) and Vh(K) are

dimUh(K) = 2(r + 1)(r + 2), dimVh(K) = (r + 1)2.

Furthermore, a function v ∈ Uh(K) is uniquely defined by the degrees offreedom

< v · n, w >e, ∀ w ∈ Pr(e), e ∈ ∂K,

(v,w)K , ∀ w ∈ Qr−1,r(K) ×Qr,r−1(K).

The lowest-order (i.e., r = 0) basis function v of Uh on a rectangle K takesthe form

v|K =(a1 + a2x1

a3 + a4x2

), ai ∈ R, i = 1, 2, 3, 4. (8.54)

The ai’s are determined by the traces < v · n, 1 >e along four edges of therectangle.

The RTN spaces on cubes are defined for each r ≥ 0 by

Uh(K) = Qr+1,r,r(K) ×Qr,r+1,r(K) ×Qr,r,r+1(K), Vh(K) = Qr,r,r(K).(8.55)

The dimensions of Uh(K) and Vh(K) are

dimUh(K) = 3(r + 1)2(r + 2), dimVh(K) = (r + 1)3.

Furthermore, a function v ∈ Uh(K) is uniquely defined by the degrees offreedom

< v · n, w >e, ∀ w ∈ Qr,r(e), e ∈ ∂K,

(v,w)K , ∀ w ∈ Qr−1,r,r(K) ×Qr,r−1,r(K) ×Qr,r,r−1(K).

Similarly, the lowest-order (i.e., r = 0) basis function v of Uh on a cube Ktakes the form

v|K =

⎝a1 + a2x1

a3 + a4x2

a5 + a6x3

⎠ , ai ∈ R, i = 1, · · · , 6, (8.56)

and ai’s are uniquely determined by the traces < v · n, 1 >e on six faces ofthe cube.

Page 223: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

208 Computational Partial Differential Equations Using MATLAB

8.2.3 The error estimates

To prove the error estimates for the mixed method (8.41)-(8.42), we need toprove the discrete inf-sup condition (8.43) and coercivity condition (8.44).

Note that all RTN spaces satisfy the property

∇ · Uh = Vh, (8.57)

from which we see that for any vh ∈ U0h (defined by (8.45)), ∇ · vh = 0. This

fact combining with the assumption (8.27) yields

a(vh,vh) ≥ 1a∗

||vh||20 =1a∗

||vh||2H(div;Ω), ∀ vh ∈ U0

h ,

i.e., the condition (8.44) is true.To prove the discrete inf-sup condition (8.43), we need a useful result due

to Fortin [7].

LEMMA 8.2

Assume that the bilinear form b(·, ·) satisfies the continuous inf-sup condition(8.7). If there exists a projection operator Πh : U → Uh such that

b(v − Πhv, q) = 0 ∀ q ∈ Vh (8.58)

and||Πhv||U ≤ C∗||v||U ∀ v ∈ U, (8.59)

where the constants C∗ > 0 is independent of the mesh size h. Then thediscrete inf-sup condition (8.7) holds true with βh = β∗/C∗.

Proof. For any q ∈ Vh, using (8.7), (8.58) and (8.59), we have

β∗||q||V ≤ supv∈U

b(v, q)||v||U = sup

v∈U

b(Πhv, q)||v||U

≤ C∗ supv∈U

b(Πhv, q)||Πhv||U ≤ C∗ sup

w∈Uh

b(w, q)||w||U ,

which implies (8.13) with βh = β∗/C∗.For the RTN spaces, the projection operator Πh does exist [7]. First we

can define the corresponding local interpolation operator ΠK : (H1(K))d →Uh ⊂ H(div; Ω). For example, on a triangular or tetrahedral element, ΠK :(H1(K))d → RTr(K) is defined by

< (v − ΠKv) · n, w >∂K= 0, ∀ w ∈ Pr(∂K),(v − ΠKv,w)K = 0, ∀ w ∈ (Pr−1(K))d, d = 2 or 3.

Page 224: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 209

On a rectangular element K, ΠK : (H1(K))2 → Qr+1,r(K) ×Qr,r+1(K) isdefined by

< (v − ΠKv) · n, w >∂K= 0, ∀ w ∈ Pr(∂K),(v − ΠKv,w)K = 0, ∀ w ∈ Qr−1,r(K) ×Qr,r−1(K),

while on a cubic element K, ΠK : (H1(K))3 → Qr+1,r,r(K) ×Qr,r+1,r(K) ×Qr,r,r+1(K) is defined by

< (v − ΠKv) · n, w >∂K= 0, ∀ w ∈ Qr,r(∂K),(v − ΠKv,w)K = 0, ∀ w ∈ Qr−1,r,r(K) ×Qr,r−1,r(K) ×Qr,r,r−1(K).

LEMMA 8.3Let RTN(K) be the RTN spaces defined above, and ΠK be the interpolation

operator: (H1(Ω))d → RTN(K). Moreover, let PK be the L2-projection ontothe space div(RTN(K)), which is Pr(K) or Qr,r(K) or Qr,r,r(K). Then wehave

div(ΠKv) = PK(divv) ∀ v ∈ (H1(Ω))d, d = 2 or 3. (8.60)

Proof. For any w ∈ div(RTN(K)), we have

(w,∇·(ΠKv−v))K =< w, (ΠKv−v)·n >∂K −(ΠKv−v,∇·w)K = 0, (8.61)

using the definition of ΠK .By the definition of PK , we have

(w,∇ · v)K = (w,PK (∇ · v))K , ∀ w ∈ div(RTN(K)). (8.62)

Combining (8.61) and (8.62), we obtain

(∇ · (ΠKv) − PK(∇ · v), w)K = 0, ∀ w ∈ div(RTN(K)),

which leads to ∇ · (ΠKv) − PK(∇ · v) = 0, i.e., (8.60) is proved.Considering that ΠK is defined in (H1(Ω))d and not inH(div; Ω), we have to

use a regularizing procedure introduced in [18, p. 237] to define the projectionoperator Πh in H(div; Ω). Let v ∈ H(div; Ω), define φ = divv in Ω and extendφ to zero in B \ Ω, where B is an open ball containing Ω.

Considering that for any φ ∈ L2(Ω), the problem

�ψ = φ in B

ψ|∂B = 0 on ∂B

has a solution ψ ∈ H2(B), which has the estimate

||ψ||H2(B) ≤ C||φ||L2(B).

Page 225: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

210 Computational Partial Differential Equations Using MATLAB

Let us define v∗ = (∇ψ)|Ω. Hence v∗ ∈ (H1(Ω))d, ∇ · v∗ = �ψ = divv inΩ, and

||v∗||H1(Ω) ≤ ||ψ||H2(B) ≤ C||φ||L2(B) = C||divv||L2(Ω).

Now we can define the projection operator

Πh(v)|K = ΠK(v∗),

from which we have

||Πh(v)||H(div;Ω)

= ||Πh(v∗)||H(div;Ω)≤ C||v∗||H1(Ω) ≤ C||divv||L2(Ω),

i.e., (8.59) holds true.Note that (8.58) has proved to be true by (8.61), hence Lemma 8.2 implies

that the discrete inf-sup condition (8.13) holds true. Thus the error estimate(8.46) is true, i.e.,

||u− uh||H(div;Ω) + ||p− ph||0≤ C[ inf

vh∈Uh

||u− vh||H(div;Ω) + infqh∈Vh

||p− qh||0]. (8.63)

Hence the error estimate becomes a problem of interpolation estimates for Uhand Vh, which is well known and stated in the following lemma.

LEMMA 8.4[7, p. 132] Let Th be a regular family of triangulation of Ω. There exists a

constant C independent of h such that

||v−Πhv||0 ≤ Chm|v|m, ||∇ · (v−Πhv)||0 ≤ Chm|∇ ·v|m, ∀ 1 ≤ m ≤ r+1.

Define the global L2-projection Ph onto

Vh ≡ div(RTN(K)) : (Phq)|K = PK(q|K), ∀ q ∈ L2(Ω),

we have [18, p. 99]:

||q − Phq||0 ≤ Chm|q|m ∀ q ∈ Hm(Ω), 0 ≤ m ≤ r + 1. (8.64)

Substituting Lemma 8.4 and (8.64) into (8.63), we finally obtain the errorestimate

||u−uh||H(div;Ω)+||p−ph||0 ≤ Chm[|u|m+|∇·u|m+|p|m], ∀ 1 ≤ m ≤ r+1,

where (u, p) and (uh, ph) are the solutions to (8.34)-(8.35) and (8.41)-(8.42),respectively. The mixed finite element spaces are any RNT spaces of orderr ≥ 0.

Page 226: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 211

8.3 Mixed methods for the Stokes problem

8.3.1 The mixed variational formulation

We now consider mixed finite element methods for the Stokes problem ofincompressible flow of a viscous fluid. The model problem is: Find the pair(u, p) satisfying

−μ�u+ ∇p = f in Ω, (8.65)divu = 0 in Ω, (8.66)u = 0 on ∂Ω, (8.67)

where Ω is a bounded Lipschitz domain in R2, μ is the viscosity, u is thevelocity field, f is the body force, and p is the pressure. The boundarycondition (8.67) is often called the no-slip condition. Note that the pressurep is unique up to an additive constant, which is usually fixed by enforcing thecondition ∫

Ω

pdx = 0

or simply imposing the pressure to zero at one grid point.We introduce the spaces

U = (H10 (Ω))2, Q ≡ L2

0(Ω) = {q ∈ L2(Ω) :∫

Ω

qdx = 0}.

A mixed formulation corresponding to (8.65)-(8.67) is: Find u ∈ U and p ∈ Qsuch that

μ(∇u,∇v) − (divv, p) = (f ,v), v ∈ U, (8.68)(divu, q) = 0, q ∈ Q. (8.69)

Let us introduce the bilinear forms a(·, ·) : U×U → R and b(·, ·) : U×Q→ Ras

a(u,v) = μ(∇u,∇v), b(v, p) = −(divv, p).

Hence we can rewrite (8.68)-(8.69) as: Find (u, p) ∈ U ×Q such that

a(u,v) + b(v, p) = (f ,v), v ∈ U, (8.70)b(u, q) = 0, q ∈ Q. (8.71)

The problem (8.70)-(8.71) satisifies an inf-sup condition as stated in thenext lemma.

LEMMA 8.5The bilinear form b(·, ·) satisifies

infq∈Q

supv∈U

b(v, q)||v||H1(Ω)||q||L2(Ω)

≥ β∗, (8.72)

Page 227: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

212 Computational Partial Differential Equations Using MATLAB

where β∗ > 0 is a constant.

Proof. From Arnold et al. [2], for any q ∈ Q, there exists v ∈ (H10 (Ω))2

such that divv = −q and

||v||H1(Ω) ≤ CΩ||q||L2(Ω),

where CΩ > 0 is a constant.Hence we have

b(v, q)||v||H1(Ω)

≥ 1CΩ

· b(v, q)||q||L2(Ω)

=1CΩ

||q||L2(Ω),

which implies (8.72) with β∗ = 1/CΩ.Using (8.40), it is easy to see that for any v ∈ (H1

0 (Ω))2, we have

a(v,v) = μ||∇v||20 ≥ μ

C2Ω + 1

(||v||20 + ||∇v||20) ≥μ

C2Ω + 1

||v||21,

which proves that a(·, ·) satisfies the coercivity over U . Thus a(·, ·) also satisi-fies the coercivity over the space

U0 = {v ∈ U : b(v, q) = 0 ∀ q ∈ Q},which is a subspace of U .

Hence by Theorem 8.1, the problem (8.68)-(8.69) has a unique solution.Now we can consider mixed finite element approximations of the problem

(8.68)-(8.69). Let Th be a regular triangulation of Ω into triangles. Moreover,let Uh and Qh be the corresponding finite dimensional subspaces of U and Q.

The mixed finite element method for the Stokes problem (8.65)-(8.67) is:Find uh ∈ Uh and ph ∈ Qh such that

a(uh,vh) + b(vh, ph) = (f ,vh), vh ∈ Uh, (8.73)b(uh, qh) = 0, qh ∈ Qh. (8.74)

To guarantee the existence and stability for the mixed method (8.73)-(8.74),we have to construct the spaces Uh and Qh very carefully. In the next section,we will state some popular choices of Uh and Qh that satisfy the discrete inf-sup condition

infqh∈Qh

supvh∈Uh

b(vh, qh)||vh||H1(Ω)||qh||L2(Ω)

≥ βh > 0. (8.75)

8.3.2 Mixed finite element spaces

Example 8.1The P2 − P0 element

Page 228: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 213

FIGURE 8.1P2 − P0 element.

In this case, the spaces Uh and Qh are defined as

Uh = {v ∈ (H10 (Ω))2 : v|K ∈ (P2(K))2, K ∈ Th}, (8.76)

Qh = {q ∈ L20(Ω) : q|K ∈ P0(K), K ∈ Th}, (8.77)

i.e., we use the continuous P2 element for velocity field and the P0 (piecewiseconstant) element for pressure on triangles. The degrees of freedom are in-dicated in Fig. 8.1. Here and below the symbol • denotes the values of thevelocity components, while ◦ refers to the value of the pressure.

The P2 − P0 element is proved to satisfy the discrete inf-sup condition [7,p. 221], thus Theorem 8.2 implies that

||u− uh||H1(Ω) + ||p− ph||L2(Ω) ≤ Ch(||u||H2(Ω) + ||p||H1(Ω)). (8.78)

Example 8.2The Q2 −Q0 element

Similarly, the Q2 −Q0 element can be defined as

Uh = {v ∈ (H10 (Ω))2 : v|K ∈ (Q2(K))2, K ∈ Th},

Qh = {q ∈ L20(Ω) : q|K ∈ Q0(K), K ∈ Th}.

It can be proved that this pair also satisfies the discrete inf-sup condition [15,p. 235] and the error estimate (8.78).

Example 8.3Crouzeix-Raviart elements

The lowest Crouzeix-Raviart element is defined by

Uh = {v ∈ (H10 (Ω))2 : v|K = (P2(K))2 ⊕ aKλ1λ2λ3, K ∈ Th}, (8.79)

Qh = {q ∈ L20(Ω) : q|K = P1(K), K ∈ Th}, (8.80)

Page 229: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

214 Computational Partial Differential Equations Using MATLAB

FIGURE 8.2Crouzeix-Raviart element.

where λi is the barycentric coordinates of the triangle defined in a previouschapter. Note that bK ≡ λ1λ2λ3 is cubic and vanishes on the edges of K,hence bK is often called the cubic bubble function of K. Moreover, we wantto remark that here we use the discontinuous P1 element for pressure. Weplot the degrees of freedom in Fig. 8.2.

This element is proved to satisfy the discrete inf-sup condition [11, p. 139]and has the convergence result

||u− uh||H1(Ω) + ||p− ph||L2(Ω) ≤ Ch2(||u||H3(Ω) + ||p||H2(Ω)). (8.81)

Higher order Crouzeix-Raviart elements can be obtained using the discon-tinuous piecewise Pk−1 function for pressure and piecewise P 2

k⊕aKpk−2λ1λ2λ3

for velocities, where pk−2 ∈ Pk−2 for any k ≥ 3. These elements satisfy thecondition (8.75) and converge as O(hk).

Example 8.4Boland-Nicolaides elements

These elements were introduced by Boland and Nicolaides [6] for rectangles,with discontiunous piecewise Qk−1 (k ≥ 1) pressure and piecewise Pk veloci-ties on both triangles obtained by bisecting through one of the diagonals; seeFig. 8.3 for the k = 2 case.

The Boland-Nicolaides elements satisfy the discrete inf-sup condition andconverge as O(hk) (see also [12, p. 36]).

Example 8.5Taylor-Hood elements

These elements were proposed by Taylor and Hood [21], where continuousPk (k ≥ 2) velocities and continuous Pk−1 pressure are used on triangles,while on rectangles continuous Qk (k ≥ 2) velocities and continuous Qk−1

pressure are used. We show in Fig. 8.4 the corresponding degrees of freedomfor the case k = 2 on a triangle.

Page 230: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 215

FIGURE 8.3Pk −Qk−1 elements (k = 2).

FIGURE 8.4Taylor-Hood element (k = 2).

Page 231: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

216 Computational Partial Differential Equations Using MATLAB

FIGURE 8.5The MINI element.

The Taylor-Hood elements on both triangles and rectangles are proved tosatisfy the discrete inf-sup condition and have the optimal error estimates

||u− uh||H1(Ω) + ||p− ph||L2(Ω) ≤ Chk(||u||Hk+1(Ω) + ||p||Hk(Ω)), k ≥ 2.

For detailed proofs, see [21, 7, 11].

Example 8.6

MINI elementThe MINI element was introduced by Arnold et al. [1], where we have

Uh = {v ∈ (H10 (Ω))2 : v|K = (P1(K))2 ⊕ aKλ1λ2λ3, K ∈ Th}, (8.82)

Qh = {q ∈ L20(Ω) ∩ C0(Ω) : q|K = P1(K), K ∈ Th}, (8.83)

i.e., the velocities are approximated by piecewise P1 augmented by a cubicbubble function. We plot the degrees of freedom for the MINI element in Fig.8.5.

The MINI element satisfies the discrete inf-sup condition and have conver-gence result

||u− uh||H1(Ω) + ||p− ph||L2(Ω) ≤ Ch2(||u||H3(Ω) + ||p||H2(Ω)).

Before we conclude this section, we would like to remark that some simplechoices such as P1 −P0, Q1 −Q0, Q2 −Q1, P2 −P1 (discontinuous), and equalinterpolation methods (such as continuous P1−P1 and Q1−Q1) are unstableand have spurious pressure modes.

More detailed discussions on other mixed finite element spaces for the Stokesproblem can be found in [11, 7].

Page 232: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 217

8.4 An example MATLAB code for the Stokes problem

In this section, we will demonstrate how to solve the Stokes problem usingthe P2 − P0 element. For simplicity, we assume that the body force f = 0,and Ω is a polygon discretized by a triangular mesh Th with total ne elementsand total ng nodes. Hence we can approximate the velocity and pressure byP2 and P0 functions as

uh =ng∑

j=1

(uxjuyj

)φuj (x), ph =

ne∑

j=1

pjφpj (x), (8.84)

where φuj (x) is the continuous P2 function, and φpj (x) = 1 over each triangleEj . Here uxj and uyj represent the x- and y-component of the approximatevelocity field.

Substituting vh = (φui , 0)′ into (8.73) gives the x-component equation

μ∑

j

(∇φuj ,∇φui )uxj −∑

j

(∂xφui , φpj )pj = 0. (8.85)

Similarly, substituting vh = (0, φui )′ into (8.73) gives the y-component equa-

tionμ∑

j

(∇φuj ,∇φui )uyj −∑

j

(∂yφui , φpj )pj = 0. (8.86)

Substituting qh = φpi into (8.74) leads to the equation∑

j

[(∂xφuj , φpi )u

xj + (∂yφuj , φ

pi )u

yj ] = 0. (8.87)

Denote the element matrices

Du,ij =∫ ∫

E

∇φuj · ∇φui dxdy,

Dx,ij =∫ ∫

E

∂xφuj φ

pi dxdy, Dy,ij =

∫ ∫

E

∂yφuj φ

pi dxdy, (8.88)

and the vector solutions

ux =

⎢⎢⎢⎢⎣

ux1···uxng

⎥⎥⎥⎥⎦, uy =

⎢⎢⎢⎢⎣

uy1···uyng

⎥⎥⎥⎥⎦, p =

⎢⎢⎢⎢⎣

p1

···pne

⎥⎥⎥⎥⎦. (8.89)

Assembling (8.85)-(8.87) leads to the global linear system⎡

⎣μDu 0 −DT

x

0 μDu −DTy

−Dx −Dy 0

⎣ux

uy

p

⎦ = 0, (8.90)

Page 233: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

218 Computational Partial Differential Equations Using MATLAB

1

2

3

4

56

1

1 2

3

4

FIGURE 8.6An examplary p2 grid and its refinement.

where Du is a ng × ng matrix, Dx and Dy are ne × ng matrices, and thesuperscript T denotes the matrix transpose.

Note that φpi (x) = 1 over each element Ei, hence the evaluation of Dx,ij

and Dy,ij can be simplified to

Dx,ij =∫ ∫

Ei

∂xφuj dxdy, Dy,ij =

∫ ∫

Ei

∂yφuj dxdy, (8.91)

i.e., Dx,ij and Dy,ij are non-zero if the jth global node belongs to the ithelement.

To evaluate the matrices Du, Dx and Dy, we have to start with the P2 func-tion, which is defined on the 6-node triangular elements. The mesh generationof the 6-node triangles is similar to what we described in an earlier chapter.Here our implementation is inspired by Pozrikidis [17]. The basic idea is todivide each triangle into four subtriangles; the nodes and subtriangles arelabeled as shown in Fig. 8.6.

The attached MATLAB code gen p2grid.m can generate a 6-node triangularmesh from a coarse initial mesh by uniform refinement. An examplary initialgrid and the grid after one refinement are shown in Fig. 8.7.

%--------------------------------------------------------% Generate the 6-node triangular mesh% ne: total number of elements% np: total number of nodes

Page 234: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 219

% p(1:np,1:2): (x,y) coordinates of all nodes% conn(1:ne,1:6): connectivity matrix% efl(1:ne,1:6): nodal type indicator% gfl(1:np,1): global nodal type indicator%--------------------------------------------------------function [ne,np,p,conn,efl,gfl] = gen_p2grid(nref)

% create an initial mesh with eight 6-node trianglesne = 8;

x(1,1) = 0.0; y(1,1) = 0.0; efl(1,1)=0; % 1st elementx(1,2) = 1.0; y(1,2) = 0.0; efl(1,2)=1;x(1,3) = 1.0; y(1,3) = 1.0; efl(1,3)=1;

x(2,1) = 0.0; y(2,1) = 0.0; efl(2,1)=0; % 2nd elementx(2,2) = 1.0; y(2,2) = 1.0; efl(2,2)=1;x(2,3) = 0.0; y(2,3) = 1.0; efl(2,3)=1;

x(3,1) = 0.0; y(3,1) = 0.0; efl(3,1)=0; % 3rd elementx(3,2) = 0.0; y(3,2) = 1.0; efl(3,2)=1;x(3,3) =-1.0; y(3,3) = 1.0; efl(3,3)=1;

x(4,1) = 0.0; y(4,1) = 0.0; efl(4,1)=0; % 4th elementx(4,2) =-1.0; y(4,2) = 1.0; efl(4,2)=1;x(4,3) =-1.0; y(4,3) = 0.0; efl(4,3)=1;

x(5,1) = 0.0; y(5,1) = 0.0; efl(5,1)=0; % 5th elementx(5,2) =-1.0; y(5,2) = 0.0; efl(5,2)=1;x(5,3) =-1.0; y(5,3) =-1.0; efl(5,3)=1;

x(6,1) = 0.0; y(6,1) = 0.0; efl(6,1)=0; % 6th elementx(6,2) =-1.0; y(6,2) =-1.0; efl(6,2)=1;x(6,3) = 0.0; y(6,3) =-1.0; efl(6,3)=1;

x(7,1) = 0.0; y(7,1) = 0.0; efl(7,1)=0; % 7th elementx(7,2) = 0.0; y(7,2) =-1.0; efl(7,2)=1;x(7,3) = 1.0; y(7,3) =-1.0; efl(7,3)=1;

x(8,1) = 0.0; y(8,1) = 0.0; efl(8,1)=0; % 8th elementx(8,2) = 1.0; y(8,2) =-1.0; efl(8,2)=1;x(8,3) = 1.0; y(8,3) = 0.0; efl(8,3)=1;

for ie=1:8 % mid-edge nodes: other examples are differentx(ie,4) = 0.5*(x(ie,1)+x(ie,2));y(ie,4) = 0.5*(y(ie,1)+y(ie,2)); efl(ie,4)=0;

Page 235: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

220 Computational Partial Differential Equations Using MATLAB

x(ie,5) = 0.5*(x(ie,2)+x(ie,3));y(ie,5) = 0.5*(y(ie,2)+y(ie,3)); efl(ie,5)=1;x(ie,6) = 0.5*(x(ie,3)+x(ie,1));y(ie,6) = 0.5*(y(ie,3)+y(ie,1)); efl(ie,6)=0;

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% uniformly refine the gridfor i=1:nrefnm = 0; % count the new elements from each refinementfor j=1:ne % loop over current elements

for k=1:4 % generate 4 sub-elementsnm = nm+1; % increse the element number by 1if (k==1) p1=1; p2=4; p3=6; end % 1st sub-ele nodesif (k==2) p1=4; p2=2; p3=5; end % 2nd sub-ele nodesif (k==3) p1=6; p2=5; p3=3; end % 3rd sub-ele nodesif (k==4) p1=4; p2=5; p3=6; end % 4th sub-ele nodes

xn(nm,1)=x(j,p1); yn(nm,1)=y(j,p1); efln(nm,1)=efl(j,p1);xn(nm,2)=x(j,p2); yn(nm,2)=y(j,p2); efln(nm,2)=efl(j,p2);xn(nm,3)=x(j,p3); yn(nm,3)=y(j,p3); efln(nm,3)=efl(j,p3);xn(nm,4) = 0.5*(xn(nm,1)+xn(nm,2)); % mid-edge nodeyn(nm,4) = 0.5*(yn(nm,1)+yn(nm,2));xn(nm,5) = 0.5*(xn(nm,2)+xn(nm,3));yn(nm,5) = 0.5*(yn(nm,2)+yn(nm,3));xn(nm,6) = 0.5*(xn(nm,3)+xn(nm,1));yn(nm,6) = 0.5*(yn(nm,3)+yn(nm,1));

if (efln(nm,1)==1 & efln(nm,2)==1) % nodal type indicatorefln(nm,4) = 1;

elseefln(nm,4) = 0;

endif (efln(nm,2)==1 & efln(nm,3)==1)

efln(nm,5) = 1;else

efln(nm,5) = 0;endif (efln(nm,3)==1 & efln(nm,1)==1)

efln(nm,6) = 1;else

efln(nm,6) = 0;end

endend % end of loop over current elements

Page 236: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 221

ne = 4*ne; % number of elements increased by factor of fourfor k=1:ne % relabel the new points

for l=1:6x(k,l)=xn(k,l); y(k,l)=yn(k,l); efl(k,l)=efln(k,l);

endend

end % end of refinement loop

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% define the global nodes and the connectivity table% we set the first element: nodes and connectivityp(1,1)=x(1,1); p(1,2)=y(1,1); gfl(1,1)=efl(1,1);p(2,1)=x(1,2); p(2,2)=y(1,2); gfl(2,1)=efl(1,2);p(3,1)=x(1,3); p(3,2)=y(1,3); gfl(3,1)=efl(1,3);p(4,1)=x(1,4); p(4,2)=y(1,4); gfl(4,1)=efl(1,4);p(5,1)=x(1,5); p(5,2)=y(1,5); gfl(5,1)=efl(1,5);p(6,1)=x(1,6); p(6,2)=y(1,6); gfl(6,1)=efl(1,6);

conn(1,1) = 1; conn(1,2) = 2; conn(1,3) = 3;conn(1,4) = 4; conn(1,5) = 5; conn(1,6) = 6;

np = 6; % we already have 6 nodes from 1st elementeps = 1.0e-8;

for i=2:ne % loop over the rest elementsfor j=1:6 % loop over nodes of each element

Iflag=0;for k=1:npif(abs(x(i,j)-p(k,1)) < eps & abs(y(i,j)-p(k,2)) < eps)

Iflag = 1; % the node has been recorded previouslyconn(i,j) = k; % the jth local node of element i

endend

if(Iflag==0) % record the nodenp = np+1;p(np,1)=x(i,j); p(np,2)=y(i,j); gfl(np,1) = efl(i,j);% the jth local node of element i becomes the new global nodeconn(i,j) = np;

end

endend % end of loop over elements

Page 237: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

222 Computational Partial Differential Equations Using MATLAB

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

FIGURE 8.7The initial mesh and the grid after one refinement.

return;

As usual, the computation of elementary matrices is carried out on a refer-ence element. We map an arbitrary triangle with vertices ai(xi, yi), 1 ≤ i ≤ 3,and edge midpoints aij , 1 ≤ i < j ≤ 3 to the reference element with vertices

a1(0, 0), a2(1, 0), a3(0, 1), a12(12, 0), a23(

12,12), a13(0,

12).

For clarity, we denote

a12 = a4, a23 = a5, a13 = a6.

Hence the quadratic basis functions on the reference element can be obtainedeasily by satisfying the conditions

ψi(ξj , ηj) = δij ,

which takes the forms

ψ1 = ζ(2ζ − 1), ψ2 = ξ(2ξ − 1), ψ3 = η(2η − 1),

ψ4 = 4ξζ, ψ5 = 4ξη, ψ6 = 4ηζ,

where (ξ, η, ζ = 1 − ξ − η) are the triangle barycentric coordinates.The mapping from an arbitrary triangle to the reference triangle is given

by

x =6∑

j=1

xj ψj(ξ, η), y =6∑

j=1

yjψj(ξ, η). (8.92)

Page 238: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 223

We denote the Jacobi matrix of the mapping is denoted as

J ≡[∂x∂ξ

∂x∂η

∂y∂ξ

∂y∂η

],

which determinant is denoted as |J |. The basis function on the physicaltriangle is defined as

ψj(x, y) = ψj(ξ(x, y), η(x, y)),

from which we have

∂ψj∂ξ

=∂ψj∂x

∂x

∂ξ+∂ψj∂y

∂y

∂ξ, (8.93)

∂ψj∂η

=∂ψj∂x

∂x

∂η+∂ψj∂y

∂y

∂η, (8.94)

i.e.,

JT · ∇ψj =

[∂ψj

∂ξ∂ψj

∂η

], j = 1, 2, 3,

where we denote the gradient

∇ψj =

[∂ψj

∂x∂ψj

∂y

]. (8.95)

The evaluations of the P2 basis functions and the gradient (8.95) are carriedout by the function p2basis.m shown below.

%------------------------------------------------------% computation of the basis functions and their gradients% over a 6-node triangle.%-------------------------------------------------------function [psi, gpsi, jac] = p2basis ...

(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,xi,eta)

% compute the basis functionspsi(2) = xi*(2.0*xi-1.0);psi(3) = eta*(2.0*eta-1.0);psi(4) = 4.0*xi*(1.0-xi-eta);psi(5) = 4.0*xi*eta;psi(6) = 4.0*eta*(1.0-xi-eta);psi(1) = 1.0-psi(2)-psi(3)-psi(4)-psi(5)-psi(6);

% compute xi derivatives of the basis functionsdps(2) = 4.0*xi-1.0;

Page 239: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

224 Computational Partial Differential Equations Using MATLAB

dps(3) = 0.0;dps(4) = 4.0*(1.0-xi-eta)-4.0*xi;dps(5) = 4.0*eta;dps(6) = -4.0*eta;dps(1) = -dps(2)-dps(3)-dps(4)-dps(5)-dps(6);

% compute eta derivatives of the basis functionspps(2) = 0.0;pps(3) = 4.0*eta-1.0;pps(4) = -4.0*xi;pps(5) = 4.0*xi;pps(6) = 4.0*(1.0-xi-eta)-4.0*eta;pps(1) = -pps(2)-pps(3)-pps(4)-pps(5)-pps(6);

% compute the xi and eta derivatives of xDxDxi = x1*dps(1) + x2*dps(2) + x3*dps(3) ...

+ x4*dps(4) + x5*dps(5) + x6*dps(6);DyDxi = y1*dps(1) + y2*dps(2) + y3*dps(3) ...

+ y4*dps(4) + y5*dps(5) + y6*dps(6);

DxDeta = x1*pps(1) + x2*pps(2) + x3*pps(3) ...+ x4*pps(4) + x5*pps(5) + x6*pps(6);

DyDeta = y1*pps(1) + y2*pps(2) + y3*pps(3) ...+ y4*pps(4) + y5*pps(5) + y6*pps(6);

% compute the determinant of Jacobi matrixjac = abs(DxDxi * DyDeta - DxDeta * DyDxi);

% compute the gradient of the basis functionsA11 = DxDxi; A12 = DyDxi;A21 = DxDeta; A22 = DyDeta;

Det = A11*A22-A21*A12;

for k=1:6B1 = dps(k); B2 = pps(k);Det1 = B1*A22 - B2*A12; Det2 = - B1*A21 + B2*A11;gpsi(k,1) = Det1/Det; gpsi(k,2) = Det2/Det;

end

return;

Page 240: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 225

Using Lemma 7.1, we have

∇ψj = (JT )−1 ·[∂ψj

∂ξ∂ψj

∂η

]=

1|J |

[∂y∂η −∂y

∂ξ

−∂x∂η

∂x∂ξ

]·[∂ψj

∂ξ∂ψj

∂η

]

=1|J |

[ ∑6i=1 yi

∂ψi

∂η −∑6i=1 yi

∂ψi

∂ξ

−∑6i=1 xi

∂ψi

∂η

∑6i=1 xi

∂ψi

∂ξ

]·[∂ψj

∂ξ∂ψj

∂η

](8.96)

which being substituted into (8.88), we can evaluate the element matrix

Du,ij =∫ ∫

E

∇ψi · ∇ψjdxdy =∫ ∫

E

∇ψi · ∇ψj |J |dξη, (8.97)

and similarly for Dx,ij and Dy,ij .Note that unlike the P1 element, Du,ij cannot be evaluated exactly. How-

ever, we can approximate Du,ij by Gaussian quadrature over the triangle:

∫ ∫

E

g(ξ, η) ≈ 12

nq∑

k=1

g(ξk, ηk)ωk,

where ωk is the weight, (ξk, ηk) are the integration point, nq is the number ofquadrature points. Here we use the 7-point formula developed by [10], whichis accurate for polynomials of degree ≤ 5. The details about the integrationpoints and weights on our reference triangle can be seen in the code p2quad.m.Other quadrature formula can be implemented without much difficulty.

%------------------------------------------------% Abscissas (xi, eta) and weights (w) for Gaussian% integration over our reference triangle%% m=7: order of the quadrature%------------------------------------------------function [xi, eta, w] = p2quad(m)

al = 0.797426958353087;be = 0.470142064105115;ga = 0.059715871789770;de = 0.101286507323456;

wt1 = 0.125939180544827;wt2 = 0.132394152788506;

xi(1) = de;xi(2) = al;xi(3) = de;

Page 241: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

226 Computational Partial Differential Equations Using MATLAB

xi(4) = be;xi(5) = ga;xi(6) = be;xi(7) = 1.0/3.0;

eta(1) = de;eta(2) = de;eta(3) = al;eta(4) = be;eta(5) = be;eta(6) = ga;eta(7) = 1.0/3.0;

w(1) = wt1; w(2) = wt1; w(3) = wt1;w(4) = wt2; w(5) = wt2; w(6) = wt2;w(7) = 0.225;

return;

Using the Gaussian quadrature over the triangle and the gradient we justderived, we can calculate the matrices Du, Dx and Dy, which are implementedin the functions elmD.m and elmDxy.m, respectively.

%-----------------------------------------------% Evaluation of element matrix D_u for a 6-node% triangle using Gauss integration quadrature%-----------------------------------------------function [edm, arel] = elmD ...

(x1,y1, x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, NQ)

% read the triangle quadrature[xi, eta, w] = p2quad(NQ);

edm=zeros(6,6); % initilization

% perform the quadraturearel = 0.0; % element area

for i=1:NQ[psi, gpsi, jac] = p2basis ...(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,xi(i),eta(i));

cf = 0.5*jac*w(i);for k=1:6for l=1:6edm(k,l) = edm(k,l) + (gpsi(k,1)*gpsi(l,1) ...

Page 242: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 227

+ gpsi(k,2)*gpsi(l,2) )*cf;endend

arel = arel + cf;end

return;

%-----------------------------------------------------% Computation of the matrices D^x and D^y%-----------------------------------------------------function [Dx, Dy] = elmDxy ...

(x1,y1, x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, NQ)

% read the triangle quadrature[xi, eta, w] = p2quad(NQ);

Dx = zeros(1,6); Dy = zeros(1,6); %initilization

% perform the quadraturefor i=1:NQ[psi, gpsi, jac] = p2basis ...

(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,xi(i),eta(i));

cf = 0.5*jac*w(i);for k=1:6Dx(k) = Dx(k) + gpsi(k,1)*cf;Dy(k) = Dy(k) + gpsi(k,2)*cf;

endend

return;

With all the preparation, now we demonstrate the main function Stokes.m,which is used to solve the flow in a square cavity driven by a translatinglid. Here we assume that μ = 1 and no-slip boundary conditions everywhereexcept at the lid, where u = (1, 0)′. An examplary velocity field and thecorresponding mesh are presented in Fig. 8.8.

%-----------------------------------------------------------% Stokes.m: solve the Stokes flow in a cavity% using P2-P0 elements.%% The code needs:

Page 243: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

228 Computational Partial Differential Equations Using MATLAB

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.5 0 0.5 1−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

x

y

FIGURE 8.8An example mesh and the corresponding velocity field obtained.

% 1. gen_p2grid.m: generate 6-node triangle mesh% 2. elmD.m: produce the element matrix D_u% 3. elmDxy.m: produce the element matrix D_x, D_y% 4. p2basis.m: calculate the P2 basis functions% 5. p2quad.m: Gaussian quadrature on triangle%-----------------------------------------------------------clear all;

vis = 1.0; % viscosityVel = 1.0; % lid velocityNQ = 7; % gauss-triangle quadraturenref = 3; % discretization level

% generate p2 grid[ne,np,p,conn,efl,gfl] = gen_p2grid(nref);disp(’Number of elements:’); ne

inodes = 0;for j=1:npif(gfl(j,1)==0) %interior nodesinodes = inodes+1;end

enddisp(’Number of interior nodes:’); inodes

% specify the boundary velocityfor i=1:np

Page 244: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 229

if(gfl(i,1)==1)gfl(i,2) = 0.0; gfl(i,3) = 0.0; % x and y velocitiesif(p(i,2) > 0.999)gfl(i,2) = Vel; % x velocity on the lid

endend

end

% assemble the global diffusion matrix, Dx and Dy matricesgdm = zeros(np,np); % initializationgDx = zeros(ne,np);gDy = zeros(ne,np);

for l=1:ne % loop over the elementsj=conn(l,1); x1=p(j,1); y1=p(j,2);j=conn(l,2); x2=p(j,1); y2=p(j,2);j=conn(l,3); x3=p(j,1); y3=p(j,2);j=conn(l,4); x4=p(j,1); y4=p(j,2);j=conn(l,5); x5=p(j,1); y5=p(j,2);j=conn(l,6); x6=p(j,1); y6=p(j,2);

[edm_elm, arel] = elmD ...(x1,y1, x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, NQ);

[Dx, Dy] = elmDxy ...(x1,y1, x2,y2, x3,y3, x4,y4, x5,y5, x6,y6, NQ);

for i=1:6i1 = conn(l,i);for j=1:6j1 = conn(l,j);gdm(i1,j1) = gdm(i1,j1) + edm_elm(i,j);

endgDx(l,i1) = Dx(i);gDy(l,i1) = Dy(i);

endend

% form the final global coefficient matrixnsys = 2*np+ne; % total number of unknownsGm=zeros(nsys,nsys);b=zeros(1,nsys);

for i=1:np % first big blockfor j=1:np

Page 245: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

230 Computational Partial Differential Equations Using MATLAB

Gm(i,j) = vis*gdm(i,j); Gm(np+i,np+j) = Gm(i,j);endfor j=1:ne

Gm(i, 2*np+j) = -gDx(j,i);Gm(np+i,2*np+j) = -gDy(j,i);

endend

% second big blockfor i=1:nefor j=1:np

Gm(2*np+i,j) = -gDx(i,j);Gm(2*np+i,np+j) = -gDy(i,j);

endend

% compute RHS of the system and implement the Dirichlet BCfor j=1:npif(gfl(j,1)==1)for i=1:nsysb(i) = b(i) - Gm(i,j)*gfl(j,2) - Gm(i,np+j)*gfl(j,3);Gm(i,j) = 0; Gm(i,np+j) = 0;Gm(j,i) = 0; Gm(np+j,i) = 0;

endGm(j,j) = 1.0;Gm(np+j,np+j) = 1.0;b(j) = gfl(j,2);b(np+j) = gfl(j,3);

endend

% solve the linear systemGm(:,nsys) = []; % remove the last columnGm(nsys,:) = []; % remove the last rowb(nsys) = []; % remove the last component

sol=Gm\b’;

% recover the velocityfor i=1:npux(i) = sol(i); uy(i) = sol(np+i);

end

% plot the velocity fieldfigure(1);

Page 246: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 231

quiver(p(:,1)’,p(:,2)’,ux,uy);hold on;xlabel(’x’,’fontsize’,10)ylabel(’y’,’fontsize’,10)set(gca,’fontsize’,15)axis(’equal’)

% plot the meshfigure(2);for i=1:nei1=conn(i,1); i2=conn(i,2); i3=conn(i,3);i4=conn(i,4); i5=conn(i,5); i6=conn(i,6);xp(1)=p(i1,1); yp(1)=p(i1,2); xp(2)=p(i4,1); yp(2)=p(i4,2);xp(3)=p(i2,1); yp(3)=p(i2,2); xp(4)=p(i5,1); yp(4)=p(i5,2);xp(5)=p(i3,1); yp(5)=p(i3,2); xp(6)=p(i6,1); yp(6)=p(i6,2);xp(7)=p(i1,1); yp(7)=p(i1,2);plot(xp, yp, ’:’);hold on;plot(xp, yp,’o’,’markersize’,5);

end

8.5 Mixed methods for viscous incompressible flows

8.5.1 The steady Navier-Stokes problem

The fundamental equations governing the steady flow of a homogeneous in-compressible Newtonian fluid are the Navier-Stokes equations:

−μ�u+ (u · ∇)u + ∇p = f in Ω, (8.98)∇ · u = 0 in Ω, (8.99)

where we denote

(u · ∇)u =d∑

j=1

uj∂u

∂xj

and Ω for a bounded domain of Rd, d = 2, 3. Furthermore, u denotes thevelocity vector, μ > 0 is the kinematic viscosity, f is the body force vector(per unit mass), p = P/ρ0, P is the fluid pressure, and ρ0 is the density.

There exist many different types of boundary conditions depending on dif-ferent physical situations. The so-called no-slip condition

u = 0 on ∂Ω, (8.100)

Page 247: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

232 Computational Partial Differential Equations Using MATLAB

is used for a viscous fluid confined in a fixed domain, in which case the particlesof the fluid are adherent at the boundary due to the viscous effects.

The so-called non-friction condition is given by

d∑

j=1

[μ(∂ui∂xj

+∂uj∂xi

) − pδij ]nj = fTi on ∂Ω, (8.101)

where n = (nj) is the unit normal to the boundary, fTi is the boundarystress component, and δij is the Kronecker notation (i.e., δij = 0 for i �= jand δjj = 1). Note that fTi = 0 is often used on planes/lines of symmetry,and fTi = constant is used as an inflow/outflow condition on a boundary.Other types of boundary conditions may be encountered in various modelingor simulation situations [18, p. 344].

Denote the two Hilbert spaces U = (H10 (Ω))d and Q = L2

0(Ω) as in Section8.3, and introduce the trilinear form

c(w;u,v) = (w · ∇u,v) =d∑

i=1

(d∑

j=1

wj∂ui∂xj

, vi), (8.102)

we can obtain the weak formulation of (8.98)-(8.100) as follows: Given f ∈(L2(Ω))d, find (u, p) ∈ U ×Q such that

μ(∇u,∇v) + c(u;u,v) − (p,∇ · v) = (f ,v), ∀ v ∈ U, (8.103)(∇ · u, q) = 0, ∀ q ∈ Q. (8.104)

With proper choice of the mixed finite element spaces Uh and Qh as inSection 8.3, the mixed finite element method for the Navier-Stokes problem(8.98)-(8.100) can be obtained: Find (uh, ph) ∈ Uh ×Qh such that

μ(∇uh,∇v) + c(uh;uh,v) − (ph,∇ · v) = (f ,v), ∀ v ∈ Uh, (8.105)(∇ · uh, q) = 0, ∀ q ∈ Qh. (8.106)

Under suitable conditions, there exists a unique solution of (8.105)-(8.106)[11]. Note that (8.105)-(8.106) is a nonlinear system and can be solved byNewton methods. For an abstract nonlinear problem

F (z) = 0, (8.107)

the Newton method is: Given an initial guess z0, find zn+1 such that

∂F

∂z(zn) · (zn+1 − zn) = −F (zn), ∀ n ≥ 0, (8.108)

i.e., at each iteration step, we have to solve a linear problem for zn+1.

Page 248: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 233

Applying the Newton method (8.108) to (8.105)-(8.106), we obtain: Given(u0

h, p0h), find (un+1

h , pn+1h ) ∈ Uh ×Qh such that

μ(∇un+1h ,∇v) + c(un+1

h ;unh,v) + c(unh;un+1h ,v) − (pn+1

h ,∇ · v)= c(unh;u

nh,v) + (f ,v), (8.109)

(∇ · un+1h , q) = 0, (8.110)

for any v ∈ Uh and q ∈ Qh.It can be proved that for any (u0

h, p0h) close to the true solution (u, p),

the scheme (8.109)-(8.110) determines a unique sequence which convergesquadratically to (u, p).

8.5.2 The unsteady Navier-Stokes problem

In this section we consider the unsteady viscous incompressible flows, whichare described by the unsteady Navier-Stokes problem:

∂u

∂t− μ�u+ (u · ∇)u + ∇p = f in Ω × (0, T ), (8.111)

∇ · u = 0 in Ω × (0, T ), (8.112)u = 0 on ∂Ω × (0, T ), (8.113)u|t=0 = u0 on Ω, (8.114)

where f = f (x, t) and u0 = u0(x, t) are given functions.The weak formulation of (8.111)-(8.114) is given as follows: For any t ∈

(0, T ), find (u(t), p(t)) ∈ U ×Q such that

d

dt(u(t),v) + μ(∇u(t),∇v) + c(u(t);u(t),v) − (p(t),∇ · v)

= (f(t),v), ∀ v ∈ U, (8.115)(∇ · u(t), q) = 0, ∀ q ∈ Q, (8.116)u(0) = u0. (8.117)

Similar to the steady problem, we can construct the semi-discrete schemefor approximating (8.115)-(8.117): For each t ∈ [0, T ], find (uh(·, t), ph(·, t)) ∈Uh ×Qh such that

d

dt(uh(t),v) + μ(∇uh(t),∇v) + c(uh(t);uh(t),v) − (ph(t),∇ · v)

= (f (t),v), ∀ v ∈ Uh, (8.118)(∇ · uh(t), q) = 0, ∀ q ∈ Qh, (8.119)uh(0) = u0,h, (8.120)

where u0,h is an approximation to u0. A simple choice of u0,h can be theL2-projection of u0 onto Uh. Here the subspace Uh ⊂ U and Qh ⊂ Q can bechosen as in Section 8.3.

Page 249: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

234 Computational Partial Differential Equations Using MATLAB

The analysis of the scheme (8.118)-(8.120) has been conducted by manyresearchers [13, 14, 4]. An explicit matrix form of (8.118)-(8.120) can beeasily derived. Assume that φj (j = 1, · · · , Nu) and ψk (k = 1, · · · , Np) arethe bases of Uh and Qh, respectively, and denoting the finite element solutionof (8.118)-(8.120) as follows

uh(x, t) =Nu∑

j=1

uj(t)φj(x), ph(x, t) =Np∑

j=1

pj(t)ψj(x),

we obtain the system of nonlinear equations:

Mdu

dt(t) +Au(t) + C(u(t))u(t) + Bp(t) = f(t), t ∈ (0, T ), (8.121)

BTu(t) = 0, t ∈ (0, T ), (8.122)u(0) = u0, (8.123)

where the matrices M,A,B, and C are given as follows:

Mij = (φi, φj), Aij = μ(∇φj ,∇φi),

(C(u))ij =Nu∑

l=1

ulc(φl;φj , φi), Bij = (φj ,∇ · ψi).

Furthermore, the vector f = (fi(t)) = ((f (t), φi)).The problem (8.121)-(8.123) can be further discretized in time by schemes

such as the backward Euler scheme and the Crank-Nicolson scheme.

8.6 Bibliographical remarks

In this chapter, we briefly introduced the fundamental theory for the mixedfinite element method and its applications to elliptic problems and the Stokesproblem. More detailed discussions on mixed methods can be found in otherbooks [7, 11, 12, 20]. Readers can find some most recent reviews on mixedfinite elements in [5]. Bahriawati and Carstensen [3] presented three shortMATLAB programs for solving the Laplace equation with inhomogeneousmixed boundary conditions in 2-D with lowest-order Raviart-Thomas mixed fi-nite elements; interested readers can download the program from http://www.math.hu-berlin.de/ cc/.

Page 250: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 235

8.7 Exercises

1. Consider the problem

−�u = f in Ω,u = g1 on Γ1,

∂u

∂n= g2 on Γ2,

where Ω is a bounded domain of R2 with boundary Γ ≡ Γ1 ∪Γ2, Γ1 ∩Γ2 = ∅,and f, g1 and g2 are given functions. Derive a mixed variational formulationfor this problem and formulate a mixed finite element method using RTNspaces on triangles.

2. Consider the 1-D problem [9, Ch. 5]

− d2p

dx2= f(x) x ∈ I ≡ (0, 1),

p(0) = p(1) = 0.

Let u = − dpdx , V = H1(I), Q = L2(I). Then prove that (u, p) ∈ V ×Q satisfies

the mixed variational form

(u, v) − (vx, p) = 0 v in V, (8.124)(ux, q) = (f, q) q ∈ Q. (8.125)

Furthermore, consider the Lagrangian functional

L(v, q) =12(v, v) − (vx, q) + (f, q), v ∈ V, q ∈ Q.

Prove that the solution (u, p) of (8.124)-(8.125) is a saddle point of the func-tional L(v, q), i.e.,

L(u, p) = minv∈V

maxq∈Q

L(v, q),

orL(u, q) ≤ L(u, p) ≤ L(v, p), ∀ (v, q) ∈ V ×Q.

3. Consider the Dirichlet problem

−∇ · (a(x)∇p+ b(x)p) + c(x)p = f(x) in Ω ⊂ Rd (d = 2 or 3),p = −g(x) on ∂Ω.

Let u = −(a∇p + bp). Prove that u ∈ H(div; Ω) and p ∈ L2(Ω) satisfy themixed weak formulation

(a−1u,v) − (∇ · v, p) + (a−1bp,v) = < g,v · n >∂Ω ∀ v ∈ H(div; Ω),(∇ · u, q) + (cp, q) = (f, q) ∀ q ∈ L2(Ω).

Page 251: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

236 Computational Partial Differential Equations Using MATLAB

4. Let RTr(K) (r ≥ 0) be the Raviart-Thomas space on the triangle K.Show that a function v ∈ RTr(K) is uniquely defined by the degrees of free-dom [19]

< v · n, w >e, ∀ w ∈ Pr(e), e ∈ ∂K,

(v,w)K , ∀ w ∈ (Pr−1(K))2.

5. Modify the code Stokes.m to solve the the Stokes flow in a rectangularcavity [−1, 1.5]× [−0.8, 0.8] with μ = 1 and lid velocity u = (1, 0)′. Plot thevelocity field and the pressure.

6. For a general triangle K with vertices ai, 1 ≤ i ≤ 3, we can define theunique affine invertible mapping

x ≡ FK(x) = BK x+ cK

such thatFK(ai) = ai, 1 ≤ i ≤ 3,

where ai, 1 ≤ i ≤ 3, are the vertices of a reference triangle K. For any vectorfunction q = (q1, q2) defined on K, we can associate a function q defined onK by

q(x) =1JK

BK q(F−1K (x)), (8.126)

where JK = det(BK). Prove that the divergences q and q are related by thefollowing

∇ · q =1JK

∇ · q,

where we denote

∇ · q =∂q1∂x1

+∂q2∂x2

, ∇ · q =∂q1∂x1

+∂q2∂x2

.

Hint: Let BK =(b11 b12b21 b22

), then use the chain rule

∇ · q = (∂q1∂x1

∂x1

∂x1+∂q1∂x2

∂x2

∂x1) + (

∂q2∂x1

∂x1

∂x2+∂q2∂x2

∂x2

∂x2)

and the following

∂x1

∂x1=b22JK

,∂x2

∂x1= − b21

JK,

∂x1

∂x2= − b12

JK,

∂x2

∂x2=b11JK

.

7. For any function q ∈ (H l(K)2 (integer l ≥ 0) defined by (8.126), provethat

|q|Hl(K) ≤ C||BK ||l||B−1K || |JK | 12 |q|Hl(K),

Page 252: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Mixed Finite Element Methods 237

where ||BK || and ||B−1K || denote the spectral norms of BK and B−1

K , respec-tively.

8. Consider the parabolic problem

∂p

∂t− (

∂2p

∂x2+∂2p

∂y2) = f(x, y), in Ω × (0, tF ),

p(x, y, 0) = p0(x, y), in Ω,p = 0 on ∂Ω × (0, tF ).

Develop a mixed variational formulation for this problem and formulate amixed finite element method using some mixed spaces defined in this chapter.Also formulate a fully discrete scheme using the Crank-Nicolson method andprove a corresponding stability result.

9. Consider the biharmonic problem

�2u = f, in Ω,

u =∂u

∂n= 0, on ∂Ω.

Let p = �u ∈ H1(Ω). Prove that (u, p) ∈ H10 (Ω) ×H1(Ω) satisfies the mixed

weak formulation

(p, q) + (∇q,∇u) = 0, ∀ q ∈ H1(Ω),(∇p,∇v) = −(f, v), ∀ v ∈ H1

0 (Ω).

10. Prove that for the trilinear form c(w;u,v), there exists a constant c > 0such that

|c(w;u,v)| ≤ c|w|1|u|1|v|1 ∀ w,u,v ∈ (H10 (Ω))d.

11. Assume that

|∂F∂z

(z1) − ∂F

∂z(z2)| ≤ L|z1 − z2|, ∀ z1, z2 ∈ B(z; ε),

where B(z; ε) denotes a ball centered at z with radius ε. Then there existsa constant δ with 0 < δ < ε such that for any initial guess z0 ∈ B(z; δ), theNewton method (8.108) converges quadratically to z, i.e.,

|zn+1 − z| ≤ C|zn − z|2,holds true for some constant C > 0.

References

[1] D.N. Arnold, F. Brezzi and M. Fortin. A stable finite element for theStokes equations. Calcolo, 21:337–344, 1984.

Page 253: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

238 Computational Partial Differential Equations Using MATLAB

[2] D.N. Arnold, L.R. Scott and M. Vogelius. Regular inversion of thedivergence operator with Dirichlet boundary conditions on a polygon.Annali della Scuola Normale Superiore di Pisa 15(2):169–192, 1988.

[3] C. Bahriawati and C. Carstensen. Three MATLAB implementations ofthe lowest-order Raviart-Thomas MFEM with a posteriori error control.Comput. Methods Appl. Math., 5(4):333–361, 2005.

[4] C. Bernardi and G. Raugel. A conforming finite element method forthe time-dependent Navier-Stokes equations. SIAM J. Numer. Anal.,22(3):455–473, 1985.

[5] D. Boffi and L. Gastaldi (eds.). Mixed Finite Elements, CompatibilityConditions, and Applications. Springer, New York, NY, 2008.

[6] J.M. Boland and R.A. Nicolaides. Stability of finite elements underdivergence constraints. SIAM J. Numer. Anal., 20:722–731, 1983.

[7] F. Brezzi and M. Fortin. Mixed and Hybrid Finite Element Methods.Springer-Verlag, Berlin/Heidelberg, 1991.

[8] P.G. Ciarlet. The Finite Element Method for Elliptic Problems. North-Holland, Amsterdam, 1978.

[9] Z. Chen. Finite Element Methods and Their Applications. Springer,New York, NY, 2005.

[10] G.R. Cowper. Gaussian quadrature formulas for triangles. Internat. J.Numer. Methods Engrg., 7:405–408, 1973.

[11] V. Girault and P.-A. Raviart. Finite Element Methods for Navier-StokesEquations. Springer-Verlag, Berlin, 1986.

[12] Max D. Gunzburger. Finite Element Methods for Viscous IncompressibleFlows. Academic Press, Boston, MA, 1989.

[13] J.G. Heywood and R. Rannacher. Finite element approximation ofthe nonstationary Navier-Stokes problem. I. Regularity of solutions andsecond-order error estimates for spatial discretization. SIAM J. Numer.Anal., 19(2):275–311, 1982.

[14] J.G. Heywood and R. Rannacher. Finite-element approximation of thenonstationary Navier-Stokes problem. IV. Error analysis for second-order time discretization. SIAM J. Numer. Anal., 27(2):353–384, 1990.

[15] C. Johnson. Numerical Solution of Partial Differential Equations by theFinite Element Method. Cambridge University Press, New York, 1988.

[16] J.-C. Nedelec. Mixed finite elements in R3. Numer. Math., 35:315–341,1980.

[17] C. Pozrikidis. Introduction to Finite and Spectral Element Methods Us-ing MATLAB. Chapman & Hall/CRC, Boca Raton, FL, 2005.

Page 254: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 239

[18] A. Quarteroni and A. Valli. Numerical Approximation of Partial Differ-ential Equations. Springer-Verlag, Berlin, 1994.

[19] P.-A. Raviart and J.M. Thomas. A mixed finite element method for2nd order elliptic problems. In Mathematical Aspects of Finite ElementMethods (Lecture Notes in Math., Vol. 606), Springer, Berlin, 292–315,1977.

[20] J.E. Roberts and J.-M. Thomas. Mixed and hybrid methods. Handbookof Numerical Analysis (eds. by P. G. Ciarlet and J.-L. Lions), Vol. II,523–639, North-Holland, Amsterdam, 1991.

[21] C. Taylor and P. Hood. A numerical solution of the Navier-Stokes equa-tions using the finite element technique. Internat. J. Comput. & Fluids,1:73–100, 1973.

Page 255: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 256: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

9

Finite Element Methods for Electromagnetics

In our daily life, we have to interact with all sorts of electromagnetic waves.Examples include heating our food using a microwave oven, talking to friendsthrough a wireless communication network, and taking a medical exam withmagnetic resonance imaging (MRI). Modeling such wave interactions becomesa very important research area often called Computational Electromagnetics(CEM).

In this chapter, we will briefly introduce how the finite element method isused in CEM. In Sec. 9.1, we introduce the Maxwell’s equations in both thetime domain and frequency domain. Then some basic time-domain Galerkinmethods and mixed methods are discussed in Sec. 9.2. In Sec. 9.3, we extendthe discussion to frequency-domain methods such as the standard Galerkinmethod and the discontinuous Galerkin method for the vector wave equation.Finally, we introduce some recent work in modeling Maxwell’s equations indispersive media including the negative index metamaterials in Sec. 9.4.

9.1 Introduction to Maxwell’s equations

The fundamental equations governing all macroscopic electromagnetic phe-nomena are the Maxwell’s equations:

Faraday’s law (1831): ∇×E = −∂B∂t

, (9.1)

Maxwell-Ampere law (1820): ∇×H =∂D

∂t+ J , (9.2)

Gauss’s law: ∇ ·D = ρ, (9.3)Gauss’s law – magnetic: ∇ ·B = 0, (9.4)

where E(x, t) and H(x, t) are the electric and magnetic fields, D(x, t) andB(x, t) are the corresponding electric and magnetic flux densities, J is theelectric current density, and ρ is the electric charge density.

Note that among the four equations above, only three are independent.Usually the first three equations are chosen as such independent equations.Furthermore, constitutive relations are needed for describing the macroscopic

241

Page 257: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

242 Computational Partial Differential Equations Using MATLAB

properties of the underlying medium. For a simple medium, we have

D = εE, B = μH , J = σE + Js, (9.5)

where Js denotes a specified current, ε, μ and σ denote the permittivity, per-meability, and conductivity of the medium, respectively. These parametersbecome tensors for anisotropic media. For inhomogeneous media, these pa-rameters are functions of position too. For more complex media, the consti-tutive relations can become more complicated.

Frequently, the electromagnetic fields are assumed to be time-harmonic(i.e., harmonically oscillating with a single frequency ω), in which case, wemay write

E(x, t) = e−iωtE(x, ω), H(x, t) = e−iωtH(x, ω), Js(x, t) = e−iωtJs(x, ω).(9.6)

Substituting (9.6) and (9.5) into (9.1) and (9.2), we obtain the time-harmonicMaxwell’s equations

∇×E = iωμH, (9.7)

∇×H = −iω(ε+ iσ

ω)E + Js. (9.8)

We can eliminate H from (9.7) and (9.8) to obtain the equation

∇× (1μ∇×E) − ω2(ε+ i

σ

ω)E = iωJs, (9.9)

which is often called the vector wave equation. Similarly, we can eliminate Eto obtain an equation for H only.

The corresponding time-domain vector wave equation of (9.9) can be writ-ten as

∇× (1μ∇×E) + ε

∂2E

∂t2+ σ

∂E

∂t= −∂Js

∂t, (9.10)

which can be obtained from (9.1) and (9.2) by eliminating H and using (9.5).Boundary conditions are needed for a complete description of an electro-

magnetic problem. Between two media, say medium 1 and medium 2, thefields must satisfy the interface conditions

n× (E2 −E1) = −Ms, (9.11)n× (H2 −H1) = Js, (9.12)n · (D2 −D1) = ρs, (9.13)n · (B2 −B1) = μs, (9.14)

where (Ms, Js) and (ρs, μs) are the magnetic and electric current and surfacecharge densities, respectively, where n is unit vector normal to the interfacepointing from medium 1 to medium 2.

Page 258: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 243

The two most common cases are:(i) Ms = Js = ρs = μs = 0, i.e., the interface is free of source and charge;(ii) Ms = μs = 0, ρs, Js �= 0, i.e., there exists a surface electric current densityJs and a surface charge density ρs.

When medium 2 becomes a perfect conductor (hence E2 = H2 = 0), weobtain the so-called perfect conducting boundary condition:

n×E1 = 0, n ·B1 = 0. (9.15)

In this case, the boundary can always support a surface current and a surfacecharge, i.e., we have

n×H1 = −Js, n ·D1 = −ρs. (9.16)

When medium 2 is not a perfect conductor, we have the impedance or imper-fectly conducting boundary condition:

n×H1 − λ(n×E1) × n = 0, (9.17)

where the impedance λ is a positive function of position.

9.2 The time-domain finite element method

9.2.1 The mixed method

Substituting (9.5) into (9.1) and (9.2), we can obtain the Maxwell’s equationsin a simple medium:

εEt + σE −∇×H = −Js, in Ω × (0, T ), (9.18)μHt + ∇×E = 0, in Ω × (0, T ), (9.19)

where Ω denotes a bounded Lipschitz continuous polyhedral domain in R3.To make the problem more general, we assume that ε, σ, and μ vary withthe position, and these coefficients are piecewise smooth, real, bounded, andpositive, i.e., there exist constants εmin, εmax, σmax, μmin, and μmax such that,for all x ∈ Ω,

0 < εmin ≤ ε(x) ≤ εmax <∞,

0 < μmin ≤ μ(x) ≤ μmax <∞,

0 ≤ σ(x) ≤ σmax <∞.

We assume that the boundary of the domain Ω is a perfect conductor, sothat

n×E = 0 on ∂Ω × (0, T ). (9.20)

Page 259: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

244 Computational Partial Differential Equations Using MATLAB

In addition, initial conditions are assumed to be

E(x, 0) = E0(x) and H(x, 0) = H0(x), ∀ x ∈ Ω, (9.21)

where E0 and H0 are given functions, and H0 satisfies

∇ · (μH0) = 0 in Ω, H0 · n = 0 on ∂Ω. (9.22)

Before we move on, we need to introduce some functional spaces. LetCm(0, T ;X) be the space of m times continuously differentiable functionsfrom [0, T ] into the Hilbert space X , and

H(curl; Ω) = {v ∈ (L2(Ω))3;∇× v ∈ (L2(Ω))3},with equipped norm

||v||0,curl = (||v||20 + ||∇ × v||20)1/2.

Furthermore, for any Hilbert space X and integer p ≥ 1, we define

Lp(0, T ; Ω) = {v ∈ X ;∫ T

0

||v(s)||pXds <∞}

with the norm

||v||Lp(0,T ;X) = (∫ T

0

||v(s)||pXds)1/p.

The weak formulation of (9.18)-(9.19) can be obtained as follows. Multi-plying (9.18) by a test function φ ∈ (L2(Ω))3 and integrating over Ω, thenmultiplying (9.19) by a test function ψ ∈ H(curl; Ω) and integrating over Ω,and using the Stokes formula

Ω

∇×E · ψ =∫

∂Ω

n×E · ψ +∫

Ω

E · ∇ × ψ, (9.23)

we obtain the weak formulation of (9.18)-(9.19): Find(E,H) ∈ [C1(0, T ; (L2(Ω))3) ∩ C0(0, T ;H(curl; Ω))]2 such that

(εEt, φ) + (σE, φ) − (∇×H, φ) = −(Js, φ), ∀ φ ∈ (L2(Ω))3, (9.24)(μHt, ψ) + (E,∇× ψ) = 0, ∀ ψ ∈ H(curl; Ω), (9.25)

for 0 < t ≤ T with the initial conditions

E(x, 0) = E0(x), H(x, 0) = H0(x).

Notice that the boundary condition (9.20) is used in deriving (9.25).To define a finite element method, we need to construct finite-dimensional

spacesUh ⊂ (L2(Ω))3 and Vh ⊂ H(curl; Ω).

Page 260: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 245

We assume that Ω is discretized by a regular finite element mesh Th, oftetrahedra with maximum diameter h. Following [41, p. 1617], let Pk denotethe standard space of polynomials of total degree less than or equal to k,and let Pk denote the space of homogeneous polynomials of order k. DefineSk ⊂ (Pk)3 and Rk ⊂ (Pk)3 by

Sk = {p ∈ (Pk)3 | p(x) · x = 0, x ∈ R3},Rk = (Pk−1)3 ⊕ Sk.

Following [46, 41], let K be a tetrahedron in Ω with general edge e and facef. Let τe be a unique vector parallel to e. Let v ∈ (W 1,l(K))3 for some l > 2.We define the following three sets of moments of v on K:

Me(v) = {∫

e

(v · τe)qds : ∀ q ∈ Pk−1(e) for 6 edges e of K}, (9.26)

Mf (v) = {∫

f

v × n · qdA : ∀ q ∈ (Pk−2(f))2 for 4 faces f of K},(9.27)

MK(v) = {∫

K

v · qdx : ∀ q ∈ (Pk−3(K))3}. (9.28)

Hence for any v ∈ (W 1,l(Ω))3, l > 2, an interpolation operator Πhv ∈ Vh canbe defined such that Πhv|K ∈ Rk has the same moments (9.26)-(9.28) as v onK for each K ∈ Th. Furthermore, these three sets of degrees of freedom areproved to be Rk-unisolvent and H(curl) conforming [46]. Note that a finiteelement is said to be conforming in H(curl) if the tangential components ofΠhv|K1 and Πhv|K2 are the same on the common face of K1 and K2.

Furthermore, for any integer k ≥ 1, we define [41, Eqs. (3.2) and (3.8)]

Uh = {uh ∈ (L2(Ω))3 : uh|K ∈ (Pk−1)3 ∀ K ∈ Th}, (9.29)Vh = {vh ∈ H(curl; Ω) : vh|K ∈ Rk ∀ K ∈ Th}, (9.30)

then any function in Vh can be uniquely defined by the degrees of freedom(9.26)-(9.28) on each K ∈ Th.

The following interpolation properties for the Nedelec spaces have beenproved (see [46, Theorem 2] and [41, Theorem 3.2]).

LEMMA 9.1If v ∈ (H l+1(Ω))3, 1 ≤ l ≤ k, then

||v − Πhv||0 + ||∇ × (v − Πhv)||0 ≤ Chl||v||l+1.

We also need the standard (L2(Ω))3 projection operator Ph : (L2(Ω))3 →Uh defined as:

(Phu− u,φh) = 0 ∀ φh ∈ Uh.

Page 261: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

246 Computational Partial Differential Equations Using MATLAB

Furthermore, we have the error estimate

||u − Phu||0 ≤ Chl||u||l, 0 ≤ l ≤ k. (9.31)

Now we can consider the semi-discrete mixed method for solving (9.24)-(9.25): Find (Eh,Hh) ∈ C1(0, T ;Uh) × C1(0, T ;Vh) such that

(ε∂Eh

∂t,φ) + (σEh,φ) − (∇×Hh,φ) = −(Js,φ), ∀ φ ∈ Uh, (9.32)

(μHh

∂t,ψ) + (Eh,∇×ψ) = 0, ∀ ψ ∈ Vh, (9.33)

for 0 < t ≤ T, and with initial conditions

Eh(0) = PhE0 and Hh(0) = ΠhH0. (9.34)

The scheme (9.32)-(9.34) was first proposed and analyzed by Monk [41],who proved the following optimal convergence result.

THEOREM 9.1Suppose that the solution (E,H) of (9.18)-(9.19) satisfies E ∈ C1(0, T ; (Hk(Ω))3)and H ∈ C1(0, T ; (Hk+1(Ω))3). Let Uh and Vh be given, respectively, by(9.29)-(9.30), and (Eh(t),Hh(t)) ∈ Uh × Vh be the solution of (9.32)-(9.34).Then there exists a constant C independent of h and t such that for any k ≥ 1,

||(H −Hh)(t)||0 + ||(E −Eh)(t)||0 + ||(E −Eh)(t)||L2(0,t;(L2(Ω))3)

≤ Chk{||H0||k+1 + ||E0||k + ||Ht||L1(0,t;(Hk+1(Ω))3)

+||H||L1(0,t;(Hk+1(Ω))3) + ||Et||L1(0,t;(Hk(Ω))3) + ||E||L2(0,t;(Hk(Ω))3)}.

The proof of the theorem is quite technical and lengthy; interested readerscan consult the original paper [41].

There exist many possible fully discrete schemes for solving (9.32)-(9.33).One popular method used in computational electromagnetics is the leapfrogscheme. Let us divide the time interval [0, T ] into M uniform subintervals bypoints

0 = t0 < t1 < · · · < tM = T, where tn = n · �t, �t = T/M.

We let Enh be the approximation of Eh(t) at tn, H

n+ 12

h be the approximationof Hh(t) at tn+ 1

2= (n + 1

2 )�t. The leapfrog scheme can be formulated as

follows: Given (Enh,H

n+ 12

h ) the new time approximation (En+1h ,H

n+ 32

h ) isobtained by successively solving the equations

(εEn+1h −En

h

�t , φ) + (σEn+1h +En

h

2, φ) − (∇×Hn+ 1

2h , φ) = −(Jn+ 1

2s , φ),

∀ φ ∈ Uh, (9.35)

(μH

n+ 32

h −Hn+ 12

h

�t , ψ) + (En+1h ,∇× ψ) = 0, ∀ ψ ∈ Vh. (9.36)

Page 262: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 247

The initial value H12h can be computed using a Taylor expansion, i.e.,

H12h ≈H 1

2 = H(0) +12�t∂H

∂t(0) = H0 − �t

2μ∇×E0. (9.37)

Notice that the leapfrog scheme (9.35)-(9.36) is an explicit scheme, whichcan be written in matrix form [41]:

MεEn+1h −En

h

�t +MσEn+1h +En

h

2−McH

n+ 12

h = −Jn+ 12

s , (9.38)

MμH

n+ 32

h −Hn+ 12

h

�t +MTc E

n+1h = 0, (9.39)

where both Mε and Mσ are symmetric positive definite block diagonal ma-trices of size dimUh × dimUh, Mμ is symmetric positive definite and of sizedimVh × dimVh, Mc is a matrix of dimUh× dimVh, and MT

c is the transposeof Mc. In the leapfrog scheme, at each time step, we first solve En+1

h from

(9.38), then Hn+ 32

h from (9.39).To eliminate the time step constraints for explicit schemes, fully implicit

schemes can be used. For example, we can develop the Crank-Nicolson schemefor solving (9.32)-(9.33): Find (En+1

h ,Hn+1h ), n ≥ 1, such that

(εEn+1h −En

h

�t ,φ) + (σEn+1h +En

h

2,φ) − (∇× Hn+1

h +Hnh

2,φ)

= −(Jn+ 12

s ,φ), (9.40)

(μHn+1

h −Hnh

�t ,ψ) + (En+1h +En

h

2,∇×ψ) = 0, (9.41)

for any φ ∈ Uh and ψ ∈ Vh. Notice that (9.40)-(9.41) can be written inmatrix form as

MεEn+1h −En

h

�t +MσEn+1h +En

h

2−Mc

Hn+1h +Hn

h

2= −Jn+ 1

2s ,

MμHn+1

h −Hnh

�t +MTc

En+1h +En

h

2= 0.

The unconditional stability of the Crank-Nicolson scheme can be provedeasily by choosing φ = En+1

h +Enh in (9.40) and ψ = Hn+1

h +Hnh in (9.41)

and adding the results together.It is claimed that [41, p. 1632] the leapfrog and the Crank-Nicolson schemes

can be proved to be convergent with error O((�t)2+hk), where k is the degreeof the basis functions in subspaces Uh and Vh defined in (9.29) and (9.30),respectively.

Page 263: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

248 Computational Partial Differential Equations Using MATLAB

9.2.2 The standard Galerkin method

Here we will discuss some methods for solving the vector wave equation intime domain

εEtt + σEt + ∇× (1μ∇×E) = −∂Js

∂tin Ω × (0, T ), (9.42)

with initial conditionsE(x, 0) = E0(x)

and

Et(x, 0) = E1(x) ≡ 1ε(x)

(−Js(x, 0) + ∇×H0(x) − σ(x)E0(x)). (9.43)

As in the last subsection, we still assume that Ω is a bounded Lipschitz con-tinuous polyhedral domain in R3. The parameters ε, μ, and σ satisfy the sameconditions as mentioned in the last subsection.

In order to obtain a weak formulation of (9.42), we define the space

H0(curl; Ω) = {v ∈ (L2(Ω))3;∇× v ∈ (L2(Ω))3,n× v = 0 on ∂Ω}.Multiplying (9.42) by a test function φ ∈ H0(curl; Ω) and integrating by parts,we obtain the weak formulation for (9.42): Find E(t) ∈ H0(curl; Ω) such that

(εEtt, φ) + (σEt, φ) + (1μ∇×E,∇× φ) = −(

∂Js∂t

, φ) ∀ φ ∈ H0(curl; Ω),

(9.44)subject to the initial conditions

E(0) = E0 and Et(0) = E1. (9.45)

Now we need to construct a finite element space Vh ⊂ H0(curl; Ω). Forsimplicity, let us consider the second type Nedelec spaces on tetrahedra [47].Denote

Dk = (Pk−1)3 ⊕ {p(x)x : p ∈ Pk−1}, k ≥ 1, (9.46)

where Pk−1 denotes the set of polynomials of total degree at most k−1, Pk−1

denotes the set of homogeneous polynomials of degree k − 1.Let K be a nondegenerate tetrahedron with faces f and edges e. Following

Nedelec [47], we can define the finite element space as follows:

Vh = {v ∈ H(curl; Ω);v|K ∈ (Pk)3, ∀ K ∈ Th,n× v = 0 on ∂Ω}, (9.47)

where each function v is uniquely defined by the following three sets of degreesof freedom:

Me(v) = {∫

e

(v · τ)qds : q ∈ Pk(e) on each edge e of K},

Mf (v) = {∫

f

v · qdA : q ∈ Dk−1(f) tangent to each face f of K},

MK(v) = {∫

K

v · qdV : q ∈ Dk−2(K)}.

Page 264: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 249

Here τ denotes the tangent vector along the direction of e. An interpolationoperator Πh can be defined such that Πhv ∈ Vh and Πhv has the same degreesof freedom as v on each tetrahedron K ∈ Th. Nedelec [47] proved that thesedegrees of freedom are (Pk)3 unisolvent and H(curl) conforming.

Now we can formulate the semi-discrete scheme for solving (9.42)-(9.43):Find Eh(t) ∈ Vh such that

(ε∂2Eh

∂t2, φ)+(σ

∂Eh

∂t, φ)+(

1μ∇×Eh,∇×φ) = −(

∂Js∂t

, φ) ∀ φ ∈ Vh, (9.48)

subject to the initial conditions

Eh(0) = ΠhE0 and∂Eh(0)∂t

= ΠhE1. (9.49)

The error analysis for the time-dependent vector wave equation (9.42) inR3 was first carried out by Monk [43], who proved the following optimalenergy-norm error estimates on general polyhedral domains.

THEOREM 9.2Let E and Eh be the solutions of (9.42)-(9.43) and (9.48)-(9.49), respectively.Under the regularity assumptions that Et(t),Ett(t) ∈ Hk+1(Ω), 0 ≤ t ≤ T,then we have

||(E −Eh)(t)||0,curl + ||(E −Eh)t(t)||0

≤ Chk{||E0||k+1 + max0≤s≤t

||Et(s)||k+1 +∫ t

0

||Ett(s)||k+1ds}, (9.50)

where the constant C = C(T ) is independent of the mesh size h.

Due to its technicality, we skipped the proof, which can be found in Monk’spaper [43]. Actually, the above estimates hold true for other elements suchas: the first type Nedelec elements on tetrahedra and cubes [46], and H1(Ω)conforming elements with continuous piecewise polynomials of degree k, sincethe proof only uses the following interpolation estimate:

||v −Πhv||0 + h||v −Πhv||0,curl ≤ Chk+1||v||k+1, for any v ∈ (Hk+1(Ω))3.(9.51)

Notice that the L2 error estimate from (9.50) is not optimal. Under theassumptions that Ω is a convex polyhedral domain, σ ≡ 0, and ε and μ areconstants, Monk [43] proved the following almost optimal error estimate

||(E −Eh)(t)||0 ≤ Chk+1−δ, (9.52)

where δ > 0 is an arbitrary small constant.

Page 265: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

250 Computational Partial Differential Equations Using MATLAB

Fully discrete finite element methods were considered later by Ciarlet andZou [12]. For example, the backward Euler scheme can be formulated asfollows: For n = 1, 2, · · · ,M , find En

h ∈ Vh such that

(εEnh − 2En−1

h +En−2h

(�t)2 , φ) + (σEnh −En−1

h

�t , φ) + (1μ∇×En

h,∇× φ)

= −(∂Js∂t

(tn), φ) ∀ φ ∈ Vh, (9.53)

subject to the initial approximations

E0h = ΠhE0, E0

h −E−1h = �tΠhE1. (9.54)

Similarly, the Crank-Nicolson scheme can be developed as follows: For n =0, 1, · · · ,M − 1 and any φ ∈ Vh, find En+1

h ∈ Vh such that

(εEn+1h − 2En

h +En−1h

(�t)2 , φ) + (σEn+1h −En−1

h

2�t , φ)

+(1μ∇× En+1

h +En−1h

2,∇× φ) = −(

∂Js∂t

(tn), φ), (9.55)

subject to the initial approximations

E0h = ΠhE0, E1

h −E−1h = 2�tΠhE1. (9.56)

Ciarlet and Zou [12] proved the optimal error estimates for the backwardEuler scheme in both the energy norm and the L2 norm for the lowest-orderfirst and second type of H(curl; Ω)-conforming Nedelec elements using lessregularity requirements than Monk assumed [43]. More specifically, the finiteelement space Vh can be chosen either as

Vh = {v ∈ H(curl; Ω) : v|K ∈ (P1)3, ∀ K ∈ Th,n× vh = 0 on ∂Ω},or

Vh = {v ∈ H(curl; Ω) : v|K = aK + bK × x, aK and bK ∈ R3, ∀ K ∈ Th,

n× vh = 0 on ∂Ω}.Then for general polyhedral domains, Ciarlet and Zou [12] proved that

max1≤n≤M

(||Enh −En−1

h

�t − ∂En

∂t||0 + ||∇ × (En

h −E)||0) ≤ C(�t+ h),

where C is a constant independent of both the time step �t and the mesh sizeh. When Ω is a convex polyhedral domain, σ ≡ 0, and ε and μ are constants,they proved the optimal error estimate

||Enh −En||0 ≤ C(�t+ h2), n = 1, 2, · · · ,M,

where C is independent of �t and h.

Page 266: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 251

9.2.3 The discontinuous Galerkin method

The discontinuous Galerkin (DG) finite element method was originally in-troduced for the neutron transport equation in 1970s. Later it was usedfor the weak enforcement of continuity of the Galerkin method for diffusionproblems. In recent years, the DG methods have been extended to broaderapplications [13]. For mathematical analysis, see recent survey articles [4, 15].The main advantages of DG methods are the local mass conservation prop-erty, great flexibility in handling nonmatching grids, elements of various typesand shapes, and parallelization. In this subsection, we will introduce severalDG methods developed for solving time-dependent Maxwell’s equations.

First, we want to introduce the nodal DG method developed by Hesthavenand Warburton [21]. For clarity, we keep similar notation of [21] and rewritethe Maxwell’s equations (9.18)-(9.19) with σ = 0 in conservation form

λ∂q

∂t+ ∇ · F (q) = s, (9.57)

where we denote

λ =[ε(x) 0

0 μ(x)

], q =

[EH

], Fi(q) =

[−ei ×Hei ×E

]. (9.58)

Here ei (i = 1, 2, 3) are the Cartesian unit vectors in x, y, and z directions,vector F (q) is represented as F (q) = [F1(q), F2(q), F3(q)], and vector s =[sE , sH ]T is the general source term.

Before we move on, let us first elaborate on how it (9.57) is derived. Notethat

e1 ×H =

∣∣∣∣∣∣

�i �j �k1 0 0Hx Hy Hz

∣∣∣∣∣∣= −Hz

�j +Hy�k.

Similarly, we can show that

e2 ×H = Hz�i−Hx

�k, e3 ×H = −Hy�i+Hx

�j,

where subscripts x, y, and z denote the components of H.Hence the first component of ∇ · F equals

∂F(1)1

∂x+∂F

(1)2

∂y+∂F

(1)3

∂z

=∂

∂x(−e1 ×H) +

∂y(−e2 ×H) +

∂z(−e3 ×H)

=∂

∂x(Hz

�j −Hy�k) +

∂y(−Hz

�i+Hx�k) +

∂z(Hy

�i−Hx�j)

= (∂Hy

∂z− ∂Hz

∂y)�i+ (

∂Hz

∂x− ∂Hx

∂z)�j + (

∂Hx

∂y− ∂Hy

∂x)�k

= ∇×H.

Page 267: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

252 Computational Partial Differential Equations Using MATLAB

By the same technique, we can see that the second component of ∇ · Fequals −∇×E, from which we can conclude that (9.57) is indeed equivalentto (9.18)-(9.19) with σ = 0 and a general source s on the right-hand side.

To derive the DG method, we assume that Ω is decomposed into tetrahedralmesh Th, i.e., Ω = ∪K∈Th

K. We require that (9.57) satisfy elementwise theweak form

K

(λ∂qh∂t

+ ∇ · F h − sh)φ(x)dx =∮

∂K

ψ(x)n · (F h − F ∗h)dx, (9.59)

where φ and ψ are test functions, F ∗h is a numerical flux, and the DG solution

qh on each element K is represented as

qh(x, t) =N∑

j=0

q(xj , t)Lj(x) =N∑

j=0

qj(t)Lj(x). (9.60)

Here Lj(x) are the 3-D Lagrange interpolation polynomials based on the N+1nodal points. To make the basis a complete polynomial of degree n, we need16 (n + 1)(n + 2)(n + 3) nodal points, which number is the total degrees offreedom for n-th order polynomial (Pn(x))3.

Note that (9.59) imposes the boundary or interface conditions rather weaklyby penalizing the interface integral. Also it gives a tremendous freedom indesigning different schemes by choosing various φ, ψ, and F ∗

h. One popularchoice [21] is to choose the test functions

φ(x) = ψ(x) = Li(x) (9.61)

and upwind flux

n · (F h − F ∗h) =

(n× (Z+[Hh] − n× [Eh])/(Z+ + Z−)n× (−n× [Hh] − Y +[Eh])/(Y + + Y −)

)(9.62)

where[Eh] = E+

h −E−h , [Hh] =H+

h −H−h

denote the jumps across an interface. Here Z± and Y ± are the local impedanceand conductance defined as

Z± = 1/Y ± =

√μ±

ε±,

where the superscript “+” refers to the value from the neighboring elementwhile “-” refers to the value inside the element.

Now substituting (9.60)-(9.62) into (9.59), we obtain the nodal DG semi-discrete scheme

N∑

j=0

(M εij

dEjdt

− Sij ×Hj −MijsEj )

Page 268: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 253

=∑

l

Fil(nl × Z+l [Hl] − nl × [El]

Z+l + Z−

l

), (9.63)

N∑

j=0

(Mμij

dHj

dt+ Sij × Ej −Mijs

Hj )

=∑

l

Fil(nl × −nl × [Hl] − Y +l [El]

Y +l + Y −

l

), (9.64)

where the local material mass matrices

M εij =

K

Li(x)ε(x)Lj(x)dx, Mμij =

K

Li(x)μ(x)Lj(x)dx,

and the face mass matrix

Fil =∮

∂K

Li(x)Lj(x)ds.

It is proved [21] that if the boundary of Ω is either periodic or terminatedwith a perfectly conducting boundary, then the semi-discrete approximation(9.63)-(9.64) is stable in the sense that

d

dt(EGY ) ≤ C(EGY + ||sE ||2L2(Ω) + ||sH ||2L2(Ω)),

where EGY denotes the global energy

EGY =∑

K∈Th

12

K

(μ|Hh|2 + ε|Eh|2)dx.

The following convergence result has been obtained in [21].

THEOREM 9.3Assume that the solution to the Maxwell’s equations q ∈ W p,2(K), p ≥ 2, forany K ∈ Th. Then the DG solution qh of (9.63)-(9.64) converges to the exactsolution, and the following error estimate holds true

K∈Th

(∫

K

|q − qh|2dx)1/2

≤ C∑

K∈Th

(hσ

np||q(0)||Wp,2(K) + t

hσ−1

np−2maxs∈[0,t]

||q(s)||Wp,2(K)),

where n is the degree of the basis polynomial, σ = min(p, n + 1), and h =maxK∈Th

(diam(K)). The constant C depends upon the material properties,but is independent of h and n.

Page 269: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

254 Computational Partial Differential Equations Using MATLAB

Another slightly different DG method was proposed in [10] as below:∫

K

λ∂qh∂t

ψdx−∫

K

F (qh) · ∇ψdx+∮

∂K

F h · nψ =∫

K

sψdx, (9.65)

for any test function ψ ∈ (Pk(K))3, the space of polynomials of degree k inthe element K. Here F h ·n is the numerical flux on ∂K, which can be chosenas the same upwind flux defined by (9.62).

Substituting the approximate solution

qh|K =Nk∑

j=1

qj(t)ψj(x) (9.66)

into (9.65), we obtain a system of ordinary differential equations

dq

dt= Lq + S(t), (9.67)

which can be solved by any time difference scheme. In [10], the mth-order,mth-stage strong stability preserving Runge-Kutta scheme with low storagewas used. Interested readers can find more details about the implementationin the original paper [10].

Finally, we would like to introduce the locally divergence-free DG methoddeveloped by Cockburn et al. [14]. Rewrite the 2-D Maxwell’s equations

∂Hx

∂t= −∂Ez

∂y,∂Hy

∂t=∂Ez∂x

,∂Ez∂t

=∂Hy

∂x− ∂Hx

∂y(9.68)

into the conservation form

∂q

∂t+ ∇ · F (q) = 0, (9.69)

where q = (Hx, Hy, Ez)T , F (q) = (F 1,F 2,F 3),

F 1 = (0,−Ez,−Hy), F 2 = (Ez , 0, Hx), F 3 = (0, 0, 0).

Note that the system (9.68) has a divergence-free solution (Hx, Hy) at alltimes if initially it is divergence free. To construct a locally divergence-free DGmethod, we need to develop the locally divergence-free finite element space

V kh = {v : v|K ∈ (Pk(K))3,K ∈ Th, (

∂v1∂x

+∂v2∂y

)|K = 0}

= V kh,0 ⊕ {v3 : v3|K ∈ Pk(K),K ∈ Th}. (9.70)

We can obtain the bases for V kh,0|K by taking the curl of bases of Pk+1(K).

Note that the 2-D curl operator is defined as

∇× f ==

(∂f∂y

−∂f∂x

). (9.71)

Page 270: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 255

Hence if K is a rectangular element, the bases of V 1h,0|K are ∇×P2(K), which

leads to (0−1

),

(10

),

(0

−2x

),

(x−y

),

(2y0

), (9.72)

from bases 1, x, y, x2, xy, y2, respectively.Similarly, for k = 2, the bases of V 2

h,0|K can be obtained from ∇× P3(K),which includes (9.72) and the extra terms below

(0

−3x2

),

(x2

−2xy

),

(2xy−y2

),

(3y2

0

), (9.73)

obtained from bases x3, x2y, xy2, y3, respectively.Now we can form the DG method for (9.69): find qh ∈ V k

h such that∫

K

∂qh∂tvdx−

K

F (qh) · ∇vdx+∑

e∈∂K

e

F h · nv = 0, ∀ v ∈ V kh, (9.74)

where the numerical flux can be the upwind flux defined by (9.62). In partic-ular, for the 2-D problem (9.68), the upwind flux can be written as

F h · n =

⎝n2(Ez − n2

2 [Hx] + n12 [Hy])

−n1(Ez − n22 [Hx] + n1

2 [Hy])n2Hx − n1Hy − 1

2 [Ez ]

⎠ , (9.75)

where we denote the average and jump as

v = 0.5(v− + v+), [v] = v+ − v−.

The following error estimate has been proved in [14].

THEOREM 9.4

Let q = (Hx, Hy, Ez) be the smooth exact solution of (9.68), and qh =(Hx,h, Hy,h, Ez,h) the solution of (9.74)-(9.75) in V k

h. Then

||q − qh||0 ≤ Chk+12 ||q||k+1, ∀ k ≥ 1. (9.76)

In [14], the Lax-Friedrichs flux

F h · n =

⎝n2(Ez − n2

2 [Hx] + n12 [Hy]) − 1

2 (n21[Hx] + n1n2[Hy])

−n1(Ez − n22 [Hx] + n1

2 [Hy]) − 12 (n1n2[Hx] + n2

2[Hy])n2Hx − n1Hy − 1

2 [Ez]

⎠ (9.77)

is proved to be another good choice, which achieves the same error estimateas (9.76) for a globally divergence-free finite element space.

Page 271: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

256 Computational Partial Differential Equations Using MATLAB

9.3 The frequency-domain finite element method

9.3.1 The standard Galerkin method

Let us consider the vector wave equation

∇× (1μ∇×E) − ω2(ε+ i

σ

ω)E = iωJs, in Ω, (9.78)

with a perfectly conducting boundary

n×E = 0 on ∂Ω, (9.79)

where Ω is a bounded polygonal domain in R3 with boundary surface ∂Ω andunit outward normal n.

For simplicity, we assume that Ω is discretized by a family of tetrahedralmeshes Th. The meshes are regular and quasi-uniform. Then we can con-struct a family of finite dimensional subspaces V h0 ⊂ H0(curl; Ω) by using theNedelec’s first type spaces, i.e.,

V h0 = { vh ∈ Vh : n× vh = 0 on ∂Ω}, (9.80)

where Vh is defined by (9.30).The standard Galerkin method for solving (9.78)-(9.79) is: Find Eh ∈ V h0

such that

(μ−1∇×Eh,∇× φ) − ω2((ε+ iσ

ω)Eh, φ) = (iωJs, φ) ∀ φ ∈ V h0 . (9.81)

If σ is strictly positive on Ω, the bilinear form in (9.81) is coercive onH0(curl; Ω), i.e., there exists a constant C > 0 such that [34]:

|(μ−1∇× v,∇× v) − ω2((ε+ iσ

ω)v,v)| ≥ C||v||2

0,curl, ∀ v ∈ H0(curl; Ω).

(9.82)Hence by Cea’s lemma and the interpolation estimate (Lemma 9.1), we easilyobtain [44, Theorem 3.1]:

THEOREM 9.5Suppose that σ is continuous and strictly positive on Ω and E ∈ (Hk+1(Ω))3.Then there exists a unique solution Eh to (9.81). Furthermore, the followingerror estimate holds true:

||E −Eh||0,curl ≤ Chk||E||k+1,

where the constant C > 0 is independent of h.

Page 272: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 257

When σ ≡ 0, the bilinear form in (9.81) is not coercive on H0(curl; Ω). Inthis case, (9.78) may fail to have a solution at a countably infinite discreteset of values of w which are termed the interior Maxwell eigenvalues. Toguarantee convergence, we need more restrictive assumptions. By applyinga discrete Helmholtz decomposition, Monk [44] proved the following optimalerror estimate:

THEOREM 9.6Assume that Ω is a convex polygonal domain in R3, σ ≡ 0, ε and μ are

constants, and E ∈ (Hk+1(Ω))3. Then provided that ω is not an interiorMaxwell eigenvalue, and h is sufficiently small, there exists a unique solutionEh of (9.81). Furthermore, there is a constant C independent of h such that

||E −Eh||0,curl ≤ Chk||E||k+1.

Notice that both Theorems 9.5 and 9.6 only provide sub-optimal error es-timates in the L2-norm. Using Nedelec’s second type elements (9.47), Monk[44] proved the almost optimal error estimate in L2-norm:

THEOREM 9.7Let the same assumptions as Theorem 9.6 hold true, and Eh is the solution

of (9.81) with V h0 as the Nedelec’s second type elements. Then for any δ >0 sufficiently small, there exists a constant C = C(δ) such that h is smallenough, we have

||E −Eh||0,curl ≤ Chk||E||k+1, ||E −Eh||0 ≤ Chk+1−δ||E||k+1.

The same convergence results as Theorem 9.5 holds true for Nedelec’s sec-ond type elements.

9.3.2 The discontinuous Galerkin method

Recently, DG methods have begun to find their applications in solving Maxwell’sequations in the frequency domain [27, 28, 26, 49]. Here we will present somerelated DG methods.

For simplicity, we consider the regular tetrahedra mesh Th of Ω defined inthe last subsection. We denote hK the diameter of the tetrahedral elementK ∈ Th, h the mesh size of Th given by h ≡ maxK∈Th

hK , F Ih the set of allinterior faces of elements in Th, FBh the set of all boundary faces, and the setFh ≡ F Ih ∪ FBh .

Next we define some trace operators for piecewise smooth vector functionv and scalar function q. For an interior face f ∈ F Ih shared by two neigh-boring elements K+ and K− with unit outward normal vectors n+ and n−,respectively, we denote by v± and q± the traces of v and q taken from K±,

Page 273: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

258 Computational Partial Differential Equations Using MATLAB

respectively. Furthermore, we define the jumps across f by

[[v]]T ≡ n+×v++n−×v−, [[v]]N ≡ v+·n++v−·n−, [[q]]N ≡ q+n++q−n−,

and the averages across f by

{{v}} ≡ 12(v+ + v−), {{q}} ≡ 1

2(q+ + q−).

On a boundary face f ∈ FBh , we define

[[v]]T ≡ n× v, {{v}} ≡ v, [[q]]N ≡ qn.

For two neighboring faces ∂K1 and ∂K2, we have∫

∂K1

v1 · n1 × u1 +∫

∂K2

v2 · n2 × u2

=∫

∂K1

v1 + v2

2· n1 × u1 +

∂K2

v1 + v2

2· n2 × u2

+∫

∂K1

v1 − v2

2· n1 × u1 −

∂K2

v1 − v2

2· n2 × u2

=∫

∂K1∩∂K2

(v1 + v2) · 12(n1 × u1 + n2 × u2)

−∫

∂K1

n1 × (v1 − v2) · u1

2+∫

∂K2

n2 × (v1 − v2) · u2

2, (9.83)

where we used the identity

a · (b× c) = (a× b) · c = −(b× a) · c,which holds true for any vectors a, b, and c.

Using the fact n2 = −n1, we obtain

−n1 × (v1 − v2) · u1

2+ n2 × (v1 − v2) · u2

2= −(n1 × v1 + n2 × v2) · u1

2− (n1 × v1 + n2 × v2) · u2

2

= −(n1 × v1 + n2 × v2) · u1 + u2

2. (9.84)

Substituting (9.84) into (9.83) and using the trace operators defined earlier,we have

LEMMA 9.2

∂K1

v1 · n1 × u1 +∫

∂K2

v2 · n2 × u2

=∫

∂K1∩∂K2

{{v}} · [[u]]T −∫

∂K1∩∂K2

[[v]]T · {{u}}. (9.85)

Page 274: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 259

Using the Stokes’ formula (9.23) and (9.85), we obtain∫

Ω

∇× (μ−1∇×E) · v

=∑

K∈Th

[∫

∂K

n× (μ−1∇×E) · v +∫

K

μ−1∇×E · ∇ × v]

=∑

f∈Fh

f

{{v}} · [[μ−1∇×E]]T −∑

f∈Fh

f

[[v]]T · {{μ−1∇×E}}

+∫

Ω

(μ−1∇×E) · (∇× v). (9.86)

For a given partition Th of Ω and approximation order l ≥ 1, we define thefollowing discontinuous finite element space

Vh = {v ∈ (L2(Ω))3, v|K ∈ (P l(K))3, ∀ K ∈ Th}, (9.87)

where P l(K) denotes the space of polynomial of total degree l on K.Now we can construct a direct interior penalty DG method for solving

(9.78)-(9.79): Find Eh ∈ Vh such that

ah(Eh, φ) − ω2((ε+ iσ

ω)Eh, φ) = (iωJs, φ), ∀ φ ∈ Vh, (9.88)

where the discrete (complex valued) sesquilinear form

ah(u,v) = (μ−1∇h × u,∇h × v) −∑

f∈Fh

f

[[u]]T · {{μ−1∇h × v}}ds

−∑

f∈Fh

f

[[v]]T · {{μ−1∇h × u}}ds+∑

f∈Fh

f

a[[u]]T · [[v]]Tds. (9.89)

Here ∇h× denotes the elementwise curl, a denotes the jumps across faces fby

a = αm−1�

−1,

where � and m are respectively defined by

�|f ={

min{hK , hK′}, f ∈ F Ih , f = ∂K ∩ ∂K ′,hK , f ∈ FBh , f = ∂K ∩ ∂Ω,

and

m|f ={

min{μK , μK′}, f ∈ F Ih , f = ∂K ∩ ∂K ′,μK , f ∈ FBh , f = ∂K ∩ ∂Ω.

Note that the sesquilinear form ah of (9.89) is obtained from (9.86) withthe facts that the exact solution E ∈ H0(curl; Ω) and μ−1∇×E ∈ H(curl; Ω),which lead to

[[μ−1∇×E]]T = 0 and [[E]]T = 0.

Page 275: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

260 Computational Partial Differential Equations Using MATLAB

The last term in ah of (9.89) is a penalty term added in order to make thesesquilinear form of (9.88) be coercive. Notice that

f∈Fh

f

[[u]]T · {{μ−1∇h × v}}ds

=∑

f∈Fh

f

a1/2[[u]]T · α−1/2m1/2�

1/2{{μ−1∇h × v}}ds

≤ α− 12 (

f∈Fh

||a 12 [[u]]T ||20,f )

12 (

f∈Fh

||m 12�

12 {{μ−1∇h × v}}||20,f)

12 ,(9.90)

and

ah(v,v) =∑

K∈Th

||μ−1/2∇× v||20,K +∑

f∈Fh

||a1/2[[v]]T ||20,f

−2∑

f∈Fh

f

[[v]]T · {{μ−1∇h × v}}ds.

Using the definition of m and � and the assumption that μ is a piecewiseconstant, we have

f∈Fh

||m1/2�

1/2{{μ−1∇h × v}}||20,f

≤∑

K∈Th

hKμK ||μ−1K ∇h × v||20,∂K =

K∈Th

hK ||μ−1/2K ∇h × v||20,∂K

≤∑

K∈Th

C2inv ||μ−1/2

K ∇h × v||20,K , (9.91)

where we used the inverse inequality

||w||0,∂K ≤ Cinvh−1/2K ||w||0,K , ∀ w ∈ (P l(K))3,

with constant Cinv depending only on the shape-regularity of the mesh andthe approximation order l.

Finally, using the definition ah of (9.89) and substituting (9.91) into (9.90),we obtain

ah(v,v) =∑

K∈Th

||μ−1/2K ∇× v||20,K +

f∈Fh

||a1/2[[v]]T ||20,f

−2∑

f∈Fh

f

[[v]]T {{μ−1∇h × v}}ds

≥ (1 − α−1/2Cinv)[∑

K∈Th

||μ−1/2∇× v||20,K +∑

f∈Fh

||a1/2[[v]]T ||20,f ],

Page 276: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 261

which leads to

ah(v,v) ≥ 12[∑

K∈Th

||μ−1/2∇× v||20,K +∑

f∈Fh

||a1/2[[v]]T ||20,f ], (9.92)

provided that α ≥ αmin = 4C2inv.

The following optimal error estimates in the energy norm have been provedin [26].

THEOREM 9.8Assume that the solution E of (9.78)-(9.79) satisfies the regularity assump-tions E,∇×E ∈ (Hs(Th))3, s > 1

2 , and let Eh be the DG solution to (9.88).Furthermore, we set V (h) = H0(curl; Ω) + Vh and its corresponding norm

||v||2V (h) = ||ε1/2v||20,Ω + ||μ−1/2∇h × v||20,Ω + ||μ−1/2�

−1/2[[v]]T ||20,Fh. (9.93)

Then for any α ≥ αmin and 0 < h ≤ h0 (i.e., mesh size is small enough), thefollowing optimal error estimate holds true

||E −Eh||V (h) ≤ Chmin(s,l)[||εE||s,Th+ ||μ−1∇×E||s,Th

], (9.94)

where we denote l ≥ 1 the polynomial approximation degree defined in thespace Vh of (9.87), and the norm ||v||s,Th

= (∑

K∈Th||v||2s,K)1/2.

9.3.3 The mixed DG method

A mixed formulation for (9.78)-(9.79) was first proposed by Demkowicz et al.[18] and later was modified by Houston et al. [27, 28] for some mixed DGmethods. To make the presentation clear, we assume that σ = 0 and denotej = iωJs in (9.78).

For any functionE ∈ H0(curl; Ω), we have the L2ε(Ω)3-orthogonal Helmholtz

decomposition [9]:

E = u+ ∇p, u ∈ H0(curl; Ω) ∩H(div0ε ; Ω), p ∈ H1

0 (Ω), (9.95)

where we let L2ε(Ω)3 denote the space of square integrable functions on Ω

equipped with the inner product (v,w)ε =∫Ωεv ·wdx, and we let

H(div0ε ; Ω) = {v ∈ L2(Ω)3 : ∇ · (εv) = 0 in Ω}.

Using the decomposition (9.95), we can reformulate the problem (9.78)-(9.79) as follows [49]: Find u ∈ H(curl; Ω) and p ∈ H1(Ω) such that

∇× (μ−1∇× u) − ω2εu− ω2ε∇p = j, in Ω, (9.96)∇ · (εu) = 0, in Ω, (9.97)n× u = 0, p = 0 on ∂Ω. (9.98)

Page 277: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

262 Computational Partial Differential Equations Using MATLAB

A mixed DG formulation was presented in [49], and optimal error estimateswere proved for smooth material coefficients by employing a duality approach.Subsequent work [27, 28] has shown that most of the stabilization terms in-troduced in [49] are unnecessary. Hence we shall present the most recent workof Houston et al. [28].

Let V = H0(curl; Ω), Q = H10 (Ω). The standard variational formulation of

(9.96)-(9.98) is [18]: Find (u, p) ∈ V ×Q such that

a(u,v) + b(v, p) =∫

Ω

j · vdx, v ∈ V, (9.99)

b(u, q) = 0, q ∈ Q, (9.100)

where the bilinear forms a and b are defined by

a(u,v) = (μ−1∇× u,∇× v) − ω2(εu,v), (9.101)b(v, p) = −ω2(εv,∇p). (9.102)

To construct a mixed DG method, we define the finite element spaces:

Vh = P l(Th)3, Qh = P l+1(Th), l ≥ 1. (9.103)

A DG mixed method for (9.96)-(9.98) can be formulated as follows: Find(uh.ph) ∈ Vh ×Qh such that

ah(uh,v) + bh(v, ph) =∫

Ω

j · vdx, v ∈ Vh, (9.104)

bh(uh, q) − ch(ph, q) = 0, q ∈ Qh, (9.105)

where we define

ah(u,v) = (μ−1∇h × u,∇h × v) −∫

Fh

[[u]]T · {{μ−1∇h × v}}ds

−∫

Fh

[[v]]T {{μ−1∇h × u}}ds+∫

Fh

a[[u]]T [[v]]Tds− ω2(εu,v),

bh(v, p) = −ω2(εv,∇hp) + ω2

Fh

{{εv}} · [[p]]Nds, (9.106)

ch(p, q) =∫

Fh

c[[p]]N · [[q]]Nds. (9.107)

Here for simplicity, we denote∫Fhφ(s)ds =

∑f∈Fh

∫f φ(s)ds.

Note that ah corresponds to the interior penalty discretization of the curl-curl operator, bh corresponds to the usual DG formulation for the divergenceoperator, and ch is the interior penalty form that enforces the continuity ofph weakly.

We can choose the interior penalty function a as we did in the last subsec-tion, i.e.,

a = αm−1�

−1.

Page 278: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 263

The penalty function c can be chosen similarly, i.e.,

c = γe(x)�−1,

where

e(x) ={

max{εK , εK′}, if x ∈ ∂K ∩ ∂K ′,εK (or εK′), if x ∈ ∂K ∩ ∂Ω (or ∂K ′ ∩ ∂Ω).

With delicate analysis, the following optimal energy-norm error estimateshave been obtained by Houston et al. [28].

THEOREM 9.9Assume that the solution (u, p) of (9.96)-(9.98) satisfies the regularity:

εu ∈ Hs(Th)3, μ−1∇× u ∈ Hs(Th)3, p ∈ Hs+1(Th), s >12.

Then for α ≥ αmin and γ > 0, the mixed DG solution (uh, ph) of (9.104)-(9.105) satisfies the following optimal error estimates

|||(u−uh, p− ph)|||DG ≤ Chmin(s,l)[||εu||s,Th+ ||μ−1∇×u||s,Th

+ ||p||s+1,Th],

where the positive constant C is independent of the mesh size h. Here wedenote the DG-norm

|||(v, q)|||DG = (||v||2V (h) + ||q||2Q(h))1/2, V (h) = V + Vh, Q(h) = Q+Qh,

where

||v||2V (h) = ||μ−1/2∇h × v||20,Ω + ||m−1/2�

−1/2[[v]]T ||20,Fh+ ω2||ε1/2v||20,Ω,

||q||2Q(h) = ω2||ε1/2∇hq||20.Ω + ||e1/2�

−1/2[[q]]N ||20,Fh.

9.4 The Maxwell’s equations in dispersive media

In previous sections, we discussed the Maxwell’s equations in a simple mediumsuch as air in the free space. While in real life, the properties of most elec-tromagnetic materials are wavelength dependent. Such materials are gen-erally called dispersive media, and examples include human tissue, water,soil, snow, ice, plasma, optical fibers, and radar-absorbing materials. Someconcrete applications of wave interactions with dispersive media include geo-physical probing and subsurface studies of the moon and other planets; highpower and ultra-wide-band (UWB) radar systems, in which it is necessary tomodel UWB electromagnetic pulse propagation through plasmas (i.e., the

Page 279: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

264 Computational Partial Differential Equations Using MATLAB

ionosphere); ground penetrating radar (GPR) detection of buried objects(such as buried waste drums, metallic or dielectric pipes, pollution plumes) insoil media; and electromagnetic wave interactions with biological and water-based substances.

In early 1990, researchers started modeling of wave propagation in disper-sive media. But most work is exclusively restricted to the finite-differencetime-domain (FDTD) method due to its much simpler implementation com-pared to the finite element methods. In 2001, Jiao and Jin [30] initiated theapplication of the time-domain finite element method (TDFEM) for dispersivemedia. Readers can find some early work on modeling of dispersive media inbook chapters ([32, Ch. 8], [53, Ch. 9], and [31, Ch. 11]). In this section, wewill introduce some finite element methods for solving Maxwell’s equations indispersive media based on our recent work in this area [35, 36, 37, 38, 39].

9.4.1 Isotropic cold plasma

Electromagnetic wave propagation in isotropic nonmagnetized cold electronplasma is governed by the following equations:

ε0∂E

∂t= ∇×H − J (9.108)

μ0∂H

∂t= −∇×E (9.109)

∂J

∂t+ νJ = ε0ω

2pE (9.110)

where E is the electric field, H is the magnetic field, ε0 is the permittivity offree space, μ0 is the permeability of free space, J is the polarization currentdensity, ωp is the plasma frequency, ν ≥ 0 is the electron-neutral collision fre-quency. Solving (9.110) with the assumption that the initial electron velocityis zero, we obtain

J(E) ≡ J(x, t;E)

= ε0ω2pe

−νt∫ t

0

eνsE(x, s)ds = ε0ω2p

∫ t

0

e−ν(t−s)E(x, s)ds.(9.111)

Substituting (9.111) into (9.108), we obtain the following system of equa-tions depending only on E and H:

ε0Et −∇×H + J(E) = 0 in Ω × (0, T ), (9.112)μ0Ht + ∇×E = 0 in Ω × (0, T ), (9.113)

where J(E) is defined by (9.111).To complete the problem, we assume a perfect conducting boundary con-

dition ofn×E = 0 on ∂Ω × (0, T ), (9.114)

Page 280: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 265

and the simple initial conditions

E(x, 0) = E0(x) and H(x, 0) =H0(x) x ∈ Ω, (9.115)

where E0 and H0 are some given functions and H0 satisfies

∇ · (μ0H0) = 0 in Ω, H0 · n = 0 on ∂Ω. (9.116)

We can solve the problem (9.112)-(9.115) by a mixed finite element method.Multiplying (9.112) by a test function φ and integrating over domain Ω, andthen multiplying (9.113) by test function ψ and integrating over domain Ω, weobtain the weak formulation: Find the solution (E,H) ∈ C1(0, T ; (L2(Ω))3)×C1(0, T ;H(curl; Ω)) of (9.112)-(9.113) such that

ε0(Et,φ) − (∇×H,φ) + (J(E),φ) = 0 ∀ φ ∈ (L2(Ω))3, (9.117)μ0(Ht,ψ) + (E,∇×ψ) = 0 ∀ ψ ∈ H(curl; Ω) (9.118)

for 0 < t ≤ T with the initial conditions

E(0) = E0 and H(0) = H0. (9.119)

Note that the boundary condition (9.114) is imposed weakly in (9.118).For simplicity, we assume that Ω is a bounded and convex Lipschitz polyhe-

dral domain in R3. Furthermore, we assume that Ω is discretized by a regularfinite element mesh Th, of tetrahedra of maximum diameter h.

We shall use the same mixed finite element spaces (9.26)-(9.28) developedpreviously for the simple medium, i.e., we can define

Uh = {uh ∈ (L2(Ω))3 : uh|K ∈ (Pk−1)3 ∀ K ∈ Th},Vh = {vh ∈ H(curl; Ω) : vh|K ∈ Rk ∀ K ∈ Th}.

To construct a fully discrete scheme for (9.117)-(9.119), we divide the timeinterval (0, T ) into M uniform subintervals by points 0 = t0 < t1 < · · · <tM = T, where tk = kτ, and denote the k-th subinterval by Ik = (tk−1, tk].Moreover, we define uk = u(·, kτ) for 0 ≤ k ≤ M, and denote the first-orderbackward finite difference:

∂τuk = (uk − uk−1)/τ.

Now we can formulate our fully discrete mixed finite element scheme for(9.117)-(9.119) as follows: for k = 1, 2, · · · ,M, find Ek

h ∈ Uh,Hkh ∈ Vh such

that

ε0(∂τEkh,φh) − (∇×Hk

h,φh) + (Jkh,φh) = 0 ∀ φh ∈ Uh, (9.120)μ0(∂τHk

h,ψh) + (Ekh,∇×ψh) = 0 ∀ ψh ∈ Vh (9.121)

for 0 < t ≤ T, subject to the initial conditions

Eh(0) = PhE0 and Hh(0) = ΠhH0. (9.122)

Page 281: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

266 Computational Partial Differential Equations Using MATLAB

Here Ph is the standard (L2(Ω))3 projection operator Ph onto Uh, and Πh

is the Nedelec interpolation operator. Furthermore, Jkh is defined by therecursive formula:

J0h = 0, Jkh = e−ντ (Jk−1

h + ε0ω2pτE

k−1h ), k ≥ 1. (9.123)

We can estimate the difference between Jk and Jkh by the following

LEMMA 9.3Let Jk ≡ J(E(·, tk)) defined by (9.111), Jkh defined by (9.123). Then for

any 1 ≤ n ≤M, we have

|Jnh − Jn| ≤ ε0ω2pτ

n−1∑

k=0

|Ekh −Ek| + ε0ω

2pτ

∫ tn

0

|νE(t) +Et(t)|dt.

Proof. ∗ By definition (9.111), we have

Jk ≡ J(E(·, tk)) = ε0ω2pe

−νtk∫ tk

0

eνsE(x, s)ds

= ε0ω2pe

−νtk [∫ tk−1

0

eνsE(x, s)ds+∫ tk

tk−1eνsE(x, s)ds]

= e−ντJk−1 + ε0ω2pe

−νtk∫

Ik

eνsE(x, s)ds. (9.124)

Subtracting (9.124) from (9.123), we obtain

Jkh − Jk

= e−ντ (Jk−1h − Jk−1) + ε0ω

2p[τe

−ντEk−1h −

Ik

e−ν(tk−s)E(x, s)ds]

= e−ντ (Jk−1h − Jk−1) + ε0ω

2p[τe

−ντ (Ek−1h −Ek−1)

+e−νtk

Ik

(eνtk−1Ek−1 − eνsE(s))ds]

=3∑

i=1

Ri. (9.125)

It is easy to see that

R1 ≤ |Jk−1h − Jk−1|,

R2 = ε0ω2pτe

−ντ (Ek−1h −Ek−1) ≤ ε0ω

2pτ |Ek−1

h −Ek−1|.

∗Reprinted from Lemma 2.3 of Computer Methods in Applied Mechanics and Engineering,Vol. 196, Jichun Li, Error analysis of fully discrete mixed finite element schemes for 3-DMaxwell’s equations in dispersive media, p. 3081–3094. Copyright(2007), with permissionfrom Elsevier.

Page 282: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 267

Using the following identity∫

Ik

|f(tk−1) − f(t)|dt =∫

Ik

|∫ t

tk−1fs(s)ds|dt

≤∫

Ik

(∫

Ik

|fs(s)|ds)dt = τ

Ik

|ft(t)|dt (9.126)

with f(t) = eνtE(x, t), we obtain

R3 ≤ ε0ω2pe

−νtkτ∫

Ik

|(eνtE(x, t))t|dt

= ε0ω2pτ

Ik

e−ν(tk−t)|νE(t) +Et(t)|dt

≤ ε0ω2pτ

Ik

|νE(t) +Et(t)|dt.

Combining the above estimates, we have

|Jkh − Jk| ≤ |Jk−1h − Jk−1| + ε0ω

2pτ [|Ek−1

h −Ek−1| +∫

Ik

|νE(t) +Et(t)|dt].

Summing both sides over k = 1, 2, · · · , n, and using the fact J0h = J0 = 0

lead to

|Jnh − Jn| ≤ ε0ω2pτ

n∑

k=1

[|Ek−1h −Ek−1| +

Ik

|νE(t) +Et(t)|dt]

= ε0ω2pτ

n−1∑

k=0

|Ekh −Ek| + ε0ω

2pτ

∫ tn

0

|νE(t) +Et(t)|dt,

which concludes our proof.The following optimal error estimates have been obtained in [36].

THEOREM 9.10Let (En,Hn) and (En

h,Hnh) be the solutions of (9.117)-(9.119) and (9.120)-

(9.123) at time t = tn, respectively. Assume that

E(t),Et(t),Ht(t) ∈ (H l(Ω))3,∇×Et(t),∇×Ht(t) ∈ (L2(Ω))3,H(t),∇×H(t) ∈ (H l+1(Ω))3,

for all 0 ≤ t ≤ T. Then there is a constant C = C(T, ε0, μ0, ωp, ν,E,H),independent of both the time step τ and the finite element mesh size h, suchthat

max1≤n≤M

(||En −Enh||0 + ||Hn −Hn

h||0) ≤ C(τ + hl), (9.127)

where 1 ≤ l ≤ k, and k is the degree of basis functions in Uh and Vh.

Page 283: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

268 Computational Partial Differential Equations Using MATLAB

REMARK 9.1 If the solutions are not smooth enough, we can obtainthe following estimate

max1≤n≤M

(||En −Enh||0 + ||Hn −Hn

h||0) ≤ C(τ + hα),12< α ≤ 1, (9.128)

for the lowest order Nedelec’s element (i.e., k = 1 in our definitions of Uh andVh) under the reasonable regularity assumptions [3, 12]: for any t ∈ [0, T ]and 1

2 < α ≤ 1,

E(t),Et(t) ∈ (Hα(Ω))3, H(t),Ht(t) ∈ (Hα(curl; Ω))3,E(t),Et(t),∇×Et(t),∇×Ht(t) ∈ (L2(Ω))3.

Finally, the same error estimates (9.127) hold true for Nedelec H(curl)conforming cubic elements [46] defined by

Uh|K = (u1, u2, u3) ∈ Qk−1,k,k ×Qk,k−1,k ×Qk,k,k−1, k ≥ 1,V h|K = (v1, v2, v3) ∈ (Qk−1,k−1,k−1)3, k ≥ 1.

9.4.2 Debye medium

For the single-pole model of Debye, the governing equations are [36]:

ε0ε∞∂E

∂t= ∇×H − 1

t0[(εs − ε∞)ε0E − P] (9.129)

μ0∂H

∂t= −∇×E (9.130)

∂P∂t

+1t0

P =(εs − ε∞)ε0

t0E (9.131)

where P is the polarization vector, ε∞ is the permittivity at infinite frequency,εs is the permittivity at zero frequency, t0 is the relaxation time, and the resthave the same meaning as those stated previously for plasma.

We introduce the polarization current

J(x, t) ≡ 1t0

[(εs − ε∞)ε0E − P],

from which and solving (9.131) for P with initial condition P = 0, we obtain

J(x, t) =(εs − ε∞)ε0

t0E(x, t) − (εs − ε∞)ε0

t20

∫ t

0

e−(t−s)/t0E(x, s)ds.

Introducing the pseudo polarization current

J(E) ≡ J(x, t;E) =(εs − ε∞)ε0

t20

∫ t

0

e−(t−s)

t0 E(x, s)ds, (9.132)

Page 284: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 269

we can rewrite the governing equations for a Debye medium: Find E and H,which satisfy

ε0ε∞Et −∇×H +(εs − ε∞)ε0

t0E − J(E) = 0 in Ω × (0, T ),(9.133)

μ0Ht + ∇×E = 0 in Ω × (0, T ), (9.134)

and the same boundary and initial conditions as those stated previously forplasma.

From (9.133)-(9.134), we can easily obtain the weak formulation: For anyφ ∈ (L2(Ω))3 and ψ ∈ H(curl; Ω), find the solution(E,H) ∈ C1(0, T ; (L2(Ω))3) × C1(0, T ;H(curl; Ω)) such that

ε0ε∞(Et,φ) − (∇×H,φ) +(εs − ε∞)ε0

t0(E,φ)

−(J(E),φ) = 0, (9.135)μ0(Ht,ψ) + (E,∇×ψ) = 0 (9.136)

for 0 < t ≤ T with the initial conditions

E(0) = E0 and H(0) = H0. (9.137)

Using the same mixed finite element spaces and notation as those introducedfor plasma, we can formulate the fully discrete mixed finite element schemefor our Debye model as follows: for k = 1, 2, · · · ,M, find Ek

h ∈ Uh,Hkh ∈ Vh

such that

ε0ε∞(∂τEkh,φh) − (∇×Hk

h,φh) +(εs − ε∞)ε0

t0(Ek

h,φh)

−(Jk

h,φh) = 0 ∀ φh ∈ Uh, (9.138)μ0(∂τHk

h,ψh) + (Ekh,∇×ψh) = 0 ∀ ψh ∈ Vh (9.139)

for 0 < t ≤ T, subject to the initial conditions

Eh(0) = PhE0 and Hh(0) = ΠhH0. (9.140)

Here Jk

h is defined by the recursive formula

J0

h = 0, Jk

h = e−τt0 (J

k−1

h +(εs − ε∞)ε0

t20τEk−1

h ), k ≥ 1. (9.141)

Note that τ denotes the time step size as in the earlier section for plasma. Theexistence and uniqueness of the solution for the linear system (9.138)-(9.141)is assured with the same arguments as discussed for plasma.

First, we have the following estimate for the difference between Jn

h and Jn

[36].

Page 285: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

270 Computational Partial Differential Equations Using MATLAB

LEMMA 9.4Let J

k ≡ J(E(·, tk)) be defined by (9.132), Jk

h defined by (9.141). Then forany 1 ≤ n ≤M, we have

|Jnh − Jn| ≤ (εs − ε∞)ε0t20

τ [n−1∑

k=0

|Ekh −Ek| +

∫ tn

0

| 1t0E(t) +Et(t)|dt].

For a Debye medium, the following optimal error estimates have beenproved in [36].

THEOREM 9.11Let (En,Hn) and (En

h,Hnh) be the solutions of (9.135)-(9.137) and (9.138)-

(9.141) at time t = tn, respectively. Assume that

E(t),Et(t),Ht(t) ∈ (H l(Ω))3,∇×Et(t),∇×Ht(t) ∈ (L2(Ω))3,H(t),∇×H(t) ∈ (H l+1(Ω))3,

for all 0 ≤ t ≤ T. Then there is a constant C = C(T, ε0, εs, ε∞, t0, μ0,E,H),independent of both the time step τ and the finite element mesh size h, suchthat

max1≤n≤M

(||En −Enh||0 + ||Hn −Hn

h ||0) ≤ C(τ + hl),

where 1 ≤ l ≤ k, and k is the degree of basis functions in Uh and Vh.

Finally, we like to mention that a unified DG method has been developedfor Maxwell’s equations in linear dispersive media in [40]. More specifically,in [40], the 2-D Maxwell’s equations in the coupled media with a single-poleDebye medium and the perfectly matched layer are written in conservationform and nodal basis functions are used in the DG method. But no erroranalysis is provided there.

9.4.3 Lorentz medium

The Lorentzian two-pole model is described by the following equations [36]:

ε0ε∞∂E

∂t= ∇×H − J , (9.142)

μ0∂H

∂t= −∇×E (9.143)

∂J

∂t= −νJ + (εs − ε∞)ε0ω2

1E − ω21P, (9.144)

∂P∂t

= J (9.145)

where, in addition to the notation defined earlier, ω1 is the resonant frequency,ν is the damping coefficient, P is the polarization vector, and J is the polar-ization current.

Page 286: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 271

Differentiating both sides of (9.144) with respect to t and using (9.145), weobtain

d2J

dt2+ ν

dJ

dt+ ω2

1J = (εs − ε∞)ε0ω21

dE

dt. (9.146)

Solving (9.146) with the fact that E(x, 0) = 0, we have

J(x, t) =(εs − ε∞)ε0ω3

1

α

∫ t

0

E(x, s) · e−δ(t−s) · sin(γ − α(t− s))ds, (9.147)

where we introduced the notation

cos γ = δ/ω1, sin γ = α/ω1, α =√ω2

1 − ν2/4.

Here we assume that ν/2 < ω1, which is the interesting case in real applica-tions.

Substituting (9.147) into (9.142), we obtain the governing equations for Eand H only:

ε0ε∞Et −∇×H + J(E) = 0 in Ω × (0, T ), (9.148)μ0Ht + ∇×E = 0 in Ω × (0, T ), (9.149)

with the same boundary and initial conditions as those stated for plasma. Forclarity, we use J to represent the polarization current J for a Lorentz mediumand rewrite (9.147) as

J(E) = β

∫ t

0

e−δ(t−s) · sin(γ − α(t− s)) ·E(x, s)ds, (9.150)

= Im(βejγ∫ t

0

e−(δ+jα)(t−s)E(x, s)ds) ≡ Im(J(E)), (9.151)

where j =√−1, β = (εs − ε∞)ε0ω3

1/√ω2

1 − ν2

4 , and Im(A) means the imagi-nary part of the complex number A.

From (9.148)-(9.149), we can easily obtain the weak formulation: find thesolution(E,H) ∈ C1(0, T ; (L2(Ω))3) × C1(0, T ;H(curl; Ω)) such that

ε0ε∞(Et,φ) − (∇×H ,φ) + (J(E),φ) = 0 ∀ φ ∈ (L2(Ω))3,(9.152)μ0(Ht,ψ) + (E,∇×ψ) = 0 ∀ ψ ∈ H(curl; Ω) (9.153)

for 0 < t ≤ T with the initial conditions

E(0) = E0 and H(0) = H0. (9.154)

Using the same mixed finite element spaces and notation as those introducedfor plasma, we can formulate our fully discrete mixed finite element scheme

Page 287: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

272 Computational Partial Differential Equations Using MATLAB

for a Lorentz medium as follows: for k = 1, 2, · · · ,M, find Ekh ∈ Uh,H

kh ∈ Vh

such that

ε0ε∞(∂τEkh,φh) − (∇×Hk

h,φh) + (Jk

h,φh) = 0 ∀ φh ∈ Uh,(9.155)μ0(∂τHk

h,ψh) + (Ekh,∇×ψh) = 0 ∀ ψh ∈ Vh (9.156)

for 0 < t ≤ T, subject to the initial conditions

Eh(0) = PhE0 and Hh(0) = ΠhH0. (9.157)

Here we denoteJk

h ≡ Im(Jk

h), (9.158)

where Jk

h satisfies the following recursive identities:

J0

h = 0, Jk

h = e−(δ+jα)τ (Jk−1

h + βejγτEk−1h ), j =

√−1, k ≥ 1. (9.159)

Following the same notation used for plasma, τ still denotes the time step size.The existence and uniqueness of the solution for the linear system (9.155)-(9.158) is assured with the same arguments as discussed earlier for plasma.

To carry out the error analysis for a Lorentz medium, we can prove thefollowing lemma [36].

LEMMA 9.5Let J

k ≡ J(E(·, tk)) defined by (9.150), Jk

h defined by (9.158). Then forany 1 ≤ n ≤M, we have

|Jnh − Jn| ≤ βτ [n−1∑

k=0

|Ekh −Ek| +

∫ tn

0

(ω1|E(t)| + |Et(t)|)dt].

For a Lorentz medium, we proved the following optimal error estimates in[36].

THEOREM 9.12Let (En,Hn) and (En

h,Hnh) be the solutions of (9.148)-(9.149) and (9.155)-

(9.158) at time t = tn, respectively. Assume that

E(t),Et(t),Ht(t) ∈ (H l(Ω))3,∇×Et(t),∇×Ht(t) ∈ (L2(Ω))3,H(t),∇×H(t) ∈ (H l+1(Ω))3,

for all 0 ≤ t ≤ T. Then there is a constant C = C(T, ε0, εs, ε∞, ν, μ0, ω1,E,H),independent of both the time step τ and the finite element mesh size h, suchthat

max1≤n≤M

(||En −Enh||0 + ||Hn −Hn

h ||0) ≤ C(τ + hl),

where 1 ≤ l ≤ k, and k is the degree of basis functions in Uh and Vh.

Page 288: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 273

9.4.4 Double-negative metamaterials

In 1968, Veselago postulated the existence of electromagnetic material inwhich both permittivity and permeability were negative real values. Until2000, such materials were realized in practice by arranging periodic arraysof small metallic wires and split-ring resonators [50, 52]. These artificiallystructured periodic media (often termed as metamaterials) have very unusualelectromagnetic properties and open great potential applications in diverse ar-eas such as interconnects for wireless telecommunications, radar and defense,nanolithography with light, medical imaging with super-resolution, and so on[19].

Here we will focus on the modeling of double-negative (DNG) metamate-rials, in which both permittivity and permeability are negative. Note thatDNG materials are also referred to as left-hand (LH) media, negative-indexmaterials (NIM), and backward-wave media (BW). Furthermore, DNG meta-materials are dispersive and are often described by lossy Drude polarizationand magnetization models.

The governing equations for modeling the wave propagation in a DNGmedium are given by:

ε0∂E

∂t= ∇×H − J , (9.160)

μ0∂H

∂t= −∇×E −K, (9.161)

∂J

∂t+ ΓeJ = ε0ω

2peE, (9.162)

∂K

∂t+ ΓmK = μ0ω

2pmH, (9.163)

where J and K are the induced electric and magnetic currents, respectively.Furthermore, ωpe and ωpm are the electric and magnetic plasma frequencies,and Γe and Γm are the electric and magnetic damping frequencies.

Solving (9.162) and (9.163) with initial electric and magnetic currents J0(x)and K0(x) respectively, we obtain

J(x, t;E) = J0(x) + ε0ω2pe

∫ t

0

e−Γe(t−s)E(x, s)ds

≡ J0(x) + J(E), (9.164)

K(x, t;H) = K0(x) + μ0ω2pm

∫ t

0

e−Γm(t−s)H(x, s)ds

≡ K0(x) +K(H). (9.165)

In summary, the model equations for wave propagation in a DNG mediumbecome: find (E,H) such that

ε0Et −∇×H + J(E) = −J0(x) in Ω × (0, T ), (9.166)μ0Ht + ∇×E +K(H) = −K0(x) in Ω × (0, T ). (9.167)

Page 289: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

274 Computational Partial Differential Equations Using MATLAB

subject to the same boundary and initial conditions as those stated earlier forplasma.

Multiplying (9.166) by a test function φ ∈ (L2(Ω))3, Eq. (9.167) by ψ ∈H(curl; Ω), and integrating over Ω, we can obtain the weak formulation for(9.164)-(9.165): For any φ ∈ (L2(Ω))3 and ψ ∈ H(curl; Ω), find(E,H) ∈ [C1(0, T ; (L2(Ω))3) ∩ C0(0, T ;H(curl; Ω))]2 of (9.166)-(9.167) suchthat

ε0(Et,φ) − (∇×H,φ) + (J(E),φ) = (−J0,φ), (9.168)μ0(Ht,ψ) + (E,∇×ψ) + (K(H),ψ) = (−K0,ψ). (9.169)

A fully discrete mixed finite element scheme for (9.166)-(9.167) can be for-mulated as follows: For k = 1, 2, · · · ,M, and any φh ∈ Uh,ψh ∈ Vh, findEkh ∈ Uh,H

kh ∈ Vh such that

ε0(∂τEkh,φh) − (∇×Hk

h,φh) + (Jk−1h ,φh) = (−J0,φh), (9.170)

μ0(∂τHkh,ψh) + (Ek

h,∇×ψh) + (Kk−1h ,ψh) = (−K0,ψh) (9.171)

for 0 < t ≤ T, subject to the initial conditions

Eh(0) = PhE0 and Hh(0) = ΠhH0. (9.172)

Here the spaces Uh and Vh, and the operators Ph and Πh have the samemeaning as we defined for plasma. Furthermore, Jkh and Kk

h are recursivelydefined as

J0h = 0, Jkh = e−ΓeτJk−1

h + ε0ω2peτE

kh, k ≥ 1, (9.173)

K0h = 0, Kk

h = e−ΓmτKk−1h + μ0ω

2pmτH

kh, k ≥ 1. (9.174)

Note that (9.173) is a little different from (9.123). Using the same techniqueas Lemmas 9.3, we can still prove the following lemma [35].

LEMMA 9.6Let Jk ≡ J(E(·, tk)) and Kk ≡K(H(·, tk)) defined by (9.164) and (9.165),Jkh and Kk

h defined by (9.173) and (9.174), respectively. Then for any 1 ≤n ≤M, we have

(i) |Jnh − Jn| ≤ ε0ω2peτ

n∑

k=1

|Ekh −Ek| + ε0ω

2peτ

∫ tn

0

|ΓeE(t) +Et(t)|dt,

(ii) |Knh −Kn| ≤ ε0ω

2pmτ

n∑

k=1

|Hkh −Hk| + ε0ω

2pmτ

∫ tn

0

|ΓmH(t) +Ht(t)|dt.

To prove our main result, we need another lemma [35] below.

Page 290: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 275

LEMMA 9.7Let B = H1(curl; Ω) or B = (Hα(Ω))3 with α ≥ 0. For any u ∈ H1(0, T ;B),we have the following estimates

(i) ‖∂τuk‖2B ≤ 1

τ

∫ tk

tk−1‖ut(t)‖2

Bdt, (9.175)

(ii) ‖uk − 1τ

Ik

u(t)dt‖2B ≤ τ

Ik

‖ut(t)‖2Bdt, (9.176)

(iii) ‖uk−1 − 1τ

Ik

u(t)dt‖2B ≤ τ

Ik

‖ut(t)‖2Bdt. (9.177)

Furthermore, we have the optimal error estimate

THEOREM 9.13Let (En,Hn) and (En

h,Hnh) be the solutions of (9.168)-(9.169) and (9.170)-

(9.174) at time t = tn, respectively. Assume that

E(t),Et(t),Ht(t) ∈ (H l(Ω))3,∇×Et(t),∇×Ht(t) ∈ (L2(Ω))3,H(t),∇×H(t) ∈ (H l+1(Ω))3,

for all 0 ≤ t ≤ T. Then there is a positive constant

C = C(T, ε0, μ0, ωpe, ωpm,Γe,Γm,E,H),

independent of both the time step τ and the finite element mesh size h, suchthat

max1≤n≤M

(||En −Enh||0 + ||Hn −Hn

h ||0) ≤ C(τ + hl),

where 1 ≤ l ≤ k, and k is the degree of basis functions in Uh and Vh.

Proof. † Integrating the weak formulation (9.168)-(9.169) in time over Ikand choosing φ = 1

τφh,ψ = 1τψh leads to

ε0τ

(Ek −Ek−1,φh) − (∇× 1

τ

ZIk

H(s)ds,φh) + (1

τ

ZIk

J(E(s))ds,φh) = 0,

μ0

τ(Hk −Hk−1,ψh) + (

1

τ

ZIk

E(s)ds,∇× ψh) + (1

τ

ZIk

K(H(s))ds,ψh) = 0,

for any φh ∈ Uh and ψh ∈ Vh. Then from each subtracting, (9.170) and(9.171), respectively, we obtain the error equations

ε0(∂τ (Ek −Ekh),φh) − (∇× (

Ik

H(s)ds−Hkh),φh)

†Reprinted from Sec. 4.2 of Journal of Computational and Applied Mathematics, Vol. 209,Jichun Li, Error analysis of mixed finite element methods for wave propagation in doublenegative metamaterials, p. 81–96. Copyright (2006), with permission from Elsevier.

Page 291: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

276 Computational Partial Differential Equations Using MATLAB

+(1τ

Ik

J(E(s))ds− Jk−1h ,φh) = 0 ∀ φh ∈ Uh, (9.178)

μ0(∂τ (Hk −Hkh),ψh) + (

Ik

E(s)ds−Ekh,∇×ψh)

+(1τ

Ik

K(H(s))ds −Kk−1h ,ψh) = 0 ∀ ψh ∈ Vh. (9.179)

Denote ξkh = PhEk −Ek

h, ηkh = ΠhH

k −Hkh. Then choosing φh = ξkh,ψh =

ηkh in (9.178)-(9.179), the above error equations can be rewritten as

ε0(∂τ ξkh, ξkh) − (∇× ηkh, ξ

kh)

= ε0(∂τ (PhEk −Ek), ξkh) − (∇× (ΠhHk − 1

τ

Ik

H(s)ds), ξkh)

+(Jk−1h − Jk−1, ξkh) + (Jk−1 − 1

τ

Ik

J(E(s))ds, ξkh),

μ0(∂τηkh, ηkh) + (ξkh ,∇× ηkh)

= μ0(∂τ (ΠhHk −Hk), ηkh) + (PhEk − 1

τ

Ik

E(s)ds,∇× ηkh)

+(Kk−1h −Kk−1, ηkh) + (Kk−1 − 1

τ

Ik

K(H(s))ds, ηkh).

Adding the above two equations together, then multiplying both sides ofthe resultant by τ , and using the inequality

a(a− b) ≥ 12(a2 − b2),

we obtainε02

(||ξkh ||20 − ||ξk−1h ||20) +

μ0

2(||ηkh||20 − ||ηk−1

h ||20)≤ ε0τ(∂τ (PhEk −Ek), ξkh) − τ(∇× (ΠhH

k −Hk), ξkh)

−τ(∇× (Hk − 1τ

Ik

H(s)ds), ξkh) + τ(Jk−1h − Jk−1, ξkh)

+τ(Jk−1 − 1τ

Ik

J(E(s))ds, ξkh) + μ0τ(∂τ (ΠhHk −Hk), ηkh)

+τ(PhEk −Ek,∇× ηkh) + τ(Ek − 1τ

Ik

E(s)ds,∇× ηkh)

+τ(Kk−1h −Kk−1, ηkh) + τ(Kk−1 − 1

τ

Ik

K(H(s))ds, ηkh)

=10∑

i=1

(I)i. (9.180)

In the rest we shall estimate (I)i one by one for i = 1, 2, · · · , 10.

Page 292: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 277

Using the Cauchy-Schwarz inequality, Lemma 9.7 and the projection errorestimate, we have

(I)1 ≤ 12ε0τ ||ξkh||20 +

12ε0τ ||∂τ (PhEk −Ek)||20

≤ 12ε0τ ||ξkh||20 +

12ε0

Ik

||(PhE −E)t(t)||20dt

≤ 12ε0τ ||ξkh||20 + Cε0h

2l

Ik

||Et(t)||2l dt.

Similarly, with the interpolation error estimate, we can easily obtain

(I)2 ≤ 12τ ||ξkh ||20 +

12τ ||∇ × (ΠhH

k −Hk)||20≤ 1

2τ ||ξkh ||20 + Cτh2l||∇ ×Hk||2l+1.

By the Cauchy-Schwarz inequality and Lemma 9.7, we have

(I)3 ≤ 12τ ||ξkh ||20 +

12τ ||∇ × (Hk − 1

τ

Ik

H(s)ds)||20

=12τ ||ξkh ||20 +

12τ ||(∇×H)k − 1

τ

Ik

∇×H(s)ds||20

≤ 12τ ||ξkh ||20 +

12τ2

Ik

||∇ ×Ht(t)||20dt.

Using the Cauchy-Schwarz inequality and Lemma 9.6, we have

(I)4 ≤ 12τ ||ξkh ||20 +

12τ ||Jk−1

h − Jk−1||20

≤ 12τ ||ξkh ||20 + Cτ3||

k−1∑

j=1

|Ejh −Ej | +

∫ tk−1

0

|ΓeE(t) +Et(t)|dt||20.

Using the Cauchy-Schwarz inequality and inequalities

|a+ b|2 ≤ 2(a2 + b2), |k∑

j=1

ajbj |2 ≤ (k∑

j=1

|aj |2)(k∑

j=1

|bj |2),

we can obtain

τ3|k−1∑

j=1

|Ejh −Ej | +

∫ tk−1

0

|ΓeE(t) +Et(t)|dt|2

≤ 2τ3[(k−1∑

j=1

12)(k−1∑

j=1

|Ejh −Ej |2) + (

∫ tk−1

0

12dt)(∫ tk−1

0

|ΓeE(t) +Et(t)|2dt]

Page 293: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

278 Computational Partial Differential Equations Using MATLAB

≤ 2τ3[(k − 1)k−1∑

j=1

|Ejh −Ej |2 + T

∫ T

0

|ΓeE(t) +Et(t)|2dt]

≤ Cτ2[k−1∑

j=1

(|ξjh|2 + |PhEj −Ej |2) + τ

∫ T

0

|ΓeE(t) +Et(t)|2dt],

where in the last step we used the triangle inequality, the fact that kτ ≤ T,and absorbed the dependence of T into the generic constant C.

Hence, integrating the above inequality in Ω gives

τ3||k−1∑

j=1

|Ejh −Ej | +

∫ tk−1

0

|ΓeE(t) +Et(t)|dt||20

≤ Cτ2[k−1∑

j=1

(||ξjh||20 + h2l||Ej ||2l ) + τ

∫ T

0

||ΓeE(t) +Et(t)||20dt]

≤ Cτ2k−1∑

j=1

||ξjh||20 + Cτh2lmax0≤t≤T ||E(t)||2l + Cτ3

∫ T

0

||ΓeE(t) +Et(t)||20dt,

where we used the fact that kτ ≤ T for any 1 ≤ k ≤M.Therefore, we have

(I)4 ≤ 12τ ||ξkh||20 + Cτ2

k−1∑

j=1

||ξjh||20 + Cτh2lmax0≤t≤T ||E(t)||2l

+Cτ3

∫ T

0

||ΓeE(t) +Et(t)||20dt.

Using the Cauchy-Schwarz inequality and Lemma 9.7, we have

(I)5 ≤ 12τ ||ξkh ||20 +

12τ ||Jk−1 − 1

τ

Ik

J(E(s))ds||20

≤ 12τ ||ξkh ||20 +

12τ2

Ik

||J t(E(t))||20dt

From the definition of J , we have

J t(E) = −ΓeJ + ε0ω2peE = −Γeε0ω2

pe

∫ t

0

e−Γe(t−s)E(s)ds+ ε0ω2peE,

integrating which in Ω and using the Cauchy-Schwarz inequality, we can ob-tain

||J t(E(t))||20 ≤ C||∫ t

0

e−Γe(t−s)E(s)ds||20 + C||E(t)||20

≤ C(∫

Ω

∫ t

0

|e−Γe(t−s)|2dsdΩ)(∫ t

0

||E(s)||20ds) + C||E(t)||20

≤ C(∫ T

0

||E(s)||20ds+ ||E(t)||20),

Page 294: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 279

where we have absorbed the dependence of Γe, ε0, ωpe and T into the genericconstant C.

Hence, we have

(I)5 ≤ 12τ ||ξkh ||20 + Cτ3(

∫ T

0

||E(s)||20ds+ ||E(t)||20).

Similarly, using Lemma 9.7, we obtain

(I)6 ≤ 12μ0τ ||ηkh||20 +

12μ0τ ||∂τ (ΠhH

k −Hk)||20

≤ 12μ0τ ||ηkh||20 +

12μ0

Ik

||(ΠhH −H)t(t)||20dt

≤ 12μ0τ ||ηkh||20 + Ch2l

Ik

||Ht(t)||2l dt.

Using the fact ∇× ηkh ⊂ Ukh, and the definition of Ph, we have

(I)7 = τ(PhEk −Ek,∇× ηkh) = 0.

Using the perfect conducting boundary condition and integration by parts,we have

(I)8 = τ(∇× (Ek − 1τ

Ik

E(s)ds), ηkh)

≤ 12τ ||ηkh||20 +

12τ ||(∇×E)k − 1

τ

Ik

(∇×E)(s)ds||20

≤ 12τ ||ηkh||20 +

12τ2

Ik

||∇ ×Et(t)||20dt.

The estimates of (I)9 and (I)10 can be carried out with the same proceduresas that of (I)4 and (I)5, i.e., we shall have

(I)9 ≤ 12τ ||ηkh||20 + Cτ2

k−1∑

j=1

||ηjh||20 + Cτh2lmax0≤t≤T ||H(t)||2l

+Cτ3

∫ T

0

||ΓmH(t) +Ht(t)||20dt,

(I)10 ≤ 12τ ||ηkh||20 + Cτ3(

∫ T

0

||H(s)||20ds+ ||H(t)||20).

Summing both sides of (9.180) over k = 1, 2, · · · , n, using the estimatesobtained above for (I)i, 1 ≤ i ≤ 10, and the fact

∑nk=1

∫Ik adt =

∫ tn0 adt ≤∫ T

0 |a|dt, we obtain

ε02||ξnh ||20 +

μ0

2||ηnh ||20

Page 295: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

280 Computational Partial Differential Equations Using MATLAB

≤ ε02||ξ0h||20 +

μ0

2||η0h||20 + C1τ

n∑

k=1

(||ξkh ||20 + ||ηkh||20)

+Ch2l

∫ T

0

||Et(t)||2l dt+ Ch2lmax0≤t≤T ||(∇×H)(t)||2l+1

+Cτ2

∫ T

0

||∇ ×Ht(t)||20dt+ C

n∑

k=1

[τ2k−1∑

j=1

||ξjh||20 + τh2lmax0≤t≤T ||E(t)||2l

+τ3

∫ T

0

||ΓeE(t) +Et(t)||20dt] + C

n∑

k=1

τ3(∫ T

0

||E(s)||20ds+ ||E(t)||20)

+Ch2l

∫ T

0

||Ht(t)||2l dt+ Cτ2

∫ T

0

||∇ ×Et(t)||20dt

+Cn∑

k=1

[τ2k−1∑

j=1

||ηjh||20 + τh2lmax0≤t≤T ||H(t)||2l

+τ3

∫ T

0

||ΓmH(t) +Ht(t)||20dt]

+Cn∑

k=1

τ3(∫ T

0

||H(s)||20ds+ ||H(t)||20). (9.181)

Absorbing the dependence of E and H into the generic constant C, andusing the fact that ξ0h = η0

h = 0 due to our initial assumptions and nτ ≤ T ,we can simply rewrite (9.181) as

||ξnh ||20 + ||ηnh ||20 ≤ C(τ2 + h2l) + C2τ

n∑

k=1

(||ξkh||20 + ||ηkh||20), (9.182)

which is equivalent to

||ξnh ||20 + ||ηnh ||20 ≤ C(τ2 + h2l) + C3τ

n−1∑

k=1

(||ξkh ||20 + ||ηkh||20), (9.183)

where we used the Cauchy-Schwarz inequality for the k = n term in thesummation and absorbed ||ξnh ||20 and ||ηnh ||20 into the left side.

Using the Gronwall inequality, we finally obtain

||ξnh ||20 + ||ηnh ||20 ≤ C(τ2 + h2l)eC3nτ ≤ C(τ2 + h2l)eC3T ,

which along with the triangle inequality and the interpolation estimates, wehave

||En −Enh||20 + ||Hn −Hn

h||20≤ 2(||En − PhE

n||20 + ||ξnh ||20) + 2(||Hn − ΠhHn||20 + ||ηnh ||20)

≤ Ch2l||En||2l + Ch2l||Hn||2l+1 + 2(||ξnh ||20 + ||ηnh ||20)≤ C(h2l + τ2),

Page 296: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 281

which concludes the proof.

9.5 Bibliographical remarks

For more advanced analysis of FEM for Maxwell’s equations, readers shouldconsult the book by Monk [42]. An overview of finite element analysis forelectromagnetic problems as of 2001 can be found in the review paper byHiptmair [24]. Readers interested in hp FEM can consult papers [1, 33]and books [16, 17]. Some posteriori error estimators have been developedfor Maxwell’s equations [7, 48, 45]. Various domain decomposition methodsand preconditioners have been studied recently for solving Maxwell’s equa-tions [2, 23, 5, 29, 20, 54, 25]. As for analysis of the perfectly matchedlayer problems, readers can consult papers [6, 8, 11] and references therein.For practical implementation of finite element methods for solving Maxwell’sequations, readers should refer to more specialized books such as the bookby Silvester and Ferrari [51] (where many classical FEMs are described andFortran source codes are provided), the book by Demkowicz [16] (where hpFEMs for Maxwell’s equations are discussed and 1-D and 2-D Fortran codesare provided in CD-ROM), and the book by Hesthaven and Warburton [22](where discontinuous Galerkin finite element MATLAB codes are describedand can be downloaded online).

9.6 Exercises

1. Prove that at each time step, the coefficient matrix for the system (9.120)-(9.123) can be written as

Q ≡(A −BB′ C

),

where the stiffness matries A = ε0τ (Uh,Uh) and C = μ0

τ (Vh,Vh) are sym-metric positive definite (SPD), and the matrix B = (∇ × Vh,Uh). Here B′

denotes the transpose of B.2. Prove that the determinant of Q equals

det(Q) = det(A) · det(C +B′A−1B),

which is non-zero. This fact guarantees the existence and uniqueness of solu-tion for the system (9.120)-(9.123) at each time step.

3. Prove Lemma 9.4.

Page 297: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

282 Computational Partial Differential Equations Using MATLAB

4. Prove Lemma 9.5.5. Prove that (9.147) is a solution of (9.146).6. Prove Lemma 9.6.7. For the isotropic cold plasma model (9.108)-(9.110), prove the following

stability

ε0||E(t)||20 + μ0||H(t)||20 +1

ε0ω2p

||J(t)||20

≤ ε0||E0||20 + μ0||H0||20 +1

ε0ω21

||J0||20, ∀ t ∈ [0, T ],

where (E(t),H(t),J(t)) is the solution of (9.108)-(9.110), and (E0,H0,J0)is the corresponding initial function.

8. For the Debye medium model (9.129)-(9.131), prove the following sta-bility

ε0ε∞||E(t)||20 + μ0||H(t)||20 +1

(εs − ε∞)ε0||P (t)||20

≤ ε0ε∞||E0||20 + μ0||H0||20 +1

(εs − ε∞)ε0||P 0||20, ∀ t ∈ [0, T ],

where (E(t),H(t),P (t)) is the solution of (9.129)-(9.131), and (E0,H0,P 0)is the corresponding initial function.

9. Prove that

|u(tk) − 1τ

∫ tk

tk−1u(t)dt|2 ≤ τ

∫ tk

tk−1|ut(t)|2dt,

for any 0 < tk−1 < tk. Here we denote τ = tk − tk−1.

10. Prove that

|12(u(tk) + u(tk−1)) − 1

τ

∫ tk

tk−1u(t)dt|2 ≤ τ3

4

∫ tk

tk−1|utt(t)|2dt,

for any 0 < tk−1 < tk. Here we denote τ = tk − tk−1.

11. Prove that the total number of degrees of freedom from (9.26)-(9.28) isNk = k(k+2)(k+3)

2 .

12. Verify that the total number of degrees of freedom for the second typeNedelec spaces on tetrahedra is

dim((Pk)3) =(k + 1)(k + 2)(k + 3)

6.

Page 298: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 283

References

[1] M. Ainsworth and J. Coyle. Hierarchic hp-edge element families forMaxwell’s equations on hybrid quadrilateral/triangular meshes. Com-put. Methods Appl. Mech. Engrg., 190(49–50):6709–6733, 2001.

[2] A. Alonso and A. Valli. A domain decomposition approach for heteroge-neous time-harmonic Maxwell equations. Comput. Methods Appl. Mech.Engrg., 143(1–2):97–112, 1997.

[3] C. Amrouche, C. Bernardi, M. Dauge and V. Girault. Vector potentialsin three-dimensional non-smooth domains. Math. Methods Appl. Sci.,21:823–864, 1998.

[4] D.N. Arnold, F. Brezzi, B. Cockburn and L.D. Marini. Unified analysis ofdiscontinuous Galerkin methods for elliptic problems. SIAM J. Numer.Anal., 39(5):1749–1779, 2002.

[5] D.N. Arnold, R.S. Falk and R. Winther. Multigrid in H(div) andH(curl). Numer. Math., 85(2):197–217, 2000.

[6] G. Bao and H. Wu. Convergence analysis of the perfectly matchedlayer problems for time-harmonic Maxwell’s equations. SIAM J. Numer.Anal., 43(5):2121–2143, 2005.

[7] R. Beck, R. Hiptmair, R.H.W. Hoppe and B. Wohlmuth. Residual baseda posteriori error estimators for eddy current computation. M2AN Math.Model. Numer. Anal., 34(1):159–182, 2000.

[8] J.H. Bramble and J.E. Pasciak. Analysis of a finite element PML ap-proximation for the three dimensional time-harmonic Maxwell problem.Math. Comp., 77(261):1–10, 2008.

[9] S. Caorsi, P. Fernandes and M. Raffetto. On the convergence of Galerkinfinite element approximations of electromagnetic eigenproblems. SIAMJ. Numer. Anal., 38(2):580–607, 2000.

[10] M.-H. Chen, B. Cockburn and F. Reitich. High-order RKDG methodsfor computational electromagnetics. J. Sci. Comput., 22/23:205–226,2005.

[11] Z. Chen and H. Wu. An adaptive finite element method with perfectlymatched absorbing layers for the wave scattering by periodic structures.SIAM J. Numer. Anal., 41(3):799–826, 2003.

[12] P. Ciarlet, Jr. and J. Zou. Fully discrete finite element approaches fortime-dependent Maxwell’s equations. Numer. Math., 82:193–219, 1999.

Page 299: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

284 Computational Partial Differential Equations Using MATLAB

[13] B. Cockburn, G.E. Karniadakis and C.-W. Shu (eds.). DiscontinuousGalerkin Methods: Theory, Computation and Applications. Springer,Berlin, 2000.

[14] B. Cockburn, F. Li and C.-W. Shu. Locally divergence-free discontin-uous Galerkin methods for the Maxwell equations. J. Comput. Phys.,194(2):588–610, 2004.

[15] B. Cockburn and C.-W. Shu. Runge-Kutta discontinuous Galerkin meth-ods for convection-dominated problems. J. Sci. Comput., 16(3):173–261,2001.

[16] L. Demkowicz. Computing with hp-Adaptive Finite Elements, Vol. 1:One and Two Dimensional Elliptic and Maxwell Problems. Chapman &Hall/CRC, Boca Raton, FL, 2006.

[17] L. Demkowicz, J. Kurtz, D. Pardo, M. Paszynski, W. Rachowicz andA. Zdunek. Computing with hp-Adaptive Finite Elements, Vol. 2: Fron-tiers: Three Dimensional Elliptic and Maxwell Problems with Applica-tions. Chapman & Hall/CRC, Boca Raton, FL, 2008.

[18] L. Demkowicz and L. Vardapetyan. Modeling of electromagnetic ab-sorption/scattering problems using hp-adaptive finite elements. Comput.Methods Appl. Mech. Engrg., 152(1-2):103–124, 1998.

[19] G.V. Eleftheriades and K.G. Balmain (eds.). Negative RefractionMetamaterials: Fundamental Properties and Applications. Wiley-Interscience, New York, NY, 2005.

[20] J. Gopalakrishnan, J.E. Pasciak and L.F. Demkowicz. Analysis of amultigrid algorithm for time harmonic Maxwell equations. SIAM J.Numer. Anal., 42(1):90–108, 2004.

[21] J.S. Hesthaven and T. Warburton. Nodal high-order methods on un-structured grids. I. Time-domain solution of Maxwell’s equations. J.Comput. Phys., 181(1):186–221, 2002.

[22] J.S. Hesthaven and T. Warburton. Nodal Discontinuous Galerkin Meth-ods: Algorithms, Analysis, and Applications. Springer, New York, NY,2007.

[23] R. Hiptmair. Multigrid method for Maxwell’s equations. SIAM J. Nu-mer. Anal., 36(1):204–225, 1999.

[24] R. Hiptmair. Finite elements in computational electromagnetism. ActaNumer., 11:237–339, 2002.

[25] R. Hiptmair and J. Xu. Nodal auxiliary space preconditioning in H(curl)and H(div) spaces. SIAM J. Numer. Anal., 45(6):2483–2509, 2007.

Page 300: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Finite Element Methods for Electromagnetics 285

[26] P. Houston, I. Perugia, A. Schneebeli and D. Schotzau. Interior penaltymethod for the indefinite time-harmonic Maxwell equations. Numer.Math., 100(3):485–518, 2005.

[27] P. Houston, I. Perugia and D. Schotzau. Mixed discontinuous Galerkinapproximation of the Maxwell operator. SIAM J. Numer. Anal.,42(1):434–459, 2004.

[28] P. Houston, I. Perugia and D. Schotzau. Mixed discontinuous Galerkinapproximation of the Maxwell operator: non-stabilized formulation. J.Sci. Comput., 22/23:315–346, 2005.

[29] Q. Hu and J. Zou. Substructuring preconditioners for saddle-pointproblems arising from Maxwell’s equations in three dimensions. Math.Comp., 73(245):35–61, 2004.

[30] D. Jiao and J.-M. Jin. Time-domain finite-element modeling of disper-sive media. IEEE Microwave and Wireless Components Letters, 11:220–223, 2001.

[31] J. Jin. The Finite Element Method in Electromagnetics. John Wiley &Sons, New York, NY, 2nd Edition, 2002.

[32] K. Kunz and R.J. Luebbers. The Finite-Difference Time-DomainMethod for Electromagnetics. CRC Press, Boca Raton, FL, 1993.

[33] P.D. Ledger and K. Morgan. The application of the hp-finite elementmethod to electromagnetic problems. Arch. Comput. Methods Engrg.,12(3):235–302, 2005.

[34] R. Leis. Exterior boundary-value problems in mathematical physics.Trends in Applications of Pure Mathematics to Mechanics. Vol. II, pp.187–203, Monographs Stud. Math., 5, Pitman, Boston, MA, London,UK, 1979.

[35] J. Li. Error analysis of mixed finite element methods for wave propaga-tion in double negative metamaterials. J. Comp. Appl. Math., 209:81–96,2007.

[36] J. Li. Error analysis of fully discrete mixed finite element schemes for3-D Maxwell’s equations in dispersive media. Comput. Methods Appl.Mech. Engrg., 196:3081–3094, 2007.

[37] J. Li and Y. Chen. Analysis of a time-domain finite element method for3-D Maxwell’s equations in dispersive media. Comput. Methods Appl.Mech. Engrg., 195:4220–4229, 2006.

[38] J. Li and A. Wood. Finite element analysis for wave propagation indouble negative metamaterials. J. Sci. Comput., 32:263–286, 2007.

[39] Q. Lin and J. Li. Superconvergence analysis for Maxwell’s equations indispersive media. Math. Comp., 77:757–771, 2008.

Page 301: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

286 Computational Partial Differential Equations Using MATLAB

[40] T. Lu, P. Zhang and W. Cai. Discontinuous Galerkin methods for dis-persive and lossy Maxwell’s equations and PML boundary conditions.J. Comput. Phys., 200(2):549–580, 2004.

[41] P. Monk. A mixed method for approximating Maxwell’s equations.SIAM J. Numer. Anal., 28:1610–1634, 1991.

[42] P. Monk. Finite Element Methods for Maxwell’s Equations. OxfordUniversity Press, Oxford, UK, 2003.

[43] P. Monk. Analysis of a finite element method for Maxwell’s equations.SIAM J. Numer. Anal., 29:714–729, 1992.

[44] P. Monk. A finite element method for approximating the time-harmonicMaxwell equations. Numer. Math., 63(2):243–261, 1992.

[45] P. Monk. A posteriori error indicators for Maxwell’s equations. J. Com-put. Appl. Math., 100(2):173–190, 1998.

[46] J.-C. Nedelec. Mixed finite elements in R3. Numer. Math., 35:315–341,1980.

[47] J.-C. Nedelec. A new family of mixed finite elements in R3. Numer.Math., 50:57–81, 1986.

[48] S. Nicaise and E. Creuse. A posteriori error estimation for the heteroge-neous Maxwell equations on isotropic and anisotropic meshes. Calcolo,40(4):249–271, 2003.

[49] I. Perugia, D. Schotzau and P. Monk. Stabilized interior penalty methodsfor the time-harmonic Maxwell equations. Comput. Methods Appl. Mech.Engrg., 191(41–42):4675–4697, 2002.

[50] A. Shelby, D.R. Smith and S. Schultz. Experimental verification of anegative index of refraction. Science, 292:489–491, 2001.

[51] P.P. Silvester and R.L. Ferrari. Finite Elements for Electrical Engineers.Cambridge University Press, 3rd Edition, Cambridge, UK, 1996.

[52] D.R. Smith, W.J. Padilla, D.C. Vier, S.C. Nemat-Nasser and S. Schultz.Composite medium with simultaneously negative permeability and per-mittivity. Phys. Rev. Lett., 84:4184–4187, 2000.

[53] A. Taflove and C. Hagness. Computational Electrodynamics: the Finite-Difference Time-Domain Method. Artech House, Norwood, MA, 2ndEdition, 2000.

[54] A. Toselli, O.B. Widlund and B.I. Wohlmuth. An iterative substructur-ing method for Maxwell’s equations in two dimensions. Math. Comp.,70(235):935–949, 2001.

Page 302: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

10

Meshless Methods with Radial BasisFunctions

Since Kansa [31] introduced the radial basis functions (RBFs) to solve PDEsin 1990, there has been a growing interest in this subject. In this chapter, wewill introduce this fascinating area to the reader. In Sec. 10.1, we provide abrief overview of the meshless methods related to RBFs. Then in Sec. 10.2,we introduce some widely used RBFs and their mathematical properties. InSec. 10.3, we present the method of fundamental solutions (MFS) and sev-eral techniques by coupling MFS with RBFs. After that, we discuss Kansa’smethod and its variants in Sec. 10.4. In order to help readers understand thealgorithm better, we present some MATLAB codes in Sec. 10.5 to solve bothelliptic and biharmonic problems in 2-D. Finally, in Sec. 10.6, we extend thediscussion to domain decomposition methods coupled with Kansa’s method.One numerical example is also presented.

10.1 Introduction

During the past decade, there has an increasing attention to the developmentof meshless methods using radial basis functions for the numerical solution ofpartial differential equations (PDEs). In general, there are two major devel-opments in this direction. The first one is the so-called MFS-DRM which hasevolved from the dual reciprocity boundary element method (DRBEM) [49] inthe boundary element literature. In the MFS-DRM approach, the method offundamental solutions is implemented instead of BEM in the solution process.The MFS is attributed to Kupradze in 1964 [36] and is often referred to as anindirect boundary method or regular BEM in the engineering literature. Moredetails about MFS can be found in the excellent review papers [17, 24]. Inthe MFS, the singularity has been avoided by the use of a fictitious boundaryoutside the domain. As a result, the MFS has the following advantages overits counterpart BEM:(i) It requires neither domain nor boundary discretization; i.e. it is trulymeshless.(ii) No domain integration is required.

287

Page 303: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

288 Computational Partial Differential Equations Using MATLAB

(iii) It converges exponentially for smooth boundary shape and boundarydata.(iv) It is insensitive to the curse of dimension and thus attractive to highdimensional problems.(iv) It is easy for implementation and coding.

Despite of these huge advantages, the MFS has never been seriously consid-ered as a major numerical technique possibly due to its limitation in solvingonly homogeneous problems. A key factor that the MFS has revived afterthree decades of dormancy is that it has been successfully extended to solv-ing nonhomogeneous problems and various types of time-dependent problems[24, 51] by coupling the DRM. The DRM was first introduced by Nardini andBrebbia in 1982 [49]. In the BEM literature, the DRM has been employed totransfer the domain integration to the boundary. In the development of theDRM, RBFs play a key role in the theoretical establishment and applications.With the combined features of the MFS and the DRM, a meshless numericalscheme for solving PDEs has been achieved. The second meshless methodusing RBFs is the so-called Kansa’s method, where the RBFs are directlyimplemented for the approximation of the solution of PDEs. Kansa’s methodwas developed in 1990 [31], in which the concept of solving PDEs by usingRBFs, especially MQ, was initiated. Due to its simplicity in implementationand generality, Kansa’s method was extended and used to solve different PDEssuch as the biphasic mixture model for tissue engineering, the shallow waterequation for the tide and currents simulation, the Navier-Stokes equations,and free boundary value problems such as American option pricing.

10.2 The radial basis functions

By definition, an RBF function ϕ : Rd → R, d ≥ 1, is a univariate functionand can be expressed as ϕ(r),where r = ‖x‖ is the Euclidean norm. The mostwidely used radial basis functions are:(i) The multiquadric (MQ) ϕ(r) = (r2 + c2)β/2 (β is an odd integer);(ii) The inverse multiquadric ϕ(r) = (r2 + c2)−β (β > d

2 );(iii) The Gaussian (GS) ϕ(r) = e−cr

2;

(iv) The polyharmonic splines ϕ(r) = r2n ln r and ϕ(r) = r2n−1 for n ≥ 1.Note that the above RBFs have infinite support. In recent years, RBFs with

compact support were developed by Wu [64], Wendland [59] and Buhmann[3]. Among the compacted supported RBFs, the Wendland’s RBFs are wellstudied and used. Some examples of Wendland’s compacted supported RBFsare listed in Table 10.1, where we denote the cutoff function

(1 − r)l+ ={

(1 − r)l if 1 − r ≥ 0,0 if 1 − r < 0.

Page 304: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 289

TABLE 10.1

Wendland’s RBFs φd,k in Rd, d ≤ 3Function Smoothness

φ3,0(r) = (1 − r)2+ C0

φ3,1(r) = (1 − r)4+(4r + 1) C2

φ3,2(r) = (1 − r)6+(35r2 + 18r + 3) C4

φ3,3(r) = (1 − r)8+(32r3 + 25r2 + 8r + 1) C6

To distinguish different RBFs, we have to introduce the concept of (condi-tionally) positive definite functions. A continuous function φ : Ω × Ω → Ris said to be conditionally positive definite of order m on Ω ⊂ Rd if for allN > 1, all distinct points x1, · · · ,xN ∈ Ω and all αj ∈ R \ {0} satisfying

N∑

j=1

αjp(xj) = 0

for all polynomials p of degree less than m, the quadratic form

N∑

j=1

N∑

i=1

αjαiφ(||xi − xi||)

is positive. If m = 0, then the function φ is positive definite.Let Πm(Rd) denote the set of d-variable polynomials of degree at most m.

The theorem below shows the connection between the degree of the polynomialp in the interpolation function

If,X(x) =N∑

j=1

αjφ(||x− xj ||) + p(x) (10.1)

and the orderm of conditional positive definiteness of the radial basis functionφ(r).

THEOREM 10.1Assume that φ is conditionally positive definite (CPD) of order m on Ω ⊂ Rd,and that the set of points X = {x1, · · · ,xN} ⊆ Ω is Πm−1(Rd) unisolvent,i.e., the zero polynomial is the only polynomial from Πm−1(Rd) that vanisheson X. Then for any f ∈ C(Ω), there is exactly one function If,X of (10.1)with a polynomial p ∈ Πm−1(Rd) such that

If,X(xi) = f(xi) (10.2)

andN∑

j=1

αjq(xj) = 0, 1 ≤ i ≤ N, ∀ q ∈ Πm−1(Rd). (10.3)

Page 305: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

290 Computational Partial Differential Equations Using MATLAB

Denote the smallest integer greater than or equal to β by [β]. The followingresults are well known (see e.g., [5, 56, 61]).

THEOREM 10.2(i) The multiquadrics φ(r) = (r2 + c2)β/2, β > 0, β �∈ 2N , are CPD of orderm ≥ [β2 ] on Rd for any d ≥ 1.

(ii) The function φ(r) = r2k−1, k ≥ 1, are CPD of order k + 1 on Rd forall d ≥ 1.

(iii) The thin-plate splines φ(r) = r2k ln r, k ≥ 1, are CPD of order k + 1on Rd for all d ≥ 1.

(iv) The Wendland’s RBFs φ3,k(r) are positive definite on Rd for any d ≤ 3.(v) The Gaussian φ(r) = e−cr

2, c > 0, is positive definite on Rd for all

d ≥ 1.(vi) The inverse multiquadrics φ(r) = (r2 +c2)−β , β > 0, is positive definite

on Rd for all d ≥ 1.

To consider the interpolation error estimate, we define the fill distance (alsocalled the minimum separation distance)

h ≡ hX,Ω = supy∈Ω

minx∈X

||y − x||2, (10.4)

for an arbitrary set X = {x1, · · · ,xN} ⊆ Ω of distinct points. Then we have[55]

THEOREM 10.3(i) For Gaussians φ(r) = e−cr

2, we have

||If,X − f ||L2(Ω) ≤ C · e−δ/h2, δ > 0.

(ii) For multiquadrics φ(r) = (r2 + c2)β/2, β �∈ 2N , we have

||If,X − f ||L2(Ω) ≤ C · e−δ/h, δ > 0.

(iii) For thin-plate splines r2k−1 and r2k ln r, k ≥ 1, we have

||If,X − f ||L2(Ω) ≤ C · hk.

To end this section, below we state some interpolation error estimates inL∞ norm.

For φ(r) = r2 ln r in R2, we have [52]

||If,X − f ||L∞(Ω) ≤ Ch| lnh|.For φ(r) = r in R3, we have [40]

||If,X − f ||L∞(Ω) ≤ Ch| lnh|.

Page 306: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 291

For φ(r) = (r2 + c2)β/2, β �∈ 2N and Gaussians φ(r) = e−cr2, we have the

superalgebraic convergence rate [40]

||If,X − f ||L∞(Ω) ≤ Chp, p ≥ 1.

Under certain conditions, Madych [45] and Beatson and Powell [2] showedthat ||If,X−f ||L∞(Ω) is exponentially decreasing in both c and h for Gaussiansφ(r) = e−cr

2.

For Wendland’s compact RBFs φ3,k(r), we have [60]

||If,X − f ||L∞(Ω) ≤ Chk+12 in R2, k ≥ 1.

For example, for φ3,1(r) = (1 − r)4+(4r + 1), its convergence rate is h32 .

For thin-plate splines r2k−1 and r2k ln r, k ≥ 2, we have [4, p. 8]

||If,X − f ||L∞(Ω) ≤ Chk−d2 .

10.3 The MFS-DRM

10.3.1 The fundamental solution of PDEs

The fundamental solution (or free-space Green’s function) for a differentialoperator L at some point x0 ∈ Rd is defined as φ(x,x0), which satisfies

Lφ(x,x0) = δ(x− x0),

where the high-dimensional delta function is defined as the product of one-dimensional delta functions.

Now let us calculate the well-known fundamental solution of the Laplacianoperator in two dimensions (2-D), i.e., we want to solve

�G ≡ (∂2

∂x2+

∂2

∂y2)G = δ(x− x0, y − y0), −∞ < x, y <∞. (10.5)

By the definition of δ(x), we have∫

Ω

δ(x− x0, y − y0)dxdy = 1 (10.6)

for any domain Ω containing point (x0, y0). Integrating (10.5) over Ω andusing Green’s Theorem, we obtain

∂Ω

∂G

∂nds = 1. (10.7)

Page 307: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

292 Computational Partial Differential Equations Using MATLAB

For simplicity, let Ω be a circular domain centered at (x0, y0) with radiusr0. Hence the problem (10.5) becomes: Find a function G such that

�G = 0, (x, y) �= (x0, y0), (10.8)

and ∫

∂Ω

∂G

∂nds = 1. (10.9)

Changing the 2-D Laplacian operator into radial form, we can rewrite theproblem (10.8)-(10.9) as

1r

d

dr(rdG

dr) = 0, r �= 0, (10.10)

∫ 2π

0

dG

drrdθ = 1. (10.11)

The equation (10.10) has a general solution

G(r) = a+ b ln r, r =√

(x− x0)2 + (y − y0)2, (10.12)

where a and b are general constants.Substituting (10.12) into (10.11) leads to b = 1

2π . Letting the constanta = 0, we obtain the fundamental solution for the 2-D Laplacian operator asG = 1

2π ln r.Similarly, the fundamental solution G for the 3-D Laplacian operator is

determined by

�G = 0, (x, y, z) �= (x0, y0, z0), (10.13)∫

∂Ω

∂G

∂nds = 1, (10.14)

where ∂Ω is the sphere of radius r0 centered at (x0, y0, z0).Changing the Laplacian into spherical coordinates and looking for the radial

solution, we can transform (10.13)-(10.14) into

1r2

d

dr(r2

dG

dr) = 0, r �= 0, (10.15)

∫ 2π

0

(∫ π

0

dG

drr2 sinφdφ)dθ = 1. (10.16)

It is easy to see that (10.15) has the general solution G = a+ br , which along

with (10.16) yields b = − 14π . Choosing the constant a to be zero, we obtain

the fundamental solution for the 3-D Laplacian operator as G = − 14πr .

In summary, the fundamental solution for the Laplacian operator � atpoint Q is given by

G(P,Q) ={

12π ln r in R2,− 1

4πr in R3,

Page 308: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 293

where we denote for r = ||P −Q||, i.e., the distance between points P and Q.Before we discuss the fundamental solution for other operators, let us first

review the Bessel functions. For the Bessel’s equation of order α:

x2y′′

+ xy′+ (x2 − α2)y = 0, (10.17)

it is known that

Jα =∞∑

k=0

(−1)k

k!Γ(k + α+ 1)(x

2)2k+α (10.18)

is a valid solution of Bessel’s equation (10.18) for any α ≥ 0. Note that Jα(x)is often called the Bessel function of the first kind of order α. Another linearlyindepedent solution of (10.18) is the Bessel function of the first kind of order−α:

J−α =∞∑

k=0

(−1)k

k!Γ(k − α+ 1)(x

2)2k−α. (10.19)

When α is not an integer, we define the function

Yα = [(cos πα)Jα(x) − J−α(x)]/ sinπα,

which is called the Bessel function of the second kind of order α. In general,Yn(x) is the form

Jn(x)(A ln x+B) + x−n∞∑

k=0

akxk, n = 1, 2, · · · ,

where constants A and a0 are nonzero.Similarly, for the modified Bessel’s equation of order α:

x2y′′

+ xy′ − (x2 + α2)y = 0, (10.20)

we have two independent solutions

Iα =∞∑

k=0

1k!Γ(k + α+ 1)

(x

2)2k+α, α ≥ 0, (10.21)

and

I−α =∞∑

k=0

1k!Γ(k − α+ 1)

(x

2)2k−α, α > 0, α not an integer. (10.22)

Iα(x) and I−α(x) are often called the modified Bessel functions of the firstkind of α and −α, respectively.

If α > 0 is not an integer, the function

Kα =π

2· I−α(x) − Iα(x)

sinπα(10.23)

Page 309: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

294 Computational Partial Differential Equations Using MATLAB

is the modified Bessel function of the second kind of order α. For any integern = 0, 1, · · · , we define

Kn(x) = limα→n

Kα(x). (10.24)

The Hankel functions of order α of the first and second kinds are definedby

H(1)α (x) = Jα(x) + iYα(x)

andH(2)α (x) = Jα(x) − iYα(x),

respectively.By similar technique used for the Laplacian operator, it is proved that the

fundamental solution for the modified Helmholtz operator �− λ2 is

G(P,Q) ={

12πK0(λr) in R2,

14πr exp(−λr) in R3,

where K0(·) denotes the modified Bessel function of the second kind withorder zero.

Similarly, the fundamental solution for the Helmholtz operator � + λ2 isgiven by

G(P,Q) ={

i4H

(1)0 (λr) in R2,

14πr exp(−iλr) in R3,

where H(1)0 (·) denotes the Hankel function of the first kind of order zero.

Finally, the fundamental solution for the iterated Laplacian operator�m (m ≥2) is given by

G(P,Q) ={

r2m−d, in Rd, d is odd, and 2m > d,r2m−d ln r, in Rd, d is even, and 2m > d.

10.3.2 The MFS for Laplace’s equation

The basic idea of the MFS is to approximate the solution u to a homogeneousequation

Lu(P ) = 0 in Ω,u(P ) = g(P ) on ∂Ω,

with a linear combination of the fundamental solution of the L operator.For illustration, we start with the Laplace’s equation

�u(P ) = 0, P ∈ Ω, (10.25)u(P ) = g(P ), P ∈ ∂Ω, (10.26)

where Ω is a bounded, simply connected domain in Rd, d = 2, 3, with bound-ary ∂Ω.

Page 310: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 295

We can approximate the solution to (10.25) by

uh(P ) =n∑

j=1

ajG(P,Qj), ∀ P ∈ Ω, (10.27)

where G(P,Q) is the fundamental solution of (10.25), and Qj are collocationpoints located on the artificial boundary ∂Ω, which encloses the domain Ω.In practical application, the artificial boundary is often chosen as a circle inR2 or a sphere in R3.

The unknown coefficients aj can be obtained by satisfying the equation

n∑

j=1

ajG(Pi, Qj) = g(Pi), 1 ≤ i ≤ n, (10.28)

where Pi are collocation points on ∂Ω.While in R2, for completeness purposes, we usually add a constant to the

solution, i.e., we seek approximate solution as

uh(P ) =n∑

j=1

ajG(P,Qj) + c, ∀ P ∈ Ω ⊂ R2, (10.29)

in which case we need to collocate at n+ 1 points on ∂Ω giving

n∑

j=1

ajG(Pk, Qj) = g(Pk), 1 ≤ k ≤ n+ 1. (10.30)

But when Ω is a circle, we usually take c = 0.Note that the MFS is equivalent to the so-called regular boundary element

method (BEM) in the engineering community. Furthermore, the MFS doesnot require either boundary mesh or numerical integration.

Though MFS has been widely used, very few theoretical results exist aboutits convergence. Cheng [12] proved the convergence of the MFS for (10.25)-(10.26) in R2 when both ∂Ω and ∂Ω are circles and the collocation pointsPk and Qj in (10.30) are uniformly distributed on ∂Ω and ∂Ω, respectively.Later, Cheng’s results were extended to the case where Ω is a simply connectedbounded domain with analytic boundary ∂Ω by Katsurada et al. [34, 35].Since the proofs are quite technical, we only state the results here. Detailedproofs can be found in the original papers.

THEOREM 10.4[24, p. 117] Let Ω be a disk of radius r with boundary ∂Ω, i.e.,

Ω = {(x, y) ∈ R2 :√x2 + y2 < r}, ∂Ω = {(x, y) ∈ R2 :

√x2 + y2 = r}.

Page 311: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

296 Computational Partial Differential Equations Using MATLAB

Furthermore, let ∂Ω = {(x, y) ∈ R2 :√x2 + y2 = R}, R > r, and

Pk = (r cos θk, r sin θk), Qj = (R cos θj , R sin θj), 1 ≤ j, k ≤ n,

whereθj =

2πn

· (j − 1).

Then for sufficiently large n, the MFS solution (10.27) exists and convergesuniformly to the analytic solution u of (10.25)-(10.26) in Ω ∪ ∂Ω. Moveover,if u can be extended to a harmonic function, then we have the error estimate

||u− uh||L∞(Ω) ≤ C · ( rR

)n,

where the constant C > 0 is independent of n.

Theorem 10.4 implies the spectral convergence of the MFS for the specialcircle domain case and it also implies that theoretically R = ∞ is the bestchoice. However, the MFS coefficient matrix becomes highly ill-conditioned asR increases. In practical implementation, R is generally limited to above fivetimes the diameter of Ω and the collocation points are often chosen equallydistributed on ∂Ω and ∂Ω.

Finally, we would like to remark that quite arbitrary boundary conditionscan be incorporated in the MFS. For example, if the Laplace problem (10.25)is imposed with mixed boundary conditions

u(P ) = g1(P ) ∀ P ∈ ∂Ω1,

∂u

∂n(P ) = g2(P ) ∀ P ∈ ∂Ω2,

where ∂Ω = ∂Ω1 ∩ ∂Ω2 and ∂Ω1 ∪ ∂Ω2 = ∅. When Ω ⊂ R2, we can choose n1

points on ∂Ω1 and n2 points on ∂Ω2, where n1 + n2 = n + 1, to satisfy thefollowing equations

n1∑

j=1

ajG(Pi, Qj) + c = g1(Pi), 1 ≤ i ≤ n1, (10.31)

n1+n2∑

j=n1+1

aj∂

∂nG(Pi, Qj) = g2(Pi), n1 + 1 ≤ i ≤ n1 + n2. (10.32)

When Ω ⊂ R3, we don’t need c in (10.31) and we only need n1 +n2 = n totalpoints. Experiences show that n ≤ 30 in R2 and n ≤ 100 in R3 often producegood enough accuracy [24, p. 109].

Note that in (10.28) and (10.29), the points Qj are chosen as fixed. Anotherapproach is to chooseQj along with the coefficients aj by minimizing the error

E =n∑

i=1

|n∑

j=1

ajG(Pi, Qj) − g(Pi)|2. (10.33)

Page 312: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 297

This approach was considered by Fairweather and Kargeorghis [30, 17]. Notethat this method is quite time-consuming, since (10.33) is a nonlinear mini-mization problem. As a compromise, we may choose the points Qj to be fixedon a circle or a sphere with radius R as an unknown parameter in (10.33).

10.3.3 The MFS-DRM for elliptic equations

The basic idea of MFS-DRM is to split the given PDE into two parts: aninhomogeneous equation and a homogeneous equation. To be more specific,consider

Lu(P ) = f(P ), P ∈ Ω, (10.34)u(P ) = g(P ), P ∈ ∂Ω (10.35)

where L is an elliptic differential operator. Then we look for a particularsolution up, which satisfies the equation

Lup(P ) = f(P ), (10.36)

but does not have to satisfy the boundary condition (10.35). Then considerthe difference between the real solution u of (10.34)-(10.35) and the particularsolution up of (10.36), i.e., vh = u− up, which satisfies

Lvh(P ) = 0, P ∈ Ω, (10.37)vh(P ) = g(P ) − up, P ∈ ∂Ω. (10.38)

Now the homogeneous problem (10.37)-(10.38) can be solved by the MFS.The rest of the issue is to determine the particular solution up. The mostpopular way for obtaining an approximate particular solution is by the dualreciprocity method (DRM), which was introduced by Nardini and Brebbia[49] and extended by many later researchers [50].

The success of the DRM depends on how the approximate particular solu-tions are evaluated. First, we approximate f by a linear combination of basisfunctions {ϕj}

f(P ) � f =N∑

j=1

ajϕj(P ) (10.39)

where the coefficients {aj}N1 are usually obtained by interpolation; i.e. bysolving

N∑

j=1

ajϕj(Pk) = f(Pk), 1 ≤ k ≤ N, (10.40)

where Pk ∈ Rd, d = 2 or 3. An approximate particular solution up to (10.36)is given by

up(P ) =N∑

j=1

ajΦj(P ) (10.41)

Page 313: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

298 Computational Partial Differential Equations Using MATLAB

where {Φj}N1 are obtained by analytically solving

LΦj = ϕj , 1 ≤ j ≤ N. (10.42)

The expectation is that if f is a good approximation of f , then up will bean accurate approximation to a particular solution up of (10.36). The simplechoice of ϕj = 1 + rj , where rj = ‖P − Pj‖, is the most popular in the earlyDRM literature.

Later, theory of RBFs provides a firm theoretical basis to approximate f byf in (10.39). Let {Pi}ni=1 be a set of distinct points. If the exactness conditionf(Pi) = f(Pi), 1 ≤ i ≤ n, is imposed, then the system in (10.40) is uniquelysolvable if the matrix

Aϕ = (ϕj(Pk − Pj))1≤j,k≤n

is non-singular. It is well known that positive definiteness is sufficient toguarantee the invertibility of the coefficient matrix Aϕ. However, most of theglobally defined RBFs are only conditionally positive definite. In order toguarantee the unique solvability of the interpolation problem, one needs toadd a polynomial term in (10.40), i.e.,

f(P ) =N∑

j=1

ajϕ(||P − Pj ||) +l∑

k=1

bkpk(P ), (10.43)

where {pk}lk=1 is the complete basis for d-variate polynomials of degree ≤m− 1. The coefficients aj , bk can be found by solving the system

N∑

j=1

ajϕ(||Pi − Pj ||) +l∑

k=1

bkpk(Pi) = f(Pi), 1 ≤ i ≤ N, (10.44)

N∑

j=1

ajpk(Pj) = 0, 1 ≤ k ≤ l, (10.45)

where {xi}Ni=1 are the collocation points on Ω.By linearity, once the coefficients aj , bk are obtained, the approximate par-

ticular solution up can be found as

up =N∑

j=1

ajΦj +l∑

k=1

bkΨk,

where Φj is shown in (10.42) and Ψk satisfies

LΨk = pk, for k = 1, · · · , l.For example, if we use the thin-plate splines

φ(r) = r2 ln r in R2; φ(r) = r in R3,

Page 314: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 299

in (10.43), we need to add a linear polynomial in (10.43) to guarantee theexistence of a solution for the interpolation, i.e., (10.45) becomes

N∑

j=1

aj =N∑

j=1

ajxj =N∑

j=1

ajyj = 0 in R2, (10.46)

andN∑

j=1

aj =N∑

j=1

ajxj =N∑

j=1

ajyj =N∑

j=1

ajzj = 0 in R3. (10.47)

More specifically, the systems (10.44) and (10.46), and (10.44) and (10.47)have a unique solution [16] if Pi are not colinear in R2 and not coplanar inR3.

Note that the derivation of Ψk can be obtained by the method of indeter-minate coefficients. A list of Ψk for L = Δ can be found in [11]. For the2-D Helmholtz-type operators, Muleshkov et al. [46] have shown that theparticular solution to

Δup + ελ2up = xmyn (ε = ±1)

is given by

up(x, y) =[ n2 ]∑

k=0

[m2 ]∑

�=0

ε(−ε)k+� (k + �)!m!n!xn−2kyn−2�

k!�!(m− 2k)!(n− 2�)!λ2k+2�+2. (10.48)

The explicit form of up in (10.48) can be easily obtained by symbolic softwaresuch as MATHEMATICA or MAPLE.

The determination of Φj has proved to be difficult, which depends on theunderlining differential operator and the chosen RBF ϕj . For L = Δ, a listof commonly used Φj have been derived as shown in Table 10.2. A list ofΦj using compactly supported RBFs is also available [7]. For example, forWendland’s RBF

φ3,0(r) ={

(1 − ra )2, for 0 ≤ r ≤ a,

0, for r > a,

we have the corresponding particular solution

Φ(r) =

{r2

4 − 2r3

9a + r4

16a2 , for 0 ≤ r ≤ a,13a2

144 + a2

12 ln ra , for r > a.

While for the other Wendland’s RBF

φ3,1(r) ={

(1 − ra )4(1 + 4r

a , for 0 ≤ r ≤ a,0, for r > a,

Page 315: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

300 Computational Partial Differential Equations Using MATLAB

TABLE 10.2

Φ verse RBFs ϕ for L = Δ in 2-Dϕ Φ

1 + r r3

9 + r2

4

r2 ln r r4 ln r16 − r4

32√r2 + c2 −c3

3 ln(c√r2 + c2 + c2) + 1

9 (r2 + 4c2√r2 + c2)

the corresponding particular solution is

Φ(r) =

{r2

4 − 5r4

8a2 + 4r5

5a3 − 5r6

12a4 + 4r7

49a5 , for 0 ≤ r ≤ a,529a2

5880 + a2

14 ln ra , for r > a.

It is noted that even for a simple differential operator such as Laplacian �,the closed form of Φ could be difficult to obtain. For example, for ϕ = e−r

2

(Gaussian), we have

Φ(r) =14

(ln r2 +

∫ ∞

r2

exp(−t)t

dt

),

which is very time-consuming to evaluate. Hence, the success of the imple-mentation of the DRM relies on the derivation of the closed form particularsolution Φ.

Recent advances in deriving the closed form Φ for Helmholtz-type op-erators using polyharmonic splines in both 2-D and 3-D [8, 47] and com-pactly supported RBFs in 3-D [25] have made it possible for solving time-dependent problems more effectively. A list of Φ using polyharmonic splinesfor the 2-D modified Helmholtz operator is given in Table 10.3, where γ �0.5772156649015328 is the Euler’s constant, K0(·) is the modified Bessel func-tions of the second kind with order zero.

In the next subsection, we present an example of how to derive the particularsolution Φ.

10.3.4 Computing particular solutions using RBFs

Considering the efficiency of using the analytic particular solutions in theMFS-DRM, here we show how to find a particular solution [8, 47] Φ to theequation

(�− λ2)Φ = r2 ln r. (10.49)

Applying �2 to both sides of (10.49) and using the fact that

�2(r2 ln r) = 0, ∀ r > 0,

we obtain�2(�− λ2)Φ = 0. (10.50)

Page 316: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 301

TABLE 10.3

Φ verse RBFs ϕ for L = Δ − λ2 in 2-Dϕ Φ

r2 ln r{− 4λ4 (K0(λr) + ln r) − r2 ln r

λ2 − 4λ4 , r > 0

4λ4

(γ + log

(λ2

))− 4λ4 , r = 0

r4 ln r{− 64λ6 (K0(λr) + ln r) − r2 ln r

λ2

(16λ2 + r2

)− 8r2

λ4 − 96λ6 , r > 0

64λ6

(γ + log

(λ2

))− 96λ6 , r = 0

r6 ln r

⎧⎪⎨

⎪⎩

− 2304λ8 (K0(λr) + ln r) − r2 ln r

λ2

(576λ4 + 36r2

λ2 + r4)

− 12r2

λ4

(40λ2 + r2

)− 4224λ8 , r > 0

2304λ8

(γ + log

(λ2

))− 4224λ8 , r = 0

Denote

�r =1r

d

dr(rd

dr) =

d2

dr2+

1r

d

dr, (10.51)

which is the radial part of the Laplacian � in two dimensions. Hence theradial solutions of (10.50) satisfying

�2r(�r − λ2)Φ = 0. (10.52)

Assume that Φ1 and Φ2 are the solutions to equations

(�r − λ2)Φ1 = 0, or (r2d2

dr2+ r

d

dr− λ2r2)Φ1 = 0, (10.53)

and�2rΦ2 = 0, (10.54)

respectively. Then we can see that

Φ = Φ1 + Φ2, (10.55)

which is a solution to (10.52).It is known that (10.53) is a modified Bessel’s equation of order n, whose

general solution can be written as

Φ1 = AI0(λr) +BK0(λr), (10.56)

where I0 and K0 are the modified Bessel functions of the first and second kindwith order zero, respectively.

It is easy to check that (10.54) is equivalent to the Euler differential equation

r4d4Φ2

dr4+ 2r3

d3Φ2

dr3− r2

d2Φ2

dr2+ r

dΦ2

dr= 0, (10.57)

whose general solution is given by:

Φ2(r) = a+ b ln r + cr2 + dr2 ln r. (10.58)

Page 317: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

302 Computational Partial Differential Equations Using MATLAB

Therefore, we obtain a general particular solution

Φ(r) = AI0(λr) +BK0(λr) + a+ b ln r + cr2 + dr2 ln r, (10.59)

whose coefficients can be found by requiring that Φ be continuous at r = 0and satisfying (10.49). Through some tedious algebra, we can obtain oneparticular solution [46]:

Φ ={− 4

λ2 − 4 ln rλ4 − r2 ln r

λ2 − 4K0(λr)λ4 , r > 0,

− 4λ2 + 4γ

λ4 + 4λ4 log(λ2 ), r = 0,

where γ is the Euler’s constant.

10.3.5 The RBF-MFS

Instead of first approximating the right-hand side function of the equationand then finding the approximate particular solution by analytical method,we can find the approximate particular solution directly by the collocationmethod, i.e., by requiring the approximate particular solution

up(x, y) =N∑

j=1

ujϕj(x, y), (10.60)

to satisfy the underlying equation Lu = f at the collocation points

N∑

j=1

(Lϕj)(xi, yi)uj = f(xi, yi), i = 1, 2, · · · , N. (10.61)

Hence we end up with solving an N ×N linear system with coefficient matrixA = [(Lϕj)(xi, yi)] for the unknowns {uj}Nj=1. Here N is the total number ofcollocation points.

Note that this technique was first proposed by Golberg in 1995 [21, p. 102]and was restated in the book of Golberg and Chen [23, p. 323]. Among manypractioners in the BEM community, Chen and Tanaka [9] used multiquadricRBF ϕ(r) = (r2 + c2)3/2 and Kogl and Gaul [33] used RBF ϕ(r) = r2 + r3 intheir applications.

10.3.6 The MFS-DRM for the parabolic equations

For time-dependent diffusion problems, the basic approach is to use the Laplacetransform or time-differencing methods to reduce a time-dependent boundaryvalue problem to a sequence of Helmholtz-type equations of the form

Δu± λ2u = f. (10.62)

In early BEM literature, the DRM was only applied to the case when themajor operator L in Lu = f is kept as the Laplace or harmonic operators.

Page 318: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 303

For instance, Lu = f will be treated as Δu = f ∓ λ2u. This is primarilydue to the difficulty in obtaining particular solutions in closed form for otherdifferential operators. As a result, the DRM is less effective when the right-hand side becomes too complicated. In general, it is preferred to keep theright-hand side as simple as possible so that it can be better approximatedby RBFs. Meanwhile, the simpler the right-hand side, the more preservedthe differential operator in the left-hand side and the fundamental solutionbecomes more involved and the better accuracy is expected.

First, let us consider a method that couples the MFS with the Laplacetransform [66] for solving the parabolic problem

∂u

∂t(P, t) = �u(P, t) P ∈ Ω ⊂ Rd, d = 2, 3, t > 0, (10.63)

u(P, t) = g1(P ) P ∈ ∂Ω1, t > 0, (10.64)∂u

∂n(P, t) = g2(P ) P ∈ ∂Ω2, t > 0, (10.65)

u(P, 0) = u0(P ) P ∈ Ω. (10.66)

Denote the Laplace transform

LT [u(P, t)] ≡ u(P, s) =∫ ∞

0

u(P, t)e−stdt, (10.67)

for s ∈ R. Using the Laplace transform to (10.63)-(10.66) and the property

LT [∂u

∂t(P, t)] = su(P, s) − u0(P ),

we obtain the transformed problem

(�− s)u(P, s) = −u0(P ) P ∈ Ω, (10.68)u(P, s) = g1(P, s) P ∈ ∂Ω1, (10.69)

∂u

∂n(P, s) = g2(P, s) P ∈ ∂Ω2, (10.70)

which becomes a modified Helmholtz equation and can be solved by the MFS-DRM.

Let up be a particular solution to

(�− λ2)u = −u0 ≡ f, λ =√s. (10.71)

Then v = u− up satisfies

(�− λ2)v(P, s) = 0, P ∈ Ω, (10.72)v(P, s) = g1(P, s) − up(P ), P ∈ ∂Ω1, (10.73)

∂v

∂n(P, s) = g2(P, s) − ∂up

∂n(P ) P ∈ ∂Ω2, (10.74)

Page 319: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

304 Computational Partial Differential Equations Using MATLAB

whose solution can be approximated by

vh =n∑

j=1

ajG(P,Qj ;λ), (10.75)

where G is the fundamental solution for the operator �− λ2.Hence,

uh = vh + up, (10.76)

is an approximation to the solution u of (10.68)-(10.70). Having done this, wecan obtain the approximate solution uh to the original problem (10.63)-(10.66)by the inverse Laplace transform

uh(P, t) = LT−1(uh), (10.77)

which can be evaluated by using Stehfest’s method [66].Another way to solve the parabolic problem (10.63)-(10.66) is to discrete

(10.63) in time first, then use the MFS to solve the modified Helmholtz equa-tion at each time step. For example, using the backward Euler scheme for(10.63), we obtain

(�− 1�t)u

n+1(P ) = − 1�tu

n(P ), (10.78)

which can be solved using the MFS for the modified Helmholtz equation.

10.4 Kansa’s method

10.4.1 Kansa’s method for elliptic problems

Without loss of generality, let us consider the Poisson’s equation

∂2u

∂x2+∂2u

∂y2= f(x, y), (x, y) ∈ Ω (10.79)

u|∂Ω = g(x, y), (10.80)

Other problems and boundary conditions can be pursued in a similar way.Let {(xj , yj)}Nj=1 be N collocation points in Ω of which {(xj , yj)}NI

i=1are

interior points and {(xj , yj)}Ni=NI+1 are boundary points. For simplicity, weconsider only Hardy’s MQ. For each point (xj , yj), let us denote

ϕj(x, y) =√

(x− xj)2 + (y − yj)2 + c2 =√r2j + c2,

where rj =√

(x − xj)2 + (y − yj)2.

Page 320: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 305

It is easy to check that

∂ϕj∂x

=x− xj√r2j + c2

,∂ϕj∂y

=y − yj√r2j + c2

,

∂2ϕj∂x2

=(y − yj)2 + c2

(r2j + c2)3/2,

∂2ϕj∂y2

=(x− xj)2 + c2

(r2j + c2)3/2.

For the elliptic problem (10.79)-(10.80), we approximate u by u by assuming

u(x, y) =N∑

j=1

cjϕj(x, y), (10.81)

where {cj}Nj=1 are the unknown coefficients to be determined.By substituting (10.81) into (10.79)-(10.80), we have

N∑

j=1

(∂2ϕj∂x2

+∂2ϕj∂y2

)(xi, yi)cj = f(xi, yi), i = 1, 2, · · · , NI , (10.82)

N∑

j=1

ϕj(xi, yi)cj = g(xi, yi), i = NI + 1, NI + 2, · · · , N, (10.83)

from which we can solve the N × N linear system of (10.82)-(10.83) for theunknowns {cj}Nj=1. Then (10.81) can give us the approximate solution at anypoint in the domain Ω.

10.4.2 Kansa’s method for parabolic equations

For the parabolic problem

∂u

∂t− α(

∂2u

∂x2+∂2u

∂y2) = f(x, y, t, u, ux, uy),

(x, y) ∈ Ω, 0 ≤ t ≤ T, (10.84)u|∂Ω = g(x, y, t), (x, y) ∈ ∂Ω, (10.85)u|t=0 = h(x, y), (x, y) ∈ Ω, (10.86)

we can consider the implicit scheme

un+1 − un

δt− α(

∂2un+1

∂x2+∂2un+1

∂y2) = f(x, y, tn, un, unx, u

ny ), (10.87)

where δt is the time step, and un and un+1 are the solutions at time tn = nδtand tn+1 = (n+ 1)δt, respectively.

Page 321: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

306 Computational Partial Differential Equations Using MATLAB

Similar to the elliptic problem, we can assume that the approximate solutionfor the parabolic problem (10.84)-(10.86) be expressed as

u(x, y, tn+1) =N∑

j=1

cn+1j ϕj(x, y), (10.88)

where {un+1j }Nj=1 are the unknown coefficients to be determined.

By substituting (10.88) into (10.84)-(10.85), we have

N∑

j=1

(ϕjδt

− α∂2ϕj∂x2

− α∂2ϕj∂y2

)(xi, yi)cn+1j

=un

δt(xi, yi) + f(xi, yi, tn, un(xi, yi), unx(xi, yi), u

ny (xi, yi)),

i = 1, 2, · · · , NI , (10.89)N∑

j=1

ϕj(xi, yi)cn+1j = g(xi, yi, tn+1), i = NI + 1, NI + 2, · · · , N,(10.90)

from which we can solve the N × N linear system of (10.89)-(10.90) for theunknowns {cn+1

j }Nj=1, and obtain the approximate solution (10.88) at anypoint in the domain Ω. Here we denote

un(xi, yi) =N∑

j=1

cnj ϕj(xi, yi),

unx(xi, yi) =N∑

j=1

cnj∂ϕj(xi, yi)

∂x, uny (xi, yi) =

N∑

j=1

cnj∂ϕj(xi, yi)

∂y.

10.4.3 The Hermite-Birkhoff collocation method

Kansa’s method leads to an unsymmetric coefficient matrix, and no one hasbeen able to prove its nonsingularity so far. Inspired by the scattered Hermite-Birkhoff interpolation method [63, 48], Fasshauer [18] extended it to solvingPDEs. In general, let us consider a general linear elliptic problem:

Lu(x) = f(x), x in Ω ⊂ Rd, d = 2, 3, (10.91)u(x) = g(x), x on ∂Ω. (10.92)

The approximate solution u to the problem (10.91)-(10.92) is chosen as

u(x) ≈NI∑

j=1

cjLξφ(||x− ξj ||) +

N∑

j=NI+1

cjφ(||x− ξj ||), (10.93)

where we denote NI for the total number of interior collocation points, N−NIthe total number of boundary collocation points, and φ some kind of radial

Page 322: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 307

basis functions. Here Lξ indicates that the differential operator L acts on φwith respect to the variable ξ.

Substituting (10.93) into (10.91)-(10.92) and satisfying them at the corre-sponding collocation points, we obtain

Lu(xi) = f(xi), i = 1, · · · , NI , (10.94)u(x) = g(x), i = NI + 1, · · · , N. (10.95)

We can rewrite (10.94)-(10.95) as a linear system

AC = F, (10.96)

where the vectors C and F are

C = (c1, · · · , cNI ; cNI+1, · · · , cN )′,F = (f(x1), · · · , f(xNI ); f(xNI+1), · · · , f(xN ))′,

and the coefficient matrix

A =[A11 A12

A21 A22

](10.97)

where

(A11)ij = LLξφ(||xi − ξj ||), 1 ≤ i, j ≤ NI ,

(A12)ij = Lφ(||xi − ξj ||), 1 ≤ i ≤ NI , NI + 1 ≤ j ≤ N,

(A21)ij = Lξφ(||xi − ξj ||), NI + 1 ≤ i ≤ N, 1 ≤ j ≤ NI ,

(A22)ij = φ(||xi − ξj ||), NI + 1 ≤ i, j ≤ N.

To illustrate the algorithm clearly, let us assume that the differential oper-ator

L = � ≡ ∂2

∂x2+

∂2

∂y2

and the RBF φ =√

(x− ξ)2 + (y − η)2 + c2.By simple calculation, we have

∂φ

∂ξ=

−(x− ξ)φ1/2

,∂2φ

∂ξ2=

(y − η)2 + c2

φ3/2,

which gives

Lξφ =(x− ξ)2 + (y − η)2 + 2c2

φ3/2.

Similarly, we can obtain

∂x(Lξφ) =

−(x− ξ)[(x − ξ)2 + (y − η)2 + 4c2]φ5/2

,

Page 323: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

308 Computational Partial Differential Equations Using MATLAB

and

∂2

∂x2(Lξφ)

=[(x− ξ)2 + (y − η)2 + c2][2(x− ξ)2 − (y − η)2 − 4c2] + 15(x− ξ)2c2

φ7/2,

which gives

LLξφ = {[(x− ξ)2 + (y − η)2 + c2][(x− ξ)2 + (y − η)2 − 8c2]+15(x− ξ)2c2 + 15(y − η)2c2}/φ7/2.

From the example, we can see that implementation of the Hermite-Birkhoffcollocation method is much more complicated than Kansa’s method, and itis not feasible for nonlinear problems. Furthermore, experiences [18, 37, 39]show that both methods achieve similar accuracy. A nice feature about theHermite-Birkhoff collocation method is that the method is mathematicallysound and error analysis is available [20].

10.5 Numerical examples with MATLAB codes

In this section, we present several examples solved by RBF meshless methods.MATLAB source codes are provided for all examples so that readers can graspsuch methods easily and use them for other application problems.

10.5.1 Elliptic problems

Here we consider the problem (10.79)-(10.80) with f(x, y) = 13 exp(−2x+3y)and Dirichlet boundary function g(x, y) chosen such that the exact solutionis

u(x, y) = exp(−2x+ 3y).

This problem was considered previously by Kansa [31, p. 159], where he ob-tained the maximum norm error 0.4480 with only 10 boundary points and 20interior points. Here we solved this problem by both the RBF-MFS methodand Kansa’s method. Both methods give almost the same results. For exam-ple, just run the attached codes Kansa All.m and LiDRM All.m without anymodification. They all give relative maximum error 0.0066 for the 21 × 21grid.

The MATLAB code LiDRM All.m is shown below:

%-------------------------------------------------------------% LiDRM_all.m: use the RBF-DRM method solve elliptic problem.

Page 324: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 309

%% This code implements most RBF functions.% Run directly the code gives the relative max error 0.0066.%-------------------------------------------------------------

tt=cputime;

%total intervals in each directionmn=20;h=1.0/mn;%total collocation pointsmn1=mn+1;nn=mn1*mn1;cs=0.2; %shape parameter for MQ

% NK: order of r^{2k+1}, k=1,2,3,...% or order of TPS r^{2k}*ln(r), k=1,2, ...%ID=1 for MQ; ID=2 for r^3;%ID=3 for r^4ln(r); ID=4 for e^(-beta*r^2)ID=2;NK=3;beta=5;

p1=zeros(1,nn);p2=zeros(1,nn);for j=1:mn1for i=1:mn1

p1(i+(j-1)*mn1)=h*(i-1);p2(i+(j-1)*mn1)=h*(j-1);

endend

aa=zeros(nn,nn);%t=cputime;

% Form matrix ’aa’. Here ’nn’ is the # of collocation pts% aa=[L\phi_j(P_i)]for i=1:nn

for j=1:nnif ID == 1 % use MQr2=(p1(i)-p1(j))^2+(p2(i)-p2(j))^2+cs*cs;aa(i,j)=(r2+cs*cs)/(r2^1.5);

elseif ID == 2 % use r^{2k+1}, k=1tmp=sqrt((p1(i)-p1(j))^2+(p2(i)-p2(j))^2);aa(i,j)=(2*NK+1)^2*tmp^(2*NK-1);

Page 325: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

310 Computational Partial Differential Equations Using MATLAB

elseif ID == 3tmp= sqrt((p1(i)-p1(j))^2+(p2(i)-p2(j))^2);if tmp > 0

aa(i,j)=16*tmp^2*log(tmp)+8*tmp^2;end

elseif ID == 4tmp= sqrt((p1(i)-p1(j))^2+(p2(i)-p2(j))^2);aa(i,j)=(-4*beta+4*beta^2*tmp^2)*exp(-beta*tmp^2);

endend

end

% RHS of the original equationg=zeros(nn,1);%g=2*exp(p1’-p2’);g=13*exp(-2*p1’+3*p2’);[L,U]=lu(aa);c=U\(L\g);

% boundary nodesq1=[0 0 0 0 0 0 .2 .4 .6 .8 1 1 1 1 1 1 .8 .6 .4 .2 ];q2=[0 .2 .4 .6 .8 1 1 1 1 1 1 .8 .6 .4 .2 0 0 0 0 0 ];

% here we get particular solutions at all pointsn=20;for i=1:nn+n

sum=0;if i <= nn

x=p1(i); y=p2(i);else

x=q1(i-nn); y=q2(i-nn);endfor j=1:nn

if ID == 1 % use MQphi=sqrt((x-p1(j))^2+(y-p2(j))^2+cs*cs);

elseif ID == 2 % use r^{2k+1}, k=1,2, ...phi=sqrt((x-p1(j))^2+(y-p2(j))^2)^(2*NK+1);

elseif ID == 3r2=(x-p1(j))^2+(y-p2(j))^2;if r2 > 0

phi=r2^2*log(r2)/2;end

elseif ID == 4r2=(x-p1(j))^2+(y-p2(j))^2;phi=exp(-beta*r2);

Page 326: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 311

endsum=sum+c(j)*phi;

endv2(i)=sum;

end

% BC values for MFS = original BC - particular solutionv3=v2(nn+1:nn+n);g2=zeros(1,n);%g2=exp(q1-q2)+exp(q1).*cos(q2)-v3;g2=exp(-2*q1+3*q2)-v3;

% form the source points for MFSm=n-1;

rad=0:2.*pi/m:2.*pi*(1-1/m);x1=5*cos(rad)+.5;y1=5*sin(rad)+.5;

% form matrix ’A’ for MFS, ’n’ is the # of boundary pointsA=zeros(n,n);for i=1:n

A(i,n)=1;for j=1:n-1A(i,j)=log((x1(j)-q1(i))^2+(y1(j)-q2(i))^2);

endend

% solution returned in vector ’z’[L,U]=lu(A);z=U\(L\g2’);

% z=A\g2’;err_max = 0;fid2=fopen(’out_LiDRM.txt’,’w’);

% evaluate the error at those interesting points only!for j=1:nn

% get the points (x,y) we are interesting in!x=p1(j);y=p2(j);

% ’n’ is the # of BC pointsv=0;for i=1:n-1

d1=x1(i)-x;d2=y1(i)-y;v=v+z(i)*log(d1*d1+d2*d2);

Page 327: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

312 Computational Partial Differential Equations Using MATLAB

end

% final solution = particular solution + MFS’ solutiontotal=v2(j)+v+z(n);exact=exp(-2*x+3*y);diff=abs(exact-total)/exact;fprintf(fid2,’%9.4f %9.4f %10.6e %10.6e %10.6e\n’,...

x, y, total, exact, diff);if (err_max < diff)

err_max = diff; % find the max relative errorend

endstatus=fclose(fid2);

disp(’max relative err=’), err_max,

The MATLAB code Kansa All.m is shown below:

%--------------------------------------------------------% KansaAll.m: use the so-called Kansa method to solve% an elliptic problem.% This implementation includes most popular RBFs.%--------------------------------------------------------

mn=20;h=1.0/(1.0+mn);NI=mn*mn; %total # of interior nodes

NBC=16; %total BC pointsc=0.9;%c=1.8; %shape parameterN=NI+NBC; %total # of collocation pointsTol=1.0e-15;

% ID=1 for MQ, ID=2 for r^{2k+1},% ID=3 for r^4ln(r), ID=4 for e^{-beta*r^2}ID=2;NK=3; % the parameter k in r^{2k+1}beta=10;

XBC=zeros(1,NBC); %x-coordinate of BC nodesYBC=zeros(1,NBC); %y-coordinate of BC nodesXBC=[0.00 0.25 0.50 0.75 1.00 1.00 1.00 1.00 ...

1.00 0.75 0.50 0.25 0.00 0.00 0.00 0.00];YBC=[0.00 0.00 0.00 0.00 0.00 0.25 0.50 0.75 ...

1.00 1.00 1.00 1.00 1.00 0.75 0.50 0.25];

Page 328: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 313

X=zeros(1,N);Y=zeros(1,N);for j=1:mnfor i=1:mn

X(i+(j-1)*mn)=h*i;Y(i+(j-1)*mn)=h*j;

endend

%after this, ’h’ is used for scaling, so h=1 means no scaling!h=1;for i=1:NBC

X(i+NI)=XBC(i);Y(i+NI)=YBC(i);

end

A=zeros(N,N); %the Kansa’s matrixA11=zeros(NI,NI); %A1 submatrix of AA12=zeros(NI,NBC); %submatrix of AA21=zeros(NBC,NI); %submatrix of AA22=zeros(NBC,NBC); %submatrix of AGF=zeros(N,1); %global RHS

%form global matrix A & rescale itfor i=1:NI

GF(i)=13*exp(-2*X(i)+3*Y(i));GF(i)=GF(i)*(h*h);for j=1:Nif ID == 1tmp=((X(i)-X(j))^2+(Y(i)-Y(j))^2)+c*c;A(i,j)=(tmp+c*c)/(tmp^1.5);

elseif ID == 2tmp=sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);A(i,j)=(2*NK+1)^2*tmp^(2*NK-1);

elseif ID == 3tmp= sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);if tmp > Tol

A(i,j)=16*tmp^2*log(tmp)+8*tmp^2;end

elseif ID == 4tmp= sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);A(i,j)=(-4*beta+4*beta^2*tmp^2)*exp(-beta*tmp^2);

endA(i,j)=A(i,j)*(h*h);

Page 329: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

314 Computational Partial Differential Equations Using MATLAB

endend

%here we rescale the BC nodesfor i=NI+1:NI+NBC

GF(i)=exp(-2*X(i)+3*Y(i));% GF(i)=GF(i)/(h*h);

for j=1:Nif ID == 1tmp=(X(i)-X(j))^2+(Y(i)-Y(j))^2+c*c;A(i,j)=sqrt(tmp);elseif ID == 2

tmp=sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);A(i,j)=tmp^(2*NK+1);

elseif ID == 3tmp=sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);if tmp > Tol

A(i,j)=tmp^4*log(tmp);end

elseif ID == 4tmp=sqrt((X(i)-X(j))^2+(Y(i)-Y(j))^2);A(i,j)=exp(-beta*tmp^2);

end% A(i,j)=A(i,j)/(h*h);

endend

%Solve the equation: u_xx+u_yy=f(x,y), u=g(x,y) on BCu=zeros(N,1); %approx solution at all pointsuex=zeros(N,1); % exact solution

for i=1:Nuex(i)=exp(-2*X(i)+3*Y(i));

end

%Solving the global system directly gives worse%accuracy than solved by LU decomposition!%u=A\GF

%solve by LU decomposition[L,U]=lu(A);u=U\(L\GF);

fid2=fopen(’out_KansaAll.txt’,’w’);for i=1:N

Page 330: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 315

%find the approx solution at each pointuappr=0.0;for j=1:N

r2=(X(i)-X(j))^2+(Y(i)-Y(j))^2;if ID == 1tmp=sqrt(r2+c*c);

elseif ID == 2tmp=sqrt(r2)^(2*NK+1);

elseif ID == 3if r2 > Tol

tmp=r2^2*log(r2)/2;end

elseif ID == 4tmp=exp(-beta*r2);

enduappr=uappr+u(j)*tmp;

enderr(i)=abs(uappr-uex(i))/uex(i);fprintf(fid2,’%9.4f %9.4f %10.6e %10.6e %10.6e\n’,...

X(i),Y(i), uappr, uex(i),err(i));endstatus=fclose(fid2);disp(’max relative err=’), max(err)

10.5.2 Biharmonic problems

Here we consider solving the biharmonic equation [42]

Lψ ≡ ∇4ψ = 0 in Ω (10.98)

in a closed, bounded domain Ω in the plane, subject to either

B1ψ ≡ ψ = f(x, y), B2ψ ≡ ∂ψ

∂n= g(x, y), for (x, y) ∈ ∂Ω, (10.99)

or

B1ψ ≡ ψ = f(x, y), B2ψ ≡ ∇2ψ = g(x, y), for (x, y) ∈ ∂Ω. (10.100)

Here (10.99) is the so-called clamped boundary condition, while (10.100) isthe simply supported boundary condition. ∂ψ

∂n denotes the normal derivativeon the boundary ∂Ω.

To solve the direct problem (10.98)-(10.100) by the RBF meshless method,we assume that the approximate solution can be expressed as

ψN (x, y) =NI+Nd+Nn∑

j=1

cjϕ(||(x, y) − (xj , yj)||), (10.101)

Page 331: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

316 Computational Partial Differential Equations Using MATLAB

where cj are the unknown coefficients to be determined, and ϕ(rj) is some kindof RBF [53, 5]. Here rj = ||(x, y)−(xj , yj)|| is the Euclidean distance betweenpoints (x, y) and (xj , yj). We denote {(xj , yj)}NI

1 the collocation points insidethe domain Ω, while {(xj , yj)}NI+Nd

NI+1 , {(xj , yj)}NI+Nd+Nn

NI+Nd+1 are the collocationpoints on the boundary ∂Ω for boundary conditions B1 and B2, respectively.Note that we use different nodes for imposing different types of boundaryconditions, even though they are all imposed on ∂Ω.

Substituting (10.101) into (10.98), (10.99), or (10.100), and making theequations hold true at the corresponding collocation points, we have

NXj=1

(Lϕ)(||(xi, yi) − (xj , yj)||)cj = 0, i = 1, 2, · · · , NI , (10.102)

NXj=1

(B1ϕ)(||(xi, yi) − (xj , yj)||)cj = f(xi, yi),

i = NI + 1, · · · , NI + Nd, (10.103)NX

j=1

(B2ϕ)(||(xi, yi) − (xj , yj)||)cj = g(xi, yi),

i = NI + Nd + 1, · · · , N. (10.104)

The resultant linear system (10.102)-(10.104) is solved for the unknowns{cj}Nj=1, where N = NI + Nd + Nn denotes the total number of collocationpoints.

Example 10.1Our first example is taken from [32, p. 441]: solve the equation ∇4ψ = 0 inthe unit square with the exact solution ψ = x2 + y2, and boundary conditionsψ and ∇2ψ imposed on the boundary ∂Ω. In [32] this problem was solved bythe method of fundamental solutions (MFS) and achieved accuracy of order10−4 in the maximum error for ψ.

Here we solved this problem by using 39×39 uniformly distributed interiornodes, 320 uniformly distributed nodes located on ∂Ω for imposing boundarycondition B1, and another 320 uniformly distributed nodes between B1 nodesfor satisfying boundary condition B2. Due to the density of this node distri-bution, a corresponding coarse 19× 19 node case is presented in Fig. 10.1 toillustrate how the collocation nodes are distributed. The obtained numericalsolution and corresponding maximum error for ψ are given in Fig. 10.2, whichshows clearly that our meshless method also produces accuracy comparableto [32].

Example 10.2Our second example is also taken from [32, p. 445] and solved there by MFS.

Page 332: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 317

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1interior nodeB

1 boundary node

B2 boundary node

FIGURE 10.1Example 1. The distribution of the collocation nodes for the case 19× 19.

[Reproduced from Fig. 1 of [42]. Copyright 2004. John Wiley & SonsLimited. Reproduced with permission.]

1

2 3

3

4

4

5

5

5

6

6

6

7

7

7

8

8

8

9

9

10

10

11

12

1415

X

Y

0 0.5 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Level Appr15 1.88E+0014 1.75E+0013 1.63E+0012 1.50E+0011 1.38E+0010 1.25E+009 1.13E+008 1.00E+007 8.75E-016 7.50E-015 6.25E-014 5.00E-013 3.75E-012 2.50E-011 1.25E-01

1

1

1

1

1

1

1

1

2

2

2

2

2 2

2

2

2

3

3

3

3

3

3

3

3

3

3

4

4

4

4

4

4

4

4

5

4

5

5

5

5

5

5

6

6

6

6

6

7

7

7

8

91113

X

Y

0 0.5 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Level Error15 8.18E-0514 7.64E-0513 7.09E-0512 6.55E-0511 6.00E-0510 5.46E-059 4.91E-058 4.36E-057 3.82E-056 3.27E-055 2.73E-054 2.18E-053 1.64E-052 1.09E-051 5.48E-06

FIGURE 10.2Example 1. (Left) numerical solution for ψ; (Right) the correspondingmaximum error. [Reproduced from Fig. 2 of [42]. Copyright 2004. JohnWiley & Sons Limited. Reproduced with permission.]

Page 333: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

318 Computational Partial Differential Equations Using MATLAB

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1interior nodeDirichlet boundary nodeNeumann boundary node

720 740 760 780 800 820 8400

0.5

1

1.5

2

2.5x 10

−6

FIGURE 10.3Example 2. (Left) the distribution of the collocation nodes; (Right) themaximum error on the domain boundary. [Reproduced from Fig. 3 of [42].Copyright 2004. John Wiley & Sons Limited. Reproduced with permission.]

This example considers the thin plate bending with clamped boundary condi-tion: more specifically we solve the equation ∇4ψ = 0 subject to the bound-ary conditions ψ = − (x2+y2)2

64 and ∂ψ∂n = − ∂

∂n ( (x2+y2)2

64 ). Here domain Ω is anellipse, whose semi-major axis and semi-minor axis are 1 and 0.8333, respec-tively. Note that the exact solution for this problem is unavailable.

We solved this problem by the RBF meshless method using 833 colloca-tion nodes (the first 735 are interior nodes, the remaining 98 are boundarynodes). The detailed nodal distribution is shown in Fig. 10.3 (Left). Thecorresponding maximum error for ψ along the domain boundary is shown inFig. 10.3 (Right), which shows clearly that our meshless method produces avery accurate solution.

The MATLAB code ellipse rbf.m is attached below.

%-------------------------------------------------------------% ellipse_rbf.m: solve the biharmonic problem over an ellipse.%% mod 1: uex=x^3+y^3;% mod 2: uex=0.5*(x*sin(x)*cosh(y)-x*cos(x)*sinh(y))% mod 3: uex=(x^2+y^2)/64;%-------------------------------------------------------------clear all;

Nc=49; % # of nodes in theta directionNr=16; % # of nodes in the radial direction

Page 334: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 319

NI=(Nr-1)*Nc; % # of interior nodes: one in the centerNd=Nc; % # of Diri BC nodes on the circleNn=Nc; % # of Neum Bc nodes on the circleNall=NI+Nd+Nn; % total # of collocation pointsNK=9; % the degree of the basis function r^NKMODEL=3; % indicator which model

dc=2*pi/Nc;Ra=1; Rb=0.8333; %semi-major, semi-minor of the ellipsedra=Ra/Nr; drb=Rb/Nr;

% generate the nodes: 1) inner; 2) Diri BC; 3) Neum BCfor j=1:Nc

for i=1:Nr-1% uniform gridra=i*dra; rb=i*drb;theta=(j-1)*dc;ij=(j-1)*(Nr-1)+i;XX(ij)=ra*cos(theta); YY(ij)=rb*sin(theta);XC(ij)=XX(ij); YC(ij)=YY(ij);

endend

% Diri BCfor j=1:Nd

theta=(j-1)*dc;ij=NI+j;XX(ij)=Ra*cos(theta); YY(ij)=Rb*sin(theta);XC(ij)=XX(ij); YC(ij)=YY(ij);

end

% Neum BCfor j=1:Nn

theta=(j-1)*dc+0.5*dc; % nodes between Diri BC nodesij=NI+Nd+j;XX(ij)=Ra*cos(theta); YY(ij)=Rb*sin(theta);XC(ij)=XX(ij); YC(ij)=YY(ij);

end

% form the coeff. matrix and HRSfor i=1:NI % inner nodes

rhs(i)=0;for j=1:Nall

Page 335: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

320 Computational Partial Differential Equations Using MATLAB

dist=sqrt((XX(i)-XC(j))^2+(YY(i)-YC(j))^2);matA(i,j)=(NK*(NK-2))^2*dist^(NK-4);

endend

for i=1:Nd % Diri BC nodesii=NI+i;if MODEL==1% mod 1rhs(ii)=XX(ii)^3+YY(ii)^3;

elseif MODEL==3rhs(ii)=-(XX(ii)^2+YY(ii)^2)^2/64;

elseif MODEL==2% mod 2rhs(ii)=0.5*XX(ii)*(sin(XX(ii))*cosh(YY(ii)) ...

-cos(XX(ii))*sinh(YY(ii)));end

for j=1:Nalldist=sqrt((XX(ii)-XC(j))^2+(YY(ii)-YC(j))^2);

matA(ii,j)=dist^NK;end

end

for i=1:Nn % Neum BC nodesii=NI+Nd+i;theta=(i-1)*dc+0.5*dc;dxdt=-Ra*sin(theta); dydt=Rb*cos(theta);% find the normal at this boundary nodeif abs(theta) < eps

cosc=1; sinc=0;elseif abs(theta-pi) < eps

cosc=-1; sinc=0;else

psi=atan(dydt/dxdt);cosc=sin(psi); sinc=cos(psi);

end

if MODEL==1% mod 1rhs(ii)=3*XX(ii)^2*cosc+3*YY(ii)^2*sinc; % du/dn

elseif MODEL==3xi=XX(ii); yi=YY(ii);t1=2*(xi^2+yi^2)/64*2*xi;t2=2*(xi^2+yi^2)/64*2*yi;

Page 336: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 321

rhs(ii)=-(t1*cosc+t2*sinc);elseif MODEL==2% mod 2xi=XX(ii); yi=YY(ii);c1=cosh(yi); s1=sinh(yi);t1=(xi*cos(xi)+sin(xi))*c1-(cos(xi)-xi*sin(xi))*s1;t2=xi*sin(xi)*s1-xi*cos(xi)*c1;rhs(ii)=0.5*(t1*cosc+t2*sinc);

endfor j=1:Nall

dist=sqrt((XX(ii)-XC(j))^2+(YY(ii)-YC(j))^2);phix=NK*dist^(NK-2)*(XX(ii)-XC(j));phiy=NK*dist^(NK-2)*(YY(ii)-YC(j));

matA(ii,j)=phix*cosc+phiy*sinc;end

end

% solve the linear systemu=matA\rhs’;

plot(XX(1:NI),YY(1:NI),’.’,... % interior nodeXX(NI+1:NI+Nd),YY(NI+1:NI+Nd),’s’,... % Diri nodeXX(NI+Nd+1:NI+Nd+Nn),YY(NI+Nd+1:NI+Nd+Nn),’o’); %Neum node

legend(’interior node’,’Dirichlet boundary node’,...’Neumann boundary node’);

fid=fopen(’V1.doc’,’w’); % save the results% get the numerical solution and compare with the exact one%for i=NI+1:Nall % model 3: only compare boundary errorsfor i=1:Nall

if MODEL==1% mod 1uex(i)=XX(i)^3+YY(i)^3; % exact solution

elseif MODEL==3uex(i)=-(XX(i)^2+YY(i)^2)^2/64;

elseif MODEL==2% mod 2uex(i)=0.5*XX(i)*(sin(XX(i))*cosh(YY(i))...

-cos(XX(i))*sinh(YY(i)));enduapp(i)=0;for j=1:Nall

dist=sqrt((XX(i)-XC(j))^2+(YY(i)-YC(j))^2);uapp(i)=uapp(i)+u(j)*dist^NK;

end

Page 337: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

322 Computational Partial Differential Equations Using MATLAB

err(i)=abs(uex(i)-uapp(i));if abs(uex(i)) > 1e-6

Rerr(i)=err(i)/abs(uex(i)); % relative errorelse

Rerr(i)=0;endfprintf(fid, ’%9.4f %9.4f %10.6e %10.6e %10.6e %10.6e\n’, ...

XX(i),YY(i),uapp(i),uex(i),err(i),Rerr(i));enddisp(’Nall=, max err, Relative err=’), ...

Nall, max(err), max(Rerr),% plot only the errors on the boundariesfigure(2),plot(NI+1:Nall,err(NI+1:Nall),’b-’, ...

NI+1:Nall,err(NI+1:Nall),’.’);status=fclose(fid);

10.6 Coupling RBF meshless methods with DDM

The resultant coefficient matrices from RBF meshless methods are highly ill-conditioned, which hinders the applicability of the RBF method to solve large-scale problems since the ill condition gets worse with increasing collocationpoints. Hence the domain decomposition method (DDM) can be used toreduce the condition number for the RBF meshless methods by decomposinga global large-domain problem into many small subdomain problems.

The earliest concept of the domain decomposition method was introducedas a classical Schwarz alternating algorithm by Schwarz in 1870, which pro-vided a fast and robust algorithm for solving the linear systems resulting fromdiscretizations of PDEs. With the development of modern supercomputers,DDM has become a common tool for solving linear systems of equations. Forthorough theory on DDM and its applications, readers can consult some re-view papers [6, 38], books [54, 57, 58], and the proceedings of the internationalconferences on DDM (see www.ddm.org).

However, coupling DDM with RBF meshless methods are very recent work.It seems that the earliest work in this direction is due to Dubal, who investi-gated DDM coupled with multiquadric function for one-dimensional problemsin [15]. Later, Hon and his collaborators applied DDM to higher-dimensionalproblems [62, 28, 43, 65]. Now, it has become a popular way to use coupledDDM and RBF to solve different PDEs [29, 44, 1, 13].

Below we describe the basic DDM for BRF meshless methods for a general

Page 338: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 323

steady-state problem in d-dimension (d = 1, 2, 3):

Lφ = f(�x) in Ω, Bu = g(�x) on ∂Ω, (10.105)

where L is an arbitrary differential operator, B is an operator imposed asboundary conditions, such as Dirichlet, Neumann, Robin, and mixing of them.

Let {Pi = (�xi)}Ni=1 be N collocation points in Ω, of which {(�xi)}NI

i=1 areinterior points; {(�xi)}Ni=NI+1 are boundary points. The approximate solutionfor the problem (10.105) can be expressed as

φ(�x) =N∑

j=1

φjϕj(�x), (10.106)

where {φj}Nj=1 are the unknown coefficients to be determined, and ϕj(�x) =ϕ(||P − Pj ||) can be any radial basis functions we discussed in previous sec-tions.

By substituting (10.106) into (10.105), we have

N∑

j=1

(Lϕj)(�xi)φj = f(�xi), i = 1, 2, · · · , NI , (10.107)

N∑

j=1

(Bϕj)(�xi)φj = g(�xi), i = NI + 1, NI + 2, · · · , N, (10.108)

which can be solved for the unknown coefficients {φj}Nj=1.

10.6.1 Overlapping DDM

Let Ω be partitioned into two subdomains Ω1 and Ω2, where Ω1

⋂Ω2 �= ∅.

The artificial boundaries Γi are the part of the boundary of Ωi that is interiorof Ω, the rest of the boundaries are denoted by ∂Ωi\Γi. We can solve theproblem on Ω by the classic additive Schwarz algorithm which can be writtenas

Lφn1 = f in Ω1

Bφn1 = g on ∂Ω1\Γ1

φn1 = φn−12 on Γ1

and

Lφn2 = f in Ω2

Bφn2 = g on ∂Ω2\Γ2

φn2 = φn−11 on Γ2

where on each subdomain, the numerical scheme is carried out as outlined inthe last section.

Page 339: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

324 Computational Partial Differential Equations Using MATLAB

The multiplicative Schwarz algorithm can be written as

Lφn1 = f in Ω1

Bφn1 = g on ∂Ω1\Γ1

φn1 = φn−12 on Γ1

and

Lφn2 = f in Ω2

Bφn2 = g on ∂Ω2\Γ2

φn2 = φn1 on Γ2

where subdomain 2 uses the newly obtained solution from subdomain 1 asthe artificial boundary condition, from which we can imagine that the multi-plicative version should converge faster than the additive version.

The generalization of the Schwarz method to many subdomains is straight-forward by coloring or grouping [57, 54].

10.6.2 Non-overlapping DDM

Let Ω be partitioned into two non-overlapping subdomains Ω1 and Ω2, whereΩ1

⋂Ω2 = ∅. The subdomain interface Γ = ∂Ω1

⋂∂Ω2.

Then the non-overlapping iteration algorithm (i.e., the so-called iterativesubstructuring method) can be written as

Lφn1 = f in Ω1

Bφn1 = g on ∂Ω1\Γφn1 = λn−1 on Γ

and

Lφn2 = f in Ω2

Bφn2 = g on ∂Ω2\Γ∂φn2∂nL

=∂φn−1

1

∂nLon Γ

whereλn|Γ = θλn−1|Γ + (1 − θ)φn2 |Γ, 0 < θ < 1,

and the conormal derivative ∂w∂nL

is defined as ∂w∂nL

= awxnx + bwyny.Here on the interface we use the Dirichlet-Neumann method. Other meth-

ods such as the Neumann-Neumann method and the Robin method can beconsidered similarly [54, Ch. 1].

Extensions to many subdomains of the Dirichlet-Neumann method can beachieved by using a black- and white- coloring, say Ω is decomposed into

Page 340: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 325

many subdomains Ωi, i = 1, · · · ,M. Denote Γij = ∂Ωi⋂∂Ωj the interface

between two adjacent subdomains Ωi and Ωj , the two groups of subdomainsare IB = {1 ≤ i ≤ M : Ωi is black} and Iw = {1 ≤ i ≤ M : Ωi is white}.The above algorithm becomes: solve

Lφni = f in Ωi, ∀ i ∈ IB

φni = θφn−1j + (1 − θ)φn−1

i on Γij , ∀ j ∈ IW : Γij �= 0

Then solve

Lφnj = f in Ωj , ∀ j ∈ IW

∂φnj∂nL

=∂φn−1

j

∂nLon Γij , ∀ i ∈ IB : Γij �= 0

This is the so-called block-parallel version [54, p. 25]. We can consider theblock-sequential version by using the newly obtained solution from IB as theinterface condition on the white subdomains.

10.6.3 One numerical example

Here we show one numerical example for DDM with RBF meshless methods.The example is from our published work [43]. Consider the Poisson problem

−�φ = xey in Ω,φ = −xey on ∂Ω.

This problem was used by Smith et al. [57, p. 8] to demonstrate the numericalconvergence of the Schwarz method on a nontrivial domain, which is a unionof a square and a circle. They used centered finite difference on the squareand piecewise linear finite elements on the circle. The number of iterationsand maximum error obtained on several meshes are presented in Table 10.4.

To compare with Smith et al.’s results, we used non-overlapping DDM witha uniform (Nx+1)× (Ny+1) grid on the square [0, 2]2, and a uniform radialgrid Nr×Nc on the circle which centered at (2, 2) and radius 1, where Nx+1, Ny+1 are the number of points in x and y directions,Nr,Nc are the numberof points in the radial and counterclockwise angle directions, respectively.Furthermore, we used a fixed error tolerance of 1.0×10−6, zero initial guess onthe artificial boundaries or the subdomain interfaces, and LU decompositionsolver. The number of iterations and maximum error obtained by our methodin both multiplicative and additive versions on several grid cases are presentedin Tables 10.5 and 10.6 ∗.

∗Tables 10.4-6 are reproduced from Table I-III of Numerical Methods for Partial Differen-tial Equations, Jichun Li and Y.C. Hon, Domain decomposition for radial basis meshlessmethods, Vol. 20, p. 450–462. Copyright 2004. John Wiley & Sons Limited. Reproducedwith permission.

Page 341: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

326 Computational Partial Differential Equations Using MATLAB

Tables 10.5 and 10.6 show that the number of iterations for the multiplica-tive Schwarz method is roughly half of that needed for the additive version.This phenomena have also been observed in our earlier work [65], and moreexamples were provided there. Note that such features are also observed forthe FEM domain decomposition method [57, p. 25] due to the fact that Gauss-Seidel (resp. Jacobi) algorithm is formally a multiplicative (resp. additive)Schwarz method [38, p. 134].

Comparing Tables 10.5-10.6 with Table 10.4, we can see that such an RBFDDM method is competitive with the classical DDM results obtained by Smithet al. Especially when we use 961 nodes on the square and 1081 nodes onthe circle, the accuracy for r5 is already better than Smith et al.’s accuracyachieved with 5329 nodes on the square and 2145 nodes on the circle. Theaccuracy for r7 is much higher than Smith et al.’s with much fewer nodalpoints.

To see more clearly, we plot a sample collocation grid of 11 × 11 on thesquare, and 10× 12 on the circle in Fig. 10.4 (Left). The convergence historyis plotted in Fig. 10.4 (Right) for both additive and multiplicative Schwarzmethods in the grid case of 31 × 31 on the square and 30 × 36 on the circle.Also the solution and pointwise error for this case are plotted in Fig. 10.5.

TABLE 10.4

Maximum error obtained by Smith et al.

No. of nodes Max. errorSquare Circle Square Circle Iter. steps

100 45 1.2 × 10−2 6.7 × 10−3 6361 153 3.1 × 10−3 2.2 × 10−3 61369 561 1.0 × 10−3 6.9 × 10−4 75329 2145 2.7 × 10−4 2.1 × 10−4 8

TABLE 10.5Maximum error obtained by our method with basis function r5: No. of nodes onsquare is (Nx + 1) × (Ny + 1), No. of nodes on circle is Nr × Nc + 1

No. of nodes Max. error Iter. steps Iter. stepsSquare Circle Square Circle additive multiplicative

112 = 121 121 1.22 × 10−2 1.79 × 10−2 15 10212 = 441 481 6.10 × 10−4 1.06 × 10−3 17 10212 = 441 721 5.37 × 10−4 8.80 × 10−4 17 10312 = 961 1081 1.14 × 10−4 2.09 × 10−4 17 10

Page 342: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 327

X

Y

0 1 2 3

0

0.5

1

1.5

2

2.5

3

Iteration Steps

Ma

xE

rro

ro

nA

rtific

ialB

ou

nd

ari

es

2 4 6 8 10 12 14 16 18 20

10-6

10-5

10-4

10-3

10-2

10-1

100

101

Multiplicative SchwarzAdditive Schwarz

FIGURE 10.4(Left) sample collocation grid; (Right) convergence history. [Reproduced

from Fig. 1 of [43]. Copyright 2004. John Wiley & Sons Limited. Reproducedwith permission.]

TABLE 10.6Maximum error obtained by our method with basis function r7: No. of nodeson square is (Nx + 1) × (Ny + 1), No. of nodes on circle is Nr × Nc + 1

No. of nodes Max. error Iter. steps Iter. stepsSquare Circle Square Circle additive multiplicative

112 = 121 121 5.17 × 10−3 8.19 × 10−3 15 10212 = 441 481 1.36 × 10−4 2.21 × 10−4 17 10

212441 721 1.69 × 10−4 2.43 × 10−4 17 10312 = 961 1081 2.17 × 10−5 3.11 × 10−5 17 10

10.7 Bibliographical remarks

The recent book by Fasshauer [19] provides an elementary introduction toRBFs and many MATLAB codes are provided for RBF interpolations andsolving PDEs. Due to the nice meshless property, recently RBFs have beenused in solving inverse problems. Readers can find more details in papers suchas [10, 14, 26, 27, 41, 41].

Page 343: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

328 Computational Partial Differential Equations Using MATLAB

13

14

15

1

456

7

89

9

10111213

14

X

Y

0 1 2 3

0

0.5

1

1.5

2

2.5

3

Level Appr15 -2.7714 -5.5413 -8.3012 -11.0711 -13.8410 -16.619 -19.388 -22.147 -24.916 -27.685 -30.454 -33.223 -35.982 -38.751 -41.52

1

1

1

1

1

2

2

2

22

3 4

15 9

1211

10

8 8

1

11

2

22

3

33

4

4

4

4

4

5

5 5

5

55 5

5

6

6

66

6 6

6

6

67

7

7

7

7

7

7

8 8

8

89

9

9

9

10

10

10

11

11

11

12

13

1314

15

X

Y

0 1 2 3

0

0.5

1

1.5

2

2.5

3

Level Err15 2.97E-0514 2.77E-0513 2.57E-0512 2.37E-0511 2.18E-0510 1.98E-059 1.78E-058 1.58E-057 1.38E-056 1.19E-055 9.89E-064 7.91E-063 5.94E-062 3.96E-061 1.98E-06

FIGURE 10.5(Left) numerical solution; (Right) pointwise error. [Reproduced from

Fig. 2 of [43]. Copyright 2004. John Wiley & Sons Limited. Reproduced withpermission.]

10.8 Exercises

1. Given φ = 1+ r, where r =√x2 + y2. Prove that Φ = r3

9 + r2

4 satisfies theequation �Φ = φ.

2. Let the thin-plate spline φ = r2 ln r, where r =√x2 + y2. Prove that

Φ = r4 ln r16 − r4

32 satisfies the equation �Φ = φ.3. Implement the RBF-MFS method to solve the Poisson’s equation

∂2u

∂x2+∂2u

∂y2= 2ex−y, (x, y) ∈ Ω,

u(x, y) = ex−y + ex cos y, (x, y) ∈ ∂Ω,

where Ω is the oval of Cassini [22] described by the parametric equation equa-tions

x = r(θ) cos θ, y = r(θ) sin θ, r(θ) =√

cos 2θ +√

1.1 − sin2 2θ, 0 ≤ θ ≤ 2π.

You can use MQ or other RBFs. Note that the exact solution is given byu(x, y) = ex−y + ex cos y.

4. Prove that in polar coordinates the 2-D Laplacian operator� ≡ ∂2

∂x2 + ∂2

∂y2

becomesd2

dr2+

1r

d

dr+

1r2

d2

dθ2,

Page 344: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 329

i.e., uxx + uyy = urr + 1rur + 1

r2uθθ.

5. Recall that the gamma function Γ(x) =∫∞0 tx−1e−tdt. Prove that Γ(x+

1) = xΓ(x) and Γ(12 ) =

√π.

6. Let y = xα∑∞

n=0 anxn be the solution of Bessel’s equation (10.18). Show

thata1 = a3 = a5 = · · · = 0

and

a2k(α) =(−1)k

22kk!(k + α)(k − 1 + α) · · · (1 + α)a0 =

(−1)kΓ(1 + α)22kk!Γ(k + α+ 1)

a0, k = 1, 2, · · · .

7. Prove thatd

dx[xαJα(x)] = xαJα−1(x)

andd

dx[x−αJα(x)] = −x−αJα+1(x).

8. Show that the 3-D Laplace’s equation can be transformed to

1r2

[(r2ur)r +1

sinφ(uφ sinφ)φ +

1sin2 φ

uθθ] = 0

under spherical coordinates.9. Show that the general radial solution to the 3-D modified Hemholtz

equation (�− λ2)u = 0 is given by

u =c

rexp(−λr).

References

[1] H. Adibi and J. Es’haghi. Numerical solution for biharmonic equationusing multilevel radial basis functions and domain decomposition meth-ods. Appl. Math. Comput., 186(1):246–255, 2007.

[2] R.K. Beatson and M.J.D. Powell. Univariate interpolation on a regularfinite grid by a multiquadric plus a linear polynomial. IMA J. Numer.Anal., 12:107–133, 1992.

[3] M.D. Buhmann. Radial functions on compact support. Proc. EdinburghMath. Soc. (2), 41(1):33–46, 1998.

[4] M.D. Buhmann. Radial basis functions. Acta Numerica, 9:1–38, 2000.

[5] M.D. Buhmann. Radial Basis Functions: Theory and Implementations.Cambridge University Press, Cambridge, UK, 2003.

Page 345: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

330 Computational Partial Differential Equations Using MATLAB

[6] T.F. Chan and T.P. Mathew. Domain decomposition algorithms. ActaNumerica, 3:61–143, 1994.

[7] C.S. Chen, C.A. Brebbia and H. Power. Dual reciprocity method usingcompactly supported radial basis functions. Commun. Numer. Mech.Engrg., 15:137–150, 1999.

[8] C.S. Chen and Y.F. Rashed. Evaluation of thin plate spline based par-ticular solutions for Helmholtz-type operators for the DRM. Mech. Res.Comm., 25:195–201, 1998.

[9] W. Chen and M. Tanaka. A meshless, integration-free, and boundary-only RBF technique. Comp. Math. Appl., 43:379–391, 2002.

[10] A.H.-D. Cheng and J. Cabral. Direct solution of ill-posed boundaryvalue problems by radial basis function collocation method. Internat. J.Numer. Methods Engrg., 64(1):45–64, 2005.

[11] A.H.-D. Cheng, O. Lafe and S. Grilli. Dual reciprocity BEM based onglobal interpolation functions. Eng. Anal. Boundary Elements, 13:303–311, 1994.

[12] R.S.C. Cheng. Delta-Trigonometric and Spline Methods Using theSingle-Layer Potential Representation. Ph.D. dissertation, Universityof Maryland, 1987.

[13] P.P. Chinchapatnam, K. Djidjeli and P.B. Nair. Domain decomposi-tion for time-dependent problems using radial based meshless methods.Numer. Methods Partial Differential Equations, 23(1):38–59, 2007.

[14] M. Dehghan and M. Tatari. The radial basis functions method for iden-tifying an unknown parameter in a parabolic equation with overspecifieddata. Numer. Methods for Partial Differential Equations, 23(5):984–997,2007.

[15] M.R. Dubal. Domain decomposition and local refinement for multi-quadric approximations. J. Appl. Sci. Comput., 1(1):146–171, 1994.

[16] J. Duchon. Splines minimizing rotation-invariant semi-norms in Sobolevspaces. Constructive Theory of Functions of Several Variables. (Proc.Conf., Math. Res. Inst., Oberwolfach, 1976), pp. 85–100. Lecture Notesin Math., Vol. 571, Springer, Berlin, 1977.

[17] G. Fairweather and A. Karageorghis. The method of fundamental so-lutions for elliptic boundary value problems. Adv. Comput. Math., 9(1-2):69–95, 1998.

[18] G.E. Fasshauer. Solving partial differential equations by collocation withradial basis functions, in Proceedings of Chamonix 1996 (eds. by A. LeMehaute, C. Rabut and L.L. Schumaker), p. 131–138, Vanderbilt Uni-versity Press, Nashville, TN, 1997.

Page 346: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 331

[19] G.E. Fasshauer. Meshfree Approximation Methods with MATLAB.World Scientific Publishers, Singapore, 2007.

[20] C. Franke and R. Schback. Convergence order estimates of meshlesscollocation methods using radial basis functions. Adv. Comput. Math.,8(4):381–399, 1998.

[21] M.A. Golberg. The numerical evaluation of particular solutions in theBEM – a review. Boundary Elems. Comm., 6:99–106, 1995.

[22] M.A. Golberg and C.S. Chen. A bibliography on radial basis functionapproximation. Boundary Elems. Comm., 7:155–163, 1996.

[23] M.A. Golberg and C.S. Chen. Discrete Projection Methods for IntegralEquations. Computational Mechanics Publications, Southampton, UK,1997.

[24] M.A. Golberg and C.S. Chen. The method of fundamental solutionsfor potential, Helmholtz and diffusion problems, in Boundary InetgralMethods – Numerical and Mathematical Aspects, M.A. Golberg (Ed.),Computational Mechanics Publications, Southampton, UK, pp. 103–176, 1998.

[25] M.A. Golberg, C.S. Chen and M. Ganesh. Particular solutions of 3DHelmholtz-type equations using compactly supported radial basis func-tions. Eng. Anal. with Boundary Elements, 24(7-8):539–548, 2000.

[26] Y.C. Hon and T. Wei. A fundamental solution method for inverse heatconduction problems. Eng. Anal. with Boundary Elements, 28(5):489–495, 2004.

[27] Y.C. Hon and Z. Wu. A numerical computation for inverse determinationproblem. Eng. Anal. with Boundary Elements, 24(78):599–606, 2000.

[28] Y.C. Hon and Z. Wu. Additive Schwarz domain decomposition with aradial basis approximation. Int. J. Appl. Math., 4(1):81–98, 2000.

[29] M.S. Ingber, C.S. Chen and J.A. Tanski. A mesh free approach us-ing radial basis functions and parallel domain decomposition for solvingthree-dimensional diffusion equations. Int. J. Numer. Methods Engrg.,60(13):2183–2201, 2004.

[30] R.L. Johnston and G. Fairweather. The method of fundamental solutionsfor problems in potential flow. Applied Mathematical Modelling, 8:265–270, 1984.

[31] E.J. Kansa. Multiquatric – A scattered data approximation scheme withapplications to computational fluid dynamics II. Comp. Math. Appl.,19(8-9):147–161, 1990.

Page 347: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

332 Computational Partial Differential Equations Using MATLAB

[32] A. Karageorghis and G. Fairweather. The method of fundamental solu-tions for the numerical solution of the biharmonic equation. J. Comp.Phys., 69:434–459, 1987.

[33] M. Kogl and L. Gaul. Dual reciprocity boundary element method forthree-dimensional problems of dynamic piezoelectricity. Boundary Ele-ments XXI, 537-548, Southampton, UK, 1999.

[34] M. Katsurada and H. Okamoto. A mathematical study of the chargesimulation method. Journal of the Faculty of Science, University ofTokyo, Section 1A, 35:507–518, 1988.

[35] M. Katsurada and H. Okamoto. The collocation points of the funda-mental solution method for the potential problem. Comp. Math. Appl.,31:123–137, 1996.

[36] V.D. Kupradze and M.A. Aaleksidze. The method of functional equa-tions for the approximate solution of certain boundary value problems.U.S.S.R. Computational Mathematics and Mathematical Physics, 4:82–126, 1964.

[37] A. La Rocca, A. Hernandez Rosales and H. Power. Radial basis functionHermite collocation approach for the solution of time dependent convec-tion diffusion problems. Eng. Anal. with Boundary Elements, 29(4):359–370, 2005.

[38] P. Le Tallec. Domain decomposition methods in computational mechan-ics. Comput. Mech. Adv., 1:121–220, 1994.

[39] V.M.A. Leitao. A meshless method for Kirchhoff plate bending prob-lems. Int. J. Numer. Meth. Engng., 52:1107–1130, 2001.

[40] J. Levesley. Pointwise estimates for multivariate interpolation using con-ditionally positive definite functions. Approximation Theory, Waveletsand Applications (Maratea, 1994), 381–401, NATO Adv. Sci. Inst. Ser.C Math. Phys. Sci., 454, Kluwer Acad. Publ., Dordrecht, 1995.

[41] J. Li. A radial basis meshless method for solving inverse boundary valueproblems. Comm. Numer. Methods Engrg., 20(1):51–61, 2004.

[42] J. Li. Application of radial basis meshless methods to direct and inversebiharmonic boundary value problems. Comm. Numer. Methods Engrg.,21(4):169–182, 2005.

[43] J. Li and Y.C. Hon. Domain decomposition for radial basis meshlessmethods. Numer. Methods Partial Differential Equations, 20(3):450–462, 2004.

[44] L. Ling and E.J. Kansa. Preconditioning for radial basis func-tions with domain decomposition methods. Math. Comput. Modelling,40(13):1413–1427, 2004.

Page 348: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Meshless Methods with Radial Basis Functions 333

[45] W.R. Madych. Miscellaneous error bounds for multiquadric and relatedinterpolators. Comput. Math. Appl., 24:121–138, 1992.

[46] A.S. Muleshkov, C.S. Chen, M.A. Golberg and A.H-D. Cheng. Ana-lytic particular solutions for inhomogeneous Helmholtz-type equations.Advances in Computational Engineering & Sciences, S.N. Atluri, F.W.Brust (eds), Tech Science Press, CA, Vol.1, pp. 27–32, 2000.

[47] A.S. Muleshkov, M.A. Golberg and C.S. Chen. Particular solutionsof Helmholtz-type operators using higher order polyharmonic splines.Computational Mechanics, 23:411–419, 1999.

[48] F.J. Narcowich and J.D. Ward. Generalized Hermite interpolation viamatrix-valued conditionally positive definite functions. Math. Comp.,63:661–687, 1994.

[49] D. Nardini and C.A. Brebbia. A new approach to free vibration analysisusing boundary elements, in Boundary Element Methods in Engineering,C.A. Brebbia (Ed.), Springer-Verlag, Berlin, 1982.

[50] P.W. Partridge, C.A. Brebbia and L.C. Wrobel. The Dual ReciprocityBoundary Element Method. Computational Mechanics Publications,London, 1992.

[51] P.W. Partridge and B. Sensale. The method of fundamental solutionswith dual reciprocity for diffusion and diffusion-convection using subdo-mains. Eng. Anal. with Boundary Elements, 24:633–641, 2000.

[52] M.J.D. Powell. The uniform convergence of thin plate spline interpola-tion in two dimensions. Numer. Math., 68:107–128, 1994.

[53] M.J.D. Powell. The theory of radial basis function approximation in1990. Advances in Numerical Analysis, Vol. II (Lancaster, 1990), 105–210, Oxford Univ. Press, New York, 1992.

[54] A. Quarteroni and A. Valli. Domain Decomposition Methods for PartialDifferential Equations. Oxford Science Publications, Oxford, UK, 1999.

[55] R. Schaback. Improved error bounds for scattered data interpolation byradial basis functions. Math. Comp., 68:201–216, 1999.

[56] R. Schaback and H. Wendland. Kernel techniques: from machine learn-ing to meshless methods. Acta Numerica, 15:543–639, 2006.

[57] B. Smith and P. Bjorstad and W. Gropp. Domain Decomposition, Par-allel Multilevel Methods for Elliptic Partial Differential Equations. Cam-bridge University Press, Cambridge, UK, 1996.

[58] A. Toselli and O. Widlund. Domain Decomposition Methods – Algo-rithms and Theory. Springer, New York, 2004.

Page 349: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

334 Computational Partial Differential Equations Using MATLAB

[59] H. Wendland. Piecewise polynomial, positive definite and compactlysupported radial functions of minimal degree. Adv. Comput. Math.,4:389–396, 1995.

[60] H. Wendland. Error estimates for interpolation by compactly supportedradial basis functions of minimal degree. J. Approx. Theory, 93:258–272,1998.

[61] H. Wendland. Scattered Data Approximation. Cambridge UniversityPress, Cambridge, UK, 2005.

[62] A.S.M. Wong, Y.C. Hon, T.S. Li, S.L. Chung and E.J. Kansa. Mul-tizone decomposition for simulation of time-dependent problems usingthe multiquadric scheme. Comput. Math. Appl., 37(8):23–43, 1999.

[63] Z. Wu. Hermite-Birkhoff interpolation of scattered data by radial basisfunctions. Approx. Theory Appl., 8:1–10, 1992.

[64] Z. Wu. Multivariate compactly supported positive definite radial func-tions. Adv. Comput. Math., 4:283–292, 1995.

[65] X. Zhou, Y.C. Hon and J. Li. Overlapping domain decompositionmethod by radial basis functions. Appl. Numer. Math., 44(1-2):241–255,2003.

[66] S. Zhu and P. Satravaha and X. Lu. Solving linear diffusion equationswith the dual reciprocity method in Laplace space. Eng. Anal. withBoundary Elements, 13:1–10, 1994.

Page 350: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

11

Other Meshless Methods

In this chapter, we introduce some so-called Galerkin-based meshless methods.First, in Sec. 11.1, we focus on how to construct meshless shape functions.Then we introduce the element-free Galerkin method in Sec. 11.2, which isfollowed by the meshless local Petrov-Galerkin methods in Sec. 11.3.

11.1 Construction of meshless shape functions

In meshless methods, the shape functions are constructed for each node basedon its selected local neighboring nodes. The construction does not depend onany fixed relation between nodes, which can be randomly distributed. In thissection we discuss several popular techniques for constructing meshless shapefunctions.

11.1.1 The smooth particle hydrodynamics method

The smooth particle hydrodynamics (SPH) method [11, 18, 19] is claimed to bethe oldest meshless method [7]. The basic idea of this method is approximatinga function u(x) on a domain Ω by

uh(x) ≈∫

Ω

wh(|x− y|)u(y)dΩy (11.1)

≈∑

I

wh(|x− xI |)uI�VI , (11.2)

where wh(·) is a weight function, h is a measure of the support size of theweight function, uI ≡ u(xI),�VI is the domain volume surrounding node I,|x − xI | denotes the Euclidean distance between node x and node xI . Theweight function usually satisfies the following properties:(a) wh(|x− y|) ≥ 0 has a compact support, i.e., zero outside of |x− y| > γh,where γ is a scaling factor;(b) the normality condition:

∫Ωwh(|x|)dx = 1;

(c) wh(|x|) → δ(|x|) as h→ 0, where δ is the Dirac delta function.Three commonly used weight functions are the Gaussian function, the cubic

spline, and the quartic spline. Let r = |x|, s = rh , we have:

335

Page 351: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

336 Computational Partial Differential Equations Using MATLAB

Gaussian: wh(r) ={Cd

hd exp(−s2), if 0 ≤ s ≤ 1,0 if s > 1,

where 1 ≤ d ≤ 3 is the spatial dimension, Cd = 1πd/2 .

Cubic spline: wh(r) = Cd

hd

⎧⎨

1 − 32s

2 + 34s

3, if 0 ≤ s < 1,14 (2 − s)3, if 1 ≤ s ≤ 2,

0 if s > 2,where the normality constant Cd = 2

3 ,107π and 1

π for one, two, and threedimensions, respectively.

Quartic spline: wh(r) = Cd

hd

{1 − 6s2 + 8s3 − 3s4, if 0 ≤ s ≤ 1,

0 if s > 1,where Cd = 5

4 ,5π and 105

16π for one, two, and three dimensions, respectively.

Example 11.1Prove that for the cubic spline, the normality constant Cd = 2

3 ,107π and 1

π forone, two, and three dimensions, respectively.

Proof. In one-dimensional space, by the normality condition, we have

1 =2Cdh

{∫ h

0

[1 − 32(r

h)2 +

34(r

h)3]dr +

∫ 2h

h

14(2 − r

h)3dr}

= 2Cd{∫ 1

0

(1 − 32s2 +

34s3)ds+

∫ 2

1

14(2 − s)3ds} = 2Cd · 3

4,

which leads to Cd = 23 .

In two-dimensional space, the normality condition becomes

1 =Cdh2

{∫ h

0

[1 − 32(r

h)2 +

34(r

h)3]2πrdr +

∫ 2h

h

14(2 − r

h)32πrdr}

= Cd{∫ 1

0

(1 − 32s2 +

34s3)2πsds+

∫ 2

1

14(2 − s)32πsds}

= πCd{(s2 − 34s4 +

310s5)|1s=0 + (2s2 − 2s3 +

34s4 − 1

10s5)|2s=1},

from which we obtain Cd = 107π .

Similarly, in three-dimensional space, using the normality condition

1 =Cdh3

{∫ h

0

[1 − 32(r

h)2 +

34(r

h)3]4πr2dr +

∫ 2h

h

14(2 − r

h)34πr2dr},

we have Cd = 1π .

In terms of finite element methods, we can rewrite (11.2) as

uh(x) ≈∑

I

uIφI(x),

where φI(x) = wh(|x− xI |)�VI are the SPH shape functions.

Page 352: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Other Meshless Methods 337

11.1.2 The moving least-square approximation

Another approach for developing a meshless shape function is to use a movingleast-square (MLS) approximation [13], which originates from data fitting.

In the MLS approximation, we define a local approximation to u(x) at anypoint xI by

uh(x,x) =m∑

i=1

pi(x)ai(x), (11.3)

where m is the number of terms in the basis functions pi(x). The unknowncoefficients ai(x) are obtained by minimizing the difference between the localapproximation (11.3) and the function u(x), i.e.,

J =n∑

I=1

w(|x− xI |)|uh(xI ,x) − u(xI)|2

=n∑

I=1

w(|x− xI |)[∑

i

pi(xI)ai(x) − uI ]2.

Here w(|x−xI |) is a weight function with compact support such as that usedin SPH, and n is the number of nodes in the neighborhood of x, for whichthe weight function w(|x− xI |) �= 0.

The coefficients a(x) can be found by

0 =∂J

∂aj= 2

n∑

I=1

w(|x− xI |)(∑

i

pi(xI)ai(x) − uI)pj(xI), j = 1, · · · ,m,

i.e.,A(x)a(x) = B(x)u, (11.4)

where we denote

A(x) =n∑

I=1

w(|x − xI |)p(xI)pT (xI),

B(x) = [w(|x− x1|)p(x1), · · · , w(|x− xn|)p(xn)],

where pT (x) = (p1(x), · · · , pm(x)).Substituting (11.4) into (11.3), we obtain the MLS approximation

uh(x) =m∑

i=1

pi(x)(A−1(x)B(x)u)i =n∑

I=1

ΦI(x)uI , (11.5)

where ΦI(x) = pT (x)A−1(x)w(|x − xI |)p(xI). The m × m matrix A(x)is often called the moment matrix, which has to be inverted whenever theMLS shape functions are to be evaluated. It should be noted that shapefunctions ΦI do not satisfy the Kronecker delta criterion: ΦI(xJ ) �= δIJ .

Page 353: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

338 Computational Partial Differential Equations Using MATLAB

Hence uh(xJ) �= uJ . This property makes the imposition of essential boundaryconditions more complicated than the traditional finite element method.

Examples of commonly used basis p(x) in two dimensions are:Linear basis: pT (x) = (1, x, y), in which case m = 3;Quadratic basis: pT (x) = (1, x, y, x2, y2, xy), in which case m = 6.If a zero-order basis p(x) = 1 is used, then the MLS shape function becomes

Φ0I(x) = w(|x− xI |)/

n∑

I=1

w(|x− xI |), (11.6)

which is the Shepard function.

11.1.3 The partition of unity method

The essense of the partition of unity method (PUM) [6, 5] is to take a partitionof unity and multiply it by some local basis approximating the exact solutionof the underlying partial differential equations. Hence this method can bemore efficient than the usual finite element methods, when the users havesome prior knowledge about the underlying problem.

DEFINITION 11.1 Let Ω ⊂ Rd be an open set, {Ωi} be an open coverof Ω satisfying a pointwise overlap condition: there exists a positive integerM such that for any x ∈ Ω,

card{ i : x ∈ Ωi} ≤M.

Furthermore, let {φi} be a Lipschitz partition of unity subordinate to the cover{Ωi} satisfying

supp(φi) ⊂ closure(Ωi), ∀ i ∈ Λ,∑

i∈Λ

φi = 1, ∀ x ∈ Ω,

||φi||L∞(Rd) ≤ C∞,||∇φi||L∞(Rd) ≤ Cg/diam(Ωi),

where C∞ and Cg are two constants. Then {φi} is called a (M,C∞, Cg)partition of unity [6] subordinate to the cover {Ωi}. If {φi} ⊂ Cm(Rd), thenthe partition of unity {φi} is said to be of degree m. The covering sets {Ωi}are called patches.

Below we present some one-dimensional partition of unity on the interval(0, 1). Considering patches Ωi = (xi−1, xi+1), i = 0, 1, · · · , n, where the meshsize h = 1

n , xi = ih, i = 0, · · · , n. Furthermore, we denote x−1 = −h, xn+1 =1 + h.

Page 354: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Other Meshless Methods 339

Example 11.2Let the usual piecewise linear hat function

φ(x) =

⎧⎨

1 + xh , if x ∈ (−h, 0],

1 − xh , if x ∈ (0, h),

0 elsewhere.

Then φi(x) = φ(x− xi), i = 0, · · · , n, form a partition of unity subordinate tothe cover {Ωi}.

Example 11.3A partition of unity of higher regularity can be constructed similarly. Considera C1 function

φ(x) =1h3

⎧⎨

(x+ h)2(h− 2x), if x ∈ (−h, 0],(h− x)2(h+ 2x), if x ∈ (0, h),

0 elsewhere.

Then φi(x) = φ(x− xi), i = 0, · · · , n, form a partition of unity subordinate tothe cover {Ωi}.

Example 11.4Let Ωi be any cover of Ω satisfying an overlap condition (i.e., no more thanM patches overlap in any given point x ∈ Ω). Let wj be Lipschitz continuousfunctions with support Ωj . Then the Shepard function

φj(x) = wj(x)/∑

i

wi(x)

forms a partition of unity subordinate to the cover {Ωi}.

As we mentioned earlier, in the partition of unity method, some prior in-formation about the underlying problem is used for the approximation. Forexample, for the one-dimensional Helmholtz equation

−u′′+ k2u = f, on (0, 1), (11.7)

Babuska and Melenk [6] introduced the approximation

uh(x) =N∑

I=1

Φ0I(x)(a0I + a1Ix+ · · · + amIx

m + b1I sinh kx+ b2I coshkx)

=N∑

I=1

Φ0I(x)

i

βiIpi(x),

where Φ0I(x) is the Shepard function (11.6), and

βiI = [a0I , · · · , amI , b1I , b2I ],

Page 355: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

340 Computational Partial Differential Equations Using MATLAB

pT (x) = [1, x, · · · , xm, sinhkx, cosh kx].

Note that sinh kx and coshkx are the fundamental solution of (11.7). Theunknown coefficients can be determined by a Galerkin procedure.

Babuska and Melenk [6] also introduced a more general approximation

uh(x) =N∑

I=1

Φ0I(x)(

J

aJLJI(x))

=∑

J

I:xJ∈ΩI

Φ0I(x)LJI(x)aJ ,

where LJI(x) are the Lagrange interpolants (i.e., LJI(xk) = δIK for any J),and aJ is the approximate value associated with node xJ .

Duarte and Oden [10] used the partition of unity concept in a more generalmanner and constructed an approximation as

uh(x) =N∑

I=1

ΦkI (x)(uI +m∑

j=1

bjIqj(x)),

where the extrinsic basis qj(x) is a monomial basis of any order greater thank, and ΦkI (x) is the MLS shape function of order k.

11.2 The element-free Galerkin method

Let us consider a two-dimensional elastostatic problem on the domain Ωbounded by Γ:

∇ · σ + b = 0 in Ω, (11.8)

subject to the boundary conditions

σ · n = t on Γt, (11.9)u = u on Γu, (11.10)

where σ is the stress tensor, b is the body force, u is the displacement field,n is the unit outward normal to Γ ≡ Γt ∪ Γu,Γt ∩ Γu = 0, t and u are givenboundary values. More specifically, the governing equations for elastostaticscan be rewritten using components as:

σij,j + bi = 0 in Ω, (11.11)ti ≡ σijnj = ti on Γt, (11.12)ui = ui on Γu, (11.13)

Page 356: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Other Meshless Methods 341

where a subscript comma denotes the spatial derivative. Furthermore, wedenote

σij(u) = Cijklεkl(u), εkl(u) =12(uk,l + ul,k) =

12(∂uk∂xl

+∂ul∂xk

). (11.14)

Multiplying (11.8) by test function v and using integration by parts, weobtain ∫

Γ

viσijnjdΓ −∫

Ω

σijvi,jdΩ +∫

Ω

vibidΩ = 0. (11.15)

Noting that σij = σji, we have

σijvi,j = σij12(vi,j + vj,i) = σij(u)εij(u) = Cijklεklεij , (11.16)

where in the last step we used the constitutive law (11.14).Substituting (11.16) and the boundary condition (11.12) into (11.15), we

have ∫

Ω

εT (u)Cε(v)dΩ =∫

Γ

t · vdΓ +∫

Ω

b · vdΩ. (11.17)

The essential boundary condition (11.13) can be imposed using the La-grange multiplier method, which leads to∫

Ω

εT (u)Cε(v)dΩ =∫

Γ

t · vdΓ +∫

Ω

b · vdΩ +∫

Γu

δλ · (u − u)dΓ +∫

Γu

v · λ,(11.18)

where the Lagrange multiplier λ is expressed by

λ(x) = Ni(s)λi, δλ(x) = Ni(s)δλi, x ∈ Γu, (11.19)

where Ni(s) denotes a Lagrange interpolant and s is the arc length along theboundary Γu.

Substituting the approximate solution

uh(x) =∑

J

uJφJ(x)

and the test function φI(x) into (11.18), we obtain the final discrete equationof (11.18): [

K GGT 0

] [uλ

]=[fq

],

where

KIJ =∫

Ω

BTI CBJdΩ, GIJ = −∫

Γu

φINJdΓ,

fI =∫

Γt

φI tdΓ +∫

Ω

φIbdΩ, qJ = −∫

Γu

NjudΓ,

BI =

⎣φI,x 00 φI,yφI,y φI,x

⎦ , NJ =[NI 00 NJ

], C =

E

1 − ν2

⎣1 ν 0ν 1 00 0 1−ν

2

⎦ .

Page 357: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

342 Computational Partial Differential Equations Using MATLAB

Here our C is for plane stress, E and ν are Young’s modulus and Poisson’sratio.

The implementation of the element-free Galerkin (EFG) method is basicallysimilar to the classic finite element method. The basic procedure using EFGto solve the model problem (11.8)-(11.10) is as follows [9]:

1. Define the given physical parameters.2. Create the nodal coordinates of the physical domain.3. Create the domain of influence for each node.4. Build a background mesh for performing numerical integration.5. Set up Gauss points, weights, and Jacobian for each mesh cell.6. Loop over all Gauss points:

• Locate all nodes in the neighborhood of the Gauss point.• Calculate the weight functions, shape functions, and derivatives of the

shape functions.• Calculate matrices B and K.

7. Locate both truncation and essential boundary nodes.8. Create Gauss points along the traction and essential boundaries.9. Integrate over the traction boundary to form vector f .10. Integrate over the essential boundary to form matrix G and vector q.11. Solve for uI .12. Postprocess to compare exact and analytical stresses at quadrature points.

A very clearly explained MATLAB code for solving the model problem(11.8)-(11.9) is provided in the paper by Dolbow and Belytschko [9].

11.3 The meshless local Petrov-Galerkin method

In 1998, Atluri and Zhu [3, 4] developed the meshless local Petrov-Galerkin(MLPG) method, which does not require a background mesh for integration.To illustrate the method, let us first consider the Poisson’s equation

∇2u(x) = f(x) x ∈ Ω ⊂ R2, (11.20)

where f is a given source function, the domain Ω is enclosed by boundaryΓ = ΓD ∪ ΓN with boundary conditions

u(x) = u(x) on ΓD, (11.21)

q ≡ ∂u

∂n= q on ΓN , (11.22)

where u and q are the prescribed potential and normal flux, respectively, andn is the unit outward normal to Γ.

Page 358: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Other Meshless Methods 343

Multiplying (11.20) by a test function v and integrating by parts over alocal subdomain Ωs, we obtain

Ωs

(u,iv,i + fv)dΩ −∫

∂Ωs

∂u

∂nvdΓ + α

ΓD

(u− u)vdΓ = 0, (11.23)

where we impose the Dirichlet boundary condition (11.21) by the penaltymethod, and α is a penalty parameter.

Splitting the boundary ∂Ωs = ΓsD ∪ ΓsN , we can obtain the local weakformulation

Ωs

u,iv,idΩ −∫

ΓsD

∂u

∂nvdΓ + α

ΓD

uvdΓ

= −∫

Ωs

fvdΩ +∫

ΓsN

qvdΓ + α

ΓD

uvdΓ. (11.24)

Note that the subdomains Ωs in a 2-D problem is usually chosen as a circle,an ellipse, or a rectangle, while for a 3-D problem, Ωs is chosen as a sphere,an ellipsoid, or a cube. In the MLPG method, the trial function and thetest function are chosen differently and they may be MLS, PUM, the Shepardfunction, or even radial basis functions.

Substituting the approximate solution

uh(x) =M∑

J=1

φJ (x)uJ , (11.25)

and test function v = v(x,xI) into (11.24), we obtain the system of linearequations

Ku = f, (11.26)

where the matrix element

KIJ =∫

Ωs

φJ,k(x)v,k(x,xI)dΩ −∫

ΓsD

∂φJ(x)∂n

v(x,xI)dΓ

+α∫

ΓD

φJ (x)v(x,xI)dΓ, (11.27)

and the vector component

fI = −∫

Ωs

f(x)v,k(x,xI)dΩ +∫

ΓsN

qv(x,xI)dΓ + α

ΓD

u(x)v(x,xI)dΓ.

(11.28)In the above M denotes the total number of nodes in Ω, and u = [u1, · · · , uM ]is the vector for the unknown fictitious nodal values.

The implementation of the MLPG method can be carried out as follows:1. Generate all nodes M in the domain Ω and on its boundary Γ. Then choosethe weight functions and shape functions.

Page 359: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

344 Computational Partial Differential Equations Using MATLAB

2. For each node, choose the proper shape and the size of the local subdomainΩs and its corresponding local boundary ∂Ωs.3. Loop over all nodes inside Ω and at the boundary Γ:

• Choose Gauss quadrature points xQ in Ωs and on ∂Ωs.• Loop over all quadrature points xQ in Ωs and on ∂Ωs:

(a) Locate all nodes xJ(J = 1, · · · , N) in the neighborhood of xQ suchthat wJ (xQ) > 0;

(b) Calculate φJ (xQ) and its derivatives φJ,k(xQ) for all xJ(J = 1, · · · , N);(c) Evaluate the numerical integrals of (11.27) and (11.28).

4. Solve the linear system (11.26) for uJ . Then postprocess for approximatesolution and compare errors.

Similarly, we can develop MLPG for the two-dimensional elastostatic prob-lem (11.11)-(11.13). Multiplying (11.11) by a test function vi and integratingover a subdomain Ωs, and then imposing the essential boundary condition(11.13) by the penalty method, we obtain

Ωs

(σij,j + bi)vidΩ − α

Γsu

(ui − ui)vidΓ = 0, (11.29)

where Γsu = Γu ∩ ∂Ωs.Using integration by parts as we did in the EFG method, we can rewrite

(11.29) as follows:

Ωs

σijvi,jdΩ −∫

∂Ωs

σijnjvidΓ + α

Γsu

uividΓ

=∫

Ωs

bividΩ + α

Γsu

uividΓ. (11.30)

We can split ∂Ωs = Γsu∪Γst∪Ls, where Γst = ∂Ωs∩Γt, and Ls is the otherpart of the local boundary ∂Ωs over which no boundary condition is specified.Note that for a subdomain located totally inside the physical domain Ω, theΓsu and Γst are empty. Imposing the natural boundary condition (11.12) in(11.30), we obtain the local weak formulation:

Ωs

σijvi,jdΩ + α

Γsu

uividΓ −∫

Γsu+Ls

tividΓ

=∫

Ωs

bividΩ + α

Γsu

uividΓ +∫

Γst

tividΓ. (11.31)

Substituting the approximate solution (11.25) and test function vi = v(x,xI)into (11.31), we obtain the following system of linear equations in uJ :

M∑

J=1

KIJ uJ = fI , I = 1, 2, · · · ,M, (11.32)

Page 360: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Other Meshless Methods 345

where

KIJ =∫

Ωs

ε(v)CBJdΩ + α

Γsu

v(x,xI)φJdΓ −∫

Γsu+Ls

v(x,xI)NCBJdΓ,

fI =∫

Ωs

b · v(x,xI) + α

Γsu

u · v(x,xI)dΓ +∫

Γst

t · v(x,xI)dΓ,

BI =

⎣φI,x 00 φI,yφI,y φI,x

⎦ ,

ε(v) =[ε11(v) ε22(v) ε12(v)ε11(v) ε22(v) ε12(v)

], εij(v) =

12(∂vi∂xj

+∂vj∂xi

),

and the matrix C = E1−ν2

⎣1 ν 0ν 1 00 0 1−ν

2

⎦ (for plane stress).

11.4 Bibliographical remarks

Readers interested in a detailed introduction to general meshless methodscan consult the book by Liu [16]. More detailed discussions on the MLPGmethod can be consulted in the books by Atluri et al. [1, 2]. Details aboutthe Smoothed Particle Hydrodynamics method and its implementation canbe found in books [15, 17]. Readers can find some more recent advances inmeshless methods in conference proceedings [8, 12, 14, 20].

11.5 Exercises

1. Prove that for the quartic spline, the normalization constant Cd = 54 ,

5π ,

and 10516π for one, two, and three dimensions, respectively.

2. Assume that a quadratic weight function has the following form

wh(r) ={a+ b( rh )2, if 0 ≤ r

h ≤ 1,0 if r

h > 1.

Prove that wh(r) = Cd

hd [1 − ( rh)2], where Cd = 34 ,

2π , and 15

8π for one, two, andthree dimensions, respectively.Hint: Use the normality condition and the property wh(h) = 0.

3. Functions that are identically 1 on a subset of their support can form apartition of unity. Prove that φ(x−xi), i = 0, · · · , n, form a partition of unity

Page 361: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

346 Computational Partial Differential Equations Using MATLAB

subordinate to patches Ωi, where

φ(x) =

⎧⎪⎪⎨

⎪⎪⎩

32 + 2 xh , if x ∈ (− 3

4h,−h4 ],

1, if x ∈ (−h4 ,

h4 ],

32 − 2 xh , if x ∈ (h4 ,

34h),

0 elsewhere.

4. Recall that the Lagrange multiplier method is to convert a constraintedminimization problem to an unconstrainted one. Use the Lagrange multipliermethod to find the minimizer of

f(x) = x21 − 2x1x2 + 2x2

2 + 10x1 + 2x2

under the constraint that g(x) ≡ x1 − x2 = 0.5. Develop a local weak formulation for the convection-diffusion problem:

− ∂

∂xj(K

∂u

∂xj) + vj

∂u

∂xj= f in Ω,

u = u on ΓD,

K∂u

∂xjnj = q on ΓN ,

where vj is the flow velocity, K is the diffusivity, f is the given source.

References

[1] S.N. Atluri. The Meshless Method (MLPG) for Domain and BIE Dis-cretizations. Tech Science Press, Forsyth, GA, 2004.

[2] S.N. Atluri and S. Shen. The Meshless Local Petrov-Galerkin (MLPG)Method. Tech Science Press, Forsyth, GA, 2002.

[3] S.N. Atluri and T. Zhu. A new meshless local Petrov-Galerkin (MLPG)approach in computational mechanics. Comput. Mech., 22:117–127,1998.

[4] S.N. Atluri and T. Zhu. A new meshless local Petrov-Galerkin (MLPG)approach to nonlinear problems in computational modeling and simula-tion. Comput. Modeling Simulation in Engrg., 3:187–196, 1998.

[5] I. Babuska, U. Banerjee and J.E. Osborn. Survey of meshless and gen-eralized finite element methods: a unified approach. Acta Numerica,12:1–125, 2003.

[6] I. Babuska and J.M. Melenk. The partition of unity method. Int. J.Num. Meth. Engrg., 40:727–758, 1997.

Page 362: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix: Answers to Selected Problems 347

[7] T. Belytschko, Y. Krongauz, D. Organ, M. Fleming and P. Krysl. Mesh-less methods: an overview and recent developments. Comput. MethodsAppl. Mech. Engrg., 139:3–47, 1996.

[8] C.A. Brebbia, D. Poljak and V. Popov (eds.). Boundary Elements andOther Mesh Reduction Methods XXIX. WIT Press, Southampton, UK,2007.

[9] J. Dolbow and T. Belytschko. An introduction to programming themeshless element free Galerkin method. Archives of ComputationalMethods in Engineering, 5(3):207–241, 1998.

[10] C.A. Duarte and J.T. Oden. H-p clouds – an h-p meshless method.Numerical Methods for Partial Differential Equations, 12:673–705, 1996.

[11] R.A. Gingold and J.J. Monaghan. Smoothed particle hydrodynamics:theory and application to non-spherical stars. Mon. Not. Roy. Astron.Soc., 181:375–389, 1977.

[12] M. Griebel and M.A. Schweitzer (eds.). Meshfree Methods for PartialDifferential Equations III. Springer-Verlag, Berlin, 2006.

[13] P. Lancaster and K. Salkauskas. Surfaces generated by moving leastsquares methods. Math. Comp., 37(155):141–158, 1981.

[14] V.M.A. Leitao, C.J.S. Alves and C. Armando Duarte (eds.). Advancesin Meshfree Techniques. Springer, New York, NY, 2007.

[15] S. Li and W.-K. Liu. Meshfree Particle Methods. Springer-Verlag, Berlin,2004.

[16] G.R. Liu. Mesh Free Methods: Moving beyond the Finite ElementMethod. CRC Press, Boca Raton, FL, 2003.

[17] G.R. Liu and M.B. Liu. Smoothed Particle Hydrodynamics. World Sci-entific, Hackensack, NJ, 2003.

[18] L.B. Lucy. A numerical approach to the testing of the fission hypothesis.The Astron. J., 8(12):1013–1024, 1977.

[19] J.J. Monaghan. Why particle methods work. SIAM J. Sci. Stat. Com-put., 3(4):422–433, 1982.

[20] J. Sladek and V. Sladek (eds.). Advances in Meshless Methods. TechScience Press, Forsyth, GA, 2006.

Page 363: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND
Page 364: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix A

Answers to Selected Problems

Chapter 2

5. Rewrite (2.70) as

un+1j = (1 − anj+ 1

2

�t(�x)2 − anj− 1

2

�t(�x)2 )unj

+anj+ 12

�t(�x)2 u

nj+1 + anj− 1

2

�t(�x)2 u

nj−1. (A.1)

Under the condition (2.71), we have

(anj+ 12

�t(�x)2 + anj− 1

2

�t(�x)2 ) ≤ 2a∗

�t(�x)2 ≤ 1,

substituting which into (A.1), we obtain

un+1j ≤ (1 − anj+ 1

2

�t(�x)2 − anj− 1

2

�t(�x)2 ) max

0≤j≤Junj

+anj+ 12

�t(�x)2 max

0≤j≤Junj + anj− 1

2

�t(�x)2 max

0≤j≤Junj

= max0≤j≤J

unj .

The other part can be proved similarly.8. From (2.75), it is easy to see that

ut = −(ikπa+ k2π2)u,ux = ikπu, uxx = −k2π2u,

which leads to ut + aux − uxx = 0.Substituting unj = λneik(j�x) into the upwind scheme, we obtain

(λ− 1) + a�t�x(1 − e−ik�x)λ =

�t(�x)2 (eik�x − 2 + e−ik�x)λ

orλ = 1/[1 + a

�t�x(2 sin2 k�x

2+ i sin k�x) + 4

�t(�x)2 sin2 k�x

2],

which yields |λ| ≤ 1 for any �t and �x. Hence the scheme is unconditionallystable.

349

Page 365: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

350 Computational Partial Differential Equations Using MATLAB

Chapter 3

5.

dE

dt=∫ 1

0

(2a2uxuxt + 2ututt)dx

= (2a2uxut)|1x=0 −∫ 1

0

2a2uxxutdx +∫ 1

0

2uttutdx

= 0,

where we used the boundary condition u|x=0,1 = 0 and the governing equationuxx = a2utt.

9. From the definition of the flux, we can easily check that

hnk+ 12− hnk− 1

2

=12(f(unk+1) − f(unk−1)) −

�x2�t(u

nk+1 − 2unk + unk−1),

from which we obtain

unk − �t�x(hnk+ 1

2− hnk− 1

2)

= unk − �t2�x(f(unk+1) − f(unk−1)) +

12(unk+1 − 2unk + unk−1)

=12(unk+1 − unk−1) −

�t2�x(f(unk+1) − f(unk−1)),

which equals the right-hand side of the Lax-Friedrichs (LF) scheme, i.e., theLF scheme can be cast in the form of (3.54). Hence the LF scheme is conser-vative.

Furthermore, it is easy to check that the flux h satisfies the propertyh(u, u) = f(u), which means that the LF scheme is consistent.

Chapter 4

4. Let vε(x, y) = u(x, y) + ε(x2 + y2). It is easy to check that

�vε = 4ε > 0 ∀ (x, y) ∈ Ω. (A.2)

Assume that vε achieves its maximum at an interior point (x∗, y∗) of Ω,then

∂2vε∂x2

(x∗, y∗) < 0,∂2vε∂y2

(x∗, y∗) < 0,

Page 366: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix: Answers to Selected Problems 351

which contradicts (A.2). Hence vε has no interior maximum point, i.e.,

vε(x, y) ≤ max(x,y)∈∂Ω

vε(x, y) ∀ (x, y) ∈ Ω.

Taking the limit ε→ 0 on both sides, we obtain

u(x, y) ≤ max(x,y)∈∂Ω

u(x, y).

For the other part, just consider vε(x, y) = u(x, y) − ε(x2 + y2).7. Assume that the grid is uniform and has mesh size h = 1

J , i.e.,

0 = x0 < x1 < · · · < xJ = 1, 0 = y0 < y1 < · · · < yJ = 1.

Then we can construct a second-order difference scheme

δ4x1uij + 2δ2x1

δ2x2uij + δ4x2

uij = 0,

or

20uij − 8(ui+1,j + ui−1,j + ui,j+1 + ui,j−1)+2(ui+1,j+1 + ui+1,j−1 + ui−1,j+1 + ui−1,j−1)+ui+2,j + ui−2,j + ui,j+2 + ui,j−2 = 0, ∀2 ≤ i, j ≤ J − 2, (A.3)

which is a 13-point scheme.For those near boundary points the scheme (A.3) has to be changed. For

example, for those nodes adjacent to the bottom side (i.e., j = 1, 2 ≤ i ≤J−2), we have to replace ui,−1 by ui,1 +2hgi,0 and ui,0 by fi,0, in which case,the scheme (A.3) becomes

21ui1 − 8(ui+1,1 + ui−1,1 + ui,2)+2(ui+1,2 + ui−1,2) + ui+2,1 + ui−2,1 + ui,3

= 8fi,0 − 2fi+1,0 − 2fi−1,0 − 2hgi,0. ∀2 ≤ i ≤ J − 2.

For the near corner point i = j = 1, we have to replace u1,−1 by u1,1+2hg1,0and u−1,1 by u1,1 + 2hg0,1, in which case, the scheme (A.3) becomes

22u11 − 8(u2,1 + u1,2) + 2u2,2 + u3,1 + u1,3

= 8(f0,1 + f1,0) − 2(f2,0 + f0,2 + f0,0) − 2h(g0,1 + g1,0).

Similar procedures apply for other nodes adjacent to the boundary.

Chapter 5

6. By Taylor expansion, we have

R(un + �tR(un)) = R(un) + �tR(un)R′(un) +O(�t2),

Page 367: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

352 Computational Partial Differential Equations Using MATLAB

from which we see that

u(x, tn+1) − u(x, tn)�t − 1

2[R(un) +R(un + �tR(un))]

= u′(x, tn) +�t2u”(x, tn) +O(�t2)

−12[2R(un) + �tR(un)R′(un) +O(�t2)]

= O(�t2),

where we used u′(x, tn) = R(un) and u”(x, tn) = R′(un)R(un).9. By Taylor expansion, we have

f(xi+ 12) − f(xi− 1

2)

= 2[h

2f ′(xi) +

13!

(h

2)3f (3)(xi) +

15!

(h

2)5f (5)(xi)] +O(h7), (A.4)

f(xi+ 32) − f(xi− 3

2)

= 2[3h2f ′(xi) +

13!

(3h2

)3f (3)(xi) +15!

(3h2

)5f (5)(xi)] +O(h7), (A.5)

f ′(xi−1) + f ′(xi+1)

= 2[f ′(xi) +h2

2f (3)(xi) +

h4

4!f (5)(xi)] +O(h6). (A.6)

Denote the truncation error

R = α[f ′(xi−1) + f ′(xi+1)] + f ′(xi) (A.7)

−ah

(f(xi+ 12) − f(xi− 1

2)) − b

3h(f(xi+ 3

2) − f(xi− 3

2)). (A.8)

Substituting (A.4)-(A.6) into (A.8), we obtain

R = (2α+ 1 − a− b)f ′(xi) + (α− a

24− 3b

8)h2f (3)(xi)

+(α

12− a

1920− 81b

1920)h4f (5)(xi) +O(h6). (A.9)

Let the first coefficients of (A.9) be zero, i.e.,

2α+ 1 − a− b = 0−24α+ a+ 9b = 0,

which leads to the solution

b =22α− 1

8, a =

−6α+ 98

.

Page 368: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix: Answers to Selected Problems 353

Hence the leading term in the truncation error (A.9) becomes

R = [α

12+

6α− 98 · 1920

− 81(22α− 1)8 · 1920

]h4f (5)(xi)

= (α

12− −9 + 222α

1920)h4f (5)

=9 − 62α

1920h4f (5).

Chapter 6

1. Using integration by parts and the boundary condition, we obtain

Ω

∂2v

∂x21

∂2v

∂x22

dx1dx2 =∫

∂Ω

∂2v

∂x21

∂v

∂x2nds−

Ω

∂3v

∂x21∂x2

∂v

∂x2dx1dx2

= −∫

∂Ω

∂2v

∂x1∂x2n∂v

∂x2ds+

Ω

∂2v

∂x1∂x2

∂2v

∂x1∂x2dx1dx2

=∫

Ω

| ∂2v

∂x1∂x2|2dx1dx2,

from which we have

|�v|2L2(Ω) =∫

Ω

(|∂2v

∂x21

|2 + |∂2v

∂x22

|2 + 2|∂2v

∂x21

∂2v

∂x22

|)dx1dx2

=∫

Ω

(|∂2v

∂x21

|2 + |∂2v

∂x22

|2 + 2| ∂2v

∂x1∂x2|2)dx1dx2 = |v|2H2(Ω).

6. We only need to show that if

v(ai) = v(aij) = v(a0) = 0,

then v ≡ 0. Since v = 0 at those four nodes on edge a2a3, hence v ≡ 0 on edgea2a3. Therefore v must contain factor λ1(x). A similar argument concludesthat

v = cλ1(x)λ2(x)λ3(x),

which leads to

v(a0) = cλ1(a0)λ2(a0)λ3(a0) = c · (13)3.

But by assumption v(a0) = 0, we conclude that c = 0, i.e., v ≡ 0.

Page 369: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

354 Computational Partial Differential Equations Using MATLAB

Chapter 7

6. Note that∂F1

∂x1= [−(1 − x2)a1 + (1 − x2)a2 + x2a3 − x2a4]|1st component

= 2(1 − x2) + 2x2 = 2.

Similarly,

∂F1

∂x2= [−(1 − x1)a1 − x1a2 + x1a3 + (1 − x1)a4]|1st component

= −2x1 + 2x1 = 0.

∂F2

∂x1= [−(1 − x2)a1 + (1 − x2)a2 + x2a3 − x2a4]|2nd component

= 3x2 − 5x2 = −2x2.

∂F2

∂x2= [−(1 − x1)a1 − x1a2 + x1a3 + (1 − x1)a4]|2nd component

= 3x1 + 5(1 − x1) = 5 − 2x1.

Hence we have

J =

∣∣∣∣∣

∂F1∂x1

∂F1∂x2

∂F2∂x1

∂F2∂x2

∣∣∣∣∣ =∣∣∣∣

2 0−2x2 5 − 2x1

∣∣∣∣ = 2(5 − 2x1),

which is always positive.7.

∂F1

∂x1= −2(1 − x2) + 3(1 − x2) + 5x2 − 2x2 = 1 + 2x2.

∂F1

∂x2= −2(1 − x1) − 3x1 + 5x1 + 2(1 − x1) = 2x1.

∂F2

∂x1= 2(1 − x2) + 3x2 − 3x2 = 2(1 − x2).

∂F2

∂x2= −2x1 + 3x1 + 3(1 − x1) = 3 − 2x1.

Hence

J =∣∣∣∣

1 + 2x2 2x1

2(1 − x2) 3 − 2x1

∣∣∣∣ = 3 − 6x1 + 6x2,

which equals zero when x1−x2 = 12 (e.g., the point (1

2 , 0)). Hence the mappingis not invertible.

Page 370: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix: Answers to Selected Problems 355

Chapter 8

2. Note that

L(u+ δu, p) =12(u+ δu, u+ δu) − (ux + (δu)x, p) + (f, p)

= L(u, p) +12(δu, δu) + (δu, u) − ((δu)x, p). (A.10)

Using integration by parts and the boundary condition p|∂Ω = 0, we have

((δu)x, p) = −(δu, px),

substituting which into (A.10) and using u = −px yields

L(u + δu, p) = L(u, p) +12(δu, δu) ≥ L(u, p),

i.e.,L(u, p) ≤ L(v, p) for any v ∈ V. (A.11)

On the other hand,

L(u, p+ δp) =12(u, u) − (ux, p+ δp) + (f, p+ δp)

= L(u, p) − (ux, δp) + (f, δp) = L(u, p),

which together with (A.11) concludes that (u, p) is a saddle-point of L(·, ·).4. First note that the total number of degrees of freedom is

3(r + 1) + 2 · r(r + 1)2

= (r + 1)(r + 3),

which equals dim(RTr(K)). Hence the uniqueness is assured if we can provethat if all degrees of freedom are zero

< v · n, w >e= 0, ∀ w ∈ Pr(e), (A.12)(v,w)K = 0, ∀ w ∈ (Pr−1(K))2, (A.13)

then v ≡ 0.Since v · n ∈ Pr(e), (A.12) leads to v · n = 0 on e.Integration by parts gives us

K

(∇ · v)w =∫

∂K

(v · n)w −∫

K

v · ∇w. (A.14)

Letting w ∈ Pr(K) in (A.14) and using (A.12)-(A.13), we have∫

K

(∇ · v)w = 0, ∀ w ∈ Pr(K),

Page 371: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

356 Computational Partial Differential Equations Using MATLAB

which yields∇ · v = 0 (A.15)

due to the fact that ∇ · v ∈ Pr(K) for any v ∈ RTr(K).(A.15) guarantees that there exists a stream function φ ∈ H1(K) such that

v = curlφ ≡ (−∂φ∂y,∂φ

∂x)′.

For any v ∈ RTr(K), we can decompose v as

v = p+(xy

)q, p ∈ (Pr(K))2, q ∈ Pr(K).

Without loss of generality, we can assume that q is a homogeneous polyno-mial of degree r (since other terms can be absorbed into p). Hence

∇ · v = ∇ · p+ 2q + x∂xq + y∂yq = ∇ · p+ (2 + r)q,

which together with (A.15) and the fact ∇ · p ∈ Pr−1(K) yields q = 0.Therefore v = p, and furthermore φ ∈ Pr+1(K).

On the other hand, 0 = v · n = −∂φ∂y · nx + ∂φ

∂x · ny is equivalent to thetangential derivative ∂φ

∂t by noting that t = (−ny, nx) if n = (nx, ny). Henceφ = const on all edges of K.

Using (A.13) and the Stokes’ formula, we have

0 =∫

K

v ·w =∫

K

curlφ ·w

=∫

∂K

n× φ ·w +∫

K

φ · curlw, ∀ w ∈ (Pr−1(K))2, (A.16)

where the scalar curl is defined as curlw = ∂w1∂y − ∂w2

∂x .

Letting w = (1, 1)′ in (A.16), we obtain n×φ = 0 on ∂K, i.e., φ = 0 on alledges of K. Therefore we can represent φ as

φ(x) = λ1(x)λ2(x)λ3(x)ψ(x), (A.17)

where λi are the barycentric coordinates of the triangle K. Hence ψ(x) ∈Pr−2(K).

Substituting (A.17) into (A.16) and choosing w ∈ Pr−1(K) such that ψ =curlw ∈ Pr−2(K), we obtain

K

λ1λ2λ3ψ2 = 0,

which leads to ψ = 0. Hence φ = 0 and v ≡ 0.

Page 372: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix: Answers to Selected Problems 357

Chapter 9

7. Multiplying (9.108) by E, and integrating over domain Ω, we have

ε0d

dt||E||20 = (∇×H,E) − (J ,E). (A.18)

Multiplying (9.109) byH , integrating over domain Ω, and using the Stokes’formula and the boundary condition n×E = 0, we have

μ0d

dt||H ||20 = −(∇×E,H) = −(E,∇×H). (A.19)

Multiplying (9.110) by 1ε0ω2

pJ , and integrating over domain Ω, we have

1ε0ω2

p

d

dt||J ||20 +

ν

ε0ω2p

||J ||20 = (E,J). (A.20)

Adding (A.18)-(A.20) together, we obtain

d

dt[ε0||E||20 + μ0||H||20 +

1ε0ω2

p

||J ||20] +ν

ε0ω2p

||J ||20 = 0,

integrating which from 0 to t and using the fact that ν ≥ 0 concludes theproof.

10. Squaring both sides of the integral identity

12(uk + uk−1) − 1

τ

∫ tk

tk−1u(t)dt =

12τ

∫ tk

tk−1(t− tk−1)(tk − t)utt(t)dt, (A.21)

we can obtain

|uk − 1τ

∫ tk

tk−1u(t)dt|2 ≤ 1

4τ2(∫ tk

tk−1(t− tk−1)2(tk − t)2dt)(

∫ tk

tk−1|utt(t)|2dt)

≤ 14τ3

∫ tk

tk−1|utt(t)|2dt.

Chapter 10

4. Note that∂

∂x=

∂r

∂r

∂x+

∂θ

∂θ

∂x

=∂

∂r· xr

+∂

∂θ· −yx2 + y2

=∂

∂r· cos θ − ∂

∂θ· sin θ

r,

Page 373: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

358 Computational Partial Differential Equations Using MATLAB

from which we obtain

∂2

∂x2=

∂r[∂

∂r· cos θ − ∂

∂θ· sin θ

r] · cos θ

− ∂

∂θ[∂

∂r· cos θ − ∂

∂θ· sin θ

r] · sin θ

r

= [∂2

∂r2· cos θ − ∂2

∂r∂θ· sin θ

r+

∂θ· sin θr2

] · cos θ

−[∂2

∂r∂θ· cos θ − ∂

∂r· sin θ − ∂2

∂θ2· sin θ

r− ∂

∂θ· cos θ

r] · sin θ

r

= cos2 θ · ∂2

∂r2− 2 sin θ cos θ

r

∂2

∂r∂θ+

2 sin θ cos θr2

∂θ+

sin2 θ

r

∂r+

sin2 θ

r2∂2

∂θ2.

Similarly, we have

∂y=

∂r

∂r

∂y+

∂θ

∂θ

∂y

=∂

∂r· yr

+∂

∂θ· x

x2 + y2=

∂r· sin θ +

∂θ· cos θ

r,

from which we obtain

∂2

∂y2=

∂r[∂

∂r· sin θ +

∂θ· cos θ

r] · sin θ

+∂

∂θ[∂

∂r· sin θ +

∂θ· cos θ

r] · cos θ

r

= [∂2

∂r2· sin θ +

∂2

∂r∂θ· cos θ

r+

∂θ· − cos θ

r2] · sin θ

+[∂2

∂r∂θ· sin θ +

∂r· cos θ +

∂2

∂θ2· cos θ

r+

∂θ· − sin θ

r] · cos θ

r

= sin2 θ · ∂2

∂r2+

2 sin θ cos θr

∂2

∂r∂θ− 2 sin θ cos θ

r2∂

∂θ+

cos2 θr

∂r+

cos2 θr2

∂2

∂θ2.

Hence, adding up ∂2

∂x2 and ∂2

∂y2 , we obtain

∂2

∂x2+

∂2

∂y2=

∂2

∂r2+

1r

∂r+

1r2

∂2

∂θ2.

7.

d

dx[xαJα(x)] =

d

dx

∞∑

k=0

[(−1)k

k!Γ(k + α+ 1)(x

2)2k+α · xα]

=∞∑

k=0

(−1)k

k!Γ(k + α+ 1)· 122k+α

· (2k + 2α)x2k+2α−1

= xα∞∑

k=0

(−1)k · (k + α)k!Γ(k + α+ 1)

· (x2)2k+α−1

Page 374: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

Appendix: Answers to Selected Problems 359

= xα∞∑

k=0

(−1)k · (k + α)k!(k + α)Γ(k + α)

· (x2)2k+α−1

= xαJα−1(x).

The other identity can be proved similarly.

Chapter 11

2. In one dimension, the normality condition gives

2∫ h

0

[a+ b(r

h)2]dr = 1,

or2h[a+ b · 1

3] = 0. (A.22)

By wh(h) = 0, we havea+ b = 0. (A.23)

Solving (A.22)-(A.23), we obtain

a =34h

= −b,

which leads to wh(r) = 34h [1 − ( rh )2].

In two dimensions, we have∫ h

0

[a+ b(r

h)2]2πrdr = 1,

orπh2[a+

b

2] = 1,

which coupling with (A.23) yields

a =2πh2

= −b.

While in three dimensions, we have∫ h

0

[a+ b(r

h)2]4πr2dr = 1,

or4πh3[

a

3+b

5] = 1,

Page 375: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND

360 Computational Partial Differential Equations Using MATLAB

which coupling with (A.23) yields

a =15

8πh3= −b.

4. Let

F = f + λg

= (x21 − 2x1x2 + 2x2

2 + 10x1 + 2x2) + λ(x1 − x2).

To achieve a minimum value, it must satisfy

0 =∂F

∂x1= 2x1 − 2x2 + 10 + λ,

0 =∂F

∂x2= −2x1 + 4x2 + 2 − λ,

0 =∂F

λ= x1 − x2,

which leads to the solution

x1 = x2 = −6.

Hence the minimizer is f(x1, x2) = −36.

Page 376: Computational Partial Differential Equations Using MATLAB · 2019. 3. 11. · Computational Partial Differential Equations Using MATLAB® CHAPMAN & HALL/CRC APPLIED MATHEMATICS AND