Chapter 32

Finite Element Method

32.1 Introduction

The last method we will study is by far the most commonly used method in numerical analysis. This method is referred to as finite element method (FEM). It was originally developed for solving problems in solid-state mechanics (plate-bending problems to be more precise), but it has since found wide application in all areas of computational physics and engineering, as well as in CFD. FEM is by far the most flexible method of all methods we have studied so far, and it can be adapted to a wide range of numerical problems. This makes FEM a universal tool for solving differential equations numerically.

The basic concept of FEM can be thought of as splitting the computational domain into individual small patches and finding local solutions that satisfy the differential equation within the boundary of this patch. By stitching the individual solutions on these patches back together, a global solution can be obtained.

32.2 Discretization

As for all numerical methods, the first step to solving a problem using FEM is the discretization. In two dimensions, the basic unit of a mesh-suitable FEM is a triangle (see Fig. 32.1). For this the domain is subdivided into an arbitrary number of triangles. Regions with sharp changes in the domain boundary or regions where large changes of the dependent variable are expected should be resolved at higher accuracy, i.e., using more and smaller triangles. Regions where the dependent function is expected to change only slightly can be approximated using a rougher mesh, i.e., larger and fewer triangles.

f32-01-9782294740381
Fig. 32.1 Mesh discretization used in FEM. The basic geometry on a two-dimensional domain Ω is a triangle. The shape and position of the triangles are not important, only the location of the vertices.

As you can see from Fig. 32.1 the individual triangles are indexed (in this case using Roman numerals i-xiv). The corners of the triangles are indexed as well in this case using Arabic numbers. Each triangle obviously has a total of three corner points commonly referred to as vertices. An index matrix is created that links up the individual triangle with its three vertices points, A, B, and C, which are ordered in a mathematically positive sense, i.e., counter-clockwise (see Tab. 32.1).

Tab. 32.1

Index matrix used in FEM. The matrix links up the individual triangles with their three vertices points A, B, and C arranged in a mathematically positive sense, i.e., counter-clockwise

TriangleVertices
ABC
i1112
ii2113
iii3114
iv4115
v51112
vi5126
vii6127
viii7128
ix81213
x8139
xi91310
xii131210
xiii101211
xiv10111

t0010

In contrast to FDM and FVM, where the individual cells are usually identified by indices along the individual coordinate axes, FEM only requires the list of vertices. In FEM the solution of the dependent function g will be substituted by approximations at the vertices of the triangles, i.e., at the position of the vertices. In between these points, the solution is linearly interpolated.

32.3 Lagrangian Coordinates

The principle concept of the linear interpolation is shown in Fig. 32.2. Zooming in on one of the triangles, we need to find a way to create a function that interpolates linearly between adjacent edges inside of the triangle. If seen in a two-dimensional view, we need to find a way to describe an inclined plane that is our reconstruction function g˜ si1_e within the bounds of the triangle. As an example, we require the value of g˜ si1_e at the location of the point S. Obviously, S has defined x- and y-coordinates that we could simply use as values for g˜ si1_e to calculate the g˜S si8_e. However, the function g˜ si1_e will be defined in a piecewise manner, i.e., it will be different for each triangle. Therefore we cannot use the x- and y-coordinates of S that are given in the global coordinate system. We would require a local coordinate system that is valid only within the triangle.

f32-02-9782294740381
Fig. 32.2 Lagrangian coordinate system used as a local coordinate system within a single triangle of an FEM mesh. a) The dependent function g is approximated with g˜ si1_e within the triangle. b) The Lagrangian coordinate system uses the areas of the subtriangles created by the point S.

The common reference system of choice are the Lagrangian surface coordinates. Instead of using x and y this system uses the following coordinates:

ξA=AASCAABC=AASCAASC+AABS+ASBCξB=AABSAABC=AABSAASC+AABS+ASBCξC=ASBCAABC=ASBCAASC+AABS+ASBCξA+ξB+ξC=AASC+AABS+ASBCAASC+AABS+ASBC=1 si10_e

which make use of the area of the subtriangles ASC, ABS, and SBC, as well as the area of the whole triangle ABC. Given the values ξA, ξB, and ξC each point within the triangle ABC is uniquely defined. Please note that 0 ≤ ξi ≤ 1. This system is very convenient to work with and very simple to implement. It provides a local coordinate system that is dependent on the coordinates of the triangle edges and is only valid inside of it.

Working With the Coordinate System. As stated, given the values ξA, ξB, and ξC we can determine the position of S exactly. If two of the coordinates are zero, we obtain a vertex of the triangle. As an example, for ξA = ξB = 0 and ξA = 1 we obtain the point A. For ξA = ξC = 0 and ξB = 1 we obtain the point C. For ξB = ξC = 0 and ξA = 1 we obtain the point B.

If one of the coordinates is zero, we obtain the points along the edge of the triangle. For ξA = 0 and ξB + ξC = 1 we obtain points on the line between A and C. For ξB = 0 and ξA + ξB = 1 we obtain points on the line between A and B . Finally for ξC = 0 and ξA + ξB = 1 we obtain points on the line between B and C.

Local Reconstruction Function. Our reconstruction function within the triangle j (where j is the index of the triangle in Tab. 32.1) is thus transformed from a global function g˜ si1_e (x, y) into a local function g˜j si12_e (ξA, ξB, ξC) within the triangle j. In analytical form it is given by

g˜jξAξBξC=gjAξA+gjBξB+gjCξC

si13_e  (Eq. 32.1)

where g(j, {A, B, C}) are the values of the dependent function at vertices A, B, and C.

Global Coordinate System. This function is now given as a function of the Lagrangian coordinates ξA, ξB, and ξC. However, we require it as a function of the global coordinate system, i.e., as a function of x and y. Due to the properties of the Lagrangian coordinates, we can simply convert Lagrangian to global coordinates by noting

x=xAξA+xBξB+xCξC

si14_e  (Eq. 32.2)

y=yAξA+yBξB+yCξC

si15_e  (Eq. 32.3)

1=ξA+ξB+ξC

si16_e  (Eq.32.4)

where xi and yi are the x- and y-coordinates of the respective triangle, respectively. This is a system of equations that can be solved for ξA, ξB, and ξC for which we find

ξA=xyByC+yxCxB+xByCxCyBxAyByC+xByCyA+xCyAyB=xyByC+yxCxB+xByCxCyB2AABC

si17_e  (Eq. 32.5)

ξB=xyAyC+yxCxA+xAyCxCyAxAyByC+xByCyA+xCyAyB=xyAyC+yxCxA+xAyCxCyA2AABC

si18_e  (Eq. 32.6)

ξC=xyAyB+yxBxA+xAyBxByAxAyByC+xByCyA+xCyAyB=xyAyB+yxBxA+xAyBxByA2AABC

si19_e  (Eq. 32.7)

Using Eq. 32.5, Eq. 32.6, and Eq. 32.7 we can rewriteEq. 32.1 as a function of x and y.

Global Reconstruction Function. We now have a piecewise-linear solution of the differential equation in Ω given by Eq. 32.1 rewritten as a function of x and y for each triangle given by

g˜jxy=gjAξAjxy+gjBξBjxy+gjCξCjxy

si20_e  (Eq. 32.8)

where we insert Eq. 32.5, Eq. 32.6, and Eq. 32.7 as functions ξA(j)(xy), ξB(j)(xy) and ξC(j)(xy). This function is linear within the triangle j and zero outside of it. Stitching together all N triangles into which we subdivided the domain Ω results in the global reconstruction of g˜ si1_e given by

g˜jxy=j=0Ng˜jxy=j=0NgjAξAjxy+gjBξBjxy+gjCξCjxy

si22_e  (Eq. 32.9)

Eq. 32.9 is a function that depends linearly on x and y. If you look carefully at Eq. 32.9 you will see that we know almost all of the variables. As the discretization of the domain has already been done, we know the coordinate points xA(j), xB(j), and xC(j). Obviously, these do not depend on the differential equation we want to solve but merely on the geometry of the grid. We are only missing the values g(j, A), g(j, B), and g(j, C). We need a suitable approach to approximate these values.

Three-Dimensional Grids. In the following we perform the derivation of FEM on two-dimensional grids using triangles as mesh elements. If we extend the derivation in three dimensions we will obtain tetrahedral elements. In three dimensions, we obviously have four vertices to work with. Therefore we also introduce an additional Lagrangian coordinate, ξD, and Eq. 32.1 would be extended to

g˜jξA,ξB,ξC,ξD=gjAξA+gjBξB+gjCξC+gjDξD

si23_e  (Eq. 32.10)

We would then also extend Eq. 32.2, Eq. 32.3, and Eq. 32.4 to

x=xAξA+xBξB+xCξC+xDξD

si24_e  (Eq. 32.11)

y=yAξA+yBξB+yCξC+yDξD

si25_e  (Eq. 32.12)

z=zAξA+zBξB+zCξC+zDξD

si26_e  (Eq. 32.13)

1=ξA+ξB+ξC+ξD

si27_e  (Eq. 32.14)

Solving this system of equations would allow us to write the reconstruction function within the tetrahedra j in three dimensions given by

g˜jxy=gjAξAjxyz+gjBξBjxyz+gjCξCjxyz+gjDξDjxyz

si28_e  (Eq. 32.15)

where we obtain ξA(j)(xyz), ξB(j)(xyz), ξC(j)(xyz), and ξD(j)(xyz) from solving Eq. 32.11, Eq. 32.12, Eq. 32.13, and Eq. 32.14 for ξA, ξB, ξC, and ξD. Obviously, the resulting equations are slightly more complex, but the procedure is straightforward.

32.4 Basis Functions

In the next step, we require an approximation function that allows us to derive the unknown values g(j, A), g(j, B) and g(j, C). There are several methods of approaching this problem, but the most commonly used is based on a Galerkin approach. We therefore propose an approximation function according to Eq. 29.2 given by a set of N linearly independent functions:

g˜x=i=1Nciψix

si29_e  (Eq. 32.16)

In analogy to the derivation for the regular Galerkin method (see section 29.2) we chose the basis functions ψi as our weighting function, which yields a system of N equations given by Eq. 29.10. We have used the Galerkin method before and we also studied clever choices of the basis functions, which are the basis of spectral methods (see section 29.2.4).

32.4.1 Localized Support in One Dimension: Hat Functions

However, FEM takes a different approach. Here, we use functions with localized support. Localized-support functions are functions that are only defined in a very small interval and are zero everywhere else. They are therefore piecewise-defined. The most common functions for one-dimensional FEM are hat functions (see Fig. 32.3a). The name stems from the fact that they look like a very pointed hat. As you can see from Fig. 32.3a the domain is first subdivided into intervals that are not necessarily of the same size. In the interval j a piecewise-linear hat function ψj is defined such that it reaches the center value g˜j si12_e of the interval and thus “locally supports” the solution function g˜ si1_e.

f32-03-9782294740381
Fig. 32.3 Common approximation functions in FEM. a) In one-dimensional problems the most common approach is based on hat functions. The domain is split into small intervals j and a linear approximation is assumed for the center value of each interval. In order to be able to determine the constants the approximation functions must overlap. b) In a two-dimensional problem the approach is based on pyramid functions that are linear approximations of neighboring triangles in a way that the center value (in this case point 1) can be determined. All other values are assumed to be zero in this case.

As you can see, the function ψj is not defined in a way that it is zero at the boundaries of the interval but at the location of the neighboring intervals’ center values. One may ask why these functions “overlap.” The reason for this is simple: The piecewise-linear profile has two subintervals. The first subinterval in which the function increases and the second subinterval in which the function decreases. Both intervals require a gradient, i.e., we have two unknowns. Therefore it is not sufficient to consider a single interval alone, which only gives us one equation of the form Eq. 29.10. We have already encountered this problem before when introducing the piecewise-linear reconstruction in FVM (see section 31.5.4). We introduced stencil methods as a means of achieving a similar “overlapping” of the reconstruction function. We have to do the same thing here.

32.4.2 Localized Support in Two Dimensions: Pyramid Functions

The basis functions in two dimensions are simply a two-dimensional version of a hat function. These functions are referred to as pyramid functions (see Fig. 32.3b). Depending on the number of triangles that are adjacent in a specific point (in this case point 1) the function involves several neighboring triangles. In all cases, the function ψj is defined such that it supports the solution function at the central value g˜j1 si32_e and is zero at all other points. Each triangle amounts to one equation of the form of Eq. 29.10. If there are four triangles adjoining in point 1 (as shown in Fig. 32.3b) we have a total of four unknowns to solve for the unknown inclination values of each of the four triangles.

32.4.3 FEM-Galerkin Method

We can now proceed by writing out the N equations for the FEM-Galerkin method by Eq. 29.10 as

ψjxLx,g,dgdx,d2gdx2dΩ=0

si33_e  (Eq. 32.17)

We have modified the notation to account for multiple dependent variables x1, x2,…, xN, and the domain was rewritten to Ω. In this sense, Ω can refer to a one-dimensional domain (linear), a two-dimensional domain (plane), or a three-dimensional domain (volume). We apply this equation to each of the j nodes in our domain. At each node we include all adjacent triangles from which we form the basis function ψj. We apply this function to Eq. 32.17, obtaining one equation per node. Please note that in this case the index j does not refer to the individual triangle but to the pyramid made from the triangles that are adjacent in a given point. This is important to keep in mind as we are used to using fixed indices to refer to volumes, intervals, etc. This also implies that the value of the point 1 in Fig. 32.3b when calculating the pyramid j is nonzero whereas it is zero when calculating all other pyramids in the domain Ω. This is due to the nature of localized-support functions.

We will now turn to investigating potential terms that may arise from the linear differential operator L. There is only a limited choice of potential terms that we will need to discuss. We already did a similar discussion of such contributions when deriving FVM (see section 31.3.3). However, in this case, the mathematics is slightly different.

