You are on page 1of 13

Computational Fluid Dynamics Computational Fluid Dynamics

http://www.nd.edu/~gtryggva/CFD-Course/ http://www.nd.edu/~gtryggva/CFD-Course/

Computational Fluid Numerical Methods


Dynamics for
Lecture 13
Elliptic Equations-I
March 6, 2017

Grétar Tryggvason

Computational Fluid Dynamics Computational Fluid Dynamics

Examples of elliptic equations


Elliptic equations often arise due to the application of
Elementary Iterative Methods
conservation principles to quantities whose fluxes are
Note on Boundary Conditions proportional to their gradient
SOR on vector computers
∂ ∂f
Iteration as Time Integration F = −S where the flux is given by F = −α
∂x ∂x
Convergence of Iterative Methods—elementary considerations
Multigrid methods ∂ ∂f
gives α =S
Fast Direct Method ∂x ∂x
Convergence of Iterative Methods—Formal Discussion
In 2 or 3 dimension: If the transport
ADI for elliptic equations
coefficient is constant:
Krylov Methods ∇ ⋅ F = −S ⎫⎪
⎬ ⇒ ∇ ⋅ α∇f = S
Resources F = −α∇f ⎪ α∇ 2 f = S

Computational Fluid Dynamics Computational Fluid Dynamics

One-Dimensional Boundary Value Problems Two-Dimensional


∂2 f ∂2 f Laplace’s Equation
∂ ∂f ∂f + = 0; ∇ 2 f = 0
a + b + cf = s ∂x 2 ∂y 2
∂x ∂x ∂x
∂2 f ∂2 f
+ = S; ∇2 f = S Poisson’s Equation
∂x 2 ∂y 2
∂ ∂f ∂ ∂ f
∂f ∂f a + b = S; ∇ ⋅ φ∇f = S
∂x
or f given
∂x
or f given ∂x ∂x ∂y ∂ y
periodic f = f 0 ( x, y ) Dirichlet
On the
Notice that if f is not given on the boundary, f is not ∂f
boundaries (BC) = g 0 ( x, y ) Neumann
uniquely determined ∂n
Computational Fluid Dynamics Computational Fluid Dynamics

Examples of Elliptic Equations


Three-Dimensional q
∇ 2T = − Steady conduction equation
∂2 f ∂ 2 f ∂ 2 f k
+ + =0 Laplace’s Equation
∂x 2 ∂y 2 ∂z2
∇ 2ψ = −ω 2-D stream function equation
∂2 f ∂ 2 f ∂ 2 f
+ + =s Poisson’s Equation 1
∂x 2 ∂y 2 ∂z2 ∇ 2h Pi , j = ∇ h ⋅ u ti , j Projection method
Δt (Step 2)
∂ ∂f ∂ ∂f ∂ ∂f
a + b + c =s u ⋅ ∇f − ∇ 2 f = 0 Steady state
∂x ∂x ∂y ∂y ∂z ∂z advection/diffusion

∇4 f = 0 Biharmonic equation

Computational Fluid Dynamics Computational Fluid Dynamics

Solving the discrete Poisson equation


j+1
j (x, y)
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 j-1
Elementary Iterative Δx 2
Δy 2

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

