xref: /petsc/include/petscsnes.h (revision 3f1db9ec2fd39765c6c3a00831044586630c4cca)
1 /* $Id: snes.h,v 1.77 1998/11/09 20:16:33 bsmith Exp bsmith $ */
2 /*
3     User interface for the nonlinear solvers and unconstrained minimization package.
4 */
5 #if !defined(__SNES_H)
6 #define __SNES_H
7 #include "sles.h"
8 
9 typedef struct _p_SNES* SNES;
10 #define SNES_COOKIE PETSC_COOKIE+13
11 
12 #define SNES_EQ_LS          "ls"
13 #define SNES_EQ_TR          "tr"
14 #define SNES_EQ_TR_DOG_LEG
15 #define SNES_EQ_TR2_LIN
16 #define SNES_EQ_TEST        "test"
17 #define SNES_UM_LS          "umls"
18 #define SNES_UM_TR          "umtr"
19 
20 typedef char *SNESType;
21 
22 typedef enum {SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION, SNES_LEAST_SQUARES} SNESProblemType;
23 
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 SNESClearMonitor(SNES);
29 extern int SNESSetConvergenceHistory(SNES,double*,int);
30 extern int SNESSetUp(SNES,Vec);
31 extern int SNESSolve(SNES,Vec,int*);
32 
33 extern FList SNESList;
34 extern int SNESRegisterDestroy(void);
35 extern int SNESRegisterAll(char *);
36 
37 extern int SNESRegister_Private(char*,char*,char*,int(*)(SNES));
38 #if defined(USE_DYNAMIC_LIBRARIES)
39 #define SNESRegister(a,b,c,d) SNESRegister_Private(a,b,c,0)
40 #else
41 #define SNESRegister(a,b,c,d) SNESRegister_Private(a,b,c,d)
42 #endif
43 
44 extern int SNESGetSLES(SNES,SLES*);
45 extern int SNESGetSolution(SNES,Vec*);
46 extern int SNESGetSolutionUpdate(SNES,Vec*);
47 extern int SNESGetFunction(SNES,Vec*);
48 extern int SNESPrintHelp(SNES);
49 extern int SNESView(SNES,Viewer);
50 
51 extern int SNESSetOptionsPrefix(SNES,char*);
52 extern int SNESAppendOptionsPrefix(SNES,char*);
53 extern int SNESGetOptionsPrefix(SNES,char**);
54 extern int SNESSetFromOptions(SNES);
55 extern int SNESAddOptionsChecker(int (*)(SNES));
56 
57 extern int MatCreateSNESFDMF(SNES,Vec x,Mat*);
58 extern int MatSNESFDMFAddNullSpace(Mat,int,int,Vec *);
59 extern int MatSNESFDMFSetHHistory(Mat,Scalar *,int);
60 extern int MatSNESFDMFResetHHistory(Mat);
61 extern int MatSNESFDMFSetFunctionError(Mat,double);
62 extern int MatSNESFDMFGetH(Mat,Scalar *);
63 extern int MatSNESFDMFKSPMonitor(KSP,int,double,void *);
64 extern int MatSNESFDMFSetFromOptions(Mat);
65 typedef struct _p_MatSNESFDMFCtx   *MatSNESFDMFCtx;
66 extern int MatSNESFDMFSetType(Mat,char*);
67 extern int MatSNESFDMFRegister_Private(char *,char *,char *,int (*)(MatSNESFDMFCtx));
68 #if defined(USE_DYNAMIC_LIBRARIES)
69 #define MatSNESFDMFRegister(a,b,c,d) MatSNESFDMFRegister_Private(a,b,c,0)
70 #else
71 #define MatSNESFDMFRegister(a,b,c,d) MatSNESFDMFRegister_Private(a,b,c,d)
72 #endif
73 extern int MatSNESFDMFRegisterAll(char *);
74 extern int MatSNESFDMFRegisterDestroy(void);
75 extern int MatSNESFDMFDefaultSetUmin(Mat,double);
76 extern int MatSNESFDMFWPSetComputeNormA(Mat,PetscTruth);
77 extern int MatSNESFDMFWPSetComputeNormU(Mat,PetscTruth);
78 
79 extern int SNESGetType(SNES,SNESType*);
80 extern int SNESDefaultMonitor(SNES,int,double,void *);
81 extern int SNESVecViewMonitor(SNES,int,double,void *);
82 extern int SNESDefaultSMonitor(SNES,int,double,void *);
83 extern int SNESSetTolerances(SNES,double,double,double,int,int);
84 extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*);
85 extern int SNESSetTrustRegionTolerance(SNES,double);
86 extern int SNESGetIterationNumber(SNES,int*);
87 extern int SNESGetFunctionNorm(SNES,Scalar*);
88 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
89 extern int SNESGetNumberLinearIterations(SNES,int*);
90 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
91 extern int SNES_KSP_SetConvergenceTestEW(SNES);
92 
93 /*
94      Reuse the default KSP monitor routines for SNES
95 */
96 #define SNESLGMonitorCreate  KSPLGMonitorCreate
97 #define SNESLGMonitorDestroy KSPLGMonitorDestroy
98 #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
99 
100 extern int SNESSetApplicationContext(SNES,void *);
101 extern int SNESGetApplicationContext(SNES,void **);
102 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*);
103 
104 /* --------- Solving systems of nonlinear equations --------------- */
105 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *);
106 extern int SNESComputeFunction(SNES,Vec,Vec);
107 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
108 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **);
109 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
110 extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
111 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*);
112 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*);
113 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
114 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
115 extern int SNESNoLineSearchNoNorms(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
116 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
117 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
118 
119 /* --------- Unconstrained minimization routines --------------------------------*/
120 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
121 extern int SNESGetHessian(SNES,Mat*,Mat*,void **);
122 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
123 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
124 extern int SNESGetGradient(SNES,Vec*);
125 extern int SNESGetGradientNorm(SNES,Scalar*);
126 extern int SNESComputeGradient(SNES,Vec,Vec);
127 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
128 extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
129 extern int SNESGetMinimizationFunction(SNES,double*);
130 extern int SNESSetMinimizationFunctionTolerance(SNES,double);
131 extern int SNESLineSearchSetDampingParameter(SNES,Scalar*);
132 extern int SNESConverged_UM_LS(SNES,double,double,double,void*);
133 extern int SNESConverged_UM_TR(SNES,double,double,double,void*);
134 
135 
136 /* Should these 2 routines be private? */
137 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*);
138 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
139 
140 #endif
141 
142