1 PREPRINT

2 A mixed RT0 − P0 Raviart-Thomas finite element implementation of 3 Darcy Equation in GNU Octave

1 1,† 4 Agah D. Garnadi , C. Bahriawati

1 5 Jurusan Matematika, Fakultas MIPA, Institut Pertanian Bogor, Indonesia, e-mail:

6 [email protected]

7

Abstrak In this paper we shall describe mixed formulations -differential and variational- of Darcys flow equation, an important model of elliptic problem. We describe *

8 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, 9 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 *

10 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 11 element methods

12 Contents 13 1 Introduction 1 14 2 Problem formulation 1 15 3 Galerkin method -Mixed FEM 2 16 4 Local matrices and assembling 3 17 5 Lowest order Raviart-Thomas finite elements 3 18 6 Local properties and local edge basis for RT(0) elements 4 19 7 Local matrices 5 20 8 Model problem 7 21 9 Assembling 9

22 1. Introduction

23 This report describes basis of RT1 code, which can be characterized as a code for test- 24 ing solvers and preconditioners for FEM systems arising from lowest order Raviart-Thomas 25 discretization of Darcy flow problems, see also [2] [1] 26 The code is characterized by simplicity and possibility of easy modifications,

2000 Mathematics Subject Classification: 65N15; 65M30 Received: dd-03-2020, accepted: dd-mm-yyyy. 1 2 Garnadi & Bahriawati, PREPRINT

27 • directly solving model problems on square domains (generalization possible), 28 • stochastic generation of heterogeneity, 29 • fast system assembling using vectorization and sparse reconstruction, 30 • possible testing of Krylov type solvers with both (block) matrix and matrix free (vari- 31 able) preconditioners.

32 This report describes the finite element system generation, experiments are involved in 33 papers, e.g. [3].

34 2. Problem formulation

35 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

36 where g 6= 0 if we consider elevation changes. It can be also written in a two field form 1 n 37 with two basic variables p :Ω → and u :Ω → R ,

k−1u + grad p = g  in Ω div(u) = f 38

p =p ˆ on ΓD (−k grad p) · n =u ˆ on ΓN

39 The variational formulation uses test functions v and q to get

R k−1u · vdx + R ∇p · vdx = R g · vdx RΩ Ω RΩ Ω div(u)q = Ω fqdx

40 Transformation of one mixed term then provides

R R P ∂p P R R ∂vk ∇p · v = vkdx = { pvk · nk − p dx} Ω RΩ k ∂xk R k ∂Ω Ω ∂xk = ∂Ω p(v · n) − Ω pdiv(v)dx

41 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) ∀v RΩ Ω RΩ ΓD ΓN Ω div(u)q = Ω fq ∀q

42 –or in abstract form: find (u, p) ∈ UN × P

m(u, v) + b(v, p) = G(v) ∀v ∈ U0 b(u, q) = F (v) ∀q ∈ P

43 where n U = {v ∈ L2(Ω) : div(v) ∈ L2(Ω)} → H(div) U0 = {v ∈ U : v · n = 0 on ΓN } UN = {v ∈ U : v · n =u ˆ on ΓN } P = {q ∈ L2(Ω)} R 44 Note that pressure BC enters G(v) = ... − pˆ(v · n) whereas velocity BC are included Γ0 45 in UN . Darcy - Raviart-Thomas Element 3

46 3. Galerkin method -Mixed FEM

47 We start with introducing FEM spaces Uh ⊂ U, UNh ⊂ UN ,U0h ⊂ U0 and Ph ⊂ P. 48 Then the Galerkin method is to find (uh, ph) ⊂ UhN × Ph

m(uh, vh) + b(vh, ph) = G(vh) ∀vh ∈ U0h b(uh, qh) = F (qh) ∀ph ∈ Ph

49 After a choice of bases

Uh = lin{Φi, i ∈ I},Ph = lin{Ψj : j ∈ J}

UNh = uN + u, u ∈ U0h

U0h = lin{Φi : i ∈ I0} X uN ∈ lin{Φi : i ∈ I\I0}, uN = (ˆu · n)(xi)Φi

50 the discrete mixed problem can be written as -find (uh, ph) ∈ UhN × Ph, uh = uN + P P 51 α Φ , p = β Ψ i∈I0 i i h j∈J j j

P α m(Φ , Φ ) + P β b(Φ , Ψ ) = G(Φ ) − m(u , Φ ) ∀k ∈ I i∈I0 i i k j∈J j k j k N k 0 P α b(Φ , Ψ ) = F (Ψ ) − b(u , Ψ ) ∀l ∈ J i∈I0 i i l l N l

52 Rewriting to matrix form provides

T n1 Bα + B β = G, α ∈ R , n1 = #I0 n2 Bα = F, β ∈ R , n2 = #J

n1×n1 n2×n1 T n1×n2 T 53 where M ∈ R ,Mij = m(Φj, Φi),B ∈ R ,Bij = b(Φj, Ψi),B ∈ R ,Bij = 54 b(Φi, Ψj) = Bji,G = (Gi),Gi = G(Φi),F = (Fk),Fk = F (Ψk).

55 4. Lowest order Raviart-Thomas finite elements

2 56 Let Ω ∈ R be a 2D polygonal domain, Th be its triangulation, Eh be set of edges of all 57 elements T ∈ Th see the situation in the following Figure 1. 58 Then, we can define 2 T T RT0(T ) = {v : T → R , v(x) = ξ[x1 x2] + [η1 η2] , ξ, η1, η2 ∈ R} 59 2 Uh = {v :Ω ∈ R , v|T ∈ RT0(T ) ∀T ∈ Th, v · nE is continuous over E ∈ Eh} 1 Ph = {q :Ω ∈ R , q|T is constant ∀T ∈ Th}.

60 Continuity of ν · nE guarantees Uh ∈ U, Ph ∈ P is obvious. Note that ∀E ∈ Eh we define 61 nE (unit normal vector), independently of relation to triangles and consequently in possibly 62 inner or outer direction, see Figure 2.

63 6 Local properties and local edge basis for RT(0) elements

64 Lemma 4.1. Let T ∈ Th, v ∈ RT0(T ). Then ∀E ∈ Eh ∪ ∂T : v · n|E = const.

∗ 65 Proof. Let E ∈ Eh ∪ ∂T, nE be normal to E (can be either outer or inner to T ), x ∈ E be 66 arbitrary point at E. Then ∗ ∗ ∗ x ∈ E ⇒ (x − x ) · nE = 0, nE = (n1, n2) ⇒ x1n1 + x2n2 = x1n1 + x2n2 = const. ⇒ 67 ∗ ∗ v(x) · n = ξx1n1 + ξx2n2 + η1n1 + η2n2 = ξ(x1n1 + x2n2) + η1n1 + η2n2 = const . 68  4 Garnadi & Bahriawati, PREPRINT

(i) (j) Gambar 1. {x } set of centres of Ei ∈ Eh, {y } barycentres of Tj ∈ Th

Gambar 2. Prescribed normal nE. Possible definition of nE,E ∈ Eh.

Gambar 3. Triangle T ∈ Th. Darcy - Raviart-Thomas Element 5

69 Lemma 4.2. (Expression for local basis functions.) Let

E Φ (x) = σ i (x − P ), σ = n n(i), i i 2|T | i i Ei (i) 70 where nEi are global prescribed normals and n are outer normals for T ∈ Th, see Figure 71 3. Then

72 (i)Φ j(x) · nEi = δij, 73 (ii)Φ i ∈ RT0(T ), 74 (iii)Φ 1, Φ2, Φ3 create a basis of RT0(T ), Ei 75 (iv) divΦi = σi |T | .

76 Proof. (i) If i 6= j, then Pi ∈ Ej and (x − Pi) · nEj = 0 for x ∈ Ej. If i = j then for

77 x ∈ Ei the value (x − Pi) · nEi appears in the projection of (x − Pi) to the height of 1 78 T passing through Pi and therefore |(x − Pi) · nEi | = hi. Moreover, 2 hi|Ei| = |T | and (i) 79 hi = 2|T |/|Ei|, (x − Pi) · n ≥ 0 -both vectors have outward direction w.r.t. T. Finally 2|T | (x − Pi) · nEi = σi |Ei|

80 (ii) obvious 3 81 P (iii) u ∈ RT0(T ), w = u − 1(u · nEi )Φi. Obviously w · nEi = 0∀Ei. Therefore ∀Pj :

