71
Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 8.10.2010 Iterative Solvers for Linear Systems Bernhard Gatzhammer Chair of Scientific Computing in Computer Science Technische Universität München Germany 9th SimLab Course on Parallel Numerical Simulation, 4.10. 8.10.2010

Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10 – 8.10.2010

Iterative Solvers for Linear Systems

Bernhard Gatzhammer

Chair of Scientific Computing in Computer Science

Technische Universität München

Germany

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Page 2: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

Page 3: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

Page 4: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

• General:

• 1D:

• 2D:

The Poisson Equation – An Elliptic PDE

­ 2 Rd, ±­ 2 Rd¡1, u : ­! R

¢u = f in ­ (¢ = r2 = r ¢ r)

@2u

@x21+

@2u

@x22+ : : :+

@2u

@x2d= f in ­

u = g on ±­

­ 2 R, @2u

@x2= f in ­

­ 2 R2, @2u

@x21+

@2u

@x22= f in ­

Page 5: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Laplace operator is part of many important PDEs:

• Heat equation: diffusion of heat

Why the Poisson Equation is of Importance

¢

Page 6: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Laplace operator is part of many important PDEs:

• Flow dynamics: friction between molecules

Why the Poisson Equation is of Importance

¢

Page 7: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Laplace operator is part of many important PDEs:

• Structural mechanics: displacement of membrane structures

Why the Poisson Equation is of Importance

¢

Page 8: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Laplace operator is part of many important PDEs:

• Electrics: electric-, magnetic potentials

Why the Poisson Equation is of Importance

¢

Page 9: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Laplace operator is part of many important PDEs:

• Financial mathematics: Diffusive process for option pricing

Why the Poisson Equation is of Importance

¢

Page 10: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Laplace operator is part of many important PDEs:

• Heat equation: diffusion of heat

• Flow dynamics: friction between molecules

• Structural mechanics: displacement of membrane structures

• Electrics: electric-, magnetic potentials

• Financial mathematics: Diffusive process for option pricing

• ...

Why the Poisson Equation is of Importance

¢

Page 11: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Find solution to Poisson equation numerically on a computer:

• Computer has only a finite amount of memory/power discretization

• Finite Differences as simple discretization

• Idea: Replace derivative by difference

Discretization with Finite Differences I

u(x+ h)¡ u(x)

h

h!0¡¡¡! @u

@x

u(x)¡ u(x¡ h)

h

h!0¡¡¡! @u

@x

x x+ h

xx¡ h

Page 12: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Use forward and backward differences for 2nd derivatives:

Discretization with Finite Differences II

@2u

@x2=

@

@x

@u

@x

¼ @

@x

u(x+ h)¡ u(x)

h

¼

u(x+ h)¡ u(x)

h¡ u(x+ h¡ h)¡ u(x¡ h)

hh

=u(x+ h)¡ 2u(x) + u(x¡ h)

h2

forward diff.:

backward diff.:

Page 13: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Regular Cartesian grid: Nodal equation: Stencil:

System matrix:

Grid, Stencil, and Matrix 1D

xi = ih

xi xi+1xi¡1

1 1¡21 2 3 xh

ui¡1¡ 2ui +ui+1 = h2fi

A =1

h2

0@¡2 1 0

1 ¡2 1

0 1 ¡2

1A

Page 14: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Regular Cartesian grid: Nodal equation:

Stencil:

Grid, Stencil, and Matrix 2D

hh

xi;j = (ih; jh)

ui¡1;j +ui+1;j +ui;j¡1+ui;j+1¡ 4ui;j = h2fi;j

1 1¡4

1

1

xi;j xi+1;jxi¡1;j

xi;j¡1

xi;j+1

Page 15: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

System matrix:

Grid, Stencil, and Matrix 2D

A =1

h2

0BBBBBBBBBBBB@

¡4 1 ¢ 1 ¢ ¢ ¢ ¢ ¢1 ¡4 1 ¢ 1 ¢ ¢ ¢ ¢¢ 1 ¡4 ¢ ¢ 1 ¢ ¢ ¢1 ¢ ¢ ¡4 1 ¢ 1 ¢ ¢¢ 1 ¢ 1 ¡4 1 ¢ 1 ¢¢ ¢ 1 ¢ 1 ¡4 ¢ ¢ 1

¢ ¢ ¢ 1 ¢ ¢ ¡4 1 ¢¢ ¢ ¢ ¢ 1 ¢ 1 ¡4 1

¢ ¢ ¢ ¢ ¢ 1 ¢ 1 ¡4

1CCCCCCCCCCCCA

1 1¡4

1

1

hh

Page 16: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

We obtain a system of equations to be solved:

• is the number of grid unknowns, i.e. equations

• contains sink/source terms and boundary influences

• We want to obtain

Discretized Poisson Equation

Au = f, A 2 RN£N , u; f 2 RN

N

f

u = A¡1f

Page 17: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

Page 18: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Popular direct solvers for :

• Gaussian elimination

• LU decomposition

• Cholesky factorization

compute directly up to numerical accuracy

computational complexity of GEM in 2D: , in 3D:

GEM optimized for band-structure: in 2D: , in 3D:

Direct Solvers of Systems of Linear Equations

u = A¡1f

A= LU, LUu= f, Uu= L¡1f

A= UTU

TN ¢ ::: ¢T2 ¢Au = TN ¢ ::: ¢ T2 ¢ f, Uu= f0

Au= f

O(h6)

¢ =U

O(h9)

O(h4) O(h7)

Page 19: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

h N runtime (33 TFlop/s)

2-8 65.536 0.5 sec

2-9 262.144 8.3 sec

2-10 1.048.576 2 min 23 sec

2-11 4.194.304 35 min 32 sec

2-12 16.777.216 9 h 28 min 38 sec

2-13 67.108.864 6 d 7 h 28 min 10 sec

Runtime of GEM for Solving Poisson 2D

x 16

Page 20: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Runtime of GEM for Solving Poisson 3D

h N runtime (33 TFlop/s)

2-6 262.144 8 min 53 sec

2-7 2.097.152 18 h 57 min 26 sec

2-8 16.777.216 100 d 26 h 10 min 53 sec

2-9 134.217.728 35 a 156 d 57 h 53 min 04 sec

x 128

Page 21: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Iterative Solvers of Systems of Linear Equations

In contrast to direct solvers, iterative solvers

• Compute approximate solutions

• Improve the approximation in an iterative process

• One iteration is cheap to compute, in 2D , in 3D

• Fixpoint iteration:

• Types of methods:

Splitting methods, Krylov-subspace methods, Multigrid methods

uk ¼ A¡1f

uk+1 = F(uk)k!1¡¡¡¡! u = F(u)

O(h2) O(h3)

Page 22: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

Page 23: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Splitting Methods

Split up matrix :

Update rule:

Matrix has to be of simple form to to get

Au = f

(S + T )u = f

Suk+1 = f ¡ Tuk

uk+1 = S¡1(f ¡ Tuk)

uk+1 = F (uk)

S uk+1

A

Page 24: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Jacobi Method

• Choose:

• Splitting:

• Update rule:

S = diag(A) :=DA

A= S+T =DA+ (A¡DA)

Au = f

(DA + (A ¡DA))u = f

DAuk+1 = (f ¡ (A¡DA)u

k)

uk+1 = D¡1A (f ¡ (A¡DA)uk)

uk+1i =1

aii(fi ¡

NX

j=1j 6=i

aijukj )

Page 25: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

• Stationary heat equation with as temperature:

• Boundaries have zero temperature, no sources:

• Solution is known:

f = 0

u

u = 0

@2u

@x2= f in ­

uk+1i =1

aii(fi ¡

NX

j=1j 6=i

aijuj) =) uk+1i =1

2(uki¡1 + uki+1)

Page 26: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

Unit domain:

0 1

x

­ := [0; 1]; h =1

8; N = 7

A =

0BBBBBBBB@

¡2 1

1 ¡2 1

1 ¡2 1

1 ¡2 1

1 ¡2 1

1 ¡2 1

1 ¡2

1CCCCCCCCA

Page 27: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

• Random initial value u0 = rand(N)

Page 28: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 0

uk+1i =1

2(uki¡1 + uki+1)

Page 29: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 1

Page 30: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 2

Page 31: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 3

Page 32: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 4

Page 33: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 5

Page 34: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 6

Page 35: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 7

Page 36: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 8

Page 37: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Jacobi Method Example – 1D Heat Equation

0 1

x

k = 8

Initial values

Page 38: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

The Gauss-Seidel Method

• Choose:

• Splitting:

• Update rule:

S = L(A) := LA

A= S+ T = LA+ (A¡LA)

Au = f

(LA + (A¡ LA))u = f

LAuk+1 = (f ¡ (A ¡ LA)u

k)

uk+1 = L¡1A (f ¡ (A ¡ LA)uk)

uk+1i =1

aii(fi ¡

i¡1X

j=1

aijuk+1j ¡

NX

j=i+1

aijukj )

Page 39: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

• Stationary heat equation with as temperature:

• Boundaries have zero temperature, no sources:

• Solution is known:

f = 0

u

u = 0

@2u

@x2= f in ­

uk+1i =1

aii(fi ¡

i¡1X

j=1

aijuk+1j ¡

NX

j=i+1

aijukj ) =) uk+1i =

1

2(uk+1i¡1 + uki+1)

Page 40: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

• Random initial value u0 = rand(N)

Page 41: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 42: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 43: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 44: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 45: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 46: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 47: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 0

Page 48: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 1

Page 49: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 2

Page 50: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 3

Page 51: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 4

Page 52: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 5

Page 53: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 6

Page 54: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 7

Page 55: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 8

Page 56: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 8

Initial values

Page 57: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Gauss-Seidel Method Example – 1D Heat Equation

0 1

x

k = 8

Jacobi after 8 iterations

Page 58: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

Page 59: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Residual

• Residual:

• Splitting: Au = (S + T )u = f

uk+1 = S¡1(f ¡ Tuk)

Au = f

Auk 6= f

f ¡Auk = resk

uk+1 = S¡1(f ¡ (A¡ S)uk)

uk+1 = S¡1(f ¡Auk) + uk

uk+1 = uk + S¡1resk

Page 60: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

• Local influences form residual:

• GS : high residual

oscillatory error/fct values

• GS : low residual

smooth error/fct values

Residual for 1D Heat Equation Example

ui¡1 ¡ 2ui + ui+1 = 0

uki¡1 ¡ 2uki + uki+1 = reski

0 1

x

0 1

x

k = 0

k = 8

Page 61: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Smoothnes depends on grid resolution :

• :

• :

• :

Smoothness Observation

h

h =1

8

h =1

4

0 1

x

0 1

x

0 1

x

h =1

2

0 1

x

0 1

x

0 1

x

k! k+1

Error reduction

Page 62: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Outline

• Poisson-Equation: From the Model to an Equation System

• Direct Solvers vs. Iterative Solvers

• Jacobi and Gauss-Seidel Method

• Residual and Smoothness

• Multigrid Solver

Page 63: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Geometric Multigrid Idea

• Only high error frequencies are removed effectively

• Frequencies depend on grid resolution

• Idea:

• Use several grid levels

• Use splitting method to smooth error on each grid level

Page 64: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

• Random initial value u0 = rand(N)

Page 65: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

k = 0, N = 1

Page 66: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

k = 0, N = 1

Page 67: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

k = 0, N = 3

Page 68: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

k = 0, N = 3

Page 69: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

k = 0, N = 7

Page 70: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Multigrid Example – 1D Heat Equation

0 1

x

k = 1

Page 71: Iterative Solvers for Linear Systems · Technische Universität München 9th SimLab Course on Parallel Numerical Simulation, 4.10 –8.10.2010 Iterative Solvers for Linear Systems

Technische Universität München

9th SimLab Course on Parallel Numerical Simulation, 4.10. – 8.10.2010

Thank you for your attention!