# SNESSetType
Sets the method for the nonlinear solver. 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetType(SNES snes, SNESType type)
```
Collective on snes


## Input Parameters

- ***snes -*** the `SNES` context
- ***type -*** a known method



## Options Database Key

- ***-snes_type <type> -*** Sets the method; use -help for a list
of available methods (for instance, newtonls or newtontr)



## Notes
See "petsc/include/petscsnes.h" for available methods (for instance)

- ***`SNESNEWTONLS` -*** Newton's method with line search
(systems of nonlinear equations)
- ***`SNESNEWTONTRDC` -*** Newton's method with trust region
(systems of nonlinear equations)


Normally, it is best to use the `SNESSetFromOptions()` command and then
set the `SNES` solver type from the options database rather than by using
this routine.  Using the options database provides the user with
maximum flexibility in evaluating the many nonlinear solvers.
The `SNESSetType()` routine is provided for those situations where it
is necessary to set the nonlinear solver independently of the command
line or options database.  This might be the case, for example, when
the choice of solver changes during the execution of the program,
and the user's application is taking responsibility for choosing the
appropriate method.


## Developer Note
`SNESRegister()` adds a constructor for a new `SNESType` to `SNESList`, `SNESSetType()` locates
the constructor in that list and calls it to create the specific object.




## See Also
 `SNES`, `SNESSolve()`, `SNESType`, `SNESCreate()`, `SNESDestroy()`, `SNESGetType()`, `SNESSetFromOptions()`

## Level
intermediate

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex1.c.html">src/snes/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex35.c.html">src/snes/tutorials/ex35.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex9.c.html">src/snes/tutorials/ex9.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex22.c.html">src/ts/tutorials/ex22.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)  
