xref: /petsc/include/petscsnes.h (revision 6a67db7e1512b5d9ff9ba8f94e48d05f0a9eae3d)
1 /* $Id: snes.h,v 1.52 1996/08/09 23:32:39 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} 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 SNESSetMatrixFreeParameters(SNES,double,double);
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 SNESGetTolerances(SNES,double*,double*,double*,int*,int*);
51 extern int SNESSetTrustRegionTolerance(SNES,double);
52 extern int SNESGetIterationNumber(SNES,int*);
53 extern int SNESGetFunctionNorm(SNES,Scalar*);
54 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
55 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
56 extern int SNES_KSP_SetConvergenceTestEW(SNES);
57 
58 #if defined(__DRAW_PACKAGE)
59 #define SNESLGMonitorCreate  KSPLGMonitorCreate
60 #define SNESLGMonitorDestroy KSPLGMonitorDestroy
61 #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
62 #endif
63 
64 extern int SNESSetApplicationContext(SNES,void *);
65 extern int SNESGetApplicationContext(SNES,void **);
66 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*);
67 
68 /* Routines for solving systems of nonlinear equations */
69 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *);
70 extern int SNESComputeFunction(SNES,Vec,Vec);
71 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
72 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **);
73 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
74 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*);
75 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*);
76 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
77 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
78 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
79 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
80 
81 /* Unconstrained minimization routines */
82 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
83 extern int SNESGetHessian(SNES,Mat*,Mat*,void **);
84 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
85 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
86 extern int SNESGetGradient(SNES,Vec*);
87 extern int SNESGetGradientNorm(SNES,Scalar*);
88 extern int SNESComputeGradient(SNES,Vec,Vec);
89 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
90 extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
91 extern int SNESGetMinimizationFunction(SNES,double*);
92 extern int SNESSetMinimizationFunctionTolerance(SNES,double);
93 extern int SNESGetLineSearchDampingParameter(SNES,Scalar*);
94 extern int SNESConverged_UM_LS(SNES,double,double,double,void*);
95 extern int SNESConverged_UM_TR(SNES,double,double,double,void*);
96 
97 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *);
98 
99 /* Should these 2 routines be private? */
100 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*);
101 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
102 
103 #endif
104 
105