Some solvers and matrix storage schemes provide capabilities for
significantly reducing memory usage when the coefficient matrix is
symmetric. In this situation, each off-diagonal coefficient appears
twice in the matrix, but only one copy needs to be stored. The
Struct
interface provides support for matrix and solver
implementations that use symmetric storage via the
SetSymmetric()
routine.
To describe this in more detail, consider again the 5-pt finite-volume
discretization of (3.1) on the grid pictured in Figure
3.1. Because the discretization is symmetric, only half
of the off-diagonal coefficients need to be stored. To turn symmetric
storage on, the following line of code needs to be inserted somewhere
between the Create()
and Initialize()
calls.
Note that symmetric storage may or may not actually be used, depending on the underlying storage scheme. Currently in HYPRE, symmetric storage is always used when indicated.HYPRE_StructMatrixSetSymmetric(A, 1);
To most efficiently utilize the Struct
interface for symmetric
matrices, notice that only half of the off-diagonal coefficients need
to be set. To do this for the example being considered, we simply
need to redefine the 5-pt stencil of Section
3.2 to an ``appropriate'' 3-pt stencil, then
set matrix coefficients (as in Section 3.3)
for these three stencil elements only. For example, we could
use the following stencil
This 3-pt stencil provides enough information to recover the full 5-pt stencil geometry and associated matrix coefficients.