Skip to main content
`Ctrl`+`K`

# KSPConvergedReasonView

Displays the reason a `KSP` solve converged or diverged, `KSPConvergedReason` to a `PetscViewer`

## Synopsis

    #include "petscksp.h"
    #include "petscmat.h"
    PetscErrorCode KSPConvergedReasonView(KSP ksp, PetscViewer viewer)

Collective

## Input Parameters

- ksp - iterative solver obtained from `KSPCreate()`

- viewer - the `PetscViewer` on which to display the reason

## Options Database Keys

- -ksp_converged_reason - print reason for converged or diverged, also prints number of iterations

- -ksp_converged_reason ::failed - only print reason and number of iterations when diverged

## Note

Use `KSPConvergedReasonViewFromOptions()` to display the reason based on values in the PETSc options database.

To change the format of the output call `PetscViewerPushFormat`(`viewer`,`format`) before this call. Use `PETSC_VIEWER_DEFAULT` for the default, use `PETSC_VIEWER_FAILED` to only display a reason if it fails.

## See Also

KSP: Linear System Solvers, `KSPConvergedReasonViewFromOptions()`, `KSPCreate()`, `KSPSetUp()`, `KSPDestroy()`, `KSPSetTolerances()`, `KSPConvergedDefault()`, `KSPSolveTranspose()`, `KSPGetIterationNumber()`, `KSP`, `KSPGetConvergedReason()`, `PetscViewerPushFormat()`, `PetscViewerPopFormat()`

## Level

beginner

## Location

src/ksp/ksp/interface/itfunc.c

## Examples

src/ksp/ksp/tutorials/ex1f.F90

Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages