xref: /petsc/include/petscsnes.h (revision b17ce1af89b448f824bb09659a9de6779534cd8e)
1 /*
2     User interface for the nonlinear solvers package.
3 */
4 #if !defined(__PETSCSNES_H)
5 #define __PETSCSNES_H
6 #include "petscksp.h"
7 PETSC_EXTERN_CXX_BEGIN
8 
9 /*S
10      SNES - Abstract PETSc object that manages all nonlinear solves
11 
12    Level: beginner
13 
14   Concepts: nonlinear solvers
15 
16 .seealso:  SNESCreate(), SNESSetType(), SNESType, TS, KSP, KSP, PC
17 S*/
18 typedef struct _p_SNES* SNES;
19 
20 /*J
21     SNESType - String with the name of a PETSc SNES method or the creation function
22        with an optional dynamic library name, for example
23        http://www.mcs.anl.gov/petsc/lib.a:mysnescreate()
24 
25    Level: beginner
26 
27 .seealso: SNESSetType(), SNES
28 J*/
29 #define SNESType char*
30 #define SNESLS           "ls"
31 #define SNESTR           "tr"
32 #define SNESPYTHON       "python"
33 #define SNESTEST         "test"
34 #define SNESNRICHARDSON  "nrichardson"
35 #define SNESKSPONLY      "ksponly"
36 #define SNESVIRS         "virs"
37 #define SNESVISS         "viss"
38 #define SNESNGMRES       "ngmres"
39 #define SNESQN           "qn"
40 #define SNESSHELL        "shell"
41 #define SNESGS           "gs"
42 #define SNESNCG          "ncg"
43 #define SNESSORQN        "sorqn"
44 #define SNESFAS          "fas"
45 #define SNESMS           "ms"
46 
47 /* Logging support */
48 extern PetscClassId  SNES_CLASSID;
49 
50 extern PetscErrorCode  SNESInitializePackage(const char[]);
51 
52 extern PetscErrorCode  SNESCreate(MPI_Comm,SNES*);
53 extern PetscErrorCode  SNESReset(SNES);
54 extern PetscErrorCode  SNESDestroy(SNES*);
55 extern PetscErrorCode  SNESSetType(SNES,const SNESType);
56 extern PetscErrorCode  SNESMonitor(SNES,PetscInt,PetscReal);
57 extern PetscErrorCode  SNESMonitorSet(SNES,PetscErrorCode(*)(SNES,PetscInt,PetscReal,void*),void *,PetscErrorCode (*)(void**));
58 extern PetscErrorCode  SNESMonitorCancel(SNES);
59 extern PetscErrorCode  SNESSetConvergenceHistory(SNES,PetscReal[],PetscInt[],PetscInt,PetscBool );
60 extern PetscErrorCode  SNESGetConvergenceHistory(SNES,PetscReal*[],PetscInt *[],PetscInt *);
61 extern PetscErrorCode  SNESSetUp(SNES);
62 extern PetscErrorCode  SNESSolve(SNES,Vec,Vec);
63 extern PetscErrorCode  SNESSetErrorIfNotConverged(SNES,PetscBool );
64 extern PetscErrorCode  SNESGetErrorIfNotConverged(SNES,PetscBool  *);
65 
66 
67 extern PetscErrorCode  SNESAddOptionsChecker(PetscErrorCode (*)(SNES));
68 
69 extern PetscErrorCode  SNESSetUpdate(SNES, PetscErrorCode (*)(SNES, PetscInt));
70 extern PetscErrorCode  SNESDefaultUpdate(SNES, PetscInt);
71 
72 extern PetscFList SNESList;
73 extern PetscErrorCode  SNESRegisterDestroy(void);
74 extern PetscErrorCode  SNESRegisterAll(const char[]);
75 
76 extern PetscErrorCode  SNESRegister(const char[],const char[],const char[],PetscErrorCode (*)(SNES));
77 
78 /*MC
79    SNESRegisterDynamic - Adds a method to the nonlinear solver package.
80 
81    Synopsis:
82    PetscErrorCode SNESRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(SNES))
83 
84    Not collective
85 
86    Input Parameters:
87 +  name_solver - name of a new user-defined solver
88 .  path - path (either absolute or relative) the library containing this solver
89 .  name_create - name of routine to create method context
90 -  routine_create - routine to create method context
91 
92    Notes:
93    SNESRegisterDynamic() may be called multiple times to add several user-defined solvers.
94 
95    If dynamic libraries are used, then the fourth input argument (routine_create)
96    is ignored.
97 
98    Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
99    and others of the form ${any_environmental_variable} occuring in pathname will be
100    replaced with appropriate values.
101 
102    Sample usage:
103 .vb
104    SNESRegisterDynamic("my_solver",/home/username/my_lib/lib/libg/solaris/mylib.a,
105                 "MySolverCreate",MySolverCreate);
106 .ve
107 
108    Then, your solver can be chosen with the procedural interface via
109 $     SNESSetType(snes,"my_solver")
110    or at runtime via the option
111 $     -snes_type my_solver
112 
113    Level: advanced
114 
115     Note: If your function is not being put into a shared library then use SNESRegister() instead
116 
117 .keywords: SNES, nonlinear, register
118 
119 .seealso: SNESRegisterAll(), SNESRegisterDestroy()
120 M*/
121 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
122 #define SNESRegisterDynamic(a,b,c,d) SNESRegister(a,b,c,0)
123 #else
124 #define SNESRegisterDynamic(a,b,c,d) SNESRegister(a,b,c,d)
125 #endif
126 
127 extern PetscErrorCode  SNESGetKSP(SNES,KSP*);
128 extern PetscErrorCode  SNESSetKSP(SNES,KSP);
129 extern PetscErrorCode  SNESGetSolution(SNES,Vec*);
130 extern PetscErrorCode  SNESGetSolutionUpdate(SNES,Vec*);
131 extern PetscErrorCode  SNESGetRhs(SNES,Vec*);
132 extern PetscErrorCode  SNESView(SNES,PetscViewer);
133 
134 extern PetscErrorCode  SNESSetOptionsPrefix(SNES,const char[]);
135 extern PetscErrorCode  SNESAppendOptionsPrefix(SNES,const char[]);
136 extern PetscErrorCode  SNESGetOptionsPrefix(SNES,const char*[]);
137 extern PetscErrorCode  SNESSetFromOptions(SNES);
138 extern PetscErrorCode  SNESDefaultGetWork(SNES,PetscInt);
139 
140 extern PetscErrorCode  MatCreateSNESMF(SNES,Mat*);
141 extern PetscErrorCode  MatMFFDComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
142 
143 extern PetscErrorCode  MatDAADSetSNES(Mat,SNES);
144 
145 extern PetscErrorCode  SNESGetType(SNES,const SNESType*);
146 extern PetscErrorCode  SNESMonitorDefault(SNES,PetscInt,PetscReal,void *);
147 extern PetscErrorCode  SNESMonitorRange(SNES,PetscInt,PetscReal,void *);
148 extern PetscErrorCode  SNESMonitorRatio(SNES,PetscInt,PetscReal,void *);
149 extern PetscErrorCode  SNESMonitorSetRatio(SNES,PetscViewer);
150 extern PetscErrorCode  SNESMonitorSolution(SNES,PetscInt,PetscReal,void *);
151 extern PetscErrorCode  SNESMonitorResidual(SNES,PetscInt,PetscReal,void *);
152 extern PetscErrorCode  SNESMonitorSolutionUpdate(SNES,PetscInt,PetscReal,void *);
153 extern PetscErrorCode  SNESMonitorDefaultShort(SNES,PetscInt,PetscReal,void *);
154 extern PetscErrorCode  SNESSetTolerances(SNES,PetscReal,PetscReal,PetscReal,PetscInt,PetscInt);
155 extern PetscErrorCode  SNESGetTolerances(SNES,PetscReal*,PetscReal*,PetscReal*,PetscInt*,PetscInt*);
156 extern PetscErrorCode  SNESSetTrustRegionTolerance(SNES,PetscReal);
157 extern PetscErrorCode  SNESGetFunctionNorm(SNES,PetscReal*);
158 extern PetscErrorCode  SNESGetIterationNumber(SNES,PetscInt*);
159 
160 extern PetscErrorCode  SNESGetNonlinearStepFailures(SNES,PetscInt*);
161 extern PetscErrorCode  SNESSetMaxNonlinearStepFailures(SNES,PetscInt);
162 extern PetscErrorCode  SNESGetMaxNonlinearStepFailures(SNES,PetscInt*);
163 extern PetscErrorCode  SNESGetNumberFunctionEvals(SNES,PetscInt*);
164 
165 extern PetscErrorCode  SNESSetLagPreconditioner(SNES,PetscInt);
166 extern PetscErrorCode  SNESGetLagPreconditioner(SNES,PetscInt*);
167 extern PetscErrorCode  SNESSetLagJacobian(SNES,PetscInt);
168 extern PetscErrorCode  SNESGetLagJacobian(SNES,PetscInt*);
169 extern PetscErrorCode  SNESSetGridSequence(SNES,PetscInt);
170 
171 extern PetscErrorCode  SNESGetLinearSolveIterations(SNES,PetscInt*);
172 extern PetscErrorCode  SNESGetLinearSolveFailures(SNES,PetscInt*);
173 extern PetscErrorCode  SNESSetMaxLinearSolveFailures(SNES,PetscInt);
174 extern PetscErrorCode  SNESGetMaxLinearSolveFailures(SNES,PetscInt*);
175 
176 extern PetscErrorCode  SNESKSPSetUseEW(SNES,PetscBool );
177 extern PetscErrorCode  SNESKSPGetUseEW(SNES,PetscBool *);
178 extern PetscErrorCode  SNESKSPSetParametersEW(SNES,PetscInt,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
179 extern PetscErrorCode  SNESKSPGetParametersEW(SNES,PetscInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
180 
181 extern PetscErrorCode  SNESMonitorLGCreate(const char[],const char[],int,int,int,int,PetscDrawLG*);
182 extern PetscErrorCode  SNESMonitorLG(SNES,PetscInt,PetscReal,void*);
183 extern PetscErrorCode  SNESMonitorLGDestroy(PetscDrawLG*);
184 extern PetscErrorCode  SNESMonitorLGRangeCreate(const char[],const char[],int,int,int,int,PetscDrawLG*);
185 extern PetscErrorCode  SNESMonitorLGRange(SNES,PetscInt,PetscReal,void*);
186 extern PetscErrorCode  SNESMonitorLGRangeDestroy(PetscDrawLG*);
187 
188 extern PetscErrorCode  SNESSetApplicationContext(SNES,void *);
189 extern PetscErrorCode  SNESGetApplicationContext(SNES,void *);
190 extern PetscErrorCode  SNESSetComputeApplicationContext(SNES,PetscErrorCode (*)(SNES,void**),PetscErrorCode (*)(void**));
191 
192 extern PetscErrorCode  SNESPythonSetType(SNES,const char[]);
193 
194 extern PetscErrorCode  SNESSetFunctionDomainError(SNES);
195 /*E
196     SNESConvergedReason - reason a SNES method was said to
197          have converged or diverged
198 
199    Level: beginner
200 
201    The two most common reasons for divergence are
202 $   1) an incorrectly coded or computed Jacobian or
203 $   2) failure or lack of convergence in the linear system (in this case we recommend
204 $      testing with -pc_type lu to eliminate the linear solver as the cause of the problem).
205 
206    Diverged Reasons:
207 .    SNES_DIVERGED_LOCAL_MIN - this can only occur when using the line-search variant of SNES.
208        The line search wants to minimize Q(alpha) = 1/2 || F(x + alpha s) ||^2_2  this occurs
209        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
210        you get Q'(alpha) = -F(x)^T F'(x)^(-1)^T F'(x+alpha s)F(x+alpha s); when alpha = 0
211        Q'(0) = - ||F(x)||^2_2 which is always NEGATIVE if F'(x) is invertible. This means the Newton
212        direction is a descent direction and the line search should succeed if alpha is small enough.
213 
214        If F'(x) is NOT invertible AND F'(x)^T F(x) = 0 then Q'(0) = 0 and the Newton direction
215        is NOT a descent direction so the line search will fail. All one can do at this point
216        is change the initial guess and try again.
217 
218        An alternative explanation: Newton's method can be regarded as replacing the function with
219        its linear approximation and minimizing the 2-norm of that. That is F(x+s) approx F(x) + F'(x)s
220        so we minimize || F(x) + F'(x) s ||^2_2; do this using Least Squares. If F'(x) is invertible then
221        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
222        exists a nontrival (that is F'(x)s != 0) solution to the equation and this direction is
223        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)
224        = - (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
225        and F'(x)^T F'(x) has no negative eigenvalues Q'(0) < 0 so s is a descent direction and the line
226        search should succeed for small enough alpha.
227 
228        Note that this RARELY happens in practice. Far more likely the linear system is not being solved
229        (well enough?) or the Jacobian is wrong.
230 
231    SNES_DIVERGED_MAX_IT means that the solver reached the maximum number of iterations without satisfying any
232    convergence criteria. SNES_CONVERGED_ITS means that SNESSkipConverged() was chosen as the convergence test;
233    thus the usual convergence criteria have not been checked and may or may not be satisfied.
234 
235    Developer Notes: this must match finclude/petscsnes.h
236 
237        The string versions of these are in SNESConvergedReason, if you change any value here you must
238      also adjust that array.
239 
240    Each reason has its own manual page.
241 
242 .seealso: SNESSolve(), SNESGetConvergedReason(), KSPConvergedReason, SNESSetConvergenceTest()
243 E*/
244 typedef enum {/* converged */
245               SNES_CONVERGED_FNORM_ABS         =  2, /* ||F|| < atol */
246               SNES_CONVERGED_FNORM_RELATIVE    =  3, /* ||F|| < rtol*||F_initial|| */
247               SNES_CONVERGED_PNORM_RELATIVE    =  4, /* Newton computed step size small; || delta x || < stol */
248               SNES_CONVERGED_ITS               =  5, /* maximum iterations reached */
249               SNES_CONVERGED_TR_DELTA          =  7,
250               /* diverged */
251               SNES_DIVERGED_FUNCTION_DOMAIN     = -1, /* the new x location passed the function is not in the domain of F */
252               SNES_DIVERGED_FUNCTION_COUNT      = -2,
253               SNES_DIVERGED_LINEAR_SOLVE        = -3, /* the linear solve failed */
254               SNES_DIVERGED_FNORM_NAN           = -4,
255               SNES_DIVERGED_MAX_IT              = -5,
256               SNES_DIVERGED_LINE_SEARCH         = -6, /* the line search failed */
257               SNES_DIVERGED_INNER               = -7, /* inner solve failed */
258               SNES_DIVERGED_LOCAL_MIN           = -8, /* || J^T b || is small, implies converged to local minimum of F() */
259               SNES_CONVERGED_ITERATING          =  0} SNESConvergedReason;
260 extern const char *const*SNESConvergedReasons;
261 
262 /*MC
263      SNES_CONVERGED_FNORM_ABS - 2-norm(F) <= abstol
264 
265    Level: beginner
266 
267 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
268 
269 M*/
270 
271 /*MC
272      SNES_CONVERGED_FNORM_RELATIVE - 2-norm(F) <= rtol*2-norm(F(x_0)) where x_0 is the initial guess
273 
274    Level: beginner
275 
276 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
277 
278 M*/
279 
280 /*MC
281      SNES_CONVERGED_PNORM_RELATIVE - The 2-norm of the last step <= stol * 2-norm(x) where x is the current
282           solution and stol is the 4th argument to SNESSetTolerances()
283 
284    Level: beginner
285 
286 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
287 
288 M*/
289 
290 /*MC
291      SNES_DIVERGED_FUNCTION_COUNT - The user provided function has been called more times then the final
292          argument to SNESSetTolerances()
293 
294    Level: beginner
295 
296 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
297 
298 M*/
299 
300 /*MC
301      SNES_DIVERGED_FNORM_NAN - the 2-norm of the current function evaluation is not-a-number (NaN), this
302       is usually caused by a division of 0 by 0.
303 
304    Level: beginner
305 
306 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
307 
308 M*/
309 
310 /*MC
311      SNES_DIVERGED_MAX_IT - SNESSolve() has reached the maximum number of iterations requested
312 
313    Level: beginner
314 
315 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
316 
317 M*/
318 
319 /*MC
320      SNES_DIVERGED_LINE_SEARCH - The line search has failed. This only occurs for a SNESType of SNESLS
321 
322    Level: beginner
323 
324 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
325 
326 M*/
327 
328 /*MC
329      SNES_DIVERGED_LOCAL_MIN - the algorithm seems to have stagnated at a local minimum that is not zero.
330         See the manual page for SNESConvergedReason for more details
331 
332    Level: beginner
333 
334 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
335 
336 M*/
337 
338 /*MC
339      SNES_CONERGED_ITERATING - this only occurs if SNESGetConvergedReason() is called during the SNESSolve()
340 
341    Level: beginner
342 
343 .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
344 
345 M*/
346 
347 extern PetscErrorCode  SNESSetConvergenceTest(SNES,PetscErrorCode (*)(SNES,PetscInt,PetscReal,PetscReal,PetscReal,SNESConvergedReason*,void*),void*,PetscErrorCode (*)(void*));
348 extern PetscErrorCode  SNESDefaultConverged(SNES,PetscInt,PetscReal,PetscReal,PetscReal,SNESConvergedReason*,void*);
349 extern PetscErrorCode  SNESSkipConverged(SNES,PetscInt,PetscReal,PetscReal,PetscReal,SNESConvergedReason*,void*);
350 extern PetscErrorCode  SNESGetConvergedReason(SNES,SNESConvergedReason*);
351 
352 extern PetscErrorCode  SNESDMDAComputeFunction(SNES,Vec,Vec,void*);
353 extern PetscErrorCode  SNESDMDAComputeJacobianWithAdic(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
354 extern PetscErrorCode  SNESDMDAComputeJacobianWithAdifor(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
355 extern PetscErrorCode  SNESDMDAComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
356 
357 extern PetscErrorCode SNESDMMeshComputeFunction(SNES,Vec,Vec,void*);
358 extern PetscErrorCode SNESDMMeshComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
359 extern PetscErrorCode SNESDMComplexComputeFunction(SNES,Vec,Vec,void *);
360 extern PetscErrorCode SNESDMComplexComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
361 
362 /* --------- Solving systems of nonlinear equations --------------- */
363 typedef PetscErrorCode (*SNESFunction)(SNES,Vec,Vec,void*);
364 typedef PetscErrorCode (*SNESJacobian)(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
365 typedef PetscErrorCode (*SNESGSFunction)(SNES,Vec,Vec,void*);
366 extern PetscErrorCode  SNESSetFunction(SNES,Vec,SNESFunction,void*);
367 extern PetscErrorCode  SNESGetFunction(SNES,Vec*,SNESFunction*,void**);
368 extern PetscErrorCode  SNESComputeFunction(SNES,Vec,Vec);
369 extern PetscErrorCode  SNESSetJacobian(SNES,Mat,Mat,SNESJacobian,void*);
370 extern PetscErrorCode  SNESGetJacobian(SNES,Mat*,Mat*,SNESJacobian*,void**);
371 extern PetscErrorCode  SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
372 extern PetscErrorCode  SNESDefaultComputeJacobianColor(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
373 extern PetscErrorCode  SNESSetComputeInitialGuess(SNES,PetscErrorCode (*)(SNES,Vec,void*),void*);
374 extern PetscErrorCode  SNESSetPicard(SNES,Vec,SNESFunction,Mat,Mat,SNESJacobian,void*);
375 extern PetscErrorCode  SNESGetPicard(SNES,Vec*,SNESFunction*,Mat*,SNESJacobian*,void**);
376 
377 extern PetscErrorCode  SNESSetGS(SNES,SNESGSFunction,void*);
378 extern PetscErrorCode  SNESGetGS(SNES,SNESGSFunction*,void**);
379 extern PetscErrorCode  SNESSetUseGS(SNES,PetscBool);
380 extern PetscErrorCode  SNESGetUseGS(SNES,PetscBool *);
381 extern PetscErrorCode  SNESSetGSSweeps(SNES,PetscInt);
382 extern PetscErrorCode  SNESGetGSSweeps(SNES,PetscInt *);
383 extern PetscErrorCode  SNESComputeGS(SNES,Vec,Vec);
384 
385 /* --------- Routines specifically for line search methods --------------- */
386 /*E
387     SNESLineSearchType - type of line search used in Newton's method as well as VI solvers and Richardson solvers
388 
389     Level: beginner
390 
391 .seealso: SNESSetFromOptions(), SNESLineSearchSet()
392 E*/
393 typedef enum {SNES_LS_BASIC, SNES_LS_BASIC_NONORMS, SNES_LS_QUADRATIC, SNES_LS_CUBIC, SNES_LS_EXACT, SNES_LS_TEST, SNES_LS_SECANT,SNES_LS_USER_DEFINED} SNESLineSearchType;
394 extern const char *const SNESLineSearchTypes[];
395 extern const char *SNESLineSearchTypeName(SNESLineSearchType); /* Does bounds checking, use this for viewing */
396 
397 extern PetscErrorCode  SNESLineSearchSet(SNES,PetscErrorCode(*)(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *),void*);
398 extern PetscErrorCode  SNESLineSearchSetType(SNES,SNESLineSearchType);
399 extern PetscErrorCode  SNESLineSearchNo(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *);
400 extern PetscErrorCode  SNESLineSearchNoNorms(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *);
401 extern PetscErrorCode  SNESLineSearchQuadratic(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *);
402 extern PetscErrorCode  SNESLineSearchCubic(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *);
403 extern PetscErrorCode  SNESLineSearchSecant(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *);
404 extern PetscErrorCode  SNESLineSearchQuadraticSecant(SNES,void*,Vec,Vec,Vec,PetscReal,PetscReal,Vec,Vec,PetscReal*,PetscReal*,PetscBool *);
405 
406 extern PetscErrorCode  SNESLineSearchSetPostCheck(SNES,PetscErrorCode(*)(SNES,Vec,Vec,Vec,void*,PetscBool *,PetscBool *),void*);
407 extern PetscErrorCode  SNESLineSearchSetPreCheck(SNES,PetscErrorCode(*)(SNES,Vec,Vec,void*,PetscBool *),void*);
408 extern PetscErrorCode  SNESLineSearchPreCheckPicard(SNES,Vec,Vec,void*,PetscBool*);
409 extern PetscErrorCode  SNESLineSearchSetParams(SNES,PetscReal,PetscReal,PetscReal);
410 extern PetscErrorCode  SNESLineSearchGetParams(SNES,PetscReal*,PetscReal*,PetscReal*);
411 extern PetscErrorCode  SNESLineSearchSetMonitor(SNES,PetscBool );
412 
413 extern PetscErrorCode  SNESShellGetContext(SNES,void**);
414 extern PetscErrorCode  SNESShellSetContext(SNES,void*);
415 extern PetscErrorCode  SNESShellSetSolve(SNES,PetscErrorCode (*)(SNES,Vec));
416 
417 /* Routines for VI solver */
418 extern PetscErrorCode  SNESVISetVariableBounds(SNES,Vec,Vec);
419 extern PetscErrorCode  SNESVISetComputeVariableBounds(SNES, PetscErrorCode (*)(SNES,Vec,Vec));
420 extern PetscErrorCode  SNESVIGetInactiveSet(SNES,IS*);
421 extern PetscErrorCode  SNESVIGetActiveSetIS(SNES,Vec,Vec,IS*);
422 extern PetscErrorCode  SNESVIComputeInactiveSetFnorm(SNES,Vec,Vec,PetscReal*);
423 extern PetscErrorCode  SNESVISetRedundancyCheck(SNES,PetscErrorCode(*)(SNES,IS,IS*,void*),void*);
424 #define SNES_VI_INF   1.0e20
425 #define SNES_VI_NINF -1.0e20
426 
427 extern PetscErrorCode  SNESTestLocalMin(SNES);
428 
429 /* Should this routine be private? */
430 extern PetscErrorCode  SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
431 
432 extern PetscErrorCode SNESSetDM(SNES,DM);
433 extern PetscErrorCode SNESGetDM(SNES,DM*);
434 extern PetscErrorCode SNESSetPC(SNES,SNES);
435 extern PetscErrorCode SNESGetPC(SNES,SNES*);
436 extern PetscErrorCode SNESRestrictHookAdd(SNES,PetscErrorCode (*)(SNES,SNES,void*),void*);
437 extern PetscErrorCode SNESRestrictHooksRun(SNES,SNES);
438 
439 /* Routines for Multiblock solver */
440 extern PetscErrorCode SNESMultiblockSetFields(SNES, const char [], PetscInt, const PetscInt *);
441 extern PetscErrorCode SNESMultiblockSetIS(SNES, const char [], IS);
442 extern PetscErrorCode SNESMultiblockSetBlockSize(SNES, PetscInt);
443 extern PetscErrorCode SNESMultiblockSetType(SNES, PCCompositeType);
444 
445 /*J
446     SNESMSType - String with the name of a PETSc SNESMS method.
447 
448    Level: intermediate
449 
450 .seealso: SNESMSSetType(), SNES
451 J*/
452 #define SNESMSType char*
453 #define SNESMSM62       "m62"
454 #define SNESMSEULER     "euler"
455 #define SNESMSJAMESON83 "jameson83"
456 #define SNESMSVLTP21    "vltp21"
457 #define SNESMSVLTP31    "vltp31"
458 #define SNESMSVLTP41    "vltp41"
459 #define SNESMSVLTP51    "vltp51"
460 #define SNESMSVLTP61    "vltp61"
461 
462 extern PetscErrorCode SNESMSRegister(const SNESMSType,PetscInt,PetscInt,PetscReal,const PetscReal[],const PetscReal[],const PetscReal[]);
463 extern PetscErrorCode SNESMSSetType(SNES,const SNESMSType);
464 extern PetscErrorCode SNESMSFinalizePackage(void);
465 extern PetscErrorCode SNESMSInitializePackage(const char path[]);
466 extern PetscErrorCode SNESMSRegisterDestroy(void);
467 extern PetscErrorCode SNESMSRegisterAll(void);
468 
469 PETSC_EXTERN_CXX_END
470 #endif
471