An illustrative example

7.7.2 An illustrative example

Example 7.5 Consider solving a one-dimensional conduction equation for an insulated metal rod which has internal heat generation. The governing equation is

d 2 T k 2 +g=0 dx

The dimensions and other data are as follows: length of the rod is 1 m, cross- sectional area of the rod is 0.01 m 2 , thermal conductivity k = 5 W/m.K, generation g = 20 kW/m 3 , the ends are at 100°C and 500°C. We are inter- ested in obtaining a solution, say, using a grid of 20 cells giving a spacing of ∆x = 0.05 m, which we name Grid 1.

Solution Figure 7.6 shows Grid 1 along with the boundary conditions marked at each end. It is not necessary here to describe how discretisation equations

7.7 MULTIGRID TECHNIQUES

Figure 7.6 The 20 node grids used to solve the problem –

are obtained for this problem; the procedure is similar to Example 4.2. Grid 1

Table 7.12 gives a summary of coefficients of the discretisation equations at nodes 1, 2, 3, . . . , 20.

Table 7.12 Coefficients of the discretisation equation at each point

1 (first node)

0 qAδx +

(internal nodes)

20 (last node)

0 qAδx +

We use the expressions in Table 7.12 to compile the numerical values of coefficients in Table 7.13 and to construct the matrix equation A . x = b, where solution vector x contains the temperatures at the nodes of Grid 1.

Table 7.13 Numerical values of the coefficients of the discretisation equation

The matrix equation is

G 3.0 −1.0 0 .

0 JGx 1 J G 210J

. KH. .K = H. .K (7.37)

H. .

. KH.K H.K

H. .

. −1.0 2.0 −1.0 K Hx 19 K H 10K

3.0 L Ix 20 L I1010L The matrix of coefficients is tri-diagonal, so we can use the TDMA to obtain

I. .

a solution in a single pass. The result is given in Table 7.14 to enable later verification of the multigrid solution.

234 CHAPTER 7 SOLUTION OF DISCRETISED EQUATIONS

Table 7.14 The TDMA solution

Grid 1 – Temperature at nodes

Step 1: Fine grid iterations We use the Gauss–Seidel iteration (7.20) to solve these equations. We simply initialise the temperature to 150°C everywhere as an initial guess to start the iterative process (a field closer to the final solution will not highlight

the benefit of the method). The solution vector y h after five Gauss–Seidel

iterations is shown below:

Gy 1 J

G116.755J

Hy 2 K

H141.994K

H160.427K H.K =H . K

Hy 3 K

H.K (7.38) H. K

H.K

H. K

Hy 19 K H394.392K Iy 20 L I468.130L

The residual vector r h =b−A h .y h at this stage is

G 210J

G 3.0 −1.0 0

Gr h 1 .

JGy 1 J G1.728J

0 KHy 2 K H3.193K

0 KHy 3 K H4.658K

r h =H . K =H . K −H .

. KH.K . K

. KH.K =H H.K

. h KH.K H.K

2.0 −1.0 K Hy 19 K H7.461K

. −1.0 3.0 L Iy 20 L I0.000L The total r.m.s. residual value is 14.951. If the iteration process is continued

Ir 20 L

I1010L

I. .

the residual vector will reduce slowly until the convergence criterion is achieved. Figure 7.9 at the end of this section shows the pattern of conver- gence for the Gauss–Seidel iteration. Using a sum of r.m.s. residuals less than 10 −6 as the convergence criterion, the final solution is achieved after 664 iterations. The converged solution is of course indistinguishable from the TDMA solution in Table 7.14.

Step 2: Restriction To apply the multigrid method we have to construct a coarse grid first. The simplest method is to construct a grid which has half the number of cells. Figure 7.7 shows the fine mesh and the proposed coarse meshes drawn one beneath the other. The first coarse mesh uses 10 cells with a spacing of 0.1 m and is named Grid 2. The next coarse mesh – Grid 3 – consists of 5 cells with

a spacing of 0.2 m.

If the fine grid mesh spacing is h, a mesh using half the number of cells would have a mesh spacing of 2h. In the multigrid literature the mesh spacing is indicated by means of superscripts. In this notation the residual

vector we have on the fine mesh is r h .

7.7 MULTIGRID TECHNIQUES

Figure 7.7 Grids used to solve Now we need to interpolate the residual vector from a fine grid to a coarse the problem

