Let's say we have set up a preconditioned iterative solver as follows:
...
solver = PETScKrylovSolver("cg", "ml_amg")
solver.parameters["monitor_convergence"] = True
...
solver.solve(X.vector(), b)
While running, the "monitor_convergence" option prints something similar to the following:
...
0 KSP preconditioned resid norm 2.546283814132e+01 true resid norm 5.176456155465e+01 ||r(i)||/||b|| 1.000000000000e+00
1 KSP preconditioned resid norm 5.032752659820e+00 true resid norm 5.997902616157e+00 ||r(i)||/||b|| 1.158688963264e-01
2 KSP preconditioned resid norm 3.076095473748e+00 true resid norm 3.780358877571e+00 ||r(i)||/||b|| 7.302986375302e-02
3 KSP preconditioned resid norm 1.633999784699e+00 true resid norm 3.047832991298e+00 ||r(i)||/||b|| 5.887875604008e-02
4 KSP preconditioned resid norm 1.284962393197e+00 true resid norm 2.622602497636e+00 ||r(i)||/||b|| 5.066405314507e-02
5 KSP preconditioned resid norm 1.051833859216e+00 true resid norm 2.126405762563e+00 ||r(i)||/||b|| 4.107840767314e-02
...
Is there a way to gain access to the residual norm values in an array? To be clear, I'm looking for something that would act like solver.residual_values()
that could be called post-solve that would return the residual values as an array.