Jasmin Smajic 1, Christian Hafner 2, Jürg Leuthold 2, March 16, 2015 Introduction to Finite Element Method (FEM) Part 1 (2-D FEM) 1 HSR - University of Applied Sciences of Eastern Switzerland Institute of Energy Technology (IET) Obersstrasse 10, Rapperswil, Switzerland jasmin.smajic@hsr.ch 2 Swiss Federal Institute of Technology (ETH) Institute of Electromagnetic Fields (IEF) Gloriastrasse 35, CH-8092 Zürich, Switzerland christian.hafner@ief..ethz.ch, juerg.leuthold@ief..ethz.ch
Contents (1) Introduction: finite elements in Nature Boundary value problem (BVP) - strong form FEM discretization of the 2-D BVP Equivalent integral form - weak form Domain subdivision Approximation of the unknown function Mesh topology Approximation of a scalar function Isolines of the approximated function Weak form discretization Selection of the weighting functions Matrix assembly Matrix structure and solution methods
Contents (2) FEM sparse linear system of equations Numerical examples (2-D scalar FEM) Electrostatic analysis and capacitance calculation Analysis of waveguide discontinuities Summary
Introduction Finite Elements in Nature Ancient lakebed with cracked dried mud, Black Rock Desert, Nevada, USA.
Introduction Finite Elements in Nature Cracked mud and shallow pond, near Mitzpe Ramon, Negev Desert, Israel.
Boundary Value Problem (BVP) General 2-D Form (Strong Form) The PDE of second order along with the corresponding BCs form the BVP: αα xx αα yy + ββββ = ff, xx, yy Ω RR2 ΦΦ xx, yy = pp, (xx, yy) DD Ω αα xx xx xx + αα yy yy yy nn = qq, (xx, yy) NN Ω DD NN = = bbbbbbbbbbbbbbbb() where is the computational domain, αα and ββ are constants representing the material properties, ff is a predefined source term, nn is a normal outward unit vector at a certain point on the Neumann boundary, and ΦΦ is an unknown function.
FEM Discretization of the 2-D BVP Equivalent Integral Form (Weak Form) The method of weighted residuals is used in order to obtain an equivalent integral form of the 2-D BVP: ww ii αα xx αα yy + ββββ ff dd + + DD Ω ww ii ΦΦ pp dddd + NN ww ii αα xx xx xx + αα yy yy yy nn qq dddd = 0 DD NN = = bbbbbbbbbbbbbbbb() where ww ii = ww ii xx, yy, ii = 1,2,, NN are so called weighting functions.
FEM Discretization of the 2-D BVP Equivalent Integral Form (Weak Form) Mathematical transformation of the first integral: II 1 = ww ii αα xx II 1 = ww ii αα xx αα yy αα yy + ββββ ff dd dd + ww ii ββββ ff dd = II 11 + II 12 II 11 = ww ii αα xx II 11 = II 11 = ww ii αα yy dd = xx + yy αα xx xx + αα yy yy ww ii αα xx xx + αα yy yy dd ww ii dd αα xx + αα yy dd
FEM Discretization of the 2-D BVP Equivalent Integral Form (Weak Form) Mathematical transformation of the first integral: II 11 = ww ii αα xx xx + αα yy yy dd The function under this integral can be transformed in the following form: ww ii αα xx xx + αα yy yy = = ww ii αα xx xx + αα yy yy ww ii αα xx xx + αα yy yy By introducing it into the integral I 11 the following form is obtained: II 11 = ww ii αα xx xx + αα yy yy dd + ww ii αα xx xx + αα yy yy dd
FEM Discretization of the 2-D BVP Equivalent Integral Form (Weak Form) The obtained form of the integral I 11 : II 11 = ww ii αα xx xx + αα yy yy dd + ww ii can be further transformed by using Grn s theorem: ww ii αα xx xx + αα yy yy dd = ww ii αα xx xx + αα yy yy αα xx xx + αα yy yy nn dddd dd Thus the Integral I 11 becomes: II 11 = ww ii αα xx xx + αα yy yy nn dddd + ww ii αα xx xx + αα yy yy dd
FEM Discretization of the 2-D BVP Equivalent Integral Form (Weak Form) In the last integral form (Slide 10) the boundary integrals can be merged: ww ii αα xx xx + αα yy yy dd NN + ww ii ββββ ff dd + ww ii qq dddd DD ww ii DD Ω ww ii ΦΦ pp dddd + αα xx xx + αα yy yy nn dddd = 0
FEM Discretization of the 2-D BVP Equivalent Integral Form (Weak Form) Over the Dirichlet boundaries the values of the unknown function is known and therefore the weighting functions can be there set to zero: ww ii xx, yy = 0, (xx, yy) DD Thus the equivalent integral form becomes: ww ii αα xx xx + αα yy yy dd + ww ii ββββ dd ww ii ff dd NN ww ii qq dddd = 0 This form is sometimes called the weak form of the BVP from Slide 5. The name weak comes from the fact that this form consists of only partial derivatives of first order, while the partial derivatives in the BVP are of second order ( strong form).
FEM Discretization of the Weak Form Domain Subdivision (Meshing) 2D computational domain: Domain subdivision (triangular mesh): Meshing Computational domain is of arbitrary shape (usually very complex geometry) Mesh consists of a large number of elements with simple geometry (triangles, quadrilaterals)
FEM Discretization of the Weak Form Domain Subdivision (Meshing) The original weak form: Subdivision: αα ww ii dd + ww ii ββββ dd ww ii ff dd = NN =1 The corresponding weak form after the subdivision: NN ww ii qq dddd = 0 NN =1 αα ww ii ΦΦ dd + NN =1 ww ii NN ββ ΦΦ dd =1 ww ii ff dd Ω NN where the superscript e refers to a local approximation within the element e. ww ii qq ddll = 0 Ω
FEM Discretization of the Weak Form Approximation of the Unknown Function Linear triangular element: Linear approximation of the unknown function over the element: ΦΦ xx, yy = aa + bbbb + cccc (1) The thr unknown coefficients of the approximation can be expressed with respect to the nodal values of the unknown function: The coordinates of the nodes are known (given by the mesh generator). ΦΦ 1 = aa + bbxx 1 + ccyy 1 ΦΦ 2 = aa + bbxx 2 + ccyy 2 ΦΦ 3 = aa + bbxx 3 + ccyy 3
FEM Discretization of the Weak Form Approximation of the Unknown Function Linear triangular element: It is useful to write the approximation equations in matrix form: ΦΦ xx, yy = aa + bbbb + cccc ΦΦ xx, yy = 1 xx yy aa bb cc (2) ΦΦ 1 = aa + bbxx 1 + ccyy 1 ΦΦ 2 = aa + bbxx 2 + ccyy 2 ΦΦ 3 = aa + bbxx 3 + ccyy 3 The coordinates of the nodes are known (given by the mesh generator). ΦΦ 1 ΦΦ 2 ΦΦ 3 = 1 xx 1 yy 1 1 xx 2 yy 2 1 xx 3 yy 3 aa bb cc = SS aa bb cc (3)
FEM Discretization of the Weak Form Approximation of the Unknown Function According to Equation (3) the coefficient of the function approximation are: aa bb cc = SS 1 ΦΦ 1 ΦΦ 2 ΦΦ 3 (4) The inversion of the matrix SS is not so difficult to find: SS 1 = 1 xx 1 yy 1 1 xx 2 yy 2 1 xx 3 yy 3 1 = 1 2AA xx 2 yy 3 xx 3 yy 2 xx 3 yy 1 xx 1 yy 3 xx 1 yy 2 xx 2 yy 1 yy 2 yy 3 yy 3 yy 1 yy 1 yy 2 xx 3 xx 2 xx 1 xx 3 xx 2 xx 1 where A is the surface area of the triangular element: AA = xx 2 xx 1 yy 3 yy 1 xx 3 xx 1 yy 2 yy 1
FEM Discretization of the Weak Form Approximation of the Unknown Function Finally, the approximation of the unknown function becomes: ΦΦ xx, yy = 1 aa 4 xx yy bb ΦΦ xx, yy = 1 xx yy SS 1 cc or even more detailed description: ΦΦ 1 ΦΦ 2 ΦΦ 3 (4) ΦΦ xx, yy = 1 xx yy 1 2AA xx 2 yy 3 xx 3 yy 2 xx 3 yy 1 xx 1 yy 3 xx 1 yy 2 xx 2 yy 1 yy 2 yy 3 yy 3 yy 1 yy 1 yy 2 xx 3 xx 2 xx 1 xx 3 xx 2 xx 1 ΦΦ 1 ΦΦ 2 ΦΦ 3 (5) The last equation is usually written in the following form: ΦΦ xx, yy = NN 1 (xx, yy) NN 2 (xx, yy) NN 3 (xx, yy) ΦΦ 1 ΦΦ 2 ΦΦ 3 3 = NN ii (xx, yy) ΦΦ ii ii=1 (6)
FEM Discretization of the Weak Form Approximation of the Unknown Function The final form of the approximation of the unknown function is thus obtained (Eq. (6)): 3 ΦΦ xx, yy = NN ii (xx, yy) ΦΦ ii ii=1 where NN ii (xx, yy) is the shape function of the node i of the element e. The shape function of a linear triangular element are also obtained (Equation (5)): NN 1 xx, yy = 1 2AA xx 2 yy 3 xx 3 yy 2 + yy 2 yy 3 xx + xx 3 xx 2 yy NN 2 xx, yy = 1 2AA xx 3 yy 1 xx 1 yy 3 + yy 3 yy 1 xx + xx 1 xx 3 yy NN 3 xx, yy = 1 2AA xx 1 yy 2 xx 2 yy 1 + yy 1 yy 2 xx + xx 2 xx 1 yy
FEM Discretization of the Weak Form Approximation of the Unknown Function The shape functions of a linear triangular element: A scalar shape function linearly increases its value over the triangle starting with zero along the edge opposite to its corresponding node and ending with 1 at the corresponding node. The most important properties of the shape functions are: NN ii xx jj, yy 0, ii jj jj = 1, ii = jj 3 NN ii (xx, yy) = 1, (xx, yy) Ω ii=1
FEM Discretization of the Weak Form Local Character of the Shape Functions ii 1.0 0.8 0.6 0.4 The shape function of the node i lives on all the elements that contain this node: NN ii TT ii = xx, yy 0, (xx, yy) TT ii ii 0.2 Everywhere else is the shape function equal to zero: 0.0 NN ii xx, yy = 0, xx, yy TT ii
FEM Discretization of the Weak Form Local Character of the Shape Functions Due to the local character of the shape functions, it is rather simple to switch from the local (element based) notation to the global (computational domain) notation: 3 NN nn NN ii ΦΦ xx, yy = NN ii (xx, yy) ΦΦ LLoooooooo tttt GGGGGGGGGGGG NNNNNNNNNNNNNNNN ii ΦΦ xx, yy = (xx, yy) ΦΦ ii ii=1 ii=1
Numerical Example Mesh Topology Nodes (black) - coordinates: Node 1: xx 1, yy 1 = (0.70,0.10) Node 2: xx 2, yy 2 = (0.85,0.40) Node 3: xx 3, yy 3 = (0.73,0.67) Node 4: xx 4, yy 4 = (0.50,0.69) Node 5: xx 5, yy 5 = (0.30,0.35) Node 6: xx 6, yy 6 = (0.45,0.22) Node 7: xx 7, yy 7 = (0.60,0.43) Elements (red) - topology: Element 1: (nnnnnnnn 1, nnnnnnnn 2, nnnnnnnn 3 ) = (1,7,6) Element 2: (nnnnnnnn 1, nnnnnnnn 2, nnnnnnnn 3 ) = (1,2,7) Element 3: (nnnnnnnn 1, nnnnnnnn 2, nnnnnnnn 3 ) = (2,3,7) Element 4: (nnnnnnnn 1, nnnnnnnn 2, nnnnnnnn 3 ) = (3,4,7) Element 5: (nnnnnnnn 1, nnnnnnnn 2, nnnnnnnn 3 ) = (4,5,7) Element 6: (nnnnnnnn 1, nnnnnnnn 2, nnnnnnnn 3 ) = (5,6,7)
Numerical Example Approximation of a Scalar Function Assumption nodal field values are known: Node 1: ΦΦ xx 1, yy 1 = ΦΦ 1 = 1.2 Node 2: ΦΦ xx 2, yy 2 = ΦΦ 2 = 0.9 Node 3: ΦΦ xx 3, yy 3 = ΦΦ 3 = 0.8 Node 4: ΦΦ xx 4, yy 4 = ΦΦ 4 = 0.8 Node 5: ΦΦ xx 5, yy 5 = ΦΦ 5 = 1.5 Node 6: ΦΦ xx 6, yy 6 = ΦΦ 6 = 1.4 Node 7: ΦΦ xx 6, yy 6 = ΦΦ 7 = 1.5 The function ΦΦ is approximated over the elements of the mesh according to the following equation (global notation): NN nn NN ii ΦΦ xx, yy = ii=1 (xx, yy) ΦΦ ii
Numerical Example Isolines of the Approximated Function The function ΦΦ is approximated over the elements of the mesh according to the following equation (global notation): NN nn NN ii ΦΦ xx, yy = (xx, yy) ΦΦ ii ii=1 The visualized isolines reveal the linear character of our approximation.
FEM Sparse Linear System of Equations Weak Form Discretization The original weak form: Subdivision: αα ww ii dd + ww ii ββββ dd ww ii ff dd = NN =1 The corresponding weak form after the subdivision: NN ww ii qq dddd = 0 NN =1 αα ww ii ΦΦ dd + NN =1 ww ii NN ββ ΦΦ dd =1 ww ii ff dd Ω NN where the superscript e refers to a local approximation within the element e. ww ii qq ddll = 0 Ω
FEM Sparse Linear System of Equations Weak Form Discretization If we introduce the local approximation of the unknown function: 3 ΦΦ xx, yy = NN jj (xx, yy) ΦΦ jj jj=1 into the corresponding weak form obtained after the computational domain subdivision: NN =1 αα ww ii ΦΦ dd + NN =1 the following form is obtained: NN =1 NN =1 αα ww ii jj=1 3 ww ii ff dd ww ii NN jj (xx, yy) ΦΦ jj dd + Ω NN NN ββ ΦΦ dd NN =1 ww ii qq dddd = 0 Ω =1 3 ww ii ββ jj=1 ww ii ff dd Ω NN NN jj (xx, yy) ΦΦ jj dd ww ii qq ddll = 0 Ω
FEM Sparse Linear System of Equations Weak Form Discretization Concerning the obtained form: NN =1 NN =1 3 αα ww ii jj=1 ww ii ff dd NN jj (xx, yy) ΦΦ jj dd + Ω NN =1 ww ii qq dddd = 0 Ω 3 ww ii ββ jj=1 NN jj (xx, yy) ΦΦ jj dd it is beneficial to switch from the local to the global approximation of the unknown function, and to reverse the order of the nested sums: NN nn ΦΦ jj jj=1 NN =1 ssssssssssssss(nn jj ) NN nn αα ww ii jj dd + ΦΦ jj jj=1 ww ii ffdd ww ii qq dddd = 0 Ω Ω NN ssssssssssssss(nn jj ) ββ ww ii NN jj dd
FEM Sparse Linear System of Equations Selection of the Weighting Functions Up to now the weighting functions ww ii were not discussed. According to the well established mathematical foundations of FEM, for the selection of the weighting functions the so-called Galerkin method has a clear advantage in terms of accuracy over the other methods. Galerkin method suggests that the shape functions themselves play a role of the weighting functions: ww ii (xx, yy) = NN ii (xx, yy) Thus the weak form becomes: NN nn ΦΦ jj jj=1 ssssssssssssss(nn jj ) NN nn αα NN ii jj dd + ΦΦ jj jj=1 ssssssssssssss(nn jj ) ββ NN ii NN jj dd ssssssssssssss(nn ii ) NN ii ffdd NN ii qq dddd = 0 ssssssssssssss(nn ii ) Ω Ω NN
FEM Sparse Linear System of Equations Selection of the Weighting Functions The final equation of the weak form: NN nn ΦΦ jj jj=1 ssssssssssssss NN ii ssssssssssssss NN jj αα NN ii jj dd + NN nn + ΦΦ jj jj=1 ssssssssssssss(nn ii ) ssssssssssssss(nn jj ) ββ NN ii NN jj dd ssssssssssssss(nn ii ) NN ii ffdd NN ii qq dddd = 0 ssssssssssssss(nn ii ) Ω Ω NN can be written for each shape function NN ii, ii = 1,2,, NN nn. Thus, we have obtained a square system of NN nn linear equations with NN nn unknowns.
FEM Sparse Linear System of Equations Matrix Assembly According to the last equation the FEM linear system has the following form: where the matrix entries are: KK Φ = bb KK iiii = ssssssssssssss NN ii ssssssssssssss NN jj αα NN ii jj dd + ssssssssssssss NN ii ssssssssssssss NN jj ββ NN ii NN jj dd the right-hand side vector components are: bb ii = ssssssssssssss(nn ii ) NN ii ffdd + NN ii ssssssssssssss(nn ii ) Ω Ω NN and Φ is the unknown vector containing all the coefficients of the approximation of the unknown function. qq dddd
FEM Sparse Linear System of Equations Matrix Assembly (Elemental Contributions) According to the last equation the FEM linear system has the following form: KK Φ = bb where the matrix entries are: KK iiii = ssssssssssssss NN ii ssssssssssssss NN jj KK iiii the right-hand side vector components are: bb ii = ssssssssssssss(nn ii ) bb ii It is evident that each element contributes to the matrix and to the right-hand side.
FEM Sparse Linear System of Equations Matrix Assembly (Elemental Contributions) It is evident that each element contributes to the matrix and to the right-hand side: KK iiii = αα NN ii jj dd + ββ NN ii NN jj dd, ii, jj = 1,2,3 bb ii = NN ii ffdd + NN ii qq dddd, ii = 1,2,3 Ω
FEM Sparse Linear System of Equations Matrix Assembly (Elemental Contributions) It is evident that each element contributes to the matrix and to the right-hand side: [ ] e K { b e }
FEM Sparse Linear System of Equations Matrix Structure Typical sparse structure of the FEM matrix
FEM Sparse Linear System of Equations Solution Methods Direct solution of the FEM system of equations LU-decomposition Cholesky factorization Direct methods are impractical for large systems (above 10 6 unknowns) due to its high number of mathematical operations and round-off error. Iterative solution methods CG BiCG GMRES Iterative methods are very suitable for large systems but have a slow convergence when the FEM matrix is ill-conditioned (which is usually the case) Convergence acceleration could be achieved by using preconditioning methods: diagonal preconditioning, ILU (incomplete-lu), etc.
Numerical Examples (2-D Scalar FEM) Electrostatic Analysis and Capacitance Calculation V V ε r ε r = x x y y ρ ε 0 ε r = 1 ρ = 0 V = 0 n V = 0 V =1 ε r = 5
Numerical Examples (2-D Scalar FEM) Electrostatic Analysis and Capacitance Calculation Complete MATLAB Code for this example could be downloaded from the document repository. Triangular mesh Field plot N e =1399, N dof =1492 Equipotential lines Electric field vectors
Numerical Examples (2-D Scalar FEM) Analysis of Waveguide Discontinuities
Numerical Examples (2-D Scalar FEM) Analysis of Waveguide Discontinuities Theoretical description and Matlab-Code: http://homepage.swissonline.ch/jasmin/waveguide_bend1.htm
Summary (1) The fundamental idea of the finite element method can be observed in natural processes such as cracking of dried mud, for example. FEM does not discretize the original BVP (strong form) but the so called equivalent integral form (weak form). The weak form can be obtained from the general BVP by integrating its weighted residuals over the computational domain (the method of weighted residuals). Numerous practical simulation problems are special cases of the general BVP, i.e. of the general weak form presented (electrostatic, magnetostatic, thermal, etc. analyses). As an example, the general FEM-theory was applied to the problem of computing the leakage magnetic flux of a typical transformer winding configuration.
Summary (2) The FEM discretization process starts with domain discretization or subdivision. This subdivision is also called meshing and in this process topologically simple elements (triangles, quadrilaterals) are used. After the mesh of the computational domain is established, the integrals of the weak form are reduced to the corresponding finite sums. The unknown function is approximated over the elements of the mesh by using linear, quadratic, cubic, etc. shape functions. As a result of the approximation, the unknown function is represented as a sum of the known shape functions multiplied with the corresponding approximation coefficients. The unknown coefficients of this approximation are the nodal values of the unknown function. The shape functions are defined for each node of the mesh and have a local character. This means that a shape function has non-zero values only over those elements that contain its particular node.
Summary (3) For the selection of the weighting functions the so-called Galerkin method has a clear advantage in terms of accuracy over the other available methods (for example the point collocation or subdomain collocation). Galerkin method suggests that the shape functions themselves play a role of the weighting functions. Due to the local character of the shape functions the obtained linear equations system is sparse, i.e. the majority of its matrix entries are equal to zero. There are several modern direct (LU-decomposition, Cholesky-factorization, etc.) and iterative (CG, BiCG, GMRES, etc.) for solving of large FEM linear systems. The iterative solution methods have an advantage in terms of their complexity and accuracy over the direct methods but they usually have slow convergence since the FEM matrices are almost exclusively ill-conditioned. The convergence rate of the iterative methods could be accelerated by applying an appropriate preconditioner (diagonal preconditioner, incomplete-lu, etc.)
Literature Wolfram MathWorld, the web s most extensive mathematics resource, http://mathworld.wolfram.com/. J. D. Jackson, Classical Electrodynamics, Third Edition, John Wiley & Sons, New York, 1998. N. Ida, Enginring Electromagnetics, Second Edition, Springer-Verlag, New York, 2004. J. Jin, The Finite Element Method in Electromagnetics, Second Edition, John Wiley & Sons, New York, 2002.