82 w(Pj) · nEi = 0 and because ∀Ei : Pj ∈ Ei, it holds w(Pj) = 0∀j = 1, 2, 3. As w is 83 linear polynomial, w = 0. Proof of uniqueness: 3 X w = αiΦi = 0 ⇒ wnEj = αjΦjnEj = αj = 0∀j. 1

84 (iv) obvious 85 

86 5. Local matrices and assembling

87 Assume that Φi and Ψi are constructed as finite element basis functions above some 88 triangulation Th, i.e.T ∈ Th Φi|T ∈ {Φ1, ..., Φρ, 0 = Φ0} 89 Ψj|T ∈ {Ψ1, ...Ψs, 0 = Ψ0}.

90 Then R −1 m(Φi, Φk) = Ω k ΦiΦkdx = P R k−1Φ Φ dx T ∈Th T i k = P R k−1Φ Φ dx T ∈Th T loc(i) loc(k) R b(Φi, Ψj) = Ω(divΦi)Ψjdx = P R (divΦ )Ψ dx T ∈Th T loc(i) loc(j)

91 where lock(i) = lock(i, T ) is a transformation from global index to local index of basis 92 function on T. It can be also zero.

93 Vice versa, for T ∈ Th, it is possible to construct local matrices R −1 MT , (MT )rs = k ΦsΦrdx TR BT , (BT )rs = − T divΦs · Ψrdx

94 and then perform the assembling of local matrices to global M,B

(MT )rs → Mglob(T,r)glob(T,s) = +(MT )rs 95 (BT )rs → B = +(BT )rs glob1(T,r)glob2(T,s) 6 Garnadi & Bahriawati, PREPRINT

96 Note there are two sets of basis functions {Φi}, {Ψi}, two sets of local basis functions {Φi}, {Ψi} 97 and two mappings loc1(i) = loc1(i, T ), loc2 98 glob1(r, T ) = i, glob2(s, T ) = j.

99 6. Local matrices

100 Let us consider the local basis on T created by Φ1, Φ2, Φ3 ∈ RT0(T ) and Ψ1 = 1. Then 1×3 101 BT ∈ R , Z |Es| (BT )1s = (divΦs)Ψ1 = σs |T | = σs|Es|, T |T | 1×3 3×3 102 i.e. BT = [σ1|E1|, σ2|E2|, σ3|E3|] ∈ R . Further, MT ∈ R , Z Z −1 |Er||Es| −1 (MT )rs = k ΦsΦrdx = σrσs 2 k (x − Ps) · (x − Pr)dx. T 4|T | T R −1 103 To compute the integral T k (x − Ps) · (x − Pr)dx, we can use barycentric coordinates 104 at T,

x = λ1(x)P1 + λ2(x)P2 + λ3(x)P3, λ1 + λ2 + λ3 = 1,

105 thus x − Pr = λ1(x)(P1 − Pr) + λ2(x)(P2 − Pr) + λ3(x)(P3 − Pr)

106 and 3 Z |Er||Es| X (M ) = σ σ λ λ k−1(P − P ) · (P − P )dx. T rs r s 4|T |2 α β α s β r α,β=1 T R |T | 107 Assuming k constant on T and using the integration formula T λαλβ = 12 (1 + δαβ), 108 which is a special case of Z a b c a!b!c! λ1λ2λ3dx = 2|T | T (a + b + c + 2)! Z a b c d a!b!c!d! λ1λ2λ3λ4dx = 6|V | V (a + b + c + d + 3)! 109 see e.g. [4, 5]

110 the elements of MT can be expressed as

3 1 X (M ) = σ |E | (1 + δ )k−1(P − P ) · (P − P )σ |E | T rs 48|T | r r α,β α s β r s s α,β=1 6×1 111 If we define vectors vr, vs ∈ R ,     P1 − Pr P1 − Ps   x1 vr =  P2 − Pr  , vs =  P2 − Ps  , pi = x2 P3 − Pr P3 − Ps

