You are on page 1of 12

Computational Fluid Dynamics I

Computational Fluid Dynamics I



http://users.wpi.edu/~gretar/me612.html!

Numerical Methods! Examples of elliptic equations!


Direct Methods for 1D problems!
for! Elementary Iterative Methods!
Iteration as Time Integration!
Elliptic Equations-I! Example!
Boundary Conditions!
Convergence of Iterative Methods!
!1D Example!
Grétar Tryggvason! !Formal Discussion!
Spring 2010!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Elliptic equations often arise due to the application of One-Dimensional Boundary Value Problems!
conservation principles to quantities whose fluxes are
proportional to their gradient! ∂ ∂f ∂f

a + b + cf = s
∂f ∂x ∂x ∂x
F = −S where the flux is given by! F = −α
∂x ∂x
∂ ∂f
gives! α =S
∂x ∂x ∂f ∂f
or f given or f given
∂x ∂x
In 2 or 3 dimension:! If the transport periodic!
coefficient is constant:!
∇ ⋅ F = −S ⎫
⎬ ⇒ ∇ ⋅ α∇f = S Notice that if f is not given on the boundary, f is not
F = −α∇f ⎪⎭ α∇ 2 f = S uniquely determined!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Two-Dimensional!
∂2 f ∂2 f Laplaceʼs Equation! Three-Dimensional!
+ = 0; ∇ 2 f = 0
∂x 2 ∂y 2 ∂2 f ∂ 2 f ∂ 2 f
+ + =0 Laplaceʼs Equation!
∂ f ∂ f
2 2 ∂x 2 ∂y 2 ∂z2
+ = S; ∇2 f = S Poissonʼs Equation!
∂x 2 ∂y 2 ∂2 f ∂ 2 f ∂ 2 f
∂ ∂f ∂ ∂ f + + =s Poissonʼs Equation!
a + b = S; ∇ ⋅ φ∇f = S ∂x 2 ∂y 2 ∂z2
∂x ∂x ∂y ∂ y
∂ ∂f ∂ ∂f ∂ ∂f
f = f 0 ( x, y ) Dirichlet! a + b + c =s
On the ∂x ∂x ∂y ∂y ∂z ∂z
∂f
boundaries (BC)! = g 0 ( x, y ) Neumann!
∂n
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Examples of Elliptic Equations!


q
∇ 2T = − Steady conduction equation!
k
One-Dimensional
∇ 2ψ = −ω 2-D stream function equation!
Boundary Value Problems
1
∇ 2h Pi , j =
Δt
∇ h ⋅ u ti , j Projection method!
(Step 2)!
—Direct Methods!
u ⋅ ∇f − ∇ 2 f = 0 Steady state !
advection/diffusion!

∇4 f = 0 Biharmonic equation!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

One-Dimensional Boundary Value Problems! One-Dimensional Boundary Value Problems!

a j f j −1 − d j f j + c j f j +1 = b j
∂f ∂2 f
U −D 2 =0
∂x ∂x Write out!

f −f f − 2 f i + f i−1 d1 f1 + c1 f 2 = b1
U i+1 i−1 − D i+1 =0 a2 f1 + d2 f 2 + c 2 f 3 = b2
2h h2
R 
( f i+1 − f i−1) − ( f i+1 − 2 f i + f i−1 ) = 0
2 R=
Uh aN −1 f N −2 + dN −1 f N −1 + c N −1 f N = bN −1
⎛ 1 ⎞ ⎛ 1 ⎞ D aN f N −1 + dN f N = bN
⎜1+ R⎟ f i−1 − 2 f i + ⎜1− R⎟ f i+1 = 0
⎝ 2 ⎠ ⎝ 2 ⎠
If the endpoints b1 = −a1 f 0
a j−1 f j−1 − d j f j + c j +1 f j +1 = b j are given!
bN = −c N f N +1

Computational Fluid Dynamics I


Computational Fluid Dynamics I

One-Dimensional Boundary Value Problems! One-Dimensional Boundary Value Problems!
% solving a tridiagonal system
nx=50;r=0.1; Matlab functions!
a=zeros(nx,1)+(1+r);d=zeros(nx,1)-2;c=zeros(nx,1)+(1-r);
b=zeros(nx,1); x=zeros(nx,1); b(nx)=-(1-r);

