KSPCheckSolve — PETSc 3.21.4 documentation

Skip to main content
`Ctrl`+`K`

# KSPCheckSolve

Checks if the `PCSetUp()` or `KSPSolve()` failed and set the error flag for the outer `PC`. A `KSP_DIVERGED_ITS` is not considered a failure in this context

## Synopsis

    #include "petscksp.h"
    PetscErrorCode KSPCheckSolve(KSP ksp, PC pc, Vec vec)

Collective

## Input Parameters

- ksp - the linear solver `KSP` context.

- pc - the preconditioner context

- vec - a vector that will be initialized with Inf to indicate lack of convergence

## Note

This is called within `PCApply()` implementations to check if an error has been detected on any particular MPI processes. By initializing the vector with Inf the next call to `KSPCheckNorm()` or `KSPCheckDot()` will provide the same information to all the MPI processes that an error occurred on at least one of the processes.

This may be called by a subset of the processes in the `PC`.

## Developer Note

This is used to manage returning with appropriate information from preconditioners whose inner `KSP` solvers have failed in some way

## See Also

KSP: Linear System Solvers, `KSP`, `KSPCreate()`, `KSPSetType()`, `KSPCheckNorm()`, `KSPCheckDot()`

## Level

developer

## Location

src/ksp/ksp/interface/iterativ.c

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