Adaptive Mesh Refinement

Similar documents
Adaptive-Mesh-Refinement Hydrodynamic GPU Computation in Astrophysics

Computational Astrophysics 5 Higher-order and AMR schemes

Development of a Computational Framework for Block-Based AMR Simulations

Adaptive Refinement Tree (ART) code. N-Body: Parallelization using OpenMP and MPI

Lagrangian methods and Smoothed Particle Hydrodynamics (SPH) Computation in Astrophysics Seminar (Spring 2006) L. J. Dursi

A brief description of the particle finite element method (PFEM2). Extensions to free surface

Parallel Algorithms: Adaptive Mesh Refinement (AMR) method and its implementation

Example 13 - Shock Tube

AREPO: a moving-mesh code for cosmological hydrodynamical simulations

Level Set Methods and Fast Marching Methods

Solving Partial Differential Equations on Overlapping Grids

Free Convection Cookbook for StarCCM+

RAMSES on the GPU: An OpenACC-Based Approach

IMPROVING THE NUMERICAL ACCURACY OF HYDROTHERMAL RESERVOIR SIMULATIONS USING THE CIP SCHEME WITH THIRD-ORDER ACCURACY

ELEC Dr Reji Mathew Electrical Engineering UNSW

Volume Tracking on Adaptively Refined Grids with Curvature Based Refinement

arxiv:astro-ph/ v3 29 Jul 1997

Discrete representations of geometric objects: Features, data structures and adequacy for dynamic simulation. Part I : Solid geometry

Chapter 6. Semi-Lagrangian Methods

Moving Interface Problems: Methods & Applications Tutorial Lecture II

Two-Phase flows on massively parallel multi-gpu clusters

Acknowledgements. Prof. Dan Negrut Prof. Darryl Thelen Prof. Michael Zinn. SBEL Colleagues: Hammad Mazar, Toby Heyn, Manoj Kumar

Research Article Parallel Adaptive Mesh Refinement Combined with Additive Multigrid for the Efficient Solution of the Poisson Equation

Unstructured Mesh Generation for Implicit Moving Geometries and Level Set Applications

Introduction to C omputational F luid Dynamics. D. Murrin

An explicit and conservative remapping strategy for semi-lagrangian advection

Investigating The Stability of The Balance-force Continuum Surface Force Model of Surface Tension In Interfacial Flow

Simulation of liquid cube fracture with SPH

Realtime Water Simulation on GPU. Nuttapong Chentanez NVIDIA Research

Dynamic Load Distributions for Adaptive Computations on MIMD Machines using Hybrid Genetic Algorithms (a subset)

SPH: Why and what for?

T6: Position-Based Simulation Methods in Computer Graphics. Jan Bender Miles Macklin Matthias Müller

Fluent User Services Center

Numerical Methods for PDEs. SSC Workgroup Meetings Juan J. Alonso October 8, SSC Working Group Meetings, JJA 1

Challenges and recent progress in developing numerical methods for multi-material ALE Hydrocodes

An Embedded Boundary Method with Adaptive Mesh Refinements

Adaptive-Mesh-Refinement Pattern

A cell by cell anisotropic adaptive mesh Arbitrary Lagrangian Eulerian method for the numerical solution of the Euler equations. J. M.

New formulations of the semi-lagrangian method for Vlasov-type equations

FEMLAB Exercise 1 for ChE366

A MULTI-DOMAIN ALE ALGORITHM FOR SIMULATING FLOWS INSIDE FREE-PISTON DRIVEN HYPERSONIC TEST FACILITIES

The gas-kinetic methods have become popular for the simulation of compressible fluid flows in the last

Highly efficient «on-the-fly» data processing using the open-source library CPPPO

AMR Multi-Moment FVM Scheme

Coupling of STAR-CCM+ to Other Theoretical or Numerical Solutions. Milovan Perić

Solver Settings. Introductory FLUENT Training ANSYS, Inc. All rights reserved. ANSYS, Inc. Proprietary

Microwell Mixing with Surface Tension

The Swift simulation code

Influence of mesh quality and density on numerical calculation of heat exchanger with undulation in herringbone pattern

Metafor FE Software. 2. Operator split. 4. Rezoning methods 5. Contact with friction

arxiv: v1 [astro-ph.ga] 8 Nov 2016

Particle Velocimetry Data from COMSOL Model of Micro-channels

HPC Algorithms and Applications

arxiv: v1 [astro-ph] 11 Dec 2008 PIERNIK MHD CODE A MULTI FLUID, NON IDEAL EXTENSION OF THE RELAXING TVD SCHEME (I)

Enzo-P / Cello. Scalable Adaptive Mesh Refinement for Astrophysics and Cosmology. San Diego Supercomputer Center. Department of Physics and Astronomy

Lecture 1.1 Introduction to Fluid Dynamics

Numerical Analysis of Shock Tube Problem by using TVD and ACM Schemes

Spatio-temporal Feature Exploration in Combined Particle/Volume Reference Frames

Computational Fluid Dynamics (CFD) using Graphics Processing Units

Overview of Traditional Surface Tracking Methods

Module 4: Fluid Dynamics Lecture 9: Lagrangian and Eulerian approaches; Euler's acceleration formula. Fluid Dynamics: description of fluid-motion

Considerations about level-set methods: Accuracy, interpolation and reinitialization

SPH: Towards the simulation of wave-body interactions in extreme seas

Parallel Summation of Inter-Particle Forces in SPH

GEOMETRY MODELING & GRID GENERATION

NUMERICAL INVESTIGATION OF THE FLOW BEHAVIOR INTO THE INLET GUIDE VANE SYSTEM (IGV)

Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs)

Chapter 1 - Basic Equations

Efficiency of adaptive mesh algorithms

Extension and Validation of the CFX Cavitation Model for Sheet and Tip Vortex Cavitation on Hydrofoils

CONSERVATIVE AND NON-CONSERVATIVE METHODS BASED ON HERMITE WEIGHTED ESSENTIALLY-NON-OSCILLATORY RECONSTRUCTION FOR VLASOV EQUATIONS

Directions: 1) Delete this text box 2) Insert desired picture here

Voronoi Diagram. Xiao-Ming Fu

An adaptive discretization of incompressible flow using a multitude of moving Cartesian grids

2.7 Cloth Animation. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter 2 123

A Multi-scale Approach to 3D Scattered Data Interpolation with Compactly Supported Basis Functions

Eulerian Techniques for Fluid-Structure Interactions - Part II: Applications

PiTP Summer School 2009

The 3D DSC in Fluid Simulation

A New Parallel N-body Gravity Solver: TPM

Advective and conservative semi-lagrangian schemes on uniform and non-uniform grids

An adaptive discretization of compressible flow using a multitude of moving Cartesian grids

Store Separation Simulation using Oct-tree Grid Based Solver

CFD MODELING FOR PNEUMATIC CONVEYING

Water. Notes. Free surface. Boundary conditions. This week: extend our 3D flow solver to full 3D water We need to add two things:

Continuum-Microscopic Models

Characteristic Aspects of SPH Solutions

A Novel Approach to High Speed Collision

BACK AND FORTH ERROR COMPENSATION AND CORRECTION METHODS FOR REMOVING ERRORS INDUCED BY UNEVEN GRADIENTS OF THE LEVEL SET FUNCTION

Computational Fluid Dynamics - Incompressible Flows

Multigrid Pattern. I. Problem. II. Driving Forces. III. Solution

Numerical Simulation of Coupled Fluid-Solid Systems by Fictitious Boundary and Grid Deformation Methods

CGT 581 G Fluids. Overview. Some terms. Some terms

CFD Best Practice Guidelines: A process to understand CFD results and establish Simulation versus Reality

Weno Scheme for Transport Equation on Unstructured Grids with a DDFV Approach

Subdivision. Outline. Key Questions. Subdivision Surfaces. Advanced Computer Graphics (Spring 2013) Video: Geri s Game (outside link)

The Development of a Volume-of-Fluid Interface Tracking Method for Modeling Problems in Mantle Convection

Mesh refinement in FE-micromagnetics for multi-domain Nd 2 Fe 14 B particles

Smoothers. < interactive example > Partial Differential Equations Numerical Methods for PDEs Sparse Linear Systems

Simulation of Curtain Airbag with Arbitrary. Eulerian- Lagrangian Method

Transcription:

Aleander Knebe, Universidad Autonoma de Madrid Adaptive Mesh Refinement

AMR codes

Poisson s equation ΔΦ( ) = 4πGρ( )

Poisson s equation F ( ) = m Φ( ) ΔΦ( ) = 4πGρ( ) particle approach F ( Gm i ) = i m j ( i j ) ( 3 i j ) i j grid approach ΔΦ( i, j,k ) = 4πGρ( i, j,k ) F ( i, j,k ) = m Φ( i, j,k ) ( i, j,k =position of centre of grid cell (i, j,k))

Poisson s equation weapon of choice: tree codes F ( ) = m Φ( ) ΔΦ( ) = 4πGρ( ) particle approach F ( Gm i ) = i m j ( i j ) ( 3 i j ) i j grid approach ΔΦ( i, j,k ) = 4πGρ( i, j,k ) F ( i, j,k ) = m Φ( i, j,k ) ( i, j,k =position of centre of grid cell (i, j,k))

Poisson s equation F ( ) = m Φ( ) ΔΦ( ) = 4πGρ( ) particle approach F ( Gm i ) = i m j ( i j ) ( 3 i j ) i j grid approach ΔΦ( i, j,k ) = 4πGρ( i, j,k ) F ( i, j,k ) = m Φ( i, j,k ) ( i, j,k =position of centre of grid cell (i, j,k)) weapon of choice: AMR codes

Particle-Mesh Method Particle-Mesh (PM) method ΔΦ( g k,l,m ) = 4πGρ( g k,l,m ) F ( g k,l,m ) = m Φ( g k,l,m ) 1. calculate mass density on grid 2. solve Poisson s equation on grid 3. differentiate potential to get forces 4. interpolate forces back to particles i ρ( g k,l,m ) Φ( g k,l,m ) F ( g k,l,m ) F ( g k,l,m ) F ( i )

Particle-Mesh Method numerically integrate Poisson s equation pure PM calculation

Particle-Mesh Method numerically integrate Poisson s equation density assignment schemes: interplay pure PM between calculation N and ε: Nε 3 =const. NGP = too crude CIC = common choice TSC = pretty smooth

Particle-Mesh Method numerically integrate Poisson s equation pure PM calculation overcoming the spatial resolution limitation?

Particle-Mesh Method numerically integrate Poisson s equation AMR calculation Yahagi & Yoshi (2001)

Particle-Mesh Method numerically integrate Poisson s equation AMR calculation...details now Yahagi & Yoshi (2001)

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration

Mesh Refinements types of mesh refinement r refinement: move or stretch the mesh p refinement: adjust the order of the method h refinement: change the mesh spacing

Mesh Refinements types of mesh refinement r refinement non-uniform mesh (refined region is known) = advantages: - simple to implement = disadvantages: - difference epression for non-constant zone spacing COSMOS code (Ricker 2000)

Mesh Refinements types of mesh refinement r refinement Lagragian mesh (mesh is tied to fluid) = advantages: - constant mass resolution - sharp resolution of contacts = disadvantages: - grid stretching causes numerical dissipation - grid tangling in rotational flows MMH code (Pen 1998)

Mesh Refinements types of mesh refinement r refinement Lagragian mesh (mesh is tied to fluid) = advantages: - constant mass resolution - sharp resolution of contacts = disadvantages: - grid stretching causes numerical dissipation - grid tangling in rotational flows usually used only in 1D (e.g. stellar evolution codes) MMH code (Pen 1998)

AMR Codes Mesh Refinements types of mesh refinement r refinement arbitrary Lagrangian-Eulerion mesh (mesh moves arbitrarily fluid) = advantages: - Lagrangian mesh where flow is irrotational - Eulerian where mesh distortion is problematic = disadvantages: - difficult to handle... DJEHUTY code (Dearborn et al. 2002)

Mesh Refinements types of mesh refinement p refinement not in this course...

Mesh Refinements types of mesh refinement h refinement nested grids (static meshes with different resolutions) = advantages: - easy to handle boundaries between meshes = disadvantages: - refined region should not move

Mesh Refinements types of mesh refinement h refinement adaptive mesh refinement (refined patches are created and destroyed as needed) = advantages: - fully fleible to problem = disadvantages: - serious book-keeping for grid hierarchy density field of simulated galay cluster AMIGA code (Doumler & Knebe 2010) adaptive grid hierarchy

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration

Adaptive Mesh Refinement adaptive mesh refinement improvements using finer grids double pancake test (Doumler & Knebe 2010)

Adaptive Mesh Refinement adaptive mesh refinement improvements using finer grids shock tube test (Teyssier 2002)

Adaptive Mesh Refinement adaptive mesh refinement improvements using finer grids grid level shock tube test (Teyssier 2002)

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density truncation error physics

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ()

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ()

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ() AMR level #4 AMR level #3 AMR level #2 AMR level #1 domain grid

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density 1D density distribution δ() AMR level #4 AMR level #3 AMR level #2 AMR level #1 domain grid

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density: - refine regions of high density truncation error: physics:

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density: - refine regions of high density truncation error: - refine regions of large truncation errors i R k,l,m i = ΔΦ k,l,m ρ k,l,m ετ k,l,m with i [ ] ΔΦ k,l,m i Τ k,l,m = P Δ( RΦ k,l,m ) ( ) physics:

Adaptive Mesh Refinement adaptive mesh refinement refinement criterion density: - refine regions of high density truncation error: - refine regions of large truncation errors i R k,l,m i = ΔΦ k,l,m ρ k,l,m ετ k,l,m with i [ ] ΔΦ k,l,m i Τ k,l,m = P Δ( RΦ k,l,m ) ( ) physics: - compare grid spacing against local critical wavelength π Δ < ε λ with λ = c s Gρ

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration

AMR for N-body gravity tends to clump matter together...

AMR for N-body gravity tends to clump matter together...

AMR for N-body gravity tends to clump matter together...

AMR for N-body gravity tends to clump matter together... introduce finer grids where needed and gain a factor of 2 in accuracy (in regions of interest)

AMR for N-body gravity tends to clump matter together... introduce finer grids where needed and gain a factor of 2 in accuracy (in regions of interest) factor 2 not mandatory, but most common choice

AMR for N-body gravity tends to clump matter together... introduce finer grids where needed periodic boundary conditions isolated boundary conditions

AMR for N-body gravity tends to clump matter together... introduce finer grids where needed...and update the grids where and when necessary

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration

AMR Codes generating refinements N-body simulations: number of particles per cell refinement criterion: 6 particles/cell AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell loop through given grid generating refinement by checking each individual cell N-body simulations: AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell N-body simulations: AMR for N-body

AMR Codes generating refinements number of particles per cell refinement criterion: 6 particles/cell stop when no more cell require splitting N-body simulations: AMR for N-body

AMR for N-body generating refinements N-body simulations: number of particles per cell Note: in this scheme we split the volume of a coarse cell into eight equal sub-cells => non-cospatial scheme refinement criterion: 6 particles/cell

AMR for N-body generating refinements interpolation between grids: f ( i ) = F( i ) + ʹ F ( i )Δ F = value on coarse grid f = value on fine grid

AMR for N-body generating refinements interpolation between grids: f ( i ) = F( i ) + ʹ F ( i )Δ co-spatial vs. non-cospatial F( i ) F( i ) f ( i ) = F( i ) f ( i+1/ 2 ) = F( i ) + F ʹ ( i ) Δ 2 f ( i 1/ 2 ) = F( i ) F ʹ ( i ) Δ 2 f ( i+1/ 2 ) = F( i ) + F ʹ ( i ) Δ 2

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration

AMR for N-body density assignment (co-spatial scheme)

AMR for N-body density assignment (co-spatial scheme)

AMR for N-body density assignment (co-spatial scheme) TSC mass assignment

AMR for N-body density assignment (co-spatial scheme) unproblematic:

AMR for N-body density assignment (co-spatial scheme) unproblematic:

AMR for N-body density assignment (co-spatial scheme) problematic:

AMR for N-body density assignment (co-spatial scheme) problematic:

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) transfer particles to refinement

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) density on coarse grid assign density on coarse grid

AMR for N-body density assignment (co-spatial scheme) density on coarse grid nodes with zero density

AMR for N-body density assignment (co-spatial scheme) density on coarse grid nodes carrying the density contribution from particles outside refinement => to be transferred to refinement nodes

AMR for N-body density assignment (co-spatial scheme) density on coarse grid remember nodes carrying the density contribution from particles outside refinement => to be transferred to refinement nodes

AMR for N-body density assignment (co-spatial scheme) density on coarse grid same nodes still missing density from particles on refinement edge => to be derived from refinement density

AMR for N-body density assignment (co-spatial scheme) density on coarse grid remember nodes still missing density from particles on refinement edge

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) density on refinement grid assign density on refinement grid

AMR for N-body density assignment (co-spatial scheme) density on refinement grid refinement nodes still missing the density contribution from particles outside refinement

AMR for N-body density assignment (co-spatial scheme) density on refinement grid remember refinement nodes still missing the density contribution from particles outside refinement

AMR for N-body density assignment (co-spatial scheme) density on refinement grid all refinement nodes carry information required by coarse nodes

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) density on coarse grid nodes carrying the density contribution from particles outside refinement

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) density on coarse grid all refinement nodes carry information required by coarse nodes

AMR for N-body density assignment (co-spatial scheme) steps required to get density correct on both coarse and fine grid 1. transfer particles from coarse to fine grid 2. assign coarse particles to coarse grid 3. assign fine particles to refinement grid 4. temporarily store borderline density 5. inject refinement density to coarse grid 6. add borderline density to refinement

AMR for N-body density assignment (co-spatial scheme) density on refinement grid refinement nodes still missing the density contribution from particles outside refinement

AMR for N-body density assignment (co-spatial scheme) density finally correct on both levels

AMR for N-body density assignment (co-spatial scheme) density finally correct on both levels phew...

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes gravity generating refinements density assignment solving Poisson s equation handling irregular grids adaptive leap-frog integration

AMR for N-body solving Poisson s equation 16 3 boundary values 32 3 boundary values 64 3 boundary values 128 3

AMR for N-body adaptive mesh refinement cover simulation with regular domain grid create AMR hierarchy: generate fine grid by comparing each node against some refinement criterion " recursive procedure assign density on all grids solve Poisson s equation on regular domain grid (FFT is fastest ) loop over all refinement levels: interpolate potential down from parent level rela potential until converged (keeping boundary values fied) " this will give the correct potential on all (refinement) grids

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration

AMR Codes Irregular Grids handling refinements refinement grids can have a highly irregular shape and consist of multiple spatially disjunctive blocks

AMR Codes Irregular Grids handling refinements how to manage and maneuver such irregular grids? refinement grids can have a highly irregular shape and consist of multiple spatially disjunctive blocks

Irregular Grids handling regular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 struct { N = 16 node[0].rho, =3 node[1].rho, =6, node[n-1].rho, =48 float rho; } node;

Irregular Grids handling regular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 struct { N = 16 float rho; } node; node[0].rho, =3 node[1].rho, =6, node[n-1].rho, =48 unique mapping between array inde i and spatial position possible

Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 struct { float rho; } node;

Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 node[0]. = 12 node[1]. = 15 node[2]. = 18 node[3]. = 21 node[4]. = 24 node[5]. = 27 node[6]. = 36 node[7]. = 39 node[8]. = 42 struct { long ; float rho; } node;

Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 node[0]. = 12 node[1]. = 15 node[2]. = 18 node[3]. = 21 node[4]. = 24 node[5]. = 27 node[6]. = 36 node[7]. = 39 node[8]. = 42 struct { long ; float rho; } node; no unique mapping between array inde i and spatial position possible

Irregular Grids handling irregular grids (1D) = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 N = 9 node[0]. = 12 node[1]. = 15 node[2]. = 18 node[3]. = 21 node[4]. = 24 node[5]. = 27 node[6]. = 36 node[7]. = 39 node[8]. = 42 struct { long ; float rho; } node; no unique mapping between array inde i and spatial position possible generate a meta-structure storing the geometry of the grid

Irregular Grids handling irregular grids (1D) quad s = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { float rho; } node;

Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { float rho; } node;

Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { float rho; } node;

Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { this node is addressed via (QUAD.node)+0 float rho; } node;

Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { this node is addressed via (QUAD.node)+1 float rho; } node;

Irregular Grids handling irregular grids (1D) quad s the memory for each array of nodes needs to be consecutively malloc() ed = 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 QUAD = (*node, 12, 6, *net) QUAD = (*node, 36, 3, *net) NULL struct { this node is addressed via (QUAD.node)+2 float rho; } node;

Irregular Grids handling irregular grids (2D) quad s

Irregular Grids handling irregular grids (2D) quad s the memory for each quad array needs to be malloc() ed consecutively

Irregular Grids handling irregular grids (2D) quad s store grid structures as a consecutive memory block each grid points to the first yquad which in turns gives access to all nodes grid #1 grid #1 grid #2 grid #3

Irregular Grids handling irregular grids (2D) quad s store grid structures as a consecutive memory block each grid points to the first yquad which in turns gives access to all nodes grid #2 grid #1 grid #2 grid #3 (pointer, y=1, length=3, net) (pointer, y=1, length=3, NULL) +1 (pointer, =1, length=2, net) (pointer, =1, length=2, NULL) +2 +1 (pointer, =4, length=2, net) (pointer, =1, length=2, net) (pointer, =5, length=2, NULL) (pointer, =4, length=2, net) (pointer, =9, length=1, NULL) (pointer, =8, length=2, NULL) (pointer, =7, length=3, NULL)

Irregular Grids handling irregular grids (3D) quad s too complicated to sketch

Irregular Grids handling irregular grids (3D) quad s C-code eample of how to loop over all nodes attached to a grid for (zquad=grid.first_zquad; zquad = NULL; zquad=zquad->net) { for (yquad=zquad->first_yquad; yquad < yquad->pointer+yquad->length; yquad++) for (iyquad=yquad; iyquad = NULL; iyquad=iyquad->net) { for (quad=yquad->first_quad; quad < quad->pointer+quad->length; quad++) for (iquad=quad; iquad = NULL; iquad=iquad->net) { for (node=iquad->pointer; node < iquad->+iquad->length; node++) { /* the node is at your disposal */ density = node->density; potential = node->potential; forcex = node->force[x]; for(part=node->first_particle; part = NULL; part=part->net) /* use particle structure to access particle position, velocity, etc. */ }}} loc = location of first quad

Irregular Grids handling irregular grids quad s drawback: no direct access to neighbouring nodes?

Irregular Grids handling irregular grids FTT other schemes possible: struct { NODE *daughter; float rho; } node; Fully-Threaded-Tree (FTT) by Khokhlov, 1998, J. Comp. Phy. 143, 519 (used with Andrey Kravtsov s ART code )

Irregular Grids handling irregular grids FTT other schemes possible: struct { NODE *daughter; float rho; } node; each cell stores pointers to 1 st daughter daughters are malloc() ed consecutively Fully-Threaded-Tree (FTT) by Khokhlov, 1998, J. Comp. Phy. 143, 519 (used with Andrey Kravtsov s ART code )

Itinerary mesh refinements adaptive mesh refinement adaptive mesh refinement for N-body codes handling irregular grids adaptive leap-frog integration

Adaptive Leap-Frog Integration full set of equations collisionless matter (e.g. dark matter) d DM = v DM dt leap-frog integration d v DM = φ dt AMR solver Poisson s equation Δφ = 4πGρ tot collisional matter (e.g. gas) ideal gas equations ρ t + ρ v ( ) = 0 p = ( γ 1)ρε ( ρ v ) t + ρ v v + p + 1 2µ B2 " 1 1 B B µ = ρ ( φ) ρε = ρe 1 2 ρv 2 ( ρe) t + ρe + p + 1 2µ B2 v 1 µ v B [ ] B = ρ v ( φ) + ( Γ L) Mawell s equation B t = v B ( )

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy AMR grids particles Δφ = 4πGρ tot d DM dt d v DM dt = v DM = φ

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy move particles on fine grids with smaller time step to better resolve the dynamics, too AMR grids particles Δφ = 4πGρ tot d DM dt d v DM dt = v DM = φ

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: fine grid coarse grid

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: Drift-Kick-Drift variant of the leap-frog integrator: time synchronisation between different grid levels rather than leap-frogging

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: 1. fine grid step: Drift : Kick : Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt p n +1/ 2 = p n Φ n +1/ 4 n +1/ 2 = n +1/ 4 + t n +Δt / 2 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: 2. coarse grid step: Drift : Kick : Drift : n +1/ 2 = n + t n +Δt / 2 p n p n +1 = p n Φ n +1/ 2 t n n +1 = n +1/ 2 + p n +1 dt t n +Δt t n t n +Δt dt dt t n +Δt / 2

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy fully recursive approach: 3. fine grid step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 1. fine grid DKD step: Drift : Kick : Drift : n +1/ 4 = n + t n +Δt / 4 p n t n dt p n +1/ 2 = p n Φ n +1/ 4 n +1/ 2 = n +1/ 4 + t n +Δt / 2 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 1. fine grid DKD step: Drift : Kick : Drift : n +1/ 4 = n + t n +Δt / 4 p n t n dt p n +1/ 2 = p n Φ n +1/ 4 n +1/ 2 = n +1/ 4 + t n +Δt / 2 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 2. coarse grid DKD step: Drift : Kick : Drift : n +1/ 2 = n + t n +Δt / 2 p n t n p n +1 = p n Φ n +1/ 2 n +1 = n +1/ 2 + p n +1 dt t n +Δt t n t n +Δt dt dt t n +Δt / 2

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 2. coarse grid DKD step: Drift : Kick : Drift : n +1/ 2 = n + t n +Δt / 2 p n t n p n +1 = p n Φ n +1/ 2 n +1 = n +1/ 2 + p n +1 dt t n +Δt t n t n +Δt dt dt t n +Δt / 2

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 3. fine grid DKD step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + t n +3Δt / 4 p n dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 3. fine grid DKD step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + t n +3Δt / 4 p n dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy 3. fine grid DKD step: Drift : Kick : Drift : n +3 / 4 = n +1/ 2 + t n +3Δt / 4 p n dt t n +Δt / 2 p n +1 = p n +1/ 2 Φ n +3 / 4 n +1 = n +3 / 4 + p n +1 t n +Δt t n +Δt dt t n +Δt / 2 dt t n +3Δt / 4 what about particles crossing grid boundaries?

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries particles can cross boundary during any of these steps... 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 2. coarse-grid drift 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 un-drift and move with coarse grid time step to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 2. coarse-grid drift do nothing as particle has reached t n+1 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 3. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 keep on drift ing as it will bring the particle to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 3. fine-grid step 1. Drift : n +1/ 4 = n + p n t n +Δt / 4 t n dt 3. Drift : n +3 / 4 = n +1/ 2 + p n t n +3Δt / 4 dt t n +Δt / 2 2. Drift : n +1/ 2 = n +1/ 4 + t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 4. Drift : n +1 = n +3 / 4 + p n +1 t n +Δt dt t n +3Δt / 4 keep on drift ing as it will bring the particle to t n+1

Adaptive Leap-Frog Integration moving particles on the AMR hierarchy particles crossing grid boundaries 1. Drift : 2. Drift : n +1/ 4 = n + p n n +1/ 2 = n +1/ 4 + t n +Δt / 4 t n dt t n +Δt / 2 p n +1/ 2 dt t n +Δt / 4 3. Drift : 4. Drift : n +3 / 4 = n +1/ 2 + p n n +1 = n +3 / 4 + p n +1 t n +3Δt / 4 all particles have now moved from t n to t n+1 and the refinements will be re-created... dt t n +Δt / 2 t n +Δt dt t n +3Δt / 4

Pseudo C-Code Step(dt, CurrentGrid) { NewGrid = Refine(CurrentGrid); if(newgrid) { Step(dt/2, NewGrid); } MoveParticles(dt, CurrentGrid); } if(newgrid) { Step(dt/2, NewGrid); DestroyGrid(NewGrid);}

AMIGA