This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Can NonlinearVariationalSolver return list of residuals?

+1 vote

Hi all,

is it possible to return the convergence history of the standard nonlinear solver? A simple list containing the residuals printed on the screen.

Thanks in advance,
David

asked Jun 14, 2016 by dajuno FEniCS User (4,140 points)

Well, I guess the answer is no. However, I managed doing it via PETScSNESSolver.

problem = GeneralProblem(F, w, bcs=bcs)    # own class inherits NonlinearProblem
solver = PETScSNESSolver("newtontr")
solver.parameters["linear_solver"] = "lu"
solver.init(problem, w.vector())
snes = solver.snes()
snes.setConvergenceHistory()
snes.setTolerances(rtol=1e-13, atol=1e-13, stol=0.0, max_it=30)
snes.solve(None, as_backend_type(w.vector()).vec())
residuals = snes.getConvergenceHistory()     # and here they are
...