# DMSNESSetFunction
set `SNES` residual evaluation function 
## Synopsis
```
#include "petscsnes.h" 
#include "petscdm.h" 
PetscErrorCode DMSNESSetFunction(DM dm, PetscErrorCode (*f)(SNES, Vec, Vec, void *), void *ctx)
```
Not Collective


## Input Parameters

- ***dm -*** DM to be used with `SNES`
- ***f -*** residual evaluation function; see `SNESFunction` for details
- ***ctx -*** context for residual evaluation





## Note
`SNESSetFunction()` is normally used, but it calls this function internally because the user context is actually
associated with the `DM`.  This makes the interface consistent regardless of whether the user interacts with a `DM` or
not.


## Developer Note
If `DM` took a more central role at some later date, this could become the primary method of setting the residual.


## See Also
 `DMSNESSetContext()`, `SNESSetFunction()`, `DMSNESSetJacobian()`, `SNESFunction`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/utils/dmsnes.c.html#DMSNESSetFunction">src/snes/utils/dmsnes.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/snes/utils/dmsnes.c)


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