# PCHYPRESetDiscreteGradient
Set discrete gradient matrix for `PCHYPRE` type of ams or ads 
## Synopsis
```
#include "petscpc.h" 
PetscErrorCode PCHYPRESetDiscreteGradient(PC pc, Mat G)
```
Collective on pc


## Input Parameters

- ***pc -*** the preconditioning context
- ***G -*** the discrete gradient





## Notes
G should have as many rows as the number of edges and as many columns as the number of vertices in the mesh

Each row of G has 2 nonzeros, with column indexes being the global indexes of edge's endpoints: matrix entries are +1 and -1 depending on edge orientation


## Developer Note
This automatically converts the matrix to `MATHYPRE` if it is not already of that type


## See Also
 `PCHYPRE`, `PCHYPRESetDiscreteCurl()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/impls/hypre/hypre.c.html#PCHYPRESetDiscreteGradient">src/ksp/pc/impls/hypre/hypre.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/impls/hypre/hypre.c.html#PCHYPRESetDiscreteGradient_HYPRE">PCHYPRESetDiscreteGradient_HYPRE in src/ksp/pc/impls/hypre/hypre.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/pc/impls/hypre/hypre.c)


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