xref: /petsc/include/petscsnes.h (revision ad49c6e3020e95528bc71effe5cd79a1b737ce7c)
1 /*
2     User interface for the nonlinear solvers package.
3 */
4 #pragma once
5 
6 #include <petscksp.h>
7 #include <petscdmtypes.h>
8 #include <petscfvtypes.h>
9 #include <petscdmdatypes.h>
10 #include <petscsnestypes.h>
11 
12 /* SUBMANSEC = SNES */
13 
14 /*J
15    SNESType - String with the name of a PETSc `SNES` method. These are all the nonlinear solvers that PETSc provides.
16 
17    Level: beginner
18 
19    Note:
20    Use `SNESSetType()` or the options database key `-snes_type` to set the specific nonlinear solver algorithm to use with a given `SNES` object
21 
22 .seealso: [](doc_nonlinsolve), [](ch_snes), `SNESSetType()`, `SNES`, `SNESCreate()`, `SNESDestroy()`, `SNESSetFromOptions()`
23 J*/
24 typedef const char *SNESType;
25 #define SNESNEWTONLS         "newtonls"
26 #define SNESNEWTONTR         "newtontr"
27 #define SNESNEWTONTRDC       "newtontrdc"
28 #define SNESPYTHON           "python"
29 #define SNESNRICHARDSON      "nrichardson"
30 #define SNESKSPONLY          "ksponly"
31 #define SNESKSPTRANSPOSEONLY "ksptransposeonly"
32 #define SNESVINEWTONRSLS     "vinewtonrsls"
33 #define SNESVINEWTONSSLS     "vinewtonssls"
34 #define SNESNGMRES           "ngmres"
35 #define SNESQN               "qn"
36 #define SNESSHELL            "shell"
37 #define SNESNGS              "ngs"
38 #define SNESNCG              "ncg"
39 #define SNESFAS              "fas"
40 #define SNESMS               "ms"
41 #define SNESNASM             "nasm"
42 #define SNESANDERSON         "anderson"
43 #define SNESASPIN            "aspin"
44 #define SNESCOMPOSITE        "composite"
45 #define SNESPATCH            "patch"
46 #define SNESNEWTONAL         "newtonal"
47 
48 /* Logging support */
49 PETSC_EXTERN PetscClassId SNES_CLASSID;
50 PETSC_EXTERN PetscClassId DMSNES_CLASSID;
51 
52 PETSC_EXTERN PetscErrorCode SNESInitializePackage(void);
53 PETSC_EXTERN PetscErrorCode SNESFinalizePackage(void);
54 
55 PETSC_EXTERN PetscErrorCode SNESCreate(MPI_Comm, SNES *);
56 PETSC_EXTERN PetscErrorCode SNESParametersInitialize(SNES);
57 PETSC_EXTERN PetscErrorCode SNESReset(SNES);
58 PETSC_EXTERN PetscErrorCode SNESDestroy(SNES *);
59 PETSC_EXTERN PetscErrorCode SNESSetType(SNES, SNESType);
60 PETSC_EXTERN PetscErrorCode SNESMonitor(SNES, PetscInt, PetscReal);
61 PETSC_EXTERN PetscErrorCode SNESMonitorSet(SNES, PetscErrorCode (*)(SNES, PetscInt, PetscReal, void *), void *, PetscCtxDestroyFn *);
62 PETSC_EXTERN PetscErrorCode SNESMonitorSetFromOptions(SNES, const char[], const char[], const char[], PetscErrorCode (*)(SNES, PetscInt, PetscReal, PetscViewerAndFormat *), PetscErrorCode (*)(SNES, PetscViewerAndFormat *));
63 PETSC_EXTERN PetscErrorCode SNESMonitorCancel(SNES);
64 PETSC_EXTERN PetscErrorCode SNESMonitorSAWs(SNES, PetscInt, PetscReal, void *);
65 PETSC_EXTERN PetscErrorCode SNESMonitorSAWsCreate(SNES, void **);
66 PETSC_EXTERN PetscErrorCode SNESMonitorSAWsDestroy(void **);
67 PETSC_EXTERN PetscErrorCode SNESSetConvergenceHistory(SNES, PetscReal[], PetscInt[], PetscInt, PetscBool);
68 PETSC_EXTERN PetscErrorCode SNESGetConvergenceHistory(SNES, PetscReal *[], PetscInt *[], PetscInt *);
69 PETSC_EXTERN PetscErrorCode SNESSetUp(SNES);
70 PETSC_EXTERN PetscErrorCode SNESSolve(SNES, Vec, Vec);
71 PETSC_EXTERN PetscErrorCode SNESSetErrorIfNotConverged(SNES, PetscBool);
72 PETSC_EXTERN PetscErrorCode SNESGetErrorIfNotConverged(SNES, PetscBool *);
73 PETSC_EXTERN PetscErrorCode SNESConverged(SNES, PetscInt, PetscReal, PetscReal, PetscReal);
74 
75 PETSC_EXTERN PetscErrorCode SNESSetWorkVecs(SNES, PetscInt);
76 
77 PETSC_EXTERN PetscErrorCode SNESAddOptionsChecker(PetscErrorCode (*)(SNES));
78 
79 PETSC_EXTERN PetscErrorCode SNESRegister(const char[], PetscErrorCode (*)(SNES));
80 
81 PETSC_EXTERN PetscErrorCode SNESGetKSP(SNES, KSP *);
82 PETSC_EXTERN PetscErrorCode SNESSetKSP(SNES, KSP);
83 PETSC_EXTERN PetscErrorCode SNESSetSolution(SNES, Vec);
84 PETSC_EXTERN PetscErrorCode SNESGetSolution(SNES, Vec *);
85 PETSC_EXTERN PetscErrorCode SNESGetSolutionUpdate(SNES, Vec *);
86 PETSC_EXTERN PetscErrorCode SNESGetRhs(SNES, Vec *);
87 PETSC_EXTERN PetscErrorCode SNESView(SNES, PetscViewer);
88 PETSC_EXTERN PetscErrorCode SNESLoad(SNES, PetscViewer);
89 PETSC_EXTERN PetscErrorCode SNESConvergedReasonViewSet(SNES, PetscErrorCode (*)(SNES, void *), void *, PetscCtxDestroyFn *);
90 PETSC_EXTERN PetscErrorCode SNESViewFromOptions(SNES, PetscObject, const char[]);
91 PETSC_EXTERN PetscErrorCode SNESConvergedReasonView(SNES, PetscViewer);
92 PETSC_EXTERN PetscErrorCode SNESConvergedReasonViewFromOptions(SNES);
93 PETSC_EXTERN PetscErrorCode SNESConvergedReasonViewCancel(SNES);
94 
95 PETSC_DEPRECATED_FUNCTION(3, 14, 0, "SNESConvergedReasonView()", ) static inline PetscErrorCode SNESReasonView(SNES snes, PetscViewer v)
96 {
97   return SNESConvergedReasonView(snes, v);
98 }
99 PETSC_DEPRECATED_FUNCTION(3, 14, 0, "SNESConvergedReasonViewFromOptions()", ) static inline PetscErrorCode SNESReasonViewFromOptions(SNES snes)
100 {
101   return SNESConvergedReasonViewFromOptions(snes);
102 }
103 
104 #define SNES_FILE_CLASSID 1211224
105 
106 PETSC_EXTERN PetscErrorCode SNESSetOptionsPrefix(SNES, const char[]);
107 PETSC_EXTERN PetscErrorCode SNESAppendOptionsPrefix(SNES, const char[]);
108 PETSC_EXTERN PetscErrorCode SNESGetOptionsPrefix(SNES, const char *[]);
109 PETSC_EXTERN PetscErrorCode SNESSetFromOptions(SNES);
110 PETSC_EXTERN PetscErrorCode SNESResetFromOptions(SNES);
111 
112 PETSC_EXTERN PetscErrorCode SNESSetUseMatrixFree(SNES, PetscBool, PetscBool);
113 PETSC_EXTERN PetscErrorCode SNESGetUseMatrixFree(SNES, PetscBool *, PetscBool *);
114 PETSC_EXTERN PetscErrorCode MatCreateSNESMF(SNES, Mat *);
115 PETSC_EXTERN PetscErrorCode MatSNESMFGetSNES(Mat, SNES *);
116 PETSC_EXTERN PetscErrorCode MatSNESMFSetReuseBase(Mat, PetscBool);
117 PETSC_EXTERN PetscErrorCode MatSNESMFGetReuseBase(Mat, PetscBool *);
118 PETSC_EXTERN PetscErrorCode MatMFFDComputeJacobian(SNES, Vec, Mat, Mat, void *);
119 PETSC_EXTERN PetscErrorCode MatCreateSNESMFMore(SNES, Vec, Mat *);
120 PETSC_EXTERN PetscErrorCode MatSNESMFMoreSetParameters(Mat, PetscReal, PetscReal, PetscReal);
121 
122 PETSC_EXTERN PetscErrorCode SNESGetType(SNES, SNESType *);
123 PETSC_EXTERN PetscErrorCode SNESMonitorDefaultSetUp(SNES, PetscViewerAndFormat *);
124 PETSC_EXTERN PetscErrorCode SNESMonitorDefault(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
125 PETSC_EXTERN PetscErrorCode SNESMonitorScaling(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
126 PETSC_EXTERN PetscErrorCode SNESMonitorRange(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
127 PETSC_EXTERN PetscErrorCode SNESMonitorRatio(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
128 PETSC_EXTERN PetscErrorCode SNESMonitorRatioSetUp(SNES, PetscViewerAndFormat *);
129 PETSC_EXTERN PetscErrorCode SNESMonitorSolution(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
130 PETSC_EXTERN PetscErrorCode SNESMonitorResidual(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
131 PETSC_EXTERN PetscErrorCode SNESMonitorSolutionUpdate(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
132 PETSC_EXTERN PetscErrorCode SNESMonitorDefaultShort(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
133 PETSC_EXTERN PetscErrorCode SNESMonitorDefaultField(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
134 PETSC_EXTERN PetscErrorCode SNESMonitorJacUpdateSpectrum(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
135 PETSC_EXTERN PetscErrorCode SNESMonitorFields(SNES, PetscInt, PetscReal, PetscViewerAndFormat *);
136 PETSC_EXTERN PetscErrorCode KSPMonitorSNESResidual(KSP, PetscInt, PetscReal, PetscViewerAndFormat *);
137 PETSC_EXTERN PetscErrorCode KSPMonitorSNESResidualDrawLG(KSP, PetscInt, PetscReal, PetscViewerAndFormat *);
138 PETSC_EXTERN PetscErrorCode KSPMonitorSNESResidualDrawLGCreate(PetscViewer, PetscViewerFormat, void *, PetscViewerAndFormat **);
139 
140 PETSC_EXTERN PetscErrorCode SNESSetTolerances(SNES, PetscReal, PetscReal, PetscReal, PetscInt, PetscInt);
141 PETSC_EXTERN PetscErrorCode SNESSetDivergenceTolerance(SNES, PetscReal);
142 PETSC_EXTERN PetscErrorCode SNESGetTolerances(SNES, PetscReal *, PetscReal *, PetscReal *, PetscInt *, PetscInt *);
143 PETSC_EXTERN PetscErrorCode SNESGetDivergenceTolerance(SNES, PetscReal *);
144 PETSC_EXTERN PetscErrorCode SNESGetForceIteration(SNES, PetscBool *);
145 PETSC_EXTERN PetscErrorCode SNESSetForceIteration(SNES, PetscBool);
146 PETSC_EXTERN PetscErrorCode SNESGetIterationNumber(SNES, PetscInt *);
147 PETSC_EXTERN PetscErrorCode SNESSetIterationNumber(SNES, PetscInt);
148 
149 /*E
150    SNESNewtonTRFallbackType - type of fallback in case the solution of the trust-region subproblem is outside of the radius
151 
152    Values:
153 +  `SNES_TR_FALLBACK_NEWTON` - use scaled Newton step
154 .  `SNES_TR_FALLBACK_CAUCHY` - use Cauchy direction
155 -  `SNES_TR_FALLBACK_DOGLEG` - use dogleg method
156 
157    Level: intermediate
158 
159 .seealso: [](ch_snes), `SNES`, `SNESNEWTONTR`, `SNESNEWTONTRDC`
160 E*/
161 typedef enum {
162   SNES_TR_FALLBACK_NEWTON,
163   SNES_TR_FALLBACK_CAUCHY,
164   SNES_TR_FALLBACK_DOGLEG,
165 } SNESNewtonTRFallbackType;
166 
167 PETSC_EXTERN const char *const SNESNewtonTRFallbackTypes[];
168 
169 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetPreCheck(SNES, PetscErrorCode (*)(SNES, Vec, Vec, PetscBool *, void *), void *ctx);
170 PETSC_EXTERN PetscErrorCode SNESNewtonTRGetPreCheck(SNES, PetscErrorCode (**)(SNES, Vec, Vec, PetscBool *, void *), void **ctx);
171 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetPostCheck(SNES, PetscErrorCode (*)(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void *ctx);
172 PETSC_EXTERN PetscErrorCode SNESNewtonTRGetPostCheck(SNES, PetscErrorCode (**)(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void **ctx);
173 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetFallbackType(SNES, SNESNewtonTRFallbackType);
174 PETSC_EXTERN PetscErrorCode SNESNewtonTRPreCheck(SNES, Vec, Vec, PetscBool *);
175 PETSC_EXTERN PetscErrorCode SNESNewtonTRPostCheck(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *);
176 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetNormType(SNES, NormType);
177 
178 /*E
179     SNESNewtonTRQNType - type of quasi-Newton model to use
180 
181    Values:
182 +  `SNES_TR_QN_NONE` - do not use a quasi-Newton model
183 .  `SNES_TR_QN_SAME` - use the same quasi-Newton model for matrix and preconditioner
184 -  `SNES_TR_QN_DIFFERENT` - use different quasi-Newton models for matrix and preconditioner
185 
186    Level: intermediate
187 
188 .seealso: [](ch_snes), `SNES`, `SNESNEWTONTR`
189 E*/
190 typedef enum {
191   SNES_TR_QN_NONE,
192   SNES_TR_QN_SAME,
193   SNES_TR_QN_DIFFERENT,
194 } SNESNewtonTRQNType;
195 
196 PETSC_EXTERN const char *const SNESNewtonTRQNTypes[];
197 
198 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetQNType(SNES, SNESNewtonTRQNType);
199 
200 PETSC_EXTERN PETSC_DEPRECATED_FUNCTION(3, 22, 0, "SNESNewtonTRSetTolerances()", ) PetscErrorCode SNESSetTrustRegionTolerance(SNES, PetscReal);
201 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetTolerances(SNES, PetscReal, PetscReal, PetscReal);
202 PETSC_EXTERN PetscErrorCode SNESNewtonTRGetTolerances(SNES, PetscReal *, PetscReal *, PetscReal *);
203 PETSC_EXTERN PetscErrorCode SNESNewtonTRSetUpdateParameters(SNES, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal);
204 PETSC_EXTERN PetscErrorCode SNESNewtonTRGetUpdateParameters(SNES, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscReal *);
205 
206 PETSC_EXTERN PetscErrorCode SNESNewtonTRDCGetRhoFlag(SNES, PetscBool *);
207 PETSC_EXTERN PetscErrorCode SNESNewtonTRDCSetPreCheck(SNES, PetscErrorCode (*)(SNES, Vec, Vec, PetscBool *, void *), void *ctx);
208 PETSC_EXTERN PetscErrorCode SNESNewtonTRDCGetPreCheck(SNES, PetscErrorCode (**)(SNES, Vec, Vec, PetscBool *, void *), void **ctx);
209 PETSC_EXTERN PetscErrorCode SNESNewtonTRDCSetPostCheck(SNES, PetscErrorCode (*)(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void *ctx);
210 PETSC_EXTERN PetscErrorCode SNESNewtonTRDCGetPostCheck(SNES, PetscErrorCode (**)(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void **ctx);
211 
212 PETSC_EXTERN PetscErrorCode SNESGetNonlinearStepFailures(SNES, PetscInt *);
213 PETSC_EXTERN PetscErrorCode SNESSetMaxNonlinearStepFailures(SNES, PetscInt);
214 PETSC_EXTERN PetscErrorCode SNESGetMaxNonlinearStepFailures(SNES, PetscInt *);
215 PETSC_EXTERN PetscErrorCode SNESGetNumberFunctionEvals(SNES, PetscInt *);
216 
217 PETSC_EXTERN PetscErrorCode SNESSetLagPreconditioner(SNES, PetscInt);
218 PETSC_EXTERN PetscErrorCode SNESGetLagPreconditioner(SNES, PetscInt *);
219 PETSC_EXTERN PetscErrorCode SNESSetLagJacobian(SNES, PetscInt);
220 PETSC_EXTERN PetscErrorCode SNESGetLagJacobian(SNES, PetscInt *);
221 PETSC_EXTERN PetscErrorCode SNESSetLagPreconditionerPersists(SNES, PetscBool);
222 PETSC_EXTERN PetscErrorCode SNESSetLagJacobianPersists(SNES, PetscBool);
223 PETSC_EXTERN PetscErrorCode SNESSetGridSequence(SNES, PetscInt);
224 PETSC_EXTERN PetscErrorCode SNESGetGridSequence(SNES, PetscInt *);
225 
226 PETSC_EXTERN PetscErrorCode SNESGetLinearSolveIterations(SNES, PetscInt *);
227 PETSC_EXTERN PetscErrorCode SNESGetLinearSolveFailures(SNES, PetscInt *);
228 PETSC_EXTERN PetscErrorCode SNESSetMaxLinearSolveFailures(SNES, PetscInt);
229 PETSC_EXTERN PetscErrorCode SNESGetMaxLinearSolveFailures(SNES, PetscInt *);
230 PETSC_EXTERN PetscErrorCode SNESSetCountersReset(SNES, PetscBool);
231 PETSC_EXTERN PetscErrorCode SNESResetCounters(SNES);
232 
233 PETSC_EXTERN PetscErrorCode SNESKSPSetUseEW(SNES, PetscBool);
234 PETSC_EXTERN PetscErrorCode SNESKSPGetUseEW(SNES, PetscBool *);
235 PETSC_EXTERN PetscErrorCode SNESKSPSetParametersEW(SNES, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal);
236 PETSC_EXTERN PetscErrorCode SNESKSPGetParametersEW(SNES, PetscInt *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscReal *);
237 
238 PETSC_EXTERN PetscErrorCode SNESMonitorLGRange(SNES, PetscInt, PetscReal, void *);
239 
240 PETSC_EXTERN PetscErrorCode SNESSetApplicationContext(SNES, void *);
241 PETSC_EXTERN PetscErrorCode SNESGetApplicationContext(SNES, void *);
242 PETSC_EXTERN PetscErrorCode SNESSetComputeApplicationContext(SNES, PetscErrorCode (*)(SNES, void **), PetscCtxDestroyFn *);
243 
244 PETSC_EXTERN PetscErrorCode SNESPythonSetType(SNES, const char[]);
245 PETSC_EXTERN PetscErrorCode SNESPythonGetType(SNES, const char *[]);
246 
247 PETSC_EXTERN PetscErrorCode SNESSetFunctionDomainError(SNES);
248 PETSC_EXTERN PetscErrorCode SNESGetFunctionDomainError(SNES, PetscBool *);
249 PETSC_EXTERN PetscErrorCode SNESGetJacobianDomainError(SNES, PetscBool *);
250 PETSC_EXTERN PetscErrorCode SNESSetJacobianDomainError(SNES);
251 PETSC_EXTERN PetscErrorCode SNESSetCheckJacobianDomainError(SNES, PetscBool);
252 PETSC_EXTERN PetscErrorCode SNESGetCheckJacobianDomainError(SNES, PetscBool *);
253 
254 #define SNES_CONVERGED_TR_DELTA_DEPRECATED SNES_CONVERGED_TR_DELTA PETSC_DEPRECATED_ENUM(3, 12, 0, "SNES_DIVERGED_TR_DELTA", )
255 /*E
256     SNESConvergedReason - reason a `SNESSolve()` was determined to have converged or diverged
257 
258    Values:
259 +  `SNES_CONVERGED_FNORM_ABS`      - 2-norm(F) <= abstol
260 .  `SNES_CONVERGED_FNORM_RELATIVE` - 2-norm(F) <= rtol*2-norm(F(x_0)) where x_0 is the initial guess
261 .  `SNES_CONVERGED_SNORM_RELATIVE` - The 2-norm of the last step <= stol * 2-norm(x) where x is the current
262 .  `SNES_CONVERGED_USER`           - The user has indicated convergence for an arbitrary reason
263 .  `SNES_DIVERGED_FUNCTION_COUNT`  - The user provided function has been called more times than the maximum set in `SNESSetTolerances()`
264 .  `SNES_DIVERGED_DTOL`            - The norm of the function has increased by a factor of divtol set with `SNESSetDivergenceTolerance()`
265 .  `SNES_DIVERGED_FNORM_NAN`       - the 2-norm of the current function evaluation is not-a-number (NaN), this
266                                      is usually caused by a division of 0 by 0.
267 .  `SNES_DIVERGED_MAX_IT`          - `SNESSolve()` has reached the maximum number of iterations requested
268 .  `SNES_DIVERGED_LINE_SEARCH`     - The line search has failed. This only occurs for `SNES` solvers that use a line search
269 .  `SNES_DIVERGED_LOCAL_MIN`       - the algorithm seems to have stagnated at a local minimum that is not zero.
270 .  `SNES_DIVERGED_USER`            - The user has indicated divergence for an arbitrary reason
271 -  `SNES_CONVERGED_ITERATING       - this only occurs if `SNESGetConvergedReason()` is called during the `SNESSolve()`
272 
273    Level: beginner
274 
275     Notes:
276    The two most common reasons for divergence are an incorrectly coded or computed Jacobian or failure or lack of convergence in the linear system
277    (in this case we recommend
278    testing with `-pc_type lu` to eliminate the linear solver as the cause of the problem).
279 
280    `SNES_DIVERGED_LOCAL_MIN` can only occur when using a `SNES` solver that uses a line search (`SNESLineSearch`).
281    The line search wants to minimize Q(alpha) = 1/2 || F(x + alpha s) ||^2_2  this occurs
282    at Q'(alpha) = s^T F'(x+alpha s)^T F(x+alpha s) = 0. If s is the Newton direction - F'(x)^(-1)F(x) then
283    you get Q'(alpha) = -F(x)^T F'(x)^(-1)^T F'(x+alpha s)F(x+alpha s); when alpha = 0
284    Q'(0) = - ||F(x)||^2_2 which is always NEGATIVE if F'(x) is invertible. This means the Newton
285    direction is a descent direction and the line search should succeed if alpha is small enough.
286 
287    If F'(x) is NOT invertible AND F'(x)^T F(x) = 0 then Q'(0) = 0 and the Newton direction
288    is NOT a descent direction so the line search will fail. All one can do at this point
289    is change the initial guess and try again.
290 
291    An alternative explanation: Newton's method can be regarded as replacing the function with
292    its linear approximation and minimizing the 2-norm of that. That is F(x+s) approx F(x) + F'(x)s
293    so we minimize || F(x) + F'(x) s ||^2_2; do this using Least Squares. If F'(x) is invertible then
294    s = - F'(x)^(-1)F(x) otherwise F'(x)^T F'(x) s = -F'(x)^T F(x). If F'(x)^T F(x) is NOT zero then there
295    exists a nontrivial (that is F'(x)s != 0) solution to the equation and this direction is
296    s = - [F'(x)^T F'(x)]^(-1) F'(x)^T F(x) so Q'(0) = - F(x)^T F'(x) [F'(x)^T F'(x)]^(-T) F'(x)^T F(x)
297    = - (F'(x)^T F(x)) [F'(x)^T F'(x)]^(-T) (F'(x)^T F(x)). Since we are assuming (F'(x)^T F(x)) != 0
298    and F'(x)^T F'(x) has no negative eigenvalues Q'(0) < 0 so s is a descent direction and the line
299    search should succeed for small enough alpha.
300 
301    Note that this RARELY happens in practice. Far more likely the linear system is not being solved
302    (well enough?) or the Jacobian is wrong.
303 
304    `SNES_DIVERGED_MAX_IT` means that the solver reached the maximum number of iterations without satisfying any
305    convergence criteria. `SNES_CONVERGED_ITS` means that `SNESConvergedSkip()` was chosen as the convergence test;
306    thus the usual convergence criteria have not been checked and may or may not be satisfied.
307 
308 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `KSPConvergedReason`, `SNESSetConvergenceTest()`, `SNESSetTolerances()`
309 E*/
310 typedef enum {                       /* converged */
311   SNES_CONVERGED_FNORM_ABS      = 2, /* ||F|| < atol */
312   SNES_CONVERGED_FNORM_RELATIVE = 3, /* ||F|| < rtol*||F_initial|| */
313   SNES_CONVERGED_SNORM_RELATIVE = 4, /* Newton computed step size small; || delta x || < stol || x || */
314   SNES_CONVERGED_ITS            = 5, /* maximum iterations reached */
315   SNES_BREAKOUT_INNER_ITER      = 6, /* Flag to break out of inner loop after checking custom convergence, used in multi-phase flow when state changes */
316   SNES_CONVERGED_USER           = 7, /* The user has indicated convergence for an arbitrary reason */
317   /* diverged */
318   SNES_DIVERGED_FUNCTION_DOMAIN      = -1, /* the new x location passed the function is not in the domain of F */
319   SNES_DIVERGED_FUNCTION_COUNT       = -2,
320   SNES_DIVERGED_LINEAR_SOLVE         = -3, /* the linear solve failed */
321   SNES_DIVERGED_FNORM_NAN            = -4,
322   SNES_DIVERGED_MAX_IT               = -5,
323   SNES_DIVERGED_LINE_SEARCH          = -6,  /* the line search failed */
324   SNES_DIVERGED_INNER                = -7,  /* inner solve failed */
325   SNES_DIVERGED_LOCAL_MIN            = -8,  /* || J^T b || is small, implies converged to local minimum of F() */
326   SNES_DIVERGED_DTOL                 = -9,  /* || F || > divtol*||F_initial|| */
327   SNES_DIVERGED_JACOBIAN_DOMAIN      = -10, /* Jacobian calculation does not make sense */
328   SNES_DIVERGED_TR_DELTA             = -11,
329   SNES_CONVERGED_TR_DELTA_DEPRECATED = -11,
330   SNES_DIVERGED_USER                 = -12, /* The user has indicated divergence for an arbitrary reason */
331 
332   SNES_CONVERGED_ITERATING = 0
333 } SNESConvergedReason;
334 PETSC_EXTERN const char *const *SNESConvergedReasons;
335 
336 /*MC
337    SNES_CONVERGED_FNORM_ABS - 2-norm(F) <= abstol
338 
339    Level: beginner
340 
341 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
342 M*/
343 
344 /*MC
345    SNES_CONVERGED_FNORM_RELATIVE - 2-norm(F) <= rtol*2-norm(F(x_0)) where x_0 is the initial guess
346 
347    Level: beginner
348 
349 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
350 M*/
351 
352 /*MC
353   SNES_CONVERGED_SNORM_RELATIVE - The 2-norm of the last step <= stol * 2-norm(x) where x is the current
354   solution and stol is the 4th argument to `SNESSetTolerances()`
355 
356   Options Database Key:
357   -snes_stol <stol> - the step tolerance
358 
359    Level: beginner
360 
361 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
362 M*/
363 
364 /*MC
365    SNES_DIVERGED_FUNCTION_COUNT - The user provided function has been called more times then the final
366    argument to `SNESSetTolerances()`
367 
368    Level: beginner
369 
370 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
371 M*/
372 
373 /*MC
374    SNES_DIVERGED_DTOL - The norm of the function has increased by a factor of divtol set with `SNESSetDivergenceTolerance()`
375 
376    Level: beginner
377 
378 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`, `SNESSetDivergenceTolerance()`
379 M*/
380 
381 /*MC
382    SNES_DIVERGED_FNORM_NAN - the 2-norm of the current function evaluation is not-a-number (NaN), this
383    is usually caused by a division of 0 by 0.
384 
385    Level: beginner
386 
387 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
388 M*/
389 
390 /*MC
391    SNES_DIVERGED_MAX_IT - SNESSolve() has reached the maximum number of iterations requested
392 
393    Level: beginner
394 
395 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
396 M*/
397 
398 /*MC
399    SNES_DIVERGED_LINE_SEARCH - The line search has failed. This only occurs for a `SNES` solvers that use a line search
400 
401    Level: beginner
402 
403 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`, `SNESLineSearch`
404 M*/
405 
406 /*MC
407    SNES_DIVERGED_LOCAL_MIN - the algorithm seems to have stagnated at a local minimum that is not zero.
408    See the manual page for `SNESConvergedReason` for more details
409 
410    Level: beginner
411 
412 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
413 M*/
414 
415 /*MC
416    SNES_CONERGED_ITERATING - this only occurs if `SNESGetConvergedReason()` is called during the `SNESSolve()`
417 
418    Level: beginner
419 
420 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `SNESConvergedReason`, `SNESSetTolerances()`
421 M*/
422 
423 PETSC_EXTERN PetscErrorCode SNESSetConvergenceTest(SNES, PetscErrorCode (*)(SNES, PetscInt, PetscReal, PetscReal, PetscReal, SNESConvergedReason *, void *), void *, PetscErrorCode (*)(void *));
424 PETSC_EXTERN PetscErrorCode SNESConvergedDefault(SNES, PetscInt, PetscReal, PetscReal, PetscReal, SNESConvergedReason *, void *);
425 PETSC_EXTERN PetscErrorCode SNESConvergedSkip(SNES, PetscInt, PetscReal, PetscReal, PetscReal, SNESConvergedReason *, void *);
426 PETSC_EXTERN PetscErrorCode SNESConvergedCorrectPressure(SNES, PetscInt, PetscReal, PetscReal, PetscReal, SNESConvergedReason *, void *);
427 PETSC_EXTERN PetscErrorCode SNESGetConvergedReason(SNES, SNESConvergedReason *);
428 PETSC_EXTERN PetscErrorCode SNESGetConvergedReasonString(SNES, const char **);
429 PETSC_EXTERN PetscErrorCode SNESSetConvergedReason(SNES, SNESConvergedReason);
430 
431 PETSC_DEPRECATED_FUNCTION(3, 5, 0, "SNESConvergedSkip()", ) static inline void SNESSkipConverged(void)
432 { /* never called */
433 }
434 #define SNESSkipConverged (SNESSkipConverged, SNESConvergedSkip)
435 
436 /*S
437   SNESInitialGuessFn - A prototype of a `SNES` compute initial guess function that would be passed to `SNESSetComputeInitialGuess()`
438 
439   Calling Sequence:
440 + snes  - `SNES` context
441 . u   - output vector to contain initial guess
442 - ctx - [optional] user-defined function context
443 
444   Level: beginner
445 
446 .seealso: [](ch_snes), `SNES`, `SNESSetComputeInitialGuess()`, `SNESSetFunction()`, `SNESGetFunction()`, `SNESJacobianFn`, `SNESFunctionFn`
447 S*/
448 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESInitialGuessFn(SNES snes, Vec u, void *ctx);
449 
450 /*S
451   SNESFunctionFn - A prototype of a `SNES` evaluation function that would be passed to `SNESSetFunction()`
452 
453   Calling Sequence:
454 + snes  - `SNES` context
455 . u   - input vector
456 . F   - function vector
457 - ctx - [optional] user-defined function context
458 
459   Level: beginner
460 
461 .seealso: [](ch_snes), `SNES`, `SNESSetFunction()`, `SNESGetFunction()`, `SNESJacobianFn`, `SNESNGSFn`
462 S*/
463 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESFunctionFn(SNES snes, Vec u, Vec F, void *ctx);
464 
465 /*S
466   SNESObjectiveFn - A prototype of a `SNES` objective evaluation function that would be passed to `SNESSetObjective()`
467 
468   Calling Sequence:
469 + snes  - `SNES` context
470 . u   - input vector
471 . o   - output value
472 - ctx - [optional] user-defined function context
473 
474   Level: beginner
475 
476 .seealso: [](ch_snes), `SNES`, `SNESSetFunction()`, `SNESGetFunction()`, `SNESJacobianFn`, `SNESNGSFn`
477 S*/
478 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESObjectiveFn(SNES snes, Vec u, PetscReal *o, void *ctx);
479 
480 /*S
481   SNESJacobianFn - A prototype of a `SNES` Jacobian evaluation function that would be passed to `SNESSetJacobian()`
482 
483   Calling Sequence:
484 + snes   - the `SNES` context obtained from `SNESCreate()`
485 . u    - input vector
486 . Amat - (approximate) Jacobian matrix
487 . Pmat - matrix used to construct the preconditioner, often the same as `Amat`
488 - ctx  - [optional] user-defined context for matrix evaluation routine
489 
490   Level: beginner
491 
492 .seealso: [](ch_snes), `SNES`, `SNESSetJacobian()`, `SNESGetJacobian()`, `SNESFunctionFn`, `SNESNGSFn`
493 S*/
494 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESJacobianFn(SNES snes, Vec u, Mat Amat, Mat Pmat, void *ctx);
495 
496 /*S
497   SNESNGSFn - A prototype of a `SNES` nonlinear Gauss-Seidel function that would be passed to `SNESSetNGS()`
498 
499   Calling Sequence:
500 + snes   - the `SNES` context obtained from `SNESCreate()`
501 . u    - the current solution, updated in place
502 . b    - the right-hand side vector (which may be `NULL`)
503 - ctx  - [optional] user-defined context for matrix evaluation routine
504 
505   Level: beginner
506 
507 .seealso: [](ch_snes), `SNES`, `SNESSetJacobian()`, `SNESGetJacobian()`, `SNESFunctionFn`, `SNESSetFunction()`, `SNESGetFunction()`, `SNESJacobianFn`
508 S*/
509 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESNGSFn(SNES snes, Vec u, Vec b, void *ctx);
510 
511 /*S
512   SNESUpdateFn - A prototype of a `SNES` update function that would be passed to `SNESSetUpdate()`
513 
514   Calling Sequence:
515 + snes - `SNES` context
516 - step - the current iteration index
517 
518   Level: advanced
519 
520 .seealso: [](ch_snes), `SNES`, `SNESSetUpdate()`
521 S*/
522 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESUpdateFn(SNES snes, PetscInt step);
523 
524 /* --------- Solving systems of nonlinear equations --------------- */
525 PETSC_EXTERN PetscErrorCode SNESSetFunction(SNES, Vec, SNESFunctionFn *, void *);
526 PETSC_EXTERN PetscErrorCode SNESGetFunction(SNES, Vec *, SNESFunctionFn **, void **);
527 PETSC_EXTERN PetscErrorCode SNESComputeFunction(SNES, Vec, Vec);
528 PETSC_EXTERN PetscErrorCode SNESComputeMFFunction(SNES, Vec, Vec);
529 PETSC_EXTERN PetscErrorCode SNESSetInitialFunction(SNES, Vec);
530 
531 PETSC_EXTERN PetscErrorCode SNESSetJacobian(SNES, Mat, Mat, SNESJacobianFn *, void *);
532 PETSC_EXTERN PetscErrorCode SNESGetJacobian(SNES, Mat *, Mat *, SNESJacobianFn **, void **);
533 PETSC_EXTERN SNESFunctionFn SNESObjectiveComputeFunctionDefaultFD;
534 PETSC_EXTERN SNESJacobianFn SNESComputeJacobianDefault;
535 PETSC_EXTERN SNESJacobianFn SNESComputeJacobianDefaultColor;
536 PETSC_EXTERN PetscErrorCode SNESPruneJacobianColor(SNES, Mat, Mat);
537 PETSC_EXTERN PetscErrorCode SNESSetComputeInitialGuess(SNES, SNESInitialGuessFn *, void *);
538 PETSC_EXTERN PetscErrorCode SNESSetPicard(SNES, Vec, SNESFunctionFn *, Mat, Mat, SNESJacobianFn *, void *);
539 PETSC_EXTERN PetscErrorCode SNESGetPicard(SNES, Vec *, SNESFunctionFn **, Mat *, Mat *, SNESJacobianFn **, void **);
540 PETSC_EXTERN SNESFunctionFn SNESPicardComputeFunction;
541 PETSC_EXTERN SNESFunctionFn SNESPicardComputeMFFunction;
542 PETSC_EXTERN SNESJacobianFn SNESPicardComputeJacobian;
543 
544 PETSC_EXTERN PetscErrorCode SNESSetObjective(SNES, SNESObjectiveFn *, void *);
545 PETSC_EXTERN PetscErrorCode SNESGetObjective(SNES, SNESObjectiveFn **, void **);
546 PETSC_EXTERN PetscErrorCode SNESComputeObjective(SNES, Vec, PetscReal *);
547 
548 PETSC_EXTERN PetscErrorCode SNESSetUpdate(SNES, SNESUpdateFn *);
549 
550 /*E
551    SNESNormSchedule - Frequency with which the norm is computed during a nonliner solve
552 
553    Values:
554 +   `SNES_NORM_DEFAULT`            - use the default behavior for the current `SNESType`
555 .   `SNES_NORM_NONE`               - avoid all norm computations
556 .   `SNES_NORM_ALWAYS`             - compute the norms whenever possible
557 .   `SNES_NORM_INITIAL_ONLY`       - compute the norm only when the algorithm starts
558 .   `SNES_NORM_FINAL_ONLY`         - compute the norm only when the algorithm finishes
559 -   `SNES_NORM_INITIAL_FINAL_ONLY` - compute the norm at the start and end of the algorithm
560 
561    Level: advanced
562 
563    Notes:
564    Support for these is highly dependent on the solver.
565 
566    Some options limit the convergence tests that can be used.
567 
568    The `SNES_NORM_NONE` option is most commonly used when the nonlinear solver is being used as a smoother, for example for `SNESFAS`
569 
570    This is primarily used to turn off extra norm and function computation
571    when the solvers are composed.
572 
573 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `KSPSetNormType()`,
574           `KSPSetConvergenceTest()`, `KSPSetPCSide()`
575 E*/
576 typedef enum {
577   SNES_NORM_DEFAULT            = -1,
578   SNES_NORM_NONE               = 0,
579   SNES_NORM_ALWAYS             = 1,
580   SNES_NORM_INITIAL_ONLY       = 2,
581   SNES_NORM_FINAL_ONLY         = 3,
582   SNES_NORM_INITIAL_FINAL_ONLY = 4
583 } SNESNormSchedule;
584 PETSC_EXTERN const char *const *const SNESNormSchedules;
585 
586 /*MC
587    SNES_NORM_NONE - Don't compute function and its L2 norm when possible
588 
589    Level: advanced
590 
591    Note:
592    This is most useful for stationary solvers with a fixed number of iterations used as smoothers.
593 
594 .seealso: [](ch_snes), `SNESNormSchedule`, `SNES`, `SNESSetNormSchedule()`, `SNES_NORM_DEFAULT`
595 M*/
596 
597 /*MC
598    SNES_NORM_ALWAYS - Compute the function and its L2 norm at each iteration.
599 
600    Level: advanced
601 
602    Note:
603    Most solvers will use this no matter what norm type is passed to them.
604 
605 .seealso: [](ch_snes), `SNESNormSchedule`, `SNES`, `SNESSetNormSchedule()`, `SNES_NORM_NONE`
606 M*/
607 
608 /*MC
609    SNES_NORM_INITIAL_ONLY - Compute the function and its L2 at iteration 0, but do not update it.
610 
611    Level: advanced
612 
613    Notes:
614    This method is useful in composed methods, when a true solution might actually be found before `SNESSolve()` is called.
615    This option enables the solve to abort on the zeroth iteration if this is the case.
616 
617    For solvers that require the computation of the L2 norm of the function as part of the method, this merely cancels
618    the norm computation at the last iteration (if possible).
619 
620 .seealso: [](ch_snes), `SNESNormSchedule`, `SNES`, `SNESSetNormSchedule()`, `SNES_NORM_FINAL_ONLY`, `SNES_NORM_INITIAL_FINAL_ONLY`
621 M*/
622 
623 /*MC
624    SNES_NORM_FINAL_ONLY - Compute the function and its L2 norm on only the final iteration.
625 
626    Level: advanced
627 
628    Note:
629    For solvers that require the computation of the L2 norm of the function as part of the method, behaves
630    exactly as `SNES_NORM_DEFAULT`.  This method is useful when the function is gotten after `SNESSolve()` and
631    used in subsequent computation for methods that do not need the norm computed during the rest of the
632    solution procedure.
633 
634 .seealso: [](ch_snes), `SNESNormSchedule`, `SNES`, `SNESSetNormSchedule()`, `SNES_NORM_INITIAL_ONLY`, `SNES_NORM_INITIAL_FINAL_ONLY`
635 M*/
636 
637 /*MC
638    SNES_NORM_INITIAL_FINAL_ONLY - Compute the function and its L2 norm on only the initial and final iterations.
639 
640    Level: advanced
641 
642    Note:
643    This method combines the benefits of `SNES_NORM_INITIAL_ONLY` and `SNES_NORM_FINAL_ONLY`.
644 
645 .seealso: [](ch_snes), `SNESNormSchedule`, `SNES`, `SNESSetNormSchedule()`, `SNES_NORM_SNES_NORM_INITIAL_ONLY`, `SNES_NORM_FINAL_ONLY`
646 M*/
647 
648 PETSC_EXTERN PetscErrorCode SNESSetNormSchedule(SNES, SNESNormSchedule);
649 PETSC_EXTERN PetscErrorCode SNESGetNormSchedule(SNES, SNESNormSchedule *);
650 PETSC_EXTERN PetscErrorCode SNESSetFunctionNorm(SNES, PetscReal);
651 PETSC_EXTERN PetscErrorCode SNESGetFunctionNorm(SNES, PetscReal *);
652 PETSC_EXTERN PetscErrorCode SNESGetUpdateNorm(SNES, PetscReal *);
653 PETSC_EXTERN PetscErrorCode SNESGetSolutionNorm(SNES, PetscReal *);
654 
655 /*E
656    SNESFunctionType - Type of function computed
657 
658    Values:
659 +  `SNES_FUNCTION_DEFAULT`          - the default behavior for the current `SNESType`
660 .  `SNES_FUNCTION_UNPRECONDITIONED` - the original function provided
661 -  `SNES_FUNCTION_PRECONDITIONED`   - the modification of the function by the preconditioner
662 
663    Level: advanced
664 
665    Note:
666    Support for these is dependent on the solver.
667 
668 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `KSPSetNormType()`,
669           `KSPSetConvergenceTest()`, `KSPSetPCSide()`
670 E*/
671 typedef enum {
672   SNES_FUNCTION_DEFAULT          = -1,
673   SNES_FUNCTION_UNPRECONDITIONED = 0,
674   SNES_FUNCTION_PRECONDITIONED   = 1
675 } SNESFunctionType;
676 PETSC_EXTERN const char *const *const SNESFunctionTypes;
677 
678 PETSC_EXTERN PetscErrorCode SNESSetFunctionType(SNES, SNESFunctionType);
679 PETSC_EXTERN PetscErrorCode SNESGetFunctionType(SNES, SNESFunctionType *);
680 
681 PETSC_EXTERN PetscErrorCode SNESSetNGS(SNES, SNESNGSFn *, void *);
682 PETSC_EXTERN PetscErrorCode SNESGetNGS(SNES, SNESNGSFn **, void **);
683 PETSC_EXTERN PetscErrorCode SNESComputeNGS(SNES, Vec, Vec);
684 
685 PETSC_EXTERN PetscErrorCode SNESNGSSetSweeps(SNES, PetscInt);
686 PETSC_EXTERN PetscErrorCode SNESNGSGetSweeps(SNES, PetscInt *);
687 PETSC_EXTERN PetscErrorCode SNESNGSSetTolerances(SNES, PetscReal, PetscReal, PetscReal, PetscInt);
688 PETSC_EXTERN PetscErrorCode SNESNGSGetTolerances(SNES, PetscReal *, PetscReal *, PetscReal *, PetscInt *);
689 
690 PETSC_EXTERN PetscErrorCode SNESSetAlwaysComputesFinalResidual(SNES, PetscBool);
691 PETSC_EXTERN PetscErrorCode SNESGetAlwaysComputesFinalResidual(SNES, PetscBool *);
692 
693 PETSC_EXTERN PetscErrorCode SNESShellGetContext(SNES, void *);
694 PETSC_EXTERN PetscErrorCode SNESShellSetContext(SNES, void *);
695 PETSC_EXTERN PetscErrorCode SNESShellSetSolve(SNES, PetscErrorCode (*)(SNES, Vec));
696 
697 /* --------- Routines specifically for line search methods --------------- */
698 
699 /*S
700    SNESLineSearch - Abstract PETSc object that manages line-search operations for nonlinear solvers
701 
702    Level: beginner
703 
704 .seealso: [](ch_snes), `SNESLineSearchType`, `SNESLineSearchCreate()`, `SNESLineSearchSetType()`, `SNES`
705 S*/
706 typedef struct _p_LineSearch *SNESLineSearch;
707 
708 /*J
709    SNESLineSearchType - String with the name of a PETSc line search method `SNESLineSearch`. Provides all the linesearches for the nonlinear solvers, `SNES`,
710                         in PETSc.
711 
712    Values:
713 +  `SNESLINESEARCHBASIC`     - (or equivalently `SNESLINESEARCHNONE`) Simple damping line search, defaults to using the full Newton step
714 .  `SNESLINESEARCHBT`        - Backtracking line search over the L2 norm of the function or an objective function
715 .  `SNESLINESEARCHSECANT`    - Secant line search over the L2 norm of the function or an objective function
716 .  `SNESLINESEARCHCP`        - Critical point secant line search assuming $F(x) = \nabla G(x)$ for some unknown $G(x)$
717 .  `SNESLINESEARCHNLEQERR`   - Affine-covariant error-oriented linesearch
718 -  `SNESLINESEARCHBISECTION` - bisection line search for a root in the directional derivative
719 -  `SNESLINESEARCHSHELL`     - User provided `SNESLineSearch` implementation
720 
721    Level: beginner
722 
723    Note:
724    Use `SNESLineSearchSetType()` or the options database key `-snes_linesearch_type` to set
725    the specific line search algorithm to use with a given `SNES` object. Not all `SNESType` can utilize a line search.
726 
727 .seealso: [](ch_snes), `SNESLineSearch`, `SNESLineSearchSetType()`, `SNES`
728 J*/
729 typedef const char *SNESLineSearchType;
730 #define SNESLINESEARCHBT        "bt"
731 #define SNESLINESEARCHNLEQERR   "nleqerr"
732 #define SNESLINESEARCHBASIC     "basic"
733 #define SNESLINESEARCHNONE      "none"
734 #define SNESLINESEARCHSECANT    "secant"
735 #define SNESLINESEARCHCP        "cp"
736 #define SNESLINESEARCHSHELL     "shell"
737 #define SNESLINESEARCHNCGLINEAR "ncglinear"
738 #define SNESLINESEARCHBISECTION "bisection"
739 
740 PETSC_EXTERN PetscFunctionList SNESList;
741 PETSC_EXTERN PetscClassId      SNESLINESEARCH_CLASSID;
742 PETSC_EXTERN PetscFunctionList SNESLineSearchList;
743 
744 #define SNES_LINESEARCH_ORDER_LINEAR    1
745 #define SNES_LINESEARCH_ORDER_QUADRATIC 2
746 #define SNES_LINESEARCH_ORDER_CUBIC     3
747 
748 /*S
749   SNESLineSearchVIProjectFn - A prototype of a `SNES` function that projects a vector onto the VI bounds, passed to `SNESLineSearchSetVIFunctions()`
750 
751   Calling Sequence:
752 + snes  - `SNES` context
753 - u     - the vector to project to the bounds
754 
755   Level: advanced
756 
757   Note:
758   The deprecated `SNESLineSearchVIProjectFunc` still works as a replacement for `SNESLineSearchVIProjectFn` *.
759 
760 .seealso: [](ch_snes), `SNES`, `SNESLineSearch`
761 S*/
762 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode             SNESLineSearchVIProjectFn(SNES snes, Vec u);
763 PETSC_EXTERN_TYPEDEF typedef SNESLineSearchVIProjectFn *SNESLineSearchVIProjectFunc PETSC_DEPRECATED_TYPEDEF(3, 21, 0, "SNESLineSearchVIProjectFn*", );
764 
765 /*S
766   SNESLineSearchVIProjectFn - A prototype of a `SNES` function that computes the norm of the active set variables in a vector in a VI solve,
767   passed to `SNESLineSearchSetVIFunctions()`
768 
769   Calling Sequence:
770 + snes  - `SNES` context
771 . f     - the vector to compute the norm of
772 . u     - the current solution, entries that are on the VI bounds are ignored
773 - fnorm - the resulting norm
774 
775   Level: advanced
776 
777   Note:
778   The deprecated `SNESLineSearchVINormFunc` still works as a replacement for `SNESLineSearchVINormFn` *.
779 
780 .seealso: [](ch_snes), `SNES`, `SNESLineSearch`
781 S*/
782 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode          SNESLineSearchVINormFn(SNES snes, Vec f, Vec u, PetscReal *fnorm);
783 PETSC_EXTERN_TYPEDEF typedef SNESLineSearchVINormFn *SNESLineSearchVINormFunc PETSC_DEPRECATED_TYPEDEF(3, 21, 0, "SNESLineSearchVINormFnn*", );
784 
785 /*S
786   SNESLineSearchVIDirDerivFn - A prototype of a `SNES` function that computes the directional derivative considering the VI bounds, passed to `SNESLineSearchSetVIFunctions()`
787 
788   Calling Sequence:
789 + snes  - `SNES` context
790 . f     - the function vector to compute the directional derivative with
791 . u     - the current solution, entries that are on the VI bounds are ignored
792 . y     - the direction to compute the directional derivative
793 - fty   - the resulting directional derivative
794 
795   Level: advanced
796 
797 .seealso: [](ch_snes), `SNES`, `SNESLineSearch`, `SNESLineSearchVIProjectFn`, `SNESLineSearchVIProjectFn`, `SNESLineSearchSetVIFunctions()`, `SNESLineSearchGetVIFunctions()`
798 S*/
799 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode SNESLineSearchVIDirDerivFn(SNES snes, Vec f, Vec u, Vec y, PetscScalar *fty);
800 
801 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode              SNESLineSearchApplyFn(SNESLineSearch);
802 PETSC_EXTERN_TYPEDEF typedef SNESLineSearchApplyFn      *SNESLineSearchApplyFunc PETSC_DEPRECATED_TYPEDEF(3, 21, 0, "SNESLineSearchApplyFn*", );
803 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode              SNESLineSearchShellApplyFn(SNESLineSearch, void *);
804 PETSC_EXTERN_TYPEDEF typedef SNESLineSearchShellApplyFn *SNESLineSearchUserFunc PETSC_DEPRECATED_TYPEDEF(3, 21, 0, "SNESLineSearchApplyFn*", );
805 
806 PETSC_EXTERN PetscErrorCode SNESLineSearchCreate(MPI_Comm, SNESLineSearch *);
807 PETSC_EXTERN PetscErrorCode SNESLineSearchReset(SNESLineSearch);
808 PETSC_EXTERN PetscErrorCode SNESLineSearchView(SNESLineSearch, PetscViewer);
809 PETSC_EXTERN PetscErrorCode SNESLineSearchDestroy(SNESLineSearch *);
810 PETSC_EXTERN PetscErrorCode SNESLineSearchGetType(SNESLineSearch, SNESLineSearchType *);
811 PETSC_EXTERN PetscErrorCode SNESLineSearchSetType(SNESLineSearch, SNESLineSearchType);
812 PETSC_EXTERN PetscErrorCode SNESLineSearchSetFromOptions(SNESLineSearch);
813 PETSC_EXTERN PetscErrorCode SNESLineSearchSetFunction(SNESLineSearch, PetscErrorCode (*)(SNES, Vec, Vec));
814 PETSC_EXTERN PetscErrorCode SNESLineSearchSetUp(SNESLineSearch);
815 PETSC_EXTERN PetscErrorCode SNESLineSearchApply(SNESLineSearch, Vec, Vec, PetscReal *, Vec);
816 PETSC_EXTERN PetscErrorCode SNESLineSearchPreCheck(SNESLineSearch, Vec, Vec, PetscBool *);
817 PETSC_EXTERN PetscErrorCode SNESLineSearchPostCheck(SNESLineSearch, Vec, Vec, Vec, PetscBool *, PetscBool *);
818 PETSC_EXTERN PetscErrorCode SNESLineSearchSetWorkVecs(SNESLineSearch, PetscInt);
819 
820 /* set the functions for precheck and postcheck */
821 
822 PETSC_EXTERN PetscErrorCode SNESLineSearchSetPreCheck(SNESLineSearch, PetscErrorCode (*)(SNESLineSearch, Vec, Vec, PetscBool *, void *), void *ctx);
823 PETSC_EXTERN PetscErrorCode SNESLineSearchSetPostCheck(SNESLineSearch, PetscErrorCode (*)(SNESLineSearch, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void *ctx);
824 
825 PETSC_EXTERN PetscErrorCode SNESLineSearchGetPreCheck(SNESLineSearch, PetscErrorCode (**)(SNESLineSearch, Vec, Vec, PetscBool *, void *), void **ctx);
826 PETSC_EXTERN PetscErrorCode SNESLineSearchGetPostCheck(SNESLineSearch, PetscErrorCode (**)(SNESLineSearch, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void **ctx);
827 
828 /* set the functions for VI-specific line search operations */
829 
830 PETSC_EXTERN PetscErrorCode SNESLineSearchSetVIFunctions(SNESLineSearch, SNESLineSearchVIProjectFn *, SNESLineSearchVINormFn *, SNESLineSearchVIDirDerivFn *);
831 PETSC_EXTERN PetscErrorCode SNESLineSearchGetVIFunctions(SNESLineSearch, SNESLineSearchVIProjectFn **, SNESLineSearchVINormFn **, SNESLineSearchVIDirDerivFn **);
832 
833 /* pointers to the associated SNES in order to be able to get the function evaluation out */
834 PETSC_EXTERN PetscErrorCode SNESLineSearchSetSNES(SNESLineSearch, SNES);
835 PETSC_EXTERN PetscErrorCode SNESLineSearchGetSNES(SNESLineSearch, SNES *);
836 
837 /* set and get the parameters and vectors */
838 PETSC_EXTERN PetscErrorCode SNESLineSearchGetTolerances(SNESLineSearch, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscInt *);
839 PETSC_EXTERN PetscErrorCode SNESLineSearchSetTolerances(SNESLineSearch, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscInt);
840 
841 PETSC_EXTERN PetscErrorCode SNESLineSearchPreCheckPicard(SNESLineSearch, Vec, Vec, PetscBool *, void *);
842 
843 PETSC_EXTERN PetscErrorCode SNESLineSearchGetLambda(SNESLineSearch, PetscReal *);
844 PETSC_EXTERN PetscErrorCode SNESLineSearchSetLambda(SNESLineSearch, PetscReal);
845 
846 PETSC_EXTERN PetscErrorCode SNESLineSearchGetDamping(SNESLineSearch, PetscReal *);
847 PETSC_EXTERN PetscErrorCode SNESLineSearchSetDamping(SNESLineSearch, PetscReal);
848 
849 PETSC_EXTERN PetscErrorCode SNESLineSearchGetOrder(SNESLineSearch, PetscInt *);
850 PETSC_EXTERN PetscErrorCode SNESLineSearchSetOrder(SNESLineSearch, PetscInt);
851 
852 /*E
853     SNESLineSearchReason - indication if the line search has succeeded or failed and why
854 
855   Values:
856 +  `SNES_LINESEARCH_SUCCEEDED`       - the line search succeeded
857 .  `SNES_LINESEARCH_FAILED_NANORINF` - a not a number of infinity appeared in the computions
858 .  `SNES_LINESEARCH_FAILED_DOMAIN`   - the function was evaluated outside of its domain, see `SNESSetFunctionDomainError()` and `SNESSetJacobianDomainError()`
859 .  `SNES_LINESEARCH_FAILED_REDUCT`   - the linear search failed to get the requested decrease in its norm or objective
860 .  `SNES_LINESEARCH_FAILED_USER`     - used by `SNESLINESEARCHNLEQERR` to indicate the user changed the search direction inappropriately
861 -  `SNES_LINESEARCH_FAILED_FUNCTION` - indicates the maximum number of function evaluations allowed has been surpassed, `SNESConvergedReason` is also
862                                        set to `SNES_DIVERGED_FUNCTION_COUNT`
863 
864    Level: intermediate
865 
866    Developer Note:
867    Some of these reasons overlap with values of `SNESConvergedReason`
868 
869 .seealso: [](ch_snes), `SNES`, `SNESSolve()`, `SNESGetConvergedReason()`, `KSPConvergedReason`, `SNESSetConvergenceTest()`,
870           `SNESSetFunctionDomainError()` and `SNESSetJacobianDomainError()`
871 E*/
872 typedef enum {
873   SNES_LINESEARCH_SUCCEEDED,
874   SNES_LINESEARCH_FAILED_NANORINF,
875   SNES_LINESEARCH_FAILED_DOMAIN,
876   SNES_LINESEARCH_FAILED_REDUCT, /* INSUFFICIENT REDUCTION */
877   SNES_LINESEARCH_FAILED_USER,
878   SNES_LINESEARCH_FAILED_FUNCTION
879 } SNESLineSearchReason;
880 
881 PETSC_EXTERN PetscErrorCode SNESLineSearchGetReason(SNESLineSearch, SNESLineSearchReason *);
882 PETSC_EXTERN PetscErrorCode SNESLineSearchSetReason(SNESLineSearch, SNESLineSearchReason);
883 
884 PETSC_EXTERN PetscErrorCode SNESLineSearchGetVecs(SNESLineSearch, Vec *, Vec *, Vec *, Vec *, Vec *);
885 PETSC_EXTERN PetscErrorCode SNESLineSearchSetVecs(SNESLineSearch, Vec, Vec, Vec, Vec, Vec);
886 
887 PETSC_EXTERN PetscErrorCode SNESLineSearchGetNorms(SNESLineSearch, PetscReal *, PetscReal *, PetscReal *);
888 PETSC_EXTERN PetscErrorCode SNESLineSearchSetNorms(SNESLineSearch, PetscReal, PetscReal, PetscReal);
889 PETSC_EXTERN PetscErrorCode SNESLineSearchComputeNorms(SNESLineSearch);
890 PETSC_EXTERN PetscErrorCode SNESLineSearchSetComputeNorms(SNESLineSearch, PetscBool);
891 
892 PETSC_EXTERN PetscErrorCode SNESLineSearchMonitor(SNESLineSearch);
893 PETSC_EXTERN PetscErrorCode SNESLineSearchMonitorSet(SNESLineSearch, PetscErrorCode (*)(SNESLineSearch, void *), void *, PetscCtxDestroyFn *);
894 PETSC_EXTERN PetscErrorCode SNESLineSearchMonitorSetFromOptions(SNESLineSearch, const char[], const char[], const char[], PetscErrorCode (*)(SNESLineSearch, PetscViewerAndFormat *), PetscErrorCode (*)(SNESLineSearch, PetscViewerAndFormat *));
895 PETSC_EXTERN PetscErrorCode SNESLineSearchMonitorCancel(SNESLineSearch);
896 PETSC_EXTERN PetscErrorCode SNESLineSearchSetDefaultMonitor(SNESLineSearch, PetscViewer);
897 PETSC_EXTERN PetscErrorCode SNESLineSearchGetDefaultMonitor(SNESLineSearch, PetscViewer *);
898 PETSC_EXTERN PetscErrorCode SNESLineSearchMonitorSolutionUpdate(SNESLineSearch, PetscViewerAndFormat *);
899 
900 PETSC_EXTERN PetscErrorCode SNESLineSearchAppendOptionsPrefix(SNESLineSearch, const char[]);
901 PETSC_EXTERN PetscErrorCode SNESLineSearchGetOptionsPrefix(SNESLineSearch, const char *[]);
902 
903 /* Shell interface functions */
904 PETSC_EXTERN PetscErrorCode SNESLineSearchShellSetApply(SNESLineSearch, SNESLineSearchShellApplyFn *, void *);
905 PETSC_EXTERN PetscErrorCode SNESLineSearchShellGetApply(SNESLineSearch, SNESLineSearchShellApplyFn **, void **);
906 
907 PETSC_DEPRECATED_FUNCTION(3, 21, 0, "SNESLinesearchShellSetApply()", ) static inline PetscErrorCode SNESLineSearchShellSetUserFunc(SNESLineSearch ls, SNESLineSearchShellApplyFn *f, void *ctx)
908 {
909   return SNESLineSearchShellSetApply(ls, f, ctx);
910 }
911 
912 PETSC_DEPRECATED_FUNCTION(3, 21, 0, "SNESLinesearchShellGetApply()", ) static inline PetscErrorCode SNESLineSearchShellGetUserFunc(SNESLineSearch ls, SNESLineSearchShellApplyFn **f, void **ctx)
913 {
914   return SNESLineSearchShellGetApply(ls, f, ctx);
915 }
916 
917 /* BT interface functions */
918 PETSC_EXTERN PetscErrorCode SNESLineSearchBTSetAlpha(SNESLineSearch, PetscReal);
919 PETSC_EXTERN PetscErrorCode SNESLineSearchBTGetAlpha(SNESLineSearch, PetscReal *);
920 
921 /*register line search types */
922 PETSC_EXTERN PetscErrorCode SNESLineSearchRegister(const char[], PetscErrorCode (*)(SNESLineSearch));
923 
924 /* Routines for VI solver */
925 PETSC_EXTERN PetscErrorCode SNESVISetVariableBounds(SNES, Vec, Vec);
926 PETSC_EXTERN PetscErrorCode SNESVIGetVariableBounds(SNES, Vec *, Vec *);
927 PETSC_EXTERN PetscErrorCode SNESVISetComputeVariableBounds(SNES, PetscErrorCode (*)(SNES, Vec, Vec));
928 PETSC_EXTERN PetscErrorCode SNESVIGetInactiveSet(SNES, IS *);
929 PETSC_EXTERN PetscErrorCode SNESVIGetActiveSetIS(SNES, Vec, Vec, IS *);
930 PETSC_EXTERN PetscErrorCode SNESVIComputeInactiveSetFnorm(SNES, Vec, Vec, PetscReal *);
931 PETSC_EXTERN PetscErrorCode SNESVIComputeInactiveSetFtY(SNES, Vec, Vec, Vec, PetscScalar *);
932 PETSC_EXTERN PetscErrorCode SNESVISetRedundancyCheck(SNES, PetscErrorCode (*)(SNES, IS, IS *, void *), void *);
933 PETSC_EXTERN PetscErrorCode SNESVIComputeMeritFunction(Vec, PetscReal *, PetscReal *);
934 PETSC_EXTERN PetscErrorCode SNESVIComputeFunction(SNES, Vec, Vec, void *);
935 PETSC_EXTERN PetscErrorCode DMSetVI(DM, IS);
936 PETSC_EXTERN PetscErrorCode DMDestroyVI(DM);
937 
938 PETSC_EXTERN PetscErrorCode SNESTestLocalMin(SNES);
939 
940 /* Should this routine be private? */
941 PETSC_EXTERN PetscErrorCode SNESComputeJacobian(SNES, Vec, Mat, Mat);
942 PETSC_EXTERN PetscErrorCode SNESTestJacobian(SNES, PetscReal *, PetscReal *);
943 PETSC_EXTERN PetscErrorCode SNESTestFunction(SNES);
944 
945 PETSC_EXTERN PetscErrorCode SNESSetDM(SNES, DM);
946 PETSC_EXTERN PetscErrorCode SNESGetDM(SNES, DM *);
947 PETSC_EXTERN PetscErrorCode SNESSetNPC(SNES, SNES);
948 PETSC_EXTERN PetscErrorCode SNESGetNPC(SNES, SNES *);
949 PETSC_EXTERN PetscErrorCode SNESHasNPC(SNES, PetscBool *);
950 PETSC_EXTERN PetscErrorCode SNESApplyNPC(SNES, Vec, Vec, Vec);
951 PETSC_EXTERN PetscErrorCode SNESGetNPCFunction(SNES, Vec, PetscReal *);
952 PETSC_EXTERN PetscErrorCode SNESComputeFunctionDefaultNPC(SNES, Vec, Vec);
953 PETSC_EXTERN PetscErrorCode SNESSetNPCSide(SNES, PCSide);
954 PETSC_EXTERN PetscErrorCode SNESGetNPCSide(SNES, PCSide *);
955 PETSC_EXTERN PetscErrorCode SNESSetLineSearch(SNES, SNESLineSearch);
956 PETSC_EXTERN PetscErrorCode SNESGetLineSearch(SNES, SNESLineSearch *);
957 
958 PETSC_DEPRECATED_FUNCTION(3, 4, 0, "SNESGetLineSearch()", ) static inline PetscErrorCode SNESGetSNESLineSearch(SNES snes, SNESLineSearch *ls)
959 {
960   return SNESGetLineSearch(snes, ls);
961 }
962 PETSC_DEPRECATED_FUNCTION(3, 4, 0, "SNESSetLineSearch()", ) static inline PetscErrorCode SNESSetSNESLineSearch(SNES snes, SNESLineSearch ls)
963 {
964   return SNESSetLineSearch(snes, ls);
965 }
966 
967 PETSC_EXTERN PetscErrorCode SNESSetUpMatrices(SNES);
968 PETSC_EXTERN PetscErrorCode DMSNESSetFunction(DM, SNESFunctionFn *, void *);
969 PETSC_EXTERN PetscErrorCode DMSNESGetFunction(DM, SNESFunctionFn **, void **);
970 PETSC_EXTERN PetscErrorCode DMSNESSetFunctionContextDestroy(DM, PetscCtxDestroyFn *);
971 PETSC_EXTERN PetscErrorCode DMSNESSetMFFunction(DM, SNESFunctionFn *, void *);
972 PETSC_EXTERN PetscErrorCode DMSNESSetNGS(DM, SNESNGSFn *, void *);
973 PETSC_EXTERN PetscErrorCode DMSNESGetNGS(DM, SNESNGSFn **, void **);
974 PETSC_EXTERN PetscErrorCode DMSNESSetJacobian(DM, SNESJacobianFn *, void *);
975 PETSC_EXTERN PetscErrorCode DMSNESGetJacobian(DM, SNESJacobianFn **, void **);
976 PETSC_EXTERN PetscErrorCode DMSNESSetJacobianContextDestroy(DM, PetscCtxDestroyFn *);
977 PETSC_EXTERN PetscErrorCode DMSNESSetPicard(DM, SNESFunctionFn *, SNESJacobianFn *, void *);
978 PETSC_EXTERN PetscErrorCode DMSNESGetPicard(DM, SNESFunctionFn **, SNESJacobianFn **, void **);
979 PETSC_EXTERN PetscErrorCode DMSNESSetObjective(DM, SNESObjectiveFn *, void *);
980 PETSC_EXTERN PetscErrorCode DMSNESGetObjective(DM, SNESObjectiveFn **, void **);
981 PETSC_EXTERN PetscErrorCode DMCopyDMSNES(DM, DM);
982 
983 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode DMDASNESFunctionFn(DMDALocalInfo *, void *, void *, void *);
984 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode DMDASNESJacobianFn(DMDALocalInfo *, void *, Mat, Mat, void *);
985 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode DMDASNESObjectiveFn(DMDALocalInfo *, void *, PetscReal *, void *);
986 
987 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode DMDASNESFunctionVecFn(DMDALocalInfo *, Vec, Vec, void *);
988 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode DMDASNESJacobianVecFn(DMDALocalInfo *, Vec, Mat, Mat, void *);
989 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode DMDASNESObjectiveVecFn(DMDALocalInfo *, Vec, PetscReal *, void *);
990 
991 PETSC_EXTERN PetscErrorCode DMDASNESSetFunctionLocal(DM, InsertMode, DMDASNESFunctionFn *, void *);
992 PETSC_EXTERN PetscErrorCode DMDASNESSetJacobianLocal(DM, DMDASNESJacobianFn *, void *);
993 PETSC_EXTERN PetscErrorCode DMDASNESSetObjectiveLocal(DM, DMDASNESObjectiveFn *, void *);
994 PETSC_EXTERN PetscErrorCode DMDASNESSetPicardLocal(DM, InsertMode, DMDASNESFunctionFn *, DMDASNESJacobianFn, void *);
995 
996 PETSC_EXTERN PetscErrorCode DMDASNESSetFunctionLocalVec(DM, InsertMode, DMDASNESFunctionVecFn *, void *);
997 PETSC_EXTERN PetscErrorCode DMDASNESSetJacobianLocalVec(DM, DMDASNESJacobianVecFn *, void *);
998 PETSC_EXTERN PetscErrorCode DMDASNESSetObjectiveLocalVec(DM, DMDASNESObjectiveVecFn *, void *);
999 
1000 PETSC_EXTERN PetscErrorCode DMSNESSetBoundaryLocal(DM, PetscErrorCode (*)(DM, Vec, void *), void *);
1001 PETSC_EXTERN PetscErrorCode DMSNESSetObjectiveLocal(DM, PetscErrorCode (*)(DM, Vec, PetscReal *, void *), void *);
1002 PETSC_EXTERN PetscErrorCode DMSNESSetFunctionLocal(DM, PetscErrorCode (*)(DM, Vec, Vec, void *), void *);
1003 PETSC_EXTERN PetscErrorCode DMSNESSetJacobianLocal(DM, PetscErrorCode (*)(DM, Vec, Mat, Mat, void *), void *);
1004 PETSC_EXTERN PetscErrorCode DMSNESGetBoundaryLocal(DM, PetscErrorCode (**)(DM, Vec, void *), void **);
1005 PETSC_EXTERN PetscErrorCode DMSNESGetObjectiveLocal(DM, PetscErrorCode (**)(DM, Vec, PetscReal *, void *), void **);
1006 PETSC_EXTERN PetscErrorCode DMSNESGetFunctionLocal(DM, PetscErrorCode (**)(DM, Vec, Vec, void *), void **);
1007 PETSC_EXTERN PetscErrorCode DMSNESGetJacobianLocal(DM, PetscErrorCode (**)(DM, Vec, Mat, Mat, void *), void **);
1008 
1009 /* Routines for Multiblock solver */
1010 PETSC_EXTERN PetscErrorCode SNESMultiblockSetFields(SNES, const char[], PetscInt, const PetscInt *);
1011 PETSC_EXTERN PetscErrorCode SNESMultiblockSetIS(SNES, const char[], IS);
1012 PETSC_EXTERN PetscErrorCode SNESMultiblockSetBlockSize(SNES, PetscInt);
1013 PETSC_EXTERN PetscErrorCode SNESMultiblockSetType(SNES, PCCompositeType);
1014 PETSC_EXTERN PetscErrorCode SNESMultiblockGetSubSNES(SNES, PetscInt *, SNES *[]);
1015 
1016 /*J
1017    SNESMSType - String with the name of a PETSc `SNESMS` method.
1018 
1019    Level: intermediate
1020 
1021 .seealso: [](ch_snes), `SNESMS`, `SNESMSGetType()`, `SNESMSSetType()`, `SNES`
1022 J*/
1023 typedef const char *SNESMSType;
1024 #define SNESMSM62       "m62"
1025 #define SNESMSEULER     "euler"
1026 #define SNESMSJAMESON83 "jameson83"
1027 #define SNESMSVLTP11    "vltp11"
1028 #define SNESMSVLTP21    "vltp21"
1029 #define SNESMSVLTP31    "vltp31"
1030 #define SNESMSVLTP41    "vltp41"
1031 #define SNESMSVLTP51    "vltp51"
1032 #define SNESMSVLTP61    "vltp61"
1033 
1034 PETSC_EXTERN PetscErrorCode SNESMSRegister(SNESMSType, PetscInt, PetscInt, PetscReal, const PetscReal[], const PetscReal[], const PetscReal[]);
1035 PETSC_EXTERN PetscErrorCode SNESMSRegisterAll(void);
1036 PETSC_EXTERN PetscErrorCode SNESMSGetType(SNES, SNESMSType *);
1037 PETSC_EXTERN PetscErrorCode SNESMSSetType(SNES, SNESMSType);
1038 PETSC_EXTERN PetscErrorCode SNESMSGetDamping(SNES, PetscReal *);
1039 PETSC_EXTERN PetscErrorCode SNESMSSetDamping(SNES, PetscReal);
1040 PETSC_EXTERN PetscErrorCode SNESMSFinalizePackage(void);
1041 PETSC_EXTERN PetscErrorCode SNESMSInitializePackage(void);
1042 PETSC_EXTERN PetscErrorCode SNESMSRegisterDestroy(void);
1043 
1044 /*MC
1045    SNESNGMRESRestartType - the restart approach used by `SNESNGMRES`
1046 
1047   Values:
1048 +   `SNES_NGMRES_RESTART_NONE`       - never restart
1049 .   `SNES_NGMRES_RESTART_DIFFERENCE` - restart based upon difference criteria
1050 -   `SNES_NGMRES_RESTART_PERIODIC`   - restart after a fixed number of iterations
1051 
1052   Options Database Keys:
1053 + -snes_ngmres_restart_type <difference,periodic,none> - set the restart type
1054 - -snes_ngmres_restart <30>                            - sets the number of iterations before restart for periodic
1055 
1056    Level: intermediate
1057 
1058 .seealso: `SNES, `SNESNGMRES`, `SNESNGMRESSetSelectType()`, `SNESNGMRESGetSelectType()`, `SNESNGMRESSetRestartType()`,
1059           `SNESNGMRESGetRestartType()`, `SNESNGMRESSelectType`
1060 M*/
1061 typedef enum {
1062   SNES_NGMRES_RESTART_NONE       = 0,
1063   SNES_NGMRES_RESTART_PERIODIC   = 1,
1064   SNES_NGMRES_RESTART_DIFFERENCE = 2
1065 } SNESNGMRESRestartType;
1066 PETSC_EXTERN const char *const SNESNGMRESRestartTypes[];
1067 
1068 /*MC
1069    SNESNGMRESSelectType - the approach used by `SNESNGMRES` to determine how the candidate solution and
1070   combined solution are used to create the next iterate.
1071 
1072    Values:
1073 +   `SNES_NGMRES_SELECT_NONE`       - choose the combined solution all the time
1074 .   `SNES_NGMRES_SELECT_DIFFERENCE` - choose based upon the selection criteria
1075 -   `SNES_NGMRES_SELECT_LINESEARCH` - choose based upon line search combination
1076 
1077   Options Database Key:
1078 . -snes_ngmres_select_type<difference,none,linesearch> - select type
1079 
1080    Level: intermediate
1081 
1082 .seealso: `SNES, `SNESNGMRES`, `SNESNGMRESSetSelectType()`, `SNESNGMRESGetSelectType()`, `SNESNGMRESSetRestartType()`,
1083           `SNESNGMRESGetRestartType()`, `SNESNGMRESRestartType`
1084 M*/
1085 typedef enum {
1086   SNES_NGMRES_SELECT_NONE       = 0,
1087   SNES_NGMRES_SELECT_DIFFERENCE = 1,
1088   SNES_NGMRES_SELECT_LINESEARCH = 2
1089 } SNESNGMRESSelectType;
1090 PETSC_EXTERN const char *const SNESNGMRESSelectTypes[];
1091 
1092 PETSC_EXTERN PetscErrorCode SNESNGMRESSetRestartType(SNES, SNESNGMRESRestartType);
1093 PETSC_EXTERN PetscErrorCode SNESNGMRESSetSelectType(SNES, SNESNGMRESSelectType);
1094 PETSC_EXTERN PetscErrorCode SNESNGMRESSetRestartFmRise(SNES, PetscBool);
1095 PETSC_EXTERN PetscErrorCode SNESNGMRESGetRestartFmRise(SNES, PetscBool *);
1096 
1097 /*MC
1098    SNESNCGType - the conjugate update approach for `SNESNCG`
1099 
1100    Values:
1101 +   `SNES_NCG_FR`  - Fletcher-Reeves update
1102 .   `SNES_NCG_PRP` - Polak-Ribiere-Polyak update, the default and the only one that tolerates generalized search directions
1103 .   `SNES_NCG_HS`  - Hestenes-Steifel update
1104 .   `SNES_NCG_DY`  - Dai-Yuan update
1105 -   `SNES_NCG_CD`  - Conjugate Descent update
1106 
1107   Options Database Key:
1108 . -snes_ncg_type<fr,prp,hs,dy,cd> - select type
1109 
1110    Level: intermediate
1111 
1112 .seealso: `SNES, `SNESNCG`, `SNESNCGSetType()`
1113 M*/
1114 typedef enum {
1115   SNES_NCG_FR  = 0,
1116   SNES_NCG_PRP = 1,
1117   SNES_NCG_HS  = 2,
1118   SNES_NCG_DY  = 3,
1119   SNES_NCG_CD  = 4
1120 } SNESNCGType;
1121 PETSC_EXTERN const char *const SNESNCGTypes[];
1122 
1123 PETSC_EXTERN PetscErrorCode SNESNCGSetType(SNES, SNESNCGType);
1124 
1125 /*MC
1126    SNESQNScaleType - the scaling type used by `SNESQN`
1127 
1128    Values:
1129 +   `SNES_QN_SCALE_NONE`     - don't scale the problem
1130 .   `SNES_QN_SCALE_SCALAR`   - use Shanno scaling
1131 .   `SNES_QN_SCALE_DIAGONAL` - scale with a diagonalized BFGS formula (see Gilbert and Lemarechal 1989), available
1132 -   `SNES_QN_SCALE_JACOBIAN` - scale by solving a linear system coming from the Jacobian you provided with `SNESSetJacobian()`
1133                                computed at the first iteration of `SNESQN` and at ever restart.
1134 
1135     Options Database Key:
1136 . -snes_qn_scale_type <diagonal,none,scalar,jacobian> - Scaling type
1137 
1138    Level: intermediate
1139 
1140 .seealso: `SNES, `SNESQN`, `SNESQNSetScaleType()`, `SNESQNType`, `SNESQNSetType()`, `SNESQNSetRestartType()`, `SNESQNRestartType`
1141 M*/
1142 typedef enum {
1143   SNES_QN_SCALE_DEFAULT  = 0,
1144   SNES_QN_SCALE_NONE     = 1,
1145   SNES_QN_SCALE_SCALAR   = 2,
1146   SNES_QN_SCALE_DIAGONAL = 3,
1147   SNES_QN_SCALE_JACOBIAN = 4
1148 } SNESQNScaleType;
1149 PETSC_EXTERN const char *const SNESQNScaleTypes[];
1150 
1151 /*MC
1152    SNESQNRestartType - the restart approached used by `SNESQN`
1153 
1154    Values:
1155 +   `SNES_QN_RESTART_NONE`     - never restart
1156 .   `SNES_QN_RESTART_POWELL`   - restart based upon descent criteria
1157 -   `SNES_QN_RESTART_PERIODIC` - restart after a fixed number of iterations
1158 
1159   Options Database Keys:
1160 + -snes_qn_restart_type <powell,periodic,none> - set the restart type
1161 - -snes_qn_m <m>                               - sets the number of stored updates and the restart period for periodic
1162 
1163    Level: intermediate
1164 
1165 .seealso: `SNES, `SNESQN`, `SNESQNSetScaleType()`, `SNESQNType`, `SNESQNSetType()`, `SNESQNSetRestartType()`, `SNESQNScaleType`
1166 M*/
1167 typedef enum {
1168   SNES_QN_RESTART_DEFAULT  = 0,
1169   SNES_QN_RESTART_NONE     = 1,
1170   SNES_QN_RESTART_POWELL   = 2,
1171   SNES_QN_RESTART_PERIODIC = 3
1172 } SNESQNRestartType;
1173 PETSC_EXTERN const char *const SNESQNRestartTypes[];
1174 
1175 /*MC
1176    SNESQNType - the type used by `SNESQN`
1177 
1178   Values:
1179 +   `SNES_QN_LBFGS`      - LBFGS variant
1180 .   `SNES_QN_BROYDEN`    - Broyden variant
1181 -   `SNES_QN_BADBROYDEN` - Bad Broyden variant
1182 
1183   Options Database Key:
1184 . -snes_qn_type <lbfgs,broyden,badbroyden> - quasi-Newton type
1185 
1186    Level: intermediate
1187 
1188 .seealso: `SNES, `SNESQN`, `SNESQNSetScaleType()`, `SNESQNSetType()`, `SNESQNScaleType`, `SNESQNRestartType`, `SNESQNSetRestartType()`
1189 M*/
1190 typedef enum {
1191   SNES_QN_LBFGS      = 0,
1192   SNES_QN_BROYDEN    = 1,
1193   SNES_QN_BADBROYDEN = 2
1194 } SNESQNType;
1195 PETSC_EXTERN const char *const SNESQNTypes[];
1196 
1197 PETSC_EXTERN PetscErrorCode SNESQNSetType(SNES, SNESQNType);
1198 PETSC_EXTERN PetscErrorCode SNESQNSetScaleType(SNES, SNESQNScaleType);
1199 PETSC_EXTERN PetscErrorCode SNESQNSetRestartType(SNES, SNESQNRestartType);
1200 
1201 PETSC_EXTERN PetscErrorCode SNESNASMGetType(SNES, PCASMType *);
1202 PETSC_EXTERN PetscErrorCode SNESNASMSetType(SNES, PCASMType);
1203 PETSC_EXTERN PetscErrorCode SNESNASMGetSubdomains(SNES, PetscInt *, SNES *[], VecScatter *[], VecScatter *[], VecScatter *[]);
1204 PETSC_EXTERN PetscErrorCode SNESNASMSetSubdomains(SNES, PetscInt, SNES[], VecScatter[], VecScatter[], VecScatter[]);
1205 PETSC_EXTERN PetscErrorCode SNESNASMSetDamping(SNES, PetscReal);
1206 PETSC_EXTERN PetscErrorCode SNESNASMGetDamping(SNES, PetscReal *);
1207 PETSC_EXTERN PetscErrorCode SNESNASMGetSubdomainVecs(SNES, PetscInt *, Vec *[], Vec *[], Vec *[], Vec *[]);
1208 PETSC_EXTERN PetscErrorCode SNESNASMSetComputeFinalJacobian(SNES, PetscBool);
1209 PETSC_EXTERN PetscErrorCode SNESNASMGetSNES(SNES, PetscInt, SNES *);
1210 PETSC_EXTERN PetscErrorCode SNESNASMGetNumber(SNES, PetscInt *);
1211 PETSC_EXTERN PetscErrorCode SNESNASMSetWeight(SNES, Vec);
1212 
1213 /*E
1214   SNESCompositeType - Determines how two or more preconditioners are composed with the `SNESType` of `SNESCOMPOSITE`
1215 
1216   Values:
1217 + `SNES_COMPOSITE_ADDITIVE`        - results from application of all preconditioners are added together
1218 . `SNES_COMPOSITE_MULTIPLICATIVE`  - preconditioners are applied sequentially to the residual freshly
1219                                      computed after the previous preconditioner application
1220 - `SNES_COMPOSITE_ADDITIVEOPTIMAL` - uses a linear combination of the solutions obtained with each preconditioner that approximately minimize the function
1221                                      value at the new iteration.
1222 
1223    Level: beginner
1224 
1225 .seealso: [](sec_pc), `PCCOMPOSITE`, `PCFIELDSPLIT`, `PC`, `PCCompositeSetType()`, `PCCompositeType`
1226 E*/
1227 typedef enum {
1228   SNES_COMPOSITE_ADDITIVE,
1229   SNES_COMPOSITE_MULTIPLICATIVE,
1230   SNES_COMPOSITE_ADDITIVEOPTIMAL
1231 } SNESCompositeType;
1232 PETSC_EXTERN const char *const SNESCompositeTypes[];
1233 
1234 PETSC_EXTERN PetscErrorCode SNESCompositeSetType(SNES, SNESCompositeType);
1235 PETSC_EXTERN PetscErrorCode SNESCompositeAddSNES(SNES, SNESType);
1236 PETSC_EXTERN PetscErrorCode SNESCompositeGetSNES(SNES, PetscInt, SNES *);
1237 PETSC_EXTERN PetscErrorCode SNESCompositeGetNumber(SNES, PetscInt *);
1238 PETSC_EXTERN PetscErrorCode SNESCompositeSetDamping(SNES, PetscInt, PetscReal);
1239 
1240 PETSC_EXTERN PetscErrorCode SNESPatchSetDiscretisationInfo(SNES, PetscInt, DM *, PetscInt *, PetscInt *, const PetscInt **, const PetscInt *, PetscInt, const PetscInt *, PetscInt, const PetscInt *);
1241 PETSC_EXTERN PetscErrorCode SNESPatchSetComputeOperator(SNES, PetscErrorCode (*func)(PC, PetscInt, Vec, Mat, IS, PetscInt, const PetscInt *, const PetscInt *, void *), void *);
1242 PETSC_EXTERN PetscErrorCode SNESPatchSetComputeFunction(SNES, PetscErrorCode (*func)(PC, PetscInt, Vec, Vec, IS, PetscInt, const PetscInt *, const PetscInt *, void *), void *);
1243 PETSC_EXTERN PetscErrorCode SNESPatchSetConstructType(SNES, PCPatchConstructType, PetscErrorCode (*func)(PC, PetscInt *, IS **, IS *, void *), void *);
1244 PETSC_EXTERN PetscErrorCode SNESPatchSetCellNumbering(SNES, PetscSection);
1245 
1246 /*E
1247     SNESFASType - Determines the type of nonlinear multigrid method that is run.
1248 
1249    Values:
1250 +  `SNES_FAS_MULTIPLICATIVE` (default) - traditional V or W cycle as determined by `SNESFASSetCycles()`
1251 .  `SNES_FAS_ADDITIVE`                 - additive FAS cycle
1252 .  `SNES_FAS_FULL`                     - full FAS cycle
1253 -  `SNES_FAS_KASKADE`                  - Kaskade FAS cycle
1254 
1255    Level: beginner
1256 
1257 .seealso: [](ch_snes), `SNESFAS`, `PCMGSetType()`, `PCMGType`
1258 E*/
1259 typedef enum {
1260   SNES_FAS_MULTIPLICATIVE,
1261   SNES_FAS_ADDITIVE,
1262   SNES_FAS_FULL,
1263   SNES_FAS_KASKADE
1264 } SNESFASType;
1265 PETSC_EXTERN const char *const SNESFASTypes[];
1266 
1267 /* called on the finest level FAS instance*/
1268 PETSC_EXTERN PetscErrorCode SNESFASSetType(SNES, SNESFASType);
1269 PETSC_EXTERN PetscErrorCode SNESFASGetType(SNES, SNESFASType *);
1270 PETSC_EXTERN PetscErrorCode SNESFASSetLevels(SNES, PetscInt, MPI_Comm *);
1271 PETSC_EXTERN PetscErrorCode SNESFASGetLevels(SNES, PetscInt *);
1272 PETSC_EXTERN PetscErrorCode SNESFASGetCycleSNES(SNES, PetscInt, SNES *);
1273 PETSC_EXTERN PetscErrorCode SNESFASSetNumberSmoothUp(SNES, PetscInt);
1274 PETSC_EXTERN PetscErrorCode SNESFASSetNumberSmoothDown(SNES, PetscInt);
1275 PETSC_EXTERN PetscErrorCode SNESFASSetCycles(SNES, PetscInt);
1276 PETSC_EXTERN PetscErrorCode SNESFASSetMonitor(SNES, PetscViewerAndFormat *, PetscBool);
1277 PETSC_EXTERN PetscErrorCode SNESFASSetLog(SNES, PetscBool);
1278 
1279 PETSC_EXTERN PetscErrorCode SNESFASSetGalerkin(SNES, PetscBool);
1280 PETSC_EXTERN PetscErrorCode SNESFASGetGalerkin(SNES, PetscBool *);
1281 PETSC_EXTERN PetscErrorCode SNESFASGalerkinFunctionDefault(SNES, Vec, Vec, void *);
1282 
1283 /* called on any level -- "Cycle" FAS instance */
1284 PETSC_EXTERN PetscErrorCode SNESFASCycleGetSmoother(SNES, SNES *);
1285 PETSC_EXTERN PetscErrorCode SNESFASCycleGetSmootherUp(SNES, SNES *);
1286 PETSC_EXTERN PetscErrorCode SNESFASCycleGetSmootherDown(SNES, SNES *);
1287 PETSC_EXTERN PetscErrorCode SNESFASCycleGetCorrection(SNES, SNES *);
1288 PETSC_EXTERN PetscErrorCode SNESFASCycleGetInterpolation(SNES, Mat *);
1289 PETSC_EXTERN PetscErrorCode SNESFASCycleGetRestriction(SNES, Mat *);
1290 PETSC_EXTERN PetscErrorCode SNESFASCycleGetInjection(SNES, Mat *);
1291 PETSC_EXTERN PetscErrorCode SNESFASCycleGetRScale(SNES, Vec *);
1292 PETSC_EXTERN PetscErrorCode SNESFASCycleSetCycles(SNES, PetscInt);
1293 PETSC_EXTERN PetscErrorCode SNESFASCycleIsFine(SNES, PetscBool *);
1294 
1295 /* called on the (outer) finest level FAS to set/get parameters on any level instance */
1296 PETSC_EXTERN PetscErrorCode SNESFASSetInterpolation(SNES, PetscInt, Mat);
1297 PETSC_EXTERN PetscErrorCode SNESFASGetInterpolation(SNES, PetscInt, Mat *);
1298 PETSC_EXTERN PetscErrorCode SNESFASSetRestriction(SNES, PetscInt, Mat);
1299 PETSC_EXTERN PetscErrorCode SNESFASGetRestriction(SNES, PetscInt, Mat *);
1300 PETSC_EXTERN PetscErrorCode SNESFASSetInjection(SNES, PetscInt, Mat);
1301 PETSC_EXTERN PetscErrorCode SNESFASGetInjection(SNES, PetscInt, Mat *);
1302 PETSC_EXTERN PetscErrorCode SNESFASSetRScale(SNES, PetscInt, Vec);
1303 PETSC_EXTERN PetscErrorCode SNESFASGetRScale(SNES, PetscInt, Vec *);
1304 PETSC_EXTERN PetscErrorCode SNESFASSetContinuation(SNES, PetscBool);
1305 
1306 PETSC_EXTERN PetscErrorCode SNESFASGetSmoother(SNES, PetscInt, SNES *);
1307 PETSC_EXTERN PetscErrorCode SNESFASGetSmootherUp(SNES, PetscInt, SNES *);
1308 PETSC_EXTERN PetscErrorCode SNESFASGetSmootherDown(SNES, PetscInt, SNES *);
1309 PETSC_EXTERN PetscErrorCode SNESFASGetCoarseSolve(SNES, SNES *);
1310 
1311 /* parameters for full FAS */
1312 PETSC_EXTERN PetscErrorCode SNESFASFullSetDownSweep(SNES, PetscBool);
1313 PETSC_EXTERN PetscErrorCode SNESFASCreateCoarseVec(SNES, Vec *);
1314 PETSC_EXTERN PetscErrorCode SNESFASRestrict(SNES, Vec, Vec);
1315 PETSC_EXTERN PetscErrorCode SNESFASFullSetTotal(SNES, PetscBool);
1316 PETSC_EXTERN PetscErrorCode SNESFASFullGetTotal(SNES, PetscBool *);
1317 
1318 PETSC_EXTERN PetscErrorCode DMPlexSetSNESVariableBounds(DM, SNES);
1319 PETSC_EXTERN PetscErrorCode DMSNESCheckDiscretization(SNES, DM, PetscReal, Vec, PetscReal, PetscReal[]);
1320 PETSC_EXTERN PetscErrorCode DMSNESCheckResidual(SNES, DM, Vec, PetscReal, PetscReal *);
1321 PETSC_EXTERN PetscErrorCode DMSNESCheckJacobian(SNES, DM, Vec, PetscReal, PetscBool *, PetscReal *);
1322 PETSC_EXTERN PetscErrorCode DMSNESCheckFromOptions(SNES, Vec);
1323 PETSC_EXTERN PetscErrorCode DMSNESComputeJacobianAction(DM, Vec, Vec, Vec, void *);
1324 PETSC_EXTERN PetscErrorCode DMSNESCreateJacobianMF(DM, Vec, void *, Mat *);
1325 
1326 PETSC_EXTERN PetscErrorCode SNESNewtonALSetFunction(SNES, SNESFunctionFn *, void *ctx);
1327 PETSC_EXTERN PetscErrorCode SNESNewtonALGetFunction(SNES, SNESFunctionFn **, void **ctx);
1328 PETSC_EXTERN PetscErrorCode SNESNewtonALComputeFunction(SNES, Vec, Vec);
1329 PETSC_EXTERN PetscErrorCode SNESNewtonALGetLoadParameter(SNES, PetscReal *);
1330 
1331 /*MC
1332    SNESNewtonALCorrectionType - the approach used by `SNESNEWTONAL` to determine
1333    the correction to the current increment. While the exact correction satisfies
1334    the constraint surface at every iteration, it also requires solving a quadratic
1335    equation which may not have real roots. Conversely, the normal correction is more
1336    efficient and always yields a real correction and is the default.
1337 
1338    Values:
1339 +   `SNES_NEWTONAL_CORRECTION_EXACT` - choose the correction which exactly satisfies the constraint
1340 -   `SNES_NEWTONAL_CORRECTION_NORMAL` - choose the correction in the updated normal hyper-surface to the constraint surface
1341 
1342    Options Database Key:
1343 . -snes_newtonal_correction_type <exact> - select type from <exact,normal>
1344 
1345    Level: intermediate
1346 
1347 .seealso: `SNES`, `SNESNEWTONAL`, `SNESNewtonALSetCorrectionType()`
1348 M*/
1349 typedef enum {
1350   SNES_NEWTONAL_CORRECTION_EXACT  = 0,
1351   SNES_NEWTONAL_CORRECTION_NORMAL = 1,
1352 } SNESNewtonALCorrectionType;
1353 PETSC_EXTERN const char *const SNESNewtonALCorrectionTypes[];
1354 
1355 PETSC_EXTERN PetscErrorCode SNESNewtonALSetCorrectionType(SNES, SNESNewtonALCorrectionType);
1356