SNESNewtonTRFallbackType#
type of fallback in case the solution of the trust-region subproblem is outside of the radius
Synopsis#
typedef enum {
SNES_TR_FALLBACK_NEWTON,
SNES_TR_FALLBACK_CAUCHY,
SNES_TR_FALLBACK_DOGLEG,
} SNESNewtonTRFallbackType;
Values#
SNES_TR_FALLBACK_NEWTON
- use scaled Newton stepSNES_TR_FALLBACK_CAUCHY
- use Cauchy directionSNES_TR_FALLBACK_DOGLEG
- use dogleg method E*/ typedef enum { SNES_TR_FALLBACK_NEWTON, SNES_TR_FALLBACK_CAUCHY, SNES_TR_FALLBACK_DOGLEG, } SNESNewtonTRFallbackType;
PETSC_EXTERN const char *const SNESNewtonTRFallbackTypes[];
PETSC_EXTERN PetscErrorCode SNESNewtonTRSetPreCheck(SNES, PetscErrorCode (*)(SNES, Vec, Vec, PetscBool *, void *), void *ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRGetPreCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, PetscBool *, void ), void **ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRSetPostCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void *ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRGetPostCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void **ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRSetFallbackType(SNES, SNESNewtonTRFallbackType); PETSC_EXTERN PetscErrorCode SNESNewtonTRPreCheck(SNES, Vec, Vec, PetscBool *); PETSC_EXTERN PetscErrorCode SNESNewtonTRPostCheck(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *);
/* TRDC API, to be removed after 3.19 */ PETSC_EXTERN PetscErrorCode SNESNewtonTRDCGetRhoFlag(SNES, PetscBool ); PETSC_EXTERN PetscErrorCode SNESNewtonTRDCSetPreCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, PetscBool *, void *), void *ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRDCGetPreCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, PetscBool *, void ), void **ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRDCSetPostCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void *ctx); PETSC_EXTERN PetscErrorCode SNESNewtonTRDCGetPostCheck(SNES, PetscErrorCode ()(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *), void **ctx);
PETSC_EXTERN PetscErrorCode SNESGetNonlinearStepFailures(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESSetMaxNonlinearStepFailures(SNES, PetscInt); PETSC_EXTERN PetscErrorCode SNESGetMaxNonlinearStepFailures(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESGetNumberFunctionEvals(SNES, PetscInt *);
PETSC_EXTERN PetscErrorCode SNESSetLagPreconditioner(SNES, PetscInt); PETSC_EXTERN PetscErrorCode SNESGetLagPreconditioner(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESSetLagJacobian(SNES, PetscInt); PETSC_EXTERN PetscErrorCode SNESGetLagJacobian(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESSetLagPreconditionerPersists(SNES, PetscBool); PETSC_EXTERN PetscErrorCode SNESSetLagJacobianPersists(SNES, PetscBool); PETSC_EXTERN PetscErrorCode SNESSetGridSequence(SNES, PetscInt); PETSC_EXTERN PetscErrorCode SNESGetGridSequence(SNES, PetscInt *);
PETSC_EXTERN PetscErrorCode SNESGetLinearSolveIterations(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESGetLinearSolveFailures(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESSetMaxLinearSolveFailures(SNES, PetscInt); PETSC_EXTERN PetscErrorCode SNESGetMaxLinearSolveFailures(SNES, PetscInt *); PETSC_EXTERN PetscErrorCode SNESSetCountersReset(SNES, PetscBool);
PETSC_EXTERN PetscErrorCode SNESKSPSetUseEW(SNES, PetscBool); PETSC_EXTERN PetscErrorCode SNESKSPGetUseEW(SNES, PetscBool *); PETSC_EXTERN PetscErrorCode SNESKSPSetParametersEW(SNES, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal); PETSC_EXTERN PetscErrorCode SNESKSPGetParametersEW(SNES, PetscInt *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, PetscReal *);
#include <petscdrawtypes.h> PETSC_EXTERN PetscErrorCode SNESMonitorLGRange(SNES, PetscInt, PetscReal, void *);
PETSC_EXTERN PetscErrorCode SNESSetApplicationContext(SNES, void ); PETSC_EXTERN PetscErrorCode SNESGetApplicationContext(SNES, void ); PETSC_EXTERN PetscErrorCode SNESSetComputeApplicationContext(SNES, PetscErrorCode ()(SNES, void **), PetscErrorCode ()(void **));
PETSC_EXTERN PetscErrorCode SNESPythonSetType(SNES, const char[]); PETSC_EXTERN PetscErrorCode SNESPythonGetType(SNES, const char *[]);
PETSC_EXTERN PetscErrorCode SNESSetFunctionDomainError(SNES); PETSC_EXTERN PetscErrorCode SNESGetFunctionDomainError(SNES, PetscBool *); PETSC_EXTERN PetscErrorCode SNESGetJacobianDomainError(SNES, PetscBool *); PETSC_EXTERN PetscErrorCode SNESSetJacobianDomainError(SNES); PETSC_EXTERN PetscErrorCode SNESSetCheckJacobianDomainError(SNES, PetscBool); PETSC_EXTERN PetscErrorCode SNESGetCheckJacobianDomainError(SNES, PetscBool *);
#define SNES_CONVERGED_TR_DELTA_DEPRECATED SNES_CONVERGED_TR_DELTA PETSC_DEPRECATED_ENUM(“Use SNES_DIVERGED_TR_DELTA (since version 3.12)”)
/*E
SNESConvergedReason - reason a SNESSolve()
was determined to have converged or diverged
Values#
SNES_CONVERGED_FNORM_ABS
- 2-norm(F) <= abstolSNES_CONVERGED_FNORM_RELATIVE
- 2-norm(F) <= rtol*2-norm(F(x_0)) where x_0 is the initial guessSNES_CONVERGED_SNORM_RELATIVE
- The 2-norm of the last step <= stol * 2-norm(x) where x is the currentSNES_DIVERGED_FUNCTION_COUNT
- The user provided function has been called more times than the maximum set inSNESSetTolerances()
SNES_DIVERGED_DTOL
- The norm of the function has increased by a factor of divtol set withSNESSetDivergenceTolerance()
SNES_DIVERGED_FNORM_NAN
- the 2-norm of the current function evaluation is not-a-number (NaN), this is usually caused by a division of 0 by 0.SNES_DIVERGED_MAX_IT
-SNESSolve()
has reached the maximum number of iterations requestedSNES_DIVERGED_LINE_SEARCH
- The line search has failed. This only occurs forSNES
solvers that use a line searchSNES_DIVERGED_LOCAL_MIN
- the algorithm seems to have stagnated at a local minimum that is not zero.SNES_CONERGED_ITERATING
- this only occurs ifSNESGetConvergedReason()
is called during theSNESSolve()
Notes#
The two most common reasons for divergence are an incorrectly coded or computed Jacobian or failure or lack of convergence in the linear system (in this case we recommend
testing with -pc_type lu
to eliminate the linear solver as the cause of the problem).
SNES_DIVERGED_LOCAL_MIN
can only occur when using the line-search variant of SNES
.
The line search wants to minimize Q(alpha) = 1/2 || F(x + alpha s) ||^2_2 this occurs
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
you get Q’(alpha) = -F(x)^T F’(x)^(-1)^T F’(x+alpha s)F(x+alpha s); when alpha = 0
Q’(0) = - ||F(x)||^2_2 which is always NEGATIVE if F’(x) is invertible. This means the Newton
direction is a descent direction and the line search should succeed if alpha is small enough.
If F’(x) is NOT invertible AND F’(x)^T F(x) = 0 then Q’(0) = 0 and the Newton direction is NOT a descent direction so the line search will fail. All one can do at this point is change the initial guess and try again.
An alternative explanation: Newton’s method can be regarded as replacing the function with its linear approximation and minimizing the 2-norm of that. That is F(x+s) approx F(x) + F’(x)s so we minimize || F(x) + F’(x) s ||^2_2; do this using Least Squares. If F’(x) is invertible then 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 exists a nontrivial (that is F’(x)s != 0) solution to the equation and this direction is 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) = - (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 and F’(x)^T F’(x) has no negative eigenvalues Q’(0) < 0 so s is a descent direction and the line search should succeed for small enough alpha.
Note that this RARELY happens in practice. Far more likely the linear system is not being solved (well enough?) or the Jacobian is wrong.
SNES_DIVERGED_MAX_IT
means that the solver reached the maximum number of iterations without satisfying any
convergence criteria. SNES_CONVERGED_ITS
means that SNESConvergedSkip()
was chosen as the convergence test;
thus the usual convergence criteria have not been checked and may or may not be satisfied.
See Also#
SNES: Nonlinear Solvers, SNES
, SNESSolve()
, SNESGetConvergedReason()
, KSPConvergedReason
, SNESSetConvergenceTest()
, SNESSetTolerances()
Level#
intermediate
Location#
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages