How to monitor iteration - NonlinearVariationalSolver

Dear all,

This definitely is not an interesting problem, but how do I monitor the convergence of each iteration of the nonlinear solver?

i.e. I wish to see info "iteration :#, absolute residual = ###, relative residual = ### " after each iteration while running, rather than printing the entire pile at the end and nothing before. I wish to be able to observe the decreasing residual instead of waiting for the maximum to be reached.

I assumed that the parameter “monitor_convergence” does this but apparently it doesn’t. Everything is still printed after the solver stops.

Thanks a lot in advance!

Hi,
Consider changing the LogLevel, as set_log_level(LogLevel.TRACE).
For other print levels, see: https://fenics-dolfin.readthedocs.io/en/2017.2.0/apis/api_log.html#loglevel

Hi dokken,

Thank you so much for your timely reply. However I tried what you suggested and it didn’t seem to work. Setting the loglevel made the report printed after the solver finished running more detailed, which is not what I wanted.
Perhaps I didn’t make myself clear…For now what happens is, after I run my script, there is nothing printed in the console after the runfile(…) line, until the script is finished and all the info such as :
" …
Newton iteration 88: r (abs) = 2.193e-03 (tol = 1.000e-10) r (rel) = 1.081e-04 (tol = 1.000e-04)
Newton iteration 89: r (abs) = 2.013e-03 (tol = 1.000e-10) r (rel) = 9.926e-05 (tol = 1.000e-04)
Newton solver finished in 89 iterations and 89 linear solver iterations."
are printed all at once. I merely wish to see this lines one by one after each iteration, so I can monitor the convergence and notice abnormality before it finishes. Could this be done?

Thanks!

I found where the problem is … Spyder IDE somehow held up all the printing to the console, while any other IDE or terminal prints throughout the process nicely.

Hello, I have the same problem, could you please help me with how you solved your problem? Thanks