1 /* $Id: snes.h,v 1.55 1997/01/21 03:18:22 curfman Exp curfman $ */ 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 SNESSetConvergenceHistory(SNES,double*,int); 28 extern int SNESSetUp(SNES,Vec); 29 extern int SNESSolve(SNES,Vec,int*); 30 extern int SNESRegister(int,char*,int(*)(SNES)); 31 extern int SNESRegisterDestroy(); 32 extern int SNESRegisterAll(); 33 extern int SNESGetSLES(SNES,SLES*); 34 extern int SNESGetSolution(SNES,Vec*); 35 extern int SNESGetSolutionUpdate(SNES,Vec*); 36 extern int SNESGetFunction(SNES,Vec*); 37 extern int SNESPrintHelp(SNES); 38 extern int SNESView(SNES,Viewer); 39 40 extern int SNESSetOptionsPrefix(SNES,char*); 41 extern int SNESAppendOptionsPrefix(SNES,char*); 42 extern int SNESGetOptionsPrefix(SNES,char**); 43 extern int SNESSetFromOptions(SNES); 44 extern int SNESAddOptionsChecker(int (*)(SNES) ); 45 46 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 47 extern int SNESSetMatrixFreeParameters(SNES,double,double); 48 extern int SNESGetType(SNES,SNESType*,char**); 49 extern int SNESDefaultMonitor(SNES,int,double,void *); 50 extern int SNESDefaultSMonitor(SNES,int,double,void *); 51 extern int SNESSetTolerances(SNES,double,double,double,int,int); 52 extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*); 53 extern int SNESSetTrustRegionTolerance(SNES,double); 54 extern int SNESGetIterationNumber(SNES,int*); 55 extern int SNESGetFunctionNorm(SNES,Scalar*); 56 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 57 extern int SNESGetNumberLinearIterations(SNES,int*); 58 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 59 extern int SNES_KSP_SetConvergenceTestEW(SNES); 60 61 #if defined(__DRAW_PACKAGE) 62 #define SNESLGMonitorCreate KSPLGMonitorCreate 63 #define SNESLGMonitorDestroy KSPLGMonitorDestroy 64 #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 65 #endif 66 67 extern int SNESSetApplicationContext(SNES,void *); 68 extern int SNESGetApplicationContext(SNES,void **); 69 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*); 70 71 /* Routines for solving systems of nonlinear equations */ 72 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *); 73 extern int SNESComputeFunction(SNES,Vec,Vec); 74 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 75 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **); 76 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 77 extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 78 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*); 79 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*); 80 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 81 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 82 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 83 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 84 85 /* Unconstrained minimization routines */ 86 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 87 extern int SNESGetHessian(SNES,Mat*,Mat*,void **); 88 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 89 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 90 extern int SNESGetGradient(SNES,Vec*); 91 extern int SNESGetGradientNorm(SNES,Scalar*); 92 extern int SNESComputeGradient(SNES,Vec,Vec); 93 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 94 extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 95 extern int SNESGetMinimizationFunction(SNES,double*); 96 extern int SNESSetMinimizationFunctionTolerance(SNES,double); 97 extern int SNESGetLineSearchDampingParameter(SNES,Scalar*); 98 extern int SNESConverged_UM_LS(SNES,double,double,double,void*); 99 extern int SNESConverged_UM_TR(SNES,double,double,double,void*); 100 101 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *); 102 103 /* Should these 2 routines be private? */ 104 extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*); 105 extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*); 106 107 #endif 108 109