Constants: Sources and Sinks. Source and sink terms yield constants. Obviously, constants are simply integrated over the domain. As already stated, these values are often given as normalized values, e.g., in the form of the volume forces k si34_e of the Navier-Stokes equation (see Eq. 11.40), which are simply multiplied with the domain. As stated, the domain may not be a volume. In this case, these values may be given as the “quantity of the dependent variable per area” (two-dimensional) or the “quantity of the dependent variable per length” (one-dimensional). Thus the integration simply is

ψjcdΩ=cψjdΩ

si35_e

which only amounts to the integration of ψj.

Nabla Operators: Divergence. In general, a divergence of the dependent variable g gives rise to the integral

ΩψjgdΩ

si36_e

which cannot be simplified further.

Laplace Operators: Diffusion. The third case we will discuss are diffusion effects of the dependent variable’s quantity, which is described by Laplace operators.

ΩωΔgdΩ=Ωψj2gx2+2gy2+2gz2dΩ=Ωxψjgxψjxgx+yψjgyψjygy+zψjgzψjzgzdΩ=Ωxψjgx+yψjgy+zψjgzdΩΩψjxgx+ψjygy+ψjzgzdΩ=ΩψjgdΩΩψjgdΩ

si37_e  (Eq. 32.18)

where we apply Gauss’s theorem (see Eq. 7.10) on the first integral for which we find

ΩψjgdΩ=ΩψjgndΩ=0

si38_e

which is zero because our localized-support functions ψj are designed such that they are zero on the boundary of the domain. In this case Eq. 32.18 simplifies to

ΩψjΔgdΩ=ΩψjgdΩ

si39_e  (Eq. 32.19)

Different Reconstruction Functions. During our derivation we have used linear interpolation within the individual triangles. Obviously, this is not the only reconstruction scheme that can be used. It is equally possible to use quadratic approximations in the same way we have used these for FVM (see section 31.5.5). These approximations give rise to slightly more complex integrals but often to (significantly) more exact solutions.

32.5 One-Dimensional Example: Flow in Infinitesimally Extended Channels

32.5.1 Problem Definition

We return to the example of the infinitesimally extended channel (see section 16.2) for which we found the following ODE (see vEq. 16.9)

d2vxdz2=1ηdpdx

si40_e  (Eq. 32.20)

We use the same example we have used during the illustration of the Chebyshev polynomials in spectral methods using the values

η=1mPasdpdx=0.001mbarmm11ηdpdx=100mm1s1

si41_e

which allows us to rewrite Eq. 32.20 to

d2vxdz2+100=0

si42_e  (Eq. 32.21)

where the domain is − 1 ≤ z ≤ 1 (in mm) and the result is obtained in mms−1. The coordinate system is shifted into the center of the channel.

32.5.2 Hat Functions

We will solve this example using a one-dimensional FEM approach with hat functions as basis functions. For this, g˜ si1_e will be a function of z only, which is the only independent variable. We will split the domain into intervals of equal size according to Fig. 32.3a. Within the interval j our approximation function g˜ si1_e (j) takes the form

ψjz=g˜jzzj1zjzj1zj1zzjzj+1zzj+1zjzjzzj+10otherwise

si45_e  (Eq. 32.22)

Our approximation function g˜ si1_e on the domain is thus given by

g˜z=j=1Ng˜jψjz

si47_e  (Eq. 32.23)

32.5.3 Integration

Referring to section 4.3 we now set up the integration equation given by Eq. 32.17. The differential operator only has a single entry and contains a constant and a diffusion term. According to the derivation in section 4.3 we can write the integral as

Ωjψjd2g˜dz2+100dΩ=0Ωjψjg˜dΩ+100ΩjψjdΩ=0Ωjψjzg˜dzdΩ=100ΩjψjdΩ

si48_e  (Eq. 32.24)

which amounts to one equation per interval j. We now require the first derivative of our approximation function g˜ si1_e, which is given by

g˜z=i=1Ng˜iψiz

si50_e  (Eq. 32.25)

Please note that we have to use the index i because the derivative within the interval j will also include contributions from g˜j1 si51_e and g˜j+1 si52_e , which is why we need to use a separate index variable. Using the definition of g˜j si12_e we can now derive the partial differential and the integral given by

ψjz=1zjzj1zj1zzj1zj+1zjzjzzj+10otherwise

si54_e  (Eq. 32.26)

ΩjψjdΩ=zj1zjzzj1zjzj1dz+zj1zjzzj1zjzj1dz=z22zzj1zjzj1zj1zj+zzj1z22zj1zjzjzj+1=zj2zj122zjzj1zj1zjzj1+zj+1zjzj+1zj+12zj22zj+1zj

si55_e  (Eq. 32.27)

