xref: /petsc/include/petscsnes.h (revision 93c39befdc2c545b92559b48e3c3f7c5a930faa6)
1*93c39befSBarry Smith /* $Id: snes.h,v 1.60 1997/05/23 18:33:54 balay Exp bsmith $ */
2f26ada1bSBarry Smith /*
384cb2905SBarry Smith     User interface for the nonlinear solvers and unconstrained minimization package.
4f26ada1bSBarry Smith */
5f03417d3SBarry Smith #if !defined(__SNES_PACKAGE)
6f03417d3SBarry Smith #define __SNES_PACKAGE
7ce3d82beSBarry Smith #include "sles.h"
8b1f5cb9dSBarry Smith 
9f09e8eb9SSatish Balay typedef struct _p_SNES* SNES;
10ce3d82beSBarry Smith #define SNES_COOKIE PETSC_COOKIE+13
11b1f5cb9dSBarry Smith 
1252392280SLois Curfman McInnes typedef enum { SNES_UNKNOWN_METHOD=-1,
1340191667SLois Curfman McInnes                SNES_EQ_LS,
1440191667SLois Curfman McInnes                SNES_EQ_TR,
1540191667SLois Curfman McInnes                SNES_EQ_TR_DOG_LEG,
1640191667SLois Curfman McInnes                SNES_EQ_TR2_LIN,
1740191667SLois Curfman McInnes                SNES_EQ_TEST,
1840191667SLois Curfman McInnes                SNES_UM_LS,
1984cb2905SBarry Smith                SNES_UM_TR,
2084cb2905SBarry Smith                SNES_NEW
214b0e389bSBarry Smith } SNESType;
22b1f5cb9dSBarry Smith 
237588ac45SBarry Smith typedef enum {SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION} SNESProblemType;
244b0e389bSBarry Smith extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*);
254b0e389bSBarry Smith extern int SNESDestroy(SNES);
264b0e389bSBarry Smith extern int SNESSetType(SNES,SNESType);
27eafb4bcbSBarry Smith extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *);
2851979daaSLois Curfman McInnes extern int SNESSetConvergenceHistory(SNES,double*,int);
298ddd3da0SLois Curfman McInnes extern int SNESSetUp(SNES,Vec);
308ddd3da0SLois Curfman McInnes extern int SNESSolve(SNES,Vec,int*);
3184cb2905SBarry Smith 
3284cb2905SBarry Smith extern int SNESRegister(SNESType,SNESType*,char*,int(*)(SNES));
33c01c455dSBarry Smith extern int SNESRegisterDestroy();
34ce3d82beSBarry Smith extern int SNESRegisterAll();
3584cb2905SBarry Smith extern int SNESRegisterAllCalled;
3684cb2905SBarry Smith 
37ce3d82beSBarry Smith extern int SNESGetSLES(SNES,SLES*);
38ce3d82beSBarry Smith extern int SNESGetSolution(SNES,Vec*);
39e81d6643SLois Curfman McInnes extern int SNESGetSolutionUpdate(SNES,Vec*);
40eafb4bcbSBarry Smith extern int SNESGetFunction(SNES,Vec*);
41ce3d82beSBarry Smith extern int SNESPrintHelp(SNES);
42e9e17121SLois Curfman McInnes extern int SNESView(SNES,Viewer);
437bc3d0afSSatish Balay 
446daaf66cSBarry Smith extern int SNESSetOptionsPrefix(SNES,char*);
457bc3d0afSSatish Balay extern int SNESAppendOptionsPrefix(SNES,char*);
467bc3d0afSSatish Balay extern int SNESGetOptionsPrefix(SNES,char**);
47ce3d82beSBarry Smith extern int SNESSetFromOptions(SNES);
48639f9d9dSBarry Smith extern int SNESAddOptionsChecker(int (*)(SNES));
4940191667SLois Curfman McInnes 
5040191667SLois Curfman McInnes extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*);
51eb9086c3SLois Curfman McInnes extern int SNESSetMatrixFreeParameters(SNES,double,double);
524b0e389bSBarry Smith extern int SNESGetType(SNES,SNESType*,char**);
53eafb4bcbSBarry Smith extern int SNESDefaultMonitor(SNES,int,double,void *);
54c512e24aSBarry Smith extern int SNESDefaultSMonitor(SNES,int,double,void *);
55d7a720efSLois Curfman McInnes extern int SNESSetTolerances(SNES,double,double,double,int,int);
5633174efeSLois Curfman McInnes extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*);
5752392280SLois Curfman McInnes extern int SNESSetTrustRegionTolerance(SNES,double);
587e984346SBarry Smith extern int SNESGetIterationNumber(SNES,int*);
594f6d0874SLois Curfman McInnes extern int SNESGetFunctionNorm(SNES,Scalar*);
60a96f0e77SLois Curfman McInnes extern int SNESGetNumberUnsuccessfulSteps(SNES,int*);
61d2bb1046SLois Curfman McInnes extern int SNESGetNumberLinearIterations(SNES,int*);
6255b5a45fSLois Curfman McInnes extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double);
6355b5a45fSLois Curfman McInnes extern int SNES_KSP_SetConvergenceTestEW(SNES);
64eafb4bcbSBarry Smith 
653369ce9aSBarry Smith /*
663369ce9aSBarry Smith      Reuse the default KSP monitor routines for SNES
673369ce9aSBarry Smith */
68eafb4bcbSBarry Smith #define SNESLGMonitorCreate  KSPLGMonitorCreate
69eafb4bcbSBarry Smith #define SNESLGMonitorDestroy KSPLGMonitorDestroy
70eafb4bcbSBarry Smith #define SNESLGMonitor        ((int (*)(SNES,int,double,void*))KSPLGMonitor)
71eafb4bcbSBarry Smith 
72c01c455dSBarry Smith extern int SNESSetApplicationContext(SNES,void *);
73c01c455dSBarry Smith extern int SNESGetApplicationContext(SNES,void **);
74f26ada1bSBarry Smith extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*);
75ddbbdb52SLois Curfman McInnes 
76b67197daSBarry Smith /* --------- Solving systems of nonlinear equations --------------- */
7740191667SLois Curfman McInnes extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *);
7840191667SLois Curfman McInnes extern int SNESComputeFunction(SNES,Vec,Vec);
7940191667SLois Curfman McInnes extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
8040191667SLois Curfman McInnes extern int SNESGetJacobian(SNES,Mat*,Mat*,void **);
8140191667SLois Curfman McInnes extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
82639f9d9dSBarry Smith extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
8340191667SLois Curfman McInnes extern int SNESConverged_EQ_LS(SNES,double,double,double,void*);
8440191667SLois Curfman McInnes extern int SNESConverged_EQ_TR(SNES,double,double,double,void*);
8584cb2905SBarry Smith extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*));
8640191667SLois Curfman McInnes extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
87*93c39befSBarry Smith extern int SNESNoLineSearchNoNorms(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
8840191667SLois Curfman McInnes extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
8940191667SLois Curfman McInnes extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*);
9040191667SLois Curfman McInnes 
9184cb2905SBarry Smith /* --------- Unconstrained minimization routines --------------------------------*/
92ddbbdb52SLois Curfman McInnes extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
9382590567SLois Curfman McInnes extern int SNESGetHessian(SNES,Mat*,Mat*,void **);
9440191667SLois Curfman McInnes extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
95ddbbdb52SLois Curfman McInnes extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*);
96ddbbdb52SLois Curfman McInnes extern int SNESGetGradient(SNES,Vec*);
9725c7317fSLois Curfman McInnes extern int SNESGetGradientNorm(SNES,Scalar*);
98ddbbdb52SLois Curfman McInnes extern int SNESComputeGradient(SNES,Vec,Vec);
9925c7317fSLois Curfman McInnes extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*);
10025c7317fSLois Curfman McInnes extern int SNESComputeMinimizationFunction(SNES,Vec,double*);
10125c7317fSLois Curfman McInnes extern int SNESGetMinimizationFunction(SNES,double*);
10277c4ece6SBarry Smith extern int SNESSetMinimizationFunctionTolerance(SNES,double);
103ed967170SLois Curfman McInnes extern int SNESGetLineSearchDampingParameter(SNES,Scalar*);
10440191667SLois Curfman McInnes extern int SNESConverged_UM_LS(SNES,double,double,double,void*);
10540191667SLois Curfman McInnes extern int SNESConverged_UM_TR(SNES,double,double,double,void*);
10652392280SLois Curfman McInnes 
1074b0e389bSBarry Smith extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *);
1084b0e389bSBarry Smith 
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