# SNESSetNGS
Sets the user nonlinear Gauss-Seidel routine for use with composed nonlinear solvers. 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetNGS(SNES snes, PetscErrorCode (*f)(SNES, Vec, Vec, void *), void *ctx)
```

## Input Parameters

- ***snes   -*** the SNES context
- ***f -*** function evaluation routine to apply Gauss-Seidel see `SNESNGSFunction`
- ***ctx    -*** [optional] user-defined context for private data for the
smoother evaluation routine (may be NULL)



## Calling sequence of f
```none
PetscErrorCode f(SNES snes,Vec X,Vec B,void *ctx);
```


## Arguments of f

- ***snes -*** the `SNES` context
- ***X -*** the current solution
- ***B -*** the right hand side vector (which may be NULL)
- ***ctx -*** a user provided context



## Note
The `SNESNGS` routines are used by the composed nonlinear solver to generate
a problem appropriate update to the solution, particularly `SNESFAS`.




## See Also
 `SNESGetNGS()`, `SNESNGSFunction`, `SNESNCG`, `SNESGetFunction()`, `SNESComputeNGS()`

## Level
intermediate

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex15.c.html">src/snes/tutorials/ex15.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex16.c.html">src/snes/tutorials/ex16.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex19.c.html">src/snes/tutorials/ex19.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex5.c.html">src/snes/tutorials/ex5.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex55.c.html">src/snes/tutorials/ex55.c.html</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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
