wiki:AmrExplained

Version 7 (modified by trac, 12 years ago) ( diff )

Terminology

Root Level Grid
The coarsest representation of the data and exists everywhere inside the problem domain (like a fixed grid)
Level 0 Grid
Root Level Grids (cell width is dX(0))
Level 1 Grids
Grids that overlay level 0 Grids where more refinement is required. Each level 1 cell has a width dX(1) = dX(0)/CoarsenRatio(0)
MaxLevel
The level of maximum refinement.
CoarsenRatio()
Array that stores the refinement ratio of each level. Almost always set to 2 for every level
Children
These are refined grids that overlay a single coarser grid. AstroBear uses nested grids which means that every refined grid lays entirely inside of a single coarser grid.
Parent
This is the coarser grid that each child grid lies within. Note that Root Grids have no Parents, and that Level MaxLevel Grids have no Children.
GrandParent
The parent node of a given node's parent
GrandChild
The children of a given grid child
Great Uncle
The sibling of a given grid's Parent
Siblings
Children of the same parents. While the Root Level Grids technically have no parents, they are still considered siblings.
Uncles
Grids that are siblings of parent's.
Nephews
Grids that are the children of siblings.
Cousins
Grids that are the children of parent's siblings. (Or 2nd cousins if they are children of parent's cousins and so on…)
Finest Level Data Representation (FLDR)
This is all data that has not been overlayed with a finer grid.
Improper Nesting
When any level N grid is not complete surrounded by level N-1 grids. (Or when adjacent data on the FLDR is separated by more then 1 level.)
Internal Region
The region each grid is responsible for updating each hyperbolic step.
Ghost Region
The region around each grid that is buffered so that each grid can independently complete the required hyperbolic step(s).
Neighbors
Grids that are either cousins or siblings. (Grids that belong to the same level) - and share a common edge (or face in 3D)
Touching Grids
Same Level Grids that share a common corner (or edge in 3D)
Nearby Grids
Same Level Grids that are close enough so that the Ghost Region of one grid overlaps the internal region of another.
Ideal Stencil
Different grids on the same level will always calculate the same values for fluxes at shared boundaries. (No edge effects)
Coincident Data
Data that has multiple representations (on different grids or different levels), though refers to the same physical quantity (density in a given region)
Consistent
Ensure that Coincident Data has the same value (ie coarse values for density are averages of the finer values - and fluxes used by two grids on the same level are identical)
Conservative
Ensure that any conserved quantity (mass, momentum, energy) on the FLDR is conserved when it leaves one level for another.


Achieving Conservation and Consistency

Since the hyperbolic step on each AMR level requires flux calculation and application at cell edges/faces as well as source terms at cell centers, the code must achieve intralevel and interlevel synchronization to maintain conservative and consistent updates. There are basically two approaches for doing this.

The following assume 2D, but 3D just requires edges→faces and corners→edges.

Interlevel Synchronization

While Children can share boundaries with their parents and therefore be adjacent to their uncles (or grandparents), it is often easier to achieve child-uncle (child-grandparent) synchronization via their parents. One advantage of nested grids is that intralevel synchronization is reduced to child parent synchronization. Their are two ways to achieve this:

  • Flux/Source synchronization - Store all of the fluxes at cell edges and source terms at cell centers so they can be updated by finer level data (or merged with same level data) before being applied (and then sent to lower levels). (Nice and clean but memory intensive for hydro vars)
  • Cell Synchronization - Coarsening fluxes and source terms are unnecessary; just coarsen the final updated values on the finer level, which automatically enforces consistency. To enforce interlevel conservation, use both levels to 'store' fluxes at FLDR interlevel interfaces. These will alyways occur at the outer edge of the finer level grids, but may happen anywhere within a coarser grid. Currently AstroBear stores these finer level outer edge fluxes in Info%fixupflux, and coarse flux versions in Info%q by not adding them in the first place.

Intralevel Synchronization

While a fixed grid code using an ideal stencil would not require any intralevel synchronization (since both grids would calculate identical fluxes) - minor assumptions are sometimes made near grid edges to reduce ghost cell communication (slope limiters etc…). Even without those assumptions, an AMR grid code using an ideal stencil would still need to achieve child-uncle synchronization. Since child-parent synchronization exists, parent-uncle synchronization reduces to intralevel synchronization.

Interlevel synchronization requires most grids (those with parents) to store their fluxes at the outer edge. Intralevel synchronization additionally requires every grid (or neighbors) with children to store their exterior fluxes. The only additional need is to store exterior fluxes on the root grid; i.e., Interlevel synchronization required every level > 0 to store the fluxes at the grid edges, and intralevel synchronization requires every level < MaxLevel to store the fluxes at the grid edges. Thus, an ideal fixed grid calculation is the only one that does not require grids to store the fluxes at the outer edge.

How to synchronize intralevel fluxes

  • With interlevel synchronization, the finer level data is assumed to be more accurate and the synchronization of the two levels is simply achieved by replacing the coarse values with the fine ones.
  • With intralevel synchronization it is not as obvious. Since there are always exactly two siblings that share a flux, there are only three different possible scenarios
    • If both grids have refined values for fluxes, and if those refined values were synchronized on the finer level first, then nothing has to be done.
    • If neither grid has refined values then both should be equally valid (and identical for an ideal stencil) and a simple averaging can be done.
    • If only one of the grids has refined values, then that value should be used by both grids.
  • The first two can be achieved by simple averaging - but the third scenario requires the uncle to have knowledge of the nephew. Ghosting ChildMask makes this possible.

AMR Necessity

Using an ideal stencil, intralevel synchronization only becomes the means to achieving interlevel synchronization. It may not seem necessary as non-gradient flows calculate the same fluxes regardless of cell size. It is not required at all if FLDR interlevel interfaces were always mbc coarse cells away from any gradients. However, completely refining regions with any gradient at all does not effectively utilities AMR's capabilities.

AMR ideally makes coarse approximations—thereby introducing small errors—in some places, allowing for more accurate approximations in other places that would otherwise introduce much greater errors. These small errors might not cripple a hydrodynamic simulation, but the equivalent errors in MHD can.

MHD

Magnetic field evolution is subject to a constraint similar to those placed on fluid variable conservation (mass, momentum, and total energy densities). However, this constraint differs; since mass momentum and energy are conserved quantities, this naturally leads to an expression of the change per cell per time step cast solely as a divergence. Gauss's theorem allows for divergence calculation in the form of surface fluxes. Computed surface fluxes (while containing errors) remain globally conservative, since material that leaves one cell must enter another.

Magnetic fields are not conserved like density, but their divergence is. As a result, the expressions for changes per 'cell' per time step can be expressed solely as a curl. Stokes theorem allows for curls to be expressed as line integrals and the divergence of B can be preserved by storing each component of the B-fields on the corresponding face of each cell and calculating the EMF's along the edges. Thus, just as cell centered values need to be consistent and conservative for hydro, face centered variables need to be consistent and EMF's must be used conservatively.

Note: See TracWiki for help on using the wiki.