Actual source code: petscksp.h
1: /*
2: Defines the interface functions for the Krylov subspace accelerators.
3: */
4: #pragma once
6: #include <petscpc.h>
8: /* SUBMANSEC = KSP */
10: PETSC_EXTERN PetscErrorCode KSPInitializePackage(void);
11: PETSC_EXTERN PetscErrorCode KSPFinalizePackage(void);
13: /*S
14: KSP - Abstract PETSc object that manages the linear solves in PETSc (even those such as direct factorization-based solvers that
15: do not use Krylov accelerators).
17: Level: beginner
19: Notes:
20: When a direct solver is used, but no Krylov solver is used, the `KSP` object is still used but with a
21: `KSPType` of `KSPPREONLY` (or equivalently `KSPNONE`), meaning that only application of the preconditioner is used as the linear solver.
23: Use `KSPSetType()` or the options database key `-ksp_type` to set the specific Krylov solver algorithm to use with a given `KSP` object
25: The `PC` object is used to control preconditioners in PETSc.
27: `KSP` can also be used to solve some least squares problems (over or under-determined linear systems), using, for example, `KSPLSQR`, see `PETSCREGRESSORLINEAR`
28: for additional methods that can be used to solve least squares problems and other linear regressions).
30: .seealso: [](doc_linsolve), [](ch_ksp), `KSPCreate()`, `KSPSetType()`, `KSPType`, `SNES`, `TS`, `PC`, `KSP`, `KSPDestroy()`, `KSPCG`, `KSPGMRES`
31: S*/
32: typedef struct _p_KSP *KSP;
34: /*J
35: KSPType - String with the name of a PETSc Krylov method. These are all the Krylov solvers that PETSc provides.
37: Level: beginner
39: .seealso: [](doc_linsolve), [](ch_ksp), `KSPSetType()`, `KSP`, `KSPRegister()`, `KSPCreate()`, `KSPSetFromOptions()`
40: J*/
41: typedef const char *KSPType;
42: #define KSPRICHARDSON "richardson"
43: #define KSPCHEBYSHEV "chebyshev"
44: #define KSPCG "cg"
45: #define KSPGROPPCG "groppcg"
46: #define KSPPIPECG "pipecg"
47: #define KSPPIPECGRR "pipecgrr"
48: #define KSPPIPELCG "pipelcg"
49: #define KSPPIPEPRCG "pipeprcg"
50: #define KSPPIPECG2 "pipecg2"
51: #define KSPCGNE "cgne"
52: #define KSPNASH "nash"
53: #define KSPSTCG "stcg"
54: #define KSPGLTR "gltr"
55: #define KSPCGNASH PETSC_DEPRECATED_MACRO(3, 11, 0, "KSPNASH", ) "nash"
56: #define KSPCGSTCG PETSC_DEPRECATED_MACRO(3, 11, 0, "KSPSTCG", ) "stcg"
57: #define KSPCGGLTR PETSC_DEPRECATED_MACRO(3, 11, 0, "KSPSGLTR", ) "gltr"
58: #define KSPFCG "fcg"
59: #define KSPPIPEFCG "pipefcg"
60: #define KSPGMRES "gmres"
61: #define KSPPIPEFGMRES "pipefgmres"
62: #define KSPFGMRES "fgmres"
63: #define KSPLGMRES "lgmres"
64: #define KSPDGMRES "dgmres"
65: #define KSPPGMRES "pgmres"
66: #define KSPTCQMR "tcqmr"
67: #define KSPBCGS "bcgs"
68: #define KSPIBCGS "ibcgs"
69: #define KSPQMRCGS "qmrcgs"
70: #define KSPFBCGS "fbcgs"
71: #define KSPFBCGSR "fbcgsr"
72: #define KSPBCGSL "bcgsl"
73: #define KSPPIPEBCGS "pipebcgs"
74: #define KSPCGS "cgs"
75: #define KSPTFQMR "tfqmr"
76: #define KSPCR "cr"
77: #define KSPPIPECR "pipecr"
78: #define KSPLSQR "lsqr"
79: #define KSPPREONLY "preonly"
80: #define KSPNONE "none"
81: #define KSPQCG "qcg"
82: #define KSPBICG "bicg"
83: #define KSPMINRES "minres"
84: #define KSPSYMMLQ "symmlq"
85: #define KSPLCD "lcd"
86: #define KSPPYTHON "python"
87: #define KSPGCR "gcr"
88: #define KSPPIPEGCR "pipegcr"
89: #define KSPTSIRM "tsirm"
90: #define KSPCGLS "cgls"
91: #define KSPFETIDP "fetidp"
92: #define KSPHPDDM "hpddm"
93: #define KSPIDR "idr"
95: /* Logging support */
96: PETSC_EXTERN PetscClassId KSP_CLASSID;
97: PETSC_EXTERN PetscClassId KSPGUESS_CLASSID;
98: PETSC_EXTERN PetscClassId DMKSP_CLASSID;
100: PETSC_EXTERN PetscErrorCode KSPCreate(MPI_Comm, KSP *);
101: PETSC_EXTERN PetscErrorCode KSPSetType(KSP, KSPType);
102: PETSC_EXTERN PetscErrorCode KSPGetType(KSP, KSPType *);
103: PETSC_EXTERN PetscErrorCode KSPSetUp(KSP);
104: PETSC_EXTERN PetscErrorCode KSPSetUpOnBlocks(KSP);
105: PETSC_EXTERN PetscErrorCode KSPSolve(KSP, Vec, Vec);
106: PETSC_EXTERN PetscErrorCode KSPSolveTranspose(KSP, Vec, Vec);
107: PETSC_EXTERN PetscErrorCode KSPSetUseExplicitTranspose(KSP, PetscBool);
108: PETSC_EXTERN PetscErrorCode KSPMatSolve(KSP, Mat, Mat);
109: PETSC_EXTERN PetscErrorCode KSPMatSolveTranspose(KSP, Mat, Mat);
110: PETSC_EXTERN PetscErrorCode KSPSetMatSolveBatchSize(KSP, PetscInt);
111: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "KSPSetMatSolveBatchSize()", ) static inline PetscErrorCode KSPSetMatSolveBlockSize(KSP ksp, PetscInt n)
112: {
113: return KSPSetMatSolveBatchSize(ksp, n);
114: }
115: PETSC_EXTERN PetscErrorCode KSPGetMatSolveBatchSize(KSP, PetscInt *);
116: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "KSPGetMatSolveBatchSize()", ) static inline PetscErrorCode KSPGetMatSolveBlockSize(KSP ksp, PetscInt *n)
117: {
118: return KSPGetMatSolveBatchSize(ksp, n);
119: }
120: PETSC_EXTERN PetscErrorCode KSPReset(KSP);
121: PETSC_EXTERN PetscErrorCode KSPResetViewers(KSP);
122: PETSC_EXTERN PetscErrorCode KSPDestroy(KSP *);
123: PETSC_EXTERN PetscErrorCode KSPSetReusePreconditioner(KSP, PetscBool);
124: PETSC_EXTERN PetscErrorCode KSPGetReusePreconditioner(KSP, PetscBool *);
125: PETSC_EXTERN PetscErrorCode KSPSetSkipPCSetFromOptions(KSP, PetscBool);
126: PETSC_EXTERN PetscErrorCode KSPCheckSolve(KSP, PC, Vec);
128: PETSC_EXTERN PetscFunctionList KSPList;
129: PETSC_EXTERN PetscFunctionList KSPGuessList;
130: PETSC_EXTERN PetscFunctionList KSPMonitorList;
131: PETSC_EXTERN PetscFunctionList KSPMonitorCreateList;
132: PETSC_EXTERN PetscFunctionList KSPMonitorDestroyList;
133: PETSC_EXTERN PetscErrorCode KSPRegister(const char[], PetscErrorCode (*)(KSP));
135: /*S
136: KSPMonitorRegisterFn - A function prototype for functions provided to `KSPMonitorRegister()`
138: Calling Sequence:
139: + ksp - iterative solver obtained from `KSPCreate()`
140: . it - iteration number
141: . rnorm - (estimated) 2-norm of (preconditioned) residual
142: - ctx - `PetscViewerAndFormat` object
144: Level: beginner
146: Note:
147: This is a `KSPMonitorFn` specialized for a context of `PetscViewerAndFormat`
149: .seealso: [](ch_snes), `KSP`, `KSPMonitorSet()`, `KSPMonitorRegister()`, `KSPMonitorFn`, `KSPMonitorRegisterCreateFn`, `KSPMonitorRegisterDestroyFn`
150: S*/
151: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPMonitorRegisterFn(KSP ksp, PetscInt it, PetscReal rnorm, PetscViewerAndFormat *ctx);
153: /*S
154: KSPMonitorRegisterCreateFn - A function prototype for functions that do the creation when provided to `KSPMonitorRegister()`
156: Calling Sequence:
157: + viewer - the viewer to be used with the `KSPMonitorRegisterFn`
158: . format - the format of the viewer
159: . ctx - a context for the monitor
160: - result - a `PetscViewerAndFormat` object
162: Level: beginner
164: .seealso: [](ch_snes), `KSPMonitorRegisterFn`, `KSP`, `KSPMonitorSet()`, `KSPMonitorRegister()`, `KSPMonitorFn`, `KSPMonitorRegisterDestroyFn`
165: S*/
166: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPMonitorRegisterCreateFn(PetscViewer viewer, PetscViewerFormat format, PetscCtx ctx, PetscViewerAndFormat **result);
168: /*S
169: KSPMonitorRegisterDestroyFn - A function prototype for functions that do the after use destruction when provided to `KSPMonitorRegister()`
171: Calling Sequence:
172: . vf - a `PetscViewerAndFormat` object to be destroyed, including any context
174: Level: beginner
176: .seealso: [](ch_snes), `KSPMonitorRegisterFn`, `KSP`, `KSPMonitorSet()`, `KSPMonitorRegister()`, `KSPMonitorFn`, `KSPMonitorRegisterCreateFn`
177: S*/
178: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPMonitorRegisterDestroyFn(PetscViewerAndFormat **result);
180: PETSC_EXTERN PetscErrorCode KSPMonitorRegister(const char[], PetscViewerType, PetscViewerFormat, KSPMonitorRegisterFn *, KSPMonitorRegisterCreateFn *, KSPMonitorRegisterDestroyFn *);
182: PETSC_EXTERN PetscErrorCode KSPSetPCSide(KSP, PCSide);
183: PETSC_EXTERN PetscErrorCode KSPGetPCSide(KSP, PCSide *);
184: PETSC_EXTERN PetscErrorCode KSPSetTolerances(KSP, PetscReal, PetscReal, PetscReal, PetscInt);
185: PETSC_EXTERN PetscErrorCode KSPGetTolerances(KSP, PetscReal *, PetscReal *, PetscReal *, PetscInt *);
186: PETSC_EXTERN PetscErrorCode KSPSetMinimumIterations(KSP, PetscInt);
187: PETSC_EXTERN PetscErrorCode KSPGetMinimumIterations(KSP, PetscInt *);
188: PETSC_EXTERN PetscErrorCode KSPSetInitialGuessNonzero(KSP, PetscBool);
189: PETSC_EXTERN PetscErrorCode KSPGetInitialGuessNonzero(KSP, PetscBool *);
190: PETSC_EXTERN PetscErrorCode KSPSetErrorIfNotConverged(KSP, PetscBool);
191: PETSC_EXTERN PetscErrorCode KSPGetErrorIfNotConverged(KSP, PetscBool *);
192: PETSC_EXTERN PetscErrorCode KSPSetComputeEigenvalues(KSP, PetscBool);
193: PETSC_EXTERN PetscErrorCode KSPSetComputeRitz(KSP, PetscBool);
194: PETSC_EXTERN PetscErrorCode KSPGetComputeEigenvalues(KSP, PetscBool *);
195: PETSC_EXTERN PetscErrorCode KSPSetComputeSingularValues(KSP, PetscBool);
196: PETSC_EXTERN PetscErrorCode KSPGetComputeSingularValues(KSP, PetscBool *);
197: PETSC_EXTERN PetscErrorCode KSPGetRhs(KSP, Vec *);
198: PETSC_EXTERN PetscErrorCode KSPGetSolution(KSP, Vec *);
199: PETSC_EXTERN PetscErrorCode KSPGetResidualNorm(KSP, PetscReal *);
200: PETSC_EXTERN PetscErrorCode KSPGetIterationNumber(KSP, PetscInt *);
201: PETSC_EXTERN PetscErrorCode KSPGetTotalIterations(KSP, PetscInt *);
202: PETSC_EXTERN PetscErrorCode KSPCreateVecs(KSP, PetscInt, Vec **, PetscInt, Vec **);
203: PETSC_DEPRECATED_FUNCTION(3, 6, 0, "KSPCreateVecs()", ) static inline PetscErrorCode KSPGetVecs(KSP ksp, PetscInt n, Vec **x, PetscInt m, Vec **y)
204: {
205: return KSPCreateVecs(ksp, n, x, m, y);
206: }
208: /*S
209: KSPPSolveFn - A function prototype for functions provided to `KSPSetPreSolve()` and `KSPSetPostSolve()`
211: Calling Sequence:
212: + ksp - the `KSP` context
213: . rhs - the right-hand side vector
214: . x - the solution vector
215: - ctx - optional context that was provided with `KSPSetPreSolve()` or `KSPSetPostSolve()`
217: Level: intermediate
219: .seealso: [](ch_snes), `KSP`, `KSPSetPreSolve()`, `KSPSetPostSolve()`, `PCShellPSolveFn`
220: S*/
221: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPPSolveFn(KSP ksp, Vec rhs, Vec x, PetscCtx ctx);
223: PETSC_EXTERN PetscErrorCode KSPSetPreSolve(KSP, KSPPSolveFn *, PetscCtx);
224: PETSC_EXTERN PetscErrorCode KSPSetPostSolve(KSP, KSPPSolveFn *, PetscCtx);
225: PETSC_EXTERN PetscErrorCode KSPPreSolve(KSP, Vec, Vec);
226: PETSC_EXTERN PetscErrorCode KSPPostSolve(KSP, Vec, Vec);
228: PETSC_EXTERN PetscErrorCode KSPSetPC(KSP, PC);
229: PETSC_EXTERN PetscErrorCode KSPGetPC(KSP, PC *);
230: PETSC_EXTERN PetscErrorCode KSPSetNestLevel(KSP, PetscInt);
231: PETSC_EXTERN PetscErrorCode KSPGetNestLevel(KSP, PetscInt *);
233: /*S
234: KSPMonitorFn - A function prototype for functions provided to `KSPMonitorSet()`
236: Calling Sequence:
237: + ksp - iterative solver obtained from `KSPCreate()`
238: . it - iteration number
239: . rnorm - (estimated) 2-norm of (preconditioned) residual
240: - ctx - optional monitoring context, as provided with `KSPMonitorSet()`
242: Level: beginner
244: .seealso: [](ch_snes), `KSP`, `KSPMonitorSet()`
245: S*/
246: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPMonitorFn(KSP ksp, PetscInt it, PetscReal rnorm, PetscCtx ctx);
248: PETSC_EXTERN PetscErrorCode KSPMonitor(KSP, PetscInt, PetscReal);
249: PETSC_EXTERN PetscErrorCode KSPMonitorSet(KSP, KSPMonitorFn *, PetscCtx, PetscCtxDestroyFn *);
250: PETSC_EXTERN PetscErrorCode KSPMonitorCancel(KSP);
251: PETSC_EXTERN PetscErrorCode KSPGetMonitorContext(KSP, PetscCtxRt);
252: PETSC_EXTERN PetscErrorCode KSPGetResidualHistory(KSP, const PetscReal *[], PetscInt *);
253: PETSC_EXTERN PetscErrorCode KSPSetResidualHistory(KSP, PetscReal[], PetscCount, PetscBool);
254: PETSC_EXTERN PetscErrorCode KSPGetErrorHistory(KSP, const PetscReal *[], PetscInt *);
255: PETSC_EXTERN PetscErrorCode KSPSetErrorHistory(KSP, PetscReal[], PetscCount, PetscBool);
257: PETSC_EXTERN PetscErrorCode KSPBuildSolutionDefault(KSP, Vec, Vec *);
258: PETSC_EXTERN PetscErrorCode KSPBuildResidualDefault(KSP, Vec, Vec, Vec *);
259: PETSC_EXTERN PetscErrorCode KSPDestroyDefault(KSP);
260: PETSC_EXTERN PetscErrorCode KSPSetWorkVecs(KSP, PetscInt);
262: PETSC_EXTERN PetscErrorCode PCKSPGetKSP(PC, KSP *);
263: PETSC_EXTERN PetscErrorCode PCKSPSetKSP(PC, KSP);
264: PETSC_EXTERN PetscErrorCode PCBJacobiGetSubKSP(PC, PetscInt *, PetscInt *, KSP *[]);
265: PETSC_EXTERN PetscErrorCode PCASMGetSubKSP(PC, PetscInt *, PetscInt *, KSP *[]);
266: PETSC_EXTERN PetscErrorCode PCGASMGetSubKSP(PC, PetscInt *, PetscInt *, KSP *[]);
267: PETSC_EXTERN PetscErrorCode PCPatchGetSubKSP(PC, PetscInt *, KSP *[]);
268: PETSC_EXTERN PetscErrorCode PCFieldSplitGetSubKSP(PC, PetscInt *, KSP *[]);
269: PETSC_EXTERN PetscErrorCode PCFieldSplitSchurGetSubKSP(PC, PetscInt *, KSP *[]);
270: PETSC_EXTERN PetscErrorCode PCMGGetSmoother(PC, PetscInt, KSP *);
271: PETSC_EXTERN PetscErrorCode PCMGGetSmootherDown(PC, PetscInt, KSP *);
272: PETSC_EXTERN PetscErrorCode PCMGGetSmootherUp(PC, PetscInt, KSP *);
273: PETSC_EXTERN PetscErrorCode PCMGGetCoarseSolve(PC, KSP *);
274: PETSC_EXTERN PetscErrorCode PCGalerkinGetKSP(PC, KSP *);
275: PETSC_EXTERN PetscErrorCode PCDeflationGetCoarseKSP(PC, KSP *);
277: /*S
278: PCMGCoarseSpaceConstructorFn - A function prototype for functions registered with `PCMGRegisterCoarseSpaceConstructor()`
280: Calling Sequence:
281: + pc - The `PC` object
282: . l - The multigrid level, 0 is the coarse level
283: . dm - The `DM` for this level
284: . smooth - The level smoother
285: . Nc - The size of the coarse space
286: . initGuess - Basis for an initial guess for the space
287: - coarseSp - A basis for the computed coarse space
289: Level: beginner
291: .seealso: [](ch_ksp), `PCMGRegisterCoarseSpaceConstructor()`, `PCMGGetCoarseSpaceConstructor()`
292: S*/
293: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode PCMGCoarseSpaceConstructorFn(PC pc, PetscInt l, DM dm, KSP smooth, PetscInt Nc, Mat initGuess, Mat *coarseSp);
295: PETSC_EXTERN PetscFunctionList PCMGCoarseList;
296: PETSC_EXTERN PetscErrorCode PCMGRegisterCoarseSpaceConstructor(const char[], PCMGCoarseSpaceConstructorFn *);
297: PETSC_EXTERN PetscErrorCode PCMGGetCoarseSpaceConstructor(const char[], PCMGCoarseSpaceConstructorFn **);
299: PETSC_EXTERN PetscErrorCode KSPBuildSolution(KSP, Vec, Vec *);
300: PETSC_EXTERN PetscErrorCode KSPBuildResidual(KSP, Vec, Vec, Vec *);
302: /*E
303: KSPChebyshevKind - Which kind of Chebyshev polynomial to use with `KSPCHEBYSHEV`
305: Values:
306: + `KSP_CHEBYSHEV_FIRST` - "classic" first-kind Chebyshev polynomial
307: . `KSP_CHEBYSHEV_FOURTH` - fourth-kind Chebyshev polynomial
308: - `KSP_CHEBYSHEV_OPT_FOURTH` - optimized fourth-kind Chebyshev polynomial
310: Level: intermediate
312: .seealso: [](ch_ksp), `KSPCHEBYSHEV`, `KSPChebyshevSetKind()`, `KSPChebyshevGetKind()`
313: E*/
314: typedef enum {
315: KSP_CHEBYSHEV_FIRST,
316: KSP_CHEBYSHEV_FOURTH,
317: KSP_CHEBYSHEV_OPT_FOURTH
318: } KSPChebyshevKind;
320: PETSC_EXTERN PetscErrorCode KSPRichardsonSetScale(KSP, PetscReal);
321: PETSC_EXTERN PetscErrorCode KSPRichardsonSetSelfScale(KSP, PetscBool);
322: PETSC_EXTERN PetscErrorCode KSPChebyshevSetEigenvalues(KSP, PetscReal, PetscReal);
323: PETSC_EXTERN PetscErrorCode KSPChebyshevEstEigSet(KSP, PetscReal, PetscReal, PetscReal, PetscReal);
324: PETSC_EXTERN PetscErrorCode KSPChebyshevEstEigSetUseNoisy(KSP, PetscBool);
325: PETSC_EXTERN PetscErrorCode KSPChebyshevSetKind(KSP, KSPChebyshevKind);
326: PETSC_EXTERN PetscErrorCode KSPChebyshevGetKind(KSP, KSPChebyshevKind *);
327: PETSC_EXTERN PetscErrorCode KSPChebyshevEstEigGetKSP(KSP, KSP *);
328: PETSC_EXTERN PetscErrorCode KSPComputeExtremeSingularValues(KSP, PetscReal *, PetscReal *);
329: PETSC_EXTERN PetscErrorCode KSPComputeEigenvalues(KSP, PetscInt, PetscReal[], PetscReal[], PetscInt *);
330: PETSC_EXTERN PetscErrorCode KSPComputeEigenvaluesExplicitly(KSP, PetscInt, PetscReal[], PetscReal[]);
331: PETSC_EXTERN PetscErrorCode KSPComputeRitz(KSP, PetscBool, PetscBool, PetscInt *, Vec[], PetscReal[], PetscReal[]);
333: /*E
334: KSPFCDTruncationType - Define how stored directions are used to orthogonalize in flexible conjugate directions (FCD) methods
336: Values:
337: + `KSP_FCD_TRUNC_TYPE_STANDARD` - uses all (up to `mmax`) stored directions
338: - `KSP_FCD_TRUNC_TYPE_NOTAY` - uses the last `max(1,mod(i,mmax))` stored directions at iteration i = 0, 1, ...
340: Level: intermediate
342: Note:
343: Function such as `KSPFCGSetMmax()`, `KSPPIPEGCRSetNMax()`, `KSPPIPEGCRSetNMax()`, and `KSPPIPEFCGSetNMax()` may be
344: used to provide `nmax` or they may be provided with the option database.
346: .seealso: [](ch_ksp), `KSP`, `KSPFCG`, `KSPPIPEFCG`, `KSPPIPEGCR`, `KSPFCGSetTruncationType()`, `KSPFCGGetTruncationType()`,
347: `KSPPIPEGCRSetTruncationType()`, `KSPPIPEGCRGetTruncationType()`,
348: `KSPFCGSetMmax()`, `KSPPIPEGCRSetNMax()`, `KSPPIPEGCRGetNMax()`, `KSPPIPEFCGGetNMax()`
349: E*/
350: typedef enum {
351: KSP_FCD_TRUNC_TYPE_STANDARD,
352: KSP_FCD_TRUNC_TYPE_NOTAY
353: } KSPFCDTruncationType;
354: PETSC_EXTERN const char *const KSPFCDTruncationTypes[];
356: PETSC_EXTERN PetscErrorCode KSPFCGSetMmax(KSP, PetscInt);
357: PETSC_EXTERN PetscErrorCode KSPFCGGetMmax(KSP, PetscInt *);
358: PETSC_EXTERN PetscErrorCode KSPFCGSetNprealloc(KSP, PetscInt);
359: PETSC_EXTERN PetscErrorCode KSPFCGGetNprealloc(KSP, PetscInt *);
360: PETSC_EXTERN PetscErrorCode KSPFCGSetTruncationType(KSP, KSPFCDTruncationType);
361: PETSC_EXTERN PetscErrorCode KSPFCGGetTruncationType(KSP, KSPFCDTruncationType *);
363: PETSC_EXTERN PetscErrorCode KSPPIPEFCGSetMmax(KSP, PetscInt);
364: PETSC_EXTERN PetscErrorCode KSPPIPEFCGGetMmax(KSP, PetscInt *);
365: PETSC_EXTERN PetscErrorCode KSPPIPEFCGSetNprealloc(KSP, PetscInt);
366: PETSC_EXTERN PetscErrorCode KSPPIPEFCGGetNprealloc(KSP, PetscInt *);
367: PETSC_EXTERN PetscErrorCode KSPPIPEFCGSetTruncationType(KSP, KSPFCDTruncationType);
368: PETSC_EXTERN PetscErrorCode KSPPIPEFCGGetTruncationType(KSP, KSPFCDTruncationType *);
370: PETSC_EXTERN PetscErrorCode KSPPIPEGCRSetMmax(KSP, PetscInt);
371: PETSC_EXTERN PetscErrorCode KSPPIPEGCRGetMmax(KSP, PetscInt *);
372: PETSC_EXTERN PetscErrorCode KSPPIPEGCRSetNprealloc(KSP, PetscInt);
373: PETSC_EXTERN PetscErrorCode KSPPIPEGCRGetNprealloc(KSP, PetscInt *);
374: PETSC_EXTERN PetscErrorCode KSPPIPEGCRSetTruncationType(KSP, KSPFCDTruncationType);
375: PETSC_EXTERN PetscErrorCode KSPPIPEGCRGetTruncationType(KSP, KSPFCDTruncationType *);
376: PETSC_EXTERN PetscErrorCode KSPPIPEGCRSetUnrollW(KSP, PetscBool);
377: PETSC_EXTERN PetscErrorCode KSPPIPEGCRGetUnrollW(KSP, PetscBool *);
379: /*S
380: KSPFlexibleModifyPCFn - A prototype of a function used to modify the preconditioner during the use of flexible `KSP` methods, such as `KSPFGMRES`
382: Calling Sequence:
383: + ksp - the `KSP` context being used.
384: . total_its - the total number of iterations that have occurred.
385: . local_its - the number of iterations since last restart if applicable
386: . res_norm - the current residual norm
387: - ctx - optional context variable set with `KSPFlexibleSetModifyPC()`
389: Level: beginner
391: .seealso: [](ch_ksp), `KSP`, `KSPFlexibleSetModifyPC()`
392: S*/
393: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPFlexibleModifyPCFn(KSP ksp, PetscInt total_its, PetscInt local_its, PetscReal res_norm, PetscCtx ctx);
395: PETSC_EXTERN PetscErrorCode KSPFlexibleSetModifyPC(KSP, KSPFlexibleModifyPCFn *, PetscCtx, PetscCtxDestroyFn *);
397: PETSC_DEPRECATED_FUNCTION(3, 25, 0, "KSPFlexibleSetModifyPC()", ) static inline PetscErrorCode KSPPIPEGCRSetModifyPC(KSP ksp, KSPFlexibleModifyPCFn *fun, PetscCtx ctx, PetscCtxDestroyFn *dfun)
398: {
399: return KSPFlexibleSetModifyPC(ksp, fun, ctx, dfun);
400: }
402: PETSC_EXTERN PetscErrorCode KSPGMRESSetRestart(KSP, PetscInt);
403: PETSC_EXTERN PetscErrorCode KSPGMRESGetRestart(KSP, PetscInt *);
404: PETSC_EXTERN PetscErrorCode KSPGMRESSetHapTol(KSP, PetscReal);
405: PETSC_EXTERN PetscErrorCode KSPGMRESSetBreakdownTolerance(KSP, PetscReal);
407: PETSC_EXTERN PetscErrorCode KSPGMRESSetPreAllocateVectors(KSP);
409: PETSC_EXTERN PetscErrorCode KSPLGMRESSetAugDim(KSP, PetscInt);
410: PETSC_EXTERN PetscErrorCode KSPLGMRESSetConstant(KSP);
412: PETSC_EXTERN PetscErrorCode KSPPIPEFGMRESSetShift(KSP, PetscScalar);
414: PETSC_EXTERN PetscErrorCode KSPGCRSetRestart(KSP, PetscInt);
415: PETSC_EXTERN PetscErrorCode KSPGCRGetRestart(KSP, PetscInt *);
417: PETSC_EXTERN PetscErrorCode KSPIDRSetS(KSP, PetscInt);
418: PETSC_EXTERN PetscErrorCode KSPIDRGetS(KSP, PetscInt *);
419: PETSC_EXTERN PetscErrorCode KSPIDRSetCosine(KSP, PetscReal);
420: PETSC_EXTERN PetscErrorCode KSPIDRGetCosine(KSP, PetscReal *);
421: PETSC_EXTERN PetscErrorCode KSPIDRSetRandom(KSP, PetscRandom);
422: PETSC_EXTERN PetscErrorCode KSPIDRGetRandom(KSP, PetscRandom *);
424: PETSC_DEPRECATED_FUNCTION(3, 25, 0, "KSPFlexibleSetModifyPC()", ) static inline PetscErrorCode KSPGCRSetModifyPC(KSP ksp, KSPFlexibleModifyPCFn *fun, PetscCtx ctx, PetscCtxDestroyFn *dfun)
425: {
426: return KSPFlexibleSetModifyPC(ksp, fun, ctx, dfun);
427: }
429: PETSC_EXTERN PetscErrorCode KSPMINRESSetRadius(KSP, PetscReal);
430: PETSC_EXTERN PetscErrorCode KSPMINRESGetUseQLP(KSP, PetscBool *);
431: PETSC_EXTERN PetscErrorCode KSPMINRESSetUseQLP(KSP, PetscBool);
433: PETSC_EXTERN PetscErrorCode KSPFETIDPGetInnerBDDC(KSP, PC *);
434: PETSC_EXTERN PetscErrorCode KSPFETIDPSetInnerBDDC(KSP, PC);
435: PETSC_EXTERN PetscErrorCode KSPFETIDPGetInnerKSP(KSP, KSP *);
436: PETSC_EXTERN PetscErrorCode KSPFETIDPSetPressureOperator(KSP, Mat);
438: PETSC_EXTERN PetscErrorCode KSPHPDDMSetDeflationMat(KSP, Mat);
439: PETSC_EXTERN PetscErrorCode KSPHPDDMGetDeflationMat(KSP, Mat *);
440: #if PetscDefined(HAVE_HPDDM)
441: PETSC_DEPRECATED_FUNCTION(3, 18, 0, "KSPHPDDMSetDeflationMat()", ) static inline PetscErrorCode KSPHPDDMSetDeflationSpace(KSP ksp, Mat U)
442: {
443: return KSPHPDDMSetDeflationMat(ksp, U);
444: }
445: PETSC_DEPRECATED_FUNCTION(3, 18, 0, "KSPHPDDMGetDeflationMat()", ) static inline PetscErrorCode KSPHPDDMGetDeflationSpace(KSP ksp, Mat *U)
446: {
447: return KSPHPDDMGetDeflationMat(ksp, U);
448: }
449: #endif
450: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "KSPMatSolve()", ) static inline PetscErrorCode KSPHPDDMMatSolve(KSP ksp, Mat B, Mat X)
451: {
452: return KSPMatSolve(ksp, B, X);
453: }
454: /*E
455: KSPHPDDMType - Type of Krylov method used by `KSPHPDDM`
457: Values:
458: + `KSP_HPDDM_TYPE_GMRES` (default) - Generalized Minimal Residual method
459: . `KSP_HPDDM_TYPE_BGMRES` - block GMRES
460: . `KSP_HPDDM_TYPE_CG` - Conjugate Gradient
461: . `KSP_HPDDM_TYPE_BCG` - block CG
462: . `KSP_HPDDM_TYPE_GCRODR` - Generalized Conjugate Residual method with inner Orthogonalization and Deflated Restarting
463: . `KSP_HPDDM_TYPE_BGCRODR` - block GCRODR
464: . `KSP_HPDDM_TYPE_BFBCG` - breakdown-free BCG
465: - `KSP_HPDDM_TYPE_PREONLY` - apply the preconditioner only
467: Level: intermediate
469: .seealso: [](ch_ksp), `KSPHPDDM`, `KSPHPDDMSetType()`
470: E*/
471: typedef enum {
472: KSP_HPDDM_TYPE_GMRES = 0,
473: KSP_HPDDM_TYPE_BGMRES = 1,
474: KSP_HPDDM_TYPE_CG = 2,
475: KSP_HPDDM_TYPE_BCG = 3,
476: KSP_HPDDM_TYPE_GCRODR = 4,
477: KSP_HPDDM_TYPE_BGCRODR = 5,
478: KSP_HPDDM_TYPE_BFBCG = 6,
479: KSP_HPDDM_TYPE_PREONLY = 7
480: } KSPHPDDMType;
481: PETSC_EXTERN const char *const KSPHPDDMTypes[];
483: PETSC_EXTERN PetscErrorCode KSPHPDDMSetType(KSP, KSPHPDDMType);
484: PETSC_EXTERN PetscErrorCode KSPHPDDMGetType(KSP, KSPHPDDMType *);
486: /*S
487: KSPOrthogonalizationFn - A function prototype for functions provided to `KSPOrthogonalizationSet()`
489: Calling Sequence:
490: + ksp - the `KSP` context
491: . V - array of previously computed orthonormal vectors
492: . n - number of vectors
493: . x - vector to be orthogonalized (may be `NULL`)
494: - h - computed orthogonalization coefficients
496: Level: intermediate
498: Note:
499: If no `x` is given, then the vector to be orthogonalized is assumed to be located at `V[n]`.
501: .seealso: [](ch_ksp), `KSP`, `KSPOrthogonalizationSet()`
502: S*/
503: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPOrthogonalizationFn(KSP ksp, Vec V[], PetscInt n, Vec x, PetscScalar h[]);
505: PETSC_EXTERN PetscErrorCode KSPOrthogonalizationSet(KSP, KSPOrthogonalizationFn *);
506: PETSC_EXTERN PetscErrorCode KSPOrthogonalizationGet(KSP, KSPOrthogonalizationFn **);
507: PETSC_EXTERN KSPOrthogonalizationFn KSPOrthogonalizationClassicalGramSchmidt;
508: PETSC_EXTERN KSPOrthogonalizationFn KSPOrthogonalizationModifiedGramSchmidt;
510: #define KSP_GMRES_CGS_REFINE_NEVER_DEPRECATED KSP_GMRES_CGS_REFINE_NEVER PETSC_DEPRECATED_ENUM(3, 26, 0, "KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER", )
511: #define KSP_GMRES_CGS_REFINE_IFNEEDED_DEPRECATED KSP_GMRES_CGS_REFINE_IFNEEDED PETSC_DEPRECATED_ENUM(3, 26, 0, "KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED", )
512: #define KSP_GMRES_CGS_REFINE_ALWAYS_DEPRECATED KSP_GMRES_CGS_REFINE_ALWAYS PETSC_DEPRECATED_ENUM(3, 26, 0, "KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS", )
513: /*E
514: KSPOrthogonalizationCGSRefinementType - How the classical (unmodified) Gram-Schmidt is performed in the GMRES solvers
516: Values:
517: + `KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER` - one step of classical Gram-Schmidt
518: . `KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED` - a second step is performed if the first step does not satisfy some criteria
519: - `KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS` - always perform two steps
521: Level: advanced
523: .seealso: [](ch_ksp), `KSP`, `KSPGMRES`, `KSPOrthogonalizationClassicalGramSchmidt()`, `KSPOrthogonalizationSet()`,
524: `KSPOrthogonalizationGet()`,
525: `KSPOrthogonalizationSetCGSRefinementType()`, `KSPOrthogonalizationGetCGSRefinementType()`, `KSPOrthogonalizationModifiedGramSchmidt()`
526: E*/
527: typedef enum {
528: KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER = 0,
529: KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED = 1,
530: KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS = 2,
531: KSP_GMRES_CGS_REFINE_NEVER_DEPRECATED = 0,
532: KSP_GMRES_CGS_REFINE_IFNEEDED_DEPRECATED = 1,
533: KSP_GMRES_CGS_REFINE_ALWAYS_DEPRECATED = 2
534: } KSPOrthogonalizationCGSRefinementType;
535: PETSC_EXTERN const char *const KSPOrthogonalizationCGSRefinementTypes[];
537: /*MC
538: KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER - Do the classical (unmodified) Gram-Schmidt process
540: Level: advanced
542: Note:
543: Possibly unstable, but the fastest to compute
545: .seealso: [](ch_ksp), `KSPGMRES`, `KSPOrthogonalizationCGSRefinementType`, `KSPOrthogonalizationClassicalGramSchmidt()`, `KSPOrthogonalizationSet()`,
546: `KSP`, `KSPOrthogonalizationGet()`,
547: `KSPOrthogonalizationSetCGSRefinementType()`, `KSPOrthogonalizationGetCGSRefinementType()`, `KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED`, `KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS`,
548: `KSPOrthogonalizationModifiedGramSchmidt()`
549: M*/
551: /*MC
552: KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED - Do the classical (unmodified) Gram-Schmidt process and one step of
553: iterative refinement if an estimate of the orthogonality of the resulting vectors indicates
554: poor orthogonality.
556: Level: advanced
558: Note:
559: This is slower than `KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER` because it requires an extra norm computation to
560: estimate the orthogonality but is more stable.
562: .seealso: [](ch_ksp), `KSPGMRES`, `KSPOrthogonalizationCGSRefinementType`, `KSPOrthogonalizationClassicalGramSchmidt()`, `KSPOrthogonalizationSet()`,
563: `KSP`, `KSPOrthogonalizationGet()`,
564: `KSPOrthogonalizationSetCGSRefinementType()`, `KSPOrthogonalizationGetCGSRefinementType()`, `KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER`, `KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS`,
565: `KSPOrthogonalizationModifiedGramSchmidt()`
566: M*/
568: /*MC
569: KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS - Do two steps of the classical (unmodified) Gram-Schmidt process.
571: Level: advanced
573: Notes:
574: This is roughly twice the cost of `KSP_ORTHOGONALIZATION_CGS_REFINE_NEVER` because it performs the process twice
575: but it saves the extra norm calculation needed by `KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED`.
577: You should only use this if you absolutely know that the iterative refinement is needed.
579: .seealso: [](ch_ksp), `KSPGMRES`, `KSPOrthogonalizationCGSRefinementType`, `KSPOrthogonalizationClassicalGramSchmidt()`, `KSPOrthogonalizationSet()`,
580: `KSP`, `KSPOrthogonalizationGet()`,
581: `KSPOrthogonalizationSetCGSRefinementType()`, `KSPOrthogonalizationGetCGSRefinementType()`, `KSP_ORTHOGONALIZATION_CGS_REFINE_IFNEEDED`, `KSP_ORTHOGONALIZATION_CGS_REFINE_ALWAYS`,
582: `KSPOrthogonalizationModifiedGramSchmidt()`
583: M*/
585: PETSC_EXTERN PetscErrorCode KSPOrthogonalizationSetCGSRefinementType(KSP, KSPOrthogonalizationCGSRefinementType);
586: PETSC_EXTERN PetscErrorCode KSPOrthogonalizationGetCGSRefinementType(KSP, KSPOrthogonalizationCGSRefinementType *);
588: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPOrthogonalizationModifiedGramSchmidt()", ) static inline PetscErrorCode KSPGMRESModifiedGramSchmidtOrthogonalization(KSP ksp, PETSC_UNUSED PetscInt it)
589: {
590: SETERRQ(PetscObjectComm((PetscObject)ksp), PETSC_ERR_SUP, "Use KSPOrthogonalizationModifiedGramSchmidt()");
591: }
592: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPOrthogonalizationClassicalGramSchmidt()", ) static inline PetscErrorCode KSPGMRESClassicalGramSchmidtOrthogonalization(KSP ksp, PETSC_UNUSED PetscInt it)
593: {
594: SETERRQ(PetscObjectComm((PetscObject)ksp), PETSC_ERR_SUP, "Use KSPOrthogonalizationClassicalGramSchmidt()");
595: }
596: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPOrthogonalizationSet()", ) static inline PetscErrorCode KSPGMRESSetOrthogonalization(KSP ksp, PETSC_UNUSED PetscErrorCode (*orthog)(KSP, PetscInt))
597: {
598: SETERRQ(PetscObjectComm((PetscObject)ksp), PETSC_ERR_SUP, "Use KSPOrthogonalizationSet()");
599: }
600: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPOrthogonalizationGet()", ) static inline PetscErrorCode KSPGMRESGetOrthogonalization(KSP ksp, PETSC_UNUSED PetscErrorCode (**orthog)(KSP, PetscInt))
601: {
602: SETERRQ(PetscObjectComm((PetscObject)ksp), PETSC_ERR_SUP, "Use KSPOrthogonalizationGet()");
603: }
604: PETSC_DEPRECATED_TYPEDEF(3, 26, 0, "KSPOrthogonalizationCGSRefinementType", ) typedef KSPOrthogonalizationCGSRefinementType KSPGMRESCGSRefinementType;
605: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPOrthogonalizationSetCGSRefinementType()", )
606: static inline PetscErrorCode KSPGMRESSetCGSRefinementType(KSP ksp, KSPOrthogonalizationCGSRefinementType type)
607: {
608: return KSPOrthogonalizationSetCGSRefinementType(ksp, type);
609: }
610: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPOrthogonalizationGetCGSRefinementType()", )
611: static inline PetscErrorCode KSPGMRESGetCGSRefinementType(KSP ksp, KSPOrthogonalizationCGSRefinementType *type)
612: {
613: return KSPOrthogonalizationGetCGSRefinementType(ksp, type);
614: }
616: PETSC_EXTERN KSPFlexibleModifyPCFn KSPFlexibleModifyPCNoChange;
617: PETSC_EXTERN KSPFlexibleModifyPCFn KSPFlexibleModifyPCKSP;
619: PETSC_DEPRECATED_FUNCTION(3, 25, 0, "KSPFlexibleModifyPCNoChange()", ) static inline PetscErrorCode KSPFGMRESModifyPCNoChange(KSP ksp, PetscInt total_its, PetscInt loc_its, PetscReal res_norm, PetscCtx ctx)
620: {
621: return KSPFlexibleModifyPCNoChange(ksp, total_its, loc_its, res_norm, ctx);
622: }
624: PETSC_DEPRECATED_FUNCTION(3, 25, 0, "KSPFlexibleModifyPCKSP()", ) static inline PetscErrorCode KSPFGMRESModifyPCKSP(KSP ksp, PetscInt total_its, PetscInt loc_its, PetscReal res_norm, PetscCtx ctx)
625: {
626: return KSPFlexibleModifyPCKSP(ksp, total_its, loc_its, res_norm, ctx);
627: }
629: PETSC_EXTERN PetscErrorCode KSPQCGSetTrustRegionRadius(KSP, PetscReal);
630: PETSC_EXTERN PetscErrorCode KSPQCGGetQuadratic(KSP, PetscReal *);
631: PETSC_EXTERN PetscErrorCode KSPQCGGetTrialStepNorm(KSP, PetscReal *);
633: PETSC_EXTERN PetscErrorCode KSPBCGSLSetXRes(KSP, PetscReal);
634: PETSC_EXTERN PetscErrorCode KSPBCGSLSetPol(KSP, PetscBool);
635: PETSC_EXTERN PetscErrorCode KSPBCGSLSetEll(KSP, PetscInt);
636: PETSC_EXTERN PetscErrorCode KSPBCGSLSetUsePseudoinverse(KSP, PetscBool);
638: PETSC_EXTERN PetscErrorCode KSPSetFromOptions(KSP);
639: PETSC_EXTERN PetscErrorCode KSPResetFromOptions(KSP);
641: PETSC_EXTERN PetscErrorCode KSPMonitorSetFromOptions(KSP, const char[], const char[], PetscCtx);
642: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorResidual;
643: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorResidualView;
644: PETSC_DEPRECATED_FUNCTION(3, 23, 0, "KSPMonitorResidualDraw()", ) static inline PetscErrorCode KSPMonitorResidualDraw(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
645: {
646: return KSPMonitorResidualView(ksp, n, rnorm, vf);
647: }
648: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorResidualDrawLG;
649: PETSC_EXTERN PetscErrorCode KSPMonitorResidualDrawLGCreate(PetscViewer, PetscViewerFormat, PetscCtx, PetscViewerAndFormat **);
650: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "KSPMonitorResidual()", ) static inline PetscErrorCode KSPMonitorResidualShort(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
651: {
652: return KSPMonitorResidual(ksp, n, rnorm, vf);
653: }
654: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorResidualRange;
655: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorTrueResidual;
656: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorTrueResidualView;
657: PETSC_DEPRECATED_FUNCTION(3, 23, 0, "KSPMonitorTrueResidualDraw()", ) static inline PetscErrorCode KSPMonitorTrueResidualDraw(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
658: {
659: return KSPMonitorTrueResidualView(ksp, n, rnorm, vf);
660: }
661: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorTrueResidualDrawLG;
662: PETSC_EXTERN PetscErrorCode KSPMonitorTrueResidualDrawLGCreate(PetscViewer, PetscViewerFormat, PetscCtx, PetscViewerAndFormat **);
663: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorTrueResidualMax;
664: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorError;
665: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorErrorDraw;
666: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorErrorDrawLG;
667: PETSC_EXTERN PetscErrorCode KSPMonitorErrorDrawLGCreate(PetscViewer, PetscViewerFormat, PetscCtx, PetscViewerAndFormat **);
668: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorSolution;
669: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorSolutionDraw;
670: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorSolutionDrawLG;
671: PETSC_EXTERN PetscErrorCode KSPMonitorSolutionDrawLGCreate(PetscViewer, PetscViewerFormat, PetscCtx, PetscViewerAndFormat **);
672: PETSC_EXTERN KSPMonitorRegisterFn KSPMonitorSingularValue;
673: PETSC_EXTERN PetscErrorCode KSPMonitorSingularValueCreate(PetscViewer, PetscViewerFormat, PetscCtx, PetscViewerAndFormat **);
674: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "KSPMonitorResidual()", ) static inline PetscErrorCode KSPMonitorDefault(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
675: {
676: return KSPMonitorResidual(ksp, n, rnorm, vf);
677: }
678: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "KSPMonitorTrueResidual()", ) static inline PetscErrorCode KSPMonitorTrueResidualNorm(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
679: {
680: return KSPMonitorTrueResidual(ksp, n, rnorm, vf);
681: }
682: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "KSPMonitorTrueResidualMax()", ) static inline PetscErrorCode KSPMonitorTrueResidualMaxNorm(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
683: {
684: return KSPMonitorTrueResidualMax(ksp, n, rnorm, vf);
685: }
687: PETSC_EXTERN PetscErrorCode KSPGMRESMonitorKrylov(KSP, PetscInt, PetscReal, void *);
688: PETSC_EXTERN PetscErrorCode KSPMonitorDynamicTolerance(KSP, PetscInt, PetscReal, PetscCtx);
689: PETSC_EXTERN PetscErrorCode KSPMonitorDynamicToleranceDestroy(PetscCtxRt);
690: PETSC_EXTERN PetscErrorCode KSPMonitorDynamicToleranceCreate(void *);
691: PETSC_EXTERN PetscErrorCode KSPMonitorDynamicToleranceSetCoefficient(void *, PetscReal);
692: PETSC_EXTERN PetscErrorCode KSPMonitorSAWs(KSP, PetscInt, PetscReal, void *);
693: PETSC_EXTERN PetscErrorCode KSPMonitorSAWsCreate(KSP, void **);
694: PETSC_EXTERN PetscErrorCode KSPMonitorSAWsDestroy(PetscCtxRt);
696: PETSC_EXTERN PetscErrorCode KSPUnwindPreconditioner(KSP, Vec, Vec);
697: PETSC_EXTERN PetscErrorCode KSPInitialResidual(KSP, Vec, Vec, Vec, Vec, Vec);
699: PETSC_EXTERN PetscErrorCode KSPSetOperators(KSP, Mat, Mat);
700: PETSC_EXTERN PetscErrorCode KSPGetOperators(KSP, Mat *, Mat *);
701: PETSC_EXTERN PetscErrorCode KSPGetOperatorsSet(KSP, PetscBool *, PetscBool *);
702: PETSC_EXTERN PetscErrorCode KSPSetOptionsPrefix(KSP, const char[]);
703: PETSC_EXTERN PetscErrorCode KSPAppendOptionsPrefix(KSP, const char[]);
704: PETSC_EXTERN PetscErrorCode KSPGetOptionsPrefix(KSP, const char *[]);
706: /*S
707: KSPConvergedReasonViewFn - A prototype of a function used with `KSPConvergedReasonViewSet()`
709: Calling Sequence:
710: + ksp - the `KSP` object whose `KSPConvergedReason` is to be viewed
711: - ctx - context used by the function, set with `KSPConvergedReasonViewSet()`
713: Level: beginner
715: .seealso: [](ch_ksp), `KSP`, `KSPConvergedReasonView()`, `KSPConvergedReasonViewSet()`, `KSPConvergedReasonViewFromOptions()`, `KSPView()`
716: S*/
717: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPConvergedReasonViewFn(KSP ksp, PetscCtx ctx);
719: PETSC_EXTERN PetscErrorCode KSPView(KSP, PetscViewer);
720: PETSC_EXTERN PetscErrorCode KSPLoad(KSP, PetscViewer);
721: PETSC_EXTERN PetscErrorCode KSPViewFromOptions(KSP, PetscObject, const char[]);
722: PETSC_EXTERN PetscErrorCode KSPConvergedReasonView(KSP, PetscViewer);
723: PETSC_EXTERN PetscErrorCode KSPConvergedReasonViewSet(KSP, KSPConvergedReasonViewFn *, void *, PetscCtxDestroyFn *);
724: PETSC_EXTERN PetscErrorCode KSPConvergedReasonViewFromOptions(KSP);
725: PETSC_EXTERN PetscErrorCode KSPConvergedReasonViewCancel(KSP);
726: PETSC_EXTERN PetscErrorCode KSPConvergedRateView(KSP, PetscViewer);
728: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "KSPConvergedReasonView()", ) static inline PetscErrorCode KSPReasonView(KSP ksp, PetscViewer v)
729: {
730: return KSPConvergedReasonView(ksp, v);
731: }
732: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "KSPConvergedReasonViewFromOptions()", ) static inline PetscErrorCode KSPReasonViewFromOptions(KSP ksp)
733: {
734: return KSPConvergedReasonViewFromOptions(ksp);
735: }
737: #define KSP_FILE_CLASSID 1211223
739: PETSC_EXTERN PetscErrorCode KSPLSQRSetExactMatNorm(KSP, PetscBool);
740: PETSC_EXTERN PetscErrorCode KSPLSQRSetComputeStandardErrorVec(KSP, PetscBool);
741: PETSC_EXTERN PetscErrorCode KSPLSQRGetStandardErrorVec(KSP, Vec *);
742: PETSC_EXTERN PetscErrorCode KSPLSQRGetNorms(KSP, PetscReal *, PetscReal *);
743: PETSC_EXTERN KSPMonitorRegisterFn KSPLSQRMonitorResidual;
744: PETSC_EXTERN KSPMonitorRegisterFn KSPLSQRMonitorResidualDrawLG;
745: PETSC_EXTERN PetscErrorCode KSPLSQRMonitorResidualDrawLGCreate(PetscViewer, PetscViewerFormat, void *, PetscViewerAndFormat **);
747: PETSC_EXTERN PetscErrorCode PCRedundantGetKSP(PC, KSP *);
748: PETSC_EXTERN PetscErrorCode PCRedistributeGetKSP(PC, KSP *);
749: PETSC_EXTERN PetscErrorCode PCTelescopeGetKSP(PC, KSP *);
750: PETSC_EXTERN PetscErrorCode PCMPIGetKSP(PC, KSP *);
752: /*E
753: KSPNormType - Norm calculated by the `KSP` and passed in the Krylov convergence
754: test routines.
756: Values:
757: + `KSP_NORM_DEFAULT` - use the default for the current `KSPType`
758: . `KSP_NORM_NONE` - use no norm calculation
759: . `KSP_NORM_PRECONDITIONED` - use the preconditioned residual norm
760: . `KSP_NORM_UNPRECONDITIONED` - use the unpreconditioned residual norm
761: - `KSP_NORM_NATURAL` - use the natural norm (the norm induced by the linear operator)
763: Level: advanced
765: Note:
766: Each solver only supports a subset of these and some may support different ones
767: depending on whether left or right preconditioning is used, see `KSPSetPCSide()`
769: .seealso: [](ch_ksp), `KSP`, `PCSide`, `KSPSolve()`, `KSPGetConvergedReason()`, `KSPSetNormType()`,
770: `KSPSetConvergenceTest()`, `KSPSetPCSide()`, `KSP_NORM_DEFAULT`, `KSP_NORM_NONE`, `KSP_NORM_PRECONDITIONED`, `KSP_NORM_UNPRECONDITIONED`, `KSP_NORM_NATURAL`
771: E*/
772: typedef enum {
773: KSP_NORM_DEFAULT = -1,
774: KSP_NORM_NONE = 0,
775: KSP_NORM_PRECONDITIONED = 1,
776: KSP_NORM_UNPRECONDITIONED = 2,
777: KSP_NORM_NATURAL = 3
778: } KSPNormType;
779: #define KSP_NORM_MAX (KSP_NORM_NATURAL + 1)
780: PETSC_EXTERN const char *const *const KSPNormTypes;
782: /*MC
783: KSP_NORM_NONE - Do not compute a norm during the Krylov process. This will
784: possibly save some computation but means the convergence test cannot
785: be based on a norm of a residual etc.
787: Level: advanced
789: Note:
790: Some Krylov methods need to compute a residual norm (such as `KPSGMRES`) and then this option is ignored
792: .seealso: [](ch_ksp), `KSPNormType`, `KSP`, `KSPSetNormType()`, `KSP_NORM_PRECONDITIONED`, `KSP_NORM_UNPRECONDITIONED`, `KSP_NORM_NATURAL`
793: M*/
795: /*MC
796: KSP_NORM_PRECONDITIONED - Compute the norm of the preconditioned residual B*(b - A*x), if left preconditioning, and pass that to the
797: convergence test routine.
799: Level: advanced
801: .seealso: [](ch_ksp), `KSPNormType`, `KSP`, `KSPSetNormType()`, `KSP_NORM_NONE`, `KSP_NORM_UNPRECONDITIONED`, `KSP_NORM_NATURAL`, `KSPSetConvergenceTest()`
802: M*/
804: /*MC
805: KSP_NORM_UNPRECONDITIONED - Compute the norm of the true residual (b - A*x) and pass that to the
806: convergence test routine.
808: Level: advanced
810: .seealso: [](ch_ksp), `KSPNormType`, `KSP`, `KSPSetNormType()`, `KSP_NORM_NONE`, `KSP_NORM_PRECONDITIONED`, `KSP_NORM_NATURAL`, `KSPSetConvergenceTest()`
811: M*/
813: /*MC
814: KSP_NORM_NATURAL - Compute the 'natural norm' of residual sqrt((b - A*x)*B*(b - A*x)) and pass that to the
815: convergence test routine. This is only supported by `KSPCG`, `KSPCR`, `KSPCGNE`, `KSPCGS`, `KSPFCG`, `KSPPIPEFCG`, `KSPPIPEGCR`
817: Level: advanced
819: .seealso: [](ch_ksp), `KSPNormType`, `KSP`, `KSPSetNormType()`, `KSP_NORM_NONE`, `KSP_NORM_PRECONDITIONED`, `KSP_NORM_UNPRECONDITIONED`, `KSPSetConvergenceTest()`
820: M*/
822: PETSC_EXTERN PetscErrorCode KSPSetNormType(KSP, KSPNormType);
823: PETSC_EXTERN PetscErrorCode KSPGetNormType(KSP, KSPNormType *);
824: PETSC_EXTERN PetscErrorCode KSPSetSupportedNorm(KSP, KSPNormType, PCSide, PetscInt);
825: PETSC_EXTERN PetscErrorCode KSPSetCheckNormIteration(KSP, PetscInt);
826: PETSC_EXTERN PetscErrorCode KSPSetLagNorm(KSP, PetscBool);
828: #define KSP_CONVERGED_CG_NEG_CURVE_DEPRECATED KSP_CONVERGED_CG_NEG_CURVE PETSC_DEPRECATED_ENUM(3, 19, 0, "KSP_CONVERGED_NEG_CURVE", )
829: #define KSP_CONVERGED_CG_CONSTRAINED_DEPRECATED KSP_CONVERGED_CG_CONSTRAINED PETSC_DEPRECATED_ENUM(3, 19, 0, "KSP_CONVERGED_STEP_LENGTH", )
830: #define KSP_CONVERGED_RTOL_NORMAL_DEPRECATED KSP_CONVERGED_RTOL_NORMAL PETSC_DEPRECATED_ENUM(3, 24, 0, "KSP_CONVERGED_RTOL_NORMAL_EQUATIONS", )
831: #define KSP_CONVERGED_ATOL_NORMAL_DEPRECATED KSP_CONVERGED_ATOL_NORMAL PETSC_DEPRECATED_ENUM(3, 24, 0, "KSP_CONVERGED_ATOL_NORMAL_EQUATIONS", )
832: /*E
833: KSPConvergedReason - reason a Krylov method was determined to have converged or diverged
835: Values:
836: + `KSP_CONVERGED_RTOL_NORMAL_EQUATIONS` - requested decrease in the residual of the normal equations, for `KSPLSQR`
837: . `KSP_CONVERGED_ATOL_NORMAL_EQUATIONS` - requested absolute value in the residual of the normal equations, for `KSPLSQR`
838: . `KSP_CONVERGED_RTOL` - requested decrease in the residual
839: . `KSP_CONVERGED_ATOL` - requested absolute value in the residual
840: . `KSP_CONVERGED_ITS` - requested number of iterations
841: . `KSP_CONVERGED_NEG_CURVE` - see note below
842: . `KSP_CONVERGED_STEP_LENGTH` - see note below
843: . `KSP_CONVERGED_HAPPY_BREAKDOWN` - happy breakdown (meaning early convergence of the `KSPType` occurred).
844: . `KSP_CONVERGED_USER` - the user has indicated convergence for an arbitrary reason
845: . `KSP_DIVERGED_NULL` - breakdown when solving the Hessenberg system within `KSPGMRES`
846: . `KSP_DIVERGED_ITS` - requested number of iterations
847: . `KSP_DIVERGED_DTOL` - large increase in the residual norm indicating the solution is diverging
848: . `KSP_DIVERGED_BREAKDOWN` - breakdown in the Krylov method
849: . `KSP_DIVERGED_BREAKDOWN_BICG` - breakdown in the `KSPBCGS` Krylov method
850: . `KSP_DIVERGED_NONSYMMETRIC` - the operator or preonditioner was not symmetric for a `KSPType` that requires symmetry
851: . `KSP_DIVERGED_INDEFINITE_PC` - the preconditioner was indefinite for a `KSPType` that requires it be definite, such as `KSPCG`
852: . `KSP_DIVERGED_NANORINF` - a not a number of infinity was detected in a vector during the computation
853: . `KSP_DIVERGED_INDEFINITE_MAT` - the operator was indefinite for a `KSPType` that requires it be definite, such as `KSPCG`
854: . `KSP_DIVERGED_PC_FAILED` - the action of the preconditioner failed for some reason
855: - `KSP_DIVERGED_USER` - the user has indicated divergence for an arbitrary reason
857: Level: beginner
859: Note:
860: The values `KSP_CONVERGED_NEG_CURVE`, and `KSP_CONVERGED_STEP_LENGTH` are returned only by `KSPCG`, `KSPMINRES` and by
861: the special `KSPNASH`, `KSPSTCG`, and `KSPGLTR` solvers which are used by the `SNESNEWTONTR` (trust region) solver.
863: Developer Note:
864: The string versions of these are `KSPConvergedReasons`; if you change
865: any of the values here also change them that array of names.
867: .seealso: [](ch_ksp), `KSP`, `KSPSolve()`, `KSPGetConvergedReason()`, `KSPSetTolerances()`, `KSPConvergedReasonView()`
868: E*/
869: typedef enum { /* converged */
870: KSP_CONVERGED_RTOL_NORMAL_DEPRECATED = 1,
871: KSP_CONVERGED_RTOL_NORMAL_EQUATIONS = 1,
872: KSP_CONVERGED_ATOL_NORMAL_DEPRECATED = 9,
873: KSP_CONVERGED_ATOL_NORMAL_EQUATIONS = 9,
874: KSP_CONVERGED_RTOL = 2,
875: KSP_CONVERGED_ATOL = 3,
876: KSP_CONVERGED_ITS = 4,
877: KSP_CONVERGED_NEG_CURVE = 5,
878: KSP_CONVERGED_CG_NEG_CURVE_DEPRECATED = 5,
879: KSP_CONVERGED_CG_CONSTRAINED_DEPRECATED = 6,
880: KSP_CONVERGED_STEP_LENGTH = 6,
881: KSP_CONVERGED_HAPPY_BREAKDOWN = 7,
882: KSP_CONVERGED_USER = 8,
883: /* diverged */
884: KSP_DIVERGED_NULL = -2,
885: KSP_DIVERGED_ITS = -3,
886: KSP_DIVERGED_DTOL = -4,
887: KSP_DIVERGED_BREAKDOWN = -5,
888: KSP_DIVERGED_BREAKDOWN_BICG = -6,
889: KSP_DIVERGED_NONSYMMETRIC = -7,
890: KSP_DIVERGED_INDEFINITE_PC = -8,
891: KSP_DIVERGED_NANORINF = -9,
892: KSP_DIVERGED_INDEFINITE_MAT = -10,
893: KSP_DIVERGED_PC_FAILED = -11,
894: KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED = -11,
895: KSP_DIVERGED_USER = -12,
897: KSP_CONVERGED_ITERATING = 0
898: } KSPConvergedReason;
899: PETSC_EXTERN const char *const *KSPConvergedReasons;
901: /*MC
902: KSP_CONVERGED_RTOL - $||r|| \le rtol*||b||$ or $rtol*||b - A*x_0||$ if `KSPConvergedDefaultSetUIRNorm()` was called
904: Level: beginner
906: Notes:
907: See `KSPNormType` and `KSPSetNormType()` for possible norms that may be used. By default
908: for left preconditioning it is the 2-norm of the preconditioned residual, and the
909: 2-norm of the residual for right preconditioning
911: See also `KSP_CONVERGED_ATOL` which may apply before this tolerance.
913: .seealso: [](ch_ksp), `KSPNormType`, `KSP_CONVERGED_ATOL`, `KSP_DIVERGED_DTOL`, `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
914: M*/
916: /*MC
917: KSP_CONVERGED_ATOL - $||r|| \le atol$
919: Level: beginner
921: Notes:
922: See `KSPNormType` and `KSPSetNormType()` for possible norms that may be used. By default
923: for left preconditioning it is the 2-norm of the preconditioned residual, and the
924: 2-norm of the residual for right preconditioning
926: See also `KSP_CONVERGED_RTOL` which may apply before this tolerance.
928: .seealso: [](ch_ksp), `KSPNormType`, `KSP_CONVERGED_RTOL`, `KSP_DIVERGED_DTOL`, `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
929: M*/
931: /*MC
932: KSP_DIVERGED_DTOL - $||r|| \ge dtol*||b||$
934: Level: beginner
936: Note:
937: See `KSPNormType` and `KSPSetNormType()` for possible norms that may be used. By default
938: for left preconditioning it is the 2-norm of the preconditioned residual, and the
939: 2-norm of the residual for right preconditioning
941: .seealso: [](ch_ksp), `KSPNormType`, `KSP_CONVERGED_ATOL`, `KSP_CONVERGED_RTOL`, `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
942: M*/
944: /*MC
945: KSP_DIVERGED_ITS - Ran out of iterations before any convergence criteria was
946: reached
948: Level: beginner
950: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
951: M*/
953: /*MC
954: KSP_CONVERGED_ITS - Used by the `KSPPREONLY` solver after the single iteration of
955: the preconditioner is applied. Also used when the `KSPConvergedSkip()` convergence
956: test routine is set in `KSP`.
958: Level: beginner
960: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
961: M*/
963: /*MC
964: KSP_DIVERGED_BREAKDOWN - A breakdown in the Krylov method was detected so the
965: method could not continue to enlarge the Krylov space. Could be due to a singular matrix or
966: preconditioner. In `KSPHPDDM`, this is also returned when some search directions within a block
967: are collinear.
969: Level: beginner
971: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
972: M*/
974: /*MC
975: KSP_DIVERGED_BREAKDOWN_BICG - A breakdown in the `KSPBICG` method was detected so the
976: method could not continue to enlarge the Krylov space.
978: Level: beginner
980: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
981: M*/
983: /*MC
984: KSP_DIVERGED_NONSYMMETRIC - It appears the operator or preconditioner is not
985: symmetric and this Krylov method (`KSPCG`, `KSPMINRES`, `KSPCR`) requires symmetry
987: Level: beginner
989: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
990: M*/
992: /*MC
993: KSP_DIVERGED_INDEFINITE_PC - It appears the preconditioner is indefinite (has both
994: positive and negative eigenvalues) and this Krylov method (`KSPCG`) requires it to
995: be symmetric positive definite (SPD).
997: Level: beginner
999: Note:
1000: This can happen with the `PCICC` preconditioner, use the options database option `-pc_factor_shift_positive_definite` to force
1001: the `PCICC` preconditioner to generate a positive definite preconditioner
1003: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
1004: M*/
1006: /*MC
1007: KSP_DIVERGED_PC_FAILED - It was not possible to build or use the requested preconditioner. This is usually due to a
1008: zero pivot in a factorization. It can also result from a failure in a subpreconditioner inside a nested preconditioner
1009: such as `PCFIELDSPLIT`.
1011: Level: beginner
1013: Note:
1014: Run with `-ksp_error_if_not_converged` to stop the program when the error is detected and print an error message with details.
1016: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
1017: M*/
1019: /*MC
1020: KSP_CONVERGED_ITERATING - This flag is returned if `KSPGetConvergedReason()` is called
1021: while `KSPSolve()` is still running.
1023: Level: beginner
1025: .seealso: [](ch_ksp), `KSPSolve()`, `KSPGetConvergedReason()`, `KSPConvergedReason`, `KSPSetTolerances()`
1026: M*/
1028: /*S
1029: KSPConvergenceTestFn - A prototype of a function used with `KSPSetConvergenceTest()`
1031: Calling Sequence:
1032: + ksp - iterative solver obtained from `KSPCreate()`
1033: . it - iteration number
1034: . rnorm - (estimated) 2-norm of (preconditioned) residual
1035: . reason - the reason why it has converged or diverged
1036: - ctx - optional convergence context, as set by `KSPSetConvergenceTest()`
1038: Level: beginner
1040: .seealso: [](ch_ksp), `KSP`, `KSPSetConvergenceTest()`, `KSPGetConvergenceTest()`
1041: S*/
1042: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPConvergenceTestFn(KSP ksp, PetscInt it, PetscReal rnorm, KSPConvergedReason *reason, PetscCtx ctx);
1044: PETSC_EXTERN PetscErrorCode KSPSetConvergenceTest(KSP, KSPConvergenceTestFn *, void *, PetscCtxDestroyFn *);
1045: PETSC_EXTERN PetscErrorCode KSPGetConvergenceTest(KSP, KSPConvergenceTestFn **, PetscCtxRt, PetscCtxDestroyFn **);
1046: PETSC_EXTERN PetscErrorCode KSPGetAndClearConvergenceTest(KSP, KSPConvergenceTestFn **, PetscCtxRt, PetscCtxDestroyFn **);
1047: PETSC_EXTERN PetscErrorCode KSPGetConvergenceContext(KSP, PetscCtxRt);
1048: PETSC_EXTERN KSPConvergenceTestFn KSPConvergedDefault;
1049: PETSC_EXTERN KSPConvergenceTestFn KSPLSQRConvergedDefault;
1050: PETSC_EXTERN PetscCtxDestroyFn KSPConvergedDefaultDestroy;
1051: PETSC_EXTERN PetscErrorCode KSPConvergedDefaultCreate(void **);
1052: PETSC_EXTERN PetscErrorCode KSPConvergedDefaultSetUIRNorm(KSP);
1053: PETSC_EXTERN PetscErrorCode KSPConvergedDefaultSetUMIRNorm(KSP);
1054: PETSC_EXTERN PetscErrorCode KSPConvergedDefaultSetConvergedMaxits(KSP, PetscBool);
1055: PETSC_EXTERN PetscErrorCode KSPConvergedSkip(KSP, PetscInt, PetscReal, KSPConvergedReason *, void *);
1056: PETSC_EXTERN PetscErrorCode KSPGetConvergedReason(KSP, KSPConvergedReason *);
1057: PETSC_EXTERN PetscErrorCode KSPGetConvergedReasonString(KSP, const char *[]);
1058: PETSC_EXTERN PetscErrorCode KSPComputeConvergenceRate(KSP, PetscReal *, PetscReal *, PetscReal *, PetscReal *);
1059: PETSC_EXTERN PetscErrorCode KSPSetConvergedNegativeCurvature(KSP, PetscBool);
1060: PETSC_EXTERN PetscErrorCode KSPGetConvergedNegativeCurvature(KSP, PetscBool *);
1062: PETSC_DEPRECATED_FUNCTION(3, 5, 0, "KSPConvergedDefault()", ) static inline void KSPDefaultConverged(void)
1063: { /* never called */
1064: }
1065: #define KSPDefaultConverged (KSPDefaultConverged, KSPConvergedDefault)
1066: PETSC_DEPRECATED_FUNCTION(3, 5, 0, "KSPConvergedDefaultDestroy()", ) static inline void KSPDefaultConvergedDestroy(void)
1067: { /* never called */
1068: }
1069: #define KSPDefaultConvergedDestroy (KSPDefaultConvergedDestroy, KSPConvergedDefaultDestroy)
1070: PETSC_DEPRECATED_FUNCTION(3, 5, 0, "KSPConvergedDefaultCreate()", ) static inline void KSPDefaultConvergedCreate(void)
1071: { /* never called */
1072: }
1073: #define KSPDefaultConvergedCreate (KSPDefaultConvergedCreate, KSPConvergedDefaultCreate)
1074: PETSC_DEPRECATED_FUNCTION(3, 5, 0, "KSPConvergedDefaultSetUIRNorm()", ) static inline void KSPDefaultConvergedSetUIRNorm(void)
1075: { /* never called */
1076: }
1077: #define KSPDefaultConvergedSetUIRNorm (KSPDefaultConvergedSetUIRNorm, KSPConvergedDefaultSetUIRNorm)
1078: PETSC_DEPRECATED_FUNCTION(3, 5, 0, "KSPConvergedDefaultSetUMIRNorm()", ) static inline void KSPDefaultConvergedSetUMIRNorm(void)
1079: { /* never called */
1080: }
1081: #define KSPDefaultConvergedSetUMIRNorm (KSPDefaultConvergedSetUMIRNorm, KSPConvergedDefaultSetUMIRNorm)
1082: PETSC_DEPRECATED_FUNCTION(3, 5, 0, "KSPConvergedSkip()", ) static inline void KSPSkipConverged(void)
1083: { /* never called */
1084: }
1085: #define KSPSkipConverged (KSPSkipConverged, KSPConvergedSkip)
1087: PETSC_EXTERN PetscErrorCode KSPComputeOperator(KSP, MatType, Mat *);
1088: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "KSPComputeOperator()", ) static inline PetscErrorCode KSPComputeExplicitOperator(KSP A, Mat *B)
1089: {
1090: return KSPComputeOperator(A, PETSC_NULLPTR, B);
1091: }
1093: /*E
1094: KSPCGType - Determines what type of `KSPCG` to use
1096: Values:
1097: + `KSP_CG_SYMMETRIC` - the matrix is complex symmetric
1098: - `KSP_CG_HERMITIAN` - the matrix is complex Hermitian
1100: Level: beginner
1102: .seealso: [](ch_ksp), `KSPCG`, `KSP`, `KSPCGSetType()`
1103: E*/
1104: typedef enum {
1105: KSP_CG_SYMMETRIC = 0,
1106: KSP_CG_HERMITIAN = 1
1107: } KSPCGType;
1108: PETSC_EXTERN const char *const KSPCGTypes[];
1110: PETSC_EXTERN PetscErrorCode KSPCGSetType(KSP, KSPCGType);
1111: PETSC_EXTERN PetscErrorCode KSPCGUseSingleReduction(KSP, PetscBool);
1113: PETSC_EXTERN PetscErrorCode KSPCGSetRadius(KSP, PetscReal);
1114: PETSC_EXTERN PetscErrorCode KSPCGSetObjectiveTarget(KSP, PetscReal);
1115: PETSC_EXTERN PetscErrorCode KSPCGGetNormD(KSP, PetscReal *);
1116: PETSC_EXTERN PetscErrorCode KSPCGGetObjFcn(KSP, PetscReal *);
1118: PETSC_EXTERN PetscErrorCode KSPGLTRGetMinEig(KSP, PetscReal *);
1119: PETSC_EXTERN PetscErrorCode KSPGLTRGetLambda(KSP, PetscReal *);
1120: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "KSPGLTRGetMinEig()", ) static inline PetscErrorCode KSPCGGLTRGetMinEig(KSP ksp, PetscReal *x)
1121: {
1122: return KSPGLTRGetMinEig(ksp, x);
1123: }
1124: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "KSPGLTRGetLambda()", ) static inline PetscErrorCode KSPCGGLTRGetLambda(KSP ksp, PetscReal *x)
1125: {
1126: return KSPGLTRGetLambda(ksp, x);
1127: }
1129: PETSC_EXTERN PetscErrorCode KSPPythonSetType(KSP, const char[]);
1130: PETSC_EXTERN PetscErrorCode KSPPythonGetType(KSP, const char *[]);
1132: PETSC_EXTERN PetscErrorCode PCPreSolve(PC, KSP);
1133: PETSC_EXTERN PetscErrorCode PCPostSolve(PC, KSP);
1135: PETSC_EXTERN PetscErrorCode KSPMonitorLGRange(KSP, PetscInt, PetscReal, void *);
1137: /*S
1138: PCShellPSolveFn - A function prototype for functions provided to `PCShellSetPreSolve()` and `PCShellSetPostSolve()`
1140: Calling Sequence:
1141: + pc - the preconditioner `PC` context
1142: . ksp - the `KSP` context
1143: . xin - input vector
1144: - xout - output vector
1146: Level: intermediate
1148: .seealso: [](ch_snes), `KSPPSolveFn`, `KSP`, `PCShellSetPreSolve()`, `PCShellSetPostSolve()`
1149: S*/
1150: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode PCShellPSolveFn(PC pc, KSP ksp, Vec xim, Vec xout);
1152: PETSC_EXTERN PetscErrorCode PCShellSetPreSolve(PC, PCShellPSolveFn *);
1153: PETSC_EXTERN PetscErrorCode PCShellSetPostSolve(PC, PCShellPSolveFn *);
1155: /*S
1156: KSPGuess - Abstract PETSc object that manages all initial guess generation methods for Krylov methods.
1158: Level: intermediate
1160: Note:
1161: These methods generate initial guesses based on a series of previous, related, linear solves. For example,
1162: in implicit time-stepping with `TS`.
1164: .seealso: [](ch_ksp), `KSPCreate()`, `KSPGuessSetType()`, `KSPGuessType`
1165: S*/
1166: typedef struct _p_KSPGuess *KSPGuess;
1168: /*J
1169: KSPGuessType - String with the name of a PETSc initial guess approach for Krylov methods.
1171: Values:
1172: + `KSPGUESSFISCHER` - methodology developed by Paul Fischer
1173: - `KSPGUESSPOD` - methodology based on proper orthogonal decomposition (POD)
1175: Options Database Key:
1176: . -ksp_guess_type (fischer|pod) - set the type
1178: Level: intermediate
1180: .seealso: [](ch_ksp), `KSP`, `KSPGuess`, `KSPGuessSetType()`
1181: J*/
1182: typedef const char *KSPGuessType;
1183: #define KSPGUESSFISCHER "fischer"
1184: #define KSPGUESSPOD "pod"
1186: PETSC_EXTERN PetscErrorCode KSPGuessRegister(const char[], PetscErrorCode (*)(KSPGuess));
1187: PETSC_EXTERN PetscErrorCode KSPSetGuess(KSP, KSPGuess);
1188: PETSC_EXTERN PetscErrorCode KSPGetGuess(KSP, KSPGuess *);
1189: PETSC_EXTERN PetscErrorCode KSPGuessView(KSPGuess, PetscViewer);
1190: PETSC_EXTERN PetscErrorCode KSPGuessDestroy(KSPGuess *);
1191: PETSC_EXTERN PetscErrorCode KSPGuessCreate(MPI_Comm, KSPGuess *);
1192: PETSC_EXTERN PetscErrorCode KSPGuessSetType(KSPGuess, KSPGuessType);
1193: PETSC_EXTERN PetscErrorCode KSPGuessGetType(KSPGuess, KSPGuessType *);
1194: PETSC_EXTERN PetscErrorCode KSPGuessSetTolerance(KSPGuess, PetscReal);
1195: PETSC_EXTERN PetscErrorCode KSPGuessSetUp(KSPGuess);
1196: PETSC_EXTERN PetscErrorCode KSPGuessUpdate(KSPGuess, Vec, Vec);
1197: PETSC_EXTERN PetscErrorCode KSPGuessFormGuess(KSPGuess, Vec, Vec);
1198: PETSC_EXTERN PetscErrorCode KSPGuessSetFromOptions(KSPGuess);
1199: PETSC_EXTERN PetscErrorCode KSPGuessFischerSetModel(KSPGuess, PetscInt, PetscInt);
1200: PETSC_EXTERN PetscErrorCode KSPSetUseFischerGuess(KSP, PetscInt, PetscInt);
1201: PETSC_EXTERN PetscErrorCode KSPSetInitialGuessKnoll(KSP, PetscBool);
1202: PETSC_EXTERN PetscErrorCode KSPGetInitialGuessKnoll(KSP, PetscBool *);
1204: /*E
1205: MatSchurComplementAinvType - Determines how to approximate the inverse of the (0,0) block in Schur complement matrix assembly routines
1207: Level: intermediate
1209: .seealso: `MatSchurComplementGetAinvType()`, `MatSchurComplementSetAinvType()`, `MatSchurComplementGetPmat()`, `MatGetSchurComplement()`,
1210: `MatCreateSchurComplementPmat()`, `MatCreateSchurComplement()`
1211: E*/
1212: typedef enum {
1213: MAT_SCHUR_COMPLEMENT_AINV_DIAG,
1214: MAT_SCHUR_COMPLEMENT_AINV_LUMP,
1215: MAT_SCHUR_COMPLEMENT_AINV_BLOCK_DIAG,
1216: MAT_SCHUR_COMPLEMENT_AINV_FULL
1217: } MatSchurComplementAinvType;
1218: PETSC_EXTERN const char *const MatSchurComplementAinvTypes[];
1220: PETSC_EXTERN PetscErrorCode MatCreateSchurComplement(Mat, Mat, Mat, Mat, Mat, Mat *);
1221: PETSC_EXTERN PetscErrorCode MatSchurComplementGetKSP(Mat, KSP *);
1222: PETSC_EXTERN PetscErrorCode MatSchurComplementSetKSP(Mat, KSP);
1223: PETSC_EXTERN PetscErrorCode MatSchurComplementSetSubMatrices(Mat, Mat, Mat, Mat, Mat, Mat);
1224: PETSC_EXTERN PetscErrorCode MatSchurComplementUpdateSubMatrices(Mat, Mat, Mat, Mat, Mat, Mat);
1225: PETSC_EXTERN PetscErrorCode MatSchurComplementGetSubMatrices(Mat, Mat *, Mat *, Mat *, Mat *, Mat *);
1226: PETSC_EXTERN PetscErrorCode MatSchurComplementSetAinvType(Mat, MatSchurComplementAinvType);
1227: PETSC_EXTERN PetscErrorCode MatSchurComplementGetAinvType(Mat, MatSchurComplementAinvType *);
1228: PETSC_EXTERN PetscErrorCode MatSchurComplementGetPmat(Mat, MatReuse, Mat *);
1229: PETSC_EXTERN PetscErrorCode MatSchurComplementComputeExplicitOperator(Mat, Mat *);
1230: PETSC_EXTERN PetscErrorCode MatGetSchurComplement(Mat, IS, IS, IS, IS, MatReuse, Mat *, MatSchurComplementAinvType, MatReuse, Mat *);
1231: PETSC_EXTERN PetscErrorCode MatCreateSchurComplementPmat(Mat, Mat, Mat, Mat, MatSchurComplementAinvType, MatReuse, Mat *);
1233: PETSC_EXTERN PetscErrorCode MatCreateLMVMDFP(MPI_Comm, PetscInt, PetscInt, Mat *);
1234: PETSC_EXTERN PetscErrorCode MatCreateLMVMBFGS(MPI_Comm, PetscInt, PetscInt, Mat *);
1235: PETSC_EXTERN PetscErrorCode MatCreateLMVMDBFGS(MPI_Comm, PetscInt, PetscInt, Mat *);
1236: PETSC_EXTERN PetscErrorCode MatCreateLMVMDDFP(MPI_Comm, PetscInt, PetscInt, Mat *);
1237: PETSC_EXTERN PetscErrorCode MatCreateLMVMDQN(MPI_Comm, PetscInt, PetscInt, Mat *);
1238: PETSC_EXTERN PetscErrorCode MatCreateLMVMSR1(MPI_Comm, PetscInt, PetscInt, Mat *);
1239: PETSC_EXTERN PetscErrorCode MatCreateLMVMBroyden(MPI_Comm, PetscInt, PetscInt, Mat *);
1240: PETSC_EXTERN PetscErrorCode MatCreateLMVMBadBroyden(MPI_Comm, PetscInt, PetscInt, Mat *);
1241: PETSC_EXTERN PetscErrorCode MatCreateLMVMSymBroyden(MPI_Comm, PetscInt, PetscInt, Mat *);
1242: PETSC_EXTERN PetscErrorCode MatCreateLMVMSymBadBroyden(MPI_Comm, PetscInt, PetscInt, Mat *);
1243: PETSC_EXTERN PetscErrorCode MatCreateLMVMDiagBroyden(MPI_Comm, PetscInt, PetscInt, Mat *);
1245: PETSC_EXTERN PetscErrorCode MatLMVMUpdate(Mat, Vec, Vec);
1246: PETSC_EXTERN PetscErrorCode MatLMVMIsAllocated(Mat, PetscBool *);
1247: PETSC_EXTERN PetscErrorCode MatLMVMAllocate(Mat, Vec, Vec);
1248: PETSC_EXTERN PetscErrorCode MatLMVMReset(Mat, PetscBool);
1249: PETSC_EXTERN PetscErrorCode MatLMVMResetShift(Mat);
1250: PETSC_EXTERN PetscErrorCode MatLMVMClearJ0(Mat);
1251: PETSC_EXTERN PetscErrorCode MatLMVMSetJ0(Mat, Mat);
1252: PETSC_EXTERN PetscErrorCode MatLMVMSetJ0Scale(Mat, PetscReal);
1253: PETSC_EXTERN PetscErrorCode MatLMVMSetJ0Diag(Mat, Vec);
1254: PETSC_EXTERN PetscErrorCode MatLMVMSetJ0PC(Mat, PC);
1255: PETSC_EXTERN PetscErrorCode MatLMVMSetJ0KSP(Mat, KSP);
1256: PETSC_EXTERN PetscErrorCode MatLMVMApplyJ0Fwd(Mat, Vec, Vec);
1257: PETSC_EXTERN PetscErrorCode MatLMVMApplyJ0Inv(Mat, Vec, Vec);
1258: PETSC_EXTERN PetscErrorCode MatLMVMGetLastUpdate(Mat, Vec *, Vec *);
1259: PETSC_EXTERN PetscErrorCode MatLMVMGetJ0(Mat, Mat *);
1260: PETSC_EXTERN PetscErrorCode MatLMVMGetJ0PC(Mat, PC *);
1261: PETSC_EXTERN PetscErrorCode MatLMVMGetJ0KSP(Mat, KSP *);
1262: PETSC_EXTERN PetscErrorCode MatLMVMSetHistorySize(Mat, PetscInt);
1263: PETSC_EXTERN PetscErrorCode MatLMVMGetHistorySize(Mat, PetscInt *);
1264: PETSC_EXTERN PetscErrorCode MatLMVMGetUpdateCount(Mat, PetscInt *);
1265: PETSC_EXTERN PetscErrorCode MatLMVMGetRejectCount(Mat, PetscInt *);
1266: PETSC_EXTERN PetscErrorCode MatLMVMSymBroydenSetDelta(Mat, PetscScalar);
1268: /*E
1269: MatLMVMMultAlgorithm - The type of algorithm used for matrix-vector products and solves used internally by a `MatLMVM` matrix
1271: Values:
1272: + `MAT_LMVM_MULT_RECURSIVE` - Use recursive formulas for products and solves
1273: . `MAT_LMVM_MULT_DENSE` - Use dense formulas for products and solves when possible
1274: - `MAT_LMVM_MULT_COMPACT_DENSE` - The same as `MATLMVM_MULT_DENSE`, but go further and ensure products and solves are computed in compact low-rank update form
1276: Level: advanced
1278: Options Database Keys:
1279: . -mat_lmvm_mult_algorithm (recursive|dense|compact_dense) - the algorithm to use for multiplication
1281: .seealso: [](ch_matrices), `MATLMVM`, `MatLMVMSetMultAlgorithm()`, `MatLMVMGetMultAlgorithm()`
1282: E*/
1283: typedef enum {
1284: MAT_LMVM_MULT_RECURSIVE,
1285: MAT_LMVM_MULT_DENSE,
1286: MAT_LMVM_MULT_COMPACT_DENSE,
1287: } MatLMVMMultAlgorithm;
1289: PETSC_EXTERN const char *const MatLMVMMultAlgorithms[];
1291: PETSC_EXTERN PetscErrorCode MatLMVMSetMultAlgorithm(Mat, MatLMVMMultAlgorithm);
1292: PETSC_EXTERN PetscErrorCode MatLMVMGetMultAlgorithm(Mat, MatLMVMMultAlgorithm *);
1294: /*E
1295: MatLMVMSymBroydenScaleType - Rescaling type for the initial Hessian of a symmetric Broyden matrix.
1297: Values:
1298: + `MAT_LMVM_SYMBROYDEN_SCALE_NONE` - no rescaling
1299: . `MAT_LMVM_SYMBROYDEN_SCALE_SCALAR` - scalar rescaling
1300: . `MAT_LMVM_SYMBROYDEN_SCALE_DIAGONAL` - diagonal rescaling
1301: . `MAT_LMVM_SYMBROYDEN_SCALE_USER` - same as `MAT_LMVM_SYMBROYDN_SCALE_NONE`
1302: - `MAT_LMVM_SYMBROYDEN_SCALE_DECIDE` - let PETSc decide rescaling
1304: Level: intermediate
1306: .seealso: [](ch_matrices), `MATLMVM`, `MatLMVMSymBroydenSetScaleType()`
1307: E*/
1308: typedef enum {
1309: MAT_LMVM_SYMBROYDEN_SCALE_NONE = 0,
1310: MAT_LMVM_SYMBROYDEN_SCALE_SCALAR = 1,
1311: MAT_LMVM_SYMBROYDEN_SCALE_DIAGONAL = 2,
1312: MAT_LMVM_SYMBROYDEN_SCALE_USER = 3,
1313: MAT_LMVM_SYMBROYDEN_SCALE_DECIDE = 4
1314: } MatLMVMSymBroydenScaleType;
1315: PETSC_EXTERN const char *const MatLMVMSymBroydenScaleTypes[];
1317: PETSC_EXTERN PetscErrorCode MatLMVMSymBroydenSetScaleType(Mat, MatLMVMSymBroydenScaleType);
1318: PETSC_EXTERN PetscErrorCode MatLMVMSymBroydenGetPhi(Mat, PetscReal *);
1319: PETSC_EXTERN PetscErrorCode MatLMVMSymBroydenSetPhi(Mat, PetscReal);
1320: PETSC_EXTERN PetscErrorCode MatLMVMSymBadBroydenGetPsi(Mat, PetscReal *);
1321: PETSC_EXTERN PetscErrorCode MatLMVMSymBadBroydenSetPsi(Mat, PetscReal);
1323: /*E
1324: MatLMVMDenseType - Memory storage strategy for dense variants of `MATLMVM`.
1326: Values:
1327: + `MAT_LMVM_DENSE_REORDER` - reorders memory to minimize kernel launch
1328: - `MAT_LMVM_DENSE_INPLACE` - computes inplace to minimize memory movement
1330: Level: intermediate
1332: .seealso: [](ch_matrices), `MatLMVM`, `MatLMVMDenseSetType()`
1333: E*/
1334: typedef enum {
1335: MAT_LMVM_DENSE_REORDER,
1336: MAT_LMVM_DENSE_INPLACE
1337: } MatLMVMDenseType;
1338: PETSC_EXTERN const char *const MatLMVMDenseTypes[];
1340: PETSC_EXTERN PetscErrorCode MatLMVMDenseSetType(Mat, MatLMVMDenseType);
1342: PETSC_EXTERN PetscErrorCode KSPSetDM(KSP, DM);
1344: /*E
1345: KSPDMActive - Indicates if the `DM` attached to the `KSP` should be used to compute the operator, the right-hand side, or the initial guess
1347: Values:
1348: + `KSP_DMACTIVE_OPERATOR` - compute the operator
1349: . `KSP_DMACTIVE_RHS` - compute the right-hand side
1350: . `KSP_DMACTIVE_INITIAL_GUESS` - compute the initial guess
1351: - `KSP_DMACTIVE_ALL` - compute all of them
1353: Level: intermediate
1355: .seealso: [](ch_ksp), `KSP`, `KSPSetDMActive()`, `KSPSetDM()`
1356: E*/
1357: typedef enum {
1358: KSP_DMACTIVE_OPERATOR = 1,
1359: KSP_DMACTIVE_RHS = 2,
1360: KSP_DMACTIVE_INITIAL_GUESS = 4,
1361: KSP_DMACTIVE_ALL = 1 + 2 + 4
1362: } KSPDMActive;
1363: PETSC_EXTERN PetscErrorCode KSPSetDMActive(KSP, KSPDMActive, PetscBool);
1365: PETSC_EXTERN PetscErrorCode KSPGetDM(KSP, DM *);
1366: PETSC_EXTERN PetscErrorCode KSPSetApplicationContext(KSP, PetscCtx);
1367: PETSC_EXTERN PetscErrorCode KSPGetApplicationContext(KSP, PetscCtxRt);
1369: /*S
1370: KSPComputeRHSFn - A prototype of a `KSP` evaluation function that would be passed to `KSPSetComputeRHS()`
1372: Calling Sequence:
1373: + ksp - `ksp` context
1374: . b - output vector
1375: - ctx - [optional] user-defined function context
1377: Level: beginner
1379: .seealso: [](ch_ksp), `KSP`, `KSPSetComputeRHS()`, `SNESGetFunction()`, `KSPComputeInitialGuessFn`, `KSPComputeOperatorsFn`
1380: S*/
1381: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPComputeRHSFn(KSP ksp, Vec b, PetscCtx ctx);
1383: PETSC_EXTERN PetscErrorCode KSPSetComputeRHS(KSP, KSPComputeRHSFn *, void *);
1385: /*S
1386: KSPComputeOperatorsFn - A prototype of a `KSP` evaluation function that would be passed to `KSPSetComputeOperators()`
1388: Calling Sequence:
1389: + ksp - `KSP` context
1390: . A - the operator that defines the linear system
1391: . P - an operator from which to build the preconditioner (often the same as `A`)
1392: - ctx - [optional] user-defined function context
1394: Level: beginner
1396: .seealso: [](ch_ksp), `KSP`, `KSPSetComputeRHS()`, `SNESGetFunction()`, `KSPComputeRHSFn`, `KSPComputeInitialGuessFn`
1397: S*/
1398: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPComputeOperatorsFn(KSP ksp, Mat A, Mat P, PetscCtx ctx);
1400: PETSC_EXTERN PetscErrorCode KSPSetComputeOperators(KSP, KSPComputeOperatorsFn, void *);
1402: /*S
1403: KSPCreateOperatorsFn - A prototype of a `KSP` operator creation function that would be passed to `DMKSPSetCreateOperators()`
1405: Calling Sequence:
1406: + ksp - `KSP` context
1407: . A - the created operator that defines the linear system
1408: . P - the created operator from which to build the preconditioner, often the same as `A`
1409: - ctx - [optional] user-defined function context
1411: Level: developer
1413: Notes:
1414: The returned matrices are owned by the caller, similar to `DMCreateMatrix()`.
1416: `A` and `P` may be the same object. In such a case, users do not need to increase the reference count of `A`. If `P` is not returned, then we assume it is the same of `A`.
1418: .seealso: [](ch_ksp), `DMKSPSetCreateOperators()`, `DMKSPGetCreateOperators()`, `KSPComputeOperatorsFn`, `KSPSetOperators()`
1419: S*/
1420: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPCreateOperatorsFn(KSP ksp, Mat *A, Mat *P, PetscCtx ctx);
1422: /*S
1423: KSPComputeInitialGuessFn - A prototype of a `KSP` evaluation function that would be passed to `KSPSetComputeInitialGuess()`
1425: Calling Sequence:
1426: + ksp - `ksp` context
1427: . x - output vector
1428: - ctx - [optional] user-defined function context
1430: Level: beginner
1432: .seealso: [](ch_ksp), `KSP`, `KSPSetComputeInitialGuess()`, `SNESGetFunction()`, `KSPComputeRHSFn`, `KSPComputeOperatorsFn`
1433: S*/
1434: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode KSPComputeInitialGuessFn(KSP ksp, Vec x, PetscCtx ctx);
1436: PETSC_EXTERN PetscErrorCode KSPSetComputeInitialGuess(KSP, KSPComputeInitialGuessFn *, void *);
1437: PETSC_EXTERN PetscErrorCode DMKSPSetComputeOperators(DM, KSPComputeOperatorsFn *, void *);
1438: PETSC_EXTERN PetscErrorCode DMKSPGetComputeOperators(DM, KSPComputeOperatorsFn **, void *);
1439: PETSC_EXTERN PetscErrorCode DMKSPSetCreateOperators(DM, KSPCreateOperatorsFn *, void *);
1440: PETSC_EXTERN PetscErrorCode DMKSPGetCreateOperators(DM, KSPCreateOperatorsFn **, void *);
1441: PETSC_EXTERN PetscErrorCode DMKSPSetComputeRHS(DM, KSPComputeRHSFn *, void *);
1442: PETSC_EXTERN PetscErrorCode DMKSPGetComputeRHS(DM, KSPComputeRHSFn **, void *);
1443: PETSC_EXTERN PetscErrorCode DMKSPSetComputeInitialGuess(DM, KSPComputeInitialGuessFn *, void *);
1444: PETSC_EXTERN PetscErrorCode DMKSPGetComputeInitialGuess(DM, KSPComputeInitialGuessFn **, void *);
1446: PETSC_EXTERN PetscErrorCode DMGlobalToLocalSolve(DM, Vec, Vec);
1447: PETSC_EXTERN PetscErrorCode DMSwarmProjectFields(DM, DM, PetscInt, const char *[], Vec[], ScatterMode);
1448: PETSC_EXTERN PetscErrorCode DMSwarmProjectGradientFields(DM, DM, PetscInt, const char *[], Vec[], ScatterMode);
1450: PETSC_EXTERN PetscErrorCode DMAdaptInterpolator(DM, DM, Mat, KSP, Mat, Mat, Mat *, void *);
1451: PETSC_EXTERN PetscErrorCode DMCheckInterpolator(DM, Mat, Mat, Mat, PetscReal);
1453: PETSC_EXTERN PetscErrorCode PCBJKOKKOSSetKSP(PC, KSP);
1454: PETSC_EXTERN PetscErrorCode PCBJKOKKOSGetKSP(PC, KSP *);
1456: PETSC_EXTERN PetscErrorCode DMCopyDMKSP(DM, DM);
1458: #include <petscdstypes.h>
1459: PETSC_EXTERN PetscErrorCode DMProjectField(DM, PetscReal, Vec, PetscPointFn **, InsertMode, Vec);