In Matrix Form: Solution of Systems of Algebraic Equations in CFD
In Matrix Form: Solution of Systems of Algebraic Equations in CFD
S + W 4P + E + N = h 2QP
We have 9 unknowns.
-4 1
1 0
0 1 0
0 0 1 0
0 0 0 1 0
0 0 0 0 1 0
0 0 0 0 0 1 0
1 -4 1
0 1 -4 0
=0
Ai,j=
1 0 0 1 0 0 0 0 0 0 0 0
0 -4 1 0 1 0 0 0 0 1 0 0
1 -4 1 0 1 0
1 -4 0 0 1
0 -4 1 0
1 -4 1 1 -4
Ai , j i = Qi
The number of unknowns for 101x101 mesh N=104, therefore the number of elements of matrix A is 108.
As efficient as any other method for a general case, but it does not make use of the favorable characteristics of the matrix. 1-st step Elimination: A21/A11 times the first row is subtracted from the second row. A1,1 A1,2 A1,3 The first element of the second row Repeated for every further will become 0. Similarly, we A2 ,1 A2 ,2 A2 ,3 eliminate the other elements of the rows.
Gauss elimination
A 3,1
A3,2
A3,3
P = f
n =
Qn U nn
Qi
U k ,i k
k = k +1
i =
U i ,i
The operation cost of the method is N3/3, out of which the back substitution requires only N2/2 operations. Even if A is sparse U is not spares. The total memory requirement on a 2D mesh of 101x101 nodes is 400 Mb. We dont need such an accurate solution because the discretization error is large anyway.
A simple 2D example
The computational domain:
Iterative methods
The solution is refined step by step: approximation of in the n-th step is n. By omitting the vector notations:
2 x
2
2 y
N
2
A n = Q n
n : residual
=Q
The error:
A = A
Iterative methods:
) = Q (Q ) =
n
P S
M n +1 = N n + Q
n +1 = n =
, therefore:
A=M N
1 E P P W 1 N P P S + x x y y y
= QP
Lets subtract M
On isotropic mesh:
x = y = h
S + W 4P + E + N = h 2QP
Jacobi iteration
n n n n n S + W 4P+1 + E + N = h 2QP
n P +1 =
Multigrid method
The correction equation for a simplified 1D problem:
M is a diagonal matrix.
1 n n n n S + W + E + N h 2QP 4
)
1
2 x2
=Q
Example program: - The program... - Major characteristics of the result... - Required number of iterations ...
x 2
1
(i 1 2i + i+1 ) = Qi
+ in 1 = Qi in + + in 1 = in +
=0
x 2
(
1
n n i 1 2i
x 2
n n i 1 2 i
Gauss-Seidel relaxation
N W P S E These terms are already known due to the calculation sequence
n P +1 = n n n n n S + W+1 4P+1 + E + N+1 = h 2QP
x 2
i 1 2 i
+ i +1 = i
M is a matrix.
- It requires halve as much iterations - and halve as much memory. - The error is asymmetrically distributed.
x 2 2
PROLONGATION
X 2
I 1
2 I + I +1 = I
RESTRICTION
Line relaxation
N W P S E these values are known these obtained line by line from the tri-diagonal system solved by the Thomas algorithm.
n n n n n S + W+1 4P +1 + E+1 + N+1 = h 2QP
Generalization to 2D or 3D:
Restriction: Prolongation:
1. Restriction: i I 2. Calculation of I . Eg. in 3D we have an 8 fold reduced number of unknowns. 3. Prolongation of I to the fine mesh. (i), 4. Smoothing on the fine mesh. Why shouldnt we use an even more coarse mesh when calculating I ? 1. 2. 3. 4. Evaluation of the residuals on the finest mesh. Consecutive restrictions of to every coarser mesh. Solution of the system on the coarsest mesh. (Even by using a direct method.) Consecutively for every finer mesh: - Prolongation of - Smoothing (Eg. by using Gauss-Seidel relaxation.) 5. Correction of . (Only on the finest mesh).
Note - Much more efficient methods based on the tri-diagonal solver also exist: Operator Splitting (or Alternating Direction Implicit, ADI) methods. The problem: The above mentioned methods are only smoothing the solution. The boundary effects need a very long time to penetrate the computational domain. Solution: We need to use coarser meshes too. The first estimates of the correction can be obtained on a coarser mesh, than can be refined on the fine mesh.
Computational cost
Number of iterations in 2D:
p 3 4 5 6 7 Nline 7 15 31 63 127 N 49 225 961 3969 16129 Jacobi 40 160 640 2560 10240 G-S 20 80 320 1280 5120 Line rlx. 10 40 160 640 2560 Multigrid 13 33 59 75 79
Mveletigny / N:
p 3 4 5 6 7 Nline 7 15 31 63 127 N 49 225 961 3969 16129 Jacobi 200 800 3200 12800 51200 G-S 100 400 1600 6400 25600 Line rlx. 50 200 800 3200 12800 Multigrid 260 660 1180 1500 1580