next up previous contents index
Next: 4.5 Setting Up the Up: 4 Semi-Structured-Grid System Interface Previous: 4.3 Setting Up the

4.4 Setting Up the SStruct Matrix

 

The matrix is set up in terms of the graph object described in Section 4.3 above. The coefficients associated with each graph entry will typically vary from gridpoint to gridpoint, but in the example problem being considered, they are as follows over the entire grid (except at boundaries; see below):

 

On process 0, the following code will set up matrix values associated with the center ( ) and south ( ) stencil entries in (3.2) / (3.3). Matrix values associated with the non-stencil graph entries are also set up.

HYPRE_SStructMatrix  A;
double               values[32];
int                  sindices[2] = {0,3};
int                  gindices[4] = {9,10,11,0};
int                  i;

HYPRE_SStructMatrixCreate(MPI_COMM_WORLD, graph, &A);
HYPRE_SStructMatrixInitialize(A);

for (i = 0; i < 32; i += 2)
{
   values[i]   =  8.0;
   values[i+1] = -1.0;
}
HYPRE_SStructMatrixSetBoxValues(A, 0, ilower[0], iupper[0], 0,
                                2, sindices, values);

/* set values at non-stencil graph entries */
for (i = 0; i < 3; i++)
{
   values[i] = -1.0;
}
HYPRE_SStructMatrixSetValues(A, 0, addindex[0], 0, 2, gindices, values);
HYPRE_SStructMatrixSetValues(A, 0, addindex[1], 0, 3, gindices, values);
HYPRE_SStructMatrixSetValues(A, 0, addindex[2], 0, 3, gindices, values);
...
HYPRE_SStructMatrixSetValues(A, 0, addindex[7], 0, 1, gindices, values);
HYPRE_SStructMatrixSetValues(A, 0, addindex[7], 1, 1, &gindices[3], values);

/* zero out coefficients that reach outside of the domain or grid part */
...

/* set boundary conditions at domain boundaries, */
...

HYPRE_SStructMatrixAssemble(A);

next up previous contents index
Next: 4.5 Setting Up the Up: 4 Semi-Structured-Grid System Interface Previous: 4.3 Setting Up the

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