MatCreateMF

Creates a matrix-free matrix. See also MatCreateSNESMF()

Synopsis

#include "petscsnes.h"   
int MatCreateMF(Vec x,Mat *J)
Collective on Vec

Input Parameters

x -vector that defines layout of the vectors and matrices

Output Parameter

J -the matrix-free matrix

Notes

The matrix-free matrix context merely contains the function pointers and work space for performing finite difference approximations of Jacobian-vector products, F'(u)*a,

The default code uses the following approach to compute h

     F'(u)*a = [F(u+h*a) - F(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 the error_rel via MatSNESMFSetFunctionError() and umin via MatSNESMFDefaultSetUmin(); see the nonlinear solvers chapter of the users manual for details.

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

Options Database Keys

-snes_mf_err <error_rel> - Sets error_rel
-snes_mf_unim <umin> - Sets umin (for default PETSc routine that computes h only)
-snes_mf_ksp_monitor - KSP monitor routine that prints differencing h
-snes_mf_check_positivity-

Keywords

default, matrix-free, create, matrix

See Also

MatDestroy(), MatSNESMFSetFunctionError(), MatSNESMFDefaultSetUmin()
MatSNESMFSetHHistory(), MatSNESMFResetHHistory(), MatCreateSNESMF(), MatSNESMFGetH(),MatSNESMFKSPMonitor(), MatSNESMFRegisterDynamic),, MatSNESMFComputeJacobian()

Level:advanced
Location:
src/snes/mf/snesmfj.c
Index of all SNESMF routines
Table of Contents for all manual pages
Index of all manual pages