P0 Raviart-Thomas Finite Element Implementation Of
Total Page:16
File Type:pdf, Size:1020Kb
1 Jurnal Matematika Integratif. p-ISSN:1412-6184, e-ISSN:2549-903 2 Vol. xx, No. xx (20xx), pp. xx{xx. doi:10.24198/jmi.vxx.ny.xxxx.y-yy 3 A mixed RT0 − P0 Raviart-Thomas finite element implementation of 4 Darcy Equation in GNU Octave 1 1;y 5 Agah D. Garnadi , C. Bahriawati 1 6 Jurusan Matematika, Fakultas MIPA, Institut Pertanian Bogor, Indonesia, e-mail: 7 [email protected] 8 Abstrak In this paper we shall describe mixed formulations -differential and variational- of Darcys flow equation, an important model of elliptic problem. We describe * 9 Galerkin method with finite dimensional spaces; * Local matrices and assembling; * Raviart-Thomas RT0 − P0 elements; * Edge basis and local matrices for RT0 − P0 FEM; * Model problem with corresponding local matrices, right hand side and treatment of boundary conditions. A simple demo written in GNU Octave is given. Kata kunci: Persamaan Darcy, Aliran di bahan berpori, Flux, Kekekalan Local, 10 Metode Elemen Hingga Campuran Abstract In this paper we shall describe mixed formulations -differential and variational- of Darcys flow equation, an important model of elliptic problem. We describe * 11 Galerkin method with finite dimensional spaces; * Local matrices and assembling; * Raviart-Thomas RT0 − P0 elements; * Edge basis and local matrices for RT0 − P0 FEM; * Model problem with corresponding local matrices, right hand side and treatment of boundary conditions. A simple demo written in GNU Octave is given. Keywords: Darcy flow, Flow in porous media, Flux, Local conservation, Mixed finite 12 element methods 13 Contents 14 1 Introduction 1 15 2 Problem formulation 1 16 3 Galerkin method -Mixed FEM 2 17 4 Local matrices and assembling 3 18 5 Lowest order Raviart-Thomas finite elements 3 19 6 Local properties and local edge basis for RT(0) elements 4 20 7 Local matrices 5 21 8 Model problem 7 22 9 Assembling 9 23 1. Introduction 24 This report describes basis of RT1 code, which can be characterized as a code for test- 25 ing solvers and preconditioners for FEM systems arising from lowest order Raviart-Thomas 26 discretization of Darcy flow problems, see also [2] [1] 2000 Mathematics Subject Classification: 65N15; 65M30 Received: dd-03-2020, accepted: dd-mm-yyyy. 1 2Garnadi & Bahriawati, JMI Vol x No y Okt/Apr 2020, pp. xx-yy,doi:10.24198/jmi.vxx.ny.xxxx.y-yy 27 The code is characterized by simplicity and possibility of easy modifications, 28 • directly solving model problems on square domains (generalization possible), 29 • stochastic generation of heterogeneity, 30 • fast system assembling using vectorization and sparse reconstruction, 31 • possible testing of Krylov type solvers with both (block) matrix and matrix free (vari- 32 able) preconditioners. 33 This report describes the finite element system generation, experiments are involved in 34 papers, e.g. [3]. 35 2. Problem formulation 36 Let us consider Darcy flow elliptic problem in the form −div(k(−g + grad p) = f in Ω p =p ^ on ΓD (−k grad p) · n =u ^ on ΓN 37 where g 6= 0 if we consider elevation changes. It can be also written in a two field form 1 n 38 with two basic variables p :Ω ! R and u :Ω ! R ; k−1u + grad p = g in Ω div(u) = f 39 p =p ^ on ΓD (−k grad p) · n =u ^ on ΓN 40 The variational formulation uses test functions v and q to get R k−1u · vdx + R rp · vdx = R g · vdx RΩ Ω RΩ Ω div(u)q = Ω fqdx 41 Transformation of one mixed term then provides R R P @p P R R @vk rp · v = vkdx = f pvk · nk − p dxg Ω RΩ k @xk R k @Ω Ω @xk = @Ω p(v · n) − Ω pdiv(v)dx 42 Then the variational formulation gets the form R k−1u · v − R div(v) · p = R g · vdx − R p^(v · n) − R p(v · n) 8v RΩ Ω RΩ ΓD ΓN Ω div(u)q = Ω fq 8q 43 {or in abstract form: find (u; p) 2 UN × P m(u; v) + b(v; p) = G(v) 8v 2 U0 b(u; q) = F (v) 8q 2 P 44 where n U = fv 2 L2(Ω) : div(v) 2 L2(Ω)g ! H(div) U0 = fv 2 U : v · n = 0 on ΓN g UN = fv 2 U : v · n =u ^ on ΓN g P = fq 2 L2(Ω)g R 45 Note that pressure BC enters G(v) = ::: − p^(v · n) whereas velocity BC are included Γ0 46 in UN : Darcy - Raviart-Thomas Element 3 47 3. Galerkin method -Mixed FEM 48 We start with introducing FEM spaces Uh ⊂ U; UNh ⊂ UN ;U0h ⊂ U0 and Ph ⊂ P: 49 Then the Galerkin method is to find (uh; ph) ⊂ UhN × Ph m(uh; vh) + b(vh; ph) = G(vh) 8vh 2 U0h b(uh; qh) = F (qh) 8ph 2 Ph 50 After a choice of bases Uh = linfΦi; i 2 Ig;Ph = linfΨj : j 2 Jg UNh = uN + u; u 2 U0h U0h = linfΦi : i 2 I0g X uN 2 linfΦi : i 2 InI0g; uN = (^u · n)(xi)Φi 51 the discrete mixed problem can be written as -find (uh; ph) 2 UhN × Ph; uh = uN + P P 52 α Φ ; p = β Ψ i2I0 i i h j2J j j P α m(Φ ; Φ ) + P β b(Φ ; Ψ ) = G(Φ ) − m(u ; Φ ) 8k 2 I i2I0 i i k j2J j k j k N k 0 P α b(Φ ; Ψ ) = F (Ψ ) − b(u ; Ψ ) 8l 2 J i2I0 i i l l N l 53 Rewriting to matrix form provides T n1 Bα + B β = G; α 2 R ; n1 = #I0 n2 Bα = F; β 2 R ; n2 = #J n1×n1 n2×n1 T n1×n2 T 54 where M 2 R ;Mij = m(Φj; Φi);B 2 R ;Bij = b(Φj; Ψi);B 2 R ;Bij = 55 b(Φi; Ψj) = Bji;G = (Gi);Gi = G(Φi);F = (Fk);Fk = F (Ψk): 56 4. Lowest order Raviart-Thomas finite elements 2 57 Let Ω 2 R be a 2D polygonal domain, Th be its triangulation, Eh be set of edges of all 58 elements T 2 Th see the situation in the following Figure 1. 59 Then, we can define 2 T T RT0(T ) = fv : T ! R ; v(x) = ξ[x1 x2] + [η1 η2] ; ξ; η1; η2 2 Rg 60 2 Uh = fv :Ω 2 R ; vjT 2 RT0(T ) 8T 2 Th; v · nE is continuous over E 2 Ehg 1 Ph = fq :Ω 2 R ; qjT is constant 8T 2 Thg: 61 Continuity of ν · nE guarantees Uh 2 U; Ph 2 P is obvious. Note that 8E 2 Eh we define 62 nE (unit normal vector), independently of relation to triangles and consequently in possibly 63 inner or outer direction, see Figure 2. 64 6 Local properties and local edge basis for RT(0) elements 65 Lemma 4.1. Let T 2 Th; v 2 RT0(T ): Then 8E 2 Eh [ @T : v · njE = const. ∗ 66 Proof. Let E 2 Eh [ @T; nE be normal to E (can be either outer or inner to T ), x 2 E be 67 arbitrary point at E: Then ∗ ∗ ∗ x 2 E ) (x − x ) · nE = 0; nE = (n1; n2) ) x1n1 + x2n2 = x1n1 + x2n2 = const: ) 68 ∗ ∗ v(x) · n = ξx1n1 + ξx2n2 + η1n1 + η2n2 = ξ(x1n1 + x2n2) + η1n1 + η2n2 = const : 69 4Garnadi & Bahriawati, JMI Vol x No y Okt/Apr 2020, pp. xx-yy,doi:10.24198/jmi.vxx.ny.xxxx.y-yy (i) (j) Gambar 1. fx g set of centres of Ei 2 Eh; fy g barycentres of Tj 2 Th Gambar 2. Prescribed normal nE: Possible definition of nE;E 2 Eh: Gambar 3. Triangle T 2 Th: Darcy - Raviart-Thomas Element 5 70 Lemma 4.2. (Expression for local basis functions.) Let E Φ (x) = σ i (x − P ); σ = n n(i); i i 2jT j i i Ei (i) 71 where nEi are global prescribed normals and n are outer normals for T 2 Th; see Figure 72 3. Then 73 (i)Φ j(x) · nEi = δij; 74 (ii)Φ i 2 RT0(T ); 75 (iii)Φ 1; Φ2; Φ3 create a basis of RT0(T ); Ei 76 (iv) divΦi = σi jT j : 77 Proof. (i) If i 6= j; then Pi 2 Ej and (x − Pi) · nEj = 0 for x 2 Ej: If i = j then for 78 x 2 Ei the value (x − Pi) · nEi appears in the projection of (x − Pi) to the height of 1 79 T passing through Pi and therefore j(x − Pi) · nEi j = hi: Moreover, 2 hijEij = jT j and (i) 80 hi = 2jT j=jEij; (x − Pi) · n ≥ 0 -both vectors have outward direction w.r.t. T: Finally 2jT j (x − Pi) · nEi = σi jEij 81 (ii) obvious 3 82 P (iii) u 2 RT0(T ); w = u − 1(u · nEi )Φi: Obviously w · nEi = 08Ei: Therefore 8Pj : 83 w(Pj) · nEi = 0 and because 8Ei : Pj 2 Ei; it holds w(Pj) = 08j = 1; 2; 3: As w is 84 linear polynomial, w = 0: Proof of uniqueness: 3 X w = αiΦi = 0 ) wnEj = αjΦjnEj = αj = 08j: 1 85 (iv) obvious 86 87 5. Local matrices and assembling 88 Assume that Φi and Ψi are constructed as finite element basis functions above some 89 triangulation Th; i:e:T 2 Th ΦijT 2 fΦ1; :::; Φρ; 0 = Φ0g 90 ΨjjT 2 fΨ1; :::Ψs; 0 = Ψ0g: 91 Then R −1 m(Φi; Φk) = Ω k ΦiΦkdx = P R k−1Φ Φ dx T 2Th T i k = P R k−1Φ Φ dx T 2Th T loc(i) loc(k) R b(Φi; Ψj) = Ω(divΦi)Ψjdx = P R (divΦ )Ψ dx T 2Th T loc(i) loc(j) 92 where lock(i) = lock(i; T ) is a transformation from global index to local index of basis 93 function on T: It can be also zero.