1 /* $Id: snes.h,v 1.53 1996/08/20 16:04:48 curfman Exp bsmith $ */ 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 extern int SNESAddOptionsChecker(int (*)(SNES) ); 44 45 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 46 extern int SNESSetMatrixFreeParameters(SNES,double,double); 47 extern int SNESGetType(SNES,SNESType*,char**); 48 extern int SNESDefaultMonitor(SNES,int,double,void *); 49 extern int SNESDefaultSMonitor(SNES,int,double,void *); 50 extern int SNESSetTolerances(SNES,double,double,double,int,int); 51 extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*); 52 extern int SNESSetTrustRegionTolerance(SNES,double); 53 extern int SNESGetIterationNumber(SNES,int*); 54 extern int SNESGetFunctionNorm(SNES,Scalar*); 55 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 56 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 57 extern int SNES_KSP_SetConvergenceTestEW(SNES); 58 59 #if defined(__DRAW_PACKAGE) 60 #define SNESLGMonitorCreate KSPLGMonitorCreate 61 #define SNESLGMonitorDestroy KSPLGMonitorDestroy 62 #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 63 #endif 64 65 extern int SNESSetApplicationContext(SNES,void *); 66 extern int SNESGetApplicationContext(SNES,void **); 67 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*); 68 69 /* Routines for solving systems of nonlinear equations */ 70 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *); 71 extern int SNESComputeFunction(SNES,Vec,Vec); 72 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 73 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **); 74 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 75 extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 76 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*); 77 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*); 78 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 79 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 80 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 81 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 82 83 /* Unconstrained minimization routines */ 84 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 85 extern int SNESGetHessian(SNES,Mat*,Mat*,void **); 86 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 87 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 88 extern int SNESGetGradient(SNES,Vec*); 89 extern int SNESGetGradientNorm(SNES,Scalar*); 90 extern int SNESComputeGradient(SNES,Vec,Vec); 91 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 92 extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 93 extern int SNESGetMinimizationFunction(SNES,double*); 94 extern int SNESSetMinimizationFunctionTolerance(SNES,double); 95 extern int SNESGetLineSearchDampingParameter(SNES,Scalar*); 96 extern int SNESConverged_UM_LS(SNES,double,double,double,void*); 97 extern int SNESConverged_UM_TR(SNES,double,double,double,void*); 98 99 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *); 100 101 /* Should these 2 routines be private? */ 102 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*); 103 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*); 104 105 #endif 106 107