# running option: with -snes_mf and without -snes_mf

(Rebecca) Xuefei YUAN xy2102 at columbia.edu
Tue Feb 24 18:58:23 CST 2009

```Hi,

I was writing a FormJacobianLocal() as a part of my project, however,
I found that the result from two sets of running options (one with
-snes_mf and one without it) are not the same, and they are not even
close to each other. (The running result could be seen at the bottom
of this email.)

I believe there is sth wrong with my jacobian matrix and I double
checked with my lines and cannot find what's wrong, so I am starting
to debug the code in gdb.

The difference between two codes are happened at MatMult which is
located at SNESSolve_LS -- SNES_KSPSolve -- KSPSolve_FGMRES --
FGMREScycle -- MatMult.

With jacobian matrix given, it calls MatMult_Inode and with matrix
free, it calls MatMult_MFFD.

Any suggestions if I would like to track why and how those two give
different results?

Moreover, besides the reference "A Flexible Inner-Outer Preconditioned
GMRES Algorithm" by Y. Saad 1993, is there any other references those
codes(especially SNESSolve_LS) based on?

Or is there an already written algorithm for SNESSolve_LS()?

Thanks a lot!

with -snes_mf:
--------------------------------------------
**************************************************
0 SNES Function norm 1.413389226096e+00
0 KSP Residual norm 1.413389226096e+00
1 KSP Residual norm 8.949990968008e-03
2 KSP Residual norm 1.701213729481e-11
1 SNES Function norm 2.550842882967e-09
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE
**************************************************
time step = 1
time = 1.0000000000000000e+00
number of nonlinear iterations = 1
number of linear iterations = 2
function norm = 2.5508428829673858e-09
-----------------------------------------------
without -snes_mf**************************************************
0 SNES Function norm 1.413389226096e+00
0 KSP Residual norm 1.413389226096e+00
1 KSP Residual norm 1.417239245196e-03
2 KSP Residual norm 2.565960913946e-06
1 SNES Function norm 9.641118499860e-03
0 KSP Residual norm 9.641118499860e-03
1 KSP Residual norm 1.434927485205e-05
2 KSP Residual norm 2.360672583502e-09
2 SNES Function norm 1.310213342315e-04
0 KSP Residual norm 1.310213342315e-04
1 KSP Residual norm 1.466288489933e-07
2 KSP Residual norm 9.025797759583e-11
3 SNES Function norm 1.769344613096e-06
0 KSP Residual norm 1.769344613096e-06
1 KSP Residual norm 2.167360853642e-09
2 KSP Residual norm 5.034113683896e-13
4 SNES Function norm 2.351612245726e-08
Nonlinear solve converged due to CONVERGED_PNORM_RELATIVE
**************************************************
time step = 1
time = 1.0000000000000000e+00
number of nonlinear iterations = 4
number of linear iterations = 8
function norm = 2.3516122457259199e-08
**************************************************

-----------------------------------------------

-R

```