Skip to main content
`Ctrl`+`K`

# MatStencil

Data structure (C struct) for storing information about rows and columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`

## Synopsis

    typedef struct {
      PetscInt k, j, i, c;
    } MatStencil;

## Notes

The i,j, and k represent the logical coordinates over the entire grid (for 2 and 1 dimensional problems the k and j entries are ignored). The c represents the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored.

For stencil access to vectors see `DMDAVecGetArray()`

For staggered grids, see `DMStagStencil`

## See Also

Matrices, `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()` `DMStagStencil`

## Level

beginner

## Location

include/petscmat.h

## Examples

src/ksp/ksp/tutorials/ex45.c
src/dm/impls/stag/tutorials/ex1.c
src/ksp/ksp/tutorials/ex32.c
src/dm/tutorials/ex14.c
src/ksp/ksp/tutorials/ex43.c
src/ksp/ksp/tutorials/ex42.c
src/dm/tutorials/ex22.c
src/dm/tutorials/ex25.c
src/ksp/ksp/tutorials/ex25.c
src/ksp/ksp/tutorials/ex28.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages