AMR Grid Datastructure

Common to all of the AMR readers is an AmrGrid informational datastructure. This datastructure is not necessary for the AMRwriter. This structure stores all of the AMR parameters related to the grid that enable you to determine where it should fit into the AMR hierarchy, the type of data that it stores and the rank, dimensions, and physical size of the grid. It also has a pointer which can be used optionally to store the grid data.

The structure has both a C and a C++ representation. The only difference between the two is that the C structure represents the datatype as an integer and the C++ version represents the datatype as an enum. Since the C++ struct is inherited directly from the C version, the two interoperate seamlessly.

Datastructure Specification

C Datastructure C++ Datastructure
typedef struct AmrGrid {          
  int level;
  int maxlevel;
  int maxtime;
  int timestep;
  int persistence; 
  int rank;
  int dims[3];
  double delta[3];
  double origin[3];
  int timerefinement;
  int nbytes;
  int dataveclen;
  int datatype;
  void *data;
} AmrGrid;
struct AmrGrid {
  // Members inherited from C AmrGrid 
  int level;
  int maxlevel;
  int maxtime;
  int timestep;
  int persistence; 
  int rank;
  int dims[3];
  double delta[3];
  double origin[3];
  int timerefinement;
  int nbytes;
  int dataveclen;
  void *data;
  // Members specific to C++ AmrGrid  
  IObase::DataType datatype;
};

Datastructure Member Descriptions

int level
The level in the AMR hierarchy. Level 0 is the Top (least refined) level.
int maxlevel
The maximum number of levels in the AMR hierarchy for all timesteps stored in this file. Levels are numbered from 0 to maxlevel-1.
int maxtime
Maximum timestep in the datafile. This parameter is optional (and generally unused) and will be removed from future releases.
int timestep
This is the current integer timestep with respect to the finest granularity timestep that can occur in the file. It is not necessarily uniform in time. It simply delineates the order in which things change in the file. It is a fundamental parameter written by the AMRwriter.
int persistence
This is the number of timesteps that the grid remains active from the timestep that it is created. Like the timestep parameter, it can also be non-uniform. It is an optional parameter that is often automatically computed by the AMRreader class from available data.
int rank
The number of dimensions for the grid. Currently you cannot mix grids of different dimensions together (ie. a 2D grid cannot be embedded in a 3D grid), so if one grid is rank=3, then all of the grids in the file must have the same rank.
int dims[3]
The dimensions of the grid (only the first rank values of this array will be filled).
double delta[3]
The physical spacing between gridpoints. This is actually redundant information since the same information can be inferred/computed from the origin and integer refinement information. It is there for convenience though even though it is not as precise as the integer specification.
double origin[3]
The physical origin (minimum extent in 3-space) of the grid.
int timerefinement
The rate at which the grid steps at this level with respect to the topgrid. This is an optional parameter and will likely be dropped from future implementations of this system.
int nbytes
Number of bytes of storage required for the grid data if it were loaded into memory.. This is useful for memory allocation/management.
int dataveclen
The number of elements-per-point in the data. For instance a 3D vector velocity field would have a dataveclen=3 for the i,j,k direction of the vector components. dataveclen=1 for all scalar values like density and temperature. Currently this is not used, but will be in future implementations of the readers.
int/IObase::DataType datatype
The type of the data as it is stored on disk. This is represented as an integer for C and as an enum of type IObase::DataType for C++. The definitions for the datatypes are defined by the FlexIO libraries. Integer datatypes are implemented in IO.h and the C++ IObase::DataType is implemented in IO.hh.
void *data
Pointer to memory array storing the data. This is NULL if the data has not been loaded into memory. So you can use this datastructure just to aquire information about the grids and then load the data only when it is needed.

Last modified: Thu Jan 28 17:14:34 CST 1999