Technische Universit¨ at M¨ unchen HPC – Algorithms and Applications Dwarf #5 – Structured Grids Michael Bader Winter 2012/2013 Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 1
Technische Universit¨ at M¨ unchen Dwarf #5 – Structured Grids 1. dense linear algebra 2. sparse linear algebra 3. spectral methods 4. N-body methods 5. structured grids 6. unstructured grids 7. Monte Carlo Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 2
Technische Universit¨ at M¨ unchen Part I Modelling on Structured Grids Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 3
Technische Universit¨ at M¨ unchen Motivation: Heat Transfer • objective: compute the temperature distribution of some object • under certain prerequisites: • temperature at object boundaries given • heat sources • material parameters • observation from physical experiments: q ≈ k · δ T heat flow proportional to temperature differences Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 4
Technische Universit¨ at M¨ unchen A Wiremesh Model • consider rectangular plate as fine mesh of wires • compute temperature x ij at nodes of the mesh x i,j+1 x i−1,j x i,j x i+1,j x i,j−1 h y h x Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 5
Technische Universit¨ at M¨ unchen Wiremesh Model (2) • model assumption: temperatures in equilibrium at every mesh node • for all temperatures x ij : x ij = 1 � � x i − 1 , j + x i + 1 , j + x i , j − 1 + x i , j + 1 4 • temperature known at (part of) the boundary; for example: x 0 , j = T j • task: solve system of linear equations Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 6
Technische Universit¨ at M¨ unchen A Finite Volume Model • object: a rectangular metal plate (again) • model as a collection of small connected rectangular cells h y h x • examine the heat flow across the cell edges Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 7
Technische Universit¨ at M¨ unchen Heat Flow Across the Cell Boundaries • Heat flow across a given edge is proportional to • temperature difference ( T 1 − T 0 ) between the adjacent cells • length h of the edge • e.g.: heat flow across the left edge: q ( left ) � � = k x T ij − T i − 1 , j h y ij • heat flow across all edges determines change of heat energy: � � � � q ij = k x T ij − T i − 1 , j h y + k x T ij − T i + 1 , j h y � � � � + k y T ij − T i , j − 1 h x + k y T ij − T i , j + 1 h x Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 8
Technische Universit¨ at M¨ unchen Temperature change due to heat flow • in equilibrium: total heat flow equal to 0 • but: consider additional source term F ij due to • external heating • radiation • F ij = f ij h x h y ( f ij heat flow per area) • equilibrium with source term requires q ij + F ij = 0: � � f ij h x h y = − k x h y 2 T ij − T i − 1 , j − T i + 1 , j � � − k y h x 2 T ij − T i , j − 1 − T i , j + 1 Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 9
Technische Universit¨ at M¨ unchen Finite Volume Model • divide by h x h y : − k x � � f ij = 2 T ij − T i − 1 , j − T i + 1 , j h x − k y � � 2 T ij − T i , j − 1 − T i , j + 1 h y • again, system of linear equations • how to treat boundaries? • prescribe temperature in a cell (e.g. boundary layer of cells) • prescribe heat flow across an edge; for example insulation at left edge: q ( left ) = 0 ij Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 10
Technische Universit¨ at M¨ unchen Towards a Time Dependent Model • idea: set up ODE for each cell • simplification: no external heat sources or drains, i.e. f ij = 0 • change of temperature per time is proportional to heat flow into the cell (no longer 0): κ x ˙ � � T ij ( t ) = 2 T ij ( t ) − T i − 1 , j ( t ) − T i + 1 , j ( t ) h x κ y � � + 2 T ij ( t ) − T i , j − 1 ( t ) − T i , j + 1 ( t ) h y • solve system of ODE → using Euler time stepping, e.g.: τ κ x � � T ( n + 1 ) = T ( n ) 2 T ( n ) ( t ) − T ( n ) i − 1 , j ( t ) − T ( n ) + i + 1 , j ( t ) ij ij ij h x τ κ y � � 2 T ( n ) ( t ) − T ( n ) i , j − 1 ( t ) − T ( n ) + i , j + 1 ( t ) ij h y Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 11
Technische Universit¨ at M¨ unchen General Pattern: Stencil Computation Characterisation of stencil codes: • update of unknowns, elements, etc., according to a fixed pattern • pattern usually defined by neighbours in a structured grid/lattice • task: “update all unknowns/elements” → traversal • multiple traversals for iterative solvers (in case of systems of equations) or time stepping (in case of time-dependent problems) Additional example in the tutorials: shallow water equation on Cartesian grid (Finite Volume Model) Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 12
Technische Universit¨ at M¨ unchen Stencil Notation • illustrate structure of system of equations or unknown/element-local update as a discretisation stencil • represents one line of the system matrix (in matrix-vector notation) • matrix elements (in general: update weights) placed according to their corresponding geometrical position • stencils for the Poisson equation ( h 2 factors ignored): 1 � � 1D: 1 − 2 1 2D: 1 − 4 1 1 Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 13
Technische Universit¨ at M¨ unchen Part II Structured Grids – Classification and Overview Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 14
Technische Universit¨ at M¨ unchen Structured Grids – Characterisation • construction of points or elements follows regular process • geometric (coordinates) and topological information (neighbour relations) can be derived (i.e. are not stored) • memory addresses can be easily computed Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 15
Technische Universit¨ at M¨ unchen Regular Structured Grids • rectangular/ cartesian grids: rectangles (2D) or cuboids (3D) • triangular meshes: triangles (2D) or tetrahedra (3D) • often: row-major or column-major traversal and storage h y h x Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 16
Technische Universit¨ at M¨ unchen Transformed Structured Grids • transformation of the unit square to the computational domain • regular grid is transformed likewise (ξ(0),η(1)) (0,1) (1,1) (ξ(1),η(1)) (0,0) (1,0) (ξ(1),η(0)) (ξ(0),η(0)) Variants: • algebraic : interpolation-based • PDE-based : solve system of PDEs to obtain ξ ( x , y ) and η ( x , y ) Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 17
Technische Universit¨ at M¨ unchen Composite Structured Grids • subdivide (complicated) domain into subdomains of simpler form • and use regular meshs on each subdomain • at interfaces: • conforming at interface (“glue” required?) • overlapping grids ( chimera grids) Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 18
Technische Universit¨ at M¨ unchen Block Structured Grids Special case of composite grids: • subdivision into logically rectangular subdomains (with logically rectangular local grids) • subdomains fit together in an unstructured way, but continuity is ensured (coinciding grid points) • popular in computational fluid dynamics Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 19
Technische Universit¨ at M¨ unchen Adaptive Grids Characterization of adaptive grids: • size of grid cells varies considerably • to locally improve accuracy • sometimes requirement from numerics Challenge for structured grids: • efficient storage/traversal • retrieve structural information (neighbours, etc.) Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 20
Technische Universit¨ at M¨ unchen Block Adaptive Grids • retain regular structure • refinement of entire blocks • similar to block structured grids • efficient storage and processing • but limited w.r.t. adaptivity Michael Bader: HPC – Algorithms and Applications Dwarf #5 – Structured Grids, Winter 2012/2013 21
Recommend
More recommend