The grid is described via a global index space, i.e., via integer tuples (triples in 3D). The integers may have any value, negative or positive. The global indexes allow HYPRE to discern how data is related spatially, and how it is distributed across the parallel machine. Each process describes that portion of the grid that it ``owns'', one box at a time. For example, in the figure, the global grid can be described in terms of three boxes, two owned by process 0, and one owned by process 1. A box is described in terms of a lower and upper index.
On process 0, the following code will set up the grid shown in the figure (the code for process 1 is similar).
TheHYPRE_StructGrid grid; int ilower[2][2] = {{-3, 1}, {0, 1}}; int iupper[2][2] = {{-1, 2}, {2, 4}}; HYPRE_StructGridCreate(MPI_COMM_WORLD, 2, &grid); HYPRE_StructGridSetExtents(grid, ilower[0], iupper[0]); HYPRE_StructGridSetExtents(grid, ilower[1], iupper[1]); HYPRE_StructGridAssemble(grid);
Create()
routine creates an empty 2D grid object that lives
on the MPI_COMM_WORLD
communicator. The SetExtents()
routine adds a new box to the grid. The Assemble()
routine is
a collective call (i.e., must be called on all processes from a common
synchronization point), and finalizes the grid assembly, making the
grid ``ready to use''.