As you can see, these values depend solely on the geometry of the chosen mesh and can thus be precalculated. In this example, we assume a total of 10 intervals of equal size. Our boundary − 1 ≤ z ≤ 1 is thus subdivided into intervals of size Δz = 0.2. Using this simplification we can simplify Eq. 32.22, Eq. 32.26, and Eq. 32.27 to

g˜j=g˜jzzj1Δz,zj1zzjzj+1zΔz,zjzzj+10otherwise

si56_e  (Eq. 32.28)

ψjz=1Δz,zj1zzj1Δz,zjzzj+10otherwise

si57_e  (Eq. 32.29)

ΩjψjdΩ=zj2zj122Δzzj1+Δzzj+1zj+12zj22Δz=zj2zjΔx22ΔzzjΔz+Δzzj+Δzzj+Δz2zj22Δz=2zjΔzΔx22ΔzzjΔz+Δzzj+Δz2zjΔz+Δz22Δz=Δz

si58_e  (Eq. 32.30)

Obviously, these are some very neat simplifications. In most cases, we cannot make these types of simplifications because the mesh is not regular and thus the width of the individual interval is different.

32.5.4 Matrix Notation

We now combine Eq. 32.24 and Eq. 32.30 finding

Ωjψjzi=1Ng˜iψizdΩ=100ΩjψjdΩ

si59_e  (Eq. 32.31)

We can now insert Eq. 32.30 in the right-hand side of Eq. 32.31 finding

Ωjψjzi=1Ng˜iψizdΩ=100Δz

si60_e  (Eq. 32.32)

We need a little more caution when evaluating the left-hand side of Eq. 32.32. At interval j we only need to take into account the terms i=1Ng˜iψiz si61_e with i = j − 1, i = j, and i = j + 1. Remember that we designed the local support functions such that they overlap by one interval. We therefore can rewrite Eq. 32.32 to

Ωjψjzg˜j1ψj1z+g˜jψjz+g˜j+1ψj+1zdΩ=100Δz

si62_e  (Eq. 32.33)

We note that the first integral of Eq. 32.33 must only be evaluated on the range z(j) – Δz ≤ z ≤ z(j) because ψj1 si63_e is zero for z > z(j). We therefore find

g˜j1zjΔzzjψjzψj1zdz=g˜j1zjΔzzj1Δz2=g˜j1zΔz2zjΔzzj=g˜j1Δz

si64_e  (Eq. 32.34)

Likewise, the third integral of Eq. 32.33 must only be evaluated on the range z(j) ≤ z ≤ z(j) + Δz because ψj is zero for z < z(j). We therefore find

g˜j+1zjzj+Δzψjzψj+1zdz=g˜j+1zjzj+Δz1Δz2=g˜j+1zΔz2zjzj+Δz=g˜j+1Δz

si65_e  (Eq. 32.35)

The middle integral in Eq. 32.33 must be evaluated from z(j) − Δz ≤ z ≤ z(j) + Δz because ψj is nonzero in this range. We therefore find

g˜jzjΔzzj+Δzψjzψjzdz=g˜jzjΔzzj+Δz1Δz2=g˜jzΔz2zjΔzzj+Δz=2g˜jΔz

si66_e  (Eq. 32.36)

Inserting Eq. 32.34, Eq. 32.35, and Eq. 32.36 into Eq. 32.33 yields

1Δzg˜j1+2g˜jg˜j+1=100Δzg˜j1+2g˜jg˜j+1=100Δz2

si67_e  (Eq. 32.37)

where we have a linear equation for the interval j that involves the unknown values g˜j1 si51_e, g˜j si12_e, g˜j+1 si52_e.

Finite-Difference Scheme. If you look at Eq. 32.37 you can see that this is a finite difference approximation for the second derivative according to Eq. 4.10. This is due to the fact that we used a regular mesh for this FEM approach. We would also obtain this equation from an FDM approach. As an example, refer to Eq. 30.2 where we have obtained this equation in two-dimensional form. We could use the spreadsheet prepared for Fig. 30.5 directly to solve this problem using an FDM approach.

Left-Hand Boundary Values. If you refer to Fig. 32.3a you can see that we have to evaluate a slightly different integral for the first and the Last intervals in the domain in order to account for the boundary values. This is due to the fact that the basis functions ψ0 and ψN are only defined on half of the interval. The value g0 si71_e is the boundary value of the left-hand side of the domain. For this we find Microfluidics: Modeling, Mechanics, and Mathematics

g˜0=g˜0z1zΔzz0zz10otherwise

si72_e  (Eq. 32.38)

ψ0z=1Δzz0zz10otherwise

si73_e  (Eq. 32.39)

Ω0ψ0=zz1z22Δzz0z1=Δzz1z12z1Δz22Δz=Δz2

si74_e  (Eq.32.40)

which we require to calculate Eq. 32.33 for the first interval j = 0. Since the domain Ω0 is g˜0zg˜1 si75_eEq. 32.33 simplifies to

