:orphan:
# SNESSetComputeApplicationContext
Sets an optional function to compute a user-defined context for the nonlinear solvers. 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetComputeApplicationContext(SNES snes, PetscErrorCode (*compute)(SNES, void **), PetscErrorCode (*destroy)(void **))
```
Logically Collective; No Fortran Support


## Input Parameters

- ***snes -*** the `SNES` context
- ***compute -*** function to compute the context
- ***destroy -*** function to destroy the context





## Note
This routine is useful if you are performing grid sequencing or using `SNESFAS` and need the appropriate context generated for each level.

Use `SNESSetApplicationContext()` to see the context immediately


## See Also
 [](ch_snes), `SNESGetApplicationContext()`, `SNESSetComputeApplicationContext()`, `SNESSetApplicationContext()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/interface/snes.c.html#SNESSetComputeApplicationContext">src/snes/interface/snes.c</A>

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


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


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