SNES - Low-level Interface

This page documents the low-level, automatically wrapped PETSc SNES (Scalable Nonlinear Equations Solvers) functions available through LibPETSc. These functions provide direct access to the PETSc C API.

For the high-level Julia interface, see SNES.

Overview

The SNES interface includes:

  • Core SNES operations: Nonlinear solver creation, configuration, and solution (~283 functions in SNES_wrappers.jl)
  • SNESLineSearch: Line search methods for nonlinear solvers (~50 functions in SNESLineSearch_wrappers.jl)

Usage

All low-level SNES functions require a petsclib parameter as the first argument:

using PETSc

# Get the library instance
petsclib = PETSc.petsclibs[1]
PETSc.initialize(petsclib)

# Get PETSc types
PetscInt = petsclib.PetscInt

# Create SNES solver
snes = LibPETSc.SNESCreate(petsclib, LibPETSc.PETSC_COMM_SELF)

# Set function and Jacobian (callbacks would need to be defined)
# LibPETSc.SNESSetFunction(petsclib, snes, r, compute_function, ctx)
# LibPETSc.SNESSetJacobian(petsclib, snes, J, J, compute_jacobian, ctx)

# Configure from command line
LibPETSc.SNESSetFromOptions(petsclib, snes)

# Solve
# LibPETSc.SNESSolve(petsclib, snes, C_NULL, x)

# Get convergence info
reason = LibPETSc.SNESGetConvergedReason(petsclib, snes)

iterations = LibPETSc.SNESGetIterationNumber(petsclib, snes)

println("SNES reason: $(reason), iterations: $(iterations)")

# Clean up
LibPETSc.SNESDestroy(petsclib, snes)
PETSc.finalize(petsclib)

Function Reference

PETSc.LibPETSc.SNESAddOptionsChecker — Method
SNESAddOptionsChecker(petsclib::PetscLibType, snescheck::external)

Adds an additional function to check for SNES options.

Not Collective

Input Parameter:

  • snescheck - function that checks for options

Calling sequence of snescheck:

  • snes - the SNES object for which it is checking options

Level: developer

See also: SNES, SNESSetFromOptions()

External Links

source
PETSc.LibPETSc.SNESAppendOptionsPrefix — Method
SNESAppendOptionsPrefix(petsclib::PetscLibType, snes::AbstractSNES, prefix::String)

Appends to the prefix used for searching for all SNES options in the database.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • prefix - the prefix to prepend to all option names

Level: advanced

See also: SNESGetOptionsPrefix(), SNESSetOptionsPrefix()

External Links

source
PETSc.LibPETSc.SNESApplyNPC — Method
SNESApplyNPC(petsclib::PetscLibType, snes::AbstractSNES, x::AbstractPetscVec, f::AbstractPetscVec, y::AbstractPetscVec)

Calls SNESSolve() on the preconditioner for the SNES

Collective

Input Parameters:

  • snes - the SNES context
  • x - input vector
  • f - optional; the function evaluation on x

Output Parameter:

  • y - function vector, as set by SNESSetFunction()

Level: developer

See also: SNES, SNESGetNPC(), SNESSetNPC(), SNESComputeFunction()

External Links

source
PETSc.LibPETSc.SNESCompositeAddSNES — Method
SNESCompositeAddSNES(petsclib::PetscLibType, snes::AbstractSNES, type::String)

Adds another SNES to the SNESCOMPOSITE

Collective

Input Parameters:

  • snes - the SNES context of type SNESCOMPOSITE
  • type - the SNESType of the new solver

Level: developer

See also: SNES, SNESCOMPOSITE, SNESCompositeGetSNES()

External Links

source
PETSc.LibPETSc.SNESCompositeGetNumber — Method
n::PetscInt = SNESCompositeGetNumber(petsclib::PetscLibType, snes::AbstractSNES)

Get the number of subsolvers in the SNESCOMPOSITE

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • n - the number of subsolvers

Level: developer

See also: SNES, SNESCOMPOSITE, SNESCompositeAddSNES(), SNESCompositeGetSNES()

External Links

source
PETSc.LibPETSc.SNESCompositeGetSNES — Method
subsnes::SNES = SNESCompositeGetSNES(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt)

Gets one of the SNES objects in the SNES of SNESType SNESCOMPOSITE

Not Collective

Input Parameters:

  • snes - the SNES context
  • n - the number of the composed SNES requested

Output Parameter:

  • subsnes - the SNES requested

Level: developer

See also: SNES, SNESCOMPOSITE, SNESCompositeAddSNES(), SNESCompositeGetNumber()

External Links

source
PETSc.LibPETSc.SNESCompositeSetDamping — Method
SNESCompositeSetDamping(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt, dmp::PetscReal)

Sets the damping of a subsolver when using SNES_COMPOSITE_ADDITIVE with a SNES of SNESType SNESCOMPOSITE

Not Collective

Input Parameters:

  • snes - the SNES context
  • n - the number of the sub-SNES object requested
  • dmp - the damping

Level: intermediate

See also: SNES, SNESCOMPOSITE, SNESCompositeAddSNES(), SNESCompositeGetSNES(), SNES_COMPOSITE_ADDITIVE, SNES_COMPOSITE_MULTIPLICATIVE, SNESCompositeType, SNESCompositeSetType()

External Links

source
PETSc.LibPETSc.SNESCompositeSetType — Method
SNESCompositeSetType(petsclib::PetscLibType, snes::AbstractSNES, type::SNESCompositeType)

Sets the type of composite preconditioner.

Logically Collective

Input Parameters:

  • snes - the preconditioner context
  • type - SNES_COMPOSITE_ADDITIVE (default), SNES_COMPOSITE_MULTIPLICATIVE, or SNES_COMPOSITE_ADDITIVEOPTIMAL

Options Database Key:

  • -snes_composite_type (multiplicative|additive|additive_optimal) - Sets composite preconditioner type

Level: developer

See also: SNES_COMPOSITE_ADDITIVE, SNES_COMPOSITE_MULTIPLICATIVE, SNESCompositeType, SNESCOMPOSITE, SNES_COMPOSITE_ADDITIVEOPTIMAL, PCCompositeType

External Links

source
PETSc.LibPETSc.SNESComputeFunction — Method
SNESComputeFunction(petsclib::PetscLibType, snes::AbstractSNES, x::AbstractPetscVec, f::AbstractPetscVec)

Calls the function that has been set with SNESSetFunction().

Collective

Input Parameters:

  • snes - the SNES context
  • x - input vector

Output Parameter:

  • f - function vector, as set by SNESSetFunction()

Level: developer

See also: SNES, SNESSetFunction(), SNESGetFunction(), SNESComputeMFFunction(), SNESSetFunctionDomainError()

External Links

source
PETSc.LibPETSc.SNESComputeFunctionDefaultNPC — Method
SNESComputeFunctionDefaultNPC(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, F::AbstractPetscVec)

Compute the residual by applying the attached nonlinear preconditioner when one is present, otherwise defer to SNESComputeFunction()

Collective

Input Parameters:

  • snes - the SNES context
  • X - the current iterate

Output Parameter:

  • F - the residual vector produced by the nonlinear preconditioner (or the standard function evaluation)

Level: developer

See also: SNES, SNESSetNPC(), SNESApplyNPC(), SNESComputeFunction(), SNESGetNPCFunction()

External Links

source
PETSc.LibPETSc.SNESComputeJacobian — Method
SNESComputeJacobian(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, A::AbstractPetscMat, B::AbstractPetscMat)

Computes the Jacobian matrix that has been set with SNESSetJacobian().

Collective

Input Parameters:

  • snes - the SNES context
  • X - input vector

Output Parameters:

  • A - Jacobian matrix
  • B - optional matrix for building the preconditioner, usually the same as A

Options Database Keys:

  • -snes_lag_preconditioner lag - how often to rebuild preconditioner
  • -snes_lag_jacobian lag - how often to rebuild Jacobian
  • -snes_test_jacobian [threshold] - compare the user provided Jacobian with one compute via finite differences to check for errors.

If a threshold is given, display only those entries whose difference is greater than the threshold.

  • -snes_test_jacobian_view [viewer] - display the user provided Jacobian, the finite difference Jacobian and the difference between them to help users detect the location of errors in the user provided Jacobian
  • -snes_compare_explicit - Compare the computed Jacobian to the finite difference Jacobian and output the differences
  • -snes_compare_explicit_draw - Compare the computed Jacobian to the finite difference Jacobian and draw the result
  • -snes_compare_explicit_contour - Compare the computed Jacobian to the finite difference Jacobian and draw a contour plot with the result
  • -snes_compare_operator - Make the comparison options above use the operator instead of the matrix used to construct the preconditioner
  • -snes_compare_coloring - Compute the finite difference Jacobian using coloring and display norms of difference
  • -snes_compare_coloring_display - Compute the finite difference Jacobian using coloring and display verbose differences
  • -snes_compare_coloring_threshold - Display only those matrix entries that differ by more than a given threshold
  • -snes_compare_coloring_threshold_atol - Absolute tolerance for difference in matrix entries to be displayed by -snes_compare_coloring_threshold
  • -snes_compare_coloring_threshold_rtol - Relative tolerance for difference in matrix entries to be displayed by -snes_compare_coloring_threshold
  • -snes_compare_coloring_draw - Compute the finite difference Jacobian using coloring and draw differences
  • -snes_compare_coloring_draw_contour - Compute the finite difference Jacobian using coloring and show contours of matrices and differences

Level: developer

See also: SNESSetJacobian(), KSPSetOperators(), MatStructure, SNESSetLagPreconditioner(), SNESSetLagJacobian(), SNESSetJacobianDomainError(), SNESCheckJacobianDomainError(), SNESSetCheckJacobianDomainError()

External Links

source
PETSc.LibPETSc.SNESComputeJacobianDefault — Method
SNESComputeJacobianDefault(petsclib::PetscLibType, snes::AbstractSNES, x1::AbstractPetscVec, J::AbstractPetscMat, B::AbstractPetscMat, ctx::Ptr{Cvoid})

Computes the Jacobian using finite differences.

Collective

Input Parameters:

  • snes - the SNES context
  • x1 - compute Jacobian at this point
  • ctx - application's function context, as set with SNESSetFunction()

Output Parameters:

  • J - Jacobian matrix (not altered in this routine)
  • B - newly computed Jacobian matrix to use with preconditioner (generally the same as J)

Options Database Keys:

  • -snes_fd - Activates SNESComputeJacobianDefault()
  • -snes_fd_coloring - Activates a faster computation that uses a graph coloring of the matrix
  • -snes_test_err etol - Square root of function error tolerance, default square root of machine

epsilon (1.e-8 in double, 3.e-4 in single)

  • -mat_fd_type (wp|ds) - See MATMFFD_WP and MATMFFD_DS

Level: intermediate

See also: SNES, SNESSetJacobian(), SNESComputeJacobianDefaultColor(), MatCreateSNESMF()

External Links

source
PETSc.LibPETSc.SNESComputeJacobianDefaultColor — Method
SNESComputeJacobianDefaultColor(petsclib::PetscLibType, snes::AbstractSNES, x1::AbstractPetscVec, J::AbstractPetscMat, B::AbstractPetscMat, ctx::Ptr{Cvoid})

Computes the Jacobian using finite differences and coloring to exploit matrix sparsity.

Collective

Input Parameters:

  • snes - nonlinear solver object
  • x1 - location at which to evaluate Jacobian
  • ctx - MatFDColoring context or NULL

Output Parameters:

  • J - Jacobian matrix (not altered in this routine)
  • B - newly computed Jacobian matrix to use with preconditioner (generally the same as J)

Options Database Keys:

  • -snes_fd_color_use_mat - use a matrix coloring from the explicit matrix nonzero pattern instead of from the DM providing the matrix
  • -snes_fd_color - Activates SNESComputeJacobianDefaultColor() in SNESSetFromOptions()
  • -mat_fd_coloring_err err - Sets err (square root of relative error in the function)
  • -mat_fd_coloring_umin umin - Sets umin, the minimum allowable u-value magnitude
  • -mat_fd_type - Either wp or ds (see MATMFFD_WP or MATMFFD_DS)
  • -snes_mf_operator - Use matrix-free application of Jacobian
  • -snes_mf - Use matrix-free Jacobian with no explicit Jacobian representation

See also: SNES, SNESSetJacobian(), SNESTestJacobian(), SNESComputeJacobianDefault(), SNESSetUseMatrixFree(), MatFDColoringCreate(), MatFDColoringSetFunction()

External Links

source
PETSc.LibPETSc.SNESComputeMFFunction — Method
SNESComputeMFFunction(petsclib::PetscLibType, snes::AbstractSNES, x::AbstractPetscVec, y::AbstractPetscVec)

Calls the function that has been set with DMSNESSetMFFunction().

Collective

Input Parameters:

  • snes - the SNES context
  • x - input vector

Output Parameter:

  • y - output vector

Level: developer

See also: SNES, SNESSetFunction(), SNESGetFunction(), SNESComputeFunction(), MatCreateSNESMF(), DMSNESSetMFFunction()

External Links

source
PETSc.LibPETSc.SNESComputeNGS — Method
SNESComputeNGS(petsclib::PetscLibType, snes::AbstractSNES, b::AbstractPetscVec, x::AbstractPetscVec)

Calls the Gauss-Seidel function that has been set with SNESSetNGS().

Collective

Input Parameters:

  • snes - the SNES context
  • x - input vector
  • b - rhs vector

Output Parameter:

  • x - new solution vector

Level: developer

See also: SNESNGSFn, SNESSetNGS(), SNESComputeFunction(), SNESNGS

External Links

source
PETSc.LibPETSc.SNESComputeObjective — Method
ob::PetscReal = SNESComputeObjective(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec)

Computes the objective function that has been provided by SNESSetObjective()

Collective

Input Parameters:

  • snes - the SNES context
  • X - the state vector

Output Parameter:

  • ob - the objective value

Level: developer

See also: SNESLineSearch, SNES, SNESSetObjective(), SNESGetSolution()

External Links

source
PETSc.LibPETSc.SNESConverged — Method
SNESConverged(petsclib::PetscLibType, snes::AbstractSNES, it::PetscInt, xnorm::PetscReal, snorm::PetscReal, fnorm::PetscReal)

Run the convergence test and update the SNESConvergedReason.

Collective

Input Parameters:

  • snes - the SNES context
  • it - current iteration
  • xnorm - 2-norm of current iterate
  • snorm - 2-norm of current step
  • fnorm - 2-norm of function

Level: developer

See also: SNES, SNESSolve, SNESSetConvergenceTest()

External Links

source
PETSc.LibPETSc.SNESConvergedCorrectPressure — Method
reason::SNESConvergedReason = SNESConvergedCorrectPressure(petsclib::PetscLibType, snes::AbstractSNES, it::PetscInt, xnorm::PetscReal, gnorm::PetscReal, f::PetscReal, ctx::Ptr{Cvoid})

The regular SNES convergence test that, up on convergence, adds a vector in the nullspace to make the continuum integral of the pressure field equal to zero.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • it - the iteration (0 indicates before any Newton steps)
  • xnorm - 2-norm of current iterate
  • gnorm - 2-norm of current step
  • f - 2-norm of function at current iterate
  • ctx - Optional application context

Output Parameter:

  • reason - SNES_CONVERGED_ITERATING, SNES_CONVERGED_ITS, or SNES_DIVERGED_FUNCTION_NANORINF

Options Database Key:

  • -snes_convergence_test correct_pressure - see SNESSetFromOptions()

Level: advanced

See also: SNES, DM, SNESConvergedDefault(), SNESSetConvergenceTest(), DMSetNullSpaceConstructor()

External Links

source
PETSc.LibPETSc.SNESConvergedDefault — Method
reason::SNESConvergedReason = SNESConvergedDefault(petsclib::PetscLibType, snes::AbstractSNES, it::PetscInt, xnorm::PetscReal, snorm::PetscReal, fnorm::PetscReal, ctx::Ptr{Cvoid})

Default convergence test for SNESSolve().

Collective

Input Parameters:

  • snes - the SNES context
  • it - the iteration (0 indicates before any Newton steps)
  • xnorm - 2-norm of current iterate
  • snorm - 2-norm of current step
  • fnorm - 2-norm of function at current iterate
  • ctx - unused context

Output Parameter:

  • reason - converged reason, see SNESConvergedReason

Options Database Keys:

  • -snes_convergence_test default - see SNESSetFromOptions()
  • -snes_stol - convergence tolerance in terms of the norm of the change in the solution between steps
  • -snes_atol abstol - absolute tolerance of residual norm
  • -snes_rtol rtol - relative decrease in tolerance norm from the initial 2-norm of the solution
  • -snes_divergence_tolerance divtol - if the residual goes above divtol*rnorm0, exit with divergence
  • -snes_max_funcs max_funcs - maximum number of function evaluations, use unlimited for no maximum
  • -snes_max_fail max_fail - maximum number of line search failures allowed before stopping, default is none
  • -snes_max_linear_solve_fail - number of linear solver failures before SNESSolve() stops

Level: developer

See also: SNES, SNESSolve(), SNESSetConvergenceTest(), SNESConvergedSkip(), SNESSetTolerances(), SNESSetDivergenceTolerance(), SNESConvergedReason

External Links

source
PETSc.LibPETSc.SNESConvergedReasonView — Method
SNESConvergedReasonView(petsclib::PetscLibType, snes::AbstractSNES, viewer::PetscViewer)

Displays the reason a SNES solve converged or diverged to a viewer

Collective

Input Parameters:

  • snes - iterative context obtained from SNESCreate()
  • viewer - the viewer to display the reason

Options Database Keys:

  • -snes_converged_reason - print reason for converged or diverged, also prints number of iterations
  • -snes_converged_reason ::failed - only print reason and number of iterations when diverged

Level: beginner

See also: SNESConvergedReason, PetscViewer, SNES, SNESCreate(), SNESSetUp(), SNESDestroy(), SNESSetTolerances(), SNESConvergedDefault(), SNESGetConvergedReason(), SNESConvergedReasonViewFromOptions(), PetscViewerPushFormat(), PetscViewerPopFormat()

External Links

source
PETSc.LibPETSc.SNESConvergedReasonViewCancel — Method
SNESConvergedReasonViewCancel(petsclib::PetscLibType, snes::AbstractSNES)

Clears all the reason view functions for a SNES object provided with SNESConvergedReasonViewSet() also removes the default viewer.

Collective

Input Parameter:

  • snes - the nonlinear iterative solver context obtained from SNESCreate()

Level: intermediate

See also: SNES, SNESCreate(), SNESDestroy(), SNESReset(), SNESConvergedReasonViewSet()

External Links

source
PETSc.LibPETSc.SNESConvergedReasonViewFromOptions — Method
SNESConvergedReasonViewFromOptions(petsclib::PetscLibType, snes::AbstractSNES)

Processes command line options to determine if/how a SNESConvergedReason is to be viewed at the end of SNESSolve() All the user-provided viewer routines set with SNESConvergedReasonViewSet() will be called, if they exist.

Collective

Input Parameter:

  • snes - the SNES object

Level: advanced

See also: SNES, SNESConvergedReason, SNESConvergedReasonViewSet(), SNESCreate(), SNESSetUp(), SNESDestroy(), SNESSetTolerances(), SNESConvergedDefault(), SNESGetConvergedReason(), SNESConvergedReasonView()

External Links

source
PETSc.LibPETSc.SNESConvergedReasonViewSet — Method
SNESConvergedReasonViewSet(petsclib::PetscLibType, snes::AbstractSNES, f::external, vctx::Ptr{Cvoid}, reasonviewdestroy::Ptr{Cvoid})

Sets an ADDITIONAL function that is to be used at the end of the nonlinear solver to display the convergence reason of the nonlinear solver.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • f - the SNESConvergedReason view function
  • vctx - [optional] user-defined context for private data for the SNESConvergedReason view function (use NULL if no context is desired)
  • reasonviewdestroy - [optional] routine that frees the context (may be NULL), see PetscCtxDestroyFn for the calling sequence

Calling sequence of f:

  • snes - the SNES context
  • vctx - [optional] context for private data for the function

Options Database Keys:

  • -snes_converged_reason - sets a default SNESConvergedReasonView()
  • -snes_converged_reason_view_cancel - cancels all converged reason viewers that have been hardwired into a code by

calls to SNESConvergedReasonViewSet(), but does not cancel those set via the options database.

Level: intermediate

See also: SNES, SNESSolve(), SNESConvergedReason, SNESGetConvergedReason(), SNESConvergedReasonView(), SNESConvergedReasonViewCancel(), PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.SNESConvergedSkip — Method
reason::SNESConvergedReason = SNESConvergedSkip(petsclib::PetscLibType, snes::AbstractSNES, it::PetscInt, xnorm::PetscReal, snorm::PetscReal, fnorm::PetscReal, ctx::Ptr{Cvoid})

Convergence test for SNES that NEVER returns as converged, UNLESS the maximum number of iteration have been reached.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • it - the iteration (0 indicates before any Newton steps)
  • xnorm - 2-norm of current iterate
  • snorm - 2-norm of current step
  • fnorm - 2-norm of function at current iterate
  • ctx - unused context

Output Parameter:

  • reason - SNES_CONVERGED_ITERATING, SNES_CONVERGED_ITS, or SNES_DIVERGED_FUNCTION_NANORINF

Options Database Key:

  • -snes_convergence_test skip - see SNESSetFromOptions()

Level: advanced

See also: SNES, SNESSolve(), SNESConvergedDefault(), SNESSetConvergenceTest(), SNESConvergedReason

External Links

source
PETSc.LibPETSc.SNESCreate — Method
outsnes::SNES = SNESCreate(petsclib::PetscLibType, comm::MPI_Comm)

Creates a nonlinear solver context used to manage a set of nonlinear solves

Collective

Input Parameter:

  • comm - MPI communicator

Output Parameter:

  • outsnes - the new SNES context

Options Database Keys:

  • -snes_mf - Activates default matrix-free Jacobian-vector products, and no matrix to construct a preconditioner
  • -snes_mf_operator - Activates default matrix-free Jacobian-vector products, and a user-provided matrix as set by SNESSetJacobian()
  • -snes_fd_coloring - uses a relative fast computation of the Jacobian using finite differences and a graph coloring
  • -snes_fd - Uses (slow!) finite differences to compute Jacobian

Level: beginner

See also: SNES, SNESSolve(), SNESDestroy(), SNESSetLagPreconditioner(), SNESSetLagJacobian()

External Links

source
PETSc.LibPETSc.SNESDestroy — Method
SNESDestroy(petsclib::PetscLibType, snes::AbstractSNES)

Destroys the nonlinear solver context that was created with SNESCreate().

Collective

Input Parameter:

  • snes - the SNES context

Level: beginner

See also: SNES, SNESCreate(), SNESSolve()

External Links

source
PETSc.LibPETSc.SNESFASCreateCoarseVec — Method
Xcoarse::PetscVec = SNESFASCreateCoarseVec(petsclib::PetscLibType, snes::AbstractSNES)

create a Vec corresponding to a state vector on one level coarser than the current level

Collective

Input Parameter:

  • snes - SNESFAS object

Output Parameter:

  • Xcoarse - vector on level one coarser than the current level

Level: developer

See also: SNESFASSetRestriction(), SNESFASRestrict(), SNESFAS

External Links

source
PETSc.LibPETSc.SNESFASCycleGetCorrection — Method
correction::SNES = SNESFASCycleGetCorrection(petsclib::PetscLibType, snes::AbstractSNES)

Gets the coarse correction SNESFAS context for this level

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • correction - the coarse correction solve on this level

Level: advanced

See also: SNES, SNESFAS, SNESFASCycleGetSmootherUp(), SNESFASCycleGetSmoother()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetInjection — Method
mat::PetscMat = SNESFASCycleGetInjection(petsclib::PetscLibType, snes::AbstractSNES)

Gets the injection on a level

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • mat - the restriction operator on this level

Level: advanced

See also: SNES, SNESFAS, SNESFASGetInjection(), SNESFASCycleGetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetInterpolation — Method
mat::PetscMat = SNESFASCycleGetInterpolation(petsclib::PetscLibType, snes::AbstractSNES)

Gets the interpolation on a level

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • mat - the interpolation operator on this level

Level: advanced

See also: SNES, SNESFAS, SNESFASCycleGetSmootherUp(), SNESFASCycleGetSmoother()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetRScale — Method
vec::PetscVec = SNESFASCycleGetRScale(petsclib::PetscLibType, snes::AbstractSNES)

Gets the injection scale-factor on a level

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • vec - the restriction operator on this level

Level: advanced

See also: SNES, SNESFAS, SNESFASCycleGetRestriction(), SNESFASGetRScale()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetRestriction — Method
mat::PetscMat = SNESFASCycleGetRestriction(petsclib::PetscLibType, snes::AbstractSNES)

Gets the restriction on a level

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • mat - the restriction operator on this level

Level: advanced

See also: SNES, SNESFAS, SNESFASGetRestriction(), SNESFASCycleGetInterpolation()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetSmoother — Method
smooth::SNES = SNESFASCycleGetSmoother(petsclib::PetscLibType, snes::AbstractSNES)

Gets the smoother on a particular cycle level.

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • smooth - the smoother

Level: advanced

See also: SNES, SNESFAS, SNESFASCycleGetSmootherUp(), SNESFASCycleGetSmootherDown(), SNESFASGetCycleSNES()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetSmootherDown — Method
smoothd::SNES = SNESFASCycleGetSmootherDown(petsclib::PetscLibType, snes::AbstractSNES)

Gets the down smoother on a particular cycle level.

Logically Collective

Input Parameter:

  • snes - SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • smoothd - the smoother

Level: advanced

See also: SNES, SNESFAS, SNESFASCycleGetSmootherUp(), SNESFASCycleGetSmoother(), SNESFASGetCycleSNES()

External Links

source
PETSc.LibPETSc.SNESFASCycleGetSmootherUp — Method
smoothu::SNES = SNESFASCycleGetSmootherUp(petsclib::PetscLibType, snes::AbstractSNES)

Gets the up smoother on a particular cycle level.

Logically Collective

Input Parameter:

  • snes - the SNESFAS obtained with SNESFASGetCycleSNES()

Output Parameter:

  • smoothu - the smoother

Level: advanced

See also: SNES, SNESFAS, SNESFASCycleGetSmoother(), SNESFASCycleGetSmootherDown(), SNESFASGetCycleSNES()

