n4 Handout

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

University of Bath, School of Mechanical Engineering T7 C.F.D.

Numerical Methods 4

The Block TriDiagonal Matrix Algorithm (BTDMA)

The BTDMA is a matrix version of the TDMA, and therefore many of the details of its algorithm are
very similar to the TDMA. On the other hand, it is more complicated to encode and therefore I shall be
providing the appropriate subroutines for any assignments in which it is to be used.

Let us write the Finite Difference equations in the form:

B1 C1 Y1 R1
    
 A2 B2 C2  Y2   R2 
A3 B3 C3 Y3 R3
    
    
 .. .. ..  .. = .. .

 . . . 
 .
 
  .


 AM −1 BM −1 CM −1 Y
M −1
 R
M −1

AM BM YM RM

where A, B, and C now represent square matrices ( — 3×3 matrices for the problem we are considering),
and both Y and R are column vectors ( — 3×1 matrices).

1. Reduce to bidiagonal form

The first step is to reduce the matrix to block bidiagonal form by eliminating the subdiagonal blocks.

The A2 block is removed in two stages: first premultiply the row 1 by B1−1 and then subtract A2 × row 1
from the row 2. The first stage yields the system,

I C1∗ Y1 R1∗
    
 A2 B2 C2  Y2   R2 
A3 B3 C3 Y3 R3
    
    
 .. .. ..  .. = .. ,

 . . . 
 .
 
  .


 AM −1 BM −1 CM −1 Y
M −1
 R
M −1

AM BM YM RM

where B1 C1∗ = C1 and B1 R1∗ = R1 , or, in augmented matrix notation,

B1 × (C1∗ |R1∗ ) = (C1 |R1 );

here the matrices given in brackets are 3×4 (3 rows and 4 columns) for our example problem. The matrix
C1∗ and vector R1∗ are now obtained using a standard Gaussian elimination subroutine — this is generally
more efficient than computing B1−1 explicitly and then premultiplying C1 and R1 .

Now we can remove the A2 block by subtracting A2 × row 1 from row 2. Hence we obtain

I C1∗ Y1 R1∗
    
0 B2∗ C2  Y2   R2∗ 
A3 B3 C3 Y3 R3
    
    
 .. .. ..  .. = .. ,

 . . . 
 .
 
  .


 AM −1 BM −1 CM −1 Y
M −1
 R
M −1

AM BM YM RM

where B2∗ = B2 − A∗2 C1∗ and R2∗ = R2 − A∗2 R1∗ . Again, this form can be expressed using augmented matrix
notation:
(B2∗ |R2∗ ) = (B2 |R2 ) − A∗2 (C1∗ |R1∗ )

1
University of Bath, School of Mechanical Engineering T7 C.F.D. Numerical Methods 4

The two–stage elimination process is now used to remove the A3 block. We get
I C1∗ Y1 R1∗
    
0 I C2∗
  Y2   R2  ∗∗

0 B3 C3

  Y3   R3∗ 
    

A4 B4 C4   Y4  =  R4  ,
    

 .. .. ..  .   . 
. . .  .   . 
 .   . 


 AM −1 BM −1 CM −1   YM −1   RM −1 
AM BM YM RM
where B2 C2 = C2 , B2 R2 = R2 , B3 = B3 − A3 C2 and R3 = R3 − A3 R2 . In augmented matrix notation
∗ ∗ ∗ ∗∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗∗

this is expressed more simply as


B2∗ × (C2∗ |R2∗∗ ) = (C2 |R2∗ ) and (B3∗ |R3∗ ) = (B3 |R3 ) − A∗3 (C2∗ |R2∗∗ ),
where our objective is to obtain C2∗ , R2∗∗ , B3∗ and R3∗ , in that order.

The process of block subdiagonal elimination is continued until we obtain the block bidiagonal set of
equations,
I C1 Y1 R1
    
 I C2   Y2   R2 
I C3   Y3   R3 
    

.. .   ..  =  ..  ,
     

 . ..  .   . 
 I CM −1   YM −1   RM −1 
BM YM RM
where the superscript asterisks have been omitted.

2. Solution by back–substitution.

The values of Yi (i = 1, M ) are now computed by back–substitution. The last matrix row is equivalent to
the equation,
B M Y M = RM ,
which is solved using the Gaussian Elimination subroutine.

The penultimate row gives the equation


BM −1 YM −1 = RM −1 − CM −1 YM ,
where the right hand side is known. Again we use Gaussian Elimination to find YM −1 .

The (M − 2)nd row gives


BM −2 YM −2 = RM −2 − CM −2 YM −1 ,
to get YM −2 , and so on, until we eventually get to the equation,
B 1 Y 1 = R1 − C 1 Y 2 ,
for Y1 .

3. Writing a Fortran subroutine.

As for the TDMA development, we shall write the above algorithm in as compact a form as is possible.
Hence we obtain the following algorithm:
For i=2,M:
solve Bi × (Ci |Ri )new = (Ci |Ri )old
compute (Bi |Ri )new = (Bi |Ri )old − A∗i (Ci−1 |Ri−1 )
Solve: BM YM = RM to obtain YM
For i=M-1,1 solve:
Bi Yi = (Ri − Ci Yi+1 ) to obtain Yi

You might also like