Chapter Two: Numerical Methods for Elliptic PDEs Finite Difference Methods for Elliptic PDEs.. Finite difference scheme. We consider a simple example u := subject to Dirichlet boundary conditions ( ) u x + u = f(x, y) (x, y) Ω = [0, ] [0, ] (.) y u Ω = g Basic concept: replacing the derivatives by finite differences. Let π = {x i, y j } M+,N+ i,j=0 define a mesh on Ω. For simplicity, we consider a uniform mesh with the meshsize h x = x i x i and h y = y j y j, and u ij be a mesh function on π. The finite difference approximation is defined by u xx u(x i, y j ) u(x i, y j ) + u(x i+, y j ) h x u yy u(x i, y j ) u(x i, y j ) + u(x i, y j+ ) h y Then the finite difference solution u ij is determined by the following system L h u ij := u i,j u i,j + u i+,j h x + u i,j u i,j + u i,j+ h y i =,,..., M; j =,,..., N u ij = g(x i, y j ) i = 0, i = M +, j = 0, j = N + = f(x i, y j ) (.) In matrix form, where for h x = h y = h A = h Au = f B I I B I......... I B B = 4 4......... 4 and u = (u, u,..., u N, u..., u N,..., u M,...u MN ) T. In tensor product form, (A I N + I M A )u = f 40
where A = h x......... Here the tensor product is defined by M M A = h y......... N N B C = (b ij C) Some properties: () (A A )(B B ) = (A B ) (A B ) () (A A ) = A A () if Ax = λ A x, By = λ B y (A B)(x y) = λ A λ B (x y).. Linear Solvers. A major problem for elliptic PDEs is the efficient algorithms for solving the linear systems since the dimension of matrices for elliptic PDEs is much large than for two-point boundary value problems. Direct algorithm: Gaussian elimination. Complexity: (NM) / for two-demensional elliptic PDEs. Memory: O(NM ). Iterative algorithms: Jacobi, Gauss-Seidel, SOR, CG, Krylov subspace,... Alternatiing direction implicit (ADI) algorithm [(A + ωi) I] u n+/ = [I (A ωi)] u n + f [I (A + ωi)] u n+ = [(A ωi) I] u n+/ + f Convergence: (i) ADI is convergence for any ω > 0; (ii) If ω n = λ n, ADI is a finite method (direct) where λ n is the eigenvalue of A. Complexity: at each iteration, ADI algorithm needs to solve N M one-dimensional problems, i.e., tridiagonal linear systems. The complexity at each step is (N ) for N = M. Remarks: ADI algorithm is simple, efficient and restricted on separable problems. Convergence analysis: First we consider the following basic iteration The iterative scheme is convergent if u n+ = T u n + b ρ(t ) <. 4
(u: u = T u + b, proof is easy). ADI algorithm is a special case with T = [I (A + ωi)] [(A ωi) I] [(A + ωi) I] [I (A ωi)] It is easy to get T = [ (A ωi)(a + ωi) ] [ (A + ωi) (A ωi) ] and the eigenvalues of T are Fast Poisson s solver. We have proved that λ(t ) = (λ(a ) ω)(λ(a ) ω) (λ(a ) + ω)(λ(a ) + ω) < A F s = Λ F s where and F s F s = M + (sin ijπ M + ) λ i = 4(M + ) sin iπ (M + ) = I. Then the finite difference system can be rewitten by and moreoever, where Fast Poisson solver: (i) Calculate f = (F s I)f; (ii) Solve the system (F s I)(Λ I + I A )(F s I)u = f (Λ I + I A )ū = (F s I)f ū = (F s I)u (Λ I + I A )ū = f (iii) calculate u = (F s I)ū. Complexity: O(N logn) for N = M... General second-order Elliptic PDEs. General domain General boundary conditions Problems in three-dimensional spaces More general elliptic PDEs Linear elasticity equations where (u, v) define the displacement. a u xx + a u xy + a u yy + b u x + b u y + cu = f (λ + µ)u xx + µu yy + (λ + µ)v xy = f (λ + µ)v yy + µv xx + (λ + µ)u xy = f 4
FEM for two-dimensional elliptic PDEs. Basic idea We consider a simple model problem, Poisson equation u = f(x, y), u Ω = 0 where Ω denotes the boundary of Ω and (x, y) Ω (.) u u x + u y. Similarly to one-dimensional problem, we need a variational model which will be obtained by using Green formula instead of integration by part in the last section. Let u = u(x, y) and w = w(x, y) be smooth functions in Ω. Green formula is given by i.e., where v w dω = vw n ds + w v dω Ω Ω Ω ( ) w v Ω x + w dxdy = v w ( v y Ω n Ω ds + w x x + v y w = wn n x x + wn y y n x = cos < n, x >, n y = cos < n, y >, v = ( v x v y ) w = ( w x w y ). ) w dxdy y By using the Green formula for the model problem (.) and letting v H0(Ω), we have v w dω = u v dω = fv dω. Ω Ω Ω Let a(u, v) = Ω u v dω (f, v) = Ω fv dω F (v) = a(v, v) (f, v). We can obtain the equivalent (V) model and (M) model and Find u H 0 (Ω) such that for all v H 0 (Ω), a(u, v) = (f, v) (V ) min v H 0 (Ω) F (v) Similarly, the above models are to find a solution in a infinite dimensional space. In FEM, we need to approximate the infinite dimensional space by finite dimensional spaces V h. Let 4 (M)
φ j (x, y), j =,,, N, be the basis functions of V h. A function u h V h can be expressed by N u h (x, y) = α j φ j (x, y). Letting v = φ i, i =,,..., N, respectively, in the (V h )-model, we have and The linear system is given by where j= a(u h, φ j ) = (f, φ i ) N α j φ i φ j dω = fφ i dω, i =,,..., N. j= Ω Ω a ij = Ω Aα = b φ i φ j dω, b i = Ω fφ i dω. The importance is the choice of finite dimensional space. Piecewise polynomial space is one of most popular choices. In this case, one has to construct a mesh, i.e., divided the domain Ω into small pieces (element). Mesh generation in multi-dimensional space is one of important parts in study of FEM. Figure 4: Finite element mesh in two-dimensional space.. Basis functions Here we consider piecewise polynomial basis functions. Let Ω be a bounded domain which consists of the elements {K i } M i= and nodal points {(x j, y j } N j=. We first consider the piecewise linear space where V h = {v : continuous on Ω, piecewise linear, v = 0 on Ω}. The corresponding basis functions φ j (x) V h, j =,,..., N, satisfy * φ j (x) is piecewise linear; * φ j (x i ) = δ ij where x = (x, y). 44
Figure 5: The basis function of linear element in two-dimensional space. We see that the support of φ j (the set of points x for which φ j 0) consists of the triangles with the common node x j (shaded area). Now we need to formulate the piecewise linear function. Example. Find a linear function L(x, y) on Ω = {(x, y) 0 x a, 0 y b, x/a+y/b } satisfies * linear; * L(a, 0) = 0, L(0, b) = 0; * L(0, 0) =. L y x Figure 6: The function L(x, y). Since L(x, y) is a linear function, it can be expressed by L(x, y) = b 0 + b x + b y. Then the solution of problem is unique. The equation of line passed through the points (a, 0) and (0, b) is x a + y b =. Let l(x, y) = x a + y b. 45
Then the solution is L(x, y) = l(x, y) l(0, 0) = x a y b which satisfies the all above conditions. For a given triangle Ω with the three vertices x, x and x. We need to find three linear functions L j (x), j =,,, satisfying L j (x i ) = δ ij. Let l ij (x) denote the equation of line passed through the vertices x i and x j. Then L (x) = l (x) l (x ) L (x) = l (x) l (x ) L (x) = l (x) l (x ). Now we can formulate the linear basis functions, each of them corresponds to each interior node. φ j (x) is nonzero only in the elements around the vertex x j. The formula in such each element can be obtained as above. Example (Quadratic element). Find a function Q j (x, y) on a triangle Ω with its vertices x i, i =,,, satisfies * quadratic; * Q j (x i ) = δ ij, i, j =,,. It is obvious that the solution is not unique. We need to add some more conditions. Here we consider a triangular element below. X X 5 * * X 4 X * X 6 X Figure 7: The basis function of quadratic element. We require the second condition to be satisfied for j =,,, 4, 5, 6. Let l ij (x) be the equation of line passed through x i and x j. Then the solution is Q (x) = l 56(x) l (x) l 56 (x ) l (x ) Q (x) = l 45(x) l (x) l 45 (x ) l (x ) Q 5 (x) = l (x) l (x) l (x 5 ) l (x 5 ) Q (x) = l 46(x) l (x) l 46 (x ) l (x ) Q 4 (x) = l (x) l (x) l (x 4 ) l (x 4 ) Q 6 (x) = l (x) l (x) l (x 6 ) l (x 6 ). It is noted that Q j (x, y) defined above is quadratic for each component. Example (Quadrilateral element. Four-point quadrilateral element) 46
The linear basis functions L j (x) can be obtained analogously. L (x) = l (x) l 4 (x) l (x ) l 4 (x ) L (x) = l (x) l 4 (x) l (x ) l 4 (x ) which is not exact linear function in general. Some other high-order elements are as follows. L (x) = l 4(x) l 4 (x) l 4 (x ) l 4 (x ) L 4 (x) = l (x) l (x) l (x 4 ) l (x 4 ) X X 4 o o o o X o o X o o Figure 8: Some other elements. Stiffness matrix For the simple model problem (.), we have a ij = φ i φ j dω. Here we only consider the linear element. Ω X X4 K Xi K X K 4 K K 5 X5 X Figure 9: The elements around the node X i Let K i denote the five elements around the node x j. Then φ j (x) = l (x) l (x j ). The equation of line passed through x and x is x x x x y y y y = 0 47
i.e., We see that and l (x, y) := (x y x y ) x(y y ) + y(x x ) = 0. l (x j, y j ) = l (x, y) = x j x x y j y y x x x y y y where A(K ) = is the area of the element K. Since = A(K ) = ( ) φ j x = y y φ j y = x x, we have a ij = l K l φ i φ j dω = l K l ( φi x Obviously, if no segment between x i and x j, a ij = 0. Example. We consider the following Poisson s equation ) ( φ j φi + x y u = (x, y) Ω = [0, ] [0, ] u Ω = 0 By using linear triangular element and h = /. ) φ j dω. y 4 6 8 5 4 7 8 0 7 9 4 6 5 Figure 0: An example. Node i =, a = K +K +K 4 +K 7 +K 8 +K 9 φ φ dxdy = K + K + K 4 + K 7 + K 8 + K 9. 48
We have calculate the integrals one by one. Since on K, φ = (x + y h)/h, Also we have and Then For a, we have We can obtain and therefore, Similarly, and Then the stiffness matrix is ( ) φ φ dxdy = dxdy =. K K h ( ) φ φ dxdy = dxdy = / K K h 4 7 K = K = K 8 = / a = 4. K 9 =. a = φ φ dxdy. K 4 +K 9 φ φ dxdy = φ φ dxdy = / K 4 K 9 a =. a = a 4 = 0 ( no edge between x and x 4 ) a = a = a 44 = 4 a = 0 a 4 = a 4 =. A = h 4 0 4 0 0 4 0 4 The calculation of the load vector b is more complicated. b = K +K +K 4 +K 7 +K 8 +K 9 φ dxdy b = K 4 +K 5 +K 6 +K 9 +K 0+K φ dxdy b = K 8 +K 9 +K 0 +K +K 4 +K 5 φ dxdy b 4 = K 0 +K +K +K 5 +K 6 +K 7 φ 4 dxdy. The finite element linear system is Aα = b. 49
If we consider the case with N N mesh. Then the stiffness matrix is block tridiagonal B I I B I A =......... I B where B = 4 4......... 4 If we have used different partition, or different index, we will obtain different stiffness matrices. It will be very complicated for general geometry, equations and boundary conditions.. Element stiffness matrix. The above approach is very complicated to implement in computer. As we discussed in the section one, we consider an alternative approach, element stiffness matrix. We assume that we have had a triangular mesh on the domain Ω, which consists of the elements K k, k =,,..., M and φ j, j =,,..., N, be the linear basis functions. For the element K k, we denote its element stiffness matrix by where for the simple model (.), a (k) ij = ā(φ i, φ j ) = A k = (a (k) ij ). K k φ i φ j dxdy. Xk K k Xk Xk Figure : A typical element. Let ( x i, ȳ i ), i =,,, be the coordinates of three vertices of K k. Then ( a (k) φki φ kj ij = K k x x + φ ) k i φ kj dxdy i, j =,, y y 50
and φ k = k x x x y ȳ ȳ φ k = k x x x y ȳ ȳ φ k = k x x x y ȳ ȳ. In general, where x 4 = x and x 5 = x. Hence, φ ki x = k We have the following formulas: and φ ki = k ȳ i+ ȳ i+ x x i+ x i+ y ȳ i+ ȳ i+ φ ki y = k x i+ x i+ a (k) ij = 4 k [(ȳ i+ ȳ i+ )(ȳ j+ ȳ j+ ) + ( x i+ x i+ )( x j+ x j+ )] (.) b (k) i = f(x, y)φ i dxdy. K k Since f(x, y) could be an arbitrary function, we need to use Gauss-Quadrature technique to calculate the above integrals b (k) i = p w l f(x l, yl )φ i (x l, yl ) l= where (x l, y l ) and w l define the Gaussian points and the corresponding weight. Remarks. For some complicated elliptic PDEs, a(u, v) could be complicated and we cannot obtain the above general formula. We have to use Gauss-Quadrature to calculate both a (k) ij and b (k) i. In most computer program, the stiffness matrix is obtained by using the following approach. Let A = (a ij ) and A k = a (k) ij be the (global) stiffness matrix and element stiffness matrix, respectively. Then for each element K k, we need the following loop. a jp,j q = a jp,j q + a (k) pq p, q =,, (.) and b jp = b jp + b (k) p p, q =,,. The relationship between (j p, j q ) and (p, q) will be discussed later. Finally we use the boundary conditions to reduce the size of the matrix. Example. We consider the same problem as in the last example. Here k = /8. 5
4 4 5 6 6 8 5 9 8 0 7 9 5 8 7 4 6 4 Figure : An example. 5 (i) Element stiffness matrices. By using the above formulas, a () [( ) ( ) ( ) ( )] = 4 + = a () [( ) ( ) ( ) ] = 4 + 0 = / a () = 4 [( a () = [( 4 a () [( = 4 a () = 4 [ 0 + ( ) ( ) ( ) ( )] 0 + = / ) ( ) ] + 0 = / ) ( )] 0 + 0 = 0 )] = /. Then we have and similarly Moreover, we have A = A = / / / / 0 / 0 / / / 0 / / 0 / /. A = A = A 5 = A 5 = A 7 A = A 4 = = A 6 = A 8. 5
(ii) Global stiffness matrix. Now we assemble them into a global stiffness matrix. Key point for the assembling is the local index and global index. In our formulas, p, q represent the local indexes and j p, j q are the global indexes. The relationship is as follows. 5 4 Figure : The connection. A : local global 5 A : local global 6 5 Following the rule, we can put the element matrix into the global matrix. For example, a () should be added in a 5 a 5 = a 5 + a () and a () should be added in a 6 a 6 = a 6 + a (). We obtain (assemble the first 8 elements) A = / / / + / + / 0 / / / + / + / / / / + / / / + / + / / / + / + / + / + / / / + / + / / + / / The right hand side can be assembled similarly. (iii) Condensation. By using the boundary conditions α = α = α = α 4 = α 5 = α 8 = α 9 = α = α = α 4 = α 5 = α 6 = 0, we obtain the final linear system 4 0 α 6 4 0 α 7 0 4 α 0 0 4 α = b () + b () + b (4) + b (7) + b (8) + b (9) b (4) + b (5) + b (6) + b (9) + b (0) + b () b (8) + b (9) + b (0) + b () + b (4) + b (5) b (0) + b () + b () + b (5) + b (6) + b (7) 5.
The finite element solution can be obtained by solving the above system..4 Implementation Computer program structure. (i) Data input * functions (such as f(x, y)) and parameters in the PDE; * boundary conditions; * Geometry Ω. (ii) Mesh generation * generate the coordinates of all nodal points; * generate the connection among the local indexes (of points) and global indexes (of points). (iii) Stiffness matrix and load vector * generate element stiffness matrices; * generate element load vector; * Gaussian quadrature; * assembling. (iv) Linear solver (iterative methods or direct methods) (v) Post-process. Gauss quadrature We consider the integral 0 f(x) dx or f(x) dx In general, f(x, y) dx dy Usually we use the same approximation in FEM to approximate the function f(x, y). For example, if we use linear FEM method, then f(x, y) dx dy f L (x, y) dx dy where f L (x, y) is a linear interpolation polynomial on the element. Linear solver 54
Chapter Three Numerical Solution for Parabolic PDEs FD for parabolic PDEs. Here we consider numerical solutions of a simple model problem where u 0 (x) is given. Let {t n, x j } define a partition, where u t = u xx, x (0, ), t > 0 (.) u(0, x) = u 0 (x), x (0, ) u(t, 0) = u(t, ) = 0, t > 0 0 = t 0 < t < t... < t n < t n+ 0 = x 0 < x < x... < x N < x N+ =. For simplicity, we assume the mesh is uniform, i.e., h = x j+ x j τ = t n+ t n. Let u n j be a mesh function defined on the mesh {t n, x j }. Similarly, we use the following approximations u xx (t n, x j ) u(t n, x j ) u(t n, x j ) + u(t n, x j+ ) h u t (t n, x j ) u(t n+, x j ) u(t n, x j ) τ for the parabolic equation. The FD solution satisfies the following system u n j τ u 0 j = u 0 (x j ) u n+ j In matrix form, we have u n 0 = u n N+ = 0. (.) = un j un j + un j+ h j =,,..., N; n = 0,,... (.) U n+ = (I τ h A )U n (.4) U 0 = U 0 where A =......... U n = u n u n. u n N U 0 = u 0 (x ) u 0 (x ). u 0 (x N ) 55
which is called the explicit (forward) Euler FD scheme. Similarly, if we use the approximation u t (t n, x j ) u(t n, x j ) u(t n, x j ) τ Then we obtain the implicit (backward) Euler FD scheme and in matrix form, u n j un j τ u 0 j = u 0(x j ) u n 0 = u n N+ = 0 = un j un j + un j+ h j =,,..., N; n =,,... (.5) (I + τ h A )U n = U n n =,,... (.6) U 0 = U 0 In terms of Taylor s expansion, we can prove that the trunction error for both explicit and implicit Euler scheme is O(τ + h ). In order to get a scheme with second-order accuracy in t direction, we consider the approximation u t (t n + τ/, x j ) u(t n+, x j ) u(t n, x j ) τ u xx (t n + τ/, x j ) u(t n+, x j ) u(t n+, x j ) + u(t n+, x j+ ) (.7) h + u(t n, x j ) u(t n, x j ) + u(t n, x j+ ). h The corresponding scheme can be writtren by (I + τ h A )U n+ = (I τ h A )U n n = 0,,,... (.8) U 0 = U 0 This is so-called the Crank-Nicolson FD scheme. The trunction error is O(τ + h ).. FE for parabolic PDEs To formulate a finite element method, we need a variational model for the parabolic PDE. Let v H 0 and (u t, v) = (u xx, v) (u(0, x), v) = (u 0, v) 56
Using integration by part, (u t, v) + a(u, v) = 0 (u(0, x), v) = (u 0, v) (.) where a(u, v) = (u x, v x ). The corresponding variational model is: Find u H0 such that for all v H 0, the above equation holds. Theoretically, we can prove the equivalence of the parabolic PDE and the variational model. The variational model for FEM is to find u V N such that for all v V N, the equation (.) holds. Now we consider the linear FEM. Let {φ j } N j=0 be the basis functions of linear FEM. Then Let v = φ i (x), i =,,..., N, u(t, x) = α j (t)φ j (x), u t (t, x) = α j(t)φ j (x). ( α j(t)φ j, φ i ) + a( α j (t)φ j, φ i ) = 0 ( α j (0)φ j, φ i ) = (u 0, φ i ) equivalently α j (t)(φ j, φ i ) + α j (t)a(φ j, φ i ) = 0 In matrix form, where or αj (0)(φ j, φ i ) = (u 0, φ i ). Cα + Aα = 0 Cα(0) = b a ij = a(φ j, φ i ), c ij = (φ j, φ i ) b i = (u 0, φ i ) A = h A, C = tridiag(/6, /, /6), (.) α = (α (t), α (t),, α N (t)) T α = (α (t), α (t),, α N (t))t. (.) is a system of ODEs. In fact, in terms of FEM approximation in x direction, we reduce the parabolic PDE to a system of ODEs. One can use classical ODE solvers for solving the resulting ODE system. Thus such a scheme is called the semi-discrete method. There are many different fully-discrete schemes. Here we only consider some FD schemes for t direction. If we use the approximation in (.), the variational model is to find u V N such that for all v V N, ( u n+ (x) u n (x) τ, v ) + a(u n (x), v) = 0 (u 0 (x), v) = (u 0, v) (.) The variational model for FEM is to find u V n such that for all v V N, the equation (.) holds. 57
Similarly, we consider the linear FEM. Let {φ j } N j=0 be the basis functions of linear FEM. Then u n (x) = αj n φ j(x),. Let v = φ i (x), i =,,..., N, (α n+ j α n j )(φ j, φ i ) + τ α n j a(φ j, φ i ) = 0 α 0 j (φ j, φ i ) = (u 0, φ i ) In matrix form where Cα n+ = (C τa)α n Cα 0 = b α n = (α n (t), αn (t),, αn N (t))t. (.4) This is so-called the explicit Euler with linear FEM. Similarly, there are the implicit Euler with linear FEM and the Crank-Nicolson with linear FEM. Stablility Stability of parabolic PDEs We consider model problem (.). A perturbed model problem is given by where u 0 (x) is given. Let e(t, x) = u(t, x) v(t, x). We have v t = v xx, x (0, ), t > 0 (.) v(0, x) = u 0 (x) + δ(x), x (0, ) v(t, 0) = v(t, ) = 0, t > 0 e t = e xx, x (0, ), t > 0 (.) e(0, x) = δ(x), x (0, ) e(t, 0) = e(t, ) = 0, t > 0 The model problem (.) is said to be stable with respect to the norm, if there exist positive constants K such that e K δ. Stability of discrete methods First we consider a general scheme u n+ = Mu n + f (.) u 0 = b(given) 58
where M is an N N matrix. A perturbed system is defined by Let ɛ n = v n u n. Then and therefore, It follows that By theorem in Linear Algebra, if v n+ = Mv n + f v 0 = b + δ ɛ n+ = Mɛ n ɛ 0 = δ ɛ n+ = Mɛ n = M ɛ n =... = M n+ ɛ 0 = M n+ δ. ɛ n+ M n+ δ. ρ(m) := max λ j (M) <, (.4) j M n+ 0 as n and ɛ n+ 0. In this case, we say that the discrete method is (absolutely) stable. For the explicit (forward) Euler FD scheme Then M = (I τ h A ). λ j (I τ h A ) = τ 4 jπ h sin ( (N + ) ). The explicit Euler FD scheme is absolutely stable. τ 4 jπ h sin ( (N + ) ) < and approximately τ h <. For the implicit (backward) Euler FD scheme M = (I + τ h A ). We have λ j (M) = λ j ( (I + τ h A ) ) = + τ 4 sin jπ ( ) < h (N+) j =,,, N The implicit (backward) Euler FD scheme is unconditionally stable. 59
For the Crank-Nicolson FD scheme, M = (I + τ h A ) (I τ h A ). It is easy to verify that this method is also unconditionally stable. For FEM, we have Then A = h A, C = h(i 6 A ) For linear FEM with explicit Euler scheme, M = C (C τa) = I0C A = I τ h (I 6 A ) A. λ j (M) = τ h 4 sin jπ (N+) jπ (N+) The scheme is absolutely stable if τ h < 6. We can study the stability of linear FEM methods with implicity and Crank-Nicolson schemes similarly. 60