Is there a way to get a signal for non-converging solve() call

Hi, I’m trying to solve a flow problem, and I simply call the solve function to solve it as non-linear problem

solve(F == 0, u, bcs, J, params)

The problem is my formulation is not stable, sometimes I get non-convergence. But it is fine, I just want to know if the solver did not get converge, so that I can reactive to that and automatically tune some parameters. I don’t want it to stop as an error, nor continue running codes which only works for converged solution.

After searched for a while, I find the following params for newton solver not to stop for a nonconvergence, but I am not sure is there a way I can get a bool output for me to write a conditional code?

newton_params.add("error_on_nonconvergence", false);

You can do this by creating a NewtonSolver see here.

Cf. also here.


Thank you nate! Juntao