petsc-3.7.1 2016-05-15
Report Typos and Errors

MatCreateMFFD

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

Synopsis

#include "petscmat.h"   
PetscErrorCode  MatCreateMFFD(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *J)
Collective on Vec Many br

Input Parameters

comm - MPI communicator Many br
m - number of local rows (or PETSC_DECIDE to have calculated if M is given) Many brThis value should be the same as the local size used in creating the Many bry vector for the matrix-vector product y = Ax. Many br
n - This value should be the same as the local size used in creating the Many brx vector for the matrix-vector product y = Ax. (or PETSC_DECIDE to have Many brcalculated if N is given) For square matrices n is almost always m. Many br
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given) Many br
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given) Many br

Output Parameter

J -the matrix-free matrix Many br

Options Database Keys: call MatSetFromOptions() to trigger these Many br

-mat_mffd_type - wp or ds (see MATMFFD_WP or MATMFFD_DS) Many br
-mat_mffd_err - square root of estimated relative error in function evaluation Many br
-mat_mffd_period -how often h is recomputed, defaults to 1, everytime Many br

Many br

Notes

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

The default code uses the following approach to compute h Many br

     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
Many br

You can call SNESSetJacobian() with MatMFFDComputeJacobian() if you are using matrix and not a different Many brpreconditioner matrix Many br

The user can set the error_rel via MatMFFDSetFunctionError() and Many brumin via MatMFFDDSSetUmin(); see Users-Manual: ch_snes for details. Many br

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

Options Database Keys

-mat_mffd_err <error_rel> - Sets error_rel Many br
-mat_mffd_unim <umin> - Sets umin (for default PETSc routine that computes h only) Many br
-mat_mffd_check_positivity- Many br

Keywords

default, matrix-free, create, matrix

See Also

MatDestroy(), MatMFFDSetFunctionError(), MatMFFDDSSetUmin(), MatMFFDSetFunction()
MatMFFDSetHHistory(), MatMFFDResetHHistory(), MatCreateSNESMF(), Many brMatMFFDGetH(), MatMFFDRegister(), MatMFFDComputeJacobian() Many br

Level:advanced
Location:
src/mat/impls/mffd/mffd.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/snes/examples/tutorials/ex22.c.html