xref: /petsc/include/petscsnes.h (revision 70f55243aafb320636e2a54ff30cab5d1e8d3d7b)
1 /* $Id: snes.h,v 1.50 1996/03/26 00:11:15 curfman Exp bsmith $ */
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} SNESProblemType;
23 extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*);
24 extern int SNESDestroy(SNES);
25 extern int SNESSetType(SNES,SNESType);
26 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *);
27 extern int SNESSetUp(SNES,Vec);
28 extern int SNESSolve(SNES,Vec,int*);
29 extern int SNESRegister(int,char*,int(*)(SNES));
30 extern int SNESRegisterDestroy();
31 extern int SNESRegisterAll();
32 extern int SNESGetSLES(SNES,SLES*);
33 extern int SNESGetSolution(SNES,Vec*);
34 extern int SNESGetSolutionUpdate(SNES,Vec*);
35 extern int SNESGetFunction(SNES,Vec*);
36 extern int SNESPrintHelp(SNES);
37 extern int SNESView(SNES,Viewer);
38 
39 extern int SNESSetOptionsPrefix(SNES,char*);
40 extern int SNESAppendOptionsPrefix(SNES,char*);
41 extern int SNESGetOptionsPrefix(SNES,char**);
42 extern int SNESSetFromOptions(SNES);
43 
44 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*);
45 extern int SNESGetType(SNES,SNESType*,char**);
46 extern int SNESDefaultMonitor(SNES,int,double,void *);
47 extern int SNESDefaultSMonitor(SNES,int,double,void *);
48 extern int SNESSetTolerances(SNES,double,double,double,int,int);
49 extern int SNESSetTrustRegionTolerance(SNES,double);
50 extern int SNESGetIterationNumber(SNES,int*);
51 extern int SNESGetFunctionNorm(SNES,Scalar*);
52 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
53 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
54 extern int SNES_KSP_SetConvergenceTestEW(SNES);
55 
56 #if defined(__DRAW_PACKAGE)
57 #define SNESLGMonitorCreate  KSPLGMonitorCreate
58 #define SNESLGMonitorDestroy KSPLGMonitorDestroy
59 #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
60 #endif
61 
62 extern int SNESSetApplicationContext(SNES,void *);
63 extern int SNESGetApplicationContext(SNES,void **);
64 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*);
65 
66 /* Routines for solving systems of nonlinear equations */
67 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *);
68 extern int SNESComputeFunction(SNES,Vec,Vec);
69 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
70 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **);
71 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
72 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*);
73 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*);
74 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
75 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
76 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
77 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
78 
79 /* Unconstrained minimization routines */
80 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
81 extern int SNESGetHessian(SNES,Mat*,Mat*,void **);
82 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
83 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
84 extern int SNESGetGradient(SNES,Vec*);
85 extern int SNESGetGradientNorm(SNES,Scalar*);
86 extern int SNESComputeGradient(SNES,Vec,Vec);
87 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
88 extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
89 extern int SNESGetMinimizationFunction(SNES,double*);
90 extern int SNESSetMinimizationFunctionTolerance(SNES,double);
91 extern int SNESGetLineSearchDampingParameter(SNES,Scalar*);
92 extern int SNESConverged_UM_LS(SNES,double,double,double,void*);
93 extern int SNESConverged_UM_TR(SNES,double,double,double,void*);
94 
95 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *);
96 
97 /* Should these 2 routines be private? */
98 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*);
99 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
100 
101 #endif
102 
103