Scientific Computing WS 2017/2018 Lecture 18 Jürgen Fuhrmann juergen.fuhrmann@wias-berlin.de Lecture 18 Slide 1
Lecture 18 Slide 2 Weak formulation of homogeneous Dirichlet problem Search u H0 1 (Ω) (here, tr u = 0) such that λ u v dx = fv dx v H0 1 (Ω) Then, Ω a(u, v) := Ω Ω λ u v dx is a self-adjoint bilinear form defined on the Hilbert space H0 1(Ω). It is bounded due to Cauchy-Schwarz: a(u, v) = λ u v dx u H 1 0 (Ω) v H 1 0 (Ω) Ω f (v) = Ω fv dx is a linear functional on H1 0 (Ω). For Hilbert spaces V the dual space V (the space of linear functionals) can be identified with the space itself. Lecture 14 Slide 23
Lecture 18 Slide 3 The Lax-Milgram lemma Let V be a Hilbert space. Let a : V V R be a self-adjoint bilinear form, and f a linear functional on V. Assume a is coercive, i.e. α > 0 : u V, a(u, u) α u 2 V. Then the problem: find u V such that a(u, v) = f (v) v V admits one and only one solution with an a priori estimate u V 1 α f V Lecture 14 Slide 24
Lecture 18 Slide 4 The Galerkin method II Let V be a Hilbert space. Let a : V V R be a self-adjoint bilinear form, and f a linear functional on V. Assume a is coercive with coercivity constant α, and continuity constant γ. Continuous problem: search u V such that a(u, v) = f (v) v V Let V h V be a finite dimensional subspace of V Discrete problem Galerkin approximation: Search u h V h such that a(u h, v h ) = f (v h ) v h V h By Lax-Milgram, this problem has a unique solution as well. Lecture 15 Slide 30
Lecture 18 Slide 5 Céa s lemma What is the connection between u and u h? Let v h V h be arbitrary. Then α u u h 2 a(u u h, u u h ) (Coercivity) = a(u u h, u v h ) + a(u u h, v h u h ) = a(u u h, u v h ) (Galerkin Orthogonality) γ u u h u v h (Boundedness) As a result u u h γ α inf v h V h u v h Up to a constant, the error of the Galerkin approximation is the error of the best approximation of the solution in the subspace V h. Lecture 15 Slide 31
Lecture 18 Slide 6 From the Galerkin method to the matrix equation Let φ 1... φ n be a set of basis functions of V h. Then, we have the representation u h = n j=1 u jφ j In order to search u h V h such that it is actually sufficient to require a(u h, v h ) = f (v h ) v h V h a(u h, φ i = f (φ i ) (i = 1... n) ( n ) a u j φ j, φ i = f (φ i ) (i = 1... n) j=1 n a(φ j, φ i )u j = f (φ i ) (i = 1... n) j=1 AU = F with A = (a ij ), a ij = a(φ i, φ j ), F = (f i ), f i = F (φ i ), U = (u i ). Matrix dimension is n n. Matrix sparsity? Lecture 15 Slide 32
Matrix properties a(, ) symmetric bilinear form A symmetric Coercivity A positive definite Lecture 18 Slide 7
Lecture 18 Slide 8 Barycentric coordinates Let K be a simplex. Functions λ i (i = 0... d): λ i : R d R x λ i (x) = 1 (x a i) n i (a j a i ) n i where a j is any vertex of K situated in F i. For x K, one has 1 (x a i) n i = (a j a i ) n i (x a i ) n i (a j a i ) n i (a j a i ) n i = (a j x) n i = dist(x, F i) (a j a i ) n i dist(a i, F i ) = dist(x, F i) F i /d dist(a i, F i ) F i /d = dist(x, F i) F i K i.e. λ i (x) is the ratio of the volume of the simplex K i (x) made up of x and the vertices of F i to the volume of K. Lecture 16 Slide 22
Lecture 18 Slide 9 Polynomial space P k Space of polynomials in x 1... x d of total degree k with real coefficients α i1...i d : Dimension: P k = p(x) = 0 i 1...i d k i 1+ +i d k α i1...i d x i1 1... x id d dim P k = ( ) d + k = k k + 1, d = 1 1 2 (k + 1)(k + 2), d = 2 (k + 1)(k + 2)(k + 3), d = 3 1 6 dim P 1 = d + 1 3, d = 1 dim P 2 = 6, d = 2 10, d = 3 Lecture 16 Slide 24
Lecture 18 Slide 10 P k simplex finite elements K: simplex spanned by a 0... a d in R d P = P k, such that s = dim P k For 0 i 0... i d k, i 0 + + i d = k, let the set of nodes be defined by the points a i1...i d ;k with barycentric coordinates ( i0 k... id k ). Define Σ by σ i1...i d ;k(p) = p(a i1...i d ;k). Lecture 16 Slide 25
Lecture 18 Slide 11 Conformal triangulations Let T h be a subdivision of the polygonal domain Ω R d into non-intersecting compact simplices K m, m = 1... n e : Ω = n e m=1 Each simplex can be seen as the image of a affine transformation of a reference (e.g. unit) simplex K: K m K m = T m ( K) We assume that it is conformal, i.e. if K m, K n have a d 1 dimensional intersection F = K m K n, then there is a face F of K and renumberings of the vertices of K n, K m such that F = T m ( F ) = T n ( F ) and T m F = T n F Lecture 16 Slide 32
Lecture 18 Slide 12 Conformal triangulations II d = 1 : Each intersection F = K m K n is either empty or a common vertex d = 2 : Each intersection F = K m K n is either empty or a common vertex or a common edge d = 3 : Each intersection F = K m K n is either empty or a common vertex or a common edge or a common face Delaunay triangulations are conformal Lecture 16 Slide 33
H 1 -Conformal approximation using Lagrangian finite elemenents Approximation spacev h with zero jumps at element faces: V h = {v h C 0 (Ω) : m, v h Km P k } Zero jumps at interfaces: n, m, K m K n 0 (v h Km ) Km K n = (v h Kn ) Km K n V h H 1 (Ω). Lecture 18 Slide 13
Lecture 18 Slide 14 Zero jump at interfaces with Lagrangian finite elements Assume geometrically conformal mesh Assume all faces of K have the same number of nodes s For any face F = K 1 K 2 there are renumberings of the nodes of K 1 and K 2 such that for i = 1... s, a K1,i = a K2,i Then, v h K1 and v h K2 match at the interface K 1 K 2 if and only if they match at the common nodes v h K1 (a K1,i) = v h K2 (a K2,i) (i = 1... s ) Lecture 17 Slide 23
Lecture 18 Slide 15 Global degrees of freedom Let {a 1... a N } = {a K,1... a K,s } K T h Degree of freedom map j : T h {1... s} {1... N} (K, m) j(k, m) the global degree of freedom number Global shape functions φ 1,..., φ N W h defined by φ i K (a K,m ) = { δ mn if n {1... s} : j(k, n) = i 0 otherwise Global degrees of freedom γ 1,..., γ N : V h R defined by γ i (v h ) = v h (a i ) Lecture 17 Slide 24
Lecture 18 Slide 16 Lagrange finite element basis {φ 1,..., φ N } is a basis of V h, and γ 1... γ N is a basis of L(V h, R). Proof: {φ 1,..., φ N } are linearly independent: if N j=1 α jφ j = 0 then evaluation at a 1... a N yields that α 1... α N = 0. Let v h V h. It is single valued in a 1... a N. Let w h = N j=1 v h(a j )φ j. Then for all K T h, v h K and w h K coincide in the local nodes a K,1... a K,2, and by unisolvence, v h K = w h K. Lecture 17 Slide 25
Lecture 18 Slide 17 P 1 global shape functions Lecture 17 Slide 27
Lecture 18 Slide 18 P 2 global shape functions Node based Edge based Lecture 17 Slide 28
Lecture 18 Slide 19 Affine transformation estimates I K: reference element Let K T h. Affine mapping: T K : K K x J K x + b K with J K R d,d, b K R d, J K nonsingular Diameter of K: h K = max x1,x 2 K x 1 x 2 ρ K diameter of largest ball that can be inscribed into K σ K = hk ρ K : local shape regularity Lecture 17 Slide 31
Lecture 18 Slide 20 Shape regularity Now we discuss a family of meshes T h for h 0. We want to estimate global interpolation errors and see how they possibly diminuish For given T h, assume that h = max K Th h j A family of meshes is called shape regular if In 1D, σ K = 1 In 2D, σ K 2 sin θ K h, K T h, σ K = h K ρ K σ 0 where θ K is the smallest angle Lecture 17 Slide 37
Lecture 18 Slide 21 Error estimates for homogeneous Dirichlet problem Search u H0 1 (Ω) such that Ω λ u v dx = Ω fv dx v H 1 0 (Ω) Then, lim h 0 u u h 1,Ω = 0. If u H 2 (Ω) (e.g. on convex domains) then u u h 1,Ω ch u 2,Ω u u h 0,Ω ch 2 u 2,Ω Under certain conditions (convex domain, smooth coefficients) one has u u h 0,Ω ch u 1,Ω ( Aubin-Nitsche-Lemma ) Lecture 17 Slide 40
Lecture 18 Slide 22 H 2 -Regularity u H 2 (Ω) may be not fulfilled e.g. if Ω has re-entrant corners if on a smooth part of the domain, the boundary condition type changes if problem coefficients (λ) are discontinuos Situations differ as well between two and three space dimensions Delicate theory, ongoing research in functional analysis Consequence for simuations Deterioration of convergence rate Remedy: local refinement of the discretization mesh using a priori information using a posteriori error estimators + automatic refinement of discretizatiom mesh Lecture 17 Slide 41
More complicated integrals Assume non-constant right hand side f, space dependent heat conduction coefficient κ. Right hand side integrals f i = P 1 stiffness matrix elements a ij = K K f (x)λ i (x) dx κ(x) λ i λ j dx P k stiffness matrix elements created from higher order ansatz functions Lecture 18 Slide 23
Quadrature rules Quadrature rule: K g(x) dx K l q l=1 ω l g(ξ l ) ξ l : nodes, Gauss points ω l : weights The largest number k such that the quadrature is exact for polynomials of order k is called order k q of the quadrature rule, i.e. k k q, p P k Error estimate: φ C kq+1 (K), 1 K K K p(x) dx = K φ(x) dx l q l=1 ch kq+1 K l q l=1 ω l g(ξ l ) ω l p(ξ l ) sup x K, α =k q+1 α φ(x) Lecture 18 Slide 24
Some common quadrature rules Nodes are characterized by the barycentric coordinates d k q l q Nodes Weights 1 1 1 ( 1, 1 ) 2 2 1 1 2, 1 2 1 2 (1, 0), (0, 1) 3 2 ( 1 + 3 3 3 3 2 6 2 6 2 6 2 6 1 2 2 5 3 ( 1, ), ( 1 + 3, 1 3 ), ( 1 3, 1 + 3 ) 8, 5, 5 2 2 20 2 20 2 20 2 20 18 18 18 2 1 1 ( 1, 1, 1 ) 1 3 3 3 1 1 3 (1, 0, 0), (0, 1, 0), (0, 0, 1), 1, 1 3 3 3 2 3 ( 1, 1, 0), ( 1, 0, 1 ), (0, 1, 1 ) 1, 1, 1 2 2 2 2 2 2 3 3 3 3 4 ( 1, 1, 1 ), ( 1, 1, 3 ), ( 1, 3, 1 ), ( 3, 1, 1 ), 9, 25, 25, 25 3 3 3 5 5 5 5 5 5 5 5 5 16 48 48 48 3 1 1 ( 1, 1, 1, 1 ) 1 4 4 4 4 1 4 (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) 2 4 ( 5 5, 5 5, 5 5, 5+3 5 )... 20 20 20 20 1, 1, 1, 1 4 4 4 4 1, 1, 1, 1 4 4 4 4 Lecture 18 Slide 25
Matching of approximation order and quadrature order Variational crime : instead of we solve a(u h, v h ) = f (v h ) v h V h a h (u h, v h ) = f h (v h ) v h V h where a h, f h are derived from their exact counterparts by quadrature For P 1 finite elements, zero order quadrature for volume integrals and first order quadrature for surface intergals is sufficient to keep the convergence order estimates stated before The rule of thumb for the volume quadrature is that the highest order terms must be evaluated exactly if the coefficients of the PDE are constant. Lecture 18 Slide 26
Practical realization of integrals Integral over barycentric coordinate function λ i (x) dx = 1 3 K K Right hand side integrals. Assume f (x) is given as a piecewise linear function with given values in the nodes of the triangulation f i = f (x)λ i (x) dx 1 3 K f (a i) K Integral over space dependent heat conduction coefficient: Assume κ(x) is given as a piecewise linear function with given values in the nodes of the triangulation a ij = κ(x) λ i λ j dx = 1 3 (κ(a 0)+κ(a 1 )+κ(a 2 )) λ i λ j dx K K Lecture 18 Slide 27
Stiffness matrix for Laplace operator for P1 FEM Element-wise calculation: a ij = a(φ i, φ j ) = φ i φ j dx = Standard assembly loop: for i, j = 1... N do set a ij = 0 end for K T h do for m,n=0... d do s mn = λ m λ n dx end end K Ω Ω a jdof (K,m),j dof (K,n) = a jdof (K,m),j dof (K,n) + s mn K T h φ i K φ j K dx Local stiffness matrix: S K = (s K;m,n ) = λ m λ n dx K Lecture 18 Slide 28
Local stiffness matrix calculation for P1 FEM a 0... a d : vertices of the simplex K, a K. Barycentric coordinates: λ j (a) = Kj (a) K For indexing modulo d+1 we can write K = 1 d! det ( a j+1 a j,... a j+d a j ) K j (a) = 1 d! det ( a j+1 a,... a j+d a ) From this information, we can calculate explicitely λ j (x) (which are constant vectors due to linearity) and the corresponding entries of the local stiffness s ij = λ i λ j dx K Lecture 18 Slide 29
Local stiffness matrix calculation for P1 FEM in 2D a 0 = (x 0, y 0 )... a d = (x 2, y 2 ): vertices of the simplex K, a = (x, y) K. Barycentric coordinates: λ j (x, y) = Kj (x,y) K For indexing modulo d+1 we can write K = 1 ( ) 2 det xj+1 x j x j+2 x j y j+1 y j y j+2 y j K j (x, y) = 1 ( ) 2 det xj+1 x x j+2 x y j+1 y y j+2 y Therefore, we have K j (x, y) = 1 2 ((x j+1 x)(y j+2 y) (x j+2 x)(y j+1 y)) x K j (x, y) = 1 2 ((y j+1 y) (y j+2 y)) = 1 2 (y j+1 y j+2 ) y K j (x, y) = 1 2 ((x j+2 x) (x j+1 x)) = 1 2 (x j+2 x j+1 ) Lecture 18 Slide 30
Local stiffness matrix calculation for P1 FEM in 2D II s ij = K λ i λ j dx = ( ) x1 x So, let V = 0 x 2 x 0 y 1 y 0 y 2 y 0 Then K ( ) ( ) yj+1 y yi+1 y 4 K 2 i+2, x i+2 x j+2 i+1 x j+2 x j+1 x 1 x 2 = V 00 V 01 and y 1 y 2 = V 10 V 11 ( ) ( ) y1 y 2 K λ 0 = 2 V10 V = 11 x 2 x 1 V 01 V 00 ( ) ( ) y2 y 2 K λ 1 = 0 V11 = x 0 x 2 V 01 ( ) ( ) y0 y 2 K λ 2 = 1 V10 = x 1 x 0 V 00 Lecture 18 Slide 31
Degree of freedom map representation for P1 finite elements List of global nodes a 0... a N : two dimensional array of coordinate values with N rows and d columns Local-global degree of freedom map: two-dimensional array C of index values with N el rows and d + 1 columns such that C(i, m) = j dof (K i, m). The mesh generator triangle generates this information directly Lecture 18 Slide 32
Practical realization of boundary conditions Robin boundary value problem κ u = f κ u + α(u g) = 0 in Ω on Ω Weak formulation: search u H 1 (Ω) such that Ω κ u v dx + αuv ds = fv dx + αgv ds v H 1 (Ω) Ω Ω Ω In 2D, for P 1 FEM, boundary integrals can be calculated by trapezoidal rule without sacrificing approximation order Use Dirichlet penalty method to handle Dirichlet boundary conditions Lecture 18 Slide 33
Next lecture Next lecture: Jan. 9, 2018. Happy holidays! Lecture 18 Slide 34