SNESSetFunction

Sets the function evaluation routine and function vector for use by the SNES routines in solving systems of nonlinear equations.

Synopsis

#include "snes.h"  
int SNESSetFunction(SNES snes,Vec r,int (*func)(SNES,Vec,Vec,void*),void *ctx)
Collective on SNES

Input Parameters

snes - the SNES context
func - function evaluation routine
r - vector to store function value
ctx - [optional] user-defined context for private data for the function evaluation routine (may be PETSC_NULL)

Calling sequence of func

   func (SNES snes,Vec x,Vec f,void *ctx);

f -function vector
ctx -optional user-defined function context

Notes

The Newton-like methods typically solve linear systems of the form
     f'(x) x = -f(x),
where f'(x) denotes the Jacobian matrix and f(x) is the function.

SNESSetFunction() is valid for SNES_NONLINEAR_EQUATIONS methods only. Analogous routines for SNES_UNCONSTRAINED_MINIMIZATION methods are SNESSetMinimizationFunction() and SNESSetGradient();

Keywords

SNES, nonlinear, set, function

See Also

SNESGetFunction(), SNESComputeFunction(), SNESSetJacobian()

Examples

src/snes/examples/tutorials/ex1f.F
src/snes/examples/tutorials/ex4f.F
src/snes/examples/tutorials/ex5f.F
src/snes/examples/tutorials/ex5f90.F
src/snes/examples/tutorials/ex4.c
src/snes/examples/tutorials/ex1.c
src/snes/examples/tutorials/ex2.c
src/snes/examples/tutorials/ex5.c
src/snes/examples/tutorials/ex3.c
src/snes/examples/tutorials/ex6.c
src/snes/examples/tutorials/ex12.c
src/snes/examples/tutorials/ex5s.c
src/snes/examples/tutorials/ex7.c
src/snes/examples/tutorials/ex8.c
src/snes/examples/tutorials/ex13.c
src/snes/examples/tutorials/ex9.c
src/snes/examples/tutorials/ex14.c
src/snes/examples/tutorials/ex15.c
src/snes/examples/tutorials/ex5c.c
src/snes/examples/tutorials/ex16.c
src/snes/examples/tutorials/ex5d.c

Level:beginner
Location:src/snes/interface/snes.c
SNES Index
Table of Contents