Ω0ψ0zg˜0ψ0z+g˜1ψ1zdΩ=100Ω0ψ0dΩg˜0Ω0ψ0zψ0zdΩ+g˜1Ω0ψ0zψ1zdΩ=100Δz2

si76_e  (Eq. 32.41)

g˜0zΔz2z0z1+g˜1zΔz2z0z1=50Δzg˜0Δzg˜1Δz=50Δzg˜0g˜1=50Δz2

si77_e  (Eq. 32.42)

where we have the equation of the left-hand side boundary of the domain.

Right-Hand Boundary. We repeat this calculation for the right-hand side boundary of the domain. The last interval N in our domain is only defined for z(N-1) ≤ z ≤ z(N), where g˜N si78_e is the boundary value. As stated, ψN is only defined on a half-interval. For this we find

g˜N=g˜NzzN1ΔzzN1zzN0otherwise

si79_e  (Eq. 32.43)

ψNz=1ΔzzN1zzN0otherwise

si80_e  (Eq. 32.44)

ΩNψN=z22ΔzzzN1zN1zN=zN1+Δz2zN122ΔzzN1Δz=Δz2

si81_e  (Eq. 32.45)

which we use to calculate the integral from Eq. 32.33 of j = N. Since the domain ΩN is g˜N1zg˜N si82_eEq. 32.33 simplifies to

ΩNψNzg˜N1ψN1z+g˜NψNzdΩ=100ΩNψ0dΩg˜N1ΩNψNzψN1zdΩ+g˜NΩNψNzψNzdΩ=100Δz2

si83_e  (Eq. 32.46)

g˜N1zΔz2zN1zN+g˜NzΔz2zN1zN=50Δzg˜N1Δz+g˜NΔz=50Δzg˜N1+g˜N=50Δz2

si84_e  (Eq. 32.47)

Where we have the equation of the right-hand side boundary of the domain.

Stiffness Matrix and Load Vector. With Eq. 32.42 for the left-hand boundary of the domain, Eq. 32.47 for the right-hand boundary, and Eq. 32.37 for all intervals between we can now write out the individual equations for all intervals. Inserting the value Δz = 0.2, i.e., accounting for a total of 10 intervals on the domain, we find

g˜0g˜1=2j=0lefthandboundaryg˜j1+2g˜jg˜j+1=41jN1allnonboundaryintervalsg˜N1+g˜N=2j=Nrighthandboundary

si85_e

If we arrange the 10 intervals we obtain a total of 12 linear equations. The two additional equations are due to the boundary conditions. Written out in a matrix we obtain the following form:

110000000000121000000000012100000000001210000000000121000000000012100000000001210000000000121000000000012100000000001210000000000121000000000011g˜0g˜1g˜2g˜3g˜4g˜5g˜6g˜7g˜8g˜9g˜10g˜11=244444444442

si86_e  (Eq. 32.48)

Eq. 32.48 in a regular linear system of type Ax=b si87_e as we have studied them in section 25.3. In FEM the matrix A is referred to as the stiffness matrix. The vector b si88_e is referred to as the load vector.

The matrix of Eq. 32.48 contains a total of 10 intervals, but we have written a total of 12 equations in order to account for the boundary conditions, where g˜0 si89_e is the value on the left-hand side boundary and g˜11 si90_e is the value at the right-hand side boundary. If the boundary condition is Neumann type, we do not know these values, only their relation to the neighboring values. As an example, if the boundary values are expected to have a zero-gradient we could change the system such that g˜0=g˜1 si91_e and g˜11=g˜10 si92_e.

However, in our example, the boundary values are given. As the boundary condition is the no-slip condition we know that g˜0=g˜11=0 si93_e. Therefore, our system of equation reduces to 10 equations, as we can drop the first and the last equations brought in by the boundary conditions. This simplifies the system to

2100000000121000000001210000000012100000000121000000001210000000012100000000121000000001210000000012g˜1g˜2g˜3g˜4g˜5g˜6g˜7g˜8g˜9g˜10=4444444444

si94_e  (Eq. 32.49)

The only thing that is left to do is to solve Eq. 32.49 using any suitable method for solving linear systems of equations.

32.5.5 Maple Worksheet

For solving Eq. 32.49 we will make use of the Thomas algorithm (see section 25.3.8) and our implemented function DoThomas from listing 25.12. The listing is shown in listing 32.1. As you can see, it is fairly short. It repeats the example we have already used in listing 25.12, where we actually anticipated this example. After restarting the

Listing 32.1

