Hello, I am trying to catch the "not converged" error in a loop with the `ksp_error_if_not_converged` option on. However, it seems that PETSc only raises the exception once, even though the solver does not converge after that. Is this expected behavior? Can I make it raise an exception every time?
I have included a code snippet of the loop below, and the complete code is
attached:
```python
for i in range(3):
printf(f"Loop i = {i}")
try:
solver.solve()
except ConvergenceError:
printf(f" Error from Firedrake: solver did not converged:
{get_ksp_reason(solver)}")
except PETSc.Error as e:
if e.ierr == 91:
printf(f" Error from PETSc: solver did not converged:
{get_ksp_reason(solver)}")
else:
raise
```
The output of the code looks like this:
```python
(complex-int32-mkl) $ python test_error.py
Loop i = 0
Linear solve did not converge due to DIVERGED_ITS iterations 4
Error from PETSc: solver did not converged: DIVERGED_MAX_IT
Loop i = 1
Linear solve did not converge due to DIVERGED_ITS iterations 4
Error from Firedrake: solver did not converged: DIVERGED_MAX_IT
Loop i = 2
Linear solve did not converge due to DIVERGED_ITS iterations 4
Error from Firedrake: solver did not converged: DIVERGED_MAX_IT
```
Best wishes,
Zongze
test_error.py
Description: Binary data
