Afivo  0.3
Important data structures

Box data type

A box is the basic mesh unit in Afivo, see m_af_types::box_t. Each box consists of \(N^D\) grid cells, where \(N\) has to be an even number and \(D\) is the spatial dimension.

Two types of cell data are supported: cell-centered (cc) data and face-centered (fc) data. For example, in 2D cc(i, j, n) selects the nth variable at cell (i,j), whereas fc(i, j, dim, n) selects the nth face-centered variable in direction dim. A box contains one layer of ghost cells for its cell-centered variables, are illustrated in the figure below. How these ghost cells are filled is discussed in Filling ghost cells.

Boxes store their neighbors, their children and their parent. A special value m_af_types::af_no_box (which is zero) is used to indicate that a parent, child or neighbor does not exist. In the case of neighbors, physical boundary conditions are specified by m_af_types::af_phys_boundary (which is -1).

Furthermore, boxes contain some convenience information, such at their refinement level, minimum coordinate and spatial index.

Level data type

The level data type (see m_af_types::lvl_t) contains three lists:

  • A list with all the boxes at refinement level \(l\)
  • A list with the parents (boxes that are refined) at level \(l\)
  • A list with the leaves (boxes that are not refined) at level \(l\)

This separation is often convenient, because some algorithms operate only on leaves while others operate on parents or on all boxes. These lists contain the integer indices of the boxes in the tree data structure described below.

Tree data type

The tree data type contains all the data of the mesh, see m_af_types::af_t. Most importantly, it stores two arrays: one that contains all the boxes and one that contains all the levels.

Some other information is also stored: the current maximum refinement level, the number of cells per box-dimension \(N\), the number of face and cell-centered variables and the grid spacing \(\Delta x\) at the coarsest level.