SLESSolve

Solves a linear system.

Synopsis

int SLESSolve(SLES sles,Vec b,Vec x,int *its)
Collective on SLES

Input Parameters

sles - the SLES context
b - the right hand side

Output Parameters

x - the approximate solution
its - the number of iterations until termination

Notes

On return, the parameter "its" contains
- the iteration number at which convergence- was successfully reached,
- or the negative of the iteration at which- divergence or breakdown was detected.

If using a direct method (e.g., via the KSP solverKSPPREONLY and a preconditioner such as PCLU/PCILU), then its=1. See KSPSetTolerances() and KSPDefaultConverged() for more details. Also, see KSPSolve() for more detailsabout iterative solver options.

Setting a Nonzero Initial Guess

By default, SLES assumes an initial guess of zero by zeroingthe initial value for the solution vector, x. To use a nonzeroinitial guess, the user must call
       SLESGetKSP(sles,&ksp);
       KSPSetInitialGuessNonzero(ksp);

Solving Successive Linear Systems

When solving multiple linear systems of the same size with thesame method, several options are available.

(1) To solve successive linear systems having the SAMEpreconditioner matrix (i.e., the same data structure with exactlythe same matrix elements) but different right-hand-side vectors, the user should simply call SLESSolve() multiple times. Thepreconditioner setup operations (e.g., factorization for ILU) willbe done during the first call to SLESSolve() only; such operationswill NOT be repeated for successive solves.

(2) To solve successive linear systems that have DIFFERENTpreconditioner matrices (i.e., the matrix elements and/or thematrix data structure change), the user MUST call SLESSetOperators() and SLESSolve() for each solve. See SLESSetOperators() foroptions that can save work for such cases.

Keywords

SLES, solve, linear system

See Also

SLESCreate(), SLESSetOperators(), SLESGetKSP(), KSPSetTolerances(),
KSPDefaultConverged(), KSPSetInitialGuessNonzero()

Examples

src/sles/examples/tutorials/ex6f.F
src/sles/examples/tutorials/ex11f.F
src/sles/examples/tutorials/ex1f.F
src/sles/examples/tutorials/ex2f.F
src/sles/examples/tutorials/ex14f.F
src/sles/examples/tutorials/ex13f.F
src/sles/examples/tutorials/ex15f.F
src/sles/examples/tutorials/ex5.c
src/sles/examples/tutorials/ex10.c
src/sles/examples/tutorials/ex4.c
src/sles/examples/tutorials/ex1.c
src/sles/examples/tutorials/ex2.c
src/sles/examples/tutorials/ex3.c
src/sles/examples/tutorials/ex7.c
src/sles/examples/tutorials/ex8.c
src/sles/examples/tutorials/ex9.c
src/sles/examples/tutorials/ex11.c
src/sles/examples/tutorials/ex14.c
src/sles/examples/tutorials/ex13.c
src/sles/examples/tutorials/ex15.c
src/sles/examples/tutorials/ex16.c
src/sles/examples/tutorials/ex12.c
src/gvec/examples/tutorials/ex1.c
src/gvec/examples/tutorials/ex2.c
src/gvec/examples/tutorials/ex5.c
src/gvec/examples/tutorials/ex6.c
src/gvec/examples/tutorials/ex11.c

Location: src/sles/interface/sles.c
SLES Index
Table of Contents