AMS527: Numerical Analysis II A Brief Overview of Finite Element Methods Xiangmin Jiao SUNY Stony Brook Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 1 / 25
Overview Basic concepts Mathematical formulation and discretization Computer implementation of FEM (next lecture) Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 2 / 25
Basic Concepts Finite-element method is a spatial discretization method Commonly used in computational structural mechanics for solving linear static problem Sometimes also used in computational fluid dynamics, especially in commercial codes Source: http://www.colorado.edu/engineering/cas/courses.d/ifem.d Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 3 / 25
Typical Steps of Finite Element Method 1 Write the equation in its weak form, integrated with test functions v(x, y) 2 Subdivide the region into triangles or quadrilaterals 3 Choose N simple trial functions T j (x, y) and look for U = U 1 T 1 +... + U N T N. The 1D hat functions T (x) can change to 2D pyramid functions T (x, y) 4 Produce N equations KU = F from test functions V 1,..., V N (often V j = T j ) 5 Assemble the stiffness matrix K and the load vector F. Solve KU = F. Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 4 / 25
Example: Poisson s Equation Strong form 2 u x 2 2 u = f (x, y) in the open set S y 2 u = 0 on the boundary C Weak form multiply strong form by test function v(x, y) and integrate over S ( ) 2 u S x 2 2 u y 2 v dx dy = fv dx dy S Integrate by left side by part, and requiring v to vanish on the boundary: ( u x S v x + u y ) v dx dy = fv dx dy y S In weak form, residual u xx + u yy + f is required to be zero only in a weighted sense, where weight is provided by v Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 5 / 25
Galerkin s Method Basic steps of Galerkin s method Choose a finite set of shape functions (trial functions) T i (x, y), i = 1, 2,..., n Admit approximations to u of the form U(x, y) = n j=1 U jt j (x, y) Determine n unknown U i from weak form, using n different test functions To maintain symmetry, require test functions to be the same as trial functions, i.e., v = T i (x, y) Then weak form becomes n T j U j T n i S x x + j=1 j=1 = ft i dx dy S U j T j y T i y dx dy Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 6 / 25
Galerkin s Method Cont d Rewrite in matrix form into linear system Ku = f where K is stiffness matrix and f is load vector On left-hand side, we obtain ( Ti K ij = x S T j x + T i y ) T j dx dy y Stiffness matrix K is symmetric in that K ij = K ji. In addition, K is positive definite (later) On right-hand side, we have f i = S ft i dx dy Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 7 / 25
Rayleigh-Ritz Method For Poisson s equation, one can obtain same approximation with the minimum principle to minimize [ ( ) 1 u 2 P(u) = + 1 ( ) u 2 fu] dx dy 2 x 2 y S over all functions that satisfy essential boundary condition u = 0 Approximate u in the form U(x, y) = n j=1 U jt j (x, y), then P(u) = 1 2 ut Ku u T f and we obtain the same linear system Ku = f The derivation based on minimum principle is called Rayleigh-Ritz Method From energy P(u), it is obvious that K is symmetric and positive definite (SPD) Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 8 / 25
Finite Element Shape Functions Desired properties of shape (trial) functions Function T i must be capable of approximating true u(x, y) and must vanish at boundary Entries K ij and f i must be convenient to compute (ease of differentiation and integration) K should be sparse and well-conditioned Typical shape functions are piecewise polynomials over triangles or quadrilaterals (known as elements) For triangles, piecewise linear (P 1 ), quadratic (P 2 ), and cubic (P 3 ) For quadrilaterals, piecewise bilinear (Q 1 ) and biquadratic (Q 2 ) Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 9 / 25
Examples of Element Types Source: http://www.colorado.edu/engineering/cas/courses.d/ifem.d Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 10 / 25
More on Shape Functions Finite element shape functions are Lagrangian interpolants Each shape function is associated with a vertex It has value 1 at the vertex and vanishes at all other vertices Question: What are the meanings of the coefficients of the shape functions? There are two mathematically equivalent views of shape functions View of each shape function over whole spatial domain View of shape functions within each element Mathematical formulation is based on former, but computational implementation is typically based on latter for convenience Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 11 / 25
Examples of Linear Shape Functions Linear (P1) Bilinear (Q1) Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 12 / 25
Quadratic Shape Functions for Triangles Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 13 / 25
Biquadratic Shape Functions for Quadrilaterals Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 14 / 25
Stiffness Matrix To implement finite-element method for Poisson s equation, key is to obtain linear system where K ij = f i = S S ( Ti x ft i dx dy Ku = f T j x + T i y ) T j dx dy y On triangles, each T j is pyramid over jth vertex v j, and ( Ti T j K ij = {e v i e v j e} e x x + T ) i T j dx dy y y f i = ft i dx dy {e v i e v j e} e Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 15 / 25
Element Stiffness Matrices Within each triangle, let U = a + bx + cy, compute ( NI N J (k e ) IJ = x x + N ) I N J dx dy, I, J = 1, 2, 3 y y e where N I is shape function w.r.t. I th vertex. Matrix k e = [(k e ) IJ ], I, J = 1, 2, 3 is element stiffness matrix For Laplacian equation, it can be shown that c 2 + c 3 c 3 c 2 k e = c 3 c 1 + c 3 c 1 1, where c i = 2 tan θ c 2 c 1 c 1 + c i 2 Question: Is k e symmetric and positive definite? Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 16 / 25
Mass Matrix and Element Mass Matrices Besides stiffness matrix, mass matrix [M ij ] is very common in finite element methods M ij = T i T j dx dy S = T i T j dx dy {e v i e v j e} Its computation involves element mass matrix m e with (m e ) IJ = N I N J dx dy, I, J = 1, 2, 3 e e Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 17 / 25
General Procedure for Elemental Computation In general, N I / x and N I / y is obtained from chain rule ] ] ] [ x ξ x η y ξ y η } {{ } J T [ NI x N I y [ x2 x where J = 1 x 3 x 1 y 2 y 1 y 3 y 1 coordinates = [ NI ξ N I η ]. ξ and η are called natural Requires computing Jacobian matrix and derivatives of shape functions Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 18 / 25
Example Quadrature Rules Over Triangle Requires quadrature rules over elements Source: http://www.colorado.edu/engineering/cas/courses.d/ifem.d Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 19 / 25
Example Quadrature Rules Over Triangle http://www.colorado.edu/engineering/cas/courses.d/ifem.d Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 20 / 25
Assembling Element Matrices For each triangle, k e is 3 3 matrix, each of whose rows (columns) correspond to a vertex Each vertex of triangle has global vertex ID. Example: triangle 1: nodes 3, 1, 2 triangle 2: nodes 3, 4, 2... triangle m: nodes 5, 4, n Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 21 / 25
Assembling Element Matrices Map k e for element e to an n n matrix K e, based on local to global mapping of vertex IDs, e.g., (k e ) 22 (k e ) 23 (k e ) 21 (k e ) 32 (k e ) 33 (k e ) 31 (k e ) 12 (k e ) 13 (k e ) 11 K 1 = 0... 0 Then, K = K 1 + K 2 + + K m Without boundary condition, K is singular! After applying boundary condition, K is SPD In iterative linear solvers involving only matrix-vector multiplications, Kx = K 1 x + K 2 x + + K m x, so K need not be assembled explicitly, leading to matrix-free linear solvers Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 22 / 25
Role of Assembler Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 23 / 25
Summary of Key Aspects for Implementing FEM Input of finite element methods Vertex coordinates, used for computing Jacobian matrix Element connectivity, used for local to global mapping in assembling matrix Boundary conditions Elemental computation Shape functions, first and second derivatives Numerical quadrature rules and Gauss points Assemble element matrices into stiffness matrix Solution of sparse linear system Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 24 / 25
Accuracy and Convergence of Finite Elements When using degree p piecewise polynomials, basic theory of FEM can be stated as: The finite element method converges if p 1, and its error is O(h 2p ), where h is largest edge length. The answers are exact for solutions of degree p (checked by patch test) In addition, finite-element method gives optimal solution U that is closest to exact solution u in that it minimizes the energy E = (U u) T K(U u) within all feature solutions in function space of trial functions Xiangmin Jiao SUNY Stony Brook AMS527: Numerical Analysis II 25 / 25