# MatSetStencil
Sets the grid information for setting values into a matrix via `MatSetValuesStencil()` 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatSetStencil(Mat mat, PetscInt dim, const PetscInt dims[], const PetscInt starts[], PetscInt dof)
```
Not Collective


## Input Parameters

- ***mat -*** the matrix
- ***dim -*** dimension of the grid 1, 2, or 3
- ***dims -*** number of grid points in x, y, and z direction, including ghost points on your processor
- ***starts -*** starting point of ghost nodes on your processor in x, y, and z direction
- ***dof -*** number of degrees of freedom per node





## Notes
Inspired by the structured grid interface to the HYPRE package
(www.llnl.gov/CASC/hyper)

For matrices generated with `DMCreateMatrix()` this routine is automatically called and so not needed by the
user.


## See Also
 `Mat`, `MatStencil`, `MatSetOption()`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValuesBlocked()`, `MatSetValuesLocal()`
`MatSetValues()`, `MatSetValuesBlockedStencil()`, `MatSetValuesStencil()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatSetStencil">src/mat/interface/matrix.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex48.c.html">src/snes/tutorials/ex48.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
