xref: /petsc/include/petscsnes.h (revision dbb450ca0a1bd4568a196678f20f5151425d3a04)
1*dbb450caSBarry Smith /* $Id: snes.h,v 1.31 1995/08/21 18:14:36 bsmith Exp bsmith $ */
2b1f5cb9dSBarry Smith 
3f03417d3SBarry Smith #if !defined(__SNES_PACKAGE)
4f03417d3SBarry Smith #define __SNES_PACKAGE
5ce3d82beSBarry Smith #include "sles.h"
6b1f5cb9dSBarry Smith 
7353a3ba4SBarry Smith typedef struct _SNES* SNES;
8ce3d82beSBarry Smith #define SNES_COOKIE PETSC_COOKIE+13
9b1f5cb9dSBarry Smith 
1052392280SLois Curfman McInnes typedef enum { SNES_UNKNOWN_METHOD=-1,
1152392280SLois Curfman McInnes                SNES_EQ_NLS,
1225c7317fSLois Curfman McInnes                SNES_EQ_NTR,
1325c7317fSLois Curfman McInnes                SNES_EQ_NTR_DOG_LEG,
1425c7317fSLois Curfman McInnes                SNES_EQ_NTR2_LIN,
1525c7317fSLois Curfman McInnes                SNES_EQ_NTEST,
16ddbbdb52SLois Curfman McInnes                SNES_UM_NLS,
1725c7317fSLois Curfman McInnes                SNES_UM_NTR }
1894a5d57cSLois Curfman McInnes   SNESMethod;
19b1f5cb9dSBarry Smith 
20*dbb450caSBarry Smith typedef enum { POSITIVE_FUNCTION_VALUE,
21*dbb450caSBarry Smith                NEGATIVE_FUNCTION_VALUE } SNESFunctionSign;
22*dbb450caSBarry Smith 
2325c7317fSLois Curfman McInnes #define SNES_NLS         SNES_EQ_NLS
2425c7317fSLois Curfman McInnes #define SNES_NTR         SNES_EQ_NTR
2525c7317fSLois Curfman McInnes #define SNES_NTR2_LIN    SNES_EQ_NTR2_LIN
2625c7317fSLois Curfman McInnes #define SNES_NTR_DOG_LEG SNES_EQ_NTR_DOG_LEG
2725c7317fSLois Curfman McInnes #define SNES_NTEST       SNES_EQ_NTEST
2825c7317fSLois Curfman McInnes 
2952392280SLois Curfman McInnes typedef enum { SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION }
3052392280SLois Curfman McInnes         SNESType;
31f03417d3SBarry Smith 
3252392280SLois Curfman McInnes extern int SNESCreate(MPI_Comm,SNESType,SNES*);
3394a5d57cSLois Curfman McInnes extern int SNESSetMethod(SNES,SNESMethod);
34eafb4bcbSBarry Smith extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *);
354d08eca6SBarry Smith extern int SNESSetSolution(SNES,Vec,int(*)(SNES,Vec,void*),void *);
36*dbb450caSBarry Smith extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *,
37*dbb450caSBarry Smith                            SNESFunctionSign);
38722fc279SLois Curfman McInnes extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
39ce3d82beSBarry Smith extern int SNESDestroy(SNES);
40353a3ba4SBarry Smith extern int SNESSetUp(SNES);
41ce3d82beSBarry Smith extern int SNESSolve(SNES,int*);
42ce3d82beSBarry Smith extern int SNESRegister(int,char*,int(*)(SNES));
43c01c455dSBarry Smith extern int SNESRegisterDestroy();
44ce3d82beSBarry Smith extern int SNESRegisterAll();
45ce3d82beSBarry Smith extern int SNESGetSLES(SNES,SLES*);
46761aaf1bSLois Curfman McInnes extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
47761aaf1bSLois Curfman McInnes extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
48761aaf1bSLois Curfman McInnes extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
49761aaf1bSLois Curfman McInnes extern int SNESSetLineSearchRoutine(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
50ce3d82beSBarry Smith 
51ce3d82beSBarry Smith extern int SNESGetSolution(SNES,Vec*);
52e81d6643SLois Curfman McInnes extern int SNESGetSolutionUpdate(SNES,Vec*);
53eafb4bcbSBarry Smith extern int SNESGetFunction(SNES,Vec*);
54ce3d82beSBarry Smith 
55ce3d82beSBarry Smith extern int SNESPrintHelp(SNES);
56e9e17121SLois Curfman McInnes extern int SNESView(SNES,Viewer);
57ce3d82beSBarry Smith extern int SNESSetFromOptions(SNES);
5894a5d57cSLois Curfman McInnes extern int SNESGetMethodName(SNESMethod,char **);
5952392280SLois Curfman McInnes extern int SNESGetMethodFromContext(SNES,SNESMethod*);
60eafb4bcbSBarry Smith extern int SNESDefaultMonitor(SNES,int,double,void *);
61c512e24aSBarry Smith extern int SNESDefaultSMonitor(SNES,int,double,void *);
62ce3d82beSBarry Smith extern int SNESDefaultConverged(SNES,double,double,double,void*);
63c01c455dSBarry Smith extern int SNESTrustRegionDefaultConverged(SNES,double,double,double,void*);
640de89847SLois Curfman McInnes extern int SNESSetSolutionTolerance(SNES,double);
650de89847SLois Curfman McInnes extern int SNESSetAbsoluteTolerance(SNES,double);
660de89847SLois Curfman McInnes extern int SNESSetRelativeTolerance(SNES,double);
670de89847SLois Curfman McInnes extern int SNESSetTruncationTolerance(SNES,double);
6852392280SLois Curfman McInnes extern int SNESSetTrustRegionTolerance(SNES,double);
690de89847SLois Curfman McInnes extern int SNESSetMaxIterations(SNES,int);
7006be10caSBarry Smith extern int SNESSetMaxFunctionEvaluations(SNES,int);
717e984346SBarry Smith extern int SNESGetIterationNumber(SNES,int*);
724f6d0874SLois Curfman McInnes extern int SNESGetFunctionNorm(SNES,Scalar*);
73a96f0e77SLois Curfman McInnes extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
7455b5a45fSLois Curfman McInnes extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
7555b5a45fSLois Curfman McInnes extern int SNES_KSP_SetConvergenceTestEW(SNES);
76eafb4bcbSBarry Smith 
77eafb4bcbSBarry Smith #if defined(__DRAW_PACKAGE)
78eafb4bcbSBarry Smith #define SNESLGMonitorCreate  KSPLGMonitorCreate
79eafb4bcbSBarry Smith #define SNESLGMonitorDestroy KSPLGMonitorDestroy
80eafb4bcbSBarry Smith #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
81eafb4bcbSBarry Smith #endif
82eafb4bcbSBarry Smith 
83748e9f0dSBarry Smith extern int SNESComputeInitialGuess(SNES,Vec);
84df60cc22SBarry Smith 
85722fc279SLois Curfman McInnes extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
867e984346SBarry Smith extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*);
87748e9f0dSBarry Smith 
887f813858SBarry Smith extern int SNESComputeFunction(SNES,Vec,Vec);
89ddbbdb52SLois Curfman McInnes extern int SNESDestroy(SNES);
90ddbbdb52SLois Curfman McInnes 
91c01c455dSBarry Smith extern int SNESSetApplicationContext(SNES,void *);
92c01c455dSBarry Smith extern int SNESGetApplicationContext(SNES,void **);
93c01c455dSBarry Smith extern int SNESSetConvergenceTest(SNES,
94c01c455dSBarry Smith                   int (*)(SNES,double,double,double,void*),void*);
95ddbbdb52SLois Curfman McInnes 
9652392280SLois Curfman McInnes /* Unconstrained minimization routines */
9725c7317fSLois Curfman McInnes 
98ddbbdb52SLois Curfman McInnes extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
99ddbbdb52SLois Curfman McInnes extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
100ddbbdb52SLois Curfman McInnes extern int SNESGetGradient(SNES,Vec*);
10125c7317fSLois Curfman McInnes extern int SNESGetGradientNorm(SNES,Scalar*);
102ddbbdb52SLois Curfman McInnes extern int SNESComputeGradient(SNES,Vec,Vec);
10325c7317fSLois Curfman McInnes extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
10425c7317fSLois Curfman McInnes extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
10525c7317fSLois Curfman McInnes extern int SNESGetMinimizationFunction(SNES,double*);
10625c7317fSLois Curfman McInnes extern int SNESSetMinFunctionTolerance(SNES,double);
10752392280SLois Curfman McInnes extern int SNESGetLineSearchDampingParameter(SNES,double*);
10852392280SLois Curfman McInnes 
10952392280SLois Curfman McInnes /* Should these 2 routines be private? */
11052392280SLois Curfman McInnes extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*);
11152392280SLois Curfman McInnes extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
112ddbbdb52SLois Curfman McInnes 
113ce3d82beSBarry Smith #endif
114b1f5cb9dSBarry Smith 
115