Chapter 1: The Finite Element Method Michael Hanke Read: Strang, p 428 436 A Model Problem Mathematical Models, Analysis and Simulation, Part Applications: u = fx), < x < 1 u) = u1) = D) axial deformation of an elastic bar conduction of heat in a bar many others This formulation is the starting point for finite difference methods. Q: Are there alternatives? Michael Hanke, ADA, ovember 4, 25 Michael Hanke, ADA, ovember 4, 25 1 Principle of Virtual Work Principle of Minimum Energy n equilibrium, the virtual work vanishes for all possible virtual displacements. n equilibrium, the energy of a system attains a minimum. Multiply by a test function v virtual displacement) and integrate: u vdx = f vdx Since v) = v1) =, integration by parts yields: f vdx = u v dx [u v] 1 = u v dx We obtain the weak or variational formulation: Find u with u) = u1) = such that Energy: Pu) = The minimization formulation: [ ] 1 2 u 2 f u dx Find u with u) = u1) = such that Pu) Pv) for all admissible v ote: D is the Euler-Lagrange equation for M. M) u v dx = f vdx for all admissible v V) Michael Hanke, ADA, ovember 4, 25 2 Michael Hanke, ADA, ovember 4, 25 3
otes on These Formulations Sobolev Spaces M V Solutions of V and M need only be once differentiable. f u is twice differentiable, D and V are equivalent. M = V = D Hence, the variational formulation is the most general one. Q: What are admissible functions? They must be once differentiable in a generalized sense) and fulfill the essential) boundary conditions. 1 V := H 1,1) := {v v) = v1) =, v 2 + v 2 )dx < } This is a special case of Sobolev spaces H p ): Let be a domain in R n, H p ) := {v v p) ) 2 + +v 2 + v 2 ) dx < } These spaces are examples of a complete inner product space. otation: v p = v ) ) ) 1/2 p) 2 + + v 2 + v 2 dx Michael Hanke, ADA, ovember 4, 25 4 Michael Hanke, ADA, ovember 4, 25 5 Ritz and Galerkin Methods Finite Element Method: Example Choose a convenient) finite dimensional subspace V h V. Choose a basis of V h. Ritz method: Start from M. Determine u h V h as the minimizer of Pv h ) where v h is taken from V h. Galerkin method: Start from V. Determine u h V h such that V is fulfilled for all v h V h. Theorem. Q: How to choose V h? Criteria include: The Ritz and Galerkin procedures are equivalent. good approximation quality, efficient numerical algorithms, stable computations. Consider the introductory example. Subdivide [, 1] into + 1 subintervals not necessarily equidistant): = x < x 1 < < x < x +1 = 1. V h : set of all piecewise linear functions with corners at the grid points x i. u 2 1.5 1.5 Example of a basis function and a piecewise linear function 1 2 3 4 5 6 7 8 9 1 11 x Basis functions: Hat functions x x i 1 x i x i 1, x i 1 x x i, x φ i x) = i x x i+1 x i, x i x x i+1,, elsewhere Ansatz u h x) = u j φ j x) Michael Hanke, ADA, ovember 4, 25 6 Michael Hanke, ADA, ovember 4, 25 7
Example cont.) Example cont.) Ritz: nsert into Pv): u h x) = Pu h ) = j,k=1 u j φ j x), u hx) = 1 2 u ju k = u T Au u T f. φ jφ kdx a jk u j u j φ jx) φ j f dx f j vector of unknowns: u = u 1,...,u ) T, where u i = u h x i ) stiffness matrix A load vector f properties of the stiffness matrix t is symmetric: a jk = a k j. t is positive semi-definite: t is positive definite: u T Au = u hx) u T Au = u 2 h dx. u j = for all j Definiteness depends on the boundary conditions! Pu h ) reduces to a quadratic functional. Derivation with respect to the unknowns yields Au = f How to integrate: numerical quadrature Exercise: Do the same analysis for the Galerkin method! cf. Strang, p 43) Michael Hanke, ADA, ovember 4, 25 8 Michael Hanke, ADA, ovember 4, 25 9 Error Estimation Error Estimation cont.) Read: Strang, p 444 445 A reliable and efficient method requires an error estimate and a method to adapt the discretization to the problem at hand to produce a prescribed error with minimal resources. Some notation: Left-hand side of V: au,v) := R 1 u v dx. Exercise: Show that au,v) is a scalar product on V! Right-hand side of V: Lv) = R 1 f vdx M: Pv) = 1 2av,v) Lv) Exact solution: au,v) = Lv) for all v V Galerkin: au h,v h ) = Lv h ) for all v h V h The error: e h = u u h. With any interpolant Π h u of u in V h : ae h,e h ) = ae h,u u h ) = ae h,u Π h u+π h u u h ) = ae h,u Π h u) since ae h,π h u u h ) =. Cauchy-Schwarz inequality: Finally ae h,u Π h u) 2 ae h,e h )au Π h u,u Π h u). ae h,e h ) au Π h u,u Π h u) The right-hand term is computable if u is two times continuously differentiable. Since V h V : au,v h ) = Lv h ) for all v h V h au h,v h ) = Lv h ) for all v h V h ae h,v h ) = for all v h V h. This is called Galerkin orthogonality. Michael Hanke, ADA, ovember 4, 25 1 Michael Hanke, ADA, ovember 4, 25 11
Error Estimation cont.) Error Estimation cont.) Linear interpolation on = [x i,x i+1 ] gives: u x) Π h u) x) = u x) xx i+1) ux i ) = u x) u ξ) x i+1 x i where ξ x i,x i+1 ). u Π h u) ) 2 dx = u x) u ξ) ) 2 dx = x ξ x ξ u s)ds) 2 dx x u 2 s)ds x i+1 x i ) 2 ξ 1 2 ds)dx u 2 s)ds. Theorem. u u h 2 i= x i+1 x i ) 2 x i+1 x i u 2 s)ds A standard theorem says Friedrich s inequality): There is a constant C such that for all v H 1 ). Hence, v C v e h C e h h u. ote: n the present case, one can even show: Second order convergence: e h = Oh 2 ). Pointwise convergence: max x [,1] e h x) C 1 h 2. Michael Hanke, ADA, ovember 4, 25 12 Michael Hanke, ADA, ovember 4, 25 13 Adaptive Algorithms Adptive Algorithms cont.) The error estimate above is an a-priori one: t uses only qualitative assumption on the given data. An a-posteriori error estimate uses the actual discrete solution u h to approximate u. There are different ways available of doing this. ote that the error is localized. Adaptive algorithm: 1. Construct an initial grid 2. Discretize by FEM For the last step, a number of different strategies are available: Refine the worst elements. Equidistribution of the error. ote The success of the algorithm depends on the regularity of the solution. For problems with singularities, the refinement process may never terminate. 3. Compute the approximation u h 4. Compute an a-posteriori error estimate 5. User selected error criterion met? Yes: We are done. o: Select subintervals with large error and subdivide them. Michael Hanke, ADA, ovember 4, 25 14 Michael Hanke, ADA, ovember 4, 25 15
The Program ADFEM A 2D Model Problem This program implements an adaptive algorithm for the problem d dx dx) du ) + cx) du + ax)u = fx) dx dx x = x min : u = g or d) du dx + k u = g x = x max : u = g 1 or d1) du dx + k 1u = g 1 Assumptions: dx) d > Error control: in L 2 norm in energy norm e h E := ae h,e h ) if c =,a ) pointwise error More explicit: x max v 2 E = x min dv 2 + av 2 )dx Read: Strang, p 43 433 cx) u)+rx)u = fx),x R 2 = Γ D Γ on Γ D : u = g 1, on Γ : u n = g 2 with cx) c >, r and Γ D /. The variational formulation and the minimization formulation will be constructed by the principle of virtual work and the principle of minimum energy, respectively: Let v be a test function with vx) = on Γ D. f vdx = = = cx) u) + rx)u)vdx cx) u v cx) u v+rx)uv)dx } {{ } au,v) n cx) u)vdγ+ rx)uvdx Γ cx)g 2 x)vdγ. D) Michael Hanke, ADA, ovember 4, 25 16 Michael Hanke, ADA, ovember 4, 25 17 A 2D Problem cont.) The Galerkin Method Remember: H 1 ) = {v v 2 + v 2 )dx < } Define au,v) = cx) u v+rx)uv)dx, Lv) = f vdx+ u,v H 1 ) Γ cx)g 2 x)vdγ,v H 1 ) Let now V g := {v H 1 ) v = g on Γ D }. Variational formulation: Find u V g1 such that au,v) = Lv) for all v V. Minimization formulation: Find u V g1 such that Theorem. Pu) = min Pv) with Pv) = 1 av,v) Lv) v V g1 2 M) Exercise: Prove this! M and V are equivalent. V) We are following the lines of the one-dimensional example: 1. Choose a finite set of trial functions or, basis functions φ 1 x),...,φ x). 2. Admit approximations to u of the form u h x) = u 1 φ 1 x)+ + u φ x). 3. determine the unknown numbers u = u 1,...,u ) T from V, using different test functions φ k x). Lφ j ) = au h,φ j ) = a = k=1 f j Lφ j ) aφ k,φ j ) a jk k=1 The coefficients can be determined from Au = f u k u k φ k,φ j ) with the stiffness matrix A = a jk ) and the load vector f = f 1,..., f ) T. Exercise: Show that the Ritz approach leads to the same system. Michael Hanke, ADA, ovember 4, 25 18 Michael Hanke, ADA, ovember 4, 25 19
A Finite Element Example: P1 Triangles P1 Triangles cont.) Read: Strang, p 433 445 Bottlenecks of the Galerkin method: The computation of A is expensive. Every element is a 2D integral. Since the number of degrees of freedom is large, a high-dimensional linear system must be solved. Approximate as the union of non-overlapping triangles T k whose corners form the set of nodes x i. V h is defined as the set of continuous functions whose restriction to one triangle is a first degree polynomial. Choose basis functions cf the 1D case!) φ i x j ) = δ i j Wishes: Choose basis functions which are flexible enough to approximate the solution accurately with a small number of trial functions. Try to make A sparse. That means, use an almost orthogonal basis. The condition number should not be too large. dea borrowed from 1D: Choose piecewise polynomial trial functions which vanish almost everywhere on. ote: Later we will use other choices, too. Pseudo spectral method) Michael Hanke, ADA, ovember 4, 25 2 Michael Hanke, ADA, ovember 4, 25 21 Properties Stability Estimate Consequences: The stiffness matrix is sparse. There is a very efficient algorithm for computing A and f assembly). The condition number is conda) = Oh 2 ). Theorem. Under the given assumption on the coefficients and some regularity assumptions on and the triangulation), the solution to the Galerkin equation exists and is unique. f u is sufficiently smooth, e 1 Ch. Under additional assumptions on the data, e Ch 2. The key properties of a and L for the theorem to hold are 1. av,v) α v 2 1 v V 2. au,v) C u 1 v 1 u,v V 3. Lv) M v 1 v V As a consequence of 1), we obtain a stability estimate: au, u) = Lu) α u 2 α u 2 1 f,u) f u Consequently, u 1 α f. Michael Hanke, ADA, ovember 4, 25 22 Michael Hanke, ADA, ovember 4, 25 23