1 /* $Id: snes.h,v 1.32 1995/09/21 20:13:13 bsmith Exp bsmith $ */ 2 3 #if !defined(__SNES_PACKAGE) 4 #define __SNES_PACKAGE 5 #include "sles.h" 6 7 typedef struct _SNES* SNES; 8 #define SNES_COOKIE PETSC_COOKIE+13 9 10 typedef enum { SNES_UNKNOWN_METHOD=-1, 11 SNES_EQ_NLS, 12 SNES_EQ_NTR, 13 SNES_EQ_NTR_DOG_LEG, 14 SNES_EQ_NTR2_LIN, 15 SNES_EQ_NTEST, 16 SNES_UM_NLS, 17 SNES_UM_NTR } 18 SNESMethod; 19 20 typedef enum { POSITIVE_FUNCTION_VALUE, 21 NEGATIVE_FUNCTION_VALUE } SNESFunctionSign; 22 23 24 typedef enum { SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION } 25 SNESType; 26 27 extern int SNESCreate(MPI_Comm,SNESType,SNES*); 28 extern int SNESSetMethod(SNES,SNESMethod); 29 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *); 30 extern int SNESSetSolution(SNES,Vec,int(*)(SNES,Vec,void*),void *); 31 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *, 32 SNESFunctionSign); 33 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 34 extern int SNESDestroy(SNES); 35 extern int SNESSetUp(SNES); 36 extern int SNESSolve(SNES,int*); 37 extern int SNESRegister(int,char*,int(*)(SNES)); 38 extern int SNESRegisterDestroy(); 39 extern int SNESRegisterAll(); 40 extern int SNESGetSLES(SNES,SLES*); 41 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 42 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 43 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 44 extern int SNESSetLineSearchRoutine(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 45 46 extern int SNESGetSolution(SNES,Vec*); 47 extern int SNESGetSolutionUpdate(SNES,Vec*); 48 extern int SNESGetFunction(SNES,Vec*); 49 50 extern int SNESPrintHelp(SNES); 51 extern int SNESView(SNES,Viewer); 52 extern int SNESSetFromOptions(SNES); 53 extern int SNESGetMethodName(SNESMethod,char **); 54 extern int SNESGetMethodFromContext(SNES,SNESMethod*); 55 extern int SNESDefaultMonitor(SNES,int,double,void *); 56 extern int SNESDefaultSMonitor(SNES,int,double,void *); 57 extern int SNESDefaultConverged(SNES,double,double,double,void*); 58 extern int SNESTrustRegionDefaultConverged(SNES,double,double,double,void*); 59 extern int SNESSetSolutionTolerance(SNES,double); 60 extern int SNESSetAbsoluteTolerance(SNES,double); 61 extern int SNESSetRelativeTolerance(SNES,double); 62 extern int SNESSetTruncationTolerance(SNES,double); 63 extern int SNESSetTrustRegionTolerance(SNES,double); 64 extern int SNESSetMaxIterations(SNES,int); 65 extern int SNESSetMaxFunctionEvaluations(SNES,int); 66 extern int SNESGetIterationNumber(SNES,int*); 67 extern int SNESGetFunctionNorm(SNES,Scalar*); 68 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 69 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 70 extern int SNES_KSP_SetConvergenceTestEW(SNES); 71 72 #if defined(__DRAW_PACKAGE) 73 #define SNESLGMonitorCreate KSPLGMonitorCreate 74 #define SNESLGMonitorDestroy KSPLGMonitorDestroy 75 #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 76 #endif 77 78 extern int SNESComputeInitialGuess(SNES,Vec); 79 80 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 81 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 82 83 extern int SNESComputeFunction(SNES,Vec,Vec); 84 extern int SNESDestroy(SNES); 85 86 extern int SNESSetApplicationContext(SNES,void *); 87 extern int SNESGetApplicationContext(SNES,void **); 88 extern int SNESSetConvergenceTest(SNES, 89 int (*)(SNES,double,double,double,void*),void*); 90 91 /* Unconstrained minimization routines */ 92 93 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 94 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 95 extern int SNESGetGradient(SNES,Vec*); 96 extern int SNESGetGradientNorm(SNES,Scalar*); 97 extern int SNESComputeGradient(SNES,Vec,Vec); 98 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 99 extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 100 extern int SNESGetMinimizationFunction(SNES,double*); 101 extern int SNESSetMinFunctionTolerance(SNES,double); 102 extern int SNESGetLineSearchDampingParameter(SNES,double*); 103 104 /* Should these 2 routines be private? */ 105 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*); 106 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*); 107 108 #endif 109 110