1*2a03e22aSLois Curfman McInnes /* $Id: snes.h,v 1.61 1997/06/18 12:53:47 bsmith Exp curfman $ */ 2f26ada1bSBarry Smith /* 384cb2905SBarry Smith User interface for the nonlinear solvers and unconstrained minimization package. 4f26ada1bSBarry Smith */ 5f03417d3SBarry Smith #if !defined(__SNES_PACKAGE) 6f03417d3SBarry Smith #define __SNES_PACKAGE 7ce3d82beSBarry Smith #include "sles.h" 8b1f5cb9dSBarry Smith 9f09e8eb9SSatish Balay typedef struct _p_SNES* SNES; 10ce3d82beSBarry Smith #define SNES_COOKIE PETSC_COOKIE+13 11b1f5cb9dSBarry Smith 1252392280SLois Curfman McInnes typedef enum { SNES_UNKNOWN_METHOD=-1, 1340191667SLois Curfman McInnes SNES_EQ_LS, 1440191667SLois Curfman McInnes SNES_EQ_TR, 1540191667SLois Curfman McInnes SNES_EQ_TR_DOG_LEG, 1640191667SLois Curfman McInnes SNES_EQ_TR2_LIN, 1740191667SLois Curfman McInnes SNES_EQ_TEST, 1840191667SLois Curfman McInnes SNES_UM_LS, 1984cb2905SBarry Smith SNES_UM_TR, 20*2a03e22aSLois Curfman McInnes SNES_NEW, 21*2a03e22aSLois Curfman McInnes SNES_LS_LM 224b0e389bSBarry Smith } SNESType; 23b1f5cb9dSBarry Smith 24*2a03e22aSLois Curfman McInnes typedef enum {SNES_NONLINEAR_EQUATIONS, SNES_UNCONSTRAINED_MINIMIZATION, SNES_LEAST_SQUARES} SNESProblemType; 25*2a03e22aSLois Curfman McInnes 26*2a03e22aSLois Curfman McInnes /* temporarily add this declaration here */ 27*2a03e22aSLois Curfman McInnes extern int JorgeQuadraticMinimizer(SNES,Vec,Vec,double,Vec,int*); 28*2a03e22aSLois Curfman McInnes 294b0e389bSBarry Smith extern int SNESCreate(MPI_Comm,SNESProblemType,SNES*); 304b0e389bSBarry Smith extern int SNESDestroy(SNES); 314b0e389bSBarry Smith extern int SNESSetType(SNES,SNESType); 32eafb4bcbSBarry Smith extern int SNESSetMonitor(SNES,int(*)(SNES,int,double,void*),void *); 3351979daaSLois Curfman McInnes extern int SNESSetConvergenceHistory(SNES,double*,int); 348ddd3da0SLois Curfman McInnes extern int SNESSetUp(SNES,Vec); 358ddd3da0SLois Curfman McInnes extern int SNESSolve(SNES,Vec,int*); 3684cb2905SBarry Smith 3784cb2905SBarry Smith extern int SNESRegister(SNESType,SNESType*,char*,int(*)(SNES)); 38c01c455dSBarry Smith extern int SNESRegisterDestroy(); 39ce3d82beSBarry Smith extern int SNESRegisterAll(); 4084cb2905SBarry Smith extern int SNESRegisterAllCalled; 4184cb2905SBarry Smith 42ce3d82beSBarry Smith extern int SNESGetSLES(SNES,SLES*); 43ce3d82beSBarry Smith extern int SNESGetSolution(SNES,Vec*); 44e81d6643SLois Curfman McInnes extern int SNESGetSolutionUpdate(SNES,Vec*); 45eafb4bcbSBarry Smith extern int SNESGetFunction(SNES,Vec*); 46ce3d82beSBarry Smith extern int SNESPrintHelp(SNES); 47e9e17121SLois Curfman McInnes extern int SNESView(SNES,Viewer); 487bc3d0afSSatish Balay 496daaf66cSBarry Smith extern int SNESSetOptionsPrefix(SNES,char*); 507bc3d0afSSatish Balay extern int SNESAppendOptionsPrefix(SNES,char*); 517bc3d0afSSatish Balay extern int SNESGetOptionsPrefix(SNES,char**); 52ce3d82beSBarry Smith extern int SNESSetFromOptions(SNES); 53639f9d9dSBarry Smith extern int SNESAddOptionsChecker(int (*)(SNES)); 5440191667SLois Curfman McInnes 5540191667SLois Curfman McInnes extern int SNESDefaultMatrixFreeMatCreate(SNES,Vec x,Mat*); 56eb9086c3SLois Curfman McInnes extern int SNESSetMatrixFreeParameters(SNES,double,double); 574b0e389bSBarry Smith extern int SNESGetType(SNES,SNESType*,char**); 58eafb4bcbSBarry Smith extern int SNESDefaultMonitor(SNES,int,double,void *); 59c512e24aSBarry Smith extern int SNESDefaultSMonitor(SNES,int,double,void *); 60d7a720efSLois Curfman McInnes extern int SNESSetTolerances(SNES,double,double,double,int,int); 6133174efeSLois Curfman McInnes extern int SNESGetTolerances(SNES,double*,double*,double*,int*,int*); 6252392280SLois Curfman McInnes extern int SNESSetTrustRegionTolerance(SNES,double); 637e984346SBarry Smith extern int SNESGetIterationNumber(SNES,int*); 644f6d0874SLois Curfman McInnes extern int SNESGetFunctionNorm(SNES,Scalar*); 65a96f0e77SLois Curfman McInnes extern int SNESGetNumberUnsuccessfulSteps(SNES,int*); 66d2bb1046SLois Curfman McInnes extern int SNESGetNumberLinearIterations(SNES,int*); 6755b5a45fSLois Curfman McInnes extern int SNES_KSP_SetParametersEW(SNES,int,double,double,double,double,double,double); 6855b5a45fSLois Curfman McInnes extern int SNES_KSP_SetConvergenceTestEW(SNES); 69eafb4bcbSBarry Smith 703369ce9aSBarry Smith /* 713369ce9aSBarry Smith Reuse the default KSP monitor routines for SNES 723369ce9aSBarry Smith */ 73eafb4bcbSBarry Smith #define SNESLGMonitorCreate KSPLGMonitorCreate 74eafb4bcbSBarry Smith #define SNESLGMonitorDestroy KSPLGMonitorDestroy 75eafb4bcbSBarry Smith #define SNESLGMonitor ((int (*)(SNES,int,double,void*))KSPLGMonitor) 76eafb4bcbSBarry Smith 77c01c455dSBarry Smith extern int SNESSetApplicationContext(SNES,void *); 78c01c455dSBarry Smith extern int SNESGetApplicationContext(SNES,void **); 79f26ada1bSBarry Smith extern int SNESSetConvergenceTest(SNES,int (*)(SNES,double,double,double,void*),void*); 80ddbbdb52SLois Curfman McInnes 81b67197daSBarry Smith /* --------- Solving systems of nonlinear equations --------------- */ 8240191667SLois Curfman McInnes extern int SNESSetFunction(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void *); 8340191667SLois Curfman McInnes extern int SNESComputeFunction(SNES,Vec,Vec); 8440191667SLois Curfman McInnes extern int SNESSetJacobian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 8540191667SLois Curfman McInnes extern int SNESGetJacobian(SNES,Mat*,Mat*,void **); 8640191667SLois Curfman McInnes extern int SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 87639f9d9dSBarry Smith extern int SNESDefaultComputeJacobianWithColoring(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 8840191667SLois Curfman McInnes extern int SNESConverged_EQ_LS(SNES,double,double,double,void*); 8940191667SLois Curfman McInnes extern int SNESConverged_EQ_TR(SNES,double,double,double,void*); 9084cb2905SBarry Smith extern int SNESSetLineSearch(SNES,int(*)(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*)); 9140191667SLois Curfman McInnes extern int SNESNoLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 9293c39befSBarry Smith extern int SNESNoLineSearchNoNorms(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 9340191667SLois Curfman McInnes extern int SNESCubicLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 9440191667SLois Curfman McInnes extern int SNESQuadraticLineSearch(SNES,Vec,Vec,Vec,Vec,Vec,double,double*,double*,int*); 9540191667SLois Curfman McInnes 9684cb2905SBarry Smith /* --------- Unconstrained minimization routines --------------------------------*/ 97ddbbdb52SLois Curfman McInnes extern int SNESSetHessian(SNES,Mat,Mat,int(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *); 9882590567SLois Curfman McInnes extern int SNESGetHessian(SNES,Mat*,Mat*,void **); 9940191667SLois Curfman McInnes extern int SNESDefaultComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*,void*); 100ddbbdb52SLois Curfman McInnes extern int SNESSetGradient(SNES,Vec,int(*)(SNES,Vec,Vec,void*),void*); 101ddbbdb52SLois Curfman McInnes extern int SNESGetGradient(SNES,Vec*); 10225c7317fSLois Curfman McInnes extern int SNESGetGradientNorm(SNES,Scalar*); 103ddbbdb52SLois Curfman McInnes extern int SNESComputeGradient(SNES,Vec,Vec); 10425c7317fSLois Curfman McInnes extern int SNESSetMinimizationFunction(SNES,int(*)(SNES,Vec,double*,void*),void*); 10525c7317fSLois Curfman McInnes extern int SNESComputeMinimizationFunction(SNES,Vec,double*); 10625c7317fSLois Curfman McInnes extern int SNESGetMinimizationFunction(SNES,double*); 10777c4ece6SBarry Smith extern int SNESSetMinimizationFunctionTolerance(SNES,double); 108ed967170SLois Curfman McInnes extern int SNESGetLineSearchDampingParameter(SNES,Scalar*); 10940191667SLois Curfman McInnes extern int SNESConverged_UM_LS(SNES,double,double,double,void*); 11040191667SLois Curfman McInnes extern int SNESConverged_UM_TR(SNES,double,double,double,void*); 11152392280SLois Curfman McInnes 1124b0e389bSBarry Smith extern int SNESDefaultMatrixFreeMatAddNullSpace(Mat,int,int,Vec *); 1134b0e389bSBarry Smith 11452392280SLois Curfman McInnes /* Should these 2 routines be private? */ 11552392280SLois Curfman McInnes extern int SNESComputeHessian(SNES,Vec,Mat*,Mat*,MatStructure*); 11652392280SLois Curfman McInnes extern int SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*); 117ddbbdb52SLois Curfman McInnes 118ce3d82beSBarry Smith #endif 119b1f5cb9dSBarry Smith 120