1 /* $Id: snes.h,v 1.31 1995/08/21 18:14:36 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 #define SNES_NLS SNES_EQ_NLS 24 #define SNES_NTR SNES_EQ_NTR 25 #define SNES_NTR2_LIN SNES_EQ_NTR2_LIN 26 #define SNES_NTR_DOG_LEG SNES_EQ_NTR_DOG_LEG 27 #define SNES_NTEST SNES_EQ_NTEST 28 29 typedef enum { SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION } 30 SNESType; 31 32 extern int SNESCreate(MPI_Comm,SNESType,SNES*); 33 extern int SNESSetMethod(SNES,SNESMethod); 34 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *); 35 extern int SNESSetSolution(SNES,Vec,int(*)(SNES,Vec,void*),void *); 36 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *, 37 SNESFunctionSign); 38 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 39 extern int SNESDestroy(SNES); 40 extern int SNESSetUp(SNES); 41 extern int SNESSolve(SNES,int*); 42 extern int SNESRegister(int,char*,int(*)(SNES)); 43 extern int SNESRegisterDestroy(); 44 extern int SNESRegisterAll(); 45 extern int SNESGetSLES(SNES,SLES*); 46 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 47 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 48 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 49 extern int SNESSetLineSearchRoutine(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 50 51 extern int SNESGetSolution(SNES,Vec*); 52 extern int SNESGetSolutionUpdate(SNES,Vec*); 53 extern int SNESGetFunction(SNES,Vec*); 54 55 extern int SNESPrintHelp(SNES); 56 extern int SNESView(SNES,Viewer); 57 extern int SNESSetFromOptions(SNES); 58 extern int SNESGetMethodName(SNESMethod,char **); 59 extern int SNESGetMethodFromContext(SNES,SNESMethod*); 60 extern int SNESDefaultMonitor(SNES,int,double,void *); 61 extern int SNESDefaultSMonitor(SNES,int,double,void *); 62 extern int SNESDefaultConverged(SNES,double,double,double,void*); 63 extern int SNESTrustRegionDefaultConverged(SNES,double,double,double,void*); 64 extern int SNESSetSolutionTolerance(SNES,double); 65 extern int SNESSetAbsoluteTolerance(SNES,double); 66 extern int SNESSetRelativeTolerance(SNES,double); 67 extern int SNESSetTruncationTolerance(SNES,double); 68 extern int SNESSetTrustRegionTolerance(SNES,double); 69 extern int SNESSetMaxIterations(SNES,int); 70 extern int SNESSetMaxFunctionEvaluations(SNES,int); 71 extern int SNESGetIterationNumber(SNES,int*); 72 extern int SNESGetFunctionNorm(SNES,Scalar*); 73 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 74 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 75 extern int SNES_KSP_SetConvergenceTestEW(SNES); 76 77 #if defined(__DRAW_PACKAGE) 78 #define SNESLGMonitorCreate KSPLGMonitorCreate 79 #define SNESLGMonitorDestroy KSPLGMonitorDestroy 80 #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 81 #endif 82 83 extern int SNESComputeInitialGuess(SNES,Vec); 84 85 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 86 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 87 88 extern int SNESComputeFunction(SNES,Vec,Vec); 89 extern int SNESDestroy(SNES); 90 91 extern int SNESSetApplicationContext(SNES,void *); 92 extern int SNESGetApplicationContext(SNES,void **); 93 extern int SNESSetConvergenceTest(SNES, 94 int (*)(SNES,double,double,double,void*),void*); 95 96 /* Unconstrained minimization routines */ 97 98 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 99 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 100 extern int SNESGetGradient(SNES,Vec*); 101 extern int SNESGetGradientNorm(SNES,Scalar*); 102 extern int SNESComputeGradient(SNES,Vec,Vec); 103 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 104 extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 105 extern int SNESGetMinimizationFunction(SNES,double*); 106 extern int SNESSetMinFunctionTolerance(SNES,double); 107 extern int SNESGetLineSearchDampingParameter(SNES,double*); 108 109 /* Should these 2 routines be private? */ 110 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*); 111 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*); 112 113 #endif 114 115