petsc-3.8.4 2018-03-24
Report Typos and Errors


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().


#include "petscsnes.h"   
PetscErrorCode  SNESDefaultMatrixFreeCreate2(SNES snes,Vec x,Mat *J)

Input Parameters

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

Output Parameter

J -the matrix-free matrix


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

      J(u)*a = [J(u+h*a) - J(u)]/h,
  where by default
       h = error_rel*u'a/||a||^2                        if  |u'a| > umin*||a||_{1}
         = error_rel*umin*sign(u'a)*||a||_{1}/||a||^2   otherwise
       error_rel = square root of relative error in
                   function evaluation
       umin = minimum iterate parameter
  Alternatively, the differencing parameter, h, can be set using
  Jorge's nifty new strategy if one specifies the option

The user can set these parameters via MatMFFDSetFunctionError(). See Users-Manual: ch_snes for details

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

Options Database Keys

 -snes_mf_err <error_rel>
 -snes_mf_unim <umin>
 -snes_mf_freq_err <freq>


SNES, default, matrix-free, create, matrix

See Also

MatDestroy(), MatMFFDSetFunctionError()

Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages