next up previous contents index
Next: 4.3 Setting Up the Up: 4. Semi-Structured-Grid System Interface Previous: 4.1 Setting Up the   Contents   Index


4.2 Setting Up the SStruct 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 9-pt stencil for the example problem being considered can be represented in the following way:

\begin{displaymath}
\left [
\begin{array}{ccc}
(-1, 1) & ( 0, 1) & ( 1, 1) \\
(...
... \\
S_1 & S_0 & S_2 \\
S_5 & S_3 & S_6
\end{array}\right ] .
\end{displaymath} (4.2)

In (3.2), the $(0,0)$ entry represents the ``center'' coefficient, and is the 0th entry in the array ($S_0$). The $(0,-1)$ entry represents the ``south'' coefficient, and is the 3rd entry in the array ($S_3$). And so on.

On process 0, 1, or 2, the following code will set up the stencil in (3.2).

HYPRE_SStructStencil stencil;
int                  s;
int                  offsets[9][2] = {{0,0},
                                      {-1, 0}, { 1, 0}, { 0,-1}, { 0, 1}};
                                      {-1,-1}, { 1,-1}, {-1, 1}, { 1, 1}};

HYPRE_SStructStencilCreate(2, 9, &stencil);

for (s = 0; s < 9; s++)
   HYPRE_SStructStencilSetEntry(stencil, s, offsets[s], 0);
The Create() routine creates an empty 2D, 9-pt stencil object. The SetEntry() 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: 4.3 Setting Up the Up: 4. Semi-Structured-Grid System Interface Previous: 4.1 Setting Up the   Contents   Index
Tom Treadway 2003-10-22