grid. Since the nodes of Grid 2 are exactly mid-way between those of Grid 1 we can interpolate by simple averaging of r h to obtain the residual vector r 2h for the coarse grid. The values are summarised in Table 7.15. Note that only

3 decimal places of the actual numbers are shown in the table. As mentioned earlier, this transfer process is known as ‘restriction’.

Table 7.15 Fine mesh and coarse mesh residuals showing restriction process of transfer from fine Grid 1 to coarse Grid 2

Fine mesh (Grid 1) residuals – (r h )

Coarse mesh (Grid 2) residuals – after restriction (r 2h )

In matrix form the Grid 2 residual vector after ‘restriction’ is

Gr 2h

1 2h J G 2.460J Hr 2h 2 K H 5.317K Hr 3 K H 7.506K

2h =H r . K =H . K H.KH.K H.KH.K 2h

Hr 2h 9 K H28.173K Ir 10 L I 3.730L

Note that we have only 10 values now. The error in the coarse mesh satisfies the equation A 2h .e 2h =r 2h . We have calculated the vector r 2h , but we also need the matrix A 2h to solve this equation to obtain e 2h . In the multigrid literature there are numerous techniques which use elegant interpolation operators to evaluate A 2h . For this example problem we do not interpolate the coefficient matrix, but calculate the coefficients of the coarse grid matrix exactly using the expressions in Table 7.12. Thus, we obtain the following

matrix equation for the error vector e 2h :

236 CHAPTER 7 SOLUTION OF DISCRETISED EQUATIONS

G 1.5 −0.5 2h 0 . . . 0 J Ge

J G 2.460J

H−0.5 1.0 −0.5

0 2h

K He 2 2h K H 5.317K

H 0 −0.5 1.0 −0.5 .

0 K He 3 K H 7.506K

H. .

. KH.K . K

H. .

=H KH.KH.K (7.39)

H. .

. KH.KH.K

H. .

1.0 −0.5 2h K He 9 2h K H28.173K

I. .

. −0.5 1.5 L Ie 10 L I 3.730L We now solve system (7.39) with an initial guess of e 2h = (0, 0, 0, . . . , 0)

using the Gauss–Seidel iteration procedure. Since the iterations are now on a coarser mesh, the rate of residual reduction is faster and the cost per iteration is much lower. After 10 iterations on this coarse mesh we obtain the

error vector e 2h on the first coarse mesh (Grid 2) as

Ge 2h

1 2h J G 19.156J He 2 2h K H 58.310K He 3 K H 96.049K

H.K =H . K H.KH (7.40) . K

H.KH . 2h K He 2h 9 K H158.591K Ie 10 L I 55.351L

Since we have only performed 10 iterations this solution is partially converged and there will be a residual: < 2h =r 2h −A 2h .e at start 2h . Its values are given in Table 7.16 along with interpolated Grid 3 residuals r 4h after restriction. Table 7.16 Residuals on Grid 2 and restricted residuals on Grid 3

Coarse mesh (Grid 2) residuals > 2 h

Coarse mesh (Grid 3) residuals r 4h – after restriction

3.615 0.459 Now the residuals < 2h have been transferred to an even coarser grid with

five nodes (see Figure 7.7) to yield residual r 4h . Then we solve for the error

e 4h on Grid 3 using the system of equations A 4h . e 4h =r 4h , where the co- efficients of A 4h are again calculated from scratch using the expressions in Table 7.12. As the cost per iteration is very low we can afford to do more iterations on Grid 3 to achieve very effective error reduction. After 10 itera-

tions we get the solution in Table 7.17 for error vector e 4h .

Table 7.17

Grid 3 – solution (error vector e 4h on Grid 3)

47.205 16.348 This coarsening procedure could be continued, but in this illustrative

7.7 MULTIGRID TECHNIQUES 237

Step 3: Prolongation The next step is to go backwards transferring error vectors from each coarse grid to the next fine grid level. This is called the prolongation process. Linear interpolation or any other interpolation scheme could be used to construct fine grid values from the coarse grid values. Using linear interpolation some sample values are

e′ 1 2h = (0.75e 1 4h )

e′ 2h = (0.75e 2 4h 1 + 0.25e 4h 2 )

e′ 3 2h = (0.25e 1 4h + 0.75e 2 4h )

