PETSc version 3.16.1

Nonlinear solvers - SNES: Examples

The Scalable Nonlinear Equations Solvers (SNES) component provides an easy-to-use interface to Newton-type, quasi-Newton, full approximation scheme (FAS) multigrid, and other methods for solving systems of nonlinear equations. SNES users can set various algorithmic options at runtime via the options database (e.g., specifying a trust region method via -snes_type newtontr ). SNES internally employs KSP for the solution of its linear systems. SNES users can also set KSP options directly in application codes by first extracting the KSP context from the SNES context via SNESGetKSP() and then directly calling various KSP (and PC) routines (e.g., PCSetType() ).

Beginner - Basic usage
DMAdaptorCreate SNESANDERSON SNESQNSetType
DMAdaptorDestroy SNESConvergedReason SNESResetFromOptions
DMAdaptorSetFromOptions SNESConvergedReasonView SNESSetFromOptions
DMAdaptorSetUp SNESCreate SNESSetFunction
DMAdaptorView SNESDestroy SNESSetJacobian
DMDASNESSetFunctionLocal SNESFASType SNESSetSolution
DMDASNESSetJacobianLocal SNESGetConvergedReasonString SNESSolve
DMDASNESSetObjectiveLocal SNESGetKSP SNESType
DMDASNESSetPicardLocal SNESGetLineSearch SNESVINEWTONRSLS
DMInterpolationCreate SNESKSPONLY SNESVINEWTONSSLS
DMInterpolationDestroy SNESKSPTRANSPOSEONLY SNESView
DMInterpolationEvaluate SNESLineSearch SNES_CONERGED_ITERATING
DMSNESGetFunctionLocal SNESLineSearchType SNES_CONVERGED_FNORM_ABS
DMSNESGetJacobianLocal SNESMS SNES_CONVERGED_FNORM_RELATIVE
DMSNESSetFunctionLocal SNESMSGetType SNES_CONVERGED_SNORM_RELATIVE
DMSNESSetJacobianLocal SNESMSSetType SNES_DIVERGED_DTOL
PetscConvEstCreate SNESMULTIBLOCK SNES_DIVERGED_FNORM_NAN
PetscConvEstDestroy SNESNCG SNES_DIVERGED_FUNCTION_COUNT
PetscConvEstSetFromOptions SNESNEWTONLS SNES_DIVERGED_LINE_SEARCH
PetscConvEstSetUp SNESNGMRES SNES_DIVERGED_LOCAL_MIN
PetscConvEstView SNESNRICHARDSON SNES_DIVERGED_MAX_IT
SNES SNESQN
Intermediate - Setting options for algorithms and data structures
DMAdaptorAdapt SNESGetNumberFunctionEvals SNESNASMGetNumber
DMAdaptorGetSequenceLength SNESGetRhs SNESNASMGetSNES
DMAdaptorGetSolver SNESGetSolution SNESNASMGetSubdomains
DMAdaptorSetSequenceLength SNESGetTolerances SNESNASMGetType
DMAdaptorSetSolver SNESGetType SNESNASMSetDamping
DMInterpolationAddPoints SNESGetUseMatrixFree SNESNASMSetSubdomains
DMInterpolationGetCoordinates SNESJacobianFunction SNESNASMSetType
DMInterpolationGetDim SNESLineSearchApply SNESNASMSetWeight
DMInterpolationGetDof SNESLineSearchBTGetAlpha SNESNCGSetType
DMInterpolationGetVector SNESLineSearchBTSetAlpha SNESNEWTONTR
DMInterpolationRestoreVector SNESLineSearchComputeNorms SNESNGMRESSetRestartFmRise
DMInterpolationSetDim SNESLineSearchGetDefaultMonitor SNESNGMRESSetRestartType
DMInterpolationSetDof SNESLineSearchGetOrder SNESNGMRESSetSelectType
DMInterpolationSetUp SNESLineSearchGetPostCheck SNESNGSFunction
DMSNESGetBoundaryLocal SNESLineSearchGetPreCheck SNESNGSGetSweeps
DMSNESSetBoundaryLocal SNESLineSearchGetReason SNESNGSGetTolerances
KSPMonitorSNESResidual SNESLineSearchGetTolerances SNESNGSSetSweeps
KSPMonitorSNESResidualDrawLG SNESLineSearchGetType SNESNGSSetTolerances
KSPMonitorSNESResidualDrawLGCreate SNESLineSearchMonitorCancel SNESNewtonTRGetPostCheck
PetscConvEstGetConvRate SNESLineSearchMonitorSet SNESNewtonTRGetPreCheck
PetscConvEstGetSolver SNESLineSearchMonitorSolutionUpdate SNESNewtonTRSetPostCheck
PetscConvEstMonitorDefault SNESLineSearchReason SNESNewtonTRSetPreCheck
PetscConvEstSetSolver SNESLineSearchSetComputeNorms SNESPATCH
SNESASPIN SNESLineSearchSetDamping SNESPythonSetType
SNESCOMPOSITE SNESLineSearchSetDefaultMonitor SNESQNSetRestartType
SNESComputeJacobianDefault SNESLineSearchSetFromOptions SNESQNSetScaleType
SNESComputeJacobianDefaultColor SNESLineSearchSetOrder SNESReset
SNESConvergedDefault SNESLineSearchSetPostCheck SNESSetApplicationContext
SNESConvergedReasonViewCancel SNESLineSearchSetPreCheck SNESSetComputeApplicationContext
SNESConvergedReasonViewFromOptions SNESLineSearchSetTolerances SNESSetComputeInitialGuess
SNESConvergedReasonViewSet SNESLineSearchSetType SNESSetConvergedReason
SNESConvergenceTestFunction SNESLineSearchView SNESSetConvergenceHistory
SNESFunction SNESLoad SNESSetDM
SNESGetApplicationContext SNESMSType SNESSetDivergenceTolerance
SNESGetConvergedReason SNESMonitorCancel SNESSetErrorIfNotConverged
SNESGetConvergenceHistory SNESMonitorDefault SNESSetForceIteration
SNESGetDM SNESMonitorDefaultField SNESSetGridSequence
SNESGetDivergenceTolerance SNESMonitorFields SNESSetLagJacobian
SNESGetErrorIfNotConverged SNESMonitorRange SNESSetLagPreconditioner
SNESGetForceIteration SNESMonitorRatio SNESSetMaxLinearSolveFailures
SNESGetGridSequence SNESMonitorRatioSetUp SNESSetMaxNonlinearStepFailures
SNESGetIterationNumber SNESMonitorResidual SNESSetNGS
SNESGetLagJacobian SNESMonitorScaling SNESSetNPCSide
SNESGetLagPreconditioner SNESMonitorSet SNESSetObjective
SNESGetLinearSolveFailures SNESMonitorSolution SNESSetPicard
SNESGetLinearSolveIterations SNESMonitorSolutionUpdate SNESSetTolerances
SNESGetMaxLinearSolveFailures SNESMultiblockSetBlockSize SNESSetTrustRegionTolerance
SNESGetMaxNonlinearStepFailures SNESMultiblockSetFields SNESSetType
SNESGetNPCSide SNESMultiblockSetIS SNESSetUseMatrixFree
SNESGetNonlinearStepFailures SNESNASMGetDamping SNESViewFromOptions
Advanced - Setting more advanced options and customization
DMSNESCreateJacobianMF SNESGetOptionsPrefix SNESMSSetDamping
DMSNESGetFunction SNESGetPicard SNESMatrixFreeCreate2
DMSNESGetJacobian SNESGetSolutionUpdate SNESMonitorFunction
DMSNESGetNGS SNESKSPGetParametersEW SNESMonitorSAWs
DMSNESGetObjective SNESKSPGetUseEW SNESMultiblockGetSubSNES
DMSNESGetPicard SNESKSPSetParametersEW SNESNASM
DMSNESSetFunction SNESKSPSetUseEW SNESNGS
DMSNESSetJacobian SNESLINESEARCHBASIC SNESNormSchedule
DMSNESSetMFFunction SNESLINESEARCHBT SNESObjectiveComputeFunctionDefaultFD
DMSNESSetNGS SNESLINESEARCHCP SNESObjectiveFunction
DMSNESSetObjective SNESLINESEARCHL2 SNESRegister
DMSNESSetPicard SNESLINESEARCHNCGLINEAR SNESRegisterAll
MatCreateSNESMF SNESLINESEARCHNLEQERR SNESSHELL
MatSNESMFGetReuseBase SNESLINESEARCHSHELL SNESSetAlwaysComputesFinalResidual
MatSNESMFGetSNES SNESLineSearchAppendOptionsPrefix SNESSetCheckJacobianDomainError
MatSNESMFSetReuseBase SNESLineSearchGetDamping SNESSetConvergenceTest
SNESAppendOptionsPrefix SNESLineSearchGetLambda SNESSetFunctionDomainError
SNESComputeObjective SNESLineSearchGetOptionsPrefix SNESSetJacobianDomainError
SNESConvergedCorrectPressure SNESLineSearchGetVecs SNESSetOptionsPrefix
SNESConvergedSkip SNESLineSearchPreCheckPicard SNESSetUp
SNESDefaultMatrixFreeSetParameters2 SNESLineSearchRegister SNESSetUpdate
SNESFunctionType SNESLineSearchRegisterAll SNESShellGetContext
SNESGetAlwaysComputesFinalResidual SNESLineSearchSetLambda SNESShellSetContext
SNESGetCheckJacobianDomainError SNESLineSearchSetNorms SNESShellSetSolve
SNESGetFunction SNESLineSearchSetUp SNESVISetComputeVariableBounds
SNESGetFunctionDomainError SNESLineSearchSetVecs SNESVISetVariableBounds
SNESGetFunctionType SNESLineSearchShellGetUserFunc SNES_NORM_ALWAYS
SNESGetJacobian SNESLineSearchShellSetUserFunc SNES_NORM_FINAL_ONLY
SNESGetJacobianDomainError SNESMSGetDamping SNES_NORM_INITIAL_FINAL_ONLY
SNESGetNGS SNESMSRegister SNES_NORM_INITIAL_ONLY
SNESGetNormSchedule SNESMSRegisterAll SNES_NORM_NONE
SNESGetObjective SNESMSRegisterDestroy
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
DMCopyDMSNES SNESComputeNGS SNESMSInitializePackage
DMGetDMSNES SNESFinalizePackage SNESMonitor
DMGetDMSNESWrite SNESGetFunctionNorm SNESMonitorSAWsCreate
DMPlexSNESComputeBoundaryFEM SNESGetNPC SNESMonitorSAWsDestroy
DMPlexSNESComputeJacobianFEM SNESGetNPCFunction SNESMonitorSetFromOptions
DMPlexSNESComputeResidualFEM SNESGetSolutionNorm SNESMultiblockSetType
DMPlexSetSNESLocalFEM SNESGetUpdateNorm SNESNASMGetSubdomainVecs
DMSNESCheckDiscretization SNESHasNPC SNESNASMSetComputeFinalJacobian
DMSNESCheckFromOptions SNESInitializePackage SNESNewtonTRPostCheck
DMSNESCheckJacobian SNESLineSearchCreate SNESNewtonTRPreCheck
DMSNESCheckResidual SNESLineSearchDestroy SNESSetCountersReset
DMSNESComputeJacobianAction SNESLineSearchGetNorms SNESSetFunctionNorm
DMSNESCopy SNESLineSearchGetSNES SNESSetFunctionType
MatMFFDComputeJacobian SNESLineSearchGetVIFunctions SNESSetInitialFunction
PetscConvEstRateView SNESLineSearchMonitor SNESSetIterationNumber
SNESAddOptionsChecker SNESLineSearchMonitorSetFromOptions SNESSetKSP
SNESApplyNPC SNESLineSearchPostCheck SNESSetLagJacobianPersists
SNESCompositeAddSNES SNESLineSearchPreCheck SNESSetLagPreconditionerPersists
SNESCompositeGetNumber SNESLineSearchReset SNESSetLineSearch
SNESCompositeGetSNES SNESLineSearchSetFunction SNESSetNPC
SNESCompositeSetDamping SNESLineSearchSetReason SNESSetNormSchedule
SNESCompositeSetType SNESLineSearchSetSNES SNESSetUpMatrices
SNESComputeFunction SNESLineSearchSetVIFunctions SNESSetWorkVecs
SNESComputeJacobian SNESLineSearchSetWorkVecs
SNESComputeMFFunction SNESMSFinalizePackage
No deprecated routines

Table of Contents