xref: /petsc/include/petscsnes.h (revision fae171e0928a68051052473fbd80ecaec6ec1e7e)
1 /* $Id: snes.h,v 1.49 1996/03/23 23:11:00 curfman Exp curfman $ */
2 /*
3     User interface for the nonlinear solvers package.
4 */
5 #if !defined(__SNES_PACKAGE)
6 #define __SNES_PACKAGE
7 #include "sles.h"
8 
9 typedef struct _SNES* SNES;
10 #define SNES_COOKIE PETSC_COOKIE+13
11 
12 typedef enum { SNES_UNKNOWN_METHOD=-1,
13                SNES_EQ_LS,
14                SNES_EQ_TR,
15                SNES_EQ_TR_DOG_LEG,
16                SNES_EQ_TR2_LIN,
17                SNES_EQ_TEST,
18                SNES_UM_LS,
19                SNES_UM_TR
20 } SNESType;
21 
22 typedef enum { SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION}
23               SNESProblemType;
24 extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*);
25 extern int SNESDestroy(SNES);
26 extern int SNESSetType(SNES,SNESType);
27 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *);
28 extern int SNESSetUp(SNES,Vec);
29 extern int SNESSolve(SNES,Vec,int*);
30 extern int SNESRegister(int,char*,int(*)(SNES));
31 extern int SNESRegisterDestroy();
32 extern int SNESRegisterAll();
33 extern int SNESGetSLES(SNES,SLES*);
34 extern int SNESGetSolution(SNES,Vec*);
35 extern int SNESGetSolutionUpdate(SNES,Vec*);
36 extern int SNESGetFunction(SNES,Vec*);
37 extern int SNESPrintHelp(SNES);
38 extern int SNESView(SNES,Viewer);
39 
40 extern int SNESSetOptionsPrefix(SNES,char*);
41 extern int SNESAppendOptionsPrefix(SNES,char*);
42 extern int SNESGetOptionsPrefix(SNES,char**);
43 extern int SNESSetFromOptions(SNES);
44 
45 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*);
46 extern int SNESGetType(SNES,SNESType*,char**);
47 extern int SNESDefaultMonitor(SNES,int,double,void *);
48 extern int SNESDefaultSMonitor(SNES,int,double,void *);
49 extern int SNESSetTolerances(SNES,double,double,double,int,int);
50 extern int SNESSetTrustRegionTolerance(SNES,double);
51 extern int SNESGetIterationNumber(SNES,int*);
52 extern int SNESGetFunctionNorm(SNES,Scalar*);
53 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
54 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
55 extern int SNES_KSP_SetConvergenceTestEW(SNES);
56 
57 #if defined(__DRAW_PACKAGE)
58 #define SNESLGMonitorCreate  KSPLGMonitorCreate
59 #define SNESLGMonitorDestroy KSPLGMonitorDestroy
60 #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
61 #endif
62 
63 extern int SNESSetApplicationContext(SNES,void *);
64 extern int SNESGetApplicationContext(SNES,void **);
65 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*);
66 
67 /* Routines for solving systems of nonlinear equations */
68 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *);
69 extern int SNESComputeFunction(SNES,Vec,Vec);
70 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
71 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **);
72 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
73 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*);
74 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*);
75 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
76 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
77 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
78 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
79 
80 /* Unconstrained minimization routines */
81 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
82 extern int SNESGetHessian(SNES,Mat*,Mat*,void **);
83 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
84 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
85 extern int SNESGetGradient(SNES,Vec*);
86 extern int SNESGetGradientNorm(SNES,Scalar*);
87 extern int SNESComputeGradient(SNES,Vec,Vec);
88 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
89 extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
90 extern int SNESGetMinimizationFunction(SNES,double*);
91 extern int SNESSetMinimizationFunctionTolerance(SNES,double);
92 extern int SNESGetLineSearchDampingParameter(SNES,Scalar*);
93 extern int SNESConverged_UM_LS(SNES,double,double,double,void*);
94 extern int SNESConverged_UM_TR(SNES,double,double,double,void*);
95 
96 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *);
97 
98 /* Should these 2 routines be private? */
99 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*);
100 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
101 
102 #endif
103 
104