and so on. It should be noted that we use a prime to indicate the prolonged error vec- tor e′ 2h on Grid 2 to distinguish it from the error vector e 2h . Furthermore, for the nodes closest to the boundary we have used the fact that the value of the problem variable is known so the error on the boundary is zero. The calcu-

lations of (7.41) yield the following values for the prolonged error vector e′ 2h : Ge′ 2h 1

2h J G17.556J He′ 2 K H31.514K

He′ 3 2h K H47.726K H.K =H . K H.KH.K H.KH.K

He′ 9 2h K H24.062K Ie′ 10 2h L I12.261L

The prolonged error vector e′ 2h is now used to correct the original error vec- tor e 2h (7.40) on Grid 2:

e 2h corrected =e 2h + e′ 2h (7.42) This yields

Ge 2h 1 2h J G 19.156J G17.556J G 36.713J He 2 K H 58.310K H31.514K H 89.825K

He 3 2h K H 96.049K H47.726K H143.775K H.K =H . K +H . K =H . K H.KH . KH.KH . K H.KH . KH.KH . K

He 9 2h 2h K H158.591K H24.062K H182.654K Ie 10 L I 55.351L I12.261L I 67.612L

At this stage it is usual to do some smoothing iterations before transferring this error vector to the grid above this level. First we perform two Gauss– Seidel smoothing iterations and obtain the following corrected and smoothed error vector on Grid 2:

Ge 2h 1 2h J G 32.639J He 2

K H 95.749K He K H152.494K

3 2h

H.K =H . K H.KH . K H.KH . K

He 9 2h K H188.283K Ie 10 2h L I 65.248L

238 CHAPTER 7 SOLUTION OF DISCRETISED EQUATIONS

This result is next used to compute the prolonged error vector e h on Grid 1 by linear interpolation using the process outlined in (7.41), but replacing superscripts 2h by h and 4h by 2h:

Ge h

1 h J G24.479J He 2 h K H48.416K He 3 K H79.971K

H.K

=H . K H.K H.K

H.K h H.K He 19 h K H96.007K Ie 20 L I48.936L

Step 4: Correction and final iterations

Finally, the prolonged error vector e h is used to compute the corrected inter-

mediate solution y on Grid 1:

=y+e corrected h

(7.43a)

Thus,

Gy 1 J G116.755J G24.479J G141.235J Hy 2 K H141.994K H48.416K H190.411K Hy 3 K H160.427K H79.971K H240.399K

H.K

=H . +H K

K H.KH (7.43b) . KH.K H. K

=H

H.KH . KH.K H. K Hy 19 K H394.392K H96.007K H490.399K Iy 20 L I468.130L I48.936L I517.067L

Comparison of the corrected solution (7.43b) with intermediate solution (7.38) and the TDMA solution in Table 7.14 shows that the multigrid pro- cedure has considerably reduced the error. Substitution of the corrected solution into r = b − A . y gives an r.m.s. residual of 8.786, which is lower than the previous r.m.s. residual on Grid 1, which was 14.951. Since inter- polation errors are involved in the restriction and prolongation processes we cannot expect to achieve the true solution in one multigrid cycle. In order to improve the solution further we do more iterations on the fine mesh (say two) and repeat the ‘fine grid–coarse grid’ procedure until convergence is achieved. We proceed by using the three-grid procedure and go backwards and forwards as many times as is needed to reduce the r.m.s. residual to

10 −6 . This multigrid cycle is called a three-grid V-cycle. The process steps are illustrated in Figure 7.8 along with annotations of the number of itera- tions at each level inside the circles. The diagram also reveals the origin of the term ‘V-cycle’.

Figure 7.8 Schematic of the V- cycle multigrid procedure used in the example

7.7 MULTIGRID TECHNIQUES

The pattern of convergence achieved by repeating the V-cycle of 2 fine grid iterations, 10 and 10 coarse grid iterations is shown in Figure 7.9. The multigrid procedure is fast and effective, since it converges in 60 fine grid iterations, which compares favourably with the ordinary Gauss–Seidel method, which takes 664 iterations to achieve the same residual value. Even after allowing for extra computational effort due to the coarse grid iterations, the order-of-magnitude improvement of the convergence rate by the multi- grid procedure is clearly beneficial. When multigrid acceleration techniques are applied to 2D and 3D problems the convergence gains obtained are very attractive, which explains their popularity among CFD users.

Figure 7.9 Residual reduction pattern with ordinary Gauss–Seidel iterations and multigrid Gauss–Seidel iterations