External Links

source
PETSc.LibPETSc.SNESFASCycleIsFine — Method
flg::PetscBool = SNESFASCycleIsFine(petsclib::PetscLibType, snes::AbstractSNES)

Determines if a given SNES is the finest level in a SNESFAS

Logically Collective

Input Parameter:

  • snes - the SNESFAS context obtained with SNESFASGetCycleSNES()

Output Parameter:

  • flg - indicates if this is the fine level or not

Level: advanced

See also: SNES, SNESFAS, SNESFASSetLevels()

External Links

source
PETSc.LibPETSc.SNESFASCycleSetCycles — Method
SNESFASCycleSetCycles(petsclib::PetscLibType, snes::AbstractSNES, cycles::PetscInt)

Sets the number of cycles for all levels in a SNESFAS

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • cycles - the number of cycles – 1 for V-cycle, 2 for W-cycle

Level: advanced

See also: SNES, SNESFAS, SNESFASSetCycles()

External Links

source
PETSc.LibPETSc.SNESFASFullGetTotal — Method
total::PetscBool = SNESFASFullGetTotal(petsclib::PetscLibType, snes::AbstractSNES)

Use total residual restriction and total interpolation on the initial down and up sweep of full FAS cycles

Logically Collective

Input Parameter:

  • snes - the SNESFAS nonlinear multigrid context

Output Parameter:

  • total - whether to use total restriction / interpolatiaon or not (the alternative is defect restriction and correction interpolation)

Level: advanced

See also: SNES, SNESFAS, SNESFASSetNumberSmoothUp(), DMInterpolateSolution(), SNESFullSetTotal()

External Links

source
PETSc.LibPETSc.SNESFASFullSetDownSweep — Method
SNESFASFullSetDownSweep(petsclib::PetscLibType, snes::AbstractSNES, swp::PetscBool)

Smooth during the initial downsweep for SNESFAS

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • swp - whether to downsweep or not

Options Database Key:

  • -snes_fas_full_downsweep - Sets whether to smooth on the initial downsweep

Level: advanced

See also: SNES, SNESFAS, SNESFASSetNumberSmoothUp()

External Links

source
PETSc.LibPETSc.SNESFASFullSetTotal — Method
SNESFASFullSetTotal(petsclib::PetscLibType, snes::AbstractSNES, total::PetscBool)

Use total residual restriction and total interpolation on the initial down and up sweep of full SNESFAS cycles

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • total - whether to use total restriction / interpolatiaon or not (the alternative is defect restriction and correction interpolation)

Options Database Key:

  • -snes_fas_full_total - Use total restriction and interpolation on the initial down and up sweeps for the full SNESFAS cycle

Level: advanced

See also: SNES, SNESFAS, SNESFASSetNumberSmoothUp(), DMInterpolateSolution()

External Links

source
PETSc.LibPETSc.SNESFASGalerkinFunctionDefault — Method
SNESFASGalerkinFunctionDefault(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, F::AbstractPetscVec, ctx::Ptr{Cvoid})

Computes the Galerkin FAS function

Collective

Input Parameters:

  • snes - the SNESFAS nonlinear solver context
  • X - input vector
  • ctx - the application context

Output Parameter:

  • F - output vector

Level: developer

See also: SNES, SNESFAS, SNESFASGetGalerkin(), SNESFASSetGalerkin()

External Links

source
PETSc.LibPETSc.SNESFASGetCoarseSolve — Method
coarse::SNES = SNESFASGetCoarseSolve(petsclib::PetscLibType, snes::AbstractSNES)

Gets the coarsest level solver.

Input Parameter:

  • snes - the SNESFAS nonlinear multigrid context

Output Parameter:

  • coarse - the coarse-level solver

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASSetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASGetCycleSNES — Method
lsnes::SNES = SNESFASGetCycleSNES(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the SNES corresponding to a particular level of the SNESFAS hierarchy

Input Parameters:

  • snes - the SNES nonlinear multigrid context
  • level - the level to get

Output Parameter:

  • lsnes - the SNES for the requested level

Level: advanced

See also: SNES, SNESFAS, SNESFASSetLevels(), SNESFASGetLevels()

External Links

source
PETSc.LibPETSc.SNESFASGetGalerkin — Method
flg::PetscBool = SNESFASGetGalerkin(petsclib::PetscLibType, snes::AbstractSNES)

Gets if the coarse problems are formed by projection to the fine problem

Not Collective but the result would be the same on all MPI processes

Input Parameter:

  • snes - the SNESFAS nonlinear solver context

Output Parameter:

  • flg - PETSC_TRUE if the coarse problem is formed by projection

Level: advanced

See also: SNES, SNESFAS, SNESFASSetLevels(), SNESFASSetGalerkin()

External Links

source
PETSc.LibPETSc.SNESFASGetInjection — Method
mat::PetscMat = SNESFASGetInjection(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the matrix used to calculate the injection from l-1 to the lth level

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • level - the level (0 is coarsest) to supply [do not supply 0]

Output Parameter:

  • mat - the injection operator

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASGetRestriction(), SNESFASGetInterpolation(), SNESFASGetRScale()

External Links

source
PETSc.LibPETSc.SNESFASGetInterpolation — Method
mat::PetscMat = SNESFASGetInterpolation(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the matrix used to calculate the interpolation from l-1 to the lth level

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • level - the level (0 is coarsest) to supply [do not supply 0]

Output Parameter:

  • mat - the interpolation operator

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInterpolation(), SNESFASGetInjection(), SNESFASGetRestriction(), SNESFASGetRScale()

External Links

source
PETSc.LibPETSc.SNESFASGetLevels — Method
levels::PetscInt = SNESFASGetLevels(petsclib::PetscLibType, snes::AbstractSNES)

Gets the number of levels in a SNESFAS, including fine and coarse grids

Input Parameter:

  • snes - the SNES nonlinear solver context of SNESType SNESFAS

Output Parameter:

  • levels - the number of levels

Level: advanced

See also: SNES, SNESFAS, SNESFASSetLevels(), PCMGGetLevels()

External Links

source
PETSc.LibPETSc.SNESFASGetRestriction — Method
mat::PetscMat = SNESFASGetRestriction(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the matrix used to calculate the restriction from l to the l-1th level

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • level - the level (0 is coarsest) to supply [do not supply 0]

Output Parameter:

  • mat - the interpolation operator

Level: advanced

See also: SNES, SNESFAS, SNESFASSetRestriction(), SNESFASGetInjection(), SNESFASGetInterpolation(), SNESFASGetRScale()

External Links

source
PETSc.LibPETSc.SNESFASGetSmoother — Method
smooth::SNES = SNESFASGetSmoother(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the default smoother on a level.

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • level - the level (0 is coarsest) to supply

Output Parameter:

  • smooth - the smoother

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASSetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASGetSmootherDown — Method
smooth::SNES = SNESFASGetSmootherDown(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the downsmoother on a level.

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • level - the level (0 is coarsest) to supply

Output Parameter:

  • smooth - the smoother

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASSetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASGetSmootherUp — Method
smooth::SNES = SNESFASGetSmootherUp(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt)

Gets the upsmoother on a level.

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • level - the level (0 is coarsest)

Output Parameter:

  • smooth - the smoother

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASSetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASGetType — Method
fastype::SNESFASType = SNESFASGetType(petsclib::PetscLibType, snes::AbstractSNES)

Gets the update and correction type used for SNESFAS.

Logically Collective

Input Parameter:

  • snes - SNESFAS context

Output Parameter:

  • fastype - SNES_FAS_ADDITIVE, SNES_FAS_MULTIPLICATIVE, SNES_FAS_FULL, or SNES_FAS_KASKADE

Level: intermediate

See also: SNES, SNESFAS, PCMGSetType(), SNESFASSetType(), SNES_FAS_ADDITIVE, SNES_FAS_MULTIPLICATIVE, SNES_FAS_FULL, SNES_FAS_KASKADE

External Links

source
PETSc.LibPETSc.SNESFASRestrict — Method
SNESFASRestrict(petsclib::PetscLibType, fine::AbstractSNES, Xfine::AbstractPetscVec, Xcoarse::AbstractPetscVec)

restrict a Vec to the next coarser level

Collective

Input Parameters:

  • fine - SNES from which to restrict
  • Xfine - vector to restrict

Output Parameter:

  • Xcoarse - result of restriction

Level: developer

See also: SNES, SNESFAS, SNESFASSetRestriction(), SNESFASSetInjection(), SNESFASCreateCoarseVec()

External Links

source
PETSc.LibPETSc.SNESFASSetContinuation — Method
SNESFASSetContinuation(petsclib::PetscLibType, snes::AbstractSNES, continuation::PetscBool)

Sets the SNESFAS cycle to default to using exact Newton solves on the upsweep

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • continuation - whether to use continuation

Options Database Key:

  • -snes_fas_continuation - sets continuation to true

Level: advanced

See also: SNES, SNESFAS, SNESFASSetNumberSmoothUp()

External Links

source
PETSc.LibPETSc.SNESFASSetCycles — Method
SNESFASSetCycles(petsclib::PetscLibType, snes::AbstractSNES, cycles::PetscInt)

Sets the number of SNESFAS multigrid cycles to use each time a grid is visited. Use SNESFASSetCyclesOnLevel() for more complicated cycling.

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • cycles - the number of cycles – 1 for V-cycle, 2 for W-cycle

Options Database Key:

  • -snes_fas_cycles (1|2) - 1 for V-cycle, 2 for W-cycle

Level: advanced

See also: SNES, SNESFAS, SNESFASSetCyclesOnLevel()

External Links

source
PETSc.LibPETSc.SNESFASSetGalerkin — Method
SNESFASSetGalerkin(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Sets coarse problems as formed by projection to the fine problem

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear solver context
  • flg - PETSC_TRUE to use the projection process

Level: advanced

See also: SNES, SNESFAS, SNESFASSetLevels(), SNESFASGetGalerkin()

External Links

source
PETSc.LibPETSc.SNESFASSetInjection — Method
SNESFASSetInjection(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt, mat::AbstractPetscMat)

Sets the matrix to be used to inject the solution from level to level-1.

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • mat - the injection matrix
  • level - the level (0 is coarsest) to supply [Do not supply 0]

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInterpolation(), SNESFASSetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASSetInterpolation — Method
SNESFASSetInterpolation(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt, mat::AbstractPetscMat)

Sets the Mat to be used to apply the interpolation from l-1 to the lth level

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • mat - the interpolation operator
  • level - the level (0 is coarsest) to supply [do not supply 0]

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASSetRestriction(), SNESFASSetRScale()

External Links

source
PETSc.LibPETSc.SNESFASSetLevels — Method
comms::MPI_Comm = SNESFASSetLevels(petsclib::PetscLibType, snes::AbstractSNES, levels::PetscInt)

Sets the number of levels to use with SNESFAS. Must be called before any other SNESFAS routine.

Input Parameters:

  • snes - the SNES context of SNESType SNESFAS
  • levels - the number of levels
  • comms - optional communicators for each level; this is to allow solving the coarser

problems on smaller sets of processors.

Level: intermediate

See also: SNES, SNESFAS, SNESFASGetLevels()

External Links

source
PETSc.LibPETSc.SNESFASSetLog — Method
SNESFASSetLog(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Sets or unsets time logging for various SNESFAS stages on all levels

Logically Collective

Input Parameters:

  • snes - the SNESFAS context
  • flg - whether to log or not

Level: advanced

See also: SNES, SNESFAS, SNESFASSetMonitor()

External Links

source
PETSc.LibPETSc.SNESFASSetMonitor — Method
SNESFASSetMonitor(petsclib::PetscLibType, snes::AbstractSNES, vf::Vector{PetscViewerAndFormat}, flg::PetscBool)

Sets the method-specific cycle monitoring

Logically Collective

Input Parameters:

  • snes - the SNESFAS context
  • vf - viewer and format structure (may be NULL if flg is PETSC_FALSE)
  • flg - monitor or not

Level: advanced

See also: SNES, SNESFAS, SNESMonitorSet(), SNESFASSetCyclesOnLevel()

External Links

source
PETSc.LibPETSc.SNESFASSetNumberSmoothDown — Method
SNESFASSetNumberSmoothDown(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt)

Sets the number of pre-smoothing steps to use on all levels.

Logically Collective

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • n - the number of smoothing steps to use

Options Database Key:

  • -snes_fas_smoothdown n - Sets number of pre-smoothing steps

Level: advanced

See also: SNES, SNESFAS, SNESFASSetNumberSmoothUp()

External Links

source
PETSc.LibPETSc.SNESFASSetNumberSmoothUp — Method
SNESFASSetNumberSmoothUp(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt)

Sets the number of post-smoothing steps to use on all levels.

Logically Collective

Input Parameters:

  • snes - the SNES nonlinear multigrid context
  • n - the number of smoothing steps to use

Options Database Key:

  • -snes_fas_smoothup n - Sets number of pre-smoothing steps

Level: advanced

See also: SNES, SNESFAS, SNESFASSetNumberSmoothDown()

External Links

source
PETSc.LibPETSc.SNESFASSetRScale — Method
SNESFASSetRScale(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt, rscale::AbstractPetscVec)

Sets the scaling factor of the restriction operator from level l to l-1.

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • rscale - the restriction scaling
  • level - the level (0 is coarsest) to supply [Do not supply 0]

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInjection(), SNESFASSetRestriction()

External Links

source
PETSc.LibPETSc.SNESFASSetRestriction — Method
SNESFASSetRestriction(petsclib::PetscLibType, snes::AbstractSNES, level::PetscInt, mat::AbstractPetscMat)

Sets the matrix to be used to restrict the defect from level l to l-1.

Input Parameters:

  • snes - the SNESFAS nonlinear multigrid context
  • mat - the restriction matrix
  • level - the level (0 is coarsest) to supply [Do not supply 0]

Level: advanced

See also: SNES, SNESFAS, SNESFASSetInterpolation(), SNESFASSetInjection()

External Links

source
PETSc.LibPETSc.SNESFASSetType — Method
SNESFASSetType(petsclib::PetscLibType, snes::AbstractSNES, fastype::SNESFASType)

Sets the update and correction type used for SNESFAS.

Logically Collective

Input Parameters:

  • snes - SNESFAS context
  • fastype - SNES_FAS_ADDITIVE, SNES_FAS_MULTIPLICATIVE, SNES_FAS_FULL, or SNES_FAS_KASKADE

Level: intermediate

See also: SNES, SNESFAS, PCMGSetType(), SNESFASGetType(), SNES_FAS_ADDITIVE, SNES_FAS_MULTIPLICATIVE, SNES_FAS_FULL, SNES_FAS_KASKADE

External Links

source
PETSc.LibPETSc.SNESGetAlwaysComputesFinalResidual — Method
flg::PetscBool = SNESGetAlwaysComputesFinalResidual(petsclib::PetscLibType, snes::AbstractSNES)

checks if the SNES always computes the residual at the final solution

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • flg - PETSC_TRUE if the residual is computed

Level: advanced

See also: SNES, SNESFAS, SNESSolve(), SNESSetAlwaysComputesFinalResidual()

External Links

source
PETSc.LibPETSc.SNESGetApplicationContext — Method
ctx::Ptr{Cvoid} = SNESGetApplicationContext(petsclib::PetscLibType, snes::AbstractSNES)

Gets the user-defined context for the nonlinear solvers set with SNESGetApplicationContext() or SNESSetComputeApplicationContext()

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • ctx - the application context

Level: intermediate

See also: SNESSetApplicationContext(), SNESSetComputeApplicationContext()

External Links

source
PETSc.LibPETSc.SNESGetCheckJacobianDomainError — Method
flg::PetscBool = SNESGetCheckJacobianDomainError(petsclib::PetscLibType, snes::AbstractSNES)

Get an indicator whether or not SNES is checking Jacobian domain errors after each Jacobian evaluation.

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • flg - PETSC_FALSE indicates that it is not checking Jacobian domain errors after each Jacobian evaluation

Level: advanced

See also: SNES, SNESCreate(), SNESSetFunction(), SNESFunctionFn, SNESSetFunctionDomainError(), SNESSetCheckJacobianDomainError()

External Links

source
PETSc.LibPETSc.SNESGetConvergedReason — Method
reason::SNESConvergedReason = SNESGetConvergedReason(petsclib::PetscLibType, snes::AbstractSNES)

Gets the reason the SNES iteration was stopped, which may be due to convergence, divergence, or stagnation

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • reason - negative value indicates diverged, positive value converged, see SNESConvergedReason for the individual convergence tests for complete lists

Options Database Key:

  • -snes_converged_reason - prints the reason to standard out

Level: intermediate

See also: SNESSolve(), SNESSetConvergenceTest(), SNESSetConvergedReason(), SNESConvergedReason, SNESGetConvergedReasonString()

External Links

source
PETSc.LibPETSc.SNESGetConvergedReasonString — Method
strreason::String = SNESGetConvergedReasonString(petsclib::PetscLibType, snes::AbstractSNES)

Return a human readable string for SNESConvergedReason

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • strreason - a human readable string that describes SNES converged reason

Level: beginner

See also: SNES, SNESGetConvergedReason()

External Links

source
PETSc.LibPETSc.SNESGetConvergenceHistory — Method
a::Vector{PetscReal},its::Vector{PetscInt},na::PetscInt = SNESGetConvergenceHistory(petsclib::PetscLibType, snes::AbstractSNES)

Gets the arrays used to hold the convergence history.

Not Collective

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameters:

  • a - array to hold history, usually was set with SNESSetConvergenceHistory()
  • its - integer array holds the number of linear iterations (or

negative if not converged) for each solve.

  • na - size of a and its

Level: intermediate

See also: SNES, SNESSolve(), SNESSetConvergenceHistory()

External Links

source
PETSc.LibPETSc.SNESGetDM — Method
dm::PetscDM = SNESGetDM(petsclib::PetscLibType, snes::AbstractSNES)

Gets the DM that may be used by some SNES nonlinear solvers/preconditioners

Not Collective but dm obtained is parallel on snes

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • dm - the DM

Level: intermediate

See also: DM, SNES, SNESSetDM(), KSPSetDM(), KSPGetDM()

External Links

source
PETSc.LibPETSc.SNESGetDivergenceTolerance — Method
divtol::PetscReal = SNESGetDivergenceTolerance(petsclib::PetscLibType, snes::AbstractSNES)

Gets divergence tolerance used in divergence test.

Not Collective

Input Parameters:

  • snes - the SNES context
  • divtol - divergence tolerance

Level: intermediate

See also: SNES, SNESSetDivergenceTolerance()

External Links

source
PETSc.LibPETSc.SNESGetErrorIfNotConverged — Method
flag::PetscBool = SNESGetErrorIfNotConverged(petsclib::PetscLibType, snes::AbstractSNES)

Indicates if SNESSolve() will generate an error if the solver does not converge?

Not Collective

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameter:

  • flag - PETSC_TRUE if it will generate an error, else PETSC_FALSE

Level: intermediate

See also: SNES, SNESSolve(), SNESSetErrorIfNotConverged(), KSPGetErrorIfNotConverged(), KSPSetErrorIfNotConverged()

External Links

source
PETSc.LibPETSc.SNESGetForceIteration — Method
force::PetscBool = SNESGetForceIteration(petsclib::PetscLibType, snes::AbstractSNES)

Check whether or not SNESSolve() take at least one iteration regardless of the initial residual norm

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • force - PETSC_TRUE requires at least one iteration.

Level: intermediate

See also: SNES, SNESSetForceIteration(), SNESSetDivergenceTolerance()

External Links

source
PETSc.LibPETSc.SNESGetFunction — Method
r::PetscVec,f::Ptr{Cvoid},ctx::Ptr{Cvoid} = SNESGetFunction(petsclib::PetscLibType, snes::AbstractSNES)

Returns the function that defines the nonlinear system set with SNESSetFunction()

Not Collective, but r is parallel if snes is parallel. Collective if r is requested, but has not been created yet.

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • r - the vector that is used to store residuals (or NULL if you don't want it)
  • f - the function (or NULL if you don't want it); for calling sequence see SNESFunctionFn
  • ctx - the function context (or NULL if you don't want it)

Level: advanced

See also: SNES, SNESSolve(), SNESSetFunction(), SNESGetSolution(), SNESFunctionFn

External Links

source
PETSc.LibPETSc.SNESGetFunctionNorm — Method
norm::PetscReal = SNESGetFunctionNorm(petsclib::PetscLibType, snes::AbstractSNES)

Gets the last computed norm of the residual

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • norm - the last computed residual norm

Level: developer

See also: SNES, SNESSetNormSchedule(), SNESComputeFunction(), VecNorm(), SNESSetFunction(), SNESSetInitialFunction(), SNESNormSchedule

External Links

source
PETSc.LibPETSc.SNESGetFunctionType — Method
type::SNESFunctionType = SNESGetFunctionType(petsclib::PetscLibType, snes::AbstractSNES)

Gets the SNESFunctionType used in convergence and monitoring set with SNESSetFunctionType() of the SNES method.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • type - the type of the function evaluation, see SNESSetFunctionType()

Level: advanced

See also: SNESSetFunctionType(), SNESFunctionType, SNESSetNormSchedule(), SNESComputeFunction(), VecNorm(), SNESSetFunction(), SNESSetInitialFunction(), SNESNormSchedule

External Links

source
PETSc.LibPETSc.SNESGetGridSequence — Method
steps::PetscInt = SNESGetGridSequence(petsclib::PetscLibType, snes::AbstractSNES)

gets the number of steps of grid sequencing that SNES will do

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • steps - the number of refinements to do, defaults to 0

Level: intermediate

See also: SNESGetLagPreconditioner(), SNESSetLagJacobian(), SNESGetLagJacobian(), SNESSetGridSequence()

External Links

source
PETSc.LibPETSc.SNESGetIterationNumber — Method
iter::PetscInt = SNESGetIterationNumber(petsclib::PetscLibType, snes::AbstractSNES)

Gets the number of nonlinear iterations completed in the current or most recent SNESSolve()

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • iter - iteration number

Level: intermediate

See also: SNES, SNESSolve(), SNESSetLagJacobian(), SNESGetLinearSolveIterations(), SNESSetMonitor()

External Links

source
PETSc.LibPETSc.SNESGetJacobian — Method
Amat::PetscMat,Pmat::PetscMat,J::Ptr{Cvoid},ctx::Ptr{Cvoid} = SNESGetJacobian(petsclib::PetscLibType, snes::AbstractSNES)

Returns the Jacobian matrix and optionally the user provided context for evaluating the Jacobian.

Not Collective, but Mat object will be parallel if SNES is

Input Parameter:

  • snes - the nonlinear solver context

Output Parameters:

  • Amat - location to stash (approximate) Jacobian matrix (or NULL)
  • Pmat - location to stash matrix used to compute the preconditioner (or NULL)
  • J - location to put Jacobian function (or NULL), for calling sequence see SNESJacobianFn
  • ctx - location to stash Jacobian ctx (or NULL)

Level: advanced

See also: SNES, Mat, SNESSetJacobian(), SNESComputeJacobian(), SNESJacobianFn, SNESGetFunction()

External Links

source
PETSc.LibPETSc.SNESGetKSP — Method
ksp::KSP = SNESGetKSP(petsclib::PetscLibType, snes::AbstractSNES)

Returns the KSP context for a SNES solver.

Not Collective, but if snes is parallel, then ksp is parallel

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • ksp - the KSP context

Level: beginner

See also: SNES, KSP, PC, KSPGetPC(), SNESCreate(), KSPCreate(), SNESSetKSP()

External Links

source
PETSc.LibPETSc.SNESGetLagJacobian — Method
lag::PetscInt = SNESGetLagJacobian(petsclib::PetscLibType, snes::AbstractSNES)

Get how often the Jacobian is rebuilt. See SNESGetLagPreconditioner() to determine when the preconditioner is rebuilt

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • lag - -1 indicates NEVER rebuild, 1 means rebuild every time the Jacobian is computed within a single nonlinear solve, 2 means every second time

the Jacobian is built etc.

Level: intermediate

See also: SNES, SNESSetLagJacobian(), SNESSetLagPreconditioner(), SNESGetLagPreconditioner(), SNESSetLagJacobianPersists(), SNESSetLagPreconditionerPersists()

External Links

source
PETSc.LibPETSc.SNESGetLagPreconditioner — Method
lag::PetscInt = SNESGetLagPreconditioner(petsclib::PetscLibType, snes::AbstractSNES)

Return how often the preconditioner is rebuilt

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • lag - -1 indicates NEVER rebuild, 1 means rebuild every time the Jacobian is computed within a single nonlinear solve, 2 means every second time

the Jacobian is built etc. -2 indicates rebuild preconditioner at next chance but then never rebuild after that

Level: intermediate

See also: SNES, SNESSetLagPreconditioner(), SNESSetLagJacobianPersists(), SNESSetLagPreconditionerPersists()

External Links

source
PETSc.LibPETSc.SNESGetLineSearch — Method
linesearch::SNESLineSearch = SNESGetLineSearch(petsclib::PetscLibType, snes::AbstractSNES)

Returns the line search associated with the SNES.

Not Collective

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameter:

  • linesearch - linesearch context

Level: beginner

See also: SNESLineSearch, SNESSetLineSearch(), SNESLineSearchCreate(), SNESLineSearchSetFromOptions()

External Links

source
PETSc.LibPETSc.SNESGetLinearSolveFailures — Method
nfails::PetscInt = SNESGetLinearSolveFailures(petsclib::PetscLibType, snes::AbstractSNES)

Gets the number of failed (non-converged) linear solvers in the current or most recent SNESSolve()

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • nfails - number of failed solves

Options Database Key:

  • -snes_max_linear_solve_fail num - The number of failures before the solve is terminated

Level: intermediate

See also: SNESGetMaxLinearSolveFailures(), SNESGetLinearSolveIterations(), SNESSetMaxLinearSolveFailures()

External Links

source
PETSc.LibPETSc.SNESGetLinearSolveIterations — Method
lits::PetscInt = SNESGetLinearSolveIterations(petsclib::PetscLibType, snes::AbstractSNES)

Gets the total number of linear iterations used by the nonlinear solver in the most recent SNESSolve()

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • lits - number of linear iterations

Level: intermediate

See also: SNES, SNESGetIterationNumber(), SNESGetLinearSolveFailures(), SNESGetMaxLinearSolveFailures(), SNESSetCountersReset()

External Links

source
PETSc.LibPETSc.SNESGetMaxLinearSolveFailures — Method
maxFails::PetscInt = SNESGetMaxLinearSolveFailures(petsclib::PetscLibType, snes::AbstractSNES)

gets the maximum number of linear solve failures that are allowed before SNES returns as unsuccessful

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • maxFails - maximum of unsuccessful solves allowed

Level: intermediate

See also: SNESSetErrorIfNotConverged(), SNESGetLinearSolveFailures(), SNESGetLinearSolveIterations(), SNESSetMaxLinearSolveFailures()

External Links

source
PETSc.LibPETSc.SNESGetMaxNonlinearStepFailures — Method
maxFails::PetscInt = SNESGetMaxNonlinearStepFailures(petsclib::PetscLibType, snes::AbstractSNES)

Gets the maximum number of unsuccessful steps attempted by the nonlinear solver before it gives up and returns unconverged or generates an error

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • maxFails - maximum of unsuccessful steps

Level: intermediate

See also: SNESSetErrorIfNotConverged(), SNESGetMaxLinearSolveFailures(), SNESGetLinearSolveIterations(), SNESSetMaxLinearSolveFailures(), SNESGetLinearSolveFailures(), SNESSetMaxNonlinearStepFailures(), SNESGetNonlinearStepFailures()

External Links

source
PETSc.LibPETSc.SNESGetNGS — Method
f::Ptr{Cvoid},ctx::Ptr{Cvoid} = SNESGetNGS(petsclib::PetscLibType, snes::AbstractSNES)

Returns the function and context set with SNESSetNGS()

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • f - the function (or NULL) see SNESNGSFn for calling sequence
  • ctx - the function context (or NULL)

Level: advanced

See also: SNESSetNGS(), SNESGetFunction(), SNESNGSFn

External Links

source
PETSc.LibPETSc.SNESGetNPC — Method
pc::SNES = SNESGetNPC(petsclib::PetscLibType, snes::AbstractSNES)

Gets a nonlinear preconditioning solver SNES` to be used to precondition the original nonlinear solver.

Not Collective; but any changes to the obtained the pc object must be applied collectively

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameter:

  • pc - the SNES preconditioner context

Options Database Key:

  • -npc_snes_type type - set the type of the SNES to use as the nonlinear preconditioner

Level: advanced

See also: SNESSetNPC(), SNESHasNPC(), SNES, SNESCreate()

External Links

source
PETSc.LibPETSc.SNESGetNPCFunction — Method
fnorm::PetscReal = SNESGetNPCFunction(petsclib::PetscLibType, snes::AbstractSNES, F::AbstractPetscVec)

Gets the current function value (for the callback function provided by SNESSetFunction(), and its norm from a nonlinear preconditioner after SNESSolve() has been called on that SNES

Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • F - function vector
  • fnorm - the norm of F

Level: developer

See also: SNES, SNESGetNPC(), SNESSetNPC(), SNESComputeFunction(), SNESApplyNPC(), SNESSolve()

External Links

source
PETSc.LibPETSc.SNESGetNPCSide — Method
side::PCSide = SNESGetNPCSide(petsclib::PetscLibType, snes::AbstractSNES)

Gets the preconditioning side used by the nonlinear preconditioner inside SNES.

Not Collective

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameter:

  • side - the preconditioning side, where side is one of

$`PC_LEFT` - left preconditioning `PC_RIGHT` - right preconditioning (default for most nonlinear solvers)$

Level: intermediate

See also: SNES, SNESGetNPC(), SNESSetNPCSide(), KSPGetPCSide(), PC_LEFT, PC_RIGHT, PCSide

External Links

source
PETSc.LibPETSc.SNESGetNonlinearStepFailures — Method
nfails::PetscInt = SNESGetNonlinearStepFailures(petsclib::PetscLibType, snes::AbstractSNES)

Gets the number of unsuccessful steps taken by the nonlinear solver in the current or most recent SNESSolve() .

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • nfails - number of unsuccessful steps attempted

Level: intermediate

See also: SNES, SNESGetMaxLinearSolveFailures(), SNESGetLinearSolveIterations(), SNESSetMaxLinearSolveFailures(), SNESGetLinearSolveFailures(), SNESSetMaxNonlinearStepFailures(), SNESGetMaxNonlinearStepFailures()

External Links

source
PETSc.LibPETSc.SNESGetNormSchedule — Method
normschedule::SNESNormSchedule = SNESGetNormSchedule(petsclib::PetscLibType, snes::AbstractSNES)

Gets the SNESNormSchedule used in convergence and monitoring of the SNES method.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • normschedule - the type of the norm used

Level: advanced

See also: SNES, SNESSetNormSchedule(), SNESComputeFunction(), VecNorm(), SNESSetFunction(), SNESSetInitialFunction(), SNESNormSchedule

External Links

source
PETSc.LibPETSc.SNESGetNumberFunctionEvals — Method
nfuncs::PetscInt = SNESGetNumberFunctionEvals(petsclib::PetscLibType, snes::AbstractSNES)

Gets the number of user provided function evaluations done by the SNES object in the current or most recent SNESSolve()

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • nfuncs - number of evaluations

Level: intermediate

See also: SNES, SNESGetMaxLinearSolveFailures(), SNESGetLinearSolveIterations(), SNESSetMaxLinearSolveFailures(), SNESGetLinearSolveFailures(), SNESSetCountersReset()

External Links

source
PETSc.LibPETSc.SNESGetObjective — Method
obj::Ptr{Cvoid},ctx::Ptr{Cvoid} = SNESGetObjective(petsclib::PetscLibType, snes::AbstractSNES)

Returns the objective function set with SNESSetObjective()

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • obj - objective evaluation routine (or NULL); see SNESObjectiveFn for the calling sequence
  • ctx - the function context (or NULL)

Level: advanced

See also: SNES, SNESSetObjective(), SNESGetSolution(), SNESObjectiveFn

External Links

source
PETSc.LibPETSc.SNESGetOptionsPrefix — Method
prefix::String = SNESGetOptionsPrefix(petsclib::PetscLibType, snes::AbstractSNES)

Gets the prefix used for searching for all SNES options in the database.

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • prefix - pointer to the prefix string used

Level: advanced

See also: SNES, SNESSetOptionsPrefix(), SNESAppendOptionsPrefix()

External Links

source
PETSc.LibPETSc.SNESGetPicard — Method
r::PetscVec,f::Ptr{Cvoid},Amat::PetscMat,Pmat::PetscMat,J::Ptr{Cvoid},ctx::Ptr{Cvoid} = SNESGetPicard(petsclib::PetscLibType, snes::AbstractSNES)

Returns the context for the Picard iteration

Not Collective, but Vec is parallel if SNES is parallel. Collective if Vec is requested, but has not been created yet.

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • r - the function (or NULL)
  • f - the function (or NULL); for calling sequence see SNESFunctionFn
  • Amat - the matrix used to defined the operation A(x) x - b(x) (or NULL)
  • Pmat - the matrix from which the preconditioner will be constructed (or NULL)
  • J - the function for matrix evaluation (or NULL); for calling sequence see SNESJacobianFn
  • ctx - the function context (or NULL)

Level: advanced

See also: SNESSetFunction(), SNESSetPicard(), SNESGetFunction(), SNESGetJacobian(), SNESGetDM(), SNESFunctionFn, SNESJacobianFn

External Links

source
PETSc.LibPETSc.SNESGetRhs — Method
rhs::PetscVec = SNESGetRhs(petsclib::PetscLibType, snes::AbstractSNES)

Gets the vector for solving F(x) = rhs. If rhs is not set it assumes a zero right-hand side.

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • rhs - the right-hand side vector or NULL if there is no right-hand side vector

Level: intermediate

See also: SNES, SNESGetSolution(), SNESGetFunction(), SNESComputeFunction(), SNESSetJacobian(), SNESSetFunction()

External Links

source
PETSc.LibPETSc.SNESGetSolution — Method
x::PetscVec = SNESGetSolution(petsclib::PetscLibType, snes::AbstractSNES)

Returns the vector where the approximate solution is stored. This is the fine grid solution when using SNESSetGridSequence().

Not Collective, but x is parallel if snes is parallel

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • x - the solution

Level: intermediate

See also: SNESSetSolution(), SNESSolve(), SNES, SNESGetSolutionUpdate(), SNESGetFunction()

External Links

source
PETSc.LibPETSc.SNESGetSolutionNorm — Method
xnorm::PetscReal = SNESGetSolutionNorm(petsclib::PetscLibType, snes::AbstractSNES)

Gets the last computed norm of the solution

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • xnorm - the last computed solution norm

Level: developer

See also: SNES, SNESSetNormSchedule(), SNESComputeFunction(), SNESGetFunctionNorm(), SNESGetUpdateNorm()

External Links

source
PETSc.LibPETSc.SNESGetSolutionUpdate — Method
x::PetscVec = SNESGetSolutionUpdate(petsclib::PetscLibType, snes::AbstractSNES)

Returns the vector where the solution update is stored.

Not Collective, but x is parallel if snes is parallel

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • x - the solution update

Level: advanced

See also: SNES, SNESGetSolution(), SNESGetFunction()

External Links

source
PETSc.LibPETSc.SNESGetTolerances — Method
atol::PetscReal,rtol::PetscReal,stol::PetscReal,maxit::PetscInt,maxf::PetscInt = SNESGetTolerances(petsclib::PetscLibType, snes::AbstractSNES)

Gets various parameters used in SNES convergence tests.

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • atol - the absolute convergence tolerance
  • rtol - the relative convergence tolerance
  • stol - convergence tolerance in terms of the norm of the change in the solution between steps
  • maxit - the maximum number of iterations allowed
  • maxf - the maximum number of function evaluations allowed, PETSC_UNLIMITED indicates no bound

Level: intermediate

See also: SNES, SNESSetTolerances()

External Links

source
PETSc.LibPETSc.SNESGetType — Method
type::String = SNESGetType(petsclib::PetscLibType, snes::AbstractSNES)

Gets the SNES method type and name (as a string).

Not Collective

Input Parameter:

  • snes - nonlinear solver context

Output Parameter:

  • type - SNES method (a character string)

Level: intermediate

See also: SNESSetType(), SNESType, SNESSetFromOptions(), SNES, PetscObjectTypeCompare(), PetscObjectTypeCompareAny()

External Links

source
PETSc.LibPETSc.SNESGetUpdateNorm — Method
ynorm::PetscReal = SNESGetUpdateNorm(petsclib::PetscLibType, snes::AbstractSNES)

Gets the last computed norm of the solution update

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • ynorm - the last computed update norm

Level: developer

See also: SNES, SNESSetNormSchedule(), SNESComputeFunction(), SNESGetFunctionNorm()

External Links

source
PETSc.LibPETSc.SNESGetUseMatrixFree — Method
mf_operator::PetscBool,mf::PetscBool = SNESGetUseMatrixFree(petsclib::PetscLibType, snes::AbstractSNES)

indicates if the SNES uses matrix-free finite difference matrix vector products to apply the Jacobian.

Not Collective, but the resulting flags will be the same on all MPI processes

Input Parameter:

  • snes - SNES context

Output Parameters:

  • mf_operator - use matrix-free only for the Amat used by SNESSetJacobian(), this means the user provided Pmat will continue to be used
  • mf - use matrix-free for both the Amat and Pmat used by SNESSetJacobian(), both the Amat and Pmat set in SNESSetJacobian() will be ignored

Level: intermediate

See also: SNES, SNESSetUseMatrixFree(), MatCreateSNESMF()

External Links

source
PETSc.LibPETSc.SNESHasNPC — Method
has_npc::PetscBool = SNESHasNPC(petsclib::PetscLibType, snes::AbstractSNES)

Returns whether a nonlinear preconditioner is associated with the given SNES

Not Collective

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameter:

  • has_npc - whether the SNES has a nonlinear preconditioner or not

Level: developer

See also: SNESSetNPC(), SNESGetNPC()

External Links

source
PETSc.LibPETSc.SNESInitializePackage — Method
SNESInitializePackage(petsclib::PetscLibType)

This function initializes everything in the SNES package. It is called from PetscDLLibraryRegister_petscsnes() when using dynamic libraries, and on the first call to SNESCreate() when using shared or static libraries.

Level: developer

See also: SNES, PetscInitialize()

External Links

source
PETSc.LibPETSc.SNESKSPGetParametersEW — Method
version::PetscInt,rtol_0::PetscReal,rtol_max::PetscReal,gamma::PetscReal,alpha::PetscReal,alpha2::PetscReal,threshold::PetscReal = SNESKSPGetParametersEW(petsclib::PetscLibType, snes::AbstractSNES)

Gets parameters for Eisenstat-Walker convergence criteria for the linear solvers within an inexact Newton method.

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameters:

  • version - version 1, 2 (default is 2), 3 or 4
  • rtol_0 - initial relative tolerance (0 <= rtol_0 < 1)
  • rtol_max - maximum relative tolerance (0 <= rtol_max < 1)
  • gamma - multiplicative factor for version 2 rtol computation (0 <= gamma2 <= 1)
  • alpha - power for version 2 rtol computation (1 < alpha <= 2)
  • alpha2 - power for safeguard
  • threshold - threshold for imposing safeguard (0 < threshold < 1)

Level: advanced

See also: SNES, SNESKSPSetUseEW(), SNESKSPGetUseEW(), SNESKSPSetParametersEW()

External Links

source
PETSc.LibPETSc.SNESKSPGetUseEW — Method
flag::PetscBool = SNESKSPGetUseEW(petsclib::PetscLibType, snes::AbstractSNES)

Gets if SNES is using Eisenstat-Walker method for computing relative tolerance for linear solvers within an inexact Newton method.

Not Collective

Input Parameter:

  • snes - SNES context

Output Parameter:

  • flag - PETSC_TRUE or PETSC_FALSE

Level: advanced

See also: SNESKSPSetUseEW(), SNESKSPGetParametersEW(), SNESKSPSetParametersEW()

External Links

source
PETSc.LibPETSc.SNESKSPSetParametersEW — Method
SNESKSPSetParametersEW(petsclib::PetscLibType, snes::AbstractSNES, version::PetscInt, rtol_0::PetscReal, rtol_max::PetscReal, gamma::PetscReal, alpha::PetscReal, alpha2::PetscReal, threshold::PetscReal)

Sets parameters for Eisenstat-Walker convergence criteria for the linear solvers within an inexact Newton method.

Logically Collective

Input Parameters:

  • snes - SNES context
  • version - version 1, 2 (default is 2), 3 or 4
  • rtol_0 - initial relative tolerance (0 <= rtol_0 < 1)
  • rtol_max - maximum relative tolerance (0 <= rtol_max < 1)
  • gamma - multiplicative factor for version 2 rtol computation

(0 <= gamma2 <= 1)

  • alpha - power for version 2 rtol computation (1 < alpha <= 2)
  • alpha2 - power for safeguard
  • threshold - threshold for imposing safeguard (0 < threshold < 1)

Level: advanced

See also: SNES, SNESKSPSetUseEW(), SNESKSPGetUseEW(), SNESKSPGetParametersEW()

External Links

source
PETSc.LibPETSc.SNESKSPSetUseEW — Method
SNESKSPSetUseEW(petsclib::PetscLibType, snes::AbstractSNES, flag::PetscBool)

Sets SNES to the use Eisenstat-Walker method for computing relative tolerance for linear solvers within an inexact Newton method.

Logically Collective

Input Parameters:

  • snes - SNES context
  • flag - PETSC_TRUE or PETSC_FALSE

Options Database Keys:

  • -snes_ksp_ew - use Eisenstat-Walker method for determining linear system convergence
  • -snes_ksp_ew_version ver - version of Eisenstat-Walker method
  • -snes_ksp_ew_rtol0 rtol0 - Sets rtol0
  • -snes_ksp_ew_rtolmax rtolmax - Sets rtolmax
  • -snes_ksp_ew_gamma gamma - Sets gamma
  • -snes_ksp_ew_alpha alpha - Sets alpha
  • -snes_ksp_ew_alpha2 alpha2 - Sets alpha2
  • -snes_ksp_ew_threshold threshold - Sets threshold

Level: advanced

See also: KSP, SNES, SNESKSPGetUseEW(), SNESKSPGetParametersEW(), SNESKSPSetParametersEW()

External Links

source
PETSc.LibPETSc.SNESLoad — Method
SNESLoad(petsclib::PetscLibType, snes::AbstractSNES, viewer::PetscViewer)

Loads a SNES that has been stored in PETSCVIEWERBINARY with SNESView().

Collective

Input Parameters:

  • snes - the newly loaded SNES, this needs to have been created with SNESCreate() or

some related function before a call to SNESLoad().

  • viewer - binary file viewer, obtained from PetscViewerBinaryOpen()

Level: intermediate

See also: SNES, PetscViewer, SNESCreate(), SNESType, PetscViewerBinaryOpen(), SNESView(), MatLoad(), VecLoad()

External Links

source
PETSc.LibPETSc.SNESMSFinalizePackage — Method
SNESMSFinalizePackage(petsclib::PetscLibType)

This function destroys everything in the SNESMS package. It is called from PetscFinalize().

Level: developer

See also: SNES, SNESMS, SNESMSRegister(), SNESMSRegisterAll(), SNESMSInitializePackage(), PetscFinalize()

External Links

source
PETSc.LibPETSc.SNESMSGetDamping — Method
damping::PetscReal = SNESMSGetDamping(petsclib::PetscLibType, snes::AbstractSNES)

Get the damping parameter of SNESMS multistage scheme

Not Collective

Input Parameter:

  • snes - nonlinear solver context

Output Parameter:

  • damping - damping parameter

Level: advanced

See also: SNESMSSetDamping(), SNESMS

External Links

source
PETSc.LibPETSc.SNESMSGetType — Method
mstype::String = SNESMSGetType(petsclib::PetscLibType, snes::AbstractSNES)

Get the type of multistage smoother SNESMS

Not Collective

Input Parameter:

  • snes - nonlinear solver context

Output Parameter:

  • mstype - type of multistage method

Level: advanced

See also: SNESMS, SNESMSSetType(), SNESMSType

External Links

source
PETSc.LibPETSc.SNESMSRegister — Method
SNESMSRegister(petsclib::PetscLibType, name::String, nstages::PetscInt, nregisters::PetscInt, stability::PetscReal, gamma::Vector{PetscReal}, delta::Vector{PetscReal}, betasub::Vector{PetscReal})

register a multistage scheme for SNESMS

Logically Collective, No Fortran Support

Input Parameters:

  • name - identifier for method
  • nstages - number of stages
  • nregisters - number of registers used by low-storage implementation
  • stability - scaled stability region
  • gamma - coefficients, see Ketcheson's paper {cite}ketcheson2010runge
  • delta - coefficients, see Ketcheson's paper {cite}ketcheson2010runge
  • betasub - subdiagonal of Shu-Osher form

Level: advanced

See also: SNES, SNESMS

External Links

source
PETSc.LibPETSc.SNESMSSetDamping — Method
SNESMSSetDamping(petsclib::PetscLibType, snes::AbstractSNES, damping::PetscReal)

Set the damping parameter for a SNESMS multistage scheme

Logically Collective

Input Parameters:

  • snes - nonlinear solver context
  • damping - damping parameter

Level: advanced

See also: SNESMSGetDamping(), SNESMS

External Links

source
PETSc.LibPETSc.SNESMSSetType — Method
SNESMSSetType(petsclib::PetscLibType, snes::AbstractSNES, mstype::String)

Set the type of multistage smoother SNESMS

Logically Collective

Input Parameters:

  • snes - nonlinear solver context
  • mstype - type of multistage method

Level: advanced

See also: SNESMS, SNESMSGetType(), SNESMSType

External Links

source
PETSc.LibPETSc.SNESMonitor — Method
SNESMonitor(petsclib::PetscLibType, snes::AbstractSNES, iter::PetscInt, rnorm::PetscReal)

runs any SNES monitor routines provided with SNESMonitor() or the options database

Collective

Input Parameters:

  • snes - nonlinear solver context obtained from SNESCreate()
  • iter - current iteration number
  • rnorm - current relative norm of the residual

Level: developer

See also: SNES, SNESMonitorSet()

External Links

source
PETSc.LibPETSc.SNESMonitorCancel — Method
SNESMonitorCancel(petsclib::PetscLibType, snes::AbstractSNES)

Clears all the monitor functions for a SNES object.

Logically Collective

Input Parameter:

  • snes - the SNES context

Options Database Key:

  • -snes_monitor_cancel - cancels all monitors that have been hardwired

into a code by calls to SNESMonitorSet(), but does not cancel those set via the options database

Level: intermediate

See also: SNES, SNESMonitorDefault(), SNESMonitorSet()

External Links

source
PETSc.LibPETSc.SNESMonitorDefault — Method
SNESMonitorDefault(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors progress of a SNESSolve() (default).

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - viewer and format structure

Options Database Key:

  • -snes_monitor - use this function to monitor the convergence of the nonlinear solver

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorSolution(), SNESMonitorFunction(), SNESMonitorResidual(), SNESMonitorSolutionUpdate(), SNESMonitorScaling(), SNESMonitorRange(), SNESMonitorRatio(), SNESMonitorDefaultField(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorDefaultField — Method
SNESMonitorDefaultField(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors progress of a SNESSolve(), separated into fields.

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - the PetscViewer

Options Database Key:

  • -snes_monitor_field - activate this monitor

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorSolution(), SNESMonitorDefault(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorDefaultSetUp — Method
SNESMonitorDefaultSetUp(petsclib::PetscLibType, snes::AbstractSNES, vf::Vector{PetscViewerAndFormat})

Prepare the PetscViewerAndFormat associated with SNESMonitorDefault(), in particular by initializing the underlying PetscDrawLG when the viewer format is PETSC_VIEWER_DRAW_LG

Collective

Input Parameters:

  • snes - the SNES context
  • vf - the viewer/format pair passed to SNESMonitorSet() along with SNESMonitorDefault()

Level: developer

See also: SNES, SNESMonitorSet(), SNESMonitorDefault(), PetscViewerAndFormat, PetscViewerMonitorLGSetUp()

External Links

source
PETSc.LibPETSc.SNESMonitorFields — Method
SNESMonitorFields(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors the residual for each field separately

Collective

Input Parameters:

  • snes - the SNES context, must have an attached DM
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - PetscViewerAndFormat of PetscViewerType PETSCVIEWERASCII

Level: intermediate

See also: SNES, SNESMonitorSet(), SNESMonitorDefault()

External Links

source
PETSc.LibPETSc.SNESMonitorJacUpdateSpectrum — Method
SNESMonitorJacUpdateSpectrum(petsclib::PetscLibType, snes::AbstractSNES, it::PetscInt, fnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors the spectrun of the change in the Jacobian from the last Jacobian evaluation of a SNESSolve()

Collective

Input Parameters:

  • snes - the SNES context
  • it - iteration number
  • fnorm - 2-norm of residual
  • vf - viewer and format structure

Options Database Key:

  • -snes_monitor_jacupdate_spectrum - activates this monitor

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorSolution(), SNESMonitorRange(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorLGRange — Method
SNESMonitorLGRange(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt, rnorm::PetscReal, monctx::Ptr{Cvoid})

Line-graph monitor that plots the residual norm together with residual-range statistics for a SNESSolve()

Collective

Input Parameters:

  • snes - the SNES context
  • n - the iteration number
  • rnorm - the 2-norm of the residual
  • monctx - a PetscViewer of type PETSCVIEWERDRAW set up with PetscViewerMonitorLGSetUp()

Level: intermediate

See also: SNES, SNESMonitorSet(), SNESMonitorDefault(), PetscViewerDrawGetDrawLG(), PetscDrawLG

External Links

source
PETSc.LibPETSc.SNESMonitorRange — Method
SNESMonitorRange(petsclib::PetscLibType, snes::AbstractSNES, it::PetscInt, rnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Prints the percentage of residual elements that are more than 10 percent of the maximum entry in the residual in each iteration of a SNESSolve()

Collective

Input Parameters:

  • snes - SNES iterative context
  • it - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - unused monitor context

Options Database Key:

  • -snes_monitor_range - Activates SNESMonitorRange()

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorDefault(), SNESMonitorLGCreate(), SNESMonitorScaling(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorRatio — Method
SNESMonitorRatio(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors progress of a SNESSolve() by printing the ratio of residual norm at each iteration to the previous.

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual (or gradient)
  • vf - context of monitor

Options Database Key:

  • -snes_monitor_ratio - activate this monitor

Level: intermediate

See also: SNESMonitorRationSetUp(), SNESMonitorSet(), SNESMonitorSolution(), SNESMonitorDefault(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorRatioSetUp — Method
SNESMonitorRatioSetUp(petsclib::PetscLibType, snes::AbstractSNES, vf::Vector{PetscViewerAndFormat})

Insures the SNES object is saving its history since this monitor needs access to it

Collective

Input Parameters:

  • snes - the SNES context
  • vf - PetscViewerAndFormat (ignored)

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorSolution(), SNESMonitorDefault(), SNESMonitorRatio(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorResidual — Method
SNESMonitorResidual(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors progress of a SNESSolve() by calling VecView() for the residual at each iteration.

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - a viewer

Options Database Key:

  • -snes_monitor_residual [ascii binary draw][:filename][:viewer format] - plots residual (not its norm) at each iteration

Level: intermediate

See also: SNES, SNESMonitorSet(), SNESMonitorDefault(), VecView(), SNESMonitor()

External Links

source
PETSc.LibPETSc.SNESMonitorSAWs — Method
SNESMonitorSAWs(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt, rnorm::PetscReal, ctx::Ptr{Cvoid})

monitor solution process of SNES using SAWs

Collective

Input Parameters:

  • snes - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • ctx - PetscViewer of type PETSCVIEWERSAWS

Level: advanced

See also: PetscViewerSAWsOpen(), SNESMonitorSAWsDestroy(), SNESMonitorSAWsCreate()

External Links

source
PETSc.LibPETSc.SNESMonitorSAWsCreate — Method
ctx::Ptr{Cvoid} = SNESMonitorSAWsCreate(petsclib::PetscLibType, snes::AbstractSNES)

create an SAWs monitor context for SNES

Collective

Input Parameter:

  • snes - SNES to monitor

Output Parameter:

  • ctx - context for monitor

Level: developer

See also: SNESMonitorSet(), SNES, SNESMonitorSAWs(), SNESMonitorSAWsDestroy()

External Links

source
PETSc.LibPETSc.SNESMonitorScaling — Method
SNESMonitorScaling(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors the largest value in each row of the Jacobian of a SNESSolve()

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - viewer and format structure

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorSolution(), SNESMonitorRange(), SNESMonitorJacUpdateSpectrum(), PetscViewerFormat, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.SNESMonitorSet — Method
SNESMonitorSet(petsclib::PetscLibType, snes::AbstractSNES, f::external, mctx::Ptr{Cvoid}, monitordestroy::Ptr{Cvoid})

Sets an ADDITIONAL function that is to be used at every iteration of the SNES nonlinear solver to display the iteration's progress.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • f - the monitor function, for the calling sequence see SNESMonitorFunction
  • mctx - [optional] user-defined context for private data for the monitor routine (use NULL if no context is desired)
  • monitordestroy - [optional] routine that frees monitor context (may be NULL), see PetscCtxDestroyFn for the calling sequence

Calling sequence of f:

  • snes - the SNES object
  • it - the current iteration
  • rnorm - norm of the residual
  • mctx - the optional monitor context

Options Database Keys:

  • -snes_monitor - sets SNESMonitorDefault()
  • -snes_monitor draw::draw_lg - sets line graph monitor
  • -snes_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to SNESMonitorSet(), but does not cancel those set via

the options database.

Level: intermediate

See also: SNES, SNESSolve(), SNESMonitorDefault(), SNESMonitorCancel(), SNESMonitorFunction, PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.SNESMonitorSetFromOptions — Method
SNESMonitorSetFromOptions(petsclib::PetscLibType, snes::AbstractSNES, name::String, help::String, manual::String, monitor::external, monitorsetup::external)

Sets a monitor function and viewer appropriate for the type indicated by the user

Collective

Input Parameters:

  • snes - SNES object you wish to monitor
  • name - the monitor type one is seeking
  • help - message indicating what monitoring is done
  • manual - manual page for the monitor
  • monitor - the monitor function, this must use a PetscViewerFormat as its context
  • monitorsetup - a function that is called once ONLY if the user selected this monitor that may set additional features of the SNES or PetscViewer objects

Calling sequence of monitor:

  • snes - the nonlinear solver context
  • it - the current iteration
  • r - the current function norm
  • vf - a PetscViewerAndFormat struct that contains the PetscViewer and PetscViewerFormat to use

Calling sequence of monitorsetup:

  • snes - the nonlinear solver context
  • vf - a PetscViewerAndFormat struct that contains the PetscViewer and PetscViewerFormat to use

Options Database Key:

  • -name - trigger the use of this monitor in SNESSetFromOptions()

Level: advanced

See also: PetscOptionsCreateViewer(), PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHeadBegin(), PetscOptionsStringArray(), PetscOptionsRealArray(), PetscOptionsScalar(), PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), PetscOptionsFList(), PetscOptionsEList()

External Links

source
PETSc.LibPETSc.SNESMonitorSolution — Method
SNESMonitorSolution(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors progress of a SNES SNESSolve() by calling VecView() for the approximate solution at each iteration.

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - a viewer

Options Database Key:

  • -snes_monitor_solution [ascii binary draw][:filename][:viewer format] - plots solution at each iteration

Level: intermediate

See also: SNES, SNESMonitorSet(), SNESMonitorDefault(), VecView()

External Links

source
PETSc.LibPETSc.SNESMonitorSolutionUpdate — Method
SNESMonitorSolutionUpdate(petsclib::PetscLibType, snes::AbstractSNES, its::PetscInt, fgnorm::PetscReal, vf::Vector{PetscViewerAndFormat})

Monitors progress of a SNESSolve() by calling VecView() for the UPDATE to the solution at each iteration.

Collective

Input Parameters:

  • snes - the SNES context
  • its - iteration number
  • fgnorm - 2-norm of residual
  • vf - a viewer

Options Database Key:

  • -snes_monitor_solution_update [ascii binary draw][:filename][:viewer format] - plots update to solution at each iteration

Level: intermediate

See also: SNESMonitorSet(), SNESMonitorDefault(), VecView(), SNESMonitor()

External Links

source
PETSc.LibPETSc.SNESMultiblockGetSubSNES — Method
n::PetscInt,subsnes::Vector{SNES} = SNESMultiblockGetSubSNES(petsclib::PetscLibType, snes::AbstractSNES)

Gets the SNES contexts for all blocks in a SNESMULTIBLOCK solver.

Not Collective but each SNES obtained is parallel

Input Parameter:

  • snes - the solver context

Output Parameters:

  • n - the number of blocks
  • subsnes - the array of SNES contexts

Level: advanced

See also: SNES, SNESMULTIBLOCK, SNESMultiblockSetIS(), SNESMultiblockSetFields()

External Links

source
PETSc.LibPETSc.SNESMultiblockSetBlockSize — Method
SNESMultiblockSetBlockSize(petsclib::PetscLibType, snes::AbstractSNES, bs::PetscInt)

Sets the block size for structured block division in a SNESMULTIBLOCK solver. If not set the matrix block size is used.

Logically Collective

Input Parameters:

  • snes - the solver context
  • bs - the block size

Level: intermediate

See also: SNES, SNESMULTIBLOCK, SNESMultiblockGetSubSNES(), SNESMultiblockSetFields()

External Links

source
PETSc.LibPETSc.SNESMultiblockSetFields — Method
SNESMultiblockSetFields(petsclib::PetscLibType, snes::AbstractSNES, name::String, n::PetscInt, fields::Vector{PetscInt})

Sets the fields for one particular block in a SNESMULTIBLOCK solver

Logically Collective

Input Parameters:

  • snes - the solver
  • name - name of this block, if NULL the number of the block is used
  • n - the number of fields in this block
  • fields - the fields in this block

Level: intermediate

See also: SNES, SNESMULTIBLOCK, SNESMultiblockGetSubSNES(), SNESMultiblockSetBlockSize(), SNESMultiblockSetIS()

External Links

source
PETSc.LibPETSc.SNESMultiblockSetIS — Method
SNESMultiblockSetIS(petsclib::PetscLibType, snes::AbstractSNES, name::String, is::AbstractIS)

Sets the global row indices for one particular block in a SNESMULTIBLOCK solver

Logically Collective

Input Parameters:

  • snes - the solver context
  • name - name of this block, if NULL the number of the block is used
  • is - the index set that defines the global row indices in this block

Level: intermediate

See also: SNES, SNESMULTIBLOCK, SNESMultiblockGetSubSNES(), SNESMultiblockSetBlockSize(), SNESMultiblockSetFields()

External Links

source
PETSc.LibPETSc.SNESMultiblockSetType — Method
SNESMultiblockSetType(petsclib::PetscLibType, snes::AbstractSNES, type::PCCompositeType)

Sets the type of block combination used for a SNESMULTIBLOCK solver

Logically Collective

Input Parameters:

  • snes - the solver context
  • type - PC_COMPOSITE_ADDITIVE, PC_COMPOSITE_MULTIPLICATIVE (default), PC_COMPOSITE_SYMMETRIC_MULTIPLICATIVE

Options Database Key:

  • -snes_multiblock_type (multiplicative|additive|symmetric_multiplicative) - Sets block combination type

Level: advanced

See also: SNES, SNESMULTIBLOCK, PCCompositeSetType(), PC_COMPOSITE_ADDITIVE, PC_COMPOSITE_MULTIPLICATIVE, PC_COMPOSITE_SYMMETRIC_MULTIPLICATIVE, PCCompositeType, SNESCOMPOSITE, SNESCompositeSetType()

External Links

source
PETSc.LibPETSc.SNESNASMGetDamping — Method
dmp::PetscReal = SNESNASMGetDamping(petsclib::PetscLibType, snes::AbstractSNES)

Gets the update damping for SNESNASM the nonlinear additive Schwarz solver

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • dmp - damping

Level: intermediate

See also: SNES, SNESNASM, SNESNASMSetDamping()

External Links

source
PETSc.LibPETSc.SNESNASMGetNumber — Method
n::PetscInt = SNESNASMGetNumber(petsclib::PetscLibType, snes::AbstractSNES)

Gets number of subsolvers

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • n - the number of subsolvers

Level: intermediate

See also: SNESNASM, SNESNASMGetSNES()

External Links

source
PETSc.LibPETSc.SNESNASMGetSNES — Method
subsnes::SNES = SNESNASMGetSNES(petsclib::PetscLibType, snes::AbstractSNES, i::PetscInt)

Gets a subsolver

Not Collective

Input Parameters:

  • snes - the SNES context
  • i - the number of the subsnes to get

Output Parameter:

  • subsnes - the subsolver context

Level: intermediate

See also: SNESNASM, SNESNASMGetNumber()

External Links

source
PETSc.LibPETSc.SNESNASMGetSubdomainVecs — Method
n::PetscInt,x::Vector{PetscVec},y::Vector{PetscVec},b::Vector{PetscVec},xl::Vector{PetscVec} = SNESNASMGetSubdomainVecs(petsclib::PetscLibType, snes::AbstractSNES)

Get the processor-local subdomain vectors for the nonlinear additive Schwarz solver

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • n - the number of local subdomains
  • x - The subdomain solution vector
  • y - The subdomain step vector
  • b - The subdomain RHS vector
  • xl - The subdomain local vectors (ghosted)

Level: developer

See also: SNES, SNESNASM, SNESNASMGetSubdomains()

External Links

source
PETSc.LibPETSc.SNESNASMGetSubdomains — Method
n::PetscInt,subsnes::Vector{SNES},iscatter::Vector{VecScatter},oscatter::Vector{VecScatter},gscatter::Vector{VecScatter} = SNESNASMGetSubdomains(petsclib::PetscLibType, snes::AbstractSNES)

Get the local subdomain contexts for the nonlinear additive Schwarz solver

Not Collective but some of the objects returned will be parallel

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • n - the number of local subdomains
  • subsnes - solvers defined on the local subdomains
  • iscatter - scatters into the nonoverlapping portions of the local subdomains
  • oscatter - scatters into the overlapping portions of the local subdomains
  • gscatter - scatters into the (ghosted) local vector of the local subdomain

Level: intermediate

See also: SNES, SNESNASM, SNESNASMSetSubdomains()

External Links

source
PETSc.LibPETSc.SNESNASMGetType — Method
type::PCASMType = SNESNASMGetType(petsclib::PetscLibType, snes::AbstractSNES)

Get the type of subdomain update used for the nonlinear additive Schwarz solver SNESNASM

Logically Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • type - the type of update

Level: intermediate

See also: SNES, SNESNASM, SNESNASMSetType(), PCASMGetType(), PC_ASM_BASIC, PC_ASM_RESTRICT, PCASMType

External Links

source
PETSc.LibPETSc.SNESNASMSetComputeFinalJacobian — Method
SNESNASMSetComputeFinalJacobian(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Schedules the computation of the global and subdomain Jacobians upon convergence for the nonlinear additive Schwarz solver

Collective

Input Parameters:

  • snes - the SNES context
  • flg - PETSC_TRUE to compute the Jacobians

Level: developer

See also: SNES, SNESNASM, SNESNASMGetSubdomains()

External Links

source
PETSc.LibPETSc.SNESNASMSetDamping — Method
SNESNASMSetDamping(petsclib::PetscLibType, snes::AbstractSNES, dmp::PetscReal)

Sets the update damping for SNESNASM the nonlinear additive Schwarz solver

Logically Collective

Input Parameters:

  • snes - the SNES context
  • dmp - damping

Options Database Key:

  • -snes_nasm_damping dmp - the new solution is obtained as old solution plus dmp times (sum of the solutions on the subdomains)

Level: intermediate

See also: SNES, SNESNASM, SNESNASMGetDamping()

External Links

source
PETSc.LibPETSc.SNESNASMSetSubdomains — Method
SNESNASMSetSubdomains(petsclib::PetscLibType, snes::AbstractSNES, n::PetscInt, subsnes::Vector{<:AbstractSNES}, iscatter::Vector{VecScatter}, oscatter::Vector{VecScatter}, gscatter::Vector{VecScatter})

Manually Set the context required to restrict and solve subdomain problems in the nonlinear additive Schwarz solver

Logically Collective

Input Parameters:

  • snes - the SNES context
  • n - the number of local subdomains
  • subsnes - solvers defined on the local subdomains
  • iscatter - scatters into the nonoverlapping portions of the local subdomains
  • oscatter - scatters into the overlapping portions of the local subdomains
  • gscatter - scatters into the (ghosted) local vector of the local subdomain

Level: intermediate

See also: SNES, SNESNASM, SNESNASMGetSubdomains()

External Links

source
PETSc.LibPETSc.SNESNASMSetType — Method
SNESNASMSetType(petsclib::PetscLibType, snes::AbstractSNES, type::PCASMType)

Set the type of subdomain update used for the nonlinear additive Schwarz solver SNESNASM

Logically Collective

Input Parameters:

  • snes - the SNES context
  • type - the type of update, PC_ASM_BASIC or PC_ASM_RESTRICT

Options Database Key:

  • -snes_nasm_type (basic|restrict) - type of subdomain update used

Level: intermediate

See also: SNES, SNESNASM, SNESNASMGetType(), PCASMSetType(), PC_ASM_BASIC, PC_ASM_RESTRICT, PCASMType

External Links

source
PETSc.LibPETSc.SNESNASMSetWeight — Method
SNESNASMSetWeight(petsclib::PetscLibType, snes::AbstractSNES, weight::AbstractPetscVec)

Sets weight to use when adding overlapping updates

Collective

Input Parameters:

  • snes - the SNES context
  • weight - the weights to use (typically 1/N for each dof, where N is the number of patches it appears in)

Level: intermediate

See also: SNESNASM

External Links

source
PETSc.LibPETSc.SNESNCGSetType — Method
SNESNCGSetType(petsclib::PetscLibType, snes::AbstractSNES, btype::SNESNCGType)

Sets the conjugate update type for nonlinear CG SNESNCG.

Logically Collective

Input Parameters:

  • snes - the iterative context
  • btype - update type, see SNESNCGType

Options Database Key:

  • -snes_ncg_type (prp|fr|hs|dy|cd) - strategy for selecting algorithm for computing beta

Level: intermediate

See also: SNES, SNESNCG, SNESNCGType, SNES_NCG_FR, SNES_NCG_PRP, SNES_NCG_HS, SNES_NCG_DY, SNES_NCG_CD

External Links

source
PETSc.LibPETSc.SNESNGMRESGetRestartFmRise — Method
flg::PetscBool = SNESNGMRESGetRestartFmRise(petsclib::PetscLibType, snes::AbstractSNES)

Get whether SNESNGMRES increases the restart count when a step xM increases the residual FM

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • flg - PETSC_TRUE if the option is enabled

Level: advanced

See also: SNES, SNESNGMRES, SNESNGMRESSetRestartFmRise(), SNESNGMRESSetRestartType()

External Links

source
PETSc.LibPETSc.SNESNGMRESSetRestartFmRise — Method
SNESNGMRESSetRestartFmRise(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Increase the restart count if the step xM increases the residual FM inside a SNESNGMRES solve

Input Parameters:

  • snes - the SNES context.
  • flg - boolean value deciding whether to use the option or not, default is PETSC_FALSE

Options Database Key:

  • -snes_ngmres_restart_fm_rise (true|false) - Increase the restart count if the step xM increases the residual FM

Level: advanced

See also: SNES, SNES_NGMRES_RESTART_DIFFERENCE, SNESNGMRES, SNESNGMRESRestartType, SNESNGMRESSetRestartType()

External Links

source
PETSc.LibPETSc.SNESNGMRESSetRestartType — Method
SNESNGMRESSetRestartType(petsclib::PetscLibType, snes::AbstractSNES, rtype::SNESNGMRESRestartType)

Sets the restart type for SNESNGMRES.

Logically Collective

Input Parameters:

  • snes - the iterative context
  • rtype - restart type, see SNESNGMRESRestartType

Options Database Keys:

  • -snes_ngmres_restart_type (difference|periodic|none) - set the restart type
  • -snes_ngmres_restart restart - sets the number of iterations before restart for periodic

Level: intermediate

See also: SNES, SNES_NGMRES_RESTART_DIFFERENCE, SNESNGMRES, SNESNGMRESRestartType, SNESNGMRESSetRestartFmRise(), SNESNGMRESSetSelectType()

External Links

source
PETSc.LibPETSc.SNESNGMRESSetSelectType — Method
SNESNGMRESSetSelectType(petsclib::PetscLibType, snes::AbstractSNES, stype::SNESNGMRESSelectType)

Sets the selection type for SNESNGMRES. This determines how the candidate solution and combined solution are used to create the next iterate.

Logically Collective

Input Parameters:

  • snes - the iterative context
  • stype - selection type, see SNESNGMRESSelectType

Options Database Key:

  • -snes_ngmres_select_type (difference|none|linesearch) - select type

Level: intermediate

See also: SNES, SNESNGMRES, SNESNGMRESSelectType, SNES_NGMRES_SELECT_NONE, SNES_NGMRES_SELECT_DIFFERENCE, SNES_NGMRES_SELECT_LINESEARCH, SNESNGMRESSetRestartType()

External Links

source
PETSc.LibPETSc.SNESNGSGetSweeps — Method
sweeps::PetscInt = SNESNGSGetSweeps(petsclib::PetscLibType, snes::AbstractSNES)

Gets the number of sweeps nonlinear GS will use in SNESNCG

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • sweeps - the number of sweeps of nonlinear GS to perform.

Level: intermediate

See also: SNES, SNESNCG, SNESSetNGS(), SNESGetNGS(), SNESSetNPC(), SNESNGSSetSweeps()

External Links

source
PETSc.LibPETSc.SNESNGSGetTolerances — Method
atol::PetscReal,rtol::PetscReal,stol::PetscReal,maxit::PetscInt = SNESNGSGetTolerances(petsclib::PetscLibType, snes::AbstractSNES)

Gets various parameters used in convergence tests for nonlinear Gauss-Seidel SNESNCG

Not Collective

Input Parameters:

  • snes - the SNES context
  • atol - absolute convergence tolerance
  • rtol - relative convergence tolerance
  • stol - convergence tolerance in terms of the norm

of the change in the solution between steps

  • maxit - maximum number of iterations

Level: intermediate

See also: SNES, SNESNCG, SNESSetTolerances()

External Links

source
PETSc.LibPETSc.SNESNGSSetSweeps — Method
SNESNGSSetSweeps(petsclib::PetscLibType, snes::AbstractSNES, sweeps::PetscInt)

Sets the number of sweeps of nonlinear GS to use in SNESNCG

Logically Collective

Input Parameters:

  • snes - the SNES context
  • sweeps - the number of sweeps of nonlinear GS to perform.

Options Database Key:

  • -snes_ngs_sweeps n - Number of sweeps of nonlinear GS to apply

Level: intermediate

See also: SNES, SNESNCG, SNESSetNGS(), SNESGetNGS(), SNESSetNPC(), SNESNGSGetSweeps()

External Links

source
PETSc.LibPETSc.SNESNGSSetTolerances — Method
SNESNGSSetTolerances(petsclib::PetscLibType, snes::AbstractSNES, abstol::PetscReal, rtol::PetscReal, stol::PetscReal, maxit::PetscInt)

Sets various parameters used in convergence tests for nonlinear Gauss-Seidel SNESNCG

Logically Collective

Input Parameters:

  • snes - the SNES context
  • abstol - absolute convergence tolerance
  • rtol - relative convergence tolerance
  • stol - convergence tolerance in terms of the norm of the change in the solution between steps, || delta x || < stol*|| x ||
  • maxit - maximum number of iterations

Options Database Keys:

  • -snes_ngs_atol abstol - Sets abstol
  • -snes_ngs_rtol rtol - Sets rtol
  • -snes_ngs_stol stol - Sets stol
  • -snes_max_it maxit - Sets maxit

Level: intermediate

See also: SNES, SNESNCG

External Links

source
PETSc.LibPETSc.SNESNewtonALComputeFunction — Method
SNESNewtonALComputeFunction(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, Q::AbstractPetscVec)

Calls the function that has been set with SNESNewtonALSetFunction().

Collective

Input Parameters:

  • snes - the SNES context
  • X - input vector

Output Parameter:

  • Q - tangent load vector, as set by SNESNewtonALSetFunction()

Level: developer

See also: SNES, SNESNewtonALSetFunction(), SNESNewtonALGetFunction()

External Links

source
PETSc.LibPETSc.SNESNewtonALGetFunction — Method
SNESNewtonALGetFunction(petsclib::PetscLibType, snes::AbstractSNES, func::Ptr{Ptr{Cvoid}}, ctx::Ptr{Cvoid})

Get the user function and context set with SNESNewtonALSetFunction

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • func - [optional] tangent load function evaluation routine, see SNESNewtonALSetFunction() for the call sequence
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESNEWTONAL, SNESNewtonALSetFunction()

External Links

source
PETSc.LibPETSc.SNESNewtonALGetLoadParameter — Method
lambda::PetscReal = SNESNewtonALGetLoadParameter(petsclib::PetscLibType, snes::AbstractSNES)

Get the value of the load parameter lambda for the arc-length continuation method.

Logically Collective

Input Parameter:

  • snes - the nonlinear solver object

Output Parameter:

  • lambda - the arc-length parameter

Level: intermediate

See also: SNES, SNESNEWTONAL, SNESNewtonALSetFunction()

External Links

source
PETSc.LibPETSc.SNESNewtonALSetCorrectionType — Method
SNESNewtonALSetCorrectionType(petsclib::PetscLibType, snes::AbstractSNES, ctype::SNESNewtonALCorrectionType)

Set the type of correction to use in the arc-length continuation method.

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • ctype - the type of correction to use

Options Database Key:

  • -snes_newtonal_correction_type type - Set the type of correction to use; use -help for a list of available types

Level: intermediate

See also: SNES, SNESNEWTONAL, SNESNewtonALCorrectionType

External Links

source
PETSc.LibPETSc.SNESNewtonALSetDiagonalScaling — Method
SNESNewtonALSetDiagonalScaling(petsclib::PetscLibType, snes::AbstractSNES, v::AbstractPetscVec)

Set the global vector used to rescale DoFs for computation of arc length.

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • v - the Vec containing diagonal scaling for each DoF, must be the same size as the solution vector (may be NULL)

See also: SNES, SNESNEWTONAL, SNESNewtonALSetFunction(), SNESNewtonALGetLoadParameter()

External Links

source
PETSc.LibPETSc.SNESNewtonALSetFunction — Method
SNESNewtonALSetFunction(petsclib::PetscLibType, snes::AbstractSNES, func::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets a user function that is called at each function evaluation to compute the tangent load vector for the arc-length continuation method.

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • func - [optional] tangent load function evaluation routine, see SNESFunctionFn for the calling sequence. U is the current solution vector, Q is the output tangent load vector
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESNEWTONAL, SNESNewtonALGetFunction(), SNESNewtonALGetLoadParameter()

External Links

source
PETSc.LibPETSc.SNESNewtonTRDCGetPostCheck — Method
SNESNewtonTRDCGetPostCheck(petsclib::PetscLibType, snes::AbstractSNES, noname::Ptr{Cvoid})

Gets the post-check function optionally set with SNESNewtonTRDCSetPostCheck()

Not Collective

Input Parameter:

  • snes - the nonlinear solver context

Output Parameters:

  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRDCPostCheck()
  • ctx - [optional] context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • W - the tentative new solution value
  • changed_y - output, flag indicated Y has been changed by the post-check
  • changed_w - output, flag indicated W has been changed by the post-check
  • ctx - the optional application context

Level: intermediate

See also: SNES, SNESNEWTONTRDC, SNESNewtonTRDCSetPostCheck(), SNESNewtonTRDCPostCheck(), SNESNewtonTRDCSetPreCheck(), SNESNewtonTRDCGetPreCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRDCGetPreCheck — Method
SNESNewtonTRDCGetPreCheck(petsclib::PetscLibType, snes::AbstractSNES, noname::Ptr{Cvoid})

Gets the pre-check function optionally set with SNESNewtonTRDCSetPreCheck()

Not Collective

Input Parameter:

  • snes - the nonlinear solver context

Output Parameters:

  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRDCPreCheck()
  • ctx - [optional] context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • changed - output, flag indicating Y has been changed by the pre-check
  • ctx - the optional application context

Level: intermediate

See also: SNES, SNESNEWTONTRDC, SNESNewtonTRDCSetPreCheck(), SNESNewtonTRDCPreCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRDCGetRhoFlag — Method
rho_flag::PetscBool = SNESNewtonTRDCGetRhoFlag(petsclib::PetscLibType, snes::AbstractSNES)

Get whether the current solution update is within the trust-region.

Logically Collective

Input Parameter:

  • snes - the nonlinear solver object

Output Parameter:

  • rho_flag - PETSC_FALSE or PETSC_TRUE

Level: developer

See also: SNES, SNESNEWTONTRDC, SNESNewtonTRDCPreCheck(), SNESNewtonTRDCGetPreCheck(), SNESNewtonTRDCSetPreCheck(), SNESNewtonTRDCSetPostCheck(), SNESNewtonTRDCGetPostCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRDCSetPostCheck — Method
SNESNewtonTRDCSetPostCheck(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Sets a user function that is called after the search step has been determined but before the next function evaluation. Allows the user a chance to change or override the decision of the line search routine

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRDCPostCheck()
  • ctx - [optional] context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • W - the tentative new solution value
  • changed_y - output, flag indicated Y has been changed by the post-check
  • changed_w - output, flag indicated W has been changed by the post-check
  • ctx - the optional application context

Level: intermediate

See also: SNES, SNESNEWTONTRDC, SNESNewtonTRDCPostCheck(), SNESNewtonTRDCGetPostCheck(), SNESNewtonTRDCSetPreCheck(), SNESNewtonTRDCGetPreCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRDCSetPreCheck — Method
SNESNewtonTRDCSetPreCheck(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Sets a user function that is called before the search step has been determined. Allows the user a chance to change or override the trust region decision.

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRDCPreCheck()
  • ctx - [optional] application context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • changed - output, flag indicating Y has been changed by the pre-check
  • ctx - the optional application context

Level: intermediate

See also: SNES, SNESNEWTONTRDC, SNESNewtonTRDCPreCheck(), SNESNewtonTRDCGetPreCheck(), SNESNewtonTRDCSetPostCheck(), SNESNewtonTRDCGetPostCheck(), SNESNewtonTRDCGetRhoFlag()

External Links

source
PETSc.LibPETSc.SNESNewtonTRGetPostCheck — Method
SNESNewtonTRGetPostCheck(petsclib::PetscLibType, snes::AbstractSNES, noname::Ptr{Cvoid})

Gets the post-check function

Not Collective

Input Parameter:

  • snes - the nonlinear solver context

Output Parameters:

  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRPostCheck()
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • W - the tentative new solution value
  • changed_Y - output, flag indicated Y has been changed by the post-check
  • changed_W - output, flag indicated W has been changed by the post-check
  • ctx - the optional application context

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRSetPostCheck(), SNESNewtonTRPostCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRGetPreCheck — Method
SNESNewtonTRGetPreCheck(petsclib::PetscLibType, snes::AbstractSNES, noname::Ptr{Cvoid})

Gets the pre-check function

Not Collective

Input Parameter:

  • snes - the nonlinear solver context

Output Parameters:

  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRPreCheck()
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • changed - output, flag indicating Y has been changed by the pre-check
  • ctx - the optional application context

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRSetPreCheck(), SNESNewtonTRPreCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRGetTolerances — Method
delta_min::PetscReal,delta_max::PetscReal,delta_0::PetscReal = SNESNewtonTRGetTolerances(petsclib::PetscLibType, snes::AbstractSNES)

Gets the trust region parameter tolerances.

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • delta_min - minimum allowed trust region size or NULL
  • delta_max - maximum allowed trust region size or NULL
  • delta_0 - initial trust region size or NULL

Level: intermediate

See also: SNES, SNESNEWTONTR, SNESNewtonTRSetTolerances()

External Links

source
PETSc.LibPETSc.SNESNewtonTRGetUpdateParameters — Method
eta1::PetscReal,eta2::PetscReal,eta3::PetscReal,t1::PetscReal,t2::PetscReal = SNESNewtonTRGetUpdateParameters(petsclib::PetscLibType, snes::AbstractSNES)

Gets the trust region update parameters.

Not Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • eta1 - acceptance tolerance
  • eta2 - shrinking tolerance
  • eta3 - enlarging tolerance
  • t1 - shrink factor
  • t2 - enlarge factor

Level: intermediate

See also: SNES, SNESNEWTONTR, SNESNewtonTRSetUpdateParameters()

External Links

source
PETSc.LibPETSc.SNESNewtonTRPostCheck — Method
changed_Y::PetscBool,changed_W::PetscBool = SNESNewtonTRPostCheck(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, Y::AbstractPetscVec, W::AbstractPetscVec)

Runs the postcheck routine

Logically Collective

Input Parameters:

  • snes - the solver
  • X - The last solution
  • Y - The full step direction
  • W - The updated solution, W = X - Y

Output Parameters:

  • changed_Y - indicator if step has been changed
  • changed_W - Indicator if the new candidate solution W has been changed.

See also: SNESNEWTONTR, SNESNewtonTRSetPostCheck(), SNESNewtonTRGetPostCheck(), SNESNewtonTRPreCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRPreCheck — Method
changed_Y::PetscBool = SNESNewtonTRPreCheck(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, Y::AbstractPetscVec)

Runs the precheck routine

Logically Collective

Input Parameters:

  • snes - the solver
  • X - The last solution
  • Y - The step direction

Output Parameter:

  • changed_Y - Indicator that the step direction Y has been changed.

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRSetPreCheck(), SNESNewtonTRGetPreCheck(), SNESNewtonTRPostCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetFallbackType — Method
SNESNewtonTRSetFallbackType(petsclib::PetscLibType, snes::AbstractSNES, ftype::SNESNewtonTRFallbackType)

Set the type of fallback to use if the solution of the trust region subproblem is outside the radius

Input Parameters:

  • snes - the nonlinear solver object
  • ftype - the fallback type, see SNESNewtonTRFallbackType

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRPreCheck(), SNESNewtonTRGetPreCheck(), SNESNewtonTRSetPreCheck(), SNESNewtonTRSetPostCheck(), SNESNewtonTRGetPostCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetNormType — Method
SNESNewtonTRSetNormType(petsclib::PetscLibType, snes::AbstractSNES, norm::NormType)

Specify the type of norm to use for the computation of the trust region.

Input Parameters:

  • snes - the nonlinear solver object
  • norm - the norm type

Level: intermediate

See also: SNESNEWTONTR, NormType

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetPostCheck — Method
SNESNewtonTRSetPostCheck(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Sets a user function that is called after the search step has been determined but before the next function evaluation. Allows the user a chance to change or override the internal decision of the solver

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRPostCheck()
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • W - the tentative new solution value
  • changed_Y - output, flag indicated Y has been changed by the post-check
  • changed_W - output, flag indicated W has been changed by the post-check
  • ctx - the optional application context

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRPostCheck(), SNESNewtonTRGetPostCheck(), SNESNewtonTRSetPreCheck(), SNESNewtonTRGetPreCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetPreCheck — Method
SNESNewtonTRSetPreCheck(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Sets a user function that is called before the search step has been determined. Allows the user a chance to change or override the trust region decision.

Logically Collective

Input Parameters:

  • snes - the nonlinear solver object
  • func - [optional] function evaluation routine, for the calling sequence see SNESNewtonTRPreCheck()
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • snes - the nonlinear solver object
  • X - the current solution value
  • Y - the tentative update step
  • changed - output, flag indicating Y has been changed by the pre-check
  • ctx - the optional application context

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRPreCheck(), SNESNewtonTRGetPreCheck(), SNESNewtonTRSetPostCheck(), SNESNewtonTRGetPostCheck()

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetQNType — Method
SNESNewtonTRSetQNType(petsclib::PetscLibType, snes::AbstractSNES, use::SNESNewtonTRQNType)

Specify to use a quasi-Newton model.

Input Parameters:

  • snes - the nonlinear solver object
  • use - the type of approximations to be used

Level: intermediate

See also: SNESNEWTONTR, SNESNewtonTRQNType, MATLMVM

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetTolerances — Method
SNESNewtonTRSetTolerances(petsclib::PetscLibType, snes::AbstractSNES, delta_min::PetscReal, delta_max::PetscReal, delta_0::PetscReal)

Sets the trust region parameter tolerances.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • delta_min - minimum allowed trust region size
  • delta_max - maximum allowed trust region size
  • delta_0 - initial trust region size

Options Database Key:

  • -snes_tr_deltamin tol - Set minimum size
  • -snes_tr_deltamax tol - Set maximum size
  • -snes_tr_delta0 tol - Set initial size

See also: SNES, SNESNEWTONTR, SNESNewtonTRGetTolerances()

External Links

source
PETSc.LibPETSc.SNESNewtonTRSetUpdateParameters — Method
SNESNewtonTRSetUpdateParameters(petsclib::PetscLibType, snes::AbstractSNES, eta1::PetscReal, eta2::PetscReal, eta3::PetscReal, t1::PetscReal, t2::PetscReal)

Sets the trust region update parameters.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • eta1 - acceptance tolerance
  • eta2 - shrinking tolerance
  • eta3 - enlarging tolerance
  • t1 - shrink factor
  • t2 - enlarge factor

Options Database Key:

  • -snes_tr_eta1 tol - Set eta1
  • -snes_tr_eta2 tol - Set eta2
  • -snes_tr_eta3 tol - Set eta3
  • -snes_tr_t1 tol - Set t1
  • -snes_tr_t2 tol - Set t2

See also: SNES, SNESNEWTONTR, SNESSetObjective(), SNESNewtonTRGetUpdateParameters()

External Links

source
PETSc.LibPETSc.SNESObjectiveComputeFunctionDefaultFD — Method
SNESObjectiveComputeFunctionDefaultFD(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, F::AbstractPetscVec, ctx::Ptr{Cvoid})

Computes the gradient of a user provided objective function

Collective

Input Parameters:

  • snes - the SNES context
  • X - the state vector
  • ctx - the (ignored) function context

Output Parameter:

  • F - the function value

Options Database Keys:

  • -snes_fd_function_eps - Tolerance for including non-zero entries into the gradient, default is 1.e-6
  • -snes_fd_function - Computes function from user provided objective function (set with SNESSetObjective()) with finite difference

Level: advanced

See also: SNESSetObjective(), SNESSetFunction(), SNESComputeObjective(), SNESComputeJacobianDefault(), SNESObjectiveFn

External Links

source
PETSc.LibPETSc.SNESParametersInitialize — Method
SNESParametersInitialize(petsclib::PetscLibType, snes::AbstractSNES)

Sets all the parameters in snes to their default value (when SNESCreate() was called) if they currently contain default values

Collective

Input Parameter:

  • snes - the SNES object

Level: developer

See also: SNES, SNESSolve(), SNESDestroy(), SNESSetLagPreconditioner(), SNESSetLagJacobian(), PetscObjectParameterSetDefault()

External Links

source
PETSc.LibPETSc.SNESPatchSetCellNumbering — Method
SNESPatchSetCellNumbering(petsclib::PetscLibType, snes::AbstractSNES, cellNumbering::PetscSection)

Set the PetscSection that provides a numbering of the cells used to define patches in a SNESPATCH solver

Logically Collective

Input Parameters:

  • snes - the SNESPATCH solver
  • cellNumbering - the PetscSection giving the cell numbering; forwarded to the underlying PCPATCH via PCPatchSetCellNumbering()

Level: advanced

See also: SNESPATCH, PCPATCH, PCPatchSetCellNumbering(), PetscSection

External Links

source
PETSc.LibPETSc.SNESPatchSetComputeFunction — Method
SNESPatchSetComputeFunction(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Set the callback used to compute the per-patch nonlinear residual for a SNESPATCH solver

Logically Collective

Input Parameters:

  • snes - the SNESPATCH solver
  • func - callback that computes the patch residual; forwarded to the underlying PCPATCH via PCPatchSetComputeFunction()
  • ctx - optional application context passed to func

Calling sequence of func:

  • pc - the PC associated with the SNESPATCH solver
  • point - the point
  • x - the input solution (not used in linear problems)
  • f - the patch residual vector
  • cellIS - an array of the cell numbers
  • n - the size of dofsArray
  • dofsArray - the dofmap for the dofs to be solved for
  • dofsArrayWithAll - the dofmap for all dofs on the patch
  • ctx - the application context

Level: advanced

See also: SNESPATCH, PCPATCH, PCPatchSetComputeFunction(), SNESPatchSetComputeOperator()

External Links

source
PETSc.LibPETSc.SNESPatchSetComputeOperator — Method
SNESPatchSetComputeOperator(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Set the callback used to assemble the per-patch Jacobian for a SNESPATCH solver

Logically Collective

Input Parameters:

  • snes - the SNESPATCH solver
  • func - callback that assembles the patch Jacobian; forwarded to the underlying PCPATCH via PCPatchSetComputeOperator()
  • ctx - optional application context passed to func

Calling sequence of func:

  • pc - the PC associated with the SNESPATCH solver
  • point - the point
  • x - the input solution (not used in linear problems)
  • mat - the patch matrix
  • cellIS - an array of the cell numbers
  • n - the size of dofsArray
  • dofsArray - the dofmap for the dofs to be solved for
  • dofsArrayWithAll - the dofmap for all dofs on the patch
  • ctx - the application context

Level: advanced

See also: SNESPATCH, PCPATCH, PCPatchSetComputeOperator(), SNESPatchSetComputeFunction()

External Links

source
PETSc.LibPETSc.SNESPatchSetConstructType — Method
SNESPatchSetConstructType(petsclib::PetscLibType, snes::AbstractSNES, ctype::PCPatchConstructType, func::external, ctx::Ptr{Cvoid})

Set the way patches are constructed for a SNESPATCH solver

Logically Collective

Input Parameters:

  • snes - the SNESPATCH solver
  • ctype - the PCPatchConstructType selecting the patch construction strategy
  • func - user callback that builds the patches, used only when ctype is PC_PATCH_USER or PC_PATCH_PYTHON; may be NULL otherwise
  • ctx - optional application context passed to func

Calling sequence of func:

  • pc - the PC associated with the SNESPATCH solver
  • npatch - number of patches
  • patches - the IS that define each patch
  • patchIterationSet - how the patches are iterated over
  • ctx - optional application context

Level: advanced

See also: SNESPATCH, PCPATCH, PCPatchSetConstructType(), PCPatchConstructType

External Links

source
PETSc.LibPETSc.SNESPatchSetDiscretisationInfo — Method
SNESPatchSetDiscretisationInfo(petsclib::PetscLibType, snes::AbstractSNES, nsubspaces::PetscInt, dms::Vector{<:AbstractPetscDM}, bs::Vector{PetscInt}, nodesPerCell::Vector{PetscInt}, cellNodeMap::PetscInt, subspaceOffsets::Vector{PetscInt}, numGhostBcs::PetscInt, ghostBcNodes::Vector{PetscInt}, numGlobalBcs::PetscInt, globalBcNodes::Vector{PetscInt})

Provide the per-subspace discretisation information required by a SNESPATCH to build patch problems

Logically Collective

Input Parameters:

  • snes - the SNESPATCH solver
  • nsubspaces - the number of discretisation subspaces (e.g. fields)
  • dms - array of length nsubspaces of DMs, one per subspace
  • bs - array of length nsubspaces giving the block size of each subspace
  • nodesPerCell - array of length nsubspaces giving the number of nodes per cell for each subspace
  • cellNodeMap - array of length nsubspaces; entry i is a cell-to-node map for subspace i
  • subspaceOffsets - array of length nsubspaces + 1 giving the starting global dof offset of each subspace
  • numGhostBcs - number of ghost (off-process) boundary-condition dofs
  • ghostBcNodes - array of length numGhostBcs of the ghost boundary-condition dof indices
  • numGlobalBcs - number of global boundary-condition dofs
  • globalBcNodes - array of length numGlobalBcs of the global boundary-condition dof indices

Level: advanced

See also: SNESPATCH, PCPATCH, PCPatchSetDiscretisationInfo(), SNESPatchSetComputeOperator(), SNESPatchSetComputeFunction()

External Links

source
PETSc.LibPETSc.SNESPicardComputeFunction — Method
SNESPicardComputeFunction(petsclib::PetscLibType, snes::AbstractSNES, x::AbstractPetscVec, f::AbstractPetscVec, ctx::Ptr{Cvoid})

Compute the residual A(x) x - b(x) using the callbacks registered by SNESSetPicard()

Collective

Input Parameters:

  • snes - the SNES context
  • x - the current iterate
  • ctx - unused application context; the Picard callbacks are retrieved from the attached DMSNES

Output Parameter:

  • f - the residual vector

Level: developer

See also: SNES, SNESSetPicard(), SNESPicardComputeMFFunction(), SNESPicardComputeJacobian()

External Links

source
PETSc.LibPETSc.SNESPicardComputeJacobian — Method
SNESPicardComputeJacobian(petsclib::PetscLibType, snes::AbstractSNES, x1::AbstractPetscVec, J::AbstractPetscMat, B::AbstractPetscMat, ctx::Ptr{Cvoid})

Trivial Jacobian assembly callback used by SNESSetPicard(); the Picard operator is filled in by SNESPicardComputeFunction()

Collective

Input Parameters:

  • snes - the SNES context
  • x1 - the current iterate (unused)
  • J - the Jacobian matrix to assemble
  • B - the preconditioning matrix (unused)
  • ctx - unused application context

Level: developer

See also: SNES, SNESSetPicard(), SNESPicardComputeFunction(), SNESPicardComputeMFFunction()

External Links

source
PETSc.LibPETSc.SNESPicardComputeMFFunction — Method
SNESPicardComputeMFFunction(petsclib::PetscLibType, snes::AbstractSNES, x::AbstractPetscVec, f::AbstractPetscVec, ctx::Ptr{Cvoid})

Matrix-free residual A(x) x - b(x) used by SNESSetPicard() when the operator is applied through -snes_mf_operator

Collective

Input Parameters:

  • snes - the SNES context
  • x - the current iterate
  • ctx - unused application context; the Picard callbacks are retrieved from the attached DMSNES

Output Parameter:

  • f - the residual vector

Level: developer

See also: SNES, SNESSetPicard(), SNESPicardComputeFunction(), SNESPicardComputeJacobian()

External Links

source
PETSc.LibPETSc.SNESPruneJacobianColor — Method
SNESPruneJacobianColor(petsclib::PetscLibType, snes::AbstractSNES, J::AbstractPetscMat, B::AbstractPetscMat)

Remove nondiagonal zeros in the Jacobian matrix and update the MatMFFD coloring information based on the new nonzero structure

Collective

Input Parameters:

  • snes - the SNES context
  • J - Jacobian matrix (not altered in this routine)
  • B - newly computed Jacobian matrix to use with preconditioner (generally the same as J)

Level: intermediate

See also: SNESComputeJacobianDefaultColor(), MatEliminateZeros(), MatFDColoringCreate(), MatFDColoringSetFunction()

External Links

source
PETSc.LibPETSc.SNESPythonGetType — Method
pyname::String = SNESPythonGetType(petsclib::PetscLibType, snes::AbstractSNES)

Get the type of a SNES object implemented in Python set with SNESPythonSetType()

Not Collective

Input Parameter:

  • snes - the nonlinear solver (SNES) context.

Output Parameter:

  • pyname - full dotted Python name [package].module[.{class|function}]

Level: intermediate

See also: SNES, SNESCreate(), SNESSetType(), SNESPYTHON, PetscPythonInitialize(), SNESPythonSetType()

External Links

source
PETSc.LibPETSc.SNESPythonSetType — Method
SNESPythonSetType(petsclib::PetscLibType, snes::AbstractSNES, pyname::String)

Initialize a SNES object implemented in Python.

Collective

Input Parameters:

  • snes - the nonlinear solver (SNES) context.
  • pyname - full dotted Python name [package].module[.{class|function}]

Options Database Key:

  • -snes_python_type pyname - python class

Level: intermediate

See also: SNES, SNESCreate(), SNESSetType(), SNESPYTHON, PetscPythonInitialize(), SNESPythonGetType()

External Links

source
PETSc.LibPETSc.SNESQNSetRestartType — Method
SNESQNSetRestartType(petsclib::PetscLibType, snes::AbstractSNES, rtype::SNESQNRestartType)

Sets the restart type for SNESQN.

Logically Collective

Input Parameters:

  • snes - the iterative context
  • rtype - restart type, see SNESQNRestartType

Options Database Keys:

  • -snes_qn_restart_type (powell|periodic|none) - set the restart type
  • -snes_qn_m m - sets the number of stored updates and the restart period for periodic

Level: intermediate

See also: SNES, SNESQN, SNESQNRestartType, SNES_QN_RESTART_NONE, SNES_QN_RESTART_POWELL, SNES_QN_RESTART_PERIODIC, SNESQNType, SNESQNScaleType

External Links

source
PETSc.LibPETSc.SNESQNSetScaleType — Method
SNESQNSetScaleType(petsclib::PetscLibType, snes::AbstractSNES, stype::SNESQNScaleType)

Sets the scaling type for the inner inverse Jacobian in SNESQN.

Logically Collective

Input Parameters:

  • snes - the nonlinear solver context
  • stype - scale type, see SNESQNScaleType

Options Database Key:

  • -snes_qn_scale_type (diagonal|none|scalar|jacobian) - Scaling type

Level: intermediate

See also: SNES, SNESQN, SNESLineSearch, SNESQNScaleType, SNESSetJacobian(), SNESQNType, SNESQNRestartType

External Links

source
PETSc.LibPETSc.SNESQNSetType — Method
SNESQNSetType(petsclib::PetscLibType, snes::AbstractSNES, qtype::SNESQNType)

Sets the quasi-Newton variant to be used in SNESQN.

Logically Collective

Input Parameters:

  • snes - the iterative context
  • qtype - variant type, see SNESQNType

Options Database Key:

  • -snes_qn_type (lbfgs|broyden|badbroyden) - quasi-Newton type

Level: intermediate

See also: SNESQN, SNES_QN_LBFGS, SNES_QN_BROYDEN, SNES_QN_BADBROYDEN, SNESQNType, SNESQNScaleType, TAOLMVM, TAOBLMVM

External Links

source
PETSc.LibPETSc.SNESRegister — Method
SNESRegister(petsclib::PetscLibType, sname::String, fnc::external)

Adds a method to the nonlinear solver package.

Not Collective

Input Parameters:

  • sname - name of a new user-defined solver
  • function - routine to create method context

Level: advanced

See also: SNESRegisterAll(), SNESRegisterDestroy()

External Links

source
PETSc.LibPETSc.SNESReset — Method
SNESReset(petsclib::PetscLibType, snes::AbstractSNES)

Resets a SNES context to the state it was in before SNESSetUp() was called and removes any allocated Vec and Mat from its data structures

Collective

Input Parameter:

  • snes - the nonlinear iterative solver context obtained from SNESCreate()

Level: intermediate

See also: SNES, SNESDestroy(), SNESCreate(), SNESSetUp(), SNESSolve()

External Links

source
PETSc.LibPETSc.SNESResetCounters — Method
SNESResetCounters(petsclib::PetscLibType, snes::AbstractSNES)

Reset counters for linear iterations and function evaluations.

Logically Collective

Input Parameters:

  • snes - SNES context

Level: developer

See also: SNESGetNumberFunctionEvals(), SNESGetLinearSolveIterations(), SNESGetNPC()

External Links

source
PETSc.LibPETSc.SNESResetFromOptions — Method
SNESResetFromOptions(petsclib::PetscLibType, snes::AbstractSNES)

Sets various SNES and KSP parameters from user options ONLY if the SNESSetFromOptions() was previously called

Collective

Input Parameter:

  • snes - the SNES context

Level: advanced

See also: SNES, SNESSetFromOptions(), SNESSetOptionsPrefix()

External Links

source
PETSc.LibPETSc.SNESSetAlwaysComputesFinalResidual — Method
SNESSetAlwaysComputesFinalResidual(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

tells the SNES to always compute the residual (nonlinear function value) at the final solution

Logically Collective

Input Parameters:

  • snes - the shell SNES
  • flg - PETSC_TRUE to always compute the residual

Level: advanced

See also: SNES, SNESFAS, SNESSolve(), SNESGetAlwaysComputesFinalResidual()

External Links

source
PETSc.LibPETSc.SNESSetApplicationContext — Method
SNESSetApplicationContext(petsclib::PetscLibType, snes::AbstractSNES, ctx::Ptr{Cvoid})

Sets the optional user-defined context for the nonlinear solvers.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • ctx - the application context

Level: intermediate

See also: SNES, SNESSetComputeApplicationContext(), SNESGetApplicationContext()

External Links

source
PETSc.LibPETSc.SNESSetCheckJacobianDomainError — Method
SNESSetCheckJacobianDomainError(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

tells SNESSolve() whether to check if the user called SNESSetJacobianDomainError() to indicate a Jacobian domain error after each Jacobian evaluation.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • flg - indicates if or not to check Jacobian domain error after each Jacobian evaluation

Level: advanced

See also: SNES, SNESConvergedReason, SNESCreate(), SNESSetFunction(), SNESFunctionFn, SNESSetFunctionDomainError(), SNESGetCheckJacobianDomainError()

External Links

source
PETSc.LibPETSc.SNESSetComputeApplicationContext — Method
SNESSetComputeApplicationContext(petsclib::PetscLibType, snes::AbstractSNES, compute::external, destroy::Ptr{Cvoid})

Sets an optional function to compute a user-defined context for the nonlinear solvers.

Logically Collective; No Fortran Support

Input Parameters:

  • snes - the SNES context
  • compute - function to compute the context
  • destroy - function to destroy the context, see PetscCtxDestroyFn for the calling sequence

Calling sequence of compute:

  • snes - the SNES context
  • ctx - context to be computed

Level: intermediate

See also: SNESGetApplicationContext(), SNESSetApplicationContext(), PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.SNESSetComputeInitialGuess — Method
SNESSetComputeInitialGuess(petsclib::PetscLibType, snes::AbstractSNES, func::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets a routine used to compute an initial guess for the nonlinear problem

Logically Collective

Input Parameters:

  • snes - the SNES context
  • func - function evaluation routine, see SNESInitialGuessFn for the calling sequence
  • ctx - [optional] user-defined context for private data for the

function evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESSolve(), SNESSetFunction(), SNESGetFunction(), SNESComputeFunction(), SNESSetJacobian(), SNESInitialGuessFn

External Links

source
PETSc.LibPETSc.SNESSetConvergedReason — Method
SNESSetConvergedReason(petsclib::PetscLibType, snes::AbstractSNES, reason::SNESConvergedReason)

Sets the reason the SNES iteration was stopped.

Not Collective

Input Parameters:

  • snes - the SNES context
  • reason - negative value indicates diverged, positive value converged, see SNESConvergedReason or the

manual pages for the individual convergence tests for complete lists

Level: developer

See also: SNESGetConvergedReason(), SNESSetConvergenceTest(), SNESConvergedReason

External Links

source
PETSc.LibPETSc.SNESSetConvergenceHistory — Method
SNESSetConvergenceHistory(petsclib::PetscLibType, snes::AbstractSNES, a::Vector{PetscReal}, its::Vector{PetscInt}, na::PetscInt, reset::PetscBool)

Sets the arrays used to hold the convergence history.

Logically Collective

Input Parameters:

  • snes - iterative context obtained from SNESCreate()
  • a - array to hold history, this array will contain the function norms computed at each step
  • its - integer array holds the number of linear iterations for each solve.
  • na - size of a and its
  • reset - PETSC_TRUE indicates each new nonlinear solve resets the history counter to zero,

else it continues storing new values for new nonlinear solves after the old ones

Level: intermediate

See also: SNES, SNESSolve(), SNESGetConvergenceHistory()

External Links

source
PETSc.LibPETSc.SNESSetConvergenceTest — Method
SNESSetConvergenceTest(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid}, destroy::Ptr{Cvoid})

Sets the function that is to be used to test for convergence of the nonlinear iterative solution.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • func - routine to test for convergence
  • ctx - [optional] context for private data for the convergence routine (may be NULL)
  • destroy - [optional] destructor for the context (may be NULL; PETSC_NULL_FUNCTION in Fortran)

Calling sequence of func:

  • snes - the SNES context
  • it - the current iteration number
  • xnorm - the norm of the new solution
  • snorm - the norm of the step
  • fnorm - the norm of the function value
  • reason - output, the reason convergence or divergence as declared
  • ctx - the optional convergence test context

Level: advanced

See also: SNES, SNESConvergedDefault(), SNESConvergedSkip()

External Links

source
PETSc.LibPETSc.SNESSetCountersReset — Method
SNESSetCountersReset(petsclib::PetscLibType, snes::AbstractSNES, reset::PetscBool)

Sets whether or not the counters for linear iterations and function evaluations are reset every time SNESSolve() is called.

Logically Collective

Input Parameters:

  • snes - SNES context
  • reset - whether to reset the counters or not, defaults to PETSC_TRUE

Level: developer

See also: SNESGetNumberFunctionEvals(), SNESGetLinearSolveIterations(), SNESGetNPC()

External Links

source
PETSc.LibPETSc.SNESSetDM — Method
SNESSetDM(petsclib::PetscLibType, snes::AbstractSNES, dm::AbstractPetscDM)

Sets the DM that may be used by some SNES nonlinear solvers or their underlying preconditioners

Logically Collective

Input Parameters:

  • snes - the nonlinear solver context
  • dm - the DM, cannot be NULL

Level: intermediate

See also: DM, SNES, SNESGetDM(), KSPSetDM(), KSPGetDM()

External Links

source
PETSc.LibPETSc.SNESSetDivergenceTolerance — Method
SNESSetDivergenceTolerance(petsclib::PetscLibType, snes::AbstractSNES, divtol::PetscReal)

Sets the divergence tolerance used for the SNES divergence test.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • divtol - the divergence tolerance. Use PETSC_UNLIMITED to deactivate the test. If the residual norm F(x^n) \ge divtol * F(x^0) the solver

is stopped due to divergence.

Options Database Key:

  • -snes_divergence_tolerance divtol - Sets divtol

Level: intermediate

See also: SNES, SNESSolve(), SNESSetTolerances(), SNESGetDivergenceTolerance()

External Links

source
PETSc.LibPETSc.SNESSetErrorIfNotConverged — Method
SNESSetErrorIfNotConverged(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Causes SNESSolve() to generate an error immediately if the solver has not converged.

Logically Collective

Input Parameters:

  • snes - iterative context obtained from SNESCreate()
  • flg - PETSC_TRUE indicates you want the error generated

Options Database Key:

  • -snes_error_if_not_converged (true|false) - cause an immediate error condition and stop the program if the solver does not converge

Level: intermediate

See also: SNES, SNESGetErrorIfNotConverged(), KSPGetErrorIfNotConverged(), KSPSetErrorIfNotConverged()

External Links

source
PETSc.LibPETSc.SNESSetForceIteration — Method
SNESSetForceIteration(petsclib::PetscLibType, snes::AbstractSNES, force::PetscBool)

force SNESSolve() to take at least one iteration regardless of the initial residual norm

Logically Collective

Input Parameters:

  • snes - the SNES context
  • force - PETSC_TRUE require at least one iteration

Options Database Key:

  • -snes_force_iteration force - Sets forcing an iteration

Level: intermediate

See also: SNES, TS, SNESSetDivergenceTolerance()

External Links

source
PETSc.LibPETSc.SNESSetFromOptions — Method
SNESSetFromOptions(petsclib::PetscLibType, snes::AbstractSNES)

Sets various SNES and KSP parameters from user options.

Collective

Input Parameter:

  • snes - the SNES context

Options Database Keys:

  • -snes_type type - newtonls, newtontr, ngmres, ncg, nrichardson, qn, vi, fas, SNESType for complete list
  • -snes_rtol rtol - relative decrease in tolerance norm from initial
  • -snes_atol abstol - absolute tolerance of residual norm
  • -snes_stol stol - convergence tolerance in terms of the norm of the change in the solution between steps
  • -snes_divergence_tolerance divtol - if the residual goes above divtol*rnorm0, exit with divergence
  • -snes_max_it max_it - maximum number of iterations
  • -snes_max_funcs max_funcs - maximum number of function evaluations
  • -snes_force_iteration force - force SNESSolve() to take at least one iteration
  • -snes_max_fail max_fail - maximum number of line search failures allowed before stopping, default is none
  • -snes_max_linear_solve_fail - number of linear solver failures before SNESSolve() stops
  • -snes_lag_preconditioner lag - how often preconditioner is rebuilt (use -1 to never rebuild)
  • -snes_lag_preconditioner_persists (true|false) - retains the -sneslagpreconditioner information across multiple SNESSolve()
  • -snes_lag_jacobian lag - how often Jacobian is rebuilt (use -1 to never rebuild)
  • -snes_lag_jacobian_persists (true|false) - retains the -sneslagjacobian information across multiple SNESSolve()
  • -snes_convergence_test (default|skip|correct_pressure) - convergence test in nonlinear solver. default SNESConvergedDefault(). skip SNESConvergedSkip() means continue

iterating until maxit or some other criterion is reached, saving expense of convergence test. correctpressure SNESConvergedCorrectPressure() has special handling of a pressure null space.

  • -snes_monitor [ascii][:filename][:viewer format] - prints residual norm at each iteration. if no filename given prints to stdout
  • -snes_monitor_solution [ascii binary draw][:filename][:viewer format] - plots solution at each iteration
  • -snes_monitor_residual [ascii binary draw][:filename][:viewer format] - plots residual (not its norm) at each iteration
  • -snes_monitor_solution_update [ascii binary draw][:filename][:viewer format] - plots update to solution at each iteration
  • -snes_monitor draw::draw_lg - plots residual norm at each iteration
  • -snes_monitor_lg_range - plots function range at each iteration
  • -snes_monitor_pause_final - Pauses all monitor drawing after the solver ends
  • -snes_fd - use finite differences to compute Jacobian; very slow, only for testing
  • -snes_fd_color - use finite differences with coloring to compute Jacobian
  • -snes_mf_ksp_monitor - if using matrix-free multiply then print h at each KSP iteration
  • -snes_converged_reason - print the reason for convergence/divergence after each solve
  • -npc_snes_type type - the SNES type to use as a nonlinear preconditioner
  • -snes_test_jacobian [threshold] - compare the user provided Jacobian with one computed via finite differences to check for errors.

If a threshold is given, display only those entries whose difference is greater than the threshold.

  • -snes_test_jacobian_view - display the user provided Jacobian, the finite difference Jacobian and the difference between them

to help users detect the location of errors in the user provided Jacobian.

Options Database Keys for Eisenstat-Walker method:

  • -snes_ksp_ew - use Eisenstat-Walker method for determining linear system convergence
  • -snes_ksp_ew_version ver - version of Eisenstat-Walker method
  • -snes_ksp_ew_rtol0 rtol0 - Sets rtol0
  • -snes_ksp_ew_rtolmax rtolmax - Sets rtolmax
  • -snes_ksp_ew_gamma gamma - Sets gamma
  • -snes_ksp_ew_alpha alpha - Sets alpha
  • -snes_ksp_ew_alpha2 alpha2 - Sets alpha2
  • -snes_ksp_ew_threshold threshold - Sets threshold

Level: beginner

See also: SNESType, SNESSetOptionsPrefix(), SNESResetFromOptions(), SNES, SNESCreate(), MatCreateSNESMF(), MatFDColoring

External Links

source
PETSc.LibPETSc.SNESSetFunction — Method
SNESSetFunction(petsclib::PetscLibType, snes::AbstractSNES, r::AbstractPetscVec, f::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets the function evaluation routine and function vector for use by the SNES routines in solving systems of nonlinear equations.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • r - vector to store function values, may be NULL
  • f - function evaluation routine; for calling sequence see SNESFunctionFn
  • ctx - [optional] user-defined context for private data for the

function evaluation routine (may be NULL)

Level: beginner

See also: SNES, SNESGetFunction(), SNESComputeFunction(), SNESSetJacobian(), SNESSetPicard(), SNESFunctionFn

External Links

source
PETSc.LibPETSc.SNESSetFunctionDomainError — Method
SNESSetFunctionDomainError(petsclib::PetscLibType, snes::AbstractSNES)

tells SNES that the input vector, a proposed new solution, to your function you provided to SNESSetFunction() is not in the function's domain. For example, a step with negative pressure.

Not Collective

Input Parameter:

  • snes - the SNES context

Level: advanced

See also: SNESCreate(), SNESSetFunction(), SNESFunctionFn, SNESSetJacobianDomainError(), SNESVISetVariableBounds(), SNESVISetComputeVariableBounds(), SNESLineSearchSetPreCheck(), SNESLineSearchSetPostCheck(), SNESConvergedReason, SNESGetConvergedReason(), SNES_DIVERGED_FUNCTION_DOMAIN, SNESSetObjectiveDomainError(), SNES_DIVERGED_OBJECTIVE_DOMAIN

External Links

source
PETSc.LibPETSc.SNESSetFunctionNorm — Method
SNESSetFunctionNorm(petsclib::PetscLibType, snes::AbstractSNES, norm::PetscReal)

Sets the last computed residual norm.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • norm - the value of the norm

Level: developer

See also: SNES, SNESGetNormSchedule(), SNESComputeFunction(), VecNorm(), SNESSetFunction(), SNESSetInitialFunction(), SNESNormSchedule

External Links

source
PETSc.LibPETSc.SNESSetFunctionType — Method
SNESSetFunctionType(petsclib::PetscLibType, snes::AbstractSNES, type::SNESFunctionType)

Sets the SNESFunctionType of the SNES method.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • type - the function type

Level: developer

Values of the function type:

  • SNES_FUNCTION_DEFAULT - the default for the given SNESType
  • SNES_FUNCTION_UNPRECONDITIONED - an unpreconditioned function evaluation (this is the function provided with SNESSetFunction()
  • SNES_FUNCTION_PRECONDITIONED - a transformation of the function provided with SNESSetFunction()

See also: SNES, SNESFunctionType, SNESGetNormSchedule(), SNESComputeFunction(), VecNorm(), SNESSetFunction(), SNESSetInitialFunction(), SNESNormSchedule

External Links

source
PETSc.LibPETSc.SNESSetGridSequence — Method
SNESSetGridSequence(petsclib::PetscLibType, snes::AbstractSNES, steps::PetscInt)

sets the number of steps of grid sequencing that SNES will do

Logically Collective

Input Parameters:

  • snes - the SNES context
  • steps - the number of refinements to do, defaults to 0

Options Database Key:

  • -snes_grid_sequence steps - Use grid sequencing to generate initial guess

Level: intermediate

See also: SNES, SNESGetLagPreconditioner(), SNESSetLagJacobian(), SNESGetLagJacobian(), SNESGetGridSequence(), SNESSetDM(), SNESSolve()

External Links

source
PETSc.LibPETSc.SNESSetInitialFunction — Method
SNESSetInitialFunction(petsclib::PetscLibType, snes::AbstractSNES, f::AbstractPetscVec)

Set an already computed function evaluation at the initial guess to be reused by SNESSolve().

Logically Collective

Input Parameters:

  • snes - the SNES context
  • f - vector to store function value

Level: developer

See also: SNES, SNESFAS, SNESSetFunction(), SNESComputeFunction(), SNESSetInitialFunctionNorm()

External Links

source
PETSc.LibPETSc.SNESSetIterationNumber — Method
SNESSetIterationNumber(petsclib::PetscLibType, snes::AbstractSNES, iter::PetscInt)

Sets the current iteration number.

Not Collective

Input Parameters:

  • snes - SNES context
  • iter - iteration number

Level: developer

See also: SNESGetLinearSolveIterations()

External Links

source
PETSc.LibPETSc.SNESSetJacobian — Method
SNESSetJacobian(petsclib::PetscLibType, snes::AbstractSNES, Amat::AbstractPetscMat, Pmat::AbstractPetscMat, J::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets the function to compute Jacobian as well as the location to store the matrix.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • Amat - the matrix that defines the (approximate) Jacobian
  • Pmat - the matrix to be used in constructing the preconditioner, usually the same as Amat.
  • J - Jacobian evaluation routine (if NULL then SNES retains any previously set value), see SNESJacobianFn for details
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL) (if NULL then SNES retains any previously set value)

Level: beginner

See also: SNES, KSPSetOperators(), SNESSetFunction(), MatMFFDComputeJacobian(), SNESComputeJacobianDefaultColor(), MatStructure, SNESSetPicard(), SNESJacobianFn, SNESFunctionFn

External Links

source
PETSc.LibPETSc.SNESSetJacobianDomainError — Method
SNESSetJacobianDomainError(petsclib::PetscLibType, snes::AbstractSNES)

tells SNES that the function you provided to SNESSetJacobian() at the proposed step. For example there is a negative element transformation.

Logically Collective

Input Parameter:

  • snes - the SNES context

Level: advanced

See also: SNESCreate(), SNESSetFunction(), SNESFunctionFn, SNESSetFunctionDomainError(), SNESVISetVariableBounds(), SNESVISetComputeVariableBounds(), SNESLineSearchSetPreCheck(), SNESLineSearchSetPostCheck(), SNESConvergedReason, SNESGetConvergedReason()

External Links

source
PETSc.LibPETSc.SNESSetKSP — Method
SNESSetKSP(petsclib::PetscLibType, snes::AbstractSNES, ksp::AbstractKSP)

Sets a KSP context for the SNES object to use

Not Collective, but the SNES and KSP objects must live on the same MPI_Comm

Input Parameters:

  • snes - the SNES context
  • ksp - the KSP context

Level: developer

See also: SNES, KSP, KSPGetPC(), SNESCreate(), KSPCreate()

External Links

source
PETSc.LibPETSc.SNESSetLagJacobian — Method
SNESSetLagJacobian(petsclib::PetscLibType, snes::AbstractSNES, lag::PetscInt)

Set when the Jacobian is rebuilt in the nonlinear solve. See SNESSetLagPreconditioner() for determining how often the preconditioner is rebuilt.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • lag - -1 indicates NEVER rebuild, 1 means rebuild every time the Jacobian is computed within a single nonlinear solve, 2 means every second time

the Jacobian is built etc. -2 means rebuild at next chance but then never again

Options Database Keys:

  • -snes_lag_jacobian_persists (true|false) - sets the persistence through multiple SNES solves
  • -snes_lag_jacobian (-2|1|2|...) - sets the lag
  • -snes_lag_preconditioner_persists (true|false) - sets the persistence through multiple SNES solves
  • -snes_lag_preconditioner (-2|1|2|...) - sets the lag.

Level: intermediate

See also: SNES, SNESGetLagPreconditioner(), SNESSetLagPreconditioner(), SNESGetLagJacobianPersists(), SNESSetLagPreconditionerPersists()

External Links

source
PETSc.LibPETSc.SNESSetLagJacobianPersists — Method
SNESSetLagJacobianPersists(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Set whether or not the Jacobian lagging persists through multiple nonlinear solves

Logically collective

Input Parameters:

  • snes - the SNES context
  • flg - jacobian lagging persists if true

Options Database Keys:

  • -snes_lag_jacobian_persists (true|false) - sets the persistence through multiple SNES solves
  • -snes_lag_jacobian (-2|1|2|...) - sets the lag
  • -snes_lag_preconditioner_persists (true|false) - sets the persistence through multiple SNES solves
  • -snes_lag_preconditioner (-2|1|2|...) - sets the lag

Level: advanced

See also: SNES, SNESSetLagPreconditionerPersists(), SNESSetLagJacobian(), SNESGetLagJacobian(), SNESGetNPC()

External Links

source
PETSc.LibPETSc.SNESSetLagPreconditioner — Method
SNESSetLagPreconditioner(petsclib::PetscLibType, snes::AbstractSNES, lag::PetscInt)

Sets when the preconditioner is rebuilt in the nonlinear solve SNESSolve().

Logically Collective

Input Parameters:

  • snes - the SNES context
  • lag - 1 means rebuild every time the Jacobian is computed within a single nonlinear solve, 2 means every second time

the Jacobian is built etc. -2 indicates rebuild preconditioner at next chance but then never rebuild after that

Options Database Keys:

  • -snes_lag_jacobian_persists (true|false) - sets the persistence through multiple SNESSolve()
  • -snes_lag_jacobian (-2|1|2|...) - sets the lag
  • -snes_lag_preconditioner_persists (true|false) - sets the persistence through multiple SNESSolve()
  • -snes_lag_preconditioner (-2|1|2|...) - sets the lag

Level: intermediate

See also: SNESGetLagPreconditioner(), SNESSetLagJacobian(), SNESGetLagJacobian(), SNESSetLagPreconditionerPersists(), SNESSetLagJacobianPersists(), SNES, SNESSolve()

External Links

source
PETSc.LibPETSc.SNESSetLagPreconditionerPersists — Method
SNESSetLagPreconditionerPersists(petsclib::PetscLibType, snes::AbstractSNES, flg::PetscBool)

Set whether or not the preconditioner lagging persists through multiple nonlinear solves

Logically Collective

Input Parameters:

  • snes - the SNES context
  • flg - preconditioner lagging persists if true

Options Database Keys:

  • -snes_lag_jacobian_persists (true|false) - sets the persistence through multiple SNES solves
  • -snes_lag_jacobian (-2|1|2|...) - sets the lag
  • -snes_lag_preconditioner_persists (true|false) - sets the persistence through multiple SNES solves
  • -snes_lag_preconditioner (-2|1|2|...) - sets the lag

Level: developer

See also: SNES, SNESSetLagJacobianPersists(), SNESSetLagJacobian(), SNESGetLagJacobian(), SNESGetNPC(), SNESSetLagPreconditioner()

External Links

source
PETSc.LibPETSc.SNESSetLineSearch — Method
SNESSetLineSearch(petsclib::PetscLibType, snes::AbstractSNES, linesearch::SNESLineSearch)

Sets the SNESLineSearch to be used for a given SNES

Collective

Input Parameters:

  • snes - iterative context obtained from SNESCreate()
  • linesearch - the linesearch object

Level: developer

See also: SNES, SNESLineSearch, SNESGetLineSearch()

External Links

source
PETSc.LibPETSc.SNESSetMaxLinearSolveFailures — Method
SNESSetMaxLinearSolveFailures(petsclib::PetscLibType, snes::AbstractSNES, maxFails::PetscInt)

the number of failed linear solve attempts allowed before SNES returns with a diverged reason of SNES_DIVERGED_LINEAR_SOLVE

Logically Collective

Input Parameters:

  • snes - SNES context
  • maxFails - maximum allowed linear solve failures, use PETSC_UNLIMITED to have no limit on the number of failures

Options Database Key:

  • -snes_max_linear_solve_fail num - The number of failures before the solve is terminated

Level: intermediate

See also: SNESSetErrorIfNotConverged(), SNESGetLinearSolveFailures(), SNESGetMaxLinearSolveFailures(), SNESGetLinearSolveIterations()

External Links

source
PETSc.LibPETSc.SNESSetMaxNonlinearStepFailures — Method
SNESSetMaxNonlinearStepFailures(petsclib::PetscLibType, snes::AbstractSNES, maxFails::PetscInt)

Sets the maximum number of unsuccessful steps attempted by the nonlinear solver before it gives up and returns unconverged or generates an error

Not Collective

Input Parameters:

  • snes - SNES context
  • maxFails - maximum of unsuccessful steps allowed, use PETSC_UNLIMITED to have no limit on the number of failures

Options Database Key:

  • -snes_max_fail n - maximum number of unsuccessful steps allowed

Level: intermediate

See also: SNESSetErrorIfNotConverged(), SNESGetMaxLinearSolveFailures(), SNESGetLinearSolveIterations(), SNESSetMaxLinearSolveFailures(), SNESGetLinearSolveFailures(), SNESGetMaxNonlinearStepFailures(), SNESGetNonlinearStepFailures(), SNESCheckLineSearchFailure()

External Links

source
PETSc.LibPETSc.SNESSetNGS — Method
SNESSetNGS(petsclib::PetscLibType, snes::AbstractSNES, f::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets the user nonlinear Gauss-Seidel routine for use with composed nonlinear solvers.

Input Parameters:

  • snes - the SNES context, usually of the SNESType SNESNGS
  • f - function evaluation routine to apply Gauss-Seidel, see SNESNGSFn for calling sequence
  • ctx - [optional] user-defined context for private data for the smoother evaluation routine (may be NULL)

Level: intermediate

See also: SNESNGS, SNESGetNGS(), SNESNCG, SNESGetFunction(), SNESComputeNGS(), SNESNGSFn

External Links

source
PETSc.LibPETSc.SNESSetNPC — Method
SNESSetNPC(petsclib::PetscLibType, snes::AbstractSNES, npc::AbstractSNES)

Sets the nonlinear preconditioner to be used.

Collective

Input Parameters:

  • snes - iterative context obtained from SNESCreate()
  • npc - the SNES nonlinear preconditioner object

Options Database Key:

  • -npc_snes_type type - set the type of the SNES to use as the nonlinear preconditioner

Level: developer

See also: SNES, SNESNGS, SNESFAS, SNESGetNPC(), SNESHasNPC()

External Links

source
PETSc.LibPETSc.SNESSetNPCSide — Method
SNESSetNPCSide(petsclib::PetscLibType, snes::AbstractSNES, side::PCSide)

Sets the nonlinear preconditioning side used by the nonlinear preconditioner inside SNES.

Logically Collective

Input Parameter:

  • snes - iterative context obtained from SNESCreate()

Output Parameter:

  • side - the preconditioning side, where side is one of

$PC_LEFT - left preconditioning PC_RIGHT - right preconditioning (default for most nonlinear solvers)$

Options Database Key:

  • -snes_npc_side (right|left) - nonlinear preconditioner side

Level: intermediate

See also: SNES, SNESGetNPC(), SNESNRICHARDSON, SNESNCG, SNESType, SNESGetNPCSide(), KSPSetPCSide(), PC_LEFT, PC_RIGHT, PCSide

External Links

source
PETSc.LibPETSc.SNESSetNormSchedule — Method
SNESSetNormSchedule(petsclib::PetscLibType, snes::AbstractSNES, normschedule::SNESNormSchedule)

Sets the SNESNormSchedule used in convergence and monitoring of the SNES method, when norms are computed in the solving process

Logically Collective

Input Parameters:

  • snes - the SNES context
  • normschedule - the frequency of norm computation

Options Database Key:

  • -snes_norm_schedule (none|always|initialonly|finalonly|initialfinalonly) - set the schedule

Level: advanced

See also: SNESNormSchedule, SNESGetNormSchedule(), SNESComputeFunction(), VecNorm(), SNESSetFunction(), SNESSetInitialFunction()

External Links

source
PETSc.LibPETSc.SNESSetObjective — Method
SNESSetObjective(petsclib::PetscLibType, snes::AbstractSNES, obj::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets the objective function minimized by some of the SNES linesearch methods, used instead of the 2-norm of the residual in the line search

Logically Collective

Input Parameters:

  • snes - the SNES context
  • obj - objective evaluation routine; see SNESObjectiveFn for the calling sequence
  • ctx - [optional] user-defined context for private data for the objective evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESLineSearch(), SNESGetObjective(), SNESComputeObjective(), SNESSetFunction(), SNESSetJacobian(), SNESObjectiveFn, SNESSetObjectiveDomainError()

External Links

source
PETSc.LibPETSc.SNESSetObjectiveDomainError — Method
SNESSetObjectiveDomainError(petsclib::PetscLibType, snes::AbstractSNES)

tells SNES that the input vector, a proposed new solution, to your function you provided to SNESSetObjective() is not in the function's domain. For example, a step with negative pressure.

Not Collective

Input Parameter:

  • snes - the SNES context

Level: advanced

See also: SNESCreate(), SNESSetFunction(), SNESFunctionFn, SNESSetJacobianDomainError(), SNESVISetVariableBounds(), SNESVISetComputeVariableBounds(), SNESLineSearchSetPreCheck(), SNESLineSearchSetPostCheck(), SNESConvergedReason, SNESGetConvergedReason(), SNES_DIVERGED_OBJECTIVE_DOMAIN, SNESSetFunctionDomainError(), SNES_DIVERGED_FUNCTION_DOMAIN

External Links

source
PETSc.LibPETSc.SNESSetOptionsPrefix — Method
SNESSetOptionsPrefix(petsclib::PetscLibType, snes::AbstractSNES, prefix::String)

Sets the prefix used for searching for all SNES options in the database.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • prefix - the prefix to prepend to all option names

Level: advanced

See also: SNES, SNESSetFromOptions(), SNESAppendOptionsPrefix()

External Links

source
PETSc.LibPETSc.SNESSetPicard — Method
SNESSetPicard(petsclib::PetscLibType, snes::AbstractSNES, r::AbstractPetscVec, bp::Ptr{Cvoid}, Amat::AbstractPetscMat, Pmat::AbstractPetscMat, J::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Use SNES to solve the system A(x) x = bp(x) + b via a Picard type iteration (Picard linearization)

Logically Collective

Input Parameters:

  • snes - the SNES context
  • r - vector to store function values, may be NULL
  • bp - function evaluation routine, may be NULL, for the calling sequence see SNESFunctionFn
  • Amat - matrix with which A(x) x - bp(x) - b is to be computed
  • Pmat - matrix from which preconditioner is computed (usually the same as Amat)
  • J - function to compute matrix values, for the calling sequence see SNESJacobianFn
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESGetFunction(), SNESSetFunction(), SNESComputeFunction(), SNESSetJacobian(), SNESGetPicard(), SNESLineSearchPreCheckPicard(), SNESFunctionFn, SNESJacobianFn

External Links

source
PETSc.LibPETSc.SNESSetSolution — Method
SNESSetSolution(petsclib::PetscLibType, snes::AbstractSNES, u::AbstractPetscVec)

Sets the solution vector for use by the SNES routines.

Logically Collective

Input Parameters:

  • snes - the SNES context obtained from SNESCreate()
  • u - the solution vector

Level: beginner

See also: SNES, SNESSolve(), SNESGetSolution(), Vec

External Links

source
PETSc.LibPETSc.SNESSetTolerances — Method
SNESSetTolerances(petsclib::PetscLibType, snes::AbstractSNES, abstol::PetscReal, rtol::PetscReal, stol::PetscReal, maxit::PetscInt, maxf::PetscInt)

Sets various parameters used in SNES convergence tests.

Logically Collective

Input Parameters:

  • snes - the SNES context
  • abstol - the absolute convergence tolerance, F(x^n) \le abstol
  • rtol - the relative convergence tolerance, F(x^n) \le reltol * F(x^0)
  • stol - convergence tolerance in terms of the norm of the change in the solution between steps, || delta x || < stol*|| x ||
  • maxit - the maximum number of iterations allowed in the solver, default 50.
  • maxf - the maximum number of function evaluations allowed in the solver (use PETSC_UNLIMITED indicates no limit), default 10,000

Options Database Keys:

  • -snes_atol abstol - Sets abstol
  • -snes_rtol rtol - Sets rtol
  • -snes_stol stol - Sets stol
  • -snes_max_it maxit - Sets maxit
  • -snes_max_funcs maxf - Sets maxf (use unlimited to have no maximum)

Level: intermediate

See also: SNESSolve(), SNES, SNESSetDivergenceTolerance(), SNESSetForceIteration()

External Links

source
PETSc.LibPETSc.SNESSetType — Method
SNESSetType(petsclib::PetscLibType, snes::AbstractSNES, type::String)

Sets the algorithm/method to be used to solve the nonlinear system with the given SNES

Collective

Input Parameters:

  • snes - the SNES context
  • type - a known method

Options Database Key:

  • -snes_type type - Sets the method; see SNESType

Level: intermediate

See also: SNES, SNESSolve(), SNESType, SNESCreate(), SNESDestroy(), SNESGetType(), SNESSetFromOptions()

External Links

source
PETSc.LibPETSc.SNESSetUp — Method
SNESSetUp(petsclib::PetscLibType, snes::AbstractSNES)

Sets up the internal data structures for the later use of a nonlinear solver SNESSolve().

Collective

Input Parameter:

  • snes - the SNES context

Level: advanced

See also: SNES, SNESCreate(), SNESSolve(), SNESDestroy(), SNESSetFromOptions()

External Links

source
PETSc.LibPETSc.SNESSetUpMatrices — Method
SNESSetUpMatrices(petsclib::PetscLibType, snes::AbstractSNES)

ensures that matrices are available for SNES Newton-like methods, this is called by SNESSetUp_XXX()

Collective

Input Parameter:

  • snes - SNES object to configure

Level: developer

See also: SNES, SNESSetUp()

External Links

source
PETSc.LibPETSc.SNESSetUpdate — Method
SNESSetUpdate(petsclib::PetscLibType, snes::AbstractSNES, func::Ptr{Cvoid})

Sets the general-purpose update function called at the beginning of every iteration of the nonlinear solve. Specifically it is called just before the Jacobian is "evaluated" and after the function evaluation.

Logically Collective

Input Parameters:

  • snes - The nonlinear solver context
  • func - The update function; for calling sequence see SNESUpdateFn

Level: advanced

See also: SNES, SNESSolve(), SNESSetJacobian(), SNESLineSearchSetPreCheck(), SNESLineSearchSetPostCheck(), SNESNewtonTRSetPreCheck(), SNESNewtonTRSetPostCheck(), SNESMonitorSet()

External Links

source
PETSc.LibPETSc.SNESSetUseMatrixFree — Method
SNESSetUseMatrixFree(petsclib::PetscLibType, snes::AbstractSNES, mf_operator::PetscBool, mf::PetscBool)

indicates that SNES should use matrix-free finite difference matrix-vector products to apply the Jacobian.

Logically Collective

Input Parameters:

  • snes - SNES context
  • mf_operator - use matrix-free only for the Amat used by SNESSetJacobian(), this means the user provided Pmat will continue to be used
  • mf - use matrix-free for both the Amat and Pmat used by SNESSetJacobian(), both the Amat and Pmat set in SNESSetJacobian() will be ignored. With

this option no matrix-element based preconditioners can be used in the linear solve since the matrix won't be explicitly available

Options Database Keys:

  • -snes_mf_operator - use matrix-free only for the mat operator
  • -snes_mf - use matrix-free for both the mat and pmat operator
  • -snes_fd_color - compute the Jacobian via coloring and finite differences.
  • -snes_fd - compute the Jacobian via finite differences (slow)

Level: intermediate

See also: SNES, SNESGetUseMatrixFree(), MatCreateSNESMF(), SNESComputeJacobianDefaultColor(), MatFDColoring

External Links

source
PETSc.LibPETSc.SNESSetWorkVecs — Method
SNESSetWorkVecs(petsclib::PetscLibType, snes::AbstractSNES, nw::PetscInt)

Allocates a number of work vectors to be used internally by the SNES solver

Input Parameters:

  • snes - the SNES context
  • nw - number of work vectors to allocate

Level: developer

See also: SNES

External Links

source
PETSc.LibPETSc.SNESShellGetContext — Method
ctx::Ptr{Cvoid} = SNESShellGetContext(petsclib::PetscLibType, snes::AbstractSNES)

Returns the user-provided context associated with a SNESSHELL

Not Collective

Input Parameter:

  • snes - should have been created with SNESSetType(snes,SNESSHELL);

Output Parameter:

  • ctx - the user provided context

Level: advanced

See also: SNES, SNESSHELL, SNESCreateShell(), SNESShellSetContext()

External Links

source
PETSc.LibPETSc.SNESShellSetContext — Method
SNESShellSetContext(petsclib::PetscLibType, snes::AbstractSNES, ctx::Ptr{Cvoid})

sets the context for a SNESSHELL

Logically Collective

Input Parameters:

  • snes - the SNESSHELL
  • ctx - the context

Level: advanced

See also: SNES, SNESSHELL, SNESCreateShell(), SNESShellGetContext()

External Links

source
PETSc.LibPETSc.SNESShellSetSolve — Method
SNESShellSetSolve(petsclib::PetscLibType, snes::AbstractSNES, solve::external)

Sets routine to apply as solver to a SNESSHELL SNES object

Logically Collective

Input Parameters:

  • snes - the SNES nonlinear solver context
  • solve - the application-provided solver routine

Calling sequence of apply:

  • snes - the preconditioner, get the application context with SNESShellGetContext() provided with SNESShellSetContext()
  • xout - solution vector

Level: advanced

See also: SNES, SNESSHELL, SNESShellSetContext(), SNESShellGetContext()

External Links

source
PETSc.LibPETSc.SNESSolve — Method
SNESSolve(petsclib::PetscLibType, snes::AbstractSNES, b::Union{Ptr, AbstractPetscVec}, x::AbstractPetscVec)

Solves a nonlinear system F(x) = b associated with a SNES object

Collective

Input Parameters:

  • snes - the SNES context
  • b - the constant part of the equation F(x) = b, or NULL to use zero.
  • x - the solution vector.

Level: beginner

See also: SNES, SNESCreate(), SNESDestroy(), SNESSetFunction(), SNESSetJacobian(), SNESSetGridSequence(), SNESGetSolution(), SNESNewtonTRSetPreCheck(), SNESNewtonTRGetPreCheck(), SNESNewtonTRSetPostCheck(), SNESNewtonTRGetPostCheck(), SNESLineSearchSetPostCheck(), SNESLineSearchGetPostCheck(), SNESLineSearchSetPreCheck(), SNESLineSearchGetPreCheck()

External Links

source
PETSc.LibPETSc.SNESTSFormFunction — Method
SNESTSFormFunction(petsclib::PetscLibType, snes::AbstractSNES, U::AbstractPetscVec, F::AbstractPetscVec, ctx::Ptr{Cvoid})

Function to evaluate nonlinear residual defined by an ODE solver algorithm implemented within TS

Logically Collective

Input Parameters:

  • snes - nonlinear solver
  • U - the current state at which to evaluate the residual
  • ctx - application context, must be a TS

Output Parameter:

  • F - the nonlinear residual

Level: developer

See also: SNESSetFunction(), MatFDColoringSetFunction()

External Links

source
PETSc.LibPETSc.SNESTSFormJacobian — Method
SNESTSFormJacobian(petsclib::PetscLibType, snes::AbstractSNES, U::AbstractPetscVec, A::AbstractPetscMat, B::AbstractPetscMat, ctx::Ptr{Cvoid})

Function to evaluate the Jacobian defined by an ODE solver algorithm implemented within TS

Collective

Input Parameters:

  • snes - nonlinear solver
  • U - the current state at which to evaluate the residual
  • ctx - application context, must be a TS

Output Parameters:

  • A - the Jacobian
  • B - the matrix used to construct the preconditioner (often the same as A)

Level: developer

See also: SNESSetJacobian()

External Links

source
PETSc.LibPETSc.SNESTestFunction — Method
SNESTestFunction(petsclib::PetscLibType, snes::AbstractSNES)

Computes the difference between the computed and finite-difference functions

Collective

Input Parameter:

  • snes - the SNES context

Options Database Keys:

  • -snes_test_function - compare the user provided function with one compute via finite differences to check for errors.
  • -snes_test_function_view - display the user provided function, the finite difference function and the difference

Level: developer

See also: SNESTestJacobian(), SNESSetFunction(), SNESComputeFunction()

External Links

source
PETSc.LibPETSc.SNESTestJacobian — Method
Jnorm::PetscReal,diffNorm::PetscReal = SNESTestJacobian(petsclib::PetscLibType, snes::AbstractSNES)

Computes the difference between the computed and finite-difference Jacobians

Collective

Input Parameter:

  • snes - the SNES context

Output Parameters:

  • Jnorm - the Frobenius norm of the computed Jacobian, or NULL
  • diffNorm - the Frobenius norm of the difference of the computed and finite-difference Jacobians, or NULL

Options Database Keys:

  • -snes_test_jacobian [threshold] - compare the user provided Jacobian with one compute via finite differences to check for errors. If a threshold is given, display only those entries whose difference is greater than the threshold.
  • -snes_test_jacobian_view - display the user provided Jacobian, the finite difference Jacobian and the difference

Level: developer

See also: SNESTestFunction(), SNESSetJacobian(), SNESComputeJacobian()

External Links

source
PETSc.LibPETSc.SNESTestLocalMin — Method
SNESTestLocalMin(petsclib::PetscLibType, snes::AbstractSNES)

Diagnostic that probes each entry of the current SNES solution to check whether the residual norm has a local minimum along the coordinate directions

Collective

Input Parameter:

  • snes - the SNES context

Level: developer

See also: SNES, SNESSolve(), SNESComputeFunction()

External Links

source
PETSc.LibPETSc.SNESVIComputeFunction — Method
SNESVIComputeFunction(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, phi::AbstractPetscVec, functx::Ptr{Cvoid})

Provides the function that reformulates a system of nonlinear equations in mixed complementarity form to a system of nonlinear equations in semismooth form.

Input Parameters:

  • snes - the SNES context
  • X - current iterate
  • functx - user defined function context

Output Parameter:

  • phi - the evaluation of semismooth function at X

Level: developer

See also: SNES, SNESVINEWTONSSLS, SNESVIComputeMeritFunction()

External Links

source
PETSc.LibPETSc.SNESVIComputeInactiveSetFnorm — Method
fnorm::PetscReal = SNESVIComputeInactiveSetFnorm(petsclib::PetscLibType, snes::AbstractSNES, F::AbstractPetscVec, X::AbstractPetscVec)

Computes the function norm for variational inequalities on the inactive set

Input Parameters:

  • snes - the SNES context
  • F - the nonlinear function vector
  • X - the SNES solution vector

Output Parameter:

  • fnorm - the function norm

Level: developer

See also: SNES, SNESVINEWTONRSLS, SNESVINEWTONSSLS, SNESLineSearchSetVIFunctions()

External Links

source
PETSc.LibPETSc.SNESVIComputeInactiveSetFtY — Method
fty::PetscScalar = SNESVIComputeInactiveSetFtY(petsclib::PetscLibType, snes::AbstractSNES, F::AbstractPetscVec, X::AbstractPetscVec, Y::AbstractPetscVec)

Computes the directional derivative for variational inequalities on the inactive set, assuming that there exists some G(x) for which the SNESFunctionFn F(x) = grad G(x) (relevant for some line search algorithms)

Input Parameters:

  • snes - the SNES context
  • F - the nonlinear function vector
  • X - the SNES solution vector
  • Y - the direction vector

Output Parameter:

  • fty - the directional derivative

Level: developer

See also: SNES, SNESVINEWTONRSLS, SNESVINEWTONSSLS

External Links

source
PETSc.LibPETSc.SNESVIComputeMeritFunction — Method
merit::PetscReal,phinorm::PetscReal = SNESVIComputeMeritFunction(petsclib::PetscLibType, phi::AbstractPetscVec)

Evaluates the merit function for the mixed complementarity problem.

Input Parameter:

  • phi - the Vec holding the evaluation of the semismooth function

Output Parameters:

  • merit - the merit function 1/2 ||phi||^2
  • phinorm - the two-norm of the vector, ||phi||

Level: developer

See also: SNES, SNESVINEWTONSSLS, SNESVIComputeFunction()

External Links

source
PETSc.LibPETSc.SNESVIGetActiveSetIS — Method
ISact::IS = SNESVIGetActiveSetIS(petsclib::PetscLibType, snes::AbstractSNES, X::AbstractPetscVec, F::AbstractPetscVec)

Gets the global indices for the active set variables

Input Parameters:

  • snes - the SNES context
  • X - the snes solution vector
  • F - the nonlinear function vector

Output Parameter:

  • ISact - active set index set

Level: developer

See also: SNES, SNESVINEWTONRSLS, SNESVINEWTONSSLS

External Links

source
PETSc.LibPETSc.SNESVIGetInactiveSet — Method
inact::IS = SNESVIGetInactiveSet(petsclib::PetscLibType, snes::AbstractSNES)

Gets the global indices for the inactive set variables (these correspond to the degrees of freedom the linear system is solved on)

Input Parameter:

  • snes - the SNES context

Output Parameter:

  • inact - inactive set index set

Level: advanced

See also: SNES, SNESVINEWTONRSLS

External Links

source
PETSc.LibPETSc.SNESVIGetVariableBounds — Method
SNESVIGetVariableBounds(petsclib::PetscLibType, snes::AbstractSNES, xl::AbstractPetscVec, xu::AbstractPetscVec)

Gets the lower and upper bounds for the solution vector. xl <= x <= xu. These are used in solving (differential) variable inequalities.

Input Parameters:

  • snes - the SNES context.
  • xl - lower bound (may be NULL)
  • xu - upper bound (may be NULL)

Level: advanced

See also: SNES, SNESVISetVariableBounds(), SNESVISetComputeVariableBounds(), SNESSetFunctionDomainError(), SNESSetJacobianDomainError(), SNESVINEWTONRSLS, SNESVINEWTONSSLS, SNESSetType(), PETSC_NINFINITY, PETSC_INFINITY

External Links

source
PETSc.LibPETSc.SNESVISetComputeVariableBounds — Method
SNESVISetComputeVariableBounds(petsclib::PetscLibType, snes::AbstractSNES, compute::external)

Sets a function that is called to compute the bounds on variable for (differential) variable inequalities.

Input Parameters:

  • snes - the SNES context
  • compute - function that computes the bounds

Calling sequence of compute:

  • snes - the SNES context
  • lower - vector to hold lower bounds
  • higher - vector to hold upper bounds

Level: advanced

See also: SNES, SNESVISetVariableBounds(), DMSetVariableBounds(), SNESSetFunctionDomainError(), SNESSetJacobianDomainError(), SNESVINEWTONRSLS, SNESVINEWTONSSLS, SNESSetType(), PETSC_NINFINITY, PETSC_INFINITY

External Links

source
PETSc.LibPETSc.SNESVISetRedundancyCheck — Method
SNESVISetRedundancyCheck(petsclib::PetscLibType, snes::AbstractSNES, func::external, ctx::Ptr{Cvoid})

Provide a function to check for any redundancy in the VI active set

Logically Collective

Input Parameters:

  • snes - the SNESVINEWTONRSLS context
  • func - the function to check of redundancies
  • ctx - optional context used by the function

Calling sequence of func:

  • snes - the SNES context
  • is_act - the set of points in the active sets
  • is_redact - output, the set of points in the non-redundant active set
  • ctx - optional context

Level: advanced

See also: SNES, SNESVINEWTONRSLS, SNESVIGetInactiveSet(), DMSetVI()

External Links

source
PETSc.LibPETSc.SNESVISetVariableBounds — Method
SNESVISetVariableBounds(petsclib::PetscLibType, snes::AbstractSNES, xl::AbstractPetscVec, xu::AbstractPetscVec)

Sets the lower and upper bounds for the solution vector. xl <= x <= xu. This allows solving (differential) variable inequalities.

Input Parameters:

  • snes - the SNES context.
  • xl - lower bound.
  • xu - upper bound.

Level: advanced

See also: SNES, SNESVIGetVariableBounds(), SNESVISetComputeVariableBounds(), SNESSetFunctionDomainError(), SNESSetJacobianDomainError(), SNESVINEWTONRSLS, SNESVINEWTONSSLS, SNESSetType(), PETSC_NINFINITY, PETSC_INFINITY

External Links

source
PETSc.LibPETSc.SNESView — Method
SNESView(petsclib::PetscLibType, snes::AbstractSNES, viewer::PetscViewer)

Prints or visualizes the SNES data structure.

Collective

Input Parameters:

  • snes - the SNES context
  • viewer - the PetscViewer

Options Database Key:

  • -snes_view - Calls SNESView() at end of SNESSolve()

Level: beginner

See also: SNES, SNESLoad(), SNESCreate(), PetscViewerASCIIOpen()

External Links

source
PETSc.LibPETSc.SNESViewFromOptions — Method
SNESViewFromOptions(petsclib::PetscLibType, A::AbstractSNES, obj, name::String)

View a SNES based on values in the options database

Collective

Input Parameters:

  • A - the SNES context
  • obj - Optional object that provides the options prefix for the checks
  • name - command line option

Options Database Key:

  • -name [viewertype][:...] - option name and values. See PetscObjectViewFromOptions() for the possible arguments

Level: intermediate

See also: SNES, SNESView, PetscObjectViewFromOptions(), SNESCreate()

External Links

source
PETSc.LibPETSc.SNESLineSearchAppendOptionsPrefix — Method
SNESLineSearchAppendOptionsPrefix(petsclib::PetscLibType, linesearch::SNESLineSearch, prefix::String)

Appends to the prefix used for searching for all SNESLineSearch options in the database.

Logically Collective

Input Parameters:

  • linesearch - the SNESLineSearch context
  • prefix - the prefix to prepend to all option names

Level: advanced

See also: SNES, SNESLineSearch(), SNESLineSearchSetFromOptions(), SNESGetOptionsPrefix()

External Links

source
PETSc.LibPETSc.SNESLineSearchApply — Method
fnorm::PetscReal = SNESLineSearchApply(petsclib::PetscLibType, linesearch::SNESLineSearch, X::AbstractPetscVec, F::AbstractPetscVec, Y::AbstractPetscVec)

Computes the line-search update.

Collective

Input Parameter:

  • linesearch - The line search context

Input/Output Parameters:

  • X - The current solution, on output the new solution
  • F - The current function value, on output the new function value at the solution value X
  • fnorm - The current norm of F, on output the new norm of F
  • Y - The current search direction, on output the direction determined by the linesearch, i.e. Xnew = Xold - lambda*Y

Options Database Keys:

  • -snes_linesearch_type (none|basic|bt|secant|cp|nleqerr|bisection|shell) - Line search type, see SNESLineSearchType
  • -snes_linesearch_monitor [:filename] - Print progress of line searches
  • -snes_linesearch_damping damping - The linesearch damping parameter, default is 1.0 (no damping)
  • -snes_linesearch_norms (true|false) - Turn on/off the linesearch norms computation (SNESLineSearchSetComputeNorms())
  • -snes_linesearch_keeplambda (true|false) - Keep the previous lambda as the initial guess
  • -snes_linesearch_max_it it - The number of iterations for iterative line searches

Level: advanced

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchCreate(), SNESLineSearchGetLambda(), SNESLineSearchPreCheck(), SNESLineSearchPostCheck(), SNESSolve(), SNESComputeFunction(), SNESLineSearchSetComputeNorms(), SNESLineSearchType, SNESLineSearchSetType()

External Links

source
PETSc.LibPETSc.SNESLineSearchBTGetAlpha — Method
alpha::PetscReal = SNESLineSearchBTGetAlpha(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the descent parameter, alpha, in the SNESLINESEARCHBT variant that was set with SNESLineSearchBTSetAlpha()

Input Parameter:

  • linesearch - linesearch context

Output Parameter:

  • alpha - The descent parameter

Level: intermediate

See also: SNESLineSearch, SNESLineSearchGetLambda(), SNESLineSearchGetTolerances(), SNESLINESEARCHBT, SNESLineSearchBTSetAlpha()

External Links

source
PETSc.LibPETSc.SNESLineSearchBTSetAlpha — Method
SNESLineSearchBTSetAlpha(petsclib::PetscLibType, linesearch::SNESLineSearch, alpha::PetscReal)

Sets the descent parameter, alpha, in the SNESLINESEARCHBT SNESLineSearch variant.

Input Parameters:

  • linesearch - linesearch context
  • alpha - The descent parameter

Level: intermediate

See also: SNESLineSearch, SNESLineSearchSetLambda(), SNESLineSearchGetTolerances(), SNESLINESEARCHBT, SNESLineSearchBTGetAlpha()

External Links

source
PETSc.LibPETSc.SNESLineSearchComputeNorms — Method
SNESLineSearchComputeNorms(petsclib::PetscLibType, linesearch::SNESLineSearch)

Explicitly computes the norms of the current solution X, the current update Y, and the current function value F.

Input Parameter:

  • linesearch - the line search context

Options Database Key:

  • -snes_linesearch_norms (true|false) - turn norm computation on or off

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchGetNorms, SNESLineSearchSetNorms(), SNESLineSearchSetComputeNorms()

External Links

source
PETSc.LibPETSc.SNESLineSearchCreate — Method
outlinesearch::SNESLineSearch = SNESLineSearchCreate(petsclib::PetscLibType, comm::MPI_Comm)

Creates a SNESLineSearch context.

Logically Collective

Input Parameter:

  • comm - MPI communicator for the line search (typically from the associated SNES context).

Output Parameter:

  • outlinesearch - the new line search context

Level: developer

See also: SNES, SNESLineSearch, LineSearchDestroy(), SNESGetLineSearch()

External Links

source
PETSc.LibPETSc.SNESLineSearchDestroy — Method
SNESLineSearchDestroy(petsclib::PetscLibType, linesearch::Union{SNESLineSearch, Ref{SNESLineSearch}})

Destroys the line search instance.

Collective

Input Parameter:

  • linesearch - The line search context

Level: developer

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchCreate(), SNESLineSearchReset(), SNESDestroy()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetDamping — Method
damping::PetscReal = SNESLineSearchGetDamping(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the line search damping parameter.

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • damping - The damping parameter

Level: advanced

See also: SNES, SNESLineSearchGetStepTolerance(), SNESQN

External Links

source
PETSc.LibPETSc.SNESLineSearchGetDefaultMonitor — Method
monitor::PetscViewer = SNESLineSearchGetDefaultMonitor(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the PetscViewer instance for the default line search monitor that is turned on with SNESLineSearchSetDefaultMonitor()

Logically Collective

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • monitor - monitor context

Level: intermediate

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchSetDefaultMonitor(), PetscViewer

External Links

source
PETSc.LibPETSc.SNESLineSearchGetLambda — Method
lambda::PetscReal = SNESLineSearchGetLambda(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the last line search lambda used

Not Collective

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • lambda - The last lambda (scaling of the solution update) computed during SNESLineSearchApply()

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchSetLambda(), SNESLineSearchGetDamping(), SNESLineSearchApply()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetNorms — Method
xnorm::PetscReal,fnorm::PetscReal,ynorm::PetscReal = SNESLineSearchGetNorms(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the norms for the current solution X, the current update Y, and the current function value F.

Not Collective

Input Parameter:

  • linesearch - the line search context

Output Parameters:

  • xnorm - The norm of the current solution
  • fnorm - The norm of the current function, this is the norm(function(X)) where X is the current solution.
  • ynorm - The norm of the current update (after scaling by the linesearch computed lambda)

Level: developer

See also: SNES, SNESLineSearch, SNESLineSearchSetNorms(), SNESLineSearchGetVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetOptionsPrefix — Method
prefix::String = SNESLineSearchGetOptionsPrefix(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the prefix used for searching for all SNESLineSearch options in the database.

Not Collective

Input Parameter:

  • linesearch - the SNESLineSearch context

Output Parameter:

  • prefix - pointer to the prefix string used

Level: advanced

See also: SNES, SNESLineSearch, SNESAppendOptionsPrefix()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetOrder — Method
order::PetscInt = SNESLineSearchGetOrder(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the line search approximation order.

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • order - The order

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchSetOrder()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetPostCheck — Method
SNESLineSearchGetPostCheck(petsclib::PetscLibType, linesearch::SNESLineSearch, noname::Ptr{Cvoid})

Gets the post-check function for the line search routine.

Input Parameter:

  • linesearch - the SNESLineSearch context

Output Parameters:

  • func - [optional] function evaluation routine, see for the calling sequence SNESLineSearchSetPostCheck()
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchGetPreCheck(), SNESLineSearchSetPostCheck(), SNESLineSearchPostCheck(), SNESLineSearchSetPreCheck()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetPreCheck — Method
SNESLineSearchGetPreCheck(petsclib::PetscLibType, linesearch::SNESLineSearch, noname::Ptr{Cvoid})

Gets the pre-check function for the line search routine.

Input Parameter:

  • linesearch - the SNESLineSearch context

Output Parameters:

  • func - [optional] function evaluation routine, for calling sequence see SNESLineSearchSetPreCheck()
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Level: intermediate

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchPreCheck(), SNESLineSearchGetPostCheck(), SNESLineSearchSetPreCheck(), SNESLineSearchSetPostCheck()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetReason — Method
reason::SNESLineSearchReason = SNESLineSearchGetReason(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the success/failure status of the last line search application

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • reason - The success or failure status

Level: developer

See also: SNES, SNESLineSearch, SNESLineSearchSetReason(), SNESLineSearchReason

External Links

source
PETSc.LibPETSc.SNESLineSearchGetSNES — Method
snes::SNES = SNESLineSearchGetSNES(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the SNES instance associated with the line search.

Not Collective

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • snes - The SNES instance

Level: developer

See also: SNES, SNESLineSearch, SNESType, SNESLineSearchSetVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetTolerances — Method
minlambda::PetscReal,maxlambda::PetscReal,rtol::PetscReal,atol::PetscReal,ltol::PetscReal,max_it::PetscInt = SNESLineSearchGetTolerances(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the tolerances for the line search.

Not Collective

Input Parameter:

  • linesearch - the line search context

Output Parameters:

  • minlambda - The minimum lambda allowed
  • maxlambda - The maximum lambda allowed
  • rtol - The relative tolerance for iterative line searches
  • atol - The absolute tolerance for iterative line searches
  • ltol - The change in lambda tolerance for iterative line searches
  • max_it - The maximum number of iterations of the line search

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchSetTolerances()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetType — Method
type::String = SNESLineSearchGetType(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the SNESLinesearchType of a SNESLineSearch

Logically Collective

Input Parameter:

  • linesearch - the line search context

Output Parameter:

  • type - The type of line search, or NULL if not set

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchType, SNESLineSearchCreate(), SNESLineSearchSetFromOptions(), SNESLineSearchSetType(), PetscObjectTypeCompare(), PetscObjectTypeCompareAny()

External Links

source
PETSc.LibPETSc.SNESLineSearchGetVIFunctions — Method
projectfunc::Ptr{Cvoid},normfunc::Ptr{Cvoid},dirderivfunc::Ptr{Cvoid} = SNESLineSearchGetVIFunctions(petsclib::PetscLibType, linesearch::SNESLineSearch)

Sets VI-specific functions for line search computation.

Not Collective

Input Parameter:

  • linesearch - the line search context, obtain with SNESGetLineSearch()

Output Parameters:

  • projectfunc - function for projecting the function to the bounds, see SNESLineSearchVIProjectFn for calling sequence
  • normfunc - function for computing the norm of an active set, see SNESLineSearchVINormFn for calling sequence
  • dirderivfunc - function for computing the directional derivative of an active set, see SNESLineSearchVIDirDerivFn for calling sequence

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchSetVIFunctions(), SNESLineSearchGetPostCheck(), SNESLineSearchGetPreCheck(), SNESLineSearchVIProjectFn, SNESLineSearchVINormFn

External Links

source
PETSc.LibPETSc.SNESLineSearchGetVecs — Method
X::PetscVec,F::PetscVec,Y::PetscVec,W::PetscVec,G::PetscVec = SNESLineSearchGetVecs(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the vectors from the SNESLineSearch context

Not Collective but the vectors are parallel

Input Parameter:

  • linesearch - the line search context

Output Parameters:

  • X - Solution vector
  • F - Function vector
  • Y - Search direction vector
  • W - Solution work vector
  • G - Function work vector

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchGetNorms(), SNESLineSearchSetVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchMonitor — Method
SNESLineSearchMonitor(petsclib::PetscLibType, ls::SNESLineSearch)

runs the user provided monitor routines, if they exist

Collective

Input Parameter:

  • ls - the linesearch object

Level: developer

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchMonitorSet()

External Links

source
PETSc.LibPETSc.SNESLineSearchMonitorCancel — Method
SNESLineSearchMonitorCancel(petsclib::PetscLibType, ls::SNESLineSearch)

Clears all the monitor functions for a SNESLineSearch object.

Logically Collective

Input Parameter:

  • ls - the SNESLineSearch context

Options Database Key:

  • -snes_linesearch_monitor_cancel - cancels all monitors that have been hardwired

into a code by calls to SNESLineSearchMonitorSet(), but does not cancel those set via the options database

Level: advanced

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchMonitorDefault(), SNESLineSearchMonitorSet()

External Links

source
PETSc.LibPETSc.SNESLineSearchMonitorSet — Method
SNESLineSearchMonitorSet(petsclib::PetscLibType, ls::SNESLineSearch, f::external, mctx::Ptr{Cvoid}, monitordestroy::Ptr{Cvoid})

Sets an ADDITIONAL function that is to be used at every iteration of the nonlinear solver to display the iteration's progress.

Logically Collective

Input Parameters:

  • ls - the SNESLineSearch context
  • f - the monitor function
  • mctx - [optional] user-defined context for private data for the monitor routine (use NULL if no context is desired)
  • monitordestroy - [optional] routine that frees monitor context (may be NULL), see PetscCtxDestroyFn for the calling sequence

Calling sequence of f:

  • ls - the SNESLineSearch context
  • mctx - [optional] user-defined context for private data for the monitor routine

Level: intermediate

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchMonitorDefault(), SNESLineSearchMonitorCancel(), PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.SNESLineSearchMonitorSetFromOptions — Method
SNESLineSearchMonitorSetFromOptions(petsclib::PetscLibType, ls::SNESLineSearch, name::String, help::String, manual::String, monitor::external, monitorsetup::external)

Sets a monitor function and viewer appropriate for the type indicated in the options database

Collective

Input Parameters:

  • ls - SNESLineSearch object to monitor
  • name - the monitor type
  • help - message indicating what monitoring is done
  • manual - manual page for the monitor
  • monitor - the monitor function, must use PetscViewerAndFormat as its context
  • monitorsetup - a function that is called once ONLY if the user selected this monitor that may set additional features of the SNESLineSearch or PetscViewer

Calling sequence of monitor:

  • ls - SNESLineSearch object being monitored
  • vf - a PetscViewerAndFormat struct that provides the PetscViewer and PetscViewerFormat being used

Calling sequence of monitorsetup:

  • ls - SNESLineSearch object being monitored
  • vf - a PetscViewerAndFormat struct that provides the PetscViewer and PetscViewerFormat being used

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchSetMonitor(), PetscOptionsCreateViewer(), PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHeadBegin(), PetscOptionsStringArray(), PetscOptionsRealArray(), PetscOptionsScalar(), PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), PetscOptionsFList(), PetscOptionsEList()

External Links

source
PETSc.LibPETSc.SNESLineSearchMonitorSolutionUpdate — Method
SNESLineSearchMonitorSolutionUpdate(petsclib::PetscLibType, ls::SNESLineSearch, vf::Vector{PetscViewerAndFormat})

Monitors each update of the function value the linesearch tries

Collective

Input Parameters:

  • ls - the SNESLineSearch object
  • vf - the context for the monitor, in this case it is an PetscViewerAndFormat

Options Database Key:

  • -snes_linesearch_monitor_solution_update [viewer:filename:format] - view each update tried by line search routine

Level: developer

This is not normally called directly but is passed to SNESLineSearchMonitorSet()

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchMonitorSet(), SNESMonitorSolution()

External Links

source
PETSc.LibPETSc.SNESLineSearchPostCheck — Method
changed_Y::PetscBool,changed_W::PetscBool = SNESLineSearchPostCheck(petsclib::PetscLibType, linesearch::SNESLineSearch, X::AbstractPetscVec, Y::AbstractPetscVec, W::AbstractPetscVec)

Hook to modify step direction or updated solution after a successful linesearch

Logically Collective

Input Parameters:

  • linesearch - The line search context
  • X - The last solution
  • Y - The step direction
  • W - The updated solution, W = X - lambda * Y for some lambda

Output Parameters:

  • changed_Y - Indicator if the direction Y has been changed.
  • changed_W - Indicator if the new candidate solution W has been changed.

Level: developer

See also: SNES, SNESGetLineSearch(), SNESLineSearchPreCheck(), SNESLineSearchSetPostCheck(), SNESLineSearchGetPostCheck(), SNESLineSearchSetPrecheck(), SNESLineSearchGetPrecheck()

External Links

source
PETSc.LibPETSc.SNESLineSearchPreCheck — Method
changed::PetscBool = SNESLineSearchPreCheck(petsclib::PetscLibType, linesearch::SNESLineSearch, X::AbstractPetscVec, Y::AbstractPetscVec)

Prepares the line search for being applied.

Logically Collective

Input Parameters:

  • linesearch - The linesearch instance.
  • X - The current solution
  • Y - The step direction

Output Parameter:

  • changed - Indicator that the precheck routine has changed Y

Level: advanced

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchPostCheck(), SNESLineSearchSetPreCheck(), SNESLineSearchGetPreCheck(), SNESLineSearchSetPostCheck(), SNESLineSearchGetPostCheck()

External Links

source
PETSc.LibPETSc.SNESLineSearchPreCheckPicard — Method
changed::PetscBool = SNESLineSearchPreCheckPicard(petsclib::PetscLibType, linesearch::SNESLineSearch, X::AbstractPetscVec, Y::AbstractPetscVec, ctx::Ptr{Cvoid})

Implements a correction that is sometimes useful to improve the convergence rate of Picard iteration {cite}hindmarsh1996time

Logically Collective

Input Parameters:

  • linesearch - the line search context
  • X - base state for this step
  • ctx - context for this function

Input/Output Parameter:

  • Y - correction, possibly modified

Output Parameter:

  • changed - flag indicating that Y was modified

Options Database Keys:

  • -snes_linesearch_precheck_picard (true|false) - activate this routine
  • -snes_linesearch_precheck_picard_angle angle - the angle to use

Level: advanced

See also: SNES, SNESLineSearch, SNESSetPicard(), SNESGetLineSearch(), SNESLineSearchSetPreCheck(), SNESLineSearchSetPostCheck()

External Links

source
PETSc.LibPETSc.SNESLineSearchRegister — Method
SNESLineSearchRegister(petsclib::PetscLibType, sname::String, fnc::external)

register a line search type SNESLineSearchType

Logically Collective, No Fortran Support

Input Parameters:

  • sname - name of the SNESLineSearchType()
  • function - the creation function for that type

Calling sequence of function:

  • ls - the line search context

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchType, SNESLineSearchSetType()

External Links

source
PETSc.LibPETSc.SNESLineSearchReset — Method
SNESLineSearchReset(petsclib::PetscLibType, linesearch::SNESLineSearch)

Undoes the SNESLineSearchSetUp() and deletes any Vecs or Mats allocated by the line search.

Collective

Input Parameter:

  • linesearch - The SNESLineSearch instance.

Level: developer

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchSetUp()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetComputeNorms — Method
SNESLineSearchSetComputeNorms(petsclib::PetscLibType, linesearch::SNESLineSearch, flg::PetscBool)

Turns on or off the computation of final norms in the line search.

Input Parameters:

  • linesearch - the line search context
  • flg - indicates whether or not to compute norms

Options Database Key:

  • -snes_linesearch_norms (true|false) - Turns on/off computation of the norms for basic (none) SNESLINESEARCHBASIC line search

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchGetNorms(), SNESLineSearchSetNorms(), SNESLineSearchComputeNorms(), SNESLINESEARCHBASIC

External Links

source
PETSc.LibPETSc.SNESLineSearchSetDamping — Method
SNESLineSearchSetDamping(petsclib::PetscLibType, linesearch::SNESLineSearch, damping::PetscReal)

Sets the line search damping parameter.

Input Parameters:

  • linesearch - the line search context
  • damping - The damping parameter

Options Database Key:

  • -snes_linesearch_damping damping - the damping value

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchGetDamping()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetDefaultMonitor — Method
SNESLineSearchSetDefaultMonitor(petsclib::PetscLibType, linesearch::SNESLineSearch, viewer::PetscViewer)

Turns on/off printing useful information and debugging output about the line search.

Logically Collective

Input Parameters:

  • linesearch - the linesearch object
  • viewer - an PETSCVIEWERASCII PetscViewer or NULL to turn off monitor

Options Database Key:

  • -snes_linesearch_monitor [:filename] - enables the monitor

Level: intermediate

See also: SNES, SNESLineSearch, PETSCVIEWERASCII, SNESGetLineSearch(), SNESLineSearchGetDefaultMonitor(), PetscViewer, SNESLineSearchSetMonitor(), SNESLineSearchMonitorSetFromOptions()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetFromOptions — Method
SNESLineSearchSetFromOptions(petsclib::PetscLibType, linesearch::SNESLineSearch)

Sets options for the line search

Logically Collective

Input Parameter:

  • linesearch - a SNESLineSearch line search context

Options Database Keys:

  • -snes_linesearch_type (none|basic|bt|secant|cp|nleqerr|bisection|shell) - Line search type, see SNESLineSearchType
  • -snes_linesearch_order order - 1, 2, 3. Most types only support certain orders (bt supports 1, 2 or 3)
  • -snes_linesearch_norms (true|false) - Turn on/off the linesearch norms for the basic linesearch typem (SNESLineSearchSetComputeNorms())
  • -snes_linesearch_minlambda minlambda - The minimum lambda
  • -snes_linesearch_maxlambda maxlambda - The maximum lambda
  • -snes_linesearch_rtol rtol - Relative tolerance for iterative line searches
  • -snes_linesearch_atol atol - Absolute tolerance for iterative line searches
  • -snes_linesearch_ltol ltol - Change in lambda tolerance for iterative line searches
  • -snes_linesearch_max_it max_it - The number of iterations for iterative line searches
  • -snes_linesearch_monitor [:filename] - Print progress of line searches
  • -snes_linesearch_monitor_solution_update [viewer:filename:format] - view each update tried by line search routine
  • -snes_linesearch_damping damping - The linesearch damping parameter
  • -snes_linesearch_keeplambda (true|false) - Keep the previous lambda as the initial guess.
  • -snes_linesearch_precheck_picard (true|false) - Use precheck that speeds up convergence of picard method
  • -snes_linesearch_precheck_picard_angle angle - Angle used in Picard precheck method

Level: intermediate

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchCreate(), SNESLineSearchSetOrder(), SNESLineSearchSetType(), SNESLineSearchSetTolerances(), SNESLineSearchSetDamping(), SNESLineSearchPreCheckPicard(), SNESLineSearchType, SNESLineSearchSetComputeNorms()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetFunction — Method
SNESLineSearchSetFunction(petsclib::PetscLibType, linesearch::SNESLineSearch, func::external)

Sets the function evaluation used by the SNES line search `

Input Parameters:

  • linesearch - the SNESLineSearch context
  • func - function evaluation routine, this is usually the function provided with SNESSetFunction()

Calling sequence of func:

  • snes - the SNES with which the SNESLineSearch context is associated with
  • x - the input vector
  • f - the computed value of the function

Level: developer

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESSetFunction()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetLambda — Method
SNESLineSearchSetLambda(petsclib::PetscLibType, linesearch::SNESLineSearch, lambda::PetscReal)

Sets the line search lambda (scaling of the solution update)

Input Parameters:

  • linesearch - line search context
  • lambda - The lambda to use

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchGetLambda()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetNorms — Method
SNESLineSearchSetNorms(petsclib::PetscLibType, linesearch::SNESLineSearch, xnorm::PetscReal, fnorm::PetscReal, ynorm::PetscReal)

Sets the computed norms for the current solution X, the current update Y, and the current function value F.

Collective

Input Parameters:

  • linesearch - the line search context
  • xnorm - The norm of the current solution
  • fnorm - The norm of the current function, this is the norm(function(X)) where X is the current solution
  • ynorm - The norm of the current update (after scaling by the linesearch computed lambda)

Level: developer

See also: SNES, SNESLineSearch, SNESLineSearchGetNorms(), SNESLineSearchSetVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetOrder — Method
SNESLineSearchSetOrder(petsclib::PetscLibType, linesearch::SNESLineSearch, order::PetscInt)

Sets the maximum order of the polynomial fit used in the line search

Input Parameters:

  • linesearch - the line search context
  • order - The order

Level: intermediate

Values for order:

  • 1 orSNESLINESEARCHORDER_LINEAR` - linear order
  • 2 orSNESLINESEARCHORDER_QUADRATIC` - quadratic order
  • 3 orSNESLINESEARCHORDER_CUBIC` - cubic order

Options Database Key:

  • -snes_linesearch_order order - 1, 2, 3. Most types only support certain orders (SNESLINESEARCHBT supports 2 or 3)

See also: SNES, SNESLineSearch, SNESLineSearchGetOrder(), SNESLineSearchSetDamping()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetPostCheck — Method
SNESLineSearchSetPostCheck(petsclib::PetscLibType, linesearch::SNESLineSearch, func::external, ctx::Ptr{Cvoid})

Sets a user function that is called after the line search has been applied to determine the step direction and length. Allows the user a chance to change or override the decision of the line search routine

Logically Collective

Input Parameters:

  • linesearch - the SNESLineSearch context
  • func - [optional] function evaluation routine
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • ls - the SNESLineSearch context
  • x - the current solution
  • d - the current search direction
  • w - w = x + lambda*d for some lambda
  • changed_d - indicates if the search direction d has been changed
  • changed_w - indicates w has been changed
  • ctx - the context passed to SNESLineSearchSetPreCheck()

Level: intermediate

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchPostCheck(), SNESLineSearchSetPreCheck(), SNESLineSearchGetPreCheck(), SNESLineSearchGetPostCheck(), SNESVISetVariableBounds(), SNESVISetComputeVariableBounds(), SNESSetFunctionDomainError(), SNESSetJacobianDomainError()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetPreCheck — Method
SNESLineSearchSetPreCheck(petsclib::PetscLibType, linesearch::SNESLineSearch, func::external, ctx::Ptr{Cvoid})

Sets a function that is called after the initial search direction has been computed but before the line search routine has been applied. Allows adjusting the result of (usually a linear solve) that determined the search direction.

Logically Collective

Input Parameters:

  • linesearch - the SNESLineSearch context
  • func - [optional] function evaluation routine
  • ctx - [optional] user-defined context for private data for the function evaluation routine (may be NULL)

Calling sequence of func:

  • ls - the SNESLineSearch context
  • x - the current solution
  • d - the current search direction
  • changed_d - indicates if the search direction has been changed
  • ctx - the context passed to SNESLineSearchSetPreCheck()

Level: intermediate

See also: SNES, SNESGetLineSearch(), SNESLineSearchPreCheck(), SNESLineSearchSetPostCheck(), SNESLineSearchGetPostCheck(), SNESLineSearchGetPreCheck(), SNESVISetVariableBounds(), SNESVISetComputeVariableBounds(), SNESSetFunctionDomainError(), SNESSetJacobianDomainError()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetReason — Method
SNESLineSearchSetReason(petsclib::PetscLibType, linesearch::SNESLineSearch, reason::SNESLineSearchReason)

Sets the success/failure reason of the line search application

Logically Collective; No Fortran Support

Input Parameters:

  • linesearch - the line search context
  • reason - The success or failure reason

Level: developer

See also: SNES, SNESLineSearch, SNESLineSearchReason, SNESLineSearchGetSResult(), SNESSetFunctionDomainError(), SNESSetFunction()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetSNES — Method
SNESLineSearchSetSNES(petsclib::PetscLibType, linesearch::SNESLineSearch, snes::AbstractSNES)

Sets the SNES for the linesearch for function evaluation.

Input Parameters:

  • linesearch - the line search context
  • snes - The SNES instance

Level: developer

See also: SNES, SNESLineSearch, SNESLineSearchGetSNES(), SNESLineSearchSetVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetTolerances — Method
SNESLineSearchSetTolerances(petsclib::PetscLibType, linesearch::SNESLineSearch, minlambda::PetscReal, maxlambda::PetscReal, rtol::PetscReal, atol::PetscReal, ltol::PetscReal, max_it::PetscInt)

Sets the tolerances for the linesearch.

Collective

Input Parameters:

  • linesearch - the line search context
  • minlambda - The minimum lambda allowed
  • maxlambda - The maximum lambda allowed
  • rtol - The relative tolerance for iterative line searches
  • atol - The absolute tolerance for iterative line searches
  • ltol - The change in lambda tolerance for iterative line searches
  • max_it - The maximum number of iterations of the line search

Options Database Keys:

  • -snes_linesearch_minlambda - The minimum lambda allowed
  • -snes_linesearch_maxlambda - The maximum lambda allowed
  • -snes_linesearch_rtol - Relative tolerance for iterative line searches
  • -snes_linesearch_atol - Absolute tolerance for iterative line searches
  • -snes_linesearch_ltol - Change in lambda tolerance for iterative line searches
  • -snes_linesearch_max_it - The number of iterations for iterative line searches

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchGetTolerances()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetType — Method
SNESLineSearchSetType(petsclib::PetscLibType, linesearch::SNESLineSearch, type::String)

Sets the SNESLinesearchType of a SNESLineSearch object to indicate the line search algorithm that should be used by a given SNES solver

Logically Collective

Input Parameters:

  • linesearch - the line search context
  • type - The type of line search to be used, see SNESLineSearchType

Options Database Key:

  • -snes_linesearch_type (none|basic|bt|secant|cp|nleqerr|bisection|shell) - Line search type to use, see SNESLineSearchType

Level: intermediate

See also: SNES, SNESLineSearch, SNESLineSearchType, SNESLineSearchCreate(), SNESLineSearchSetFromOptions(), SNESLineSearchGetType(), SNESGetLineSearch()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetUp — Method
SNESLineSearchSetUp(petsclib::PetscLibType, linesearch::SNESLineSearch)

Prepares the line search for being applied by allocating any required vectors.

Collective

Input Parameter:

  • linesearch - The SNESLineSearch instance.

Level: advanced

See also: SNES, SNESLineSearch, SNESGetLineSearch(), SNESLineSearchReset()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetVIFunctions — Method
SNESLineSearchSetVIFunctions(petsclib::PetscLibType, linesearch::SNESLineSearch, projectfunc::Ptr{Cvoid}, normfunc::Ptr{Cvoid}, dirderivfunc::Ptr{Cvoid})

Sets VI-specific functions for line search computation.

Logically Collective

Input Parameters:

  • linesearch - the linesearch object
  • projectfunc - function for projecting the function to the bounds, see SNESLineSearchVIProjectFn for calling sequence
  • normfunc - function for computing the norm of an active set, see SNESLineSearchVINormFn for calling sequence
  • dirderivfunc - function for computing the directional derivative of an active set, see SNESLineSearchVIDirDerivFn for calling sequence

Level: advanced

See also: SNES, SNESLineSearch, SNESLineSearchGetVIFunctions(), SNESLineSearchSetPostCheck(), SNESLineSearchSetPreCheck(), SNESLineSearchVIProjectFn, SNESLineSearchVINormFn, SNESLineSearchVIDirDerivFn

External Links

source
PETSc.LibPETSc.SNESLineSearchSetVecs — Method
SNESLineSearchSetVecs(petsclib::PetscLibType, linesearch::SNESLineSearch, X::AbstractPetscVec, F::AbstractPetscVec, Y::AbstractPetscVec, W::AbstractPetscVec, G::AbstractPetscVec)

Sets the vectors on the SNESLineSearch context

Logically Collective

Input Parameters:

  • linesearch - the line search context
  • X - Solution vector
  • F - Function vector
  • Y - Search direction vector
  • W - Solution work vector
  • G - Function work vector

Level: developer

See also: SNES, SNESLineSearch, SNESLineSearchSetNorms(), SNESLineSearchGetVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchSetWorkVecs — Method
SNESLineSearchSetWorkVecs(petsclib::PetscLibType, linesearch::SNESLineSearch, nwork::PetscInt)

Sets work vectors for the line search.

Input Parameters:

  • linesearch - the SNESLineSearch context
  • nwork - the number of work vectors

Level: developer

See also: SNES, SNESLineSearch, SNESSetWorkVecs()

External Links

source
PETSc.LibPETSc.SNESLineSearchShellGetApply — Method
func::Ptr{Cvoid},ctx::Ptr{Cvoid} = SNESLineSearchShellGetApply(petsclib::PetscLibType, linesearch::SNESLineSearch)

Gets the apply function and context for the SNESLINESEARCHSHELL

Not Collective

Input Parameter:

  • linesearch - the line search object

Output Parameters:

  • func - the user function; can be NULL if it is not needed, see SNESLineSearchShellApplyFn for calling sequence
  • ctx - the user function context; can be NULL if it is not needed

Level: advanced

See also: SNESLineSearchShellSetApply(), SNESLINESEARCHSHELL, SNESLineSearchType, SNESLineSearch, SNESLineSearchShellApplyFn

External Links

source
PETSc.LibPETSc.SNESLineSearchShellSetApply — Method
SNESLineSearchShellSetApply(petsclib::PetscLibType, linesearch::SNESLineSearch, func::Ptr{Cvoid}, ctx::Ptr{Cvoid})

Sets the apply function for the SNESLINESEARCHSHELL implementation.

Not Collective

Input Parameters:

  • linesearch - SNESLineSearch context
  • func - function implementing the linesearch shell, see SNESLineSearchShellApplyFn for calling sequence
  • ctx - context for func

Usage: `` PetscErrorCode shellfunc(SNESLineSearch linesearch,void * ctx) { Vec X,Y,F,W,G; SNES snes;

PetscFunctionBegin; PetscCall(SNESLineSearchGetSNES(linesearch,&snes)); PetscCall(SNESLineSearchSetReason(linesearch,SNESLINESEARCHSUCCEEDED)); PetscCall(SNESLineSearchGetVecs(linesearch,&X,&F,&Y,&W,&G)); // determine lambda using W and G as work vecs.. PetscCall(VecAXPY(X,-lambda,Y)); PetscCall(SNESComputeFunction(snes,X,F)); PetscCall(SNESLineSearchComputeNorms(linesearch)); PetscFunctionReturn(PETSC_SUCCESS); }

PetscCall(SNESGetLineSearch(snes, &linesearch)); PetscCall(SNESLineSearchSetType(linesearch, SNESLINESEARCHSHELL)); PetscCall(SNESLineSearchShellSetApply(linesearch, shellfunc, NULL)); ``

Level: advanced

See also: SNESLineSearchShellGetApply(), SNESLINESEARCHSHELL, SNESLineSearchType, SNESLineSearch, SNESLineSearchShellApplyFn

External Links

source
PETSc.LibPETSc.SNESLineSearchView — Method
SNESLineSearchView(petsclib::PetscLibType, linesearch::SNESLineSearch, viewer::PetscViewer)

Prints useful information about the line search

Logically Collective

Input Parameters:

  • linesearch - line search context
  • viewer - the PetscViewer to display the line search information to

Level: intermediate

See also: SNES, SNESLineSearch, PetscViewer, SNESLineSearchCreate()

External Links

source

Hand-written helpers

PETSc.LibPETSc.SNESGetJacobianMat — Method
SNESGetJacobianMat(petsclib, snes) -> PetscMat

Return the assembled system (A) matrix from snes, passing NULL for the preconditioner matrix, Jacobian function, and context. Use this when only the system matrix is needed (e.g. to attach a null space via MatSetNullSpace).

source