112 Then

 2 0 1 0 1 0   0 2 0 1 0 1   −1    k 1 T  1 0 2 0 1 0  −1 (MT )rs = σr|Er|vr    k  vsσs|Es| 48|T |  0 1 0 2 0 1    k−1  1 0 1 2 0 0  0 1 0 1 0 2 Darcy - Raviart-Thomas Element 7

 2 0 1 0 1 0   0 2 0 1 0 1     1 0 2 0 1 0  C := (df)    0 1 0 2 0 1     1 0 1 2 0 0  0 1 0 1 0 2 6×6 113 Note that the diagonal elements are equal to elements of BT . If we denote C ∈ R the 114 matrix, which appeared in the expression above and

  0 P1 − P2 P1 − P3 V = [v1, v2, v3] =  P2 − P1 0 P2 − P3  P3 − P1 0 P3 − P2

115 \in R^{6\times 3}

116 then

   −1    σ1|E1| 0 0 k σ1|E1| 0 0 1 T −1 (MT ) =  0 σ2|E2| 0  V C  k  V  0 σ2|E2| 0  48|T | −1 0 0 σ3|E3| k 0 0 σ3|E3|

117 S \in R^{3\times 3} 118 L \in R^{6\times 6} 119 S

120 i.e. 1 (M ) = SV T CLV S T 48|T |   0 P1 − P2 P1 − P3 121 where S = diag[b1E1|, b2E2, b3E3],V =  P2 − P1 0 P2 − P3  , P3 − P1 P3 − P2 0 −1  k−1  −1 1 122 L = k = I, if we consider the isotropic environment, k = kT I on T.   kT k−1 123 For comparison see [2] formula (4.6). 124 Note that we constructed velocity mass matrix M. In the case of time dependent problems, R 125 we also need the pressure mass matrix (MT )rs = T ΨrΨs = δrs|T |

126 7. Model problem

127 We shall consider a model Darcy flow problems on a square domain with flow from left 128 to right induced by the pressure gradient. 129 The problem domain is divided into rectangular elements with the size characterized by 130 the parameter ns = number of segments on the side. 131 Heterogeneity. We assume that each cell can possess a different permeability coefficient 2 132 ki, i = 1, ..., nc = (ns) . This can be produced by MATLAB using command sequence

133 1 ) rng ( ’ d e f a u l t ’ ) ; 134 2 ) RM = randn ( ns , ns ) ; 135 3 ) LK = ( exp ( 1 ) . ^ ( sigma *RM) ) ;

136 The first command initializes the random number generator to make the results in this 137 example repeatable. The same sequence is generated as after restart of MATLAB. The second 138 command generate a ns-by-ns matrix of normally distributed random numbers from N(0, 1), 139 i.e. with mean µ = 0 and standard deviation 1. Then s∗RM is a matrix of normally distributed 8 Garnadi & Bahriawati, PREPRINT

Gambar 4. Model problem

Gambar 5. Discretization of the model problem.

2 140 random numbers with the mean µ = 0 and standard deviation σ . Third command then creates 141 matrix of conductivities such that ln(LK) has normal distribution. 142 Orientation of (global) normals to element edges

Model problem -local matrices.

1 T 1 MT = 2 SV CLV S, L = I. 24h kcell Darcy - Raviart-Thomas Element 9

Gambar 6. Global normals.

143 Lower Triangle  0 −1 0   √   0 0 −1  2   √  1 0 1  BT = [ 2h, −h, −h],S = h.  −1  ,V = h   .  0 0 −1  −1    0 −1 0  1 1 0

144 Upper triangle

 0 1 0   √   0 0 1  − 2   √  −1 0 1  BT = [− 2h, h, h],S = h.  1  = −Slow,Vupper = h   = −Vlow.  0 0 1  1    0 1 0  −1 −1 0 1 T As a conclusion -the matrices MT = 24h2 SV CLV S are the same for both lower and upper

145 146 triangles.

147 Right hand side and boundary conditions. Consider the global system

Mα + BT β = G Bα = F

148 where Z X Gi = − pˆ(pi · n) − uˆkm(Φk, Φi) Γ0 k∈I\I0 10 Garnadi & Bahriawati, PREPRINT

Gambar 7. Pressure boundary conditions for the model problem.

Gambar 8. Treatment of velocity boundary conditions: a) exclude corre- sponding rows and columns and rhs entries, b) or put 1 on diagonal otherwise zeros in corresponding row, columns and rhs entries

149 r.h.s. contribution 150 l.h.s., in our case

Z X Z Fj = − fΨj − uˆk div(Φk)Ψjdx = 0 Ω Ω k∈I\I0

