SNESDefaultMatrixFreeMatCreate

Creates a matrix-free matrix context for use with a SNES solver. This matrix can be used as the Jacobian argument for the routine SNESSetJacobian().

Synopsis

int SNESDefaultMatrixFreeMatCreate(SNES snes,Vec x, Mat *J)
Collective on SNES and Vec

Input Parameters

snes - the SNES context
x - vector where SNES solution is to be stored.

Output Parameter

J -the matrix-free matrix

Notes

The matrix-free matrix context merely contains the function pointersand work space for performing finite difference approximations ofJacobian-vector products, J(u)*a, via

     J(u)*a = [J(u+h*a) - J(u)]/h where
     h = error_rel*u'a/||a||^2                        if  |u'a| > umin*||a||_{1}
       = error_rel*umin*sign(u'a)*||a||_{1}/||a||^2   otherwise
 where
     error_rel = square root of relative error in function evaluation
     umin = minimum iterate parameter

The user can set these parameters via SNESSetMatrixFreeParameters(). See the nonlinear solvers chapter of the users manual for details.

The user should call MatDestroy() when finished with the matrix- freematrix context.

Options Database Keys

-snes_mf_err <error_rel> - Sets error_rel
-snes_mf_unim <umin> - Sets umin

Keywords

SNES, default, matrix-free, create, matrix

See Also

MatDestroy(), SNESSetMatrixFreeParameters()

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