# DMStagVecGetValuesStencil
get vector values using grid indexing 
## Synopsis
```
PetscErrorCode DMStagVecGetValuesStencil(DM dm, Vec vec, PetscInt n, const DMStagStencil *pos, PetscScalar *val)
```
Not Collective


## Input Parameters

- ***dm -*** the DMStag object
- ***vec -*** the vector object
- ***n -*** the number of values to obtain
- ***pos -*** locations to obtain values from (as an array of `DMStagStencil` values)



## Output Parameter

- ***val -*** value at the point



## Notes
Accepts stencils which refer to global element numbers, but
only allows access to entries in the local representation (including ghosts).

This approach is not as efficient as getting values directly with `DMStagVecGetArray()`,
which is recommended for matrix free operators.




## See Also
 `DMSTAG`, `DMStagStencil`, `DMStagStencilLocation`, `DMStagVecSetValuesStencil()`, `DMStagMatSetValuesStencil()`, `DMStagVecGetArray()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/stagstencil.c.html#DMStagVecGetValuesStencil">src/dm/impls/stag/stagstencil.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex1.c.html">src/dm/impls/stag/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex4.c.html">src/dm/impls/stag/tutorials/ex4.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex6.c.html">src/dm/impls/stag/tutorials/ex6.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/impls/stag/stagstencil.c)


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