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


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:

\begin{displaymath}
\left [
\begin{array}{ccc}
& ( 0, 1) & \\
(-1, 0) & ( 0, 0...
... S_4 & \\
S_1 & S_0 & S_2 \\
& S_3 &
\end{array}\right ] .
\end{displaymath} (3.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 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   Contents   Index
Tom Treadway 2003-10-22