[petsc-users] [KSP] PETSc not reporting a KSP fail when true residual is NaN

Mark Adams mfadams at lbl.gov
Fri Feb 25 10:36:33 CST 2022


That is a bug.

Others might have a better idea, but you could run with '-info :ksp' and
see if you see any messages like "Linear solver has created a not a number
(NaN) as the residual norm, declaring divergence \n"
You could also run with -log_trace and see if it is
using KSPConvergedDefault. I'm not sure if this is the method used given
your parameters, but I think it is.

Mark


On Fri, Feb 25, 2022 at 11:06 AM Giovane Avancini via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Dear PETSc users,
>
> I'm working on an inhouse code that solves the Navier-Stokes equation in a
> Lagrangian fashion for free surface flows. Because of the large distortions
> and pressure gradients, it is quite common to encounter some issues with
> iterative solvers for some time steps, and because of that, I implemented a
> function that changes the solver type based on the flag KSPConvergedReason.
> If this flag is negative after a call to KSPSolve, I solve the same linear
> system again using a direct method.
>
> The problem is that, sometimes, KSP keeps converging even though the
> residual is NaN, and because of that, I'm not able to identify the problem
> and change the solver, which leads to a solution vector equals to INF and
> obviously the code ends up crashing. Is it normal to observe this kind of
> behaviour?
>
> Please find attached the log produced with the options
> -ksp_monitor_lg_residualnorm -ksp_log -ksp_view -ksp_monitor_true_residual
> -ksp_converged_reason and the function that changes the solver. I'm
> currently using FGMRES and BJACOBI preconditioner with LU for each block.
> The problem still happens with ILU for example. We can see in the log file
> that for the time step 921, the true residual is NaN and within just one
> iteration, the solver fails and it gives the reason DIVERGED_PC_FAILED. I
> simply changed the solver to MUMPS and it converged for that time step.
> However, when solving time step 922 we can see that FGMRES converges while
> the true residual is NaN. Why is that possible? I would appreciate it if
> someone could clarify this issue to me.
>
> Kind regards,
> Giovane
>
>
>
> --
> Giovane Avancini
> Doutorando em Engenharia de Estruturas - Escola de Engenharia de São
> Carlos, USP
>
> PhD researcher in Structural Engineering - School of Engineering of São
> Carlos. USP
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220225/f816bbb4/attachment.html>


More information about the petsc-users mailing list