1 /* $Id: snes.h,v 1.60 1997/05/23 18:33:54 balay 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 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 SNES_NEW 21 } SNESType; 22 23 typedef enum {SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION} SNESProblemType; 24 extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*); 25 extern int SNESDestroy(SNES); 26 extern int SNESSetType(SNES,SNESType); 27 extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *); 28 extern int SNESSetConvergenceHistory(SNES,double*,int); 29 extern int SNESSetUp(SNES,Vec); 30 extern int SNESSolve(SNES,Vec,int*); 31 32 extern int SNESRegister(SNESType,SNESType*,char*,int(*)(SNES)); 33 extern int SNESRegisterDestroy(); 34 extern int SNESRegisterAll(); 35 extern int SNESRegisterAllCalled; 36 37 extern int SNESGetSLES(SNES,SLES*); 38 extern int SNESGetSolution(SNES,Vec*); 39 extern int SNESGetSolutionUpdate(SNES,Vec*); 40 extern int SNESGetFunction(SNES,Vec*); 41 extern int SNESPrintHelp(SNES); 42 extern int SNESView(SNES,Viewer); 43 44 extern int SNESSetOptionsPrefix(SNES,char*); 45 extern int SNESAppendOptionsPrefix(SNES,char*); 46 extern int SNESGetOptionsPrefix(SNES,char**); 47 extern int SNESSetFromOptions(SNES); 48 extern int SNESAddOptionsChecker(int (*)(SNES)); 49 50 extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 51 extern int SNESSetMatrixFreeParameters(SNES,double,double); 52 extern int SNESGetType(SNES,SNESType*,char**); 53 extern int SNESDefaultMonitor(SNES,int,double,void *); 54 extern int SNESDefaultSMonitor(SNES,int,double,void *); 55 extern int SNESSetTolerances(SNES,double,double,double,int,int); 56 extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*); 57 extern int SNESSetTrustRegionTolerance(SNES,double); 58 extern int SNESGetIterationNumber(SNES,int*); 59 extern int SNESGetFunctionNorm(SNES,Scalar*); 60 extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 61 extern int SNESGetNumberLinearIterations(SNES,int*); 62 extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 63 extern int SNES_KSP_SetConvergenceTestEW(SNES); 64 65 /* 66 Reuse the default KSP monitor routines for SNES 67 */ 68 #define SNESLGMonitorCreate KSPLGMonitorCreate 69 #define SNESLGMonitorDestroy KSPLGMonitorDestroy 70 #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 71 72 extern int SNESSetApplicationContext(SNES,void *); 73 extern int SNESGetApplicationContext(SNES,void **); 74 extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*); 75 76 /* --------- Solving systems of nonlinear equations --------------- */ 77 extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *); 78 extern int SNESComputeFunction(SNES,Vec,Vec); 79 extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 80 extern int SNESGetJacobian(SNES,Mat*,Mat*,void **); 81 extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 82 extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 83 extern int SNESConverged_EQ_LS(SNES,double,double,double,void*); 84 extern int SNESConverged_EQ_TR(SNES,double,double,double,void*); 85 extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 86 extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 87 extern int SNESNoLineSearchNoNorms(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 88 extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 89 extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 90 91 /* --------- Unconstrained minimization routines --------------------------------*/ 92 extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 93 extern int SNESGetHessian(SNES,Mat*,Mat*,void **); 94 extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 95 extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 96 extern int SNESGetGradient(SNES,Vec*); 97 extern int SNESGetGradientNorm(SNES,Scalar*); 98 extern int SNESComputeGradient(SNES,Vec,Vec); 99 extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 100 extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 101 extern int SNESGetMinimizationFunction(SNES,double*); 102 extern int SNESSetMinimizationFunctionTolerance(SNES,double); 103 extern int SNESGetLineSearchDampingParameter(SNES,Scalar*); 104 extern int SNESConverged_UM_LS(SNES,double,double,double,void*); 105 extern int SNESConverged_UM_TR(SNES,double,double,double,void*); 106 107 extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *); 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