Professional Documents
Culture Documents
http://www.nd.edu/~gtryggva/CFD-Course/ http://www.nd.edu/~gtryggva/CFD-Course/
Grétar Tryggvason
∇4 f = 0 Biharmonic equation
i-1 i i+1
Methods
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 n n 2
Jacobi
4
∂2 f ∂2 f
+ =0 40
∂x 2 ∂y 2 35
f=0.0
Example Average absolute error:
0.001
30
Number of iterations 25
Jacobi: 1989 20
Gauss-Seidler: 986
15
In large computer application (vector or parallel platform), Line Relaxation Method (Line Gauss-Seidel Method)
SOR faces difficulties in using constantly updated values. Old
, j − fi , j
fi n+1 fi n+1, j + fi n−1, j + f i,nj −1 + fi,nj +1 − 4 fi,nj
n
=
Δt
2
h
Computational Fluid Dynamics Computational Fluid Dynamics
Boundary Value Problems
or
While iterative methods can sometimes be viewed as
⎛ Δt ⎞ n
, j = fi , j + ⎝ 2 ⎠ ( fi +1, j + fi −1, j + f i, j −1 + fi, j +1 − 4 fi, j )
fi n+1 n n n n n
integration in time, the fact that we are only interested in
h the “steady-state” solution allows us to take “short
Rearrange: cuts” to get there as fast as possible.
⎛ Δt ⎞ n ⎛ Δt ⎞ n
, j = ⎝ 1− 4 2 ⎠ fi , j + ⎝ 2 ⎠ ( fi +1, j + fi −1, j + fi, j −1 + fi, j +1 )
fi n+1 n n n
h h Optimal path
Δt 1
Select the maximum time step: 2 = Initial guess
h 4
fi , j = ( fi+1, j + fi −1, j + fi , j −1 + fi, j +1)
n+1 1 n n n n
Solution
4
“time accurate” solution
Which is exactly the Jacobi iteration
a ≤1
xn for convergence
The above figure suggests that
dF
≤1 for convergence
dx
Computational Fluid Dynamics Computational Fluid Dynamics
Convergence Convergence
for convergence
∂f ⎛ ∂2 f ⎞
Basic Idea Analytic Solution of = α ⎜⎜ 2 − g ⎟⎟
∂t ⎝ ∂x ⎠
Suppose we want to solve a 1-D elliptic equation The equation can be solved by Fourier series
∂2 f f = ∑ ak (t )eikx
−g =0
∂x 2 k
Therefore, ak (t → ∞) = bk
kL=2π
⎛ 1 ⎞
Rate of convergence ~ αk ⎜τ c = 2 ⎟
2
⎝ αk ⎠ 1 N
kH=2πN
High wave number modes damps out faster.
εH
= exp(− nπ 2 N 2 h 2 ) for k H = 2πN
ε0
Short-wave errors
εL
= exp(− nπ 2 h 2 ) for k L = 2π decay much faster
ε0
Example
d2 f
= −g
dx 2
Approximate by finite differences
1D Example f i+1 + f i−1 − 2 f i
= −gi Ri = h 2 gi
h2
Solve for fi
On the coarser grid the correction is the unknown, but the This approach can be generalized so that we solve for the
second derivative of the approximate solution found on correction to the correction on even coarser grids.
the finer grid is known
Introduce
j Δf j
x i = f i , x j = Δf j , x k = ΔΔf k ,…
i fi
Where the x refers to f or the various corrections,
depending on which grid we are working on
The discretization is therefore:
2
[
Δf j = Δf j+1 + Δf j −1 + 4(h gj + fi+1 + fi −1 − 2 fi )
1 2
] Δx j =
1
[
Δx j +1 + Δx j−1 + 4 (2 m h 2 g j + x i+1 + x i−1 − 2x i ) ]
2
1
[ ]
or
Δf j = Δf j+1 + Δf j −1 + R j or
[Δx j +1 + Δx j−1 + R j ]
1
2 Δx j =
where 2
Rj = 4(h2 gj + fi +1 + fi −1 − 2 fi )
where
R j = 4 (2 m h 2 g j + x i+1 + x i−1 − 2x i )
j Δf j j Δx j
i fi i xi
xi = xi + Δx j k=6
n=2**k
it=4
i=l
60 i=i+1
s=0.5*(f(i-1)+f(i+1)+r(i))
110 f(i)=f(i)+f(j)
f(i+1)=f(i+1)+0.5*(f(j)+f(j+1))
i=i-2
t=0.0001 d1=d1+abs(s-f(i)) j=j-1
when grid points overlap Transferring u=0.7 f(i)=s if(j .gt. l)go to 110
c--------------------------- if(i .lt. ll) goto 60 n=n+n
xi +1 = x i +1 + 0.5(Δx j + Δx j +1 )
the source c input right side
c---------------------------
write(*,*)' DIFF: ',d1
if(j .lt. it) goto 50 &
write(*,*)' NUMBER OF MESH
INTERVALS: ',n
term to the 10
do 10 i=1,n
r(i)=1.0
if(d1 .lt. t) goto 100
if((d1/d0) .lt. u) goto 50
ll=l-2
l=i
if(n .eq. 2) goto 50
coarser grid c---------------------------
c initialize c---------------------------
f(i+1)=f(i+1)+0.5*f(j+1)
go to 40
when grid points do not overlap c---------------------------
s=(1.0/n)**2
c coarse mesh---slow convergence
c---------------------------
c---------------------------
c print answer
do 20 i=1,n i=ll+2 c---------------------------
20 r(i)=s*r(i) 80 l=l+2 120 m=n+1
m=n i=i+1 do 130 i=1,m
l=1 if(l .gt. ll)goto 90 j=i-1
ll=n f(i)=0.0 s=j/float(n)
j nl=n+n+k-2 r(i)=4.0*(r(l)+f(l-1)-2*f(l)+f(l+1)) 130 write(*,*)j,s,f(i)
do 30 i=1,nl go to 80 end
30 f(i)=0.0 90 n=n/2
d1=0.0 write(*,*)' NUMBER OF MESH
40 j=0 & INTERVALS: ',n
i ll=ll+n+1
l=l+1
go to 40
2D Example
DIFF: .0449317507 DIFF: .00047971122 13 .203125 .0808705986 45 .703125 .104452103
DIFF: .042871654 DIFF: .000185795128 14 .21875 .0853876173 46 .71875 .101157524
NUMBER OF MESH INTERVALS: 8 DIFF: .000103279948 15 .234375 .0896620676 47 .734375 .0976193547
DIFF: .0743431076 DIFF: 9.19029117E-05 16 .25 .0936919153 48 .75 .0938355625
DIFF: .0642947108 NUMBER OF MESH INTERVALS: 32 17 .265625 .0974791124 49 .765625 .0898081064
DIFF: .0558491573 DIFF: .00879248697 18 .28125 .101021625 50 .78125 .0855348781
DIFF: .0485739484 DIFF: .00288156606 19 .296875 .10432145 51 .796875 .0810178071
NUMBER OF MESH INTERVALS: 4 DIFF: .000945105217 20 .3125 .107376538 52 .8125 .0762547851
DIFF: .0656985492 DIFF: .000314788893 21 .328125 .110188864 53 .828125 .0712477341
DIFF: .0391116515 DIFF: .000117543153 22 .34375 .112756386 54 .84375 .0659945831
DIFF: .0212108791 DIFF: 6.65616244E-05 23 .359375 .115081109 55 .859375 .0604973249
DIFF: .0106054395 NUMBER OF MESH INTERVALS: 64 24 .375 .117160991 56 .875 .0547549129
DIFF: .00530272722 DIFF: .00484465947 25 .390625 .118997991 57 .890625 .0487679914
DIFF: .00265136361 DIFF: .00160129415 26 .40625 .120590076 58 .90625 .0425367951
DIFF: .00132568181 DIFF: .000529795885 27 .421875 .121939234 59 .921875 .0360607132
DIFF: .000662840903 DIFF: .000176671892 28 .4375 .123043418 60 .9375 .0293390807
DIFF: .000331416726 DIFF: 6.28554262E-05 29 .453125 .123904586 61 .953125 .0223717391
DIFF: .000165700912 0 0. 0. 30 .46875 .124520674 62 .96875 .0151590388
DIFF: 8.28504562E-05 31 .484375 .124893673 63 .984375 .00770158973
32 .5 .125021532 64 1. 0.
Computational Fluid Dynamics Computational Fluid Dynamics
Multigrid Methods Multigrid Methods
Define Steps:
f i , j = f i ,nj + Δf i , j Fine grid solution
fi, j Converged solution è Interpolation onto coarse grid (restriction)
è Coarse grid correction
f i ,nj Solution after n-th iteration
è Interpolated onto fine grid (prolongation)
Δf i , j Correction è Converge on fine grid
(prolongation) f i , j = f i ,nj + Δf i , j Δf i , j − 2
1
4
(
= Δfi, j + Δfi + 2, j + Δfi, j + 2 + Δfi + 2, j + 2 )
6. Go to 1.
∂ ∂f ∂ ∂f
a(x, y) + b(x, y) = S
∂x ∂x ∂y ∂y
non-separable
( kl + jm ) ⎛ i l ⎞
N N 2π 2π 2π 2π 2π
Δf k, j ≡ ∑ ∑ fˆl,m e N
l=1 i −i l i m −i m
⎜e N + e N + e N + e N − 4 ⎟
Can be evaluated in 2N log2N operations l=1 m=1 ⎝ ⎠
⎛ 2π 2π ⎞
The Cooley-Tukey algorithm ⎜⎝ 2cos N l + 2cos N m − 4⎟⎠
Have
2π
2π 2π ⎞ The algorithm is
N N
( kl + jm ) ⎛
Δfk, j = −2∑ ∑ f̂l, m e
i
⎜⎝ 2 − cos l + cos m⎟
N
N N ⎠ 1 Find bˆl,m by FFT
l =1 m =1
but Δf k, j = bk, j
−b̂l, m
Solve: f̂l, m =
⎛ 2π 2π ⎞
2 ⎜ 2 − cos l + cos m⎟
⎝ N N ⎠
Computational Fluid Dynamics Computational Fluid Dynamics