>> Now I want to reproduce the same results without providing the >> Jacobian, preparing for future real life cases where it will not be >> known. I am under the impression that Petsc can approximate the >> Jacobian itself using some sort of secant method. How exactly am I >> supposed to use it? If I change nothing in the code, just pass >> -snes_mf_operator to the options, the solver stagnates. The same if I >> fill the Jacobian with zeros. The same if only with A. What am I >> supposed to do without the known Jacobian to trigger its >> approximation? > > > Run with -ksp_monitor_true_residual -ksp_converged_reason -snes_monitor > -snes_converged_reason -snes_ls_monitor -snes_view and send the output.
I see the following stagnated output: 0 SNES Function norm 1.747536282885e+01 0 KSP unpreconditioned resid norm 1.747536282885e+01 true resid norm 1.747536282885e+01 ||r(i)||/||b|| 1.000000000000e+00 1 KSP unpreconditioned resid norm 6.112827145626e-01 true resid norm 1.751036369876e+01 ||r(i)||/||b|| 1.002002869425e+00 2 KSP unpreconditioned resid norm 6.046520497681e-01 true resid norm 2.300357730584e+01 ||r(i)||/||b|| 1.316343330386e+00 3 KSP unpreconditioned resid norm 5.994471388765e-01 true resid norm 5.655832090079e+01 ||r(i)||/||b|| 3.236460464638e+00 4 KSP unpreconditioned resid norm 5.974054975332e-01 true resid norm 5.997203971117e+01 ||r(i)||/||b|| 3.431805124649e+00 5 KSP unpreconditioned resid norm 5.956696306552e-01 true resid norm 9.280866979439e+01 ||r(i)||/||b|| 5.310829348914e+00 6 KSP unpreconditioned resid norm 5.944323800377e-01 true resid norm 9.573083746155e+01 ||r(i)||/||b|| 5.478045772159e+00 7 KSP unpreconditioned resid norm 5.933318368437e-01 true resid norm 1.283420019927e+02 ||r(i)||/||b|| 7.344168086790e+00 8 KSP unpreconditioned resid norm 5.924396174526e-01 true resid norm 1.311457478032e+02 ||r(i)||/||b|| 7.504608006575e+00 9 KSP unpreconditioned resid norm 5.916244555561e-01 true resid norm 1.636933991914e+02 ||r(i)||/||b|| 9.367095882044e+00 10 KSP unpreconditioned resid norm 5.909266031948e-01 true resid norm 1.664685701658e+02 ||r(i)||/||b|| 9.525900652028e+00 11 KSP unpreconditioned resid norm 5.902780068683e-01 true resid norm 1.989974529969e+02 ||r(i)||/||b|| 1.138731452650e+01 12 KSP unpreconditioned resid norm 5.897052848025e-01 true resid norm 2.017662138832e+02 ||r(i)||/||b|| 1.154575248933e+01 13 KSP unpreconditioned resid norm 5.891666923831e-01 true resid norm 2.342886435057e+02 ||r(i)||/||b|| 1.340679708915e+01 and so on, excessively long > Your SNES callback gets two Mat arguments, into which are you assembling > your approximate Jacobian? I am assembling my (exact) Jacobian in the second (preconditioner) matrix. > Are you still calling MatAssemblyBegin/End on the > first argument, as in the examples? Yes, I do. The moment I remove -snes_mf_operator from the options I get the expected results in the expected time. Dominik
