AMS 529: Finite Element Methods: Fundamentals, Applications, and New Trends Lecture 3: Finite Elements in 2-D Xiangmin Jiao SUNY Stony Brook Xiangmin Jiao Finite Element Methods 1 / 18
Outline 1 Boundary Value Problems in 2-D 2 Finite Element Method in 2-D Xiangmin Jiao Finite Element Methods 2 / 18
Poisson Equations in 2-D Poisson equation over R 2 with boundary = D N : (c u) = f (x, y) on R 2 subject to Dirichlet and Neumann boundary conditions: u(x, y) = u 0 (x, y) u n = w 0(x, y) on Dirichlet boundary D on Neumann boundary N In general, c(x, y) > 0 corresponds to some material properties potential Dirichlet BC & conservation law rate of change constitutive law ux Neumann BC & Xiangmin Jiao Finite Element Methods 3 / 18
Review of Gradient and Divergence in 2-D [ ] Gradient operator is defined as = x, which operates on scalar y [ u ] u : R, where R 2 : u = x u y Directional derivative along (unit vector) d, denoted as [ ] d, is d Divergence operator is defined as = x y, which operates on vector w : R 2, where R 2 : w = w 1 x + w 2 y w = 0 means divergence free (in-flow equals out-flow everywhere) Divergence theorem: total source in = total flux out w dxdy = w n ds where is simply connected and n is outward normal to {x, y} can be donated as {x 1, x 2 } for ease of generalization to n-d Xiangmin Jiao Finite Element Methods 4 / 18
Laplacian Operator and Laplace Equation Laplacian operator is = 2 x 2 + 2 y 2 ( 2 is sometimes used, but it is also often used to denote Hessian) Poisson equation with constant coefficient Laplace equation c u = f (x, y) u = u = 2 u x 2 + 2 u y 2 = 0 is special case of Poisson equation with constant coefficient and without source or sink Xiangmin Jiao Finite Element Methods 5 / 18
Outline 1 Boundary Value Problems in 2-D 2 Finite Element Method in 2-D Xiangmin Jiao Finite Element Methods 6 / 18
Outline of Finite Element Method in 2-D 1 Write equation in weak form on by integrating with n test functions ψ j (x, y) and using integration by parts 2 Subdivide into elements (triangles/quadrilaterals), i.e., = k τ k 3 Choose n trial functions {φ j (x, y)} and approximate u U j φ j (e.g., by generalizing hat functions to 2-D) 4 Produce n equations Ku = f from test functions {ψ i } (e.g., in Galerkin method, ψ i = φ i ) 5 Assemble and solve algebraic equation 1 Assemble stiffness matrix K and load vector f 2 Apply boundary conditions along 3 Solve Ku = f using sparse linear solver Xiangmin Jiao Finite Element Methods 7 / 18
Derivation of Weak Form Make residual f (x, y) + (c u) orthogonal to n test funcs {ψ i (x)} (c u)ψ i (x) dxdy = f (x, y)ψ i (x) dxdy (a.k.a. weighted-residual formulation) Applying Green s identity (i.e., integration by parts) w ψ i dxdy = wψ i dxdy + (w n)ψ i ds, where w = c u, and assuming ψ i D = 0, we obtain weak form (c u) ψ i dxdy = f ψ i dxdy + c u n ψ i ds N Question: Under what conditions is Green s identity valid? Xiangmin Jiao Finite Element Methods 8 / 18
Derivation of Weak Form Make residual f (x, y) + (c u) orthogonal to n test funcs {ψ i (x)} (c u)ψ i (x) dxdy = f (x, y)ψ i (x) dxdy (a.k.a. weighted-residual formulation) Applying Green s identity (i.e., integration by parts) w ψ i dxdy = wψ i dxdy + (w n)ψ i ds, where w = c u, and assuming ψ i D = 0, we obtain weak form (c u) ψ i dxdy = f ψ i dxdy + c u n ψ i ds N Question: Under what conditions is Green s identity valid? Answer: is simply connected with piecewise smooth boundary u and ψi are piecewise smooth and C 0 continuous over Xiangmin Jiao Finite Element Methods 8 / 18
Introduction of Trial Functions Introduce n trial functions {φ j } and approximate u(x, y) as u(x, y) U(x, y) = n U j φ j (x, y) Substituting it into weak form, we obtain Ku = f with u j = U j, k ij = c φ j ψ i dxdy and f i = f ψ i dxdy + c u N n ψ ids j=1 Xiangmin Jiao Finite Element Methods 9 / 18
Introduction of Trial Functions Introduce n trial functions {φ j } and approximate u(x, y) as u(x, y) U(x, y) = n U j φ j (x, y) Substituting it into weak form, we obtain Ku = f with u j = U j, k ij = c φ j ψ i dxdy and f i = f ψ i dxdy + c u N n ψ ids j=1 Given that ψ i is C 0, piecewise smooth with local support, desired properties of {φ j } include (regardless of whether {ψ j } = {φ i }): 1 (High-order) consistency of u U = n j=1 U jφ j with U j u(x j ) 2 C 0 continuity and piecewise smoothness of φ j over local support of ψ {φ j } & {ψ j } together should also ensure Ku = f is easy to solve Xiangmin Jiao Finite Element Methods 9 / 18
2-D Hat Functions (a.k.a. Pyramid Functions) is subdivided into elements, i.e., = k τ k Linear FEM uses piecewise linear Lagrange polynomials as {φ j } & {ψ} { 1 if i = j φ j (x i ) = 0 otherwise Within triangle, this uniquely defines linear Lagrange polynomial basis Patching local polynomials together resulting in 2-D hat functions or pyramid functions, which satisfy all the requirements of {ψ j } and {φ i } Xiangmin Jiao Finite Element Methods 10 / 18
Numerical Integration For x i D, integration of its corresponding row in linear system involves only elements containing x i For stiffness matrix: k ij = c φ j ψ i dxdy = For load vector: f i = {τ x i τ} τ f ψ i dxdy + {τ x i τ} {τ x i τ} where N τ denotes edges of element τ on N τ c φ j ψ i dxdy N τ c u n ψ ids In practice, linear system is assembled by building element matrices and element vectors (implementation detail for later lectures) Xiangmin Jiao Finite Element Methods 11 / 18
Apply Boundary Conditions Dirichlet BC u(x) = u 0 (x) for x D : If x j D, then U j u(x j ) = u 0 (x j ) from Dirichlet BC Typically, we create matrix only for nodes not on D Create rows of K only corresponding to x i D For x j D, do not store a ij but let f i f i {j x j D } a iju j Alternatively, make principle submatrix corresponding to nodes x j D identity matrix and let f j = U j Both preserve symmetry (and positive definiteness) of K Neumann BC n u = w 0(x) for x N : Substitute it into line integral for boundary edges on N f i = f ψ i dxdy + cw 0 ψ i ds τ k N τ k {k x i τ k } {k x i τ k } Xiangmin Jiao Finite Element Methods 12 / 18
Revisit 1-D Example for Applying Boundary Conditions Example: Solve u = 1 over [0, 1] with using uniform grid with h = 1 3. u(0) = 1, u (1) = 1 With essential BC u(0) = 0, and natural BC u (1) = 0: 6 3 U 1 1/3 3 6 3 U 2 = 1/3 3 3 U 3 1/6 With Direchlet BC u(0) = 1, and Neumann BC u (1) = 1: 6 3 U 1 1/3+3 3 6 3 U 2 = 1/3 3 3 U 3 1/6+1 Xiangmin Jiao Finite Element Methods 13 / 18
Solution of Resulting Linear System Let U(x, y) = n j=1 U jφ j (x, y). It can be shown that u T Ku = [ ( U ) 2 c + x ( ) ] U 2 y dxdy 0 Given that c(x) > 0, if K is nonsingular, K is positive definite Since K is sparse and SPD, efficient linear solvers exist For small problems, use sparse Cholesky factorization For intermediate problems, use iterative solver For very large problems, use multigrid methods We will discuss these issues in Part 3 of course Xiangmin Jiao Finite Element Methods 14 / 18
Robin Boundary Conditions Robin BC is linear combination of Dirichlet and Neumann BCs: au(x) + b u n (x) = g(x) for x R Robin BC is often most realistic BC for real-world problems; e.g., αt (0) = T (0) T ( ) in heat transfer means heat flux is proportional to difference between temperature at boundary and that of ambient media With Robin BC, weak form becomes c U j φ j φ i dxdy+a j R j f φ i dxdy + R U j c b φ jφ i ds = c b g(x)φ ids Xiangmin Jiao Finite Element Methods 15 / 18
Dirichlet BC as Special Case of Robin BC Dirichlet BC u(x) = u 0 (x) can be viewed as Robin BC with a = 1, b = 0, and g(x) = au 0 (x) In some literature, Dirichlet BC is enforced weakly by solving c U j φ j φ i dxdy + 1 U j cφ j φ i ds = ɛ j D j f φ i dxdy + 1 cu 0 (x)φ i ds ɛ D with some very small ɛ, where ɛ = O(h) Matrix is now K = K + 1 ɛ M, where M is mass matrix on D m ij = cφ i φ j ds D (mass matrix is important concept in FEM will reoccur later) Note: K will be ill-conditioned if ɛ < O(h) (later) Xiangmin Jiao Finite Element Methods 16 / 18
Generalization to 3-D All key components of FEM generalize to 3-D and higher dimensions In particular, weak form of Poisson equation is given by (c u) ψ i dv = f ψ i dv + c u n ψ i ds N 3-D domain is typically decomposed into tetrahedra (or other types of elements) for defining test & trial functions and for integration Linear FEM uses piecewise linear Lagrange basis functions Practical complexities associated with 3-D problems are typically associated in mesh generation and linear solvers Some equations also cause difficulties in stability, but they are typically not limited to 3-D (often also occur in 2-D and even 1-D) Xiangmin Jiao Finite Element Methods 17 / 18
Recommended Readings Section 3.6 of G. Strang (2007), Computational Science and Engineering (optional) Section 3.3 of G. Strang (2007), Computational Science and Engineering Xiangmin Jiao Finite Element Methods 18 / 18