Skip to main content
`Ctrl`+`K`

# SNESSetComputeApplicationContext

Sets an optional function to compute a user-defined context for the nonlinear solvers.

## Synopsis

    #include "petscsnes.h"
    #include "petscsnes.h"
    PetscErrorCode SNESSetComputeApplicationContext(SNES snes, PetscErrorCode (*compute)(SNES snes, PetscCtxRt ctx), PetscCtxDestroyFn *destroy)

Logically Collective; No Fortran Support

## Input Parameters

- snes - the `SNES` context

- compute - function to compute the context

- destroy - function to destroy the context, see `PetscCtxDestroyFn` for the calling sequence

## Calling sequence of `compute`

- snes - the `SNES` context

- ctx - context to be computed

## 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

SNES: Nonlinear Solvers, `SNESGetApplicationContext()`, `SNESSetApplicationContext()`, `PetscCtxDestroyFn`

## Level

intermediate

## Location

src/snes/interface/snes.c

## Examples

src/snes/tutorials/ex58.c

Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages