next up previous contents index
Next: 3.3 Setting Up the Up: 3 Structured-Grid System Interface Previous: 3.1 Setting Up the

3.2 Setting Up the Struct Stencil

 

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.

HYPRE_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]);
}
The 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.


next up previous contents index
Next: 3.3 Setting Up the Up: 3 Structured-Grid System Interface Previous: 3.1 Setting Up the

Thomas Treadway
Fri Jul 27 10:01:25 PDT 2001