data structures for scientific computing · 2011/4/14  · “adaptive mesh refinement”/amr cells...

30
1 Data Structures for Scientific Computing Orion Sky Lawlor www.cs.uaf.edu 2011/04/14

Upload: others

Post on 25-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

1

Data Structures for Scientific Computing

Orion Sky Lawlorwww.cs.uaf.edu

2011/04/14

Page 2: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

2

Overview Introduction and Motivation Structured Grids

Adaptive structured grids Unstructured Grids

Adaptive unstructured grids Particles and Spatial Search

Regular grids Trees

Page 3: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

3

Introduction / Motivation There are only a few ways to

represent the problem domain: Structured Grids Unstructured Grids Particles

Knowing the basic terms helps you talk to application folks, and understand their code

Page 4: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

4

Grids in General

Page 5: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

5

So you’re trying to represent some physical situation, like heat flow

You decide to divide up space into a bunch of little pieces:

Grids: Introduction

Element, orCell, orVolume

Node, orVertex, or

Point

Page 6: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

6

Element Centered Data Fluid Dynamics, most PDEs

Grids: Location of Data

Node Centered DataStructural dynamics/FEM

“Shape function” interpolates between nodes

Data values constant (or simple) in a cell

Hybrids too,like

Arakawa C-grid

Page 7: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

7

Eulerian: non-moving grid E.g., pressure waves move through

the grid in CFD

Grids: Motion of Grid and Data

Lagrangian: moving grid E.g., grid deformation follows the

structure deformation in FEM

Or hybrid,

e.g. “ALE”

Page 8: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

8

Structured Grids

Page 9: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

9

AKA “Regular Grid”, since grid cells lie in regular rows and columns

Cells are stored in a 3D array Cells can lie along axes (“rectilinear

grid”); or curve through space

Structured Grids: Introduction

XY

Page 10: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

10

“Stencil” of source cells to compute a destination cell Classic GPU algorithm Common in fluid dynamics Also found in PDE solvers

Structured Grids: Terminology

ij

i

j x

Read-only “Ghost” or “Dummy” cells around boundary

Page 11: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

11

Fluid Dynamics Classical fluid dynamics grid

Jacobi and other PDE solvers “Finite Difference” formulation

Level set methods E.g., fluid solidification phase field

Image processing Just a 2D pixel array!

Structured Grids: Applications

Page 12: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

12

Adaptive Structured Grids

Page 13: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

13

“Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays,

linked together with pointers For regular refinement, use quadtree

(2D) or octree (3D); can be irregular “block structured AMR”

Adaptive Structured Grids: Intro

from LLNL SC98 SAMRAI flier

Page 14: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

14

“Refinement” and “Coarsening” criteria control evolution of mesh Basically simulation error estimates

“Hanging Node Constraint” Neighbors must have similar (±1)

refinement level

Adaptive Structured Grids: Terms

bad!

Page 15: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

15

Adaptive physics solvers LLNL SAMRAI C++ Framework NASA GSFC PARAMESH AMRITA (James Quirk) INRIA GPU Gems 3:5

Adaptive Structured Grids: Apps

Page 16: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

16

Unstructured Grids

Page 17: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

17

Unstructured Grids: Introduction AKA “Mesh” Cells are stored in 1D array Vertices (“nodes”) of each cell

(“element”) are listed explicitly Mesh consists of triangles

and/or quadrilaterals (2D); tetrahedra, cubes/hexahedra, prisms, pyramids (3D)

Page 18: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

18

Run computation on separate pieces

Add up node forces along boundaries

“Ghost regions”, like structured grids “Shared nodes” along partition

boundaries:

Unstructured Grids: Terms

Page 19: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

19

“Conformality” Nodes never land in middle of element Enforced during mesh

generation/modification

Unstructured Grids: Terms

bad!

Page 20: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

20

Structural Mechanics This is the classic finite element

mesh Fluid Dynamics

In strange domains, where structured grids are tough to automatically generate

Can be extended to Adaptive Meshes!

Unstructured Grids: Applications

Page 21: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

21

Adaptive Unstructured Grids

Page 22: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

22

Adaptive Unstructured Grids: Intro AKA “Mesh Refinement”, shades into

from-scratch “Mesh Generation” Cells still stored in 1D arrays, but the

cells can now change Must respect conformality Must ensure element “quality” Must work in parallel

Page 23: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

23

“Delaunay” mesh and “flip”

“Edge bisection”: cut edge in middle

Adaptive Meshes: Terminology

Page 24: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

24

Almost every unstructured mesh program wants to be adaptive.

Charm++ Triangle Mesh Refinement (Wilmarth)

Charm++ PMAF3D (Wilmarth) Charm++ Tet Data Transfer

Library (Lawlor)

Adaptive Meshes: Applications

Page 25: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

25

Particle Methods and Spatial Search

Page 26: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

26

Particles and Spatial Search To work on a particle, you need

nearby particles E.g., all particles within cutoff r

• Used for molecular dynamics (NAMD) or, all k nearest particles

• Used by Smoothed Particle Hydrodynamics (SPH) methods

Search for neighboring particles is spatial, so need a “spatial search structure” Can use: structured grid, adaptive

search tree, unstructured grid, ...

Page 27: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

27

... using Structured Grids E.g., NAMD molecular dynamics

Particles are Atoms Search structure is based on

“Patches” of space in regular, rectilinear grid

E.g., Charm++ Collision Library Search structure is based on

regular rectilinear voxel grid

atoms over here...

...never talk to atoms over here

Page 28: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

28

... using Search Trees E.g., Cosmology simulations

Particles are stars, galaxies Search structure is a spatial octree

SPH: “Smoothed particle hydrodynamics”

Barnes-Hut gravity “Tree walk”

Page 29: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

29

Conclusions

Page 30: Data Structures for Scientific Computing · 2011/4/14  · “Adaptive Mesh Refinement”/AMR Cells are stored in small 3D arrays, linked together with pointers For regular refinement,

30

Conclusions There are only a few ways to

represent the problem domain: Structured Grids Unstructured Grids Particles

There are a lot of specialized terms, but very few concepts