151 = \int_{T_j} f =0 in our case 152 \int_{T_j} \mbox{div} (\Phi_k ); u_k are zero in our case

153 8. Assembling

154 Standard assembling

155 Algorithm 1 Standard assembling 156 define M = 0,B = 0 157 for 1:nt 158 take M_T ,B_T 159 for r = 1,...,3 160 for s = 1,2,3 161 Mi(T,r) j(T,s) = (M_T)_{rs} 162 B\kappa(T ) i(T,r) = (B_T )1r 163 end 164 end 165 end

166 The standard assembing has two drawbacks: for cycles, which are not efficient in MATLAB, 167 and dense matrix storage of the global matrix. Just replacing the global matrix declaration as 168 sparse is not a good solution as it the sparse structure is not given apriori but must be con- 169 structed during the assembling process. This inefficiency can be removed by gradual recording 170 the nonzero components and indices into one dimensional vectors X, I, J and constructing Darcy - Raviart-Thomas Element 11

171 the matrix through sparse(X, I, J, n, m).

172 Further improvement and loop avoiding can be done by vectorization, see [6][6]. The 173 resulting code is able fast assembly very large matrices.

Gambar 9. Transmissivity coefficient k, blue color k = 1.0, red color k = 1.4

174 9. Numerical Test

175 We test numerically an example from [7]. For simplicity, the exact uσ in Ω is set to be 176 uσ = cos(x − 0.5) ∗ exp(y).

 1.0, 0 < x < 0.5, 0 < y < 1 k = σ = 1.4, 0.5 < x < 0, 0 < y < 1  ∂xu = sin(x − 0.5) ∗ exp(y), 0 < y < 1, x = {0, 1} ∂nu = ∂yu = cos(x − 0.5) ∗ exp(y), 0 < x < 1, y = {0, 1}

177 The program implemented in GNU Octave run in octave-online.net, which is a web 178 UI for GNU Octave.

179 Acknowledgement.

180 This work is written posthumously, after the second author passed away. 181 The first author would like to thank program RKI 2020, that partially financed this work.

182 Daftar Pustaka

183 [1] Carstensen, C., 2009, Lectures on Adaptive Mixed Finite Element Methods. In: C. Carstensen, P. Wriggers: 184 Mixed finite element technologies, CISM Udine, Courses and Lectures No.509, Springer, Wien 185 [2] Bahriawati, C. Carstensen C., 2005, Three MATLAB implementations of the lowest-order Raviart-Thomas 186 MFEM with a posteriori error control. Computational Methods in Applied Mathematics, 5, pages 333-361. 187 [3] Axelsson, O, Blaheta, R., Byczanski, P., Kar atson J., and Ahmad, B,. 2015, Preconditioners for regularized 188 saddle point operators with an application for heterogeneous Darcy flow and transport problems. Journal 189 of Computational and Applied Mathematics, vol. 280, pages 141–157. 12 Garnadi & Bahriawati, PREPRINT

Gambar 10. Displacement

Gambar 11. Flux

190 [4] Akin, J.E., 2005, Finite Element Analysis with Errror Estimators, Wiley 191 [5] Braess, D. 2007., Finite Elements: Theory, Fast Solvers, and Applications in Solid Mechanics. Third ed., 192 Cambridge University Press 193 [6] Chen, L., Programming of finite element methods in MATLAB, 194 http : www.math.uci.edu/ chenlong/226/Ch3F EMCode.pdf on January 31,2020 195 [7] Faouzi Triki and Tao Yin., 2020,Inverse conductivity equation with internal data,arXiv, eprint= 2003.13638

196 LAMPIRAN

1971 % Program Darcy equation implementation based on 1982 % EBMFEM for2D Raviart −Thomas mixed 1993 % based on the edge−oriented basis function 2004 % 2015 % AgahD. Garnadi andC. Bahriawati 2026 % 2037 % File 2048 % 2059 %M −files you need to run 20610 % , , , , (optional) 20711 % Darcy - Raviart-Thomas Element 13