[Maple] Listing for solving a linear system of equations encountered in FEM using the Thomas algorithm. A digital version of the listing can be found under the name FEMlD.mw in the supplementary material.

 1 restart:read "Core.txt":read "CoreFunctions.txt":
 2
 3 A:=Matrix ([[2 ,−1,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0],
 4             [− 1,2 , − 1,0 ,0 ,0 ,0 ,0 ,0 ,0],
 5             [ 0, − 1,2 , − 1,0 ,0 ,0 ,0 ,0 ,0],
 6             [ 0, 0, − 1, 2, − 1,0 ,0 ,0 ,0 ,0],
 7             [ 0, 0, 0, − 1,2 , − 1,0 ,0 ,0 ,0],
 8             [ 0, 0, 0, 0, − 1,2 , − 1,0 ,0 ,0],
 9             [ 0, 0, 0, 0,0 , − 1,2 , − 1,0 ,0],
10             [ 0, 0, 0, 0,0 ,0 , − 1,2 , − 1,0],
11             [ 0, 0, 0, 0,0 ,0 ,0 , − 1,2 , − 1],
12             [ 0, 0, 0, 0,0 ,0 ,0 , 0, − 1,2]]);
13 b:=Vector( [4,4,4,4,4,4,4,4,4,4] );
14 vx:=DoThomas ( A, b);

Maple server and including the files Core.txt and CoreFunctions.txt we define the matrix A in line 3 and the vector b si88_e in line 13. We then call the functions DoThomas, obtaining the solution

vx=20364856606056483620

si96_e

We already know from Eq. 32.28 that the correct solution is

vx (z) = 50 (1 − z2)

If we plot the results from line 14 against the analytical solution we can see that the results are slightly off (see Fig. 32.4). This is due to the fact that we chose a very rough mesh with a spacing of 200 μm, which is too coarse for obtaining good solutions. However, if the mesh is refined, i.e., Δz is reduced, the solution becomes more and more exact. For Δz = 100 μm the solution is already significantly closer to the analytical solution. This requires a total of only 20 intervals.

f32-04-9782294740381
Fig. 32.4 Numerical solution of the flow profile in infinitesimally extended channels using FEM. As you can see, the numerical results are slightly off from the analytical solution. If the mesh is refined, i.e., Δz is reduced, the solution approaches the analytical solution.

Plotting the Hat Functions. In order to illustrate the hat functions, i.e., our basis functions ψj we plot the functions using the resulting values g˜j si12_e obtained from listing 32.1. The result is shown in Fig. 32.5. As you can see, the hat functions locally support the solution g˜ si1_e (x) which is linearly interpolated between the support points.

f32-05-9782294740381
Fig. 32.5 Hat functions plotted using the values obtained from listing 32.1. As you can see, the functions locally support the solution g˜ si1_e (x).

32.5.6 General Notation

As we have seen, it is not complicated to apply FEM to solving PDEs in one dimension. Ultimately, we are left with solving a linear system of equations of the form given in Eq. 32.49. We have derived the equations for the stiffness matrix A and the load vector b si88_e analytically in our example. We will now give the general notation for them depending on the type of boundary conditions.

Known Boundary Values. In this case we do not require the calculation of the boundary values as they are given. In this case, the entries aj,k of the matrix A can be calculated according to Eq. 32.33 as

aj,k=Ωjψjzg˜j1ψj1zdΩk=j11Ωjψjzg˜jψjzdΩk=jΩjψjzg˜j+1ψj+1zdΩk=j+1N0otherwise

si100_e

where j is the row and k is the column index. Likewise the entries of the load vector b si88_e can be calculated according to Eq. 32.31 as

bj=Ωjψjzg˜j1ψj1z+g˜jψjz+g˜j+1ψj+1zdΩ,1jN

si102_e

where the value g˜0 si89_e is the left-hand side boundary value and the value g˜N si78_e is the right-hand side boundary value.

Unknown Boundary Values. In case the boundary values are not known they must be calculated as well. In this case, the first (j = 0) and the last (j = N + 1) rows of the stiffness matrix are calculated differently. We find the following from Eq. 32.41 and Eq. 32.46:

a0,k=Ωjψjzg˜jψjzdΩk=jΩjψjzg˜j+1ψj+1zdΩk=j+1N0otherwise

si105_e

aj,k=Ωjψjzg˜j1ψj1zdΩk=j11Ωjψjzg˜jψjzdΩk=jΩjψjzg˜j+1ψj+1zdΩk=j+1N0otherwise

si100_e

aN,K=Ωjψjzg˜j1ψj1zdΩk=j11Ωjψjzg˜jψjzdΩk=j0otherwise

si107_e

Likewise, the load vector b si88_e is calculated as

bj=Ωjψjzg˜jψjz+g˜j+1ψj+1zdΩj=0Ωjψjzg˜j1ψj1z+g˜jψjzdΩj=NΩjψjzg˜j1ψj1z+g˜jψjz+g˜j+1ψj+1zdΩotherwise si109_e

