Technische Universität München

Algorithms of Scientific Computing
Fast Poisson Solvers
Michael Bader
Summer Term 2012

Michael Bader: Algorithms of Scientific Computing
Fast Poisson Solvers, Summer Term 2012 1

Technische Universität München Part I Excursion: Discrete Models for Heat Transfer and the Poisson Equation Modelling of Heat Transfer • objective: compute the temperature distribution of some object • under certain prerequisites: • temperature T at object boundaries given • heat sources • material parameters k . . . • observation from physical experiments: q ≈ k · δT heat flow proportional to temperature differences Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. . Summer Term 2012 2 .

j+1 x i−1. Summer Term 2012 3 .j x i.j x i.j x i+1.Technische Universität München A Wiremesh Model • consider rectangular plate as fine mesh of wires • compute temperature Tij ≈ T (xij ) at nodes xij of the mesh x i.j−1 hy hx Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.

Summer Term 2012 4 .j+1 4 • temperature known at (part of) the boundary.j − Ti+1.j + Ti.j = 1 • task: solve system of linear equations • in standard notation: −Ti−1.j = 0 Tn.j−1 + Ti.j+1 = 0 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.j−1 − Ti.Technische Universität München Wiremesh Model (2) • model assumption: temperatures in equilibrium at every mesh node • for all temperatures Tij : 1  Tij = Ti−1.j + Ti+1. for example: T0.j + 4Tij − Ti.

Summer Term 2012 5 .Technische Universität München A Finite Volume Model • object: a rectangular metal plate (again) • model as a collection of small connected rectangular cells hy hx • examine the heat flow across the cell edges Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.

j hy + kx Tij − Ti+1.Technische Universität München Heat Flow Across the Cell Boundaries • Heat flow across a given edge is proportional to • temperature difference (T1 − T0 ) between the adjacent cells • length h of the edge • e.: heat flow across the left edge: (left)  qij = kx Tij − Ti−1.j hy kx depends on material • heat flow across all edges determines change of heat energy:   qij = kx Tij − Ti−1.j−1 hx + ky Tij − Ti.j+1 hx Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. Summer Term 2012 6 .g.j hy   + ky Tij − Ti.

i.j − Ti+1.e. Summer Term 2012 7 . total heat flow equal to 0 for each cell • or: consider additional source term Fij due to external heating • radiation • • Fij = fij hx hy (fij heat flow per area) • equilibrium with source term requires qij + Fij = 0:  fij hx hy = −kx hy 2Tij − Ti−1.Technische Universität München Temperature change due to heat flow • model assumption: conservation of energy..j−1 − Ti. in equilibrium.j+1 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.j  −ky hx 2Tij − Ti.

Summer Term 2012 8 . boundary layer of cells) • prescribe heat flow across an edge.Technische Universität München Finite Volume Model • divide by hx hy : kx  fij = − 2Tij − Ti−1. system of linear equations • how to treat boundaries? • prescribe temperature in a cell (e.j−1 − Ti.j+1 hy • again. for example insulation at left edge: (left) qij =0 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.g.j − Ti+1.j hx ky  − 2Tij − Ti.

j+1 hy • assumption: heat flow across edges is proportional to temperature difference (left)  qij = kx Tij − Ti−1. Summer Term 2012 9 .j−1 − Ti.Technische Universität München From Discrete to Continuous • system of equations derived from the discrete model: kx  fij = − 2Tij − Ti−1.j hy • in reality: heat flow proportional to temperature gradient (left) Tij − Ti−1.j hx ky  − 2Tij − Ti.j qij ≈ khy hx Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.j − Ti+1.

j hx k  − 2 2Tij − Ti.j − Ti+1. Summer Term 2012 10 .Technische Universität München From Discrete to Continuous (2) • replace kx by k/hx . y ) ∂x 2 ∂y 2 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. and get: k  fij = − 2 2Tij − Ti−1. y ) ∂ 2 T (x.j+1 hy • consider arbitrary small cells: hx . ky by k /hy . y )   −k + = f (x.j−1 − Ti. hy → 0: ∂2T ∂2T     fij = −k −k ∂x 2 ij ∂y 2 ij • leads to partial differential equation (PDE): ∂ 2 T (x.

for example with 1000 × 1000 unknowns (in 2D) • actually simple to solve in 1D (tri-diagonal system). for a 1D problem: −un−1 + 2un − un+1 = fn for n = 1. j • or. simpler.j + 4uij − ui. Summer Term 2012 11 .j − ui+1.Technische Universität München Part II Fast Poisson Solvers and the Sine Transform • situation: solve a system of linear equations −ui−1. . N − 1 with u0 = uN = 0 • consider very fine meshes.j+1 = fij ∀i.j−1 − ui. . . but hard to solve in 2D (and even harder in 3D) Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. .

. . fn = 2 Fk sin (1) N N k=1 k =1 into the system of equations −un−1 + 2un − un+1 = fn for n = 1.Technische Universität München Applying the Sine Transform Idea: apply discrete sine transfrom on un and fn N−1 N−1 X πnk X πnk un = 2 Uk sin . if f (x) = sin(x) (with u(x) = 0 at both boundaries) • sine modes are eigenvectors of the system matrix. and eigenmodes of the continuous solution Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. Summer Term 2012 12 . . . N − 1 Why should that help? • corresponding continuous problem is −u 00 (x) = f (x) • is solved by u(x) = sin(x).

N − 1: N−1 N−1 N−1 X π(n + 1)k X πnk X π(n − 1)k −2 Uk sin +4 Uk sin −2 Uk sin N N N k=1 k=1 k=1 N−1 X πnk =2 Fk sin N k=1 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. for n = 1. and get. N − 1 u0 = uN = 0. . . . . . . .Technische Universität München Applying the Sine Transform (2) We insert the transformations N−1 N−1 X πnk X πnk un = 2 Uk sin and fn = 2 Fk sin N N k=1 k=1 into the system of linear equations −un+1 + 2un − un−1 = fn for n = 1. Summer Term 2012 13 . .

Technische Universität München Applying the Sine Transform (3) Use theorems of addition sin(A + B) = sin(A) cos(B) + cos(A) sin(B) and sin(A − B) = sin(A) cos(B) − cos(A) sin(B) applied to:     π(n + 1)k πnk πk sin = sin + and N N N     π(n − 1)k πnk πk sin = sin − N N N We have the situation sin(A + B) + sin(A − B) = 2 sin(A) cos(B) or. Summer Term 2012 14 . particularly:         π(n + 1)k π(n − 1)k πnk πk sin + sin = 2 sin cos N N N N Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.

Technische Universität München Applying the Sine Transform (4) Use theorems of addition in the left-hand side: N−1 X  N−1 π(n + 1)k π(n − 1)k X πnk −2 Uk sin + Uk sin +4 Uk sin N N N k=1 k=1 N−1 N−1 X πnk πk X πnk −4 Uk sin cos +4 Uk sin N N N k =1 k=1 and obtain simplified system of equations: N−1 N−1 N−1 X πnk πk X πnk X πnk −4 Uk sin cos +4 Uk sin =2 Fk sin N N N N k=1 k=1 k=1 N−1   N−1 X πnk πk X πnk ⇔2 Uk sin 1 − cos = Fk sin N N N k =1 k =1 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. Summer Term 2012 15 .

Summer Term 2012 16 . . if we set Fk Uk = for all k = 1.Technische Universität München Solution of the System of Equations We transformed the system of equations into N−1   N−1 X πnk πk X πnk 2 Uk sin 1 − cos = Fk sin N N N k=1 k=1 All equations are satisfied. . . N − 1. if   πk 2Uk 1 − cos = Fk for all k = 1. . 2 − 2 cos πk N Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers. . N − 1 N This is true. . . .

Compute the un from the Uk by means of an Inverse Fast Sine Transform: N−1 X πnk un = 2 Uk sin . . Compute the coefficients Fk by a Fast Sine Transform: N−1 1 X πnk Fk = fn sin N N n=1 2. . Compute all coefficients Uk from the Fk as Fk Uk = for all k = 1. . N k=1 Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.Technische Universität München Fast Poisson Solver – Algorithm 1. 2 − 2 cos πk N 3. Summer Term 2012 17 . . N − 1.

Summer Term 2012 18 .Technische Universität München Fast Poisson Solver – Algorithm (2) Computational Costs: • the two Fast Sine Transforms require O(N log N) operations • step 2 needs only O(N) operations ⇒ total computational effort is O(N log N) • thus: slower than solving the tridiagonal system of equations directly. which has effort O(N) • however: pays off in 2D and higher-dimensional settings! When can the Algorithm be applied: • boundary conditions need to be u0 = uN = 0 (otherwise: different transform required) • requires rectangular/cuboid domain and Cartesian mesh • requires uniform material parameters k Michael Bader: Algorithms of Scientific Computing Fast Poisson Solvers.