20812 % Data−(files) you need to prepare 20913 % coordinate , 21014 % element , 21115 % Dirichlet , 21216 % Neumann (optional) 21317 % 21418 % This program and corresponding data−files is modified from 21519 %"Three Matlab Implementations of the Lowest −Order Raviart−Thomas 21620 % MFEM witha Posteriori Error Control" by C.Bahriawati andC. Carstensen 21721 21822 % 21923 % A.1. The main program 22024 % load coordinate.dat; 22125 coordinate = [ 0 0; 0.5 0; 1 0; 1 0.5 ; 1 1; 0.5 1; 0 1; 0 0.5; 0.5 0.5];% 22226 % load element.dat; 22327 element = [2 8 1; 2 9 8 ; 2 4 9; 2 3 4; 9 4 5; 9 5 6; 9 6 7; 9 7 8];% 22428 % loadk element.dat; 22529 k element = [1 ; 1 ; 1.4 ; 1.4 ; 1.4 ; 1.4 ; 1 ; 1 ];% 22630 % load dirichlet.dat; 22731 dirichlet = [ 3 4; 4 5; 7 8 ; 8 1]; 22832 %load Neumann.dat; 22933 Neumann = [1 2; 2 3; 5 6; 6 7]; 23034 % 23135 [nodes2element,nodes2edge,noedges,edge2element,interioredge]=edge(element,coordinate); 23236 23337 % A.2. EBmfem 23438 %functionu=EBmfem(element,coordinate,dirichlet,Neumann,nodes2element,... 23539 % nodes2edge,noedges,edge2element); 23640 23741 % Assemble matricesB andC 23842 B=sparse(noedges, noedges); 23943 C=sparse(noedges,size(element,1)); 24044 for j = 1:size(element,1) 24145 coord=coordinate(element(j,:),:)'; 24246 I=diag(nodes2edge(element(j,[2 3 1]),element(j,[3 1 2]))); 24347 signum=ones(1,3); 24448 signum(find(j==edge2element(I,4)))=−1; 24549 B element = k element(j)*diag(signum)*stimaB(coord)*diag(signum); 24650 n=coord(:,[3,1,2])−coord(:,[2,3,1]); 24751 B(I,I)= B(I,I) + B element ; 24852 C(I,j) = diag(signum)*[norm(n(:,1)) norm(n(:,2)) norm(n(:,3))]'; 24953 end 25054 % Global stiffness matrixA 25155 A = sparse(noedges+size(element,1), noedges+size(element,1)); 25256 A = [B , C, ; 25357 C', sparse(size(C,2),size(C,2))]; 25458 % Volume force 25559 b = sparse(noedges+size(element ,1),1); 25660 for j = 1:size(element ,1) 25761 b(noedges+j)= −det([1,1,1; coordinate(element(j,:),:)']) * ... 25862 f(sum(coordinate(element(j,:),:))/3)/6; 25963 end 26064 % Dirichlet conditions 26165 for k = 1:size(dirichlet,1) 26266 b(nodes2edge(dirichlet(k,1),dirichlet(k,2)))= norm(coordinate(dirichlet(k,1),:)−... 26367 coordinate(dirichlet(k,2),:))*u D(sum(coordinate(dirichlet(k,:),:))/2); 26468 end 26569 % Neumann conditions 14 Garnadi & Bahriawati, PREPRINT

26670 if ¬isempty(Neumann) 26771 tmp=zeros(noedges+size(element,1),1); 26872 tmp(diag(nodes2edge(Neumann(:,1),Neumann(:,2))))=... 26973 ones(size(diag(nodes2edge(Neumann(:,1),Neumann(:,2))),1),1); 27074 FreeEdge=find(¬tmp); 27175 x=zeros(noedges+size(element,1),1); 27276 CN=coordinate(Neumann(:,2),:)−coordinate(Neumann(:,1),:); 27377 for j=1:size(Neumann,1) 27478 x(nodes2edge(Neumann(j,1),Neumann(j,2)))=... 27579 g(sum(coordinate(Neumann(j,:),:))/2,CN(j,:)*[0,−1;1,0]/norm(CN(j,:))); 27680 end 27781 b=b−A*x; 27882 x(FreeEdge)=A(FreeEdge,FreeEdge)\b(FreeEdge); 27983 else 28084 x = A\b; 28185 end 28286 figure(1) 28387 ShowDisplacement(element,coordinate,x); 28488 p=fluxEB(element,coordinate,x,noedges,nodes2edge,edge2element); 28589 figure(2) 28690 ShowFlux(element,coordinate,p); 28791 pEval=fluxEBEval(element,coordinate,x,nodes2edge,edge2element);

288 1