This behavior where the residual norm jumps at restart indicates something is very very wrong. Run with the option -ksp_monitor_true_residual and I think you'll see the true residual is not decreasing as is the preconditioned residual. My guess is that your "action of the matrix" is incorrect and not actually a linear operator. Try using MatComputeExplicitOperator() and see what explicit matrix it produces, is it what you expect?
Barry > On May 27, 2019, at 11:33 PM, Jan Izak Cornelius Vermaak via petsc-users > <[email protected]> wrote: > > Hi all, > > So I am faced with this debacle. I have a neutron transport solver with a > sweep code that can compute the action of the matrix on a vector. > > I use a matrix shell to set up the action of the matrix. The method works but > only if I can get the solution converged before GMRES restarts. It gets the > right answer. Now my first problem is (and I only saw this when I hit the > first restart) is that it looks like the solver completely resets after the > GMRES-restart. Below is an iteration log with restart interval set to 10. At > first I thought it wasn't updating the initial guess but it became clear that > it initial guess always had no effect. I do set KSPSetInitialGuessNonZero but > it has no effect. > > Is the matrix-free business defaulting my initial guess to zero everytime? > What can I do to actually supply an initial guess? I've used PETSc for > diffusion many times and the initial guess always works, just not now. > > [0] Computing b > [0] Iteration 0 Residual 169.302 > [0] Iteration 1 Residual 47.582 > [0] Iteration 2 Residual 13.2614 > [0] Iteration 3 Residual 4.46795 > [0] Iteration 4 Residual 1.03038 > [0] Iteration 5 Residual 0.246807 > [0] Iteration 6 Residual 0.0828341 > [0] Iteration 7 Residual 0.0410627 > [0] Iteration 8 Residual 0.0243749 > [0] Iteration 9 Residual 0.0136067 > [0] Iteration 10 Residual 169.302 > [0] Iteration 11 Residual 47.582 > [0] Iteration 12 Residual 13.2614 > [0] Iteration 13 Residual 4.46795 > [0] Iteration 14 Residual 1.03038 > [0] Iteration 15 Residual 0.246807 > [0] Iteration 16 Residual 0.0828341 > [0] Iteration 17 Residual 0.0410627 > [0] Iteration 18 Residual 0.0243749 > [0] Iteration 19 Residual 0.0136067 > [0] Iteration 20 Residual 169.302 > > -- > Jan Izak Cornelius Vermaak > (M.Eng Nuclear) > Email: [email protected] > Cell: +1-979-739-0789
