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