xref: /petsc/include/petscsnes.h (revision b2002411cd4bf8262b8aeca5b64ca630feca1e56)
1 /* $Id: snes.h,v 1.67 1998/04/20 16:51:06 curfman Exp curfman $ */
2 /*
3     User interface for the nonlinear solvers and unconstrained minimization package.
4 */
5 #if !defined(__SNES_PACKAGE)
6 #define __SNES_PACKAGE
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 #define SNES_LS_LM          "lslm"
20 
21 typedef char *SNESType;
22 
23 typedef enum {SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION, SNES_LEAST_SQUARES} SNESProblemType;
24 
25 extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*);
26 extern int SNESDestroy(SNES);
27 extern int SNESSetType(SNES,SNESType);
28 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *);
29 extern int SNESClearMonitor(SNES);
30 extern int SNESSetConvergenceHistory(SNES,double*,int);
31 extern int SNESSetUp(SNES,Vec);
32 extern int SNESSolve(SNES,Vec,int*);
33 
34 extern DLList SNESList;
35 extern int SNESRegisterDestroy(void);
36 extern int SNESRegisterAll(char *);
37 
38 extern int SNESRegister_Private(char*,char*,char*,int(*)(SNES));
39 #if defined(USE_DYNAMIC_LIBRARIES)
40 #define SNESRegister(a,b,c,d) SNESRegister_Private(a,b,c,0)
41 #else
42 #define SNESRegister(a,b,c,d) SNESRegister_Private(a,b,c,d)
43 #endif
44 
45 
46 extern int SNESGetSLES(SNES,SLES*);
47 extern int SNESGetSolution(SNES,Vec*);
48 extern int SNESGetSolutionUpdate(SNES,Vec*);
49 extern int SNESGetFunction(SNES,Vec*);
50 extern int SNESPrintHelp(SNES);
51 extern int SNESView(SNES,Viewer);
52 
53 extern int SNESSetOptionsPrefix(SNES,char*);
54 extern int SNESAppendOptionsPrefix(SNES,char*);
55 extern int SNESGetOptionsPrefix(SNES,char**);
56 extern int SNESSetFromOptions(SNES);
57 extern int SNESAddOptionsChecker(int (*)(SNES));
58 
59 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*);
60 extern int SNESSetMatrixFreeParameters(SNES,double,double);
61 extern int SNESGetType(SNES,SNESType*);
62 extern int SNESDefaultMonitor(SNES,int,double,void *);
63 extern int SNESDefaultSMonitor(SNES,int,double,void *);
64 extern int SNESSetTolerances(SNES,double,double,double,int,int);
65 extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*);
66 extern int SNESSetTrustRegionTolerance(SNES,double);
67 extern int SNESGetIterationNumber(SNES,int*);
68 extern int SNESGetFunctionNorm(SNES,Scalar*);
69 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
70 extern int SNESGetNumberLinearIterations(SNES,int*);
71 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
72 extern int SNES_KSP_SetConvergenceTestEW(SNES);
73 
74 /*
75      Reuse the default KSP monitor routines for SNES
76 */
77 #define SNESLGMonitorCreate  KSPLGMonitorCreate
78 #define SNESLGMonitorDestroy KSPLGMonitorDestroy
79 #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
80 
81 extern int SNESSetApplicationContext(SNES,void *);
82 extern int SNESGetApplicationContext(SNES,void **);
83 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*);
84 
85 /* --------- Solving systems of nonlinear equations --------------- */
86 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *);
87 extern int SNESComputeFunction(SNES,Vec,Vec);
88 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
89 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **);
90 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
91 extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
92 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*);
93 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*);
94 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
95 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
96 extern int SNESNoLineSearchNoNorms(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
97 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
98 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
99 
100 /* --------- Unconstrained minimization routines --------------------------------*/
101 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
102 extern int SNESGetHessian(SNES,Mat*,Mat*,void **);
103 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
104 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
105 extern int SNESGetGradient(SNES,Vec*);
106 extern int SNESGetGradientNorm(SNES,Scalar*);
107 extern int SNESComputeGradient(SNES,Vec,Vec);
108 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
109 extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
110 extern int SNESGetMinimizationFunction(SNES,double*);
111 extern int SNESSetMinimizationFunctionTolerance(SNES,double);
112 extern int SNESLineSearchSetDampingParameter(SNES,Scalar*);
113 extern int SNESConverged_UM_LS(SNES,double,double,double,void*);
114 extern int SNESConverged_UM_TR(SNES,double,double,double,void*);
115 
116 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *);
117 
118 /* Should these 2 routines be private? */
119 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*);
120 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
121 
122 #endif
123 
124