xref: /petsc/include/petscsnes.h (revision 070915c3bfb37e789592837c4dfea5ea90992e4b)
1f26ada1bSBarry Smith /*
2eef9c623SLois Curfman McInnes     User interface for the nonlinear solvers package.
3f26ada1bSBarry Smith */
40a835dfdSSatish Balay #if !defined(__PETSCSNES_H)
50a835dfdSSatish Balay #define __PETSCSNES_H
694b7f48cSBarry Smith #include "petscksp.h"
7e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN
8b1f5cb9dSBarry Smith 
9435da068SBarry Smith /*S
10435da068SBarry Smith      SNES - Abstract PETSc object that manages all nonlinear solves
11435da068SBarry Smith 
12435da068SBarry Smith    Level: beginner
13435da068SBarry Smith 
14435da068SBarry Smith   Concepts: nonlinear solvers
15435da068SBarry Smith 
1694b7f48cSBarry Smith .seealso:  SNESCreate(), SNESSetType(), SNESType, TS, KSP, KSP, PC
17435da068SBarry Smith S*/
18f09e8eb9SSatish Balay typedef struct _p_SNES* SNES;
19435da068SBarry Smith 
20435da068SBarry Smith /*E
21435da068SBarry Smith     SNESType - String with the name of a PETSc SNES method or the creation function
22435da068SBarry Smith        with an optional dynamic library name, for example
23435da068SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:mysnescreate()
24435da068SBarry Smith 
25435da068SBarry Smith    Level: beginner
26435da068SBarry Smith 
27435da068SBarry Smith .seealso: SNESSetType(), SNES
28435da068SBarry Smith E*/
29a313700dSBarry Smith #define SNESType char*
30eef9c623SLois Curfman McInnes #define SNESLS     "ls"
31eef9c623SLois Curfman McInnes #define SNESTR     "tr"
321d6018f0SLisandro Dalcin #define SNESPYTHON "python"
33eef9c623SLois Curfman McInnes #define SNESTEST   "test"
34*070915c3SMatthew G Knepley #define SNESPICARD "picard"
35b1f5cb9dSBarry Smith 
36deeb6e72SMatthew Knepley /* Logging support */
370700a824SBarry Smith extern PetscClassId PETSCSNES_DLLEXPORT SNES_CLASSID;
38deeb6e72SMatthew Knepley 
3963dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESInitializePackage(const char[]);
40deeb6e72SMatthew Knepley 
4163dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESCreate(MPI_Comm,SNES*);
4263dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDestroy(SNES);
43a313700dSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetType(SNES,const SNESType);
44a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorSet(SNES,PetscErrorCode(*)(SNES,PetscInt,PetscReal,void*),void *,PetscErrorCode (*)(void*));
45a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorCancel(SNES);
4663dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetConvergenceHistory(SNES,PetscReal[],PetscInt[],PetscInt,PetscTruth);
4763dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetConvergenceHistory(SNES,PetscReal*[],PetscInt *[],PetscInt *);
4870e92668SMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetUp(SNES);
49f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSolve(SNES,Vec,Vec);
5084cb2905SBarry Smith 
5163dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESAddOptionsChecker(PetscErrorCode (*)(SNES));
524d8f6ca9SMatthew Knepley 
5363dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetUpdate(SNES, PetscErrorCode (*)(SNES, PetscInt));
5463dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDefaultUpdate(SNES, PetscInt);
554d8f6ca9SMatthew Knepley 
56b0a32e0cSBarry Smith extern PetscFList SNESList;
5763dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESRegisterDestroy(void);
5863dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESRegisterAll(const char[]);
5984cb2905SBarry Smith 
6063dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESRegister(const char[],const char[],const char[],PetscErrorCode (*)(SNES));
6130de9b25SBarry Smith 
6230de9b25SBarry Smith /*MC
6330de9b25SBarry Smith    SNESRegisterDynamic - Adds a method to the nonlinear solver package.
6430de9b25SBarry Smith 
6530de9b25SBarry Smith    Synopsis:
661890ba74SBarry Smith    PetscErrorCode SNESRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(SNES))
6730de9b25SBarry Smith 
6830de9b25SBarry Smith    Not collective
6930de9b25SBarry Smith 
7030de9b25SBarry Smith    Input Parameters:
7130de9b25SBarry Smith +  name_solver - name of a new user-defined solver
7230de9b25SBarry Smith .  path - path (either absolute or relative) the library containing this solver
7330de9b25SBarry Smith .  name_create - name of routine to create method context
7430de9b25SBarry Smith -  routine_create - routine to create method context
7530de9b25SBarry Smith 
7630de9b25SBarry Smith    Notes:
7730de9b25SBarry Smith    SNESRegisterDynamic() may be called multiple times to add several user-defined solvers.
7830de9b25SBarry Smith 
7930de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
8030de9b25SBarry Smith    is ignored.
8130de9b25SBarry Smith 
82ab901514SBarry Smith    Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
8330de9b25SBarry Smith    and others of the form ${any_environmental_variable} occuring in pathname will be
8430de9b25SBarry Smith    replaced with appropriate values.
8530de9b25SBarry Smith 
8630de9b25SBarry Smith    Sample usage:
8730de9b25SBarry Smith .vb
8830de9b25SBarry Smith    SNESRegisterDynamic("my_solver",/home/username/my_lib/lib/libg/solaris/mylib.a,
8930de9b25SBarry Smith                 "MySolverCreate",MySolverCreate);
9030de9b25SBarry Smith .ve
9130de9b25SBarry Smith 
9230de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
9330de9b25SBarry Smith $     SNESSetType(snes,"my_solver")
9430de9b25SBarry Smith    or at runtime via the option
9530de9b25SBarry Smith $     -snes_type my_solver
9630de9b25SBarry Smith 
9730de9b25SBarry Smith    Level: advanced
9830de9b25SBarry Smith 
9930de9b25SBarry Smith     Note: If your function is not being put into a shared library then use SNESRegister() instead
10030de9b25SBarry Smith 
10130de9b25SBarry Smith .keywords: SNES, nonlinear, register
10230de9b25SBarry Smith 
10330de9b25SBarry Smith .seealso: SNESRegisterAll(), SNESRegisterDestroy()
10430de9b25SBarry Smith M*/
105aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
106f1af5d2fSBarry Smith #define SNESRegisterDynamic(a,b,c,d) SNESRegister(a,b,c,0)
107b2002411SLois Curfman McInnes #else
108f1af5d2fSBarry Smith #define SNESRegisterDynamic(a,b,c,d) SNESRegister(a,b,c,d)
109b2002411SLois Curfman McInnes #endif
110b2002411SLois Curfman McInnes 
11163dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetKSP(SNES,KSP*);
1122999313aSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetKSP(SNES,KSP);
11363dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetSolution(SNES,Vec*);
11463dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetSolutionUpdate(SNES,Vec*);
11570e92668SMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetFunction(SNES,Vec*,PetscErrorCode(**)(SNES,Vec,Vec,void*),void**);
11663dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESView(SNES,PetscViewer);
1177bc3d0afSSatish Balay 
11863dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetOptionsPrefix(SNES,const char[]);
11963dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESAppendOptionsPrefix(SNES,const char[]);
12019dca363SMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetOptionsPrefix(SNES,const char*[]);
12163dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetFromOptions(SNES);
12240191667SLois Curfman McInnes 
123fef1beadSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT MatCreateSNESMF(SNES,Mat*);
124e884886fSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT MatMFFDComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
1258f6e3e37SBarry Smith 
12663dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT MatDAADSetSNES(Mat,SNES);
1273a7fca6bSBarry Smith 
128a313700dSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetType(SNES,const SNESType*);
129a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorDefault(SNES,PetscInt,PetscReal,void *);
130b271bb04SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorRange(SNES,PetscInt,PetscReal,void *);
131a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorRatio(SNES,PetscInt,PetscReal,void *);
132d86576fbSMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorSetRatio(SNES,PetscViewerASCIIMonitor);
133a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorSolution(SNES,PetscInt,PetscReal,void *);
134a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorResidual(SNES,PetscInt,PetscReal,void *);
135a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorSolutionUpdate(SNES,PetscInt,PetscReal,void *);
136a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorDefaultShort(SNES,PetscInt,PetscReal,void *);
13763dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetTolerances(SNES,PetscReal,PetscReal,PetscReal,PetscInt,PetscInt);
13863dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetTolerances(SNES,PetscReal*,PetscReal*,PetscReal*,PetscInt*,PetscInt*);
13963dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetTrustRegionTolerance(SNES,PetscReal);
14071f87433Sdalcinl EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetFunctionNorm(SNES,PetscReal*);
141b850b91aSLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetIterationNumber(SNES,PetscInt*);
1423d4c4710SBarry Smith 
143b850b91aSLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetNonlinearStepFailures(SNES,PetscInt*);
144b850b91aSLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetMaxNonlinearStepFailures(SNES,PetscInt);
145b850b91aSLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetMaxNonlinearStepFailures(SNES,PetscInt*);
1462541af92SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetNumberFunctionEvals(SNES,PetscInt*);
147b850b91aSLisandro Dalcin 
148a8054027SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetLagPreconditioner(SNES,PetscInt);
149a8054027SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetLagPreconditioner(SNES,PetscInt*);
150e35cf81dSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetLagJacobian(SNES,PetscInt);
151e35cf81dSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetLagJacobian(SNES,PetscInt*);
152a8054027SBarry Smith 
153b850b91aSLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetLinearSolveIterations(SNES,PetscInt*);
1543d4c4710SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetLinearSolveFailures(SNES,PetscInt*);
1553d4c4710SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetMaxLinearSolveFailures(SNES,PetscInt);
1563d4c4710SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetMaxLinearSolveFailures(SNES,PetscInt*);
1573d4c4710SBarry Smith 
158fa9f3622SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESKSPSetUseEW(SNES,PetscTruth);
159fa9f3622SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESKSPGetUseEW(SNES,PetscTruth*);
160fa9f3622SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESKSPSetParametersEW(SNES,PetscInt,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
161fa9f3622SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESKSPGetParametersEW(SNES,PetscInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
162eafb4bcbSBarry Smith 
163a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorLGCreate(const char[],const char[],int,int,int,int,PetscDrawLG*);
164a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorLG(SNES,PetscInt,PetscReal,void*);
165a6570f20SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorLGDestroy(PetscDrawLG);
166b271bb04SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorLGRangeCreate(const char[],const char[],int,int,int,int,PetscDrawLG*);
167b271bb04SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorLGRange(SNES,PetscInt,PetscReal,void*);
168b271bb04SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESMonitorLGRangeDestroy(PetscDrawLG);
169eafb4bcbSBarry Smith 
17063dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetApplicationContext(SNES,void *);
17163dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetApplicationContext(SNES,void **);
172184914b5SBarry Smith 
1731d6018f0SLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESPythonSetType(SNES,const char[]);
1741d6018f0SLisandro Dalcin 
1754936397dSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetFunctionDomainError(SNES);
176435da068SBarry Smith /*E
177435da068SBarry Smith     SNESConvergedReason - reason a SNES method was said to
178435da068SBarry Smith          have converged or diverged
179435da068SBarry Smith 
180435da068SBarry Smith    Level: beginner
181435da068SBarry Smith 
182f203c74bSBarry Smith    The two most common reasons for divergence are
183f203c74bSBarry Smith $   1) an incorrectly coded or computed Jacobian or
184f203c74bSBarry Smith $   2) failure or lack of convergence in the linear system (in this case we recommend
185f203c74bSBarry Smith $      testing with -pc_type lu to eliminate the linear solver as the cause of the problem).
186f203c74bSBarry Smith 
187f203c74bSBarry Smith    Diverged Reasons:
188f203c74bSBarry Smith .    SNES_DIVERGED_LOCAL_MIN - this can only occur when using the line-search variant of SNES.
189f203c74bSBarry Smith        The line search wants to minimize Q(alpha) = 1/2 || F(x + alpha s) ||^2_2  this occurs
190f203c74bSBarry Smith        at Q'(alpha) = s^T F'(x+alpha s)^T F(x+alpha s) = 0. If s is the Newton direction - F'(x)^(-1)F(x) then
191f203c74bSBarry Smith        you get Q'(alpha) = -F(x)^T F'(x)^(-1)^T F'(x+alpha s)F(x+alpha s); when alpha = 0
192f203c74bSBarry Smith        Q'(0) = - ||F(x)||^2_2 which is always NEGATIVE if F'(x) is invertible. This means the Newton
193f203c74bSBarry Smith        direction is a descent direction and the line search should succeed if alpha is small enough.
194f203c74bSBarry Smith 
195f203c74bSBarry Smith        If F'(x) is NOT invertible AND F'(x)^T F(x) = 0 then Q'(0) = 0 and the Newton direction
196f203c74bSBarry Smith        is NOT a descent direction so the line search will fail. All one can do at this point
197f203c74bSBarry Smith        is change the initial guess and try again.
198f203c74bSBarry Smith 
199f203c74bSBarry Smith        An alternative explanation: Newton's method can be regarded as replacing the function with
200f203c74bSBarry Smith        its linear approximation and minimizing the 2-norm of that. That is F(x+s) approx F(x) + F'(x)s
201f203c74bSBarry Smith        so we minimize || F(x) + F'(x) s ||^2_2; do this using Least Squares. If F'(x) is invertible then
202f203c74bSBarry Smith        s = - F'(x)^(-1)F(x) otherwise F'(x)^T F'(x) s = -F'(x)^T F(x). If F'(x)^T F(x) is NOT zero then there
203f203c74bSBarry Smith        exists a nontrival (that is F'(x)s != 0) solution to the equation and this direction is
204f203c74bSBarry Smith        s = - [F'(x)^T F'(x)]^(-1) F'(x)^T F(x) so Q'(0) = - F(x)^T F'(x) [F'(x)^T F'(x)]^(-T) F'(x)^T F(x)
205f203c74bSBarry Smith        = - (F'(x)^T F(x)) [F'(x)^T F'(x)]^(-T) (F'(x)^T F(x)). Since we are assuming (F'(x)^T F(x)) != 0
206f203c74bSBarry Smith        and F'(x)^T F'(x) has no negative eigenvalues Q'(0) < 0 so s is a descent direction and the line
207f203c74bSBarry Smith        search should succeed for small enough alpha.
208f203c74bSBarry Smith 
209f203c74bSBarry Smith        Note that this RARELY happens in practice. Far more likely the linear system is not being solved
210f203c74bSBarry Smith        (well enough?) or the Jacobian is wrong.
211f203c74bSBarry Smith 
2124d0a8057SBarry Smith    SNES_DIVERGED_MAX_IT means that the solver reached the maximum number of iterations without satisfying any
2134d0a8057SBarry Smith    convergence criteria. SNES_CONVERGED_ITS means that SNESSkipConverged() was chosen as the convergence test;
2144d0a8057SBarry Smith    thus the usual convergence criteria have not been checked and may or may not be satisfied.
215f203c74bSBarry Smith 
2164d0a8057SBarry Smith    Developer Notes: this must match finclude/petscsnes.h
2174d0a8057SBarry Smith 
2184d0a8057SBarry Smith        The string versions of these are in SNESConvergedReason, if you change any value here you must
2194d0a8057SBarry Smith      also adjust that array.
2205968eb51SBarry Smith 
22146a9e3ceSBarry Smith    Each reason has its own manual page.
22246a9e3ceSBarry Smith 
223435da068SBarry Smith .seealso: SNESSolve(), SNESGetConvergedReason(), KSPConvergedReason, SNESSetConvergenceTest()
224435da068SBarry Smith E*/
225184914b5SBarry Smith typedef enum {/* converged */
22601b82886SBarry Smith               SNES_CONVERGED_FNORM_ABS         =  2, /* ||F|| < atol */
22701b82886SBarry Smith               SNES_CONVERGED_FNORM_RELATIVE    =  3, /* ||F|| < rtol*||F_initial|| */
22846a9e3ceSBarry Smith               SNES_CONVERGED_PNORM_RELATIVE    =  4, /* Newton computed step size small; || delta x || < stol */
2293f149594SLisandro Dalcin               SNES_CONVERGED_ITS               =  5, /* maximum iterations reached */
230184914b5SBarry Smith               SNES_CONVERGED_TR_DELTA          =  7,
231184914b5SBarry Smith               /* diverged */
23246a9e3ceSBarry Smith               SNES_DIVERGED_FUNCTION_DOMAIN    = -1, /* the new x location passed the function is not in the domain of F */
233184914b5SBarry Smith               SNES_DIVERGED_FUNCTION_COUNT     = -2,
23446a9e3ceSBarry Smith               SNES_DIVERGED_LINEAR_SOLVE       = -3, /* the linear solve failed */
235184914b5SBarry Smith               SNES_DIVERGED_FNORM_NAN          = -4,
236184914b5SBarry Smith               SNES_DIVERGED_MAX_IT             = -5,
23746a9e3ceSBarry Smith               SNES_DIVERGED_LS_FAILURE         = -6, /* the line search failed */
23858c775ebSBarry Smith               SNES_DIVERGED_LOCAL_MIN          = -8, /* || J^T b || is small, implies converged to local minimum of F() */
239184914b5SBarry Smith               SNES_CONVERGED_ITERATING         =  0} SNESConvergedReason;
2409dcbbd2bSBarry Smith extern const char **SNESConvergedReasons;
241184914b5SBarry Smith 
242c838673bSBarry Smith /*MC
243c838673bSBarry Smith      SNES_CONVERGED_FNORM_ABS - 2-norm(F) <= abstol
244c838673bSBarry Smith 
245c838673bSBarry Smith    Level: beginner
246c838673bSBarry Smith 
247c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
248c838673bSBarry Smith 
249c838673bSBarry Smith M*/
250c838673bSBarry Smith 
251c838673bSBarry Smith /*MC
252c838673bSBarry Smith      SNES_CONVERGED_FNORM_RELATIVE - 2-norm(F) <= rtol*2-norm(F(x_0)) where x_0 is the initial guess
253c838673bSBarry Smith 
254c838673bSBarry Smith    Level: beginner
255c838673bSBarry Smith 
256c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
257c838673bSBarry Smith 
258c838673bSBarry Smith M*/
259c838673bSBarry Smith 
260c838673bSBarry Smith /*MC
26146a9e3ceSBarry Smith      SNES_CONVERGED_PNORM_RELATIVE - The 2-norm of the last step <= stol * 2-norm(x) where x is the current
26246a9e3ceSBarry Smith           solution and stol is the 4th argument to SNESSetTolerances()
263c838673bSBarry Smith 
264c838673bSBarry Smith    Level: beginner
265c838673bSBarry Smith 
266c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
267c838673bSBarry Smith 
268c838673bSBarry Smith M*/
269c838673bSBarry Smith 
270c838673bSBarry Smith /*MC
271c838673bSBarry Smith      SNES_DIVERGED_FUNCTION_COUNT - The user provided function has been called more times then the final
272c838673bSBarry Smith          argument to SNESSetTolerances()
273c838673bSBarry Smith 
274c838673bSBarry Smith    Level: beginner
275c838673bSBarry Smith 
276c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
277c838673bSBarry Smith 
278c838673bSBarry Smith M*/
279c838673bSBarry Smith 
280c838673bSBarry Smith /*MC
281c838673bSBarry Smith      SNES_DIVERGED_FNORM_NAN - the 2-norm of the current function evaluation is not-a-number (NaN), this
282c838673bSBarry Smith       is usually caused by a division of 0 by 0.
283c838673bSBarry Smith 
284c838673bSBarry Smith    Level: beginner
285c838673bSBarry Smith 
286c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
287c838673bSBarry Smith 
288c838673bSBarry Smith M*/
289c838673bSBarry Smith 
290c838673bSBarry Smith /*MC
291c838673bSBarry Smith      SNES_DIVERGED_MAX_IT - SNESSolve() has reached the maximum number of iterations requested
292c838673bSBarry Smith 
293c838673bSBarry Smith    Level: beginner
294c838673bSBarry Smith 
295c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
296c838673bSBarry Smith 
297c838673bSBarry Smith M*/
298c838673bSBarry Smith 
299c838673bSBarry Smith /*MC
300c838673bSBarry Smith      SNES_DIVERGED_LS_FAILURE - The line search has failed. This only occurs for a SNESType of SNESLS
301c838673bSBarry Smith 
302c838673bSBarry Smith    Level: beginner
303c838673bSBarry Smith 
304c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
305c838673bSBarry Smith 
306c838673bSBarry Smith M*/
307c838673bSBarry Smith 
308c838673bSBarry Smith /*MC
30946a9e3ceSBarry Smith      SNES_DIVERGED_LOCAL_MIN - the algorithm seems to have stagnated at a local minimum that is not zero.
31046a9e3ceSBarry Smith         See the manual page for SNESConvergedReason for more details
311c838673bSBarry Smith 
312c838673bSBarry Smith    Level: beginner
313c838673bSBarry Smith 
314c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
315c838673bSBarry Smith 
316c838673bSBarry Smith M*/
317c838673bSBarry Smith 
318c838673bSBarry Smith /*MC
319c838673bSBarry Smith      SNES_CONERGED_ITERATING - this only occurs if SNESGetConvergedReason() is called during the SNESSolve()
320c838673bSBarry Smith 
321c838673bSBarry Smith    Level: beginner
322c838673bSBarry Smith 
323c838673bSBarry Smith .seealso:  SNESSolve(), SNESGetConvergedReason(), SNESConvergedReason, SNESSetTolerances()
324c838673bSBarry Smith 
325c838673bSBarry Smith M*/
326c838673bSBarry Smith 
3277f7931b9SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetConvergenceTest(SNES,PetscErrorCode (*)(SNES,PetscInt,PetscReal,PetscReal,PetscReal,SNESConvergedReason*,void*),void*,PetscErrorCode (*)(void*));
3283f149594SLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDefaultConverged(SNES,PetscInt,PetscReal,PetscReal,PetscReal,SNESConvergedReason*,void*);
3293f149594SLisandro Dalcin EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSkipConverged(SNES,PetscInt,PetscReal,PetscReal,PetscReal,SNESConvergedReason*,void*);
33063dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetConvergedReason(SNES,SNESConvergedReason*);
331ddbbdb52SLois Curfman McInnes 
33263dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDAFormFunction(SNES,Vec,Vec,void*);
33363dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDAComputeJacobianWithAdic(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
33463dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDAComputeJacobianWithAdifor(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
33563dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDAComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
3363a7fca6bSBarry Smith 
337b67197daSBarry Smith /* --------- Solving systems of nonlinear equations --------------- */
33863dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetFunction(SNES,Vec,PetscErrorCode(*)(SNES,Vec,Vec,void*),void *);
33963dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESComputeFunction(SNES,Vec,Vec);
34063dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESSetJacobian(SNES,Mat,Mat,PetscErrorCode(*)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void *);
34170e92668SMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetJacobian(SNES,Mat*,Mat*,PetscErrorCode(**)(SNES,Vec,Mat*,Mat*,MatStructure*,void*),void **);
34263dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDefaultComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
34363dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESDefaultComputeJacobianColor(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
3441096aae1SMatthew Knepley EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESGetRhs(SNES,Vec*);
34517bae607SBarry Smith 
34617bae607SBarry Smith /* --------- Routines specifically for line search methods --------------- */
347dc357ad2SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchSet(SNES,PetscErrorCode(*)(SNES,void*,Vec,Vec,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal*,PetscReal*,PetscTruth*),void*);
348dc357ad2SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchNo(SNES,void*,Vec,Vec,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal*,PetscReal*,PetscTruth*);
349dc357ad2SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchNoNorms(SNES,void*,Vec,Vec,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal*,PetscReal*,PetscTruth*);
350dc357ad2SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchCubic(SNES,void*,Vec,Vec,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal*,PetscReal*,PetscTruth*);
351dc357ad2SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchQuadratic(SNES,void*,Vec,Vec,Vec,Vec,Vec,PetscReal,PetscReal,PetscReal*,PetscReal*,PetscTruth*);
352e56c5435SBarry Smith 
3533c632250SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchSetPostCheck(SNES,PetscErrorCode(*)(SNES,Vec,Vec,Vec,void*,PetscTruth*,PetscTruth*),void*);
3549c3ca13aSBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchSetPreCheck(SNES,PetscErrorCode(*)(SNES,Vec,Vec,void*,PetscTruth*),void*);
3559320bcb5SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchSetParams(SNES,PetscReal,PetscReal);
3569320bcb5SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchGetParams(SNES,PetscReal*,PetscReal*);
35794298653SBarry Smith EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESLineSearchSetMonitor(SNES,PetscTruth);
35840191667SLois Curfman McInnes 
359fa039afaSSatish Balay EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESTestLocalMin(SNES);
360da9b6338SBarry Smith 
361eef9c623SLois Curfman McInnes /* Should this routine be private? */
36263dd3a1aSKris Buschelman EXTERN PetscErrorCode PETSCSNES_DLLEXPORT SNESComputeJacobian(SNES,Vec,Mat*,Mat*,MatStructure*);
363ddbbdb52SLois Curfman McInnes 
3646c699258SBarry Smith EXTERN PetscErrorCode PETSCKSP_DLLEXPORT SNESSetDM(SNES,DM);
3656c699258SBarry Smith EXTERN PetscErrorCode PETSCKSP_DLLEXPORT SNESGetDM(SNES,DM*);
3666c699258SBarry Smith 
367e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
368ce3d82beSBarry Smith #endif
369