% forward elimination For simple problems MATLAB


for j=2:nx has a number of functions to
d(j)=d(j)-(a(j)/d(j-1))*c(j-1); deal with matrices.!
b(j)=b(j)-(a(j)/d(j-1))*b(j-1);
x(j)=b(j)/d(j); Help matfun: general!
end
Help sparfun:sparse matrices

% backward substitution
for j=nx-1:-1:1
x(j)=(b(j)-c(j)*x(j+1))/d(j);
end

plot(x)
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Solving the Poisson equation! (x, y)


j+1

∂2 f ∂2 f j

+ =S
Elementary Iterative ∂x 2 ∂y 2 j-1

i-1 i i+1

Methods! Applying central differencing!
f i +1, j − 2 f i , j + f i −1, j f i , j +1 − 2 f i , j + f i , j −1
+ = Si , j
Δx 2 Δy 2

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Iterative Method!

Discretized Poisson Equation! The Jacobi iteration can be improved somewhat by


f i +1, j + f i −1, j + f i , j +1 + f i , j −1 − 4 f i , j = h 2 Si , j using new values as soon as they become available.!

Rearranging for ! f i , j j+1! for j=1:m


f i, j = [ f i+1, j + f i−1, j + f i, j +1 + f i, j−1 − h 2 Si, j ]
1 j! for i=1:n
4 iterate
j-1! end
end
[ f i+1, j + f i−1,n j + f i,nj +1 + f i,nj−1 − h 2Si, j ]
1 n i-1! i! i+1!
f i,nj+1 = Jacobi !
4
1 n
f i,nj+1 = ( f i+1, n +1 n +1
j + f i−1, j + f i, j +1 + f i, j−1 − h S i, j )
n 2

[ f i+1, j + f i−1,n +1j + f i,nj +1 + f i,nj−1+1 − h 2Si, j ]


1 n
f i,nj+1 = Gauss-Seidel ! 4
4
From a programming point of view, Gauss-Seidler
β n
f i,nj+1 =
4
[ f i+1, j + f i−1,n +1j + f i,nj +1 + f i,nj−1+1 − h 2Si, j ] + (1− β ) f i,nj SOR ! iteration is even simpler than Jacobi iteration since only
one vector with f values is needed.!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

The Gauss-Seidler iteration can be accelerated even


further by various acceleration techniques. The
The iteration must be carried out until the solution is
simplest one is the Successive Over-Relaxation (SOR)
sufficiently accurate. To measure the error, define the
iteration!
residual:!
β n
f i,nj+1 = n +1
( f i+1, j + f i−1, n +1
j + f i, j +1 + f i, j−1 − h S i, j )
n 2 n
f i+1, j + f i−1, j + f i, j−1 + f i, j +1 − 4 f i, j
4 Ri, j = − Si, j
h2
+ (1− β ) f i,nj At steady-state the residual should be zero. The point-
wise residual or the average absolute residual can be
The SOR iteration is very simple to program, just as the used, depending on the problem. Often, simpler criteria,
Gauss-Seidler iteration. The user must select the such as the change from one iteration to the next is
coefficient. It must be bounded by 1<β<2. β=1.5 is used!
usually a good starting value.!
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Boundary Value Problems!

Jacobi as a time integration!


The solution of: !
∂2 f ∂ 2 f
+ =0
Iteration versus time ∂x 2 ∂y 2
can be thought of as the steady-state solution of !
integration! ∂f ∂ 2 f ∂ 2 f
= +
∂t ∂x 2 ∂y 2
Using the discretization derived earlier: !

fi , j − fi , j fi +1, j + fi −1, j + f i, j −1 + fi, j +1 − 4 fi, j


n+1 n n n n n n

=
Δt h2

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Boundary Value Problems!

or !
⎛ Δt
fi , j = fi , j + ⎝ 2 ⎞⎠ ( fi +1, j + fi −1, j + f i, j −1 + fi, j +1 − 4 fi, j )
n+1 n n n n n n

h
Rearrange:! Example!
⎛ Δt n ⎛ Δt
= ⎝ 1− 4 2 ⎞⎠ fi , j + ⎝ 2 ⎞⎠ ( fi +1, j + fi −1, j + fi, j −1 + fi, j +1)
n+1 n n n n
fi,j
h h
Δt 1
Select the maximum time step:! =
h2 4
fi , j =
n+1
( f + f n + f n + fn )
1 n
4 i+1, j i −1, j i , j −1 i, j +1
Which is exactly the Jacobi iteration!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

% two-dimensional steady-state problem by SOR


40
n=40;m=40;nstep=5000;alpha=0.05;length=2.0;h=length/(n-1);
∂2 f ∂2 f T=zeros(n,m);bb=1.7;
+ =0 35
T(10:n-10,1)=1.0;
∂x 2 ∂y 2 for l=1:nstep,
30 for i=2:n-1, for j=2:m-1
T(i,j)=bb*0.25*(T(i+1,j)+...
25 T(i,j+1)+T(i-1,j)+T(i,j-1))+(1.0-bb)*T(i,j);
T=1.0! end,end
20 T=0.0! % find residual
res=0;
15 for i=2:n-1, for j=2:m-1
res=res+abs(T(i+1,j)+...
10 T(i,j+1)+T(i-1,j)+T(i,j-1)-4*T(i,j))/h^2;
end,end
5 l,res/((m-2)*(n-2)) % Print iteration and residual
if (res/((m-2)*(n-2)) < 0.001), break,end
5 10 15 20 25 30 35 40 end;
contour(T);
Computational Fluid Dynamics I
Computational Fluid Dynamics I

40

35

Average absolute error: 0.001!


!Number of iterations! 30

Jacobi: ! 1989! 25
Gauss-Seidler: 986!
20

SOR (1.5): ! 320! 15


SOR (1.7): ! 162!
SOR (1.9): ! 91! 10

SOR (1.95): 202!


5

5 10 15 20 25 30 35 40

Computational Fluid Dynamics I


Computational Fluid Dynamics I

1 Note on Boundary
0.8

0.6
Conditions!
0.4

0.2

0
40

30 40
30
20
20
10
10
0 0

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Boundary Conditions for Iterative Method!

Dirichlet conditions are easily implemented.!


For Neumann condition, the simplest approach is !
With only a few exceptions, Iterative Methods
∂f
= 0 ⇒ f i , 0 − f i ,1 = 0 (1st order)! are used to solve systems of equations
∂n resulting from the discretization of elliptic
Update interior points f i ,1 , f i , 2 , f i ,3 ,  and then set! f i , 0 = f i ,1 equations or implicit methods in CFD!

This generally does not converge.!


Instead, incorporate BC directly into the equations!
= f i ,1
[ f i−1,1 + f i+1,1 + f i,2 + f i,0 − h 2Si, j ]
1
f i,1 =
4
f i,1 = [ f i−1,1 + f i+1,1 + f i,2 − h 2 Si, j ]
1
3
Computational Fluid Dynamics I
Computational Fluid Dynamics I

http://users.wpi.edu/~gretar/me612.html! Outline!

Examples of elliptic equations!


Numerical Methods! Direct Methods for 1D problems!

for! Elementary Iterative Methods!


Iteration as Time Integration!
Elliptic Equations-II! Example!
Boundary Conditions!
Convergence of Iterative Methods!
!1D Example!
!Formal Discussion!
Grétar Tryggvason!
Spring 2010!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Convergence!

A One Dimensional Example!


An equation in the form!
x = F (x)
Convergence of can be solved by iterative procedure:!
Iterative Methods! x n +1 = F ( x n )
for which convergence is achieved when !
x n +1
x n +1 ≈ x n or! −1 < ε
xn

When does the iteration converge?!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Convergence! Convergence!
dF
>1 A One Dimensional Example!
x n +1 dx
dF
<1 For the linear equation!
dx
x n +1 = ax n
x = F (x) We must have:!

a ≤1

xn for convergence!
The above figure suggests that!
dF
≤1 for convergence!
dx
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Convergence! Convergence!

For multidimensional problems we have:! Hence it is possible to write !


x α +1 = Mx α x α +1 = Mx α
as!
For symmetric M it can be shown that its
eigenvectors form a complete and orthogonal y1α +1v1 + y α2 +1v 2 +  = M( y1α v1 + y α2 v 2 + )
set and span the space of x. It is therefore
possible to write: ! = y1α Mv1 + y α2 Mv 2 + 

x = y1v1 + y 2 v 2 +  = ∑ y j v j = y1α λ1v1 + y α2 λ2 v 2 + 


j or!
where! y1α +1 = λ1 y1α Which are the same as for the
1-D example. Therefore:!
α +1 α
y =λ y λmax ≤ 1
Mv j = λ j v j j = 1… M × N 2 2 2

  for convergence!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

If !Δx = Δy = h ⇒ f i +1, j + f i −1, j + f i , j +1 + f i , j −1 − 4 f i , j = h S i , j


2

⎡− 4 1 0 0  1 0    ⎤ ⎡ f1,1 ⎤ ⎡ S1,1 ⎤
⎢ 1 − 4 1 0  0 1    ⎥⎢ f ⎥ ⎢S ⎥
⎢ ⎥ ⎢ 1, 2 ⎥ ⎢ 1, 2 ⎥
More Formal ⎢0

1 − 4 1   0 1   ⎥⎢  ⎥
⎥⎢ ⎥
⎢  ⎥
⎢ ⎥
⎢  ⎥ ⎢ f1, J ⎥ ⎢ S1, J ⎥
Discussion of ⎢ 

⎥ ⎢ f 2,1 ⎥
⎥⎢
⎢ S 2,1 ⎥
⎥ = h2 ⎢ ⎥
⎢1 0 ⎥ ⎢ f 2, 2 ⎥ ⎢ S 2, 2 ⎥
Iterative Methods! ⎢0

⎢0
1
0 1
⎥⎢  ⎥
⎥⎢
⎥⎢  ⎥

⎢  ⎥

⎢  ⎥

⎢ ⎥⎢ f ⎥ ⎢S ⎥
⎢ ⎥ ⎢ I , J −1 ⎥ ⎢ I , J −1 ⎥
⎣⎢ 0 1 − 4⎦⎥ ⎣⎢ f I , J ⎦⎥ ⎣⎢ S I , J ⎦⎥

Sparse matrix: only 5 non-zero entries in each row!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

A few definitions:! Ultimately, the difference form of the Poisson equation!


boils down to solving for!

⎡a 0 0 0⎤ ⎡0 a b c⎤ ⎡0 0 0 0⎤ [ A]f = b
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
0 b 0 0⎥ 0 0 d e⎥ a 0 0 0⎥
[D] = ⎢⎢ [U ] = ⎢⎢ [L] = ⎢⎢
Hence,!
f = [ A] b
−1
0 0 c 0⎥ 0 0 0 f⎥ b c 0 0⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣0 0 0 d⎦ ⎣0 0 0 0⎦ ⎣d e f 0⎦
Direct method:!
Upper - Solving inverse matrix directly (Cramerʼs rule)!
Diagonal! Lower!
triangular! - Inverting matrix more cleverly (Gaussian elimination)!
triangular!
- Other (L-U decomposition, Thomas algorithm)!
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Convergence – Multi Dimensional -1!

Gaussian Elimination! General iterative procedure!


-  Pivoting: rearranging equations to put the largest! [ A]f = b
coefficient on the main diagonal.!
-  Eliminate the column below main diagonal.! Let! [ A] = [ A1 ] − [ A2 ]
-  Repeat until the last equation is reached.! [ A1 ]f = [ A2 ]f + b
-  Back-substitution!
An iterative scheme is constructed as!
a11 f1 + a12 f 2 +  = c1 a11 f1 + a12 f 2 +  = c1
[ A1 ]f n +1 = [ A2 ]f n + b
a21 f1 + a22 f 2 +  = c2 ′ f 2 +  = c2
a22
   !

For example, !
1
an1 f1 + an 2 f 2 +  = cn ′ f n = cn
ann [ A1 ] = [D] = − [I ], [ A2 ] = [ B] = [ A1] − [ D] Jacobi !
4
[ A1 ] = [D] − [L], [ A2 ] = [U ] Gauss-Seidel !
-  Special case: tri-diagonal matrix - Thomas algorithm!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Convergence – Multi Dimensional -2! Convergence – Multi Dimensional -3!

[ A1 ]f n +1 = [ A2 ]f n + b Condition for convergence!


lim e n = 0
Requirements:! n →∞

1.  [ A1 ] should be invertible.! ( [ A2 ])


n
which requires! lim [ A1 ]
−1
=0
n →∞
2.  Iteration should converge, i.e.!
lim f n = f This is achieved if the modulus of the eigenvalues are !
n →∞ less than unity.!
Define error at n-th iteration:! e n = f − f n
Therefore, the convergence condition becomes:!
[ A1 ]e n +1 = [ A2 ]e n
ρ = λi max
≤1
e n +1 = [ A1 ] [ A2 ]e n
−1

ρ Spectral radius of convergence!


( [ A2 ])
n
e n = [ A1 ]
−1
e0 λi Eigenvalues of matrix![ A1 ]−1 [ A2 ]

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Convergence – Jacobi Method -1! Convergence – Jacobi Method -2!

Jacobi Iteration Method for Poisson Equation! For a large matrix!


!(2nd order central difference with uniform mesh)!
1⎡ π π⎤
f i,nj+1 = [ f i+1, j + f i−1, j + f i, j +1 + f i, j−1 − h S i, j ]
1 n λmn ,max = cos + cos ⎥ largest eigenvalues for!
2 ⎢⎣
n n n 2

4 M N⎦ m = 1, n = 1
1⎡π2 π2 ⎤
[ A1 ] = [ I]
−1
≅ 1− ⎢ 2 + 2 ⎥ +
4 ⎣M N ⎦
and using a discrete analog of separation of variables, !
it can be shown that the eigenvalues of [A2 ] are! Thus, for a large matrix, λmn ,max is only slightly less!
1⎡ mπ nπ ⎤ than unity.!
λmn = ⎢cos + cos , m = 1,  , M − 1, n = 1,  , N − 1
2⎣ M N ⎥⎦
 Very slow convergence!
Therefore, λmn ≤ 1 and the Jacobi method converges.!
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Convergence – Gauss-Seidel -1! Convergence – Gauss-Seidel -2!

Gauss-Seidel Iteration Method for Poisson Equation!


It can be shown that the eigenvalues of matrix! [ A1 ] [ A2 ]
−1

!(2nd order central difference with uniform mesh)!


are simply square of the eigenvalues of Jacobi method !
f i,nj+1 = [ f i+1, j + f i−1, j + f i, j +1 + f i, j−1 − h S i, j ]
1 n n +1 n n +1 2

4 2
1⎡ π π⎤
[ A1 ] = [D] − [L], [ A2 ] = [U ] λmn ,max = cos + cos ⎥
4 ⎢⎣ M N⎦

⎡4 0 0 0  0⎤⎡ f1,1n +1⎤ ⎡0 1 0  0⎤⎡ f1,1n ⎤


0 ⎡ S1,1 ⎤
⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ Thus, Gauss-Seidel method is twice as fast as the !
⎢−1 4 0 0  0⎥⎢ f1,2n +1⎥ ⎢0 0 0  0⎥⎢ f1,2n ⎥
1 ⎢ S1,2 ⎥ Jacobi method.!
⎢ 0 −1 4 0  0⎥⎢  ⎥ ⎢0 0 1  0⎥⎢  ⎥ 2 ⎢  ⎥
0
⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥− h ⎢ ⎥
⎢ 0 0 −1 4  0⎥⎢  ⎥ ⎢    ⎥⎢  ⎥ ⎢  ⎥
⎢     ⎥⎢  ⎥ ⎢  0  ⎥⎢  ⎥ ⎢  ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥
⎣0   0 −1 4⎦⎣ f In,J+1⎦ ⎣0 0 0 0  0⎦⎣ f Mn ,N ⎦ ⎣SM ,N ⎦
A1! A2!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Successive Overrelaxation - 1! Successive Overrelaxation - 2!

Successive Overrelaxation! Hence, SOR first uses Gauss-Seidel to compute !


~
intermediate solution, !f
Consider the Gauss-Seidel method!

([D] − [L])f n +1 = [U ]f n + b ([D] − [L])f˜ = [U ]f n + b or! [ D]f˜ = [ L]f˜ + [U ]f + b


n

Then accelerate the next iteration solution !


If Gauss-Seidel is an attempt to change the solution as!
f n +1
=f +d
n ( )
f n +1 = f n + β f − f n = β f + (1 − β ) f n
Combining the two steps !
Accelerate the change by introducing a parameter!
β
f n +1 = f n + β d, β > 1 f n +1 =
c
([L]f˜ + [U ]f n + b) + (1− β )f n
since ! [ D] = c [ I ]

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Successive Overrelaxation - 3! Successive Overrelaxation - 4!

Example: Poisson Equation (2nd order CD, uniform mesh) ! Convergence of SOR!
f i +1, j + f i −1, j + f i , j +1 + f i , j −1 − 4 f i , j = h 2 Si , j From! [D]f˜ = [ L]f˜ + [U ]f n + b
G-S! f n +1 = f n + β (f˜ − f n )
[D]f˜ = [ L]f˜ + [U ]f n + b
~ n +1
Eliminating f and solving for !f
[ f i−1, j + f i,nj−1+1 + f i+1,n j + f i,nj +1 − h 2Si, j ]
1 n +1
f i,nj+1 = [ M ] SOR
4

( [L]) {(1− β )[ I] + β [D] [U ]} f n


Combining! −1
β f n +1 = [ I ] − β [ D]
−1 −1
f n +1 =
c
([L]f˜ + [U ]f n + b) + (1− β )f n
(
[L]) β [D] b
−1
+ [ I ] − β [ D]
−1 −1
β
f n +1
= ⎡⎣ fi n−1,+1j + fi,nj+1−1 + fi n+1, j + fi,nj +1 − h 2 Si, j ⎤⎦ + (1 − β ) fi,nj
Convergence depends on the eigenvalues of! [ M ] SOR
i, j
4
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Successive Overrelaxation - 5! Successive Overrelaxation - 6!

For the discretized Poission operator, it can be shown that For problems with irregular geometry and non-uniform !
that eigenvalues of the SOR matrix are:! mesh, β opt must be found by trial and error.!
µ1/ 2 =
1
2
[λβ + λ2β 2 − 4 (β −1) ] Typical Comparison Chart !
where λ is an eigenvalue of the Jacobi matrix !
[ M ] J = [D] ([ L] + [U ])
−1
λmax (µ max ) Iterations!
Note that µ = λ
2
if β = 1 (Gauss-Seidel) ! Jacobi! 0.9945! 1250!
Gauss-Seidel! 0.9890! 625!
Minimum µ occurs at!
Typically!
2 SOR! 0.7906! 29!
β opt = β opt ≈ 1.7 ~ 1.9
1+ 1− λ 2
max Ferziger, J. H., Numerical Method for Engineering Application (1981)!
λmax ≈ 1

Computational Fluid Dynamics I


Computational Fluid Dynamics I

http://users.wpi.edu/~gretar/me612.html! Outline!

Examples of elliptic equations!


Numerical Methods! Direct Methods for 1D problems!

for! Elementary Iterative Methods!


Iteration as Time Integration!
Elliptic Equations-III! Example!
Boundary Conditions!
Convergence of Iterative Methods!
!1D Example!
!Formal Discussion!
Grétar Tryggvason!
Spring 2010! SOR on vector computers!

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Coloring Scheme (Red & Black)!

In large computer application (vector or parallel platform),!


SOR faces difficulties in using constantly updated values. !
Remedy: Two separate grid system (red & black)!
SOR on Vector do i =1, nx, 2!
β
f i, j = [ f i−1, j + f i, j−1 + f i+1, j + f i, j +1
Computers! 4
−h 2 Si, j ] + (1− β ) f i, j
enddo!
do i=2, nx, 2!
β
f i, j = [ f i−1, j + f i, j−1 + f i+1, j + f i, j +1
4
−h 2 Si, j ] + (1− β ) f i, j
enddo!
Computational Fluid Dynamics I
Computational Fluid Dynamics I

Successive Line Overrelaxation (SLOR) - 1! Successive Line Overrelaxation (SLOR) - 2!

Line Relaxation Method (Line Gauss-Seidel Method)!


SLOR = Line Relaxation + Overrelaxation!
Old!

[ f i−1, j + f i,nj−1+1 + f i+1,n j + f i,nj +1 − h 2Si, j ]


1 n +1
f i,nj+1 = Apply line relaxation for intermediate solution!
4 New! New! Old!
f i−1, j + f˜i, j − f˜i+1, j = [ f i,nj−1 + f i,nj +1 − h 2 Si, j ]
1 ˜ 1 1 +1

Adding one more coupling ! New! 4 4 4
f i,nj+1 = [ f i−1, j + f i, j−1 + f i+1, j + f i, j +1 − h S i, j ]
1 n +1 n +1 n +1 n 2
and then overrelax !
4 Old!
f i,nj+1 = β f˜i, j + (1− β ) f i,nj
f i+1, j = [ f i, j−1 + f i,nj +1 − h 2 Si, j ]
1 n +1 n +1 1 n +1 1 n +1
− f i−1, j + f i, j − New! New! New!
4 4 4 which is no more complicated than line relaxation. !
New!
 Thomas algorithm !

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Successive Line Overrelaxation (SLOR) - 3! Alternating-Direction Implicit - 1!

Notes on SLOR! ADI for elliptic equation is analogous to ADI in parabolic!


equation!
-  Exact eigenvalues are unknown.! ∂f ⎡ ∂2 f ∂2 f ⎤
=α⎢ 2 + 2 ⎥−S
-  To ensure convergence, !β ≤ 2 ∂t ⎣ ∂x ∂y ⎦
-  Converges approximately twice as fast as Gauss-Seidel.! In discrete form!
-  May be faster than pointwise SOR, but each iteration!
f i,nj+1 − f i,nj = αΔt [δxx f + δyy f ] + S
takes longer with Thomas algorithm.!
-  Improved convergence is due to the direct effect of the! and take it to the limit to obtain the steady solution.!
boundary condition in each row.!
⎛ ∂f ⎞
⎜ = 0⎟
⎝ ∂t ⎠

Computational Fluid Dynamics I


Computational Fluid Dynamics I

Alternating-Direction Implicit - 2! Alternating-Direction Implicit - 3!

Convergence of ADI!
ADI for! f i,nj+1 − f i,nj = αΔt [δxx f + δyy f ] − S
αΔt n
-  Iteration parameter ρ n = usually varies with iteration!
is written as! 2
-  For example (Wachspress)!
αΔt
f n +1/ 2 − f n = 2
2h
[( f n +1/ 2
i+1, j − 2 f i,nj+1/ 2 + f i−1,
n +1/ 2 n n n
]
j ) + ( f i, j +1 − 2 f i, j + f i, j−1 ) − S i,′ j
ρ k αΔt k
(k −1)/ (n −1)
⎛a⎞
= = b⎜ ⎟ , k = 1,  , n
αΔt
f n +1 − f n +1/ 2 = 2
2h
[( f n +1/ 2
i+1, j − 2 f i,nj+1/ 2 + f i−1,
n +1/ 2 n +1 n +1 n +1
]
j ) + ( f i, j +1 − 2 f i, j + f i, j−1 ) − S i,′′ j
h2 2h 2 ⎝b⎠
a lower bound eigenvalue!
or! b upper bound eigenvalue!
(1− ρnδxx ) f n +1/ 2 = (1+ ρnδyy ) f n − Si,′ j ⎛ αΔt n ⎞
⎜ ρn = ⎟ -  Comparison with SOR is difficult!
⎝ 2 ⎠
(1− ρ δ ) fn yy
n +1
= (1+ ρ nδxx ) f n +1/ 2
− Si,′′ j
-  ADI can be efficient if appropriate parameters are found.!
Computational Fluid Dynamics I

Although the iterative methods discussed here are


important for understanding iterative methods, they
are rarely used for practical applications due to their
slow convergence rate.!

The exception is the SOR method, which was widely


used in the 70ʼs and early 80ʼs. Due to its simplicity,
it is an excellent choice during code development or
for runs where programming time is of more concern
than computer time. !

You might also like