Skip to main content
`Ctrl`+`K`

# KSPGMRESSetRestart

Sets number of iterations at which GMRES (`KSPGMRES`, `KSPFGMRES`, `KSPPGMRES`, `KSPAGMRES`, `KSPDGMRES`, `KSPPIPEFGMRES`, and `KSPLGMRES`) restarts.

## Synopsis

    #include "petscksp.h"
    PetscErrorCode KSPGMRESSetRestart(KSP ksp, PetscInt restart)

Logically Collective

## Input Parameters

- ksp - the Krylov space solver context

- restart - integer restart value, this corresponds to the number of iterations of GMRES to perform before restarting

## Options Database Key

- -ksp_gmres_restart restart - integer restart value

## Notes

The default value is 30.

GMRES builds a Krylov subspace of increasing size, where each new vector is orthogonalized against the previous ones using a Gram-Schmidt process. As the size of the Krylov subspace grows, the computational cost and memory requirements increase. To mitigate this issue, GMRES methods usually employ restart strategies, which involve periodically deleting the Krylov subspace and beginning to generate a new one. This can help reduce the computational cost and memory usage while still maintaining convergence. The maximum size of the Krylov subspace, that is the maximum number of vectors orthogonalized is called the `restart` parameter.

A larger restart parameter generally leads to faster convergence of GMRES but the memory usage is higher than with a smaller `restart` parameter, as is the average time to perform each iteration. For more ill-conditioned problems a larger restart value may be necessary.

`KSPBCGS` has the advantage over `KSPGMRES` in that it does not explicitly store the Krylov space and thus does not require as much memory as GMRES might need.

## See Also

KSP: Linear System Solvers, `KSPGMRES`, `KSPSetTolerances()`, `KSPGMRESSetOrthogonalization()`, `KSPGMRESSetPreAllocateVectors()`, `KSPGMRESGetRestart()`, `KSPFGMRES`, `KSPLGMRES`, `KSPPGMRES`, `KSPAGMRES`, `KSPDGMRES`, `KSPPIPEFGMRES`

## Level

intermediate

## Location

src/ksp/ksp/impls/gmres/gmres.c

## Examples

src/ksp/pc/tutorials/ex4.c
src/ksp/ksp/tutorials/ex71.c

## Implementations

KSPGMRESSetRestart_FGMRES() in src/ksp/ksp/impls/gmres/fgmres/fgmres.c
KSPGMRESSetRestart_GMRES() in src/ksp/ksp/impls/gmres/gmres.c

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