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