General LU-Decomposition. Using the equations provided, it is easy to derive the stiffness matrix and the load vector once the elements Ωj are known. In a general FEM scheme the domains would have different widths, and therefore the stiffness matrix and the load vector cannot be derived directly as we did in our example. However, the general layout of the matrix is retained. The matrix will be downwards-diagonal and will only be nonzero at the entries left and right of the diagonal (a tridiagonal matrix; see section 25.3.2.2). This makes these types of FEMs easy to solve using schemes for linear systems of equations, e.g., LU-decomposition.

32.6 Two-Dimensional Example: Flow in Rectangular Channels

32.6.1 Problem Definition

In the next step, we will extend our example to a two-dimensional problem. We will again turn to the example of the pressure-driven flow for which the governing PDE is Eq. 15.14 given by

2vxz2+2vxy2=1ηdpdx

si110_e  (Eq. 32.50)

where we will use the values

η=1mPasdpdx=0.001mbarmm11ηdpdx=100mm1s1

si111_e

In this example, we will assume a cylindrical channel cross-section, i.e., a Hagen-Poiseuille flow (see section 16.3). Obviously, there is no need to solve the two-dimensional Poisson equation, Eq. 32.50, in a cylindrical cross-section as this problem can be treated in cylindrical coordinates, in which case it becomes one-dimensional. This was our approach during the derivation of the Hagen-Poiseuille flow. However, the cylindrical profile serves one simple reason here as it demonstrated how well FEM can be used in cases where the geometry is curved. If you recall, this is problematic, e.g., for FDM which usually requires cubic control volumes.

32.6.2 Mesh

The first step of FEM is the discretization of the computational domain Ω. In FEM we usually refer to this domain as the mesh. The support points of the solution are referred to as nodes. As the two-dimensional FEM uses triangles as smallest unit in the mesh, this process is also referred to as triangulation.

There is more than one way to create the mesh. Usually, numerical software packages will contain a certain selection of algorithms for creating the mesh. As we will see in just a moment, the choice of mesh will influence the exactness of the solution greatly. We have already experienced the importance of the size of a single element in the mesh during our example of one-dimensional FEM (see Fig. 32.4). For smaller mesh elements we obtain significantly more accurate results. In this example, we chose the diameter of the cross-section to be 1 mm. The mesh we will use is shown Fig. 32.6. As stated, there is a certain liberty in designing the mesh and the shown geometry is by no means optimized. In general, the choice of nodes should be made such that the curvatures of the domain are approximated as closely as possible. In addition, regions where the expected solution will have steeper gradients should be more finely resolved than regions where small changes are expected. As you can see, we could have used smaller elements on the edge of the domain where we expect the steepest gradients. However, this mesh is sufficient to demonstrate the concept.

f32-06-9782294740381
Fig. 32.6 Mesh for solving the Poisson equation for a circular cross-section. The mesh has a total of 29 nodes. It is chosen randomly ensuring that the triangles are similar in size. Toward regions of (expected) steeper gradients in the solution the mesh can be further refined to obtain more accurate solutions.

32.6.3 Derivation

We have shown in section 4.3 that a Laplace operator, i.e., the left-hand side of Eq. 32.50, can be rewritten using Eq. 32.19 using the Galerkin approach. We therefore can rewrite Eq. 32.50 to

ΩψjgdΩ=Ωρx,yψjdΩΩψjxgx+ψjygydΩ=Ωρx,yψjdΩ

si112_e  (Eq. 32.51)

where we have replaced the right-hand side of Eq. 32.50 with the more general function ρ(x, y). Obviously, we need to split up this integral over the individual subdomains Ωj. Recall that these domains are not the individual triangles but the collection of neighboring triangles around the node j (see Fig. 32.3b). As an example, take the node 1 in our grid. Its domain Ωj would consist of the triangles (1,13, 2), (1,2,3), (1,3,4), (1,4,5), (1,5,6), (1,6, 7), (1, 7,8), (1,8,9), (1,9,10), (1,10,11), (1,11,12), and (1,12,13). The pyramid function g˜1 si3_e that “supports” the approximated solution g˜ si1_e at the node 1 is built up of from linear approximations within each of these triangles (see Fig. 32.7).

f32-07-9782294740381
Fig. 32.7 Pyramid function supporting the value g˜1 si3_e) in the two-dimensional mesh.

As you can see, we require the partial derivatives of basis functions ψj as well as the partial derivative of the reconstruction function g for Eq. 32.51. The product of these must be integrated for each domain Ωj. As already stated, this domain is made up of individual triangles for which we already derived a convenient coordinate system in section 3 by introducing the Lagrangian coordinates. Within one triangle ABC (denoted with Δ)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset