The geometry of the discretization stencil is described by an array of integer tuples in 2D (triples in 3D), each representing a relative offset (in index space) from some gridpoint on the grid. For example, the geometry of the 5-pt stencil for the example problem being considered can be represented in the following way:
In (3.2), the (0,0) entry represents the
``center'' coefficient, and is the 0th entry in the array ( ).
The (0,-1) entry represents the ``south'' coefficient, and is the
3rd entry in the array (
). And so on.
On process 0 or 1, the following code will set up the stencil in (3.2). The stencil must be the same on all processes.
TheHYPRE_StructStencil stencil; int offsets[5][2] = {{0,0}, {-1,0}, {1,0}, {0,-1}, {0,1}}; int s; HYPRE_StructStencilCreate(2, 5, &stencil); for (s = 0; s < 5; s++) { HYPRE_StructStencilSetElement(stencil, s, offsets[s]); }
Create()
routine creates an empty 2D, 5-pt stencil object.
The SetElement()
routine defines the geometry of the stencil
and assigns the array numbers for each of the stencil entries. None
of the calls are collective calls.