1 /* $Id: snes.h,v 1.64 1998/03/06 00:21:12 bsmith 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 _p_SNES* SNES; 10 #define SNES_COOKIE PETSC_COOKIE+13 11 12 #define SNES_EQ_LS "ls" 13 #define SNES_EQ_TR "tr" 14 #define SNES_EQ_TR_DOG_LEG 15 #define SNES_EQ_TR2_LIN 16 #define SNES_EQ_TEST "test" 17 #define SNES_UM_LS "umls" 18 #define SNES_UM_TR "umtr" 19 #define SNES_LS_LM "lslm" 20 21 typedef char *SNESType; 22 23 typedef enum {SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION, SNES_LEAST_SQUARES} SNESProblemType; 24 25 /* temporarily add this declaration here */ 26 extern int JorgeQuadraticMinimizer(SNES,Vec,Vec,double,Vec,int*); 27 28 extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*); 29 extern int SNESDestroy(SNES); 30 extern int SNESSetType(SNES,SNESType); 31 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *); 32 extern int SNESSetConvergenceHistory(SNES,double*,int); 33 extern int SNESSetUp(SNES,Vec); 34 extern int SNESSolve(SNES,Vec,int*); 35 36 extern DLList SNESList; 37 extern int SNESRegisterDestroy(void); 38 extern int SNESRegisterAll(char *); 39 40 extern int SNESGetSLES(SNES,SLES*); 41 extern int SNESGetSolution(SNES,Vec*); 42 extern int SNESGetSolutionUpdate(SNES,Vec*); 43 extern int SNESGetFunction(SNES,Vec*); 44 extern int SNESPrintHelp(SNES); 45 extern int SNESView(SNES,Viewer); 46 47 extern int SNESSetOptionsPrefix(SNES,char*); 48 extern int SNESAppendOptionsPrefix(SNES,char*); 49 extern int SNESGetOptionsPrefix(SNES,char**); 50 extern int SNESSetFromOptions(SNES); 51 extern int SNESAddOptionsChecker(int (*)(SNES)); 52 53 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 54 extern int SNESSetMatrixFreeParameters(SNES,double,double); 55 extern int SNESGetType(SNES,SNESType*); 56 extern int SNESDefaultMonitor(SNES,int,double,void *); 57 extern int SNESDefaultSMonitor(SNES,int,double,void *); 58 extern int SNESSetTolerances(SNES,double,double,double,int,int); 59 extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*); 60 extern int SNESSetTrustRegionTolerance(SNES,double); 61 extern int SNESGetIterationNumber(SNES,int*); 62 extern int SNESGetFunctionNorm(SNES,Scalar*); 63 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 64 extern int SNESGetNumberLinearIterations(SNES,int*); 65 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 66 extern int SNES_KSP_SetConvergenceTestEW(SNES); 67 68 /* 69 Reuse the default KSP monitor routines for SNES 70 */ 71 #define SNESLGMonitorCreate KSPLGMonitorCreate 72 #define SNESLGMonitorDestroy KSPLGMonitorDestroy 73 #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 74 75 extern int SNESSetApplicationContext(SNES,void *); 76 extern int SNESGetApplicationContext(SNES,void **); 77 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*); 78 79 /* --------- Solving systems of nonlinear equations --------------- */ 80 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *); 81 extern int SNESComputeFunction(SNES,Vec,Vec); 82 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 83 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **); 84 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 85 extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 86 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*); 87 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*); 88 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 89 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 90 extern int SNESNoLineSearchNoNorms(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 91 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 92 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 93 94 /* --------- Unconstrained minimization routines --------------------------------*/ 95 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 96 extern int SNESGetHessian(SNES,Mat*,Mat*,void **); 97 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 98 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 99 extern int SNESGetGradient(SNES,Vec*); 100 extern int SNESGetGradientNorm(SNES,Scalar*); 101 extern int SNESComputeGradient(SNES,Vec,Vec); 102 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 103 extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 104 extern int SNESGetMinimizationFunction(SNES,double*); 105 extern int SNESSetMinimizationFunctionTolerance(SNES,double); 106 extern int SNESLineSearchSetDampingParameter(SNES,Scalar*); 107 extern int SNESConverged_UM_LS(SNES,double,double,double,void*); 108 extern int SNESConverged_UM_TR(SNES,double,double,double,void*); 109 110 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *); 111 112 /* Should these 2 routines be private? */ 113 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*); 114 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*); 115 116 #endif 117 118