[ 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
β 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

Computational Fluid Dynamics Computational Fluid Dynamics

The most elementary iteration can be accelerated


somewhat by Successive Over-Relaxation
The iteration must be carried out until the solution is
j+1 for j=1:m sufficiently accurate. To measure the error, define the
for i=1:n
j residual:
iterate
end
j-1 end f i+1, j + f i−1, j + f i, j−1 + f i, j +1 − 4 f i, j
i-1 i i+1 Ri, j = − Si, j
β n h2
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

4 At steady-state the residual should be zero. The point-


wise residual or the average absolute residual can be
+ (1− β ) f i,nj used, depending on the problem. Often, simpler criteria,
such as the change from one iteration to the next is
The SOR iteration is very simple to program, just as the Gauss-
Seidler iteration. The user must select the coefficient. It must be used
bounded by 1<β<2. β=1.5 is usually a good starting value.
Computational Fluid Dynamics Computational Fluid Dynamics

∂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

SOR (1.5): 320 f=1.0


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

SOR (1.95): 202


5 10 15 20 25 30 35 40

Computational Fluid Dynamics Computational Fluid Dynamics


Boundary Conditions for Iterative Method

Dirichlet conditions are easily implemented.


For Neumann condition, the simplest approach is
∂f
Note on Boundary ∂n
= 0 ⇒ f i , 0 − f i ,1 = 0 (1st order)

Conditions Update interior points f i ,1 , f i , 2 , f i ,3 ,  and then set f i , 0 = f i ,1


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 Computational Fluid Dynamics

With only a few exceptions, Iterative Methods


are used to solve systems of equations
resulting from the discretization of elliptic SOR on Vector
equations or implicit methods in CFD
Computers
Computational Fluid Dynamics Computational Fluid Dynamics
Coloring Scheme (Red & Black) Successive Line Overrelaxation (SLOR) - 1

In large computer application (vector or parallel platform), Line Relaxation Method (Line Gauss-Seidel Method)
SOR faces difficulties in using constantly updated values. 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
Remedy: Two separate grid system (red & black) f i,nj+1 =
4 New New Old
do i =1, nx, 2
β Adding one more coupling New
f i, j = [ f i−1, j + f i, j−1 + f i+1, j + f i, j +1
f i,nj+1 = [ f i−1, j + f i, j−1 + f i+1, j + f i, j +1 − h S i, j ]
4 1 n +1 n +1 n +1 n 2

−h 2 Si, j ] + (1− β ) f i, j 4 Old

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


enddo 1 n +1 n +1 1 n +1 1 n +1
do i=2, nx, 2 − f i−1, j + f i, j − New New New
4 4 4
β
f i, j = [ f i−1, j + f i, j−1 + f i+1, j + f i, j +1 New
4 è Thomas algorithm
−h 2 Si, j ] + (1− β ) f i, j
enddo

Computational Fluid Dynamics Computational Fluid Dynamics


Successive Line Overrelaxation (SLOR) - 2

SLOR = Line Relaxation + Overrelaxation


Although the iterative methods discussed here are
Apply line relaxation for intermediate solution important for understanding iterative methods, they
are rarely used for practical applications due to their
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
− slow convergence rate.
4 4 4
and then overrelax The exception is the SOR method, which was widely
used in the 70’s and early 80’s. Due to its simplicity,
f i,nj+1 = β f˜i, j + (1− β ) f i,nj
it is an excellent choice during code development or
which is no more complicated than line relaxation. for runs where programming time is of more concern
than computer time.

Computational Fluid Dynamics Computational Fluid Dynamics


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:

, 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

Computational Fluid Dynamics Computational Fluid Dynamics


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 Computational Fluid Dynamics


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 Computational Fluid Dynamics
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 Computational Fluid Dynamics


Multigrid Methods

So far we have covered elementary iterative methods to


solve elliptic equations. Of those the SOR method is the
most useful, particularly for code development and
Multigrid debugging.

Methods However, considerable effort has been devoted to the


solution of elliptic equations and currently there exist a
number of much more efficient methods. For codes
intended for large problems where runtime is important you
should use such a method

Multigrid methods are among the more popular ones

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods

∂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

and assume that g can be expanded as


An iterative process is analogous to solving an unsteady
problem g = ∑ bk k 2 eikx
k
∂f ⎛ ∂2 f ⎞
= α ⎜⎜ 2 − g ⎟⎟ Substituting into the equation,
∂t ⎝ ∂x ⎠ dak
And take it to the limit t → ∞
∑ dt e ikx = −α ∑ ( ak (t) − bk ) k 2e ikx
k k
Computational Fluid Dynamics Computational Fluid Dynamics
Multigrid Methods Multigrid Methods

Solving for each k For iterative method to solve elliptic equations,


dak there are high wave number and low wave number
= −αk 2 (ak (t ) − bk )
dt components of errors that need to be damped out.
ak (t) − bk = ( ak (0) − bk )e−αk (ε = ε0e−αk )
2 2
Consider a domain L = 1 discretized by N points
t t
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.

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods
This can also be visualized by following the decay of a
initial conditions composed of two waves For explicit time step, stability condition yields
f (x) = sin(2πx) + sin(10πx) αΔt 1 h2
= ; Δt =
h2 2 2α
If the error at various wave number decays at
2 nh 2
ε = ε 0 e −αk t where t = nΔt =

( )
è ε / ε 0 = exp − k 2 nh 2 / 2

ε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

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods
ε
Multigrid Method – the Idea
t=0
1 N - A low wave number component on a fine grid becomes
a high wave number component on a coarse grid
ε ε L / ε 0 = exp(− nπ 2 h 2 )
t = 5Δt
1 - Use a coarse grid system to converge low wave number
N
component of the solution rapidly
ε - Map it onto the fine grid system to converge high wave
number component.
t = 500Δt
1 N
Computational Fluid Dynamics Computational Fluid Dynamics
Multigrid Methods Multigrid Methods

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

( f i+1 + f i−1 + h 2gi ) = 2 ( f i+1 + f i−1 + Ri )


1 1
fi =
2

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods

Iterate until convergence is “slow” on a fine grid The decomposition


f j = f˜j + Δf j
f i = ( f i+1 + f i−1 + h 2 gi ) = ( f i+1 + f i−1 + Ri )
1 1
2 2 gives
giving an approximate solution (but not fully converged). d 2Δf d 2 f˜
Write the fully converged solution as the approximate + 2 = −g
solution plus a correction:
dx 2 dx
The correction is unknown, but the second derivative of
f = f˜ + Δf the approximate solution is known, along with the source.
Solve for the correction on a coarser grid
Substitute into
d2 f j Δf j
= −g fi
dx 2 i

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods

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:

Δf j +1 + Δf j−1 − 2Δf j f + f i−1 − 2 f i ΔΔf k


= − i+1 − gj k
4h 2 h2 j Δf j
Which can be solved iteratively as before i fi
Computational Fluid Dynamics Computational Fluid Dynamics
Multigrid Methods Multigrid Methods

On the j-grid, write:


This can be generalized to the coarser grids

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

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods
c 1D multigrid example from c--------------------------- c---------------------------
c MUDPACK c Gauss-Seidel Iteration c finer mesh---faster convergence
Once the correction has been found, the solution on c Solve f''(t)=-1, f(0)=f(1)=0 c--------------------------- c---------------------------
c--------------------------- 50 d0=d1 100 if(n .eq. m)goto 120
the finer grid can be corrected: real r(518),f(518),d0,d1,s,t,u d1=0.0 i=l-3
Integer i,it,j,k,l,ll,m,n,nl j=j+1 j=ll

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

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods
DIFF: .0151367188 NUMBER OF MESH INTERVALS: 8 1 .015625 .0076798778 33 .515625 .124906182
DIFF: .0148925781 DIFF: .0155412592 2 .03125 .0151156718 34 .53125 .124545574
DIFF: .0147094727 DIFF: .00427171588 3 .046875 .022309484 35 .546875 .12394169
DIFF: .0145568857 DIFF: .0011620149 4 .0625 .0292593613 36 .5625 .123092458
NUMBER OF MESH INTERVALS: 32 DIFF: .000314570963 5 .078125 .0359672531 37 .578125 .12199983
DIFF: .0283034556 DIFF: .000181354582 6 .09375 .04243109 38 .59375 .12066175
DIFF: .02759392 DIFF: .000105820596 7 .109375 .0486528128 39 .609375 .119080193
DIFF: .0269906037 DIFF: 5.63040376E-05 8 .125 .0546303391 40 .625 .11725311
DIFF: .0264589582 NUMBER OF MESH INTERVALS: 16 9 .140625 .06036558 41 .640625 .115182482
NUMBER OF MESH INTERVALS: 16 DIFF: .0141811594 10 .15625 .0658564717 42 .65625 .112866275
DIFF: .0499347299 DIFF: .00453080423 11 .171875 .0711049736 43 .671875 .110306486
DIFF: .0472503528 DIFF: .00144574605 12 .1875 .0761090368 44 .6875 .10750109

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

Suppose we are solving a Laplace equation: Since


Lf i , j = Lf i ,nj + LΔf i , j = 0
f i +1, j − 2 f i , j + f i −1, j f i , j +1 − 2 f i , j + f i , j −1
Lf i , j = + = Ri , j and
Δx 2 Δy 2 Lf i ,nj = Ri , j
and iterate until residual becomes smaller than tolerance we have
Ri , j → 0 LΔf i , j = − Ri , j Coarse grid correction

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

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods

Two-Level Multigrid Method - (nx+1, ny+1); (nx/2+1, ny/2+1) Details on Prolongation


Coarse Grid
1. Do n iterations on the fine grid (n = 3~4) using G-S Fine grid
Lf i ,nj = Ri , j
2. If Ri , j < ε then stop.
Δf i , j + 2 Δfi +1, j =
1
2
(
Δfi, j + Δfi + 2, j )
3. Interpolate the residual Ri , j onto the coarse grid
1
(
Δfi, j +1 = Δfi, j + Δfi, j + 2
2
)
(restriction, injection)
4. Iterations on the coarse grid Δf i − 2, j Δf i , j Δf i + 2, j Δfi +1, j +1
LΔf i , j = − Ri , j =
1
(
Δfi +1, j + Δfi, j +1 + Δfi +1, j + 2 + Δfi + 2, j +1 )
5. Interpolate the correction Δf i , j onto the fine grid 4

(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.

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods
Example: 4-Level V-Cycle
The process can be extended to multi-level grids
Fine è Coarse
(nx+1,ny+1), (nx/2+1,ny/2+1), (nx/4+1,ny/4+1), …, (3,3)
1. Iterate on Grid 1 for n times Lf i ,nj = 0 ⇒ Ri1, j
Various Strategies 2 1
2. Restriction by injection to Grid 2 I1 Ri , j
Fine 3. Iterate on Grid 2 LΔ( f 2 ) i , j = − I12 Ri1, j
Ri2, j = I12 Ri1, j + LΔ( f 2 ) in, j (Save Δ( f 2 ) i , j , I12 Ri1, j )
2 3
4. Restriction by injection to Grid 3 I Ri , j 2

5. Iterate on Grid 3 LΔ( f 3 ) i , j = − I 23 Ri2, j


Ri3, j = I 23 Ri2, j + LΔ( f 3 ) in, j (Save Δ( f 3 ) i , j , I 23 Ri2, j )
Coarse exact solution 4 3
6. Restriction by injection to Grid 4 I 3 Ri , j
V-Cycle W-Cycle 7. Iterate on Grid 4 LΔ( f 4 ) i , j = − I 3 Ri , j
4 3
Computational Fluid Dynamics Computational Fluid Dynamics
Multigrid Methods Multigrid Methods
Coarse è Fine Test Problem (Tannehill et al, p. 170)
1. Prolongate from Grid 4 to Grid 3 I 43 Δ( f 4 ) in, j - Laplace equation in a square domain
Δ( f 3 ) in, j = Δ( f 3 ) i , j + I 4 Δ( f 4 ) in, j
n 3
- Dirichlet conditions on four boundaries
2. Iterate on Grid 3 LΔ( f 3 ) i , j = − I 23 Ri2, j (saved) - 5 Levels of resolution
3. Prolongate from Grid 3 to Grid 2 I 32 Δ( f 3 ) in, j 9×9, 17×17, 33×33, 65×65, 129×129
Δ( f 2 ) in, j = Δ( f 2 ) in, j + I 32 Δ( f 3 ) in, j - 4 Methods
4. Iterate on Grid 2 LΔ( f 2 ) i , j = − I12 Ri1, j (saved) 1. Conventional Gauss-Seidel (GS)
5. Prolongate from Grid 2 to Grid 1 I 21Δ( f 2 ) in, j 2. Gauss-Seidel-SOR with optimal ω (GSopt )
f i ,nj = f i ,nj + I 21Δ( f 2 ) in, j 3. Multigrid with 2-level grids (MG2)
6. Iterate on Grid 1 Lf i , j = 0 4. Multigrid with maximum levels of grid (MGMAX)
7. If Ri , j < ε then stop. Else, repeat the entire cycle.

Computational Fluid Dynamics Computational Fluid Dynamics


Multigrid Methods Multigrid Methods
“Equivalent” fine grid iterations (from Tannehill et al)
A number of packages exist already and usually it is not
Grid size GS GSωopt MG2 MGMAX
9×9 62 19 19 17
necessary to write your own multigrid solver, particularly for
17×17 215 40 40 19 simple geometries.
33×33 715 75 95 20
65×65 2282 137 258 20 Multigrid methods are also used to solve steady-state
129×129 6826 282 732 21 problems such as flow over airplanes

See, for example:


MUDPACK: Multigrid Software for Elliptic Partial Differential Equations
Fortran Code with OpenMP Directives for Shared Memory Parallelism
by John C. Adams
http://www.cisl.ucar.edu/css/software/mudpack/

Computational Fluid Dynamics Computational Fluid Dynamics

The multigrid algorithm discussed here is often referred to


as Geometric Multigrid, since the coarsening is done on
the grid used to discretize the equations
In some cases, particularly for for anisotropic coefficients, it
Algebraic is smoothing needs to account for the structure of the
algebraic equations and the magnitude of the coefficients.
Multigrid For complex unstructured meshes it can be difficult to
identify a viable coarsening strategy
Algebraic Multigrid methods have been developed to deal
with these situations by working directly with the coefficient
matrix and ignoring all geometric information
Computational Fluid Dynamics Computational Fluid Dynamics

Although iterative methods are the


dominant technique for solutions of
elliptic equations in CFD, Fast Direct
Methods exists for special cases.
Fast Direct The methods require simple
domains (rectangles), simple
Methods equations (separable), and simple ∂2 f ∂2 f
+ =S
boundary conditions (periodic, or ∂x 2 ∂y 2
the derivative or the function equal
to zero at each boundary) separable

∂ ∂f ∂ ∂f
a(x, y) + b(x, y) = S
∂x ∂x ∂y ∂y
non-separable

Computational Fluid Dynamics Computational Fluid Dynamics

The fast Fourier transform Write

N 2π Δf k, j ≡ ( f k +1, j + f k−1, j + f k, j +1 + f k, j−1 − 4 f k, j ) = bk, j


f j ≡ ∑ fˆl e
i l j
N

l=1 Take the double Fourier Transform


N N 2π
( kl + jm )
f k, j ≡ ∑ ∑ fˆl,m e
i
inverse N
N 2π
fˆl ≡ ∑ f j e
−i lj l=1 m=1
N

( 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⎟⎠

Computational Fluid Dynamics Computational Fluid Dynamics

Have

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

also 2 Find fˆl,m as shown before


N N 2π
( kl + jm )
bk, j = ∑ ∑ b̂l, m e
i
N 3 find f k, j 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

subroutine hwscrt (a,b,m,mbdcnd,bda,bdb,c,d,n,nbdcnd,bdc,bdd,


1 elmbda,f,idimf,pertrb,ierror,w)
c *********************************
c * fishpak *
As outlined the method is applicable to periodic c * *
c * a package of fortran subprograms for the solution of *
boundaries only. Other simple boundary c * separable elliptic partial differential equations *
conditions can be handled by simple changes c * (version 3.1 , october 1980) *
c * by *
(using cosine or sine series). c * john adams, paul swarztrauber and roland sweet *
c * of *
c * the national center for atmospheric research *
c * boulder, colorado (80307) u.s.a. *
Other fast direct methods, such as Cyclic c * which is sponsored by *
c * the national science foundation *
Reduction, are based on similar ideas c *********************************
c * * * * * * * * * purpose * * * * * * * * * * * * * * * * * *
See FISHPACK c subroutine hwscrt solves the standard five-point finite
c difference approximation to the helmholtz equation in cartesian
c coordinates:
c
c (d/dx)(du/dx) + (d/dy)(du/dy) + lambda*u = f(x,y).

Computational Fluid Dynamics

Examples of elliptic equations


Elementary Iterative Methods
Note on Boundary Conditions
SOR on vector computers
Iteration as Time Integration
Convergence of Iterative Methods—elementary considerations
Multigrid methods
Fast Direct Method
Convergence of Iterative Methods—Formal Discussion
ADI for elliptic equations
Krylov Methods
Resources

You might also like