KSP - Low-level Interface

This page documents the low-level, automatically wrapped PETSc KSP (Krylov Subspace Methods) functions available through LibPETSc. These functions provide direct access to the PETSc C API.

For the high-level Julia interface, see KSP.

Overview

The KSP interface includes:

  • Core KSP operations: Linear solver creation, configuration, and solution (~244 functions in KSP_wrappers.jl)
  • KSPGuess: Initial guess generation for iterative solvers (~12 functions in KSPGuess_wrappers.jl)

Usage

All low-level KSP 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

# Assume mat, b, x are already created

# Create KSP solver
ksp = LibPETSc.KSPCreate(petsclib, LibPETSc.PETSC_COMM_SELF)
LibPETSc.KSPSetOperators(petsclib, ksp, mat, mat)
LibPETSc.KSPSetFromOptions(petsclib, ksp)

# Solve Ax = b
LibPETSc.KSPSolve(petsclib, ksp, b, x)

# Get convergence info
reason = LibPETSc.KSPGetConvergedReason(petsclib, ksp)

iterations = LibPETSc.KSPGetIterationNumber(petsclib, ksp)

# Clean up
LibPETSc.KSPDestroy(petsclib, ksp)
PETSc.finalize(petsclib)

Function Reference

PETSc.LibPETSc.KSPAppendOptionsPrefixMethod
KSPAppendOptionsPrefix(petsclib::PetscLibType,ksp::PetscKSP, prefix::String)

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

Logically Collective

Input Parameters:

  • ksp - the Krylov context
  • prefix - the prefix string to prepend to all KSP option requests

Level: intermediate

-seealso: , KSP, KSPSetOptionsPrefix(), KSPGetOptionsPrefix(), KSPSetFromOptions()

External Links

source
PETSc.LibPETSc.KSPBCGSLSetEllMethod
KSPBCGSLSetEll(petsclib::PetscLibType,ksp::PetscKSP, ell::PetscInt)

Sets the number of search directions to use in the KSPBCGSL Krylov solver

Logically Collective

Input Parameters:

  • ksp - iterative context, KSP, of type KSPBCGSL
  • ell - number of search directions to use

Options Database Key:

  • -ksp_bcgsl_ell ell - Number of Krylov search directions

Level: intermediate

-seealso: , KSPBCGSLSetUsePseudoinverse(), KSP, KSPBCGSL, KSPBCGSLSetPol(), KSPBCGSLSetXRes()

External Links

source
PETSc.LibPETSc.KSPBCGSLSetPolMethod
KSPBCGSLSetPol(petsclib::PetscLibType,ksp::PetscKSP, uMROR::PetscBool)

Sets the type of polynomial part that will be used in the KSPCBGSL KSPSolve()

Logically Collective

Input Parameters:

  • ksp - iterative context of type KSPCBGSL
  • uMROR - set to PETSC_TRUE when the polynomial is a convex combination of an MR and an OR step.

Options Database Keys:

  • -ksp_bcgsl_cxpoly - use enhanced polynomial
  • -ksp_bcgsl_mrpoly - use standard polynomial

Level: intermediate

-seealso: , KSP, KSPBCGSL, KSPCreate(), KSPSetType(), KSPCBGSL, KSPBCGSLSetUsePseudoinverse(), KSPBCGSLSetEll(), KSPBCGSLSetXRes()

External Links

source
PETSc.LibPETSc.KSPBCGSLSetUsePseudoinverseMethod
KSPBCGSLSetUsePseudoinverse(petsclib::PetscLibType,ksp::PetscKSP, use_pinv::PetscBool)

Use pseudoinverse (via SVD) to solve polynomial part of the update in KSPCBGSL solver

Logically Collective

Input Parameters:

  • ksp - iterative context of type KSPCBGSL
  • use_pinv - set to PETSC_TRUE when using pseudoinverse

Options Database Key:

  • -ksp_bcgsl_pinv <true,false> - use pseudoinverse

Level: intermediate

-seealso: , KSPBCGSLSetEll(), KSP, KSPCBGSL, KSPBCGSLSetPol(), KSPBCGSLSetXRes()

External Links

source
PETSc.LibPETSc.KSPBCGSLSetXResMethod
KSPBCGSLSetXRes(petsclib::PetscLibType,ksp::PetscKSP, delta::PetscReal)

Sets the parameter governing when exact residuals will be used instead of computed residuals for KSPCBGSL.

Logically Collective

Input Parameters:

  • ksp - iterative context of type KSPBCGSL
  • delta - computed residuals are used alone when delta is not positive

Options Database Key:

  • -ksp_bcgsl_xres delta - Threshold used to decide when to refresh computed residuals

Level: intermediate

-seealso: , KSPBCGSLSetEll(), KSPBCGSLSetPol(), KSP, KSPCBGSL, KSPBCGSLSetUsePseudoinverse()

External Links

source
PETSc.LibPETSc.KSPBuildResidualMethod
KSPBuildResidual(petsclib::PetscLibType,ksp::PetscKSP, t::PetscVec, v::PetscVec, V::PetscVec)

Builds the residual in a vector provided.

Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameters:

  • t - work vector. If not provided then one is generated.
  • v - optional location to stash residual. If v is not provided, then a location is generated.
  • V - the residual

Level: advanced

-seealso: , KSP, KSPBuildSolution()

External Links

source
PETSc.LibPETSc.KSPBuildResidualDefaultMethod
KSPBuildResidualDefault(petsclib::PetscLibType,ksp::PetscKSP, t::PetscVec, v::PetscVec, V::PetscVec)

Default code to compute the residual.

Collecive on ksp

Input Parameters:

  • ksp - iterative context
  • t - pointer to temporary vector
  • v - pointer to user vector

Output Parameter:

  • V - pointer to a vector containing the residual

Level: advanced

-seealso: , KSP, KSPBuildSolutionDefault()

External Links

source
PETSc.LibPETSc.KSPBuildSolutionMethod
KSPBuildSolution(petsclib::PetscLibType,ksp::PetscKSP, v::PetscVec, V::PetscVec)

Builds the approximate solution in a vector provided.

Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter: Provide exactly one of

  • v - location to stash solution, optional, otherwise pass NULL
  • V - the solution is returned in this location. This vector is created internally. This vector should NOT be destroyed by the user with VecDestroy().

Level: developer

-seealso: , KSPGetSolution(), KSPBuildResidual(), KSP

External Links

source
PETSc.LibPETSc.KSPCGGetNormDMethod
KSPCGGetNormD(petsclib::PetscLibType,ksp::PetscKSP, norm_d::PetscReal)

Get norm of the direction when the solver is used inside SNESNEWTONTR

Not collective

Input Parameters:

  • ksp - the iterative context
  • norm_d - the norm of the direction

Level: advanced

-seealso: , KSP, KSPCG, KSPNASH, KSPSTCG, KSPGLTR, SNESNEWTONTR

External Links

source
PETSc.LibPETSc.KSPCGGetObjFcnMethod
KSPCGGetObjFcn(petsclib::PetscLibType,ksp::PetscKSP, o_fcn::PetscReal)

Get the conjugate gradient objective function value

Not collective

Input Parameters:

  • ksp - the iterative context
  • o_fcn - the objective function value

Level: advanced

-seealso: , KSP, KSPCG, KSPNASH, KSPSTCG, KSPGLTR, KSPMonitorSet

External Links

source
PETSc.LibPETSc.KSPCGSetObjectiveTargetMethod
KSPCGSetObjectiveTarget(petsclib::PetscLibType,ksp::PetscKSP, obj::PetscReal)

Sets the target value for the CG quadratic model

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • obj - the objective value (0 is the default)

Level: advanced

-seealso: , KSP, KSPCG, KSPNASH, KSPSTCG, KSPGLTR, SNESNEWTONTR

External Links

source
PETSc.LibPETSc.KSPCGSetRadiusMethod
KSPCGSetRadius(petsclib::PetscLibType,ksp::PetscKSP, radius::PetscReal)

Sets the radius of the trust region used by the KSPCG when the solver is used inside SNESNEWTONTR

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • radius - the trust region radius (0 is the default that disable the use of the radius)

Level: advanced

-seealso: , KSP, KSPCG, KSPNASH, KSPSTCG, KSPGLTR, SNESNEWTONTR

External Links

source
PETSc.LibPETSc.KSPCGSetTypeMethod
KSPCGSetType(petsclib::PetscLibType,ksp::PetscKSP, type::KSPCGType)

Sets the variant of the conjugate gradient method to use for solving a linear system with a complex coefficient matrix. This option is irrelevant when solving a real system.

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • type - the variant of CG to use, one of

-seealso: , KSP, KSPCG

External Links

source
PETSc.LibPETSc.KSPCGUseSingleReductionMethod
KSPCGUseSingleReduction(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Merge the two inner products needed in KSPCG into a single MPI_Allreduce() call.

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • flg - turn on or off the single reduction

Options Database Key:

  • -ksp_cg_single_reduction <bool> - Merge inner products into single MPI_Allreduce()

Level: intermediate

-seealso: , , KSP, KSPCG, KSPGMRES, KSPPIPECG, KSPPIPECR, and KSPGROPPCG

External Links

source
PETSc.LibPETSc.KSPChebyshevEstEigGetKSPMethod
KSPChebyshevEstEigGetKSP(petsclib::PetscLibType,ksp::PetscKSP, kspest::PetscKSP)

Get the Krylov method context used to estimate the eigenvalues for the Chebyshev method.

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • kspest - the eigenvalue estimation Krylov space context

Level: advanced

-seealso: , KSPCHEBYSHEV, KSPChebyshevEstEigSet()

External Links

source
PETSc.LibPETSc.KSPChebyshevEstEigSetMethod
KSPChebyshevEstEigSet(petsclib::PetscLibType,ksp::PetscKSP, a::PetscReal, b::PetscReal, c::PetscReal, d::PetscReal)

Automatically estimate the eigenvalues to use for Chebyshev

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • a - multiple of min eigenvalue estimate to use for min Chebyshev bound (or PETSC_DECIDE)
  • b - multiple of max eigenvalue estimate to use for min Chebyshev bound (or PETSC_DECIDE)
  • c - multiple of min eigenvalue estimate to use for max Chebyshev bound (or PETSC_DECIDE)
  • d - multiple of max eigenvalue estimate to use for max Chebyshev bound (or PETSC_DECIDE)

Options Database Key:

  • -ksp_chebyshev_esteig a,b,c,d - estimate eigenvalues using a Krylov method, then use this transform for Chebyshev eigenvalue bounds

-seealso: , KSPCHEBYSHEV, KSPChebyshevEstEigSetUseNoisy(), KSPChebyshevEstEigGetKSP()

External Links

source
PETSc.LibPETSc.KSPChebyshevEstEigSetUseNoisyMethod
KSPChebyshevEstEigSetUseNoisy(petsclib::PetscLibType,ksp::PetscKSP, use::PetscBool)

use a noisy random number generated right

Logically Collective

Input Parameters:

  • ksp - linear solver context
  • use - PETSC_TRUE to use noisy

Options Database Key:

  • -ksp_chebyshev_esteig_noisy <true,false> - Use noisy right-hand side for estimate

Level: intermediate

-seealso: , KSPCHEBYSHEV, KSPChebyshevEstEigSet(), KSPChebyshevEstEigGetKSP()

External Links

source
PETSc.LibPETSc.KSPChebyshevGetKindMethod
KSPChebyshevGetKind(petsclib::PetscLibType,ksp::PetscKSP, kind::KSPChebyshevKind)

get the kind of Chebyshev polynomial to use

Logically Collective

Input Parameters:

  • ksp - Linear solver context
  • kind - The kind of Chebyshev polynomial used

Level: intermediate

-seealso: , KSPCHEBYSHEV, KSPChebyshevKind, KSPChebyshevSetKind(), KSP_CHEBYSHEV_FIRST, KSP_CHEBYSHEV_FOURTH, KSP_CHEBYSHEV_OPT_FOURTH

External Links

source
PETSc.LibPETSc.KSPChebyshevSetEigenvaluesMethod
KSPChebyshevSetEigenvalues(petsclib::PetscLibType,ksp::PetscKSP, emax::PetscReal, emin::PetscReal)

Sets estimates for the extreme eigenvalues of the preconditioned problem.

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • emax - the eigenvalue maximum estimate
  • emin - the eigenvalue minimum estimate

Options Database Key:

  • -ksp_chebyshev_eigenvalues emin,emax - extreme eigenvalues

Level: intermediate

-seealso: , KSPCHEBYSHEV, KSPChebyshevEstEigSet(),

External Links

source
PETSc.LibPETSc.KSPChebyshevSetKindMethod
KSPChebyshevSetKind(petsclib::PetscLibType,ksp::PetscKSP, kind::KSPChebyshevKind)

set the kind of Chebyshev polynomial to use

Logically Collective

Input Parameters:

  • ksp - Linear solver context
  • kind - The kind of Chebyshev polynomial to use, see KSPChebyshevKind, one of KSP_CHEBYSHEV_FIRST, KSP_CHEBYSHEV_FOURTH, or KSP_CHEBYSHEV_OPT_FOURTH

Options Database Key:

  • -ksp_chebyshev_kind <kind> - which kind of Chebyshev polynomial to use

Level: intermediate

-seealso: , KSPCHEBYSHEV, KSPChebyshevKind, KSPChebyshevGetKind(), KSP_CHEBYSHEV_FIRST, KSP_CHEBYSHEV_FOURTH, KSP_CHEBYSHEV_OPT_FOURTH

External Links

source
PETSc.LibPETSc.KSPCheckSolveMethod
KSPCheckSolve(petsclib::PetscLibType,ksp::PetscKSP, pc::PC, vec::PetscVec)

Checks if the PCSetUp() or KSPSolve() failed and set the error flag for the outer PC. A KSP_DIVERGED_ITS is not considered a failure in this context

Collective

Input Parameters:

  • ksp - the linear solver KSP context.
  • pc - the preconditioner context
  • vec - a vector that will be initialized with Inf to indicate lack of convergence

Level: developer

-seealso: , KSP, KSPCreate(), KSPSetType(), KSPCheckNorm(), KSPCheckDot()

External Links

source
PETSc.LibPETSc.KSPComputeConvergenceRateMethod
cr::PetscReal,rRsq::PetscReal,ce::PetscReal,eRsq::PetscReal = KSPComputeConvergenceRate(petsclib::PetscLibType,ksp::PetscKSP)

Compute the convergence rate for the iteration <https:/en.wikipedia.org/wiki/Coefficientofdetermination>

Not Collective

Input Parameter:

  • ksp - The KSP

Output Parameters:

  • cr - The residual contraction rate
  • rRsq - The coefficient of determination, R^2, indicating the linearity of the data
  • ce - The error contraction rate
  • eRsq - The coefficient of determination, R^2, indicating the linearity of the data

Level: advanced

-seealso: , KSP, KSPConvergedRateView()

External Links

source
PETSc.LibPETSc.KSPComputeEigenvaluesMethod
r::Vector{PetscReal},c::Vector{PetscReal},neig::PetscInt = KSPComputeEigenvalues(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt)

Computes the extreme eigenvalues for the preconditioned operator. Called after or during KSPSolve().

Not Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • n - size of arrays r and c. The number of eigenvalues computed neig will, in general, be less than this.

Output Parameters:

  • r - real part of computed eigenvalues, provided by user with a dimension of at least n
  • c - complex part of computed eigenvalues, provided by user with a dimension of at least n
  • neig - actual number of eigenvalues computed (will be less than or equal to n)

Options Database Key:

  • -ksp_view_eigenvalues - Prints eigenvalues to stdout

Level: advanced

-seealso: , KSPSetComputeEigenvalues(), KSPSetComputeSingularValues(), KSPMonitorSingularValue(), KSPComputeExtremeSingularValues(), KSP, KSPComputeRitz()

External Links

source
PETSc.LibPETSc.KSPComputeEigenvaluesExplicitlyMethod
r::Vector{PetscReal},c::Vector{PetscReal} = KSPComputeEigenvaluesExplicitly(petsclib::PetscLibType,ksp::PetscKSP, nmax::PetscInt)

Computes all of the eigenvalues of the preconditioned operator using LAPACK.

Collective

Input Parameters:

  • ksp - iterative context obtained from KSPCreate()
  • nmax - size of arrays r and c

Output Parameters:

  • r - real part of computed eigenvalues, provided by user with a dimension at least of n
  • c - complex part of computed eigenvalues, provided by user with a dimension at least of n

Level: advanced

-seealso: , KSP, KSPComputeEigenvalues(), KSPMonitorSingularValue(), KSPComputeExtremeSingularValues(), KSPSetOperators(), KSPSolve()

External Links

source
PETSc.LibPETSc.KSPComputeExtremeSingularValuesMethod
emax::PetscReal,emin::PetscReal = KSPComputeExtremeSingularValues(petsclib::PetscLibType,ksp::PetscKSP)

Computes the extreme singular values for the preconditioned operator. Called after or during KSPSolve().

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameters:

  • emax - maximum estimated singular value
  • emin - minimum estimated singular value

Options Database Key:

  • -ksp_view_singularvalues - compute extreme singular values and print when KSPSolve() completes.

Level: advanced

-seealso: , KSPSetComputeSingularValues(), KSPMonitorSingularValue(), KSPComputeEigenvalues(), KSP, KSPComputeRitz()

External Links

source
PETSc.LibPETSc.KSPComputeOperatorMethod
KSPComputeOperator(petsclib::PetscLibType,ksp::PetscKSP, mattype::MatType, mat::PetscMat)

Computes the explicit preconditioned operator, including diagonal scaling and null space removal if applicable.

Collective

Input Parameters:

  • ksp - the Krylov subspace context
  • mattype - the matrix type to be used

Output Parameter:

  • mat - the explicit preconditioned operator

Level: advanced

-seealso: , KSP, KSPSetOperators(), KSPComputeEigenvaluesExplicitly(), PCComputeOperator(), KSPSetDiagonalScale(), KSPSetNullSpace(), MatType

External Links

source
PETSc.LibPETSc.KSPComputeRitzMethod
nrit::PetscInt,tetar::Vector{PetscReal},tetai::Vector{PetscReal} = KSPComputeRitz(petsclib::PetscLibType,ksp::PetscKSP, ritz::PetscBool, small::PetscBool, S::Vector{PetscVec})

Computes the Ritz or harmonic Ritz pairs associated with the smallest or largest in modulus, for the preconditioned operator.

Not Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • ritz - PETSC_TRUE or PETSC_FALSE for Ritz pairs or harmonic Ritz pairs, respectively
  • small - PETSC_TRUE or PETSC_FALSE for smallest or largest (harmonic) Ritz values, respectively

Output Parameters:

  • nrit - On input number of (harmonic) Ritz pairs to compute; on output, actual number of computed (harmonic) Ritz pairs
  • S - an array of the Ritz vectors, pass in an array of vectors of size nrit
  • tetar - real part of the Ritz values, pass in an array of size nrit
  • tetai - imaginary part of the Ritz values, pass in an array of size nrit

Level: advanced

-seealso: , KSPSetComputeRitz(), KSP, KSPGMRES, KSPComputeEigenvalues(), KSPSetComputeSingularValues(), KSPMonitorSingularValue()

External Links

source
PETSc.LibPETSc.KSPConvergedDefaultMethod
KSPConvergedDefault(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, reason::KSPConvergedReason, ctx::Cvoid)

Default code to determine convergence of the linear iterative solvers

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - residual norm (may be estimated, depending on the method may be the preconditioned residual norm)
  • ctx - convergence context which must be created by KSPConvergedDefaultCreate()

Output Parameter:

  • reason - the convergence reason; it is positive if the iteration has converged,

negative if the iteration has diverged, and KSP_CONVERGED_ITERATING otherwise

Options Database Keys:

  • -ksp_max_it - maximum number of linear iterations
  • -ksp_min_it - minimum number of linear iterations, defaults to 0
  • -ksp_rtol rtol - relative tolerance used in default determination of convergence, i.e. if residual norm decreases by this factor than convergence is declared
  • -ksp_atol abstol - absolute tolerance used in default convergence test, i.e. if residual norm is less than this then convergence is declared
  • -ksp_divtol tol - if residual norm increases by this factor than divergence is declared
  • -ksp_converged_use_initial_residual_norm - see KSPConvergedDefaultSetUIRNorm()
  • -ksp_converged_use_min_initial_residual_norm - see KSPConvergedDefaultSetUMIRNorm()
  • -ksp_converged_maxits - see KSPConvergedDefaultSetConvergedMaxits()

Level: advanced

-seealso: , KSP, KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPSetMinimumIterations(), KSPConvergenceTestFn, KSPConvergedDefaultSetUIRNorm(), KSPConvergedDefaultSetUMIRNorm(), KSPConvergedDefaultSetConvergedMaxits(), KSPConvergedDefaultCreate(), KSPConvergedDefaultDestroy()

External Links

source
PETSc.LibPETSc.KSPConvergedDefaultCreateMethod
ctx::Cvoid = KSPConvergedDefaultCreate(petsclib::PetscLibType)

Creates and initializes the context used by the KSPConvergedDefault() function

Not Collective

Output Parameter:

  • ctx - convergence context

Level: intermediate

-seealso: , KSP, KSPConvergedDefault(), KSPConvergedDefaultDestroy(), KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPConvergedDefaultSetUIRNorm(), KSPConvergedDefaultSetUMIRNorm(), KSPConvergedDefaultSetConvergedMaxits()

External Links

source
PETSc.LibPETSc.KSPConvergedDefaultDestroyMethod
KSPConvergedDefaultDestroy(petsclib::PetscLibType,ctx::Cvoid)

Frees the space used by the KSPConvergedDefault() function context

Not Collective

Input Parameter:

  • ctx - convergence context

Level: intermediate

-seealso: , KSP, KSPConvergedDefault(), KSPConvergedDefaultCreate(), KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPConvergedDefaultSetUIRNorm(), KSPConvergedDefaultSetUMIRNorm()

External Links

source
PETSc.LibPETSc.KSPConvergedDefaultSetConvergedMaxitsMethod
KSPConvergedDefaultSetConvergedMaxits(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

allows the default convergence test to declare convergence and return KSP_CONVERGED_ITS if the maximum number of iterations is reached

Collective

Input Parameters:

  • ksp - iterative context
  • flg - boolean flag

Options Database Key:

  • -ksp_converged_maxits <bool> - Declare convergence if the maximum number of iterations is reached

Level: intermediate

-seealso: , KSP, KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPConvergedDefaultSetUMIRNorm(), KSPConvergedDefaultSetUIRNorm()

External Links

source
PETSc.LibPETSc.KSPConvergedDefaultSetUIRNormMethod
KSPConvergedDefaultSetUIRNorm(petsclib::PetscLibType,ksp::PetscKSP)

makes the default convergence test use || B(b instead of || Bb ||. In the case of right preconditioner or if KSPSetNormType(ksp,KSP_NORM_UNPRECONDITIONED) is used there is no B in the above formula.

Collective

Input Parameters:

  • ksp - iterative context

Options Database Key:

  • -ksp_converged_use_initial_residual_norm <bool> - Use initial residual norm for computing relative convergence

Level: intermediate

-seealso: , KSP, KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPConvergedDefaultSetUMIRNorm(), KSPConvergedDefaultSetConvergedMaxits()

External Links

source
PETSc.LibPETSc.KSPConvergedDefaultSetUMIRNormMethod
KSPConvergedDefaultSetUMIRNorm(petsclib::PetscLibType,ksp::PetscKSP)

makes the default convergence test use min(|| B*(b In the case of right preconditioner or if KSPSetNormType(ksp,KSP_NORM_UNPRECONDITIONED) is used there is no B in the above formula.

Collective

Input Parameters:

  • ksp - iterative context

Options Database Key:

  • -ksp_converged_use_min_initial_residual_norm <bool> - Use minimum of initial residual norm and b for computing relative convergence

Level: intermediate

-seealso: , KSP, KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPConvergedDefaultSetUIRNorm(), KSPConvergedDefaultSetConvergedMaxits()

External Links

source
PETSc.LibPETSc.KSPConvergedRateViewMethod
KSPConvergedRateView(petsclib::PetscLibType,ksp::PetscKSP, viewer::PetscViewer)

Displays the convergence rate https://en.wikipedia.org/wiki/Coefficient_of_determination of KSPSolve() to a viewer

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • viewer - the PetscViewer to display the reason

Options Database Key:

  • -ksp_converged_rate - print reason for convergence or divergence and the convergence rate (or 0.0 for divergence)

Level: intermediate

-seealso: , KSPConvergedReasonView(), KSPGetConvergedRate(), KSPSetTolerances(), KSPConvergedDefault()

External Links

source
PETSc.LibPETSc.KSPConvergedReasonViewMethod
KSPConvergedReasonView(petsclib::PetscLibType,ksp::PetscKSP, viewer::PetscViewer)

Displays the reason a KSP solve converged or diverged, KSPConvergedReason to a PetscViewer

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • viewer - the PetscViewer on which to display the reason

Options Database Keys:

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

Level: beginner

-seealso: , KSPConvergedReasonViewFromOptions(), KSPCreate(), KSPSetUp(), KSPDestroy(), KSPSetTolerances(), KSPConvergedDefault(), KSPSolveTranspose(), KSPGetIterationNumber(), KSP, KSPGetConvergedReason(), PetscViewerPushFormat(), PetscViewerPopFormat()

External Links

source
PETSc.LibPETSc.KSPConvergedReasonViewCancelMethod
KSPConvergedReasonViewCancel(petsclib::PetscLibType,ksp::PetscKSP)

Clears all the KSPConvergedReason view functions for a KSP object set with KSPConvergedReasonViewSet() as well as the default viewer.

Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Level: intermediate

-seealso: , KSPCreate(), KSPDestroy(), KSPReset(), KSPConvergedReasonViewSet()

External Links

source
PETSc.LibPETSc.KSPConvergedReasonViewSetMethod
KSPConvergedReasonViewSet(petsclib::PetscLibType,ksp::PetscKSP, f::KSPConvergedReasonViewFn, vctx::Cvoid, reasonviewdestroy::PetscCtxDestroyFn)

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

Logically Collective

Input Parameters:

  • ksp - the KSP context
  • f - the ksp converged reason view function, see KSPConvergedReasonViewFn
  • vctx - [optional] user-defined context for private data for the

KSPConvergedReason view routine (use NULL if no context is desired)

  • reasonviewdestroy - [optional] routine that frees vctx (may be NULL), see PetscCtxDestroyFn for the calling sequence

Options Database Keys:

  • -ksp_converged_reason - sets a default KSPConvergedReasonView()
  • -ksp_converged_reason_view_cancel - cancels all converged reason viewers that have been hardwired into a code by

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

Level: intermediate

-seealso: , KSPConvergedReasonView(), KSPConvergedReasonViewFn, KSPConvergedReasonViewCancel(), PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.KSPConvergedSkipMethod
KSPConvergedSkip(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, reason::KSPConvergedReason, dtx::Cvoid)

Convergence test that do not return as converged until the maximum number of iterations is reached.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm residual value (may be estimated)
  • dtx - unused convergence context

Output Parameter:

  • reason - KSP_CONVERGED_ITERATING or KSP_CONVERGED_ITS

Options Database Key:

  • -ksp_convergence_test skip - skips the test

Level: advanced

-seealso: , KSP, KSPCG, KSPBCGS, KSPConvergenceTestFn, KSPSetConvergenceTest(), KSPSetTolerances(), KSPSetNormType(), , KSPConvergedReason

External Links

source
PETSc.LibPETSc.KSPCreateMethod
inksp::PetscKSP = KSPCreate(petsclib::PetscLibType,comm::MPI_Comm)

Creates the KSP context. This KSP context is used in PETSc to solve linear systems with KSPSolve()

Collective

Input Parameter:

  • comm - MPI communicator

Output Parameter:

  • inksp - location to put the KSP context

Level: beginner

-seealso: , KSPSetUp(), KSPSolve(), KSPDestroy(), KSP, KSPGMRES, KSPType, KSPSetType()

External Links

source
PETSc.LibPETSc.KSPCreateVecsMethod
right::Vector{PetscVec},left::Vector{PetscVec} = KSPCreateVecs(petsclib::PetscLibType,ksp::PetscKSP, rightn::PetscInt, leftn::PetscInt)

Gets a number of work vectors suitably sized for the operator in the KSP

Collective

Input Parameters:

  • ksp - iterative context
  • rightn - number of right work vectors to allocate
  • leftn - number of left work vectors to allocate

Output Parameters:

  • right - the array of vectors created
  • left - the array of left vectors

Level: advanced

-seealso: , MatCreateVecs(), VecDestroyVecs(), KSPSetWorkVecs()

External Links

source
PETSc.LibPETSc.KSPDestroyMethod
KSPDestroy(petsclib::PetscLibType,ksp::PetscKSP)

Destroys a KSP context.

Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Level: beginner

-seealso: , KSPCreate(), KSPSetUp(), KSPSolve(), KSP

External Links

source
PETSc.LibPETSc.KSPFCGGetMmaxMethod
mmax::PetscInt = KSPFCGGetMmax(petsclib::PetscLibType,ksp::PetscKSP)

get the maximum number of previous directions KSPFCG will store

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • mmax - the maximum number of previous directions allowed for orthogonalization

Level: intermediate

-seealso: , KSPFCG, KSPFCGGetTruncationType(), KSPFCGGetNprealloc(), KSPFCGSetMmax()

External Links

source
PETSc.LibPETSc.KSPFCGGetNpreallocMethod
nprealloc::PetscInt = KSPFCGGetNprealloc(petsclib::PetscLibType,ksp::PetscKSP)

get the number of directions preallocate by KSPFCG

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • nprealloc - the number of directions preallocated

Level: advanced

-seealso: , KSPFCG, KSPFCGGetTruncationType(), KSPFCGSetNprealloc(), KSPFCGSetMmax(), KSPFCGGetMmax()

External Links

source
PETSc.LibPETSc.KSPFCGGetTruncationTypeMethod
truncstrat::KSPFCDTruncationType = KSPFCGGetTruncationType(petsclib::PetscLibType,ksp::PetscKSP)

get the truncation strategy employed by KSPFCG

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • truncstrat - the strategy type

Level: intermediate

-seealso: , KSPFCG, KSPFCGSetTruncationType(), KSPFCDTruncationType, KSP_FCD_TRUNC_TYPE_STANDARD, KSP_FCD_TRUNC_TYPE_NOTAY

External Links

source
PETSc.LibPETSc.KSPFCGSetMmaxMethod
KSPFCGSetMmax(petsclib::PetscLibType,ksp::PetscKSP, mmax::PetscInt)

set the maximum number of previous directions KSPFCG will store for orthogonalization

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • mmax - the maximum number of previous directions to orthogonalize against

Options Database Key:

  • -ksp_fcg_mmax <N> - maximum number of search directions

Level: intermediate

-seealso: , KSPFCG, KSPFCGGetTruncationType(), KSPFCGGetNprealloc(), KSPFCGetMmax()

External Links

source
PETSc.LibPETSc.KSPFCGSetNpreallocMethod
KSPFCGSetNprealloc(petsclib::PetscLibType,ksp::PetscKSP, nprealloc::PetscInt)

set the number of directions to preallocate with KSPFCG

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • nprealloc - the number of vectors to preallocate

Options Database Key:

  • -ksp_fcg_nprealloc <N> - number of directions to preallocate

Level: advanced

-seealso: , KSPFCG, KSPFCGGetTruncationType(), KSPFCGGetNprealloc(), KSPFCGSetMmax(), KSPFCGGetMmax()

External Links

source
PETSc.LibPETSc.KSPFCGSetTruncationTypeMethod
KSPFCGSetTruncationType(petsclib::PetscLibType,ksp::PetscKSP, truncstrat::KSPFCDTruncationType)

specify how many of its stored previous directions KSPFCG uses during orthoganalization

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • truncstrat - the choice of strategy

-seealso: , KSPFCDTruncationType, KSPFCGGetTruncationType(), KSPFCGSetNprealloc(), KSPFCGSetMmax(), KSPFCGGetMmax(), KSP_FCD_TRUNC_TYPE_STANDARD, KSP_FCD_TRUNC_TYPE_NOTAY

External Links

source
PETSc.LibPETSc.KSPFETIDPGetInnerBDDCMethod
KSPFETIDPGetInnerBDDC(petsclib::PetscLibType,ksp::PetscKSP, pc::PC)

Gets the PCBDDC preconditioner used to set up the KSPFETIDP matrix for the Lagrange multipliers

Input Parameter:

  • ksp - the KSPFETIDP Krylov solver

Output Parameter:

  • pc - the PCBDDC preconditioner

Level: advanced

-seealso: , MATIS, PCBDDC, KSPFETIDP, KSPFETIDPSetInnerBDDC(), KSPFETIDPGetInnerKSP()

External Links

source
PETSc.LibPETSc.KSPFETIDPGetInnerKSPMethod
KSPFETIDPGetInnerKSP(petsclib::PetscLibType,ksp::PetscKSP, innerksp::PetscKSP)

Gets the KSP object for the Lagrange multipliers from inside a KSPFETIDP

Input Parameter:

  • ksp - the KSPFETIDP

Output Parameter:

  • innerksp - the KSP for the multipliers

Level: advanced

-seealso: , KSPFETIDP, MATIS, PCBDDC, KSPFETIDPSetInnerBDDC(), KSPFETIDPGetInnerBDDC()

External Links

source
PETSc.LibPETSc.KSPFETIDPSetInnerBDDCMethod
KSPFETIDPSetInnerBDDC(petsclib::PetscLibType,ksp::PetscKSP, pc::PC)

Provides the PCBDDC preconditioner used to set up the KSPFETIDP matrix for the Lagrange multipliers

Collective

Input Parameters:

  • ksp - the KSPFETIDP Krylov solver
  • pc - the PCBDDC preconditioner

Level: advanced

-seealso: , MATIS, PCBDDC, KSPFETIDPGetInnerBDDC(), KSPFETIDPGetInnerKSP()

External Links

source
PETSc.LibPETSc.KSPFETIDPSetPressureOperatorMethod
KSPFETIDPSetPressureOperator(petsclib::PetscLibType,ksp::PetscKSP, P::PetscMat)

Sets the operator used to set up the pressure preconditioner for the saddle point KSPFETIDP solver,

Collective

Input Parameters:

  • ksp - the KSPFETIDP solver
  • P - the linear operator to be preconditioned, usually the mass matrix.

Level: advanced

-seealso: , KSPFETIDP, MATIS, PCBDDC, KSPFETIDPGetInnerBDDC(), KSPFETIDPGetInnerKSP(), KSPSetOperators()

External Links

source
PETSc.LibPETSc.KSPFGMRESModifyPCKSPMethod
KSPFGMRESModifyPCKSP(petsclib::PetscLibType,ksp::PetscKSP, total_its::PetscInt, loc_its::PetscInt, res_norm::PetscReal, ctx::Cvoid)

modifies the attributes of the KSPFGMRES preconditioner, see .

Input Parameters:

  • ksp - the ksp context being used.
  • total_its - the total number of KSPFGMRES iterations that have occurred.
  • loc_its - the number of KSPFGMRES iterations since last restart.
  • res_norm - the current residual norm.
  • ctx - context, not used in this routine

Level: intermediate

-seealso: , , KSPFGMRES, KSPFlexibleModifyPCFn, KSPFGMRESSetModifyPC()

External Links

source
PETSc.LibPETSc.KSPFGMRESModifyPCNoChangeMethod
KSPFGMRESModifyPCNoChange(petsclib::PetscLibType,ksp::PetscKSP, total_its::PetscInt, loc_its::PetscInt, res_norm::PetscReal, ctx::Cvoid)

this is the default used by KSPFMGMRES

Input Parameters:

  • ksp - the ksp context being used.
  • total_its - the total number of KSPFGMRES iterations that have occurred.
  • loc_its - the number of KSPFGMRES iterations since last restart.
  • res_norm - the current residual norm.
  • ctx - context variable, unused in this routine

Level: intermediate

-seealso: , , KSPFGMRES, KSPFlexibleModifyPCFn, KSPFGMRESSetModifyPC(), KSPFGMRESModifyPCKSP()

External Links

source
PETSc.LibPETSc.KSPFGMRESSetModifyPCMethod
KSPFGMRESSetModifyPC(petsclib::PetscLibType,ksp::PetscKSP, fcn::KSPFlexibleModifyPCFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Sets the routine used by KSPFGMRES to modify the preconditioner.

Logically Collective

Input Parameters:

  • ksp - iterative context obtained from KSPCreate()
  • fcn - function to modify the PC, see KSPFlexibleModifyPCFn
  • ctx - optional context
  • destroy - optional context destroy routine

Options Database Keys:

  • -ksp_fgmres_modifypcnochange - do not change the PC
  • -ksp_fgmres_modifypcksp - changes the inner KSP solver tolerances

Level: intermediate

-seealso: , , KSPFGMRES, KSPFlexibleModifyPCFn, KSPFlexibleSetModifyPC(), KSPFGMRESModifyPCNoChange(), KSPFGMRESModifyPCKSP()

External Links

source
PETSc.LibPETSc.KSPFlexibleSetModifyPCMethod
KSPFlexibleSetModifyPC(petsclib::PetscLibType,ksp::PetscKSP, fcn::KSPFlexibleModifyPCFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Sets the routine used by flexible KSP methods to modify the preconditioner.

Logically Collective

Input Parameters:

  • ksp - iterative context obtained from KSPCreate()
  • fcn - function to modify the PC, see KSPFlexibleModifyPCFn
  • ctx - optional context
  • destroy - optional context destroy routine

Level: intermediate

-seealso: , , KSPFGMRES, KSPFGMRESModifyPCNoChange(), KSPFGMRESModifyPCKSP()

External Links

source
PETSc.LibPETSc.KSPGCRGetRestartMethod
restart::PetscInt = KSPGCRGetRestart(petsclib::PetscLibType,ksp::PetscKSP)

Gets number of iterations at which KSPGCR restarts.

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • restart - integer restart value

Level: intermediate

-seealso: , KSPGCR, KSPSetTolerances(), KSPGCRSetRestart(), KSPGMRESGetRestart()

External Links

source
PETSc.LibPETSc.KSPGCRSetModifyPCMethod
KSPGCRSetModifyPC(petsclib::PetscLibType,ksp::PetscKSP, fnc::KSPFlexibleModifyPCFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Sets the routine used by KSPGCR to modify the preconditioner for each iteration

Logically Collective

Input Parameters:

  • ksp - iterative context obtained from KSPCreate()
  • function - user defined function to modify the preconditioner, see KSPFlexibleModifyPCFn
  • ctx - user provided context for the modify preconditioner function
  • destroy - the function to use to destroy the user provided application context.

Level: intermediate

-seealso: , KSP, KSPGCR, KSPFlexibleModifyPCFn, KSPFGMRESModifyPCFn,

External Links

source
PETSc.LibPETSc.KSPGCRSetRestartMethod
KSPGCRSetRestart(petsclib::PetscLibType,ksp::PetscKSP, restart::PetscInt)

Sets number of iterations at which KSPGCR restarts.

Not Collective

Input Parameters:

  • ksp - the Krylov space context
  • restart - integer restart value

Options Database Key:

  • -ksp_gcr_restart <restart> - the number of stored vectors to orthogonalize against

Level: intermediate

-seealso: , KSPGCR, KSPSetTolerances(), KSPGCRGetRestart(), KSPGMRESSetRestart()

External Links

source
PETSc.LibPETSc.KSPGLTRGetLambdaMethod
lambda::PetscReal = KSPGLTRGetLambda(petsclib::PetscLibType,ksp::PetscKSP)

Get the multiplier on the trust

Not Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • lambda - the multiplier

Level: advanced

-seealso: , KSP, KSPGLTR, KSPGLTRGetMinEig()

External Links

source
PETSc.LibPETSc.KSPGLTRGetMinEigMethod
e_min::PetscReal = KSPGLTRGetMinEig(petsclib::PetscLibType,ksp::PetscKSP)

Get minimum eigenvalue computed by KSPGLTR

Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • e_min - the minimum eigenvalue

Level: advanced

-seealso: , KSP, KSPGLTR, KSPGLTRGetLambda()

External Links

source
PETSc.LibPETSc.KSPGMRESClassicalGramSchmidtOrthogonalizationMethod
KSPGMRESClassicalGramSchmidtOrthogonalization(petsclib::PetscLibType,ksp::PetscKSP, it::PetscInt)

This is the basic orthogonalization routine using classical Gram-Schmidt with possible iterative refinement to improve the stability

Collective, No Fortran Support

Input Parameters:

  • ksp - KSP object, must be associated with KSPGMRES, KSPFGMRES, or KSPLGMRES Krylov method
  • it - one less than the current GMRES restart iteration, i.e. the size of the Krylov space

Options Database Keys:

  • -ksp_gmres_classicalgramschmidt - Activates KSPGMRESClassicalGramSchmidtOrthogonalization()
  • -ksp_gmres_cgs_refinement_type <refine_never,refine_ifneeded,refine_always> - determine if iterative refinement is

used to increase the stability of the classical Gram-Schmidt orthogonalization.

Level: intermediate

-seealso: , KSPGMRESCGSRefinementType, KSPGMRESSetOrthogonalization(), KSPGMRESSetCGSRefinementType(), KSPGMRESGetCGSRefinementType(), KSPGMRESGetOrthogonalization(), KSPGMRESModifiedGramSchmidtOrthogonalization()

External Links

source
PETSc.LibPETSc.KSPGMRESGetCGSRefinementTypeMethod
type::KSPGMRESCGSRefinementType = KSPGMRESGetCGSRefinementType(petsclib::PetscLibType,ksp::PetscKSP)

Gets the type of iterative refinement to use in the classical Gram-Schmidt orthogonalization used by KSPGMRES and other PETSc GMRES implementations.

Not Collective

Input Parameter:

  • ksp - the Krylov space solver context

Output Parameter:

  • type - the type of refinement

Level: intermediate

-seealso: , KSPGMRES, KSPGMRESSetOrthogonalization(), KSPGMRESCGSRefinementType, KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESSetCGSRefinementType(), KSPGMRESGetOrthogonalization()

External Links

source
PETSc.LibPETSc.KSPGMRESGetRestartMethod
restart::PetscInt = KSPGMRESGetRestart(petsclib::PetscLibType,ksp::PetscKSP)

Gets number of iterations at which GMRES (KSPGMRES, KSPFGMRES, KSPPGMRES, KSPAGMRES, KSPDGMRES, KSPPIPEFGMRES, and KSPLGMRES) restarts.

Not Collective

Input Parameter:

  • ksp - the Krylov space solver context

Output Parameter:

  • restart - integer restart value

Level: intermediate

-seealso: , KSPGMRES, KSPSetTolerances(), KSPGMRESSetOrthogonalization(), KSPGMRESSetPreAllocateVectors(), KSPGMRESSetRestart(), KSPFGMRES, KSPLGMRES, KSPPGMRES, KSPAGMRES, KSPDGMRES, KSPPIPEFGMRES

External Links

source
PETSc.LibPETSc.KSPGMRESModifiedGramSchmidtOrthogonalizationMethod
KSPGMRESModifiedGramSchmidtOrthogonalization(petsclib::PetscLibType,ksp::PetscKSP, it::PetscInt)

This is the basic orthogonalization routine using modified Gram-Schmidt.

Collective, No Fortran Support

Input Parameters:

  • ksp - KSP object, must be associated with KSPGMRES, KSPFGMRES, or KSPLGMRES Krylov method
  • it - one less than the current GMRES restart iteration, i.e. the size of the Krylov space

Options Database Key:

  • -ksp_gmres_modifiedgramschmidt - Activates KSPGMRESModifiedGramSchmidtOrthogonalization()

Level: intermediate

-seealso: , KSPGMRESSetOrthogonalization(), KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESGetOrthogonalization()

External Links

source
PETSc.LibPETSc.KSPGMRESMonitorKrylovMethod
KSPGMRESMonitorKrylov(petsclib::PetscLibType,ksp::PetscKSP, its::PetscInt, fgnorm::PetscReal, dummy::Cvoid)

Calls VecView() to monitor each new direction in the KSPGMRES accumulated Krylov space.

Collective

Input Parameters:

  • ksp - the KSP context
  • its - iteration number
  • fgnorm - 2-norm of residual (or gradient)
  • dummy - a collection of viewers created with PetscViewersCreate()

Options Database Key:

  • -ksp_gmres_krylov_monitor <bool> - Plot the Krylov directions

Level: intermediate

-seealso: , KSPGMRES, KSPMonitorSet(), KSPMonitorResidual(), VecView(), PetscViewersCreate(), PetscViewersDestroy()

External Links

source
PETSc.LibPETSc.KSPGMRESSetBreakdownToleranceMethod
KSPGMRESSetBreakdownTolerance(petsclib::PetscLibType,ksp::PetscKSP, tol::PetscReal)

Sets the tolerance for determining divergence breakdown in KSPGMRES at restart.

Logically Collective

Input Parameters:

  • ksp - the Krylov space solver context
  • tol - the tolerance

Options Database Key:

  • -ksp_gmres_breakdown_tolerance <positive real value> - set tolerance for determining divergence breakdown

Level: intermediate

-seealso: , KSPGMRES, KSPSetTolerances(), KSPGMRESSetHapTol(), KSPConvergedReason

External Links

source
PETSc.LibPETSc.KSPGMRESSetCGSRefinementTypeMethod
KSPGMRESSetCGSRefinementType(petsclib::PetscLibType,ksp::PetscKSP, type::KSPGMRESCGSRefinementType)

Sets the type of iterative refinement to use in the classical Gram-Schmidt orthogonalization used by KSPGMRES and other PETSc GMRES implementations.

Logically Collective

Input Parameters:

  • ksp - the Krylov space solver context
  • type - the type of refinement

-seealso: , KSPGMRES, KSPGMRESSetOrthogonalization(), KSPGMRESCGSRefinementType, KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESGetCGSRefinementType(), KSPGMRESGetOrthogonalization()

External Links

source
PETSc.LibPETSc.KSPGMRESSetHapTolMethod
KSPGMRESSetHapTol(petsclib::PetscLibType,ksp::PetscKSP, tol::PetscReal)

Sets the tolerance for detecting a happy ending in GMRES (KSPGMRES, KSPFGMRES and KSPLGMRES and others)

Logically Collective

Input Parameters:

  • ksp - the Krylov space solver context
  • tol - the tolerance for detecting a happy ending

Options Database Key:

  • -ksp_gmres_haptol <positive real value> - set tolerance for determining happy breakdown

Level: intermediate

-seealso: , KSPGMRES, KSPSetTolerances()

External Links

source
PETSc.LibPETSc.KSPGMRESSetOrthogonalizationMethod
KSPGMRESSetOrthogonalization(petsclib::PetscLibType,ksp::PetscKSP, fcn::external)

Sets the orthogonalization routine used by KSPGMRES and KSPFGMRES.

Logically Collective

Input Parameters:

  • ksp - iterative context obtained from KSPCreate()
  • fcn - orthogonalization function

Calling sequence of fcn:

  • ksp - the solver context
  • it - the current iteration

Options Database Keys:

  • -ksp_gmres_classicalgramschmidt - Activates KSPGMRESClassicalGramSchmidtOrthogonalization() (default)
  • -ksp_gmres_modifiedgramschmidt - Activates KSPGMRESModifiedGramSchmidtOrthogonalization()

Level: intermediate

-seealso: , KSPGMRESSetRestart(), KSPGMRESSetPreAllocateVectors(), KSPGMRESSetCGSRefinementType(), KSPGMRESModifiedGramSchmidtOrthogonalization(), KSPGMRESClassicalGramSchmidtOrthogonalization(), KSPGMRESGetCGSRefinementType()

External Links

source
PETSc.LibPETSc.KSPGMRESSetPreAllocateVectorsMethod
KSPGMRESSetPreAllocateVectors(petsclib::PetscLibType,ksp::PetscKSP)

Causes KSPGMRES and KSPFGMRES to preallocate all its needed work vectors at initial setup rather than the default, which is to allocate several at a time when needed.

Logically Collective

Input Parameter:

  • ksp - iterative context obtained from KSPCreate()

Options Database Key:

  • -ksp_gmres_preallocate - Activates KSPGmresSetPreAllocateVectors()

Level: intermediate

-seealso: , KSPGMRESSetRestart(), KSPGMRESSetOrthogonalization(), KSPGMRESGetOrthogonalization(), VecMDot(), VecMAXPY()

External Links

source
PETSc.LibPETSc.KSPGMRESSetRestartMethod
KSPGMRESSetRestart(petsclib::PetscLibType,ksp::PetscKSP, restart::PetscInt)

Sets number of iterations at which GMRES (KSPGMRES, KSPFGMRES, KSPPGMRES, KSPAGMRES, KSPDGMRES, KSPPIPEFGMRES, and KSPLGMRES) restarts.

Logically Collective

Input Parameters:

  • ksp - the Krylov space solver context
  • restart - integer restart value, this corresponds to the number of iterations of GMRES to perform before restarting

Options Database Key:

  • -ksp_gmres_restart <positive integer> - integer restart value

Level: intermediate

-seealso: , KSPGMRES, KSPSetTolerances(), KSPGMRESSetOrthogonalization(), KSPGMRESSetPreAllocateVectors(), KSPGMRESGetRestart(), KSPFGMRES, KSPLGMRES, KSPPGMRES, KSPAGMRES, KSPDGMRES, KSPPIPEFGMRES

External Links

source
PETSc.LibPETSc.KSPGetAndClearConvergenceTestMethod
KSPGetAndClearConvergenceTest(petsclib::PetscLibType,ksp::PetscKSP, converge::KSPConvergenceTestFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Gets the function to be used to determine convergence. Removes the current test without calling destroy on the test context

Logically Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameters:

  • converge - pointer to convergence test function, see KSPConvergenceTestFn
  • ctx - context for private data for the convergence routine
  • destroy - a routine for destroying the context

Level: advanced

-seealso: , KSP, KSPConvergedDefault(), KSPGetConvergenceContext(), KSPSetTolerances(), KSPSetConvergenceTest(), KSPGetConvergenceTest()

External Links

source
PETSc.LibPETSc.KSPGetComputeEigenvaluesMethod
flg::PetscBool = KSPGetComputeEigenvalues(petsclib::PetscLibType,ksp::PetscKSP)

Gets the flag indicating that the extreme eigenvalues values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • flg - PETSC_TRUE or PETSC_FALSE

Level: advanced

-seealso: , KSPComputeEigenvalues(), KSPComputeEigenvaluesExplicitly(), KSP, KSPSetComputeRitz()

External Links

source
PETSc.LibPETSc.KSPGetComputeSingularValuesMethod
flg::PetscBool = KSPGetComputeSingularValues(petsclib::PetscLibType,ksp::PetscKSP)

Gets the flag indicating whether the extreme singular values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • flg - PETSC_TRUE or PETSC_FALSE

Options Database Key:

  • -ksp_monitor_singular_value - Activates KSPSetComputeSingularValues()

Level: advanced

-seealso: , KSPComputeExtremeSingularValues(), KSPMonitorSingularValue(), KSP

External Links

source
PETSc.LibPETSc.KSPGetConvergedNegativeCurvatureMethod
flg::PetscBool = KSPGetConvergedNegativeCurvature(petsclib::PetscLibType,ksp::PetscKSP)

Get the flag to declare convergence if negative curvature is detected

Collective

Input Parameter:

  • ksp - iterative context

Output Parameter:

  • flg - the Boolean value

Level: advanced

-seealso: , KSP, KSPConvergedReason, KSPSetConvergedNegativeCurvature()

External Links

source
PETSc.LibPETSc.KSPGetConvergedReasonMethod
reason::KSPConvergedReason = KSPGetConvergedReason(petsclib::PetscLibType,ksp::PetscKSP)

Gets the reason the KSP iteration was stopped.

Not Collective

Input Parameter:

  • ksp - the KSP context

Output Parameter:

  • reason - negative value indicates diverged, positive value converged, see KSPConvergedReason for the possible values

Options Database Key:

  • -ksp_converged_reason - prints the reason to standard out when the solve ends

Level: intermediate

-seealso: , KSPConvergedReason, KSP, KSPSetConvergenceTest(), KSPConvergedDefault(), KSPSetTolerances(), KSPConvergedReasonView(), KSPGetConvergedReasonString()

External Links

source
PETSc.LibPETSc.KSPGetConvergedReasonStringMethod
KSPGetConvergedReasonString(petsclib::PetscLibType,ksp::PetscKSP, strreason::String)

Return a human readable string for a KSPConvergedReason

Not Collective

Input Parameter:

  • ksp - the KSP context

Output Parameter:

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

Level: beginner

-seealso: , KSP, KSPGetConvergedReason()

External Links

source
PETSc.LibPETSc.KSPGetConvergenceContextMethod
KSPGetConvergenceContext(petsclib::PetscLibType,ksp::PetscKSP, ctx::Cvoid)

Gets the convergence context set with KSPSetConvergenceTest().

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • ctx - monitoring context

Level: advanced

-seealso: , KSP, KSPConvergedDefault(), KSPSetConvergenceTest(), KSPGetConvergenceTest()

External Links

source
PETSc.LibPETSc.KSPGetConvergenceTestMethod
KSPGetConvergenceTest(petsclib::PetscLibType,ksp::PetscKSP, converge::KSPConvergenceTestFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Gets the function to be used to determine convergence.

Logically Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameters:

  • converge - pointer to convergence test function, see KSPConvergenceTestFn
  • ctx - context for private data for the convergence routine (may be NULL)
  • destroy - a routine for destroying the context (may be NULL)

Level: advanced

-seealso: , KSP, KSPConvergedDefault(), KSPGetConvergenceContext(), KSPSetTolerances(), KSPSetConvergenceTest(), KSPGetAndClearConvergenceTest()

External Links

source
PETSc.LibPETSc.KSPGetDMMethod
dm::PetscDM = KSPGetDM(petsclib::PetscLibType,ksp::PetscKSP)

Gets the DM that may be used by some preconditioners and that may be used to construct the linear system

Not Collective

Input Parameter:

  • ksp - the KSP

Output Parameter:

  • dm - the DM

Level: intermediate

-seealso: , KSP, DM, KSPSetDM(), KSPSetDMActive()

External Links

source
PETSc.LibPETSc.KSPGetDiagonalScaleMethod
scale::PetscBool = KSPGetDiagonalScale(petsclib::PetscLibType,ksp::PetscKSP)

Checks if KSP solver scales the matrix and right

Not Collective

Input Parameter:

  • ksp - the KSP context

Output Parameter:

  • scale - PETSC_TRUE or PETSC_FALSE

Level: intermediate

-seealso: , KSP, KSPSetDiagonalScale(), KSPSetDiagonalScaleFix()

External Links

source
PETSc.LibPETSc.KSPGetDiagonalScaleFixMethod
fix::PetscBool = KSPGetDiagonalScaleFix(petsclib::PetscLibType,ksp::PetscKSP)

Determines if KSP diagonally scales the system back after solving. That is KSPSetDiagonalScaleFix() has been called

Not Collective

Input Parameter:

  • ksp - the KSP context

Output Parameter:

  • fix - PETSC_TRUE to scale back after the system solve, PETSC_FALSE to not

rescale (default)

Level: intermediate

-seealso: , KSPGetDiagonalScale(), KSPSetDiagonalScale(), KSPSetDiagonalScaleFix(), KSP

External Links

source
PETSc.LibPETSc.KSPGetErrorHistoryMethod
a::Vector{PetscReal},na::PetscInt = KSPGetErrorHistory(petsclib::PetscLibType,ksp::PetscKSP)

Gets the array used to hold the error history and the number of residuals it contains.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameters:

  • a - pointer to array to hold history (or NULL)
  • na - number of used entries in a (or NULL)

Level: advanced

-seealso: , KSPSetErrorHistory(), KSPGetResidualHistory(), KSP

External Links

source
PETSc.LibPETSc.KSPGetErrorIfNotConvergedMethod
flag::PetscBool = KSPGetErrorIfNotConverged(petsclib::PetscLibType,ksp::PetscKSP)

Will KSPSolve() generate an error if the solver does not converge?

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

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

Level: intermediate

-seealso: , KSPSetErrorIfNotConverged(), KSP

External Links

source
PETSc.LibPETSc.KSPGetGuessMethod
KSPGetGuess(petsclib::PetscLibType,ksp::PetscKSP, guess::KSPGuess)

Gets the initial guess generator for the KSP.

Not Collective

Input Parameter:

  • ksp - the Krylov context

Output Parameter:

  • guess - the object

Level: developer

-seealso: , KSPGuess, KSP, KSPSetOptionsPrefix(), KSPAppendOptionsPrefix(), KSPSetUseFischerGuess(), KSPSetGuess()

External Links

source
PETSc.LibPETSc.KSPGetInitialGuessKnollMethod
flag::PetscBool = KSPGetInitialGuessKnoll(petsclib::PetscLibType,ksp::PetscKSP)

Determines whether the KSP solver is using the Knoll trick (using PCApply(pc,b,...) to compute the initial guess

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • flag - PETSC_TRUE if using Knoll trick, else PETSC_FALSE

Level: advanced

-seealso: , KSPSetInitialGuessKnoll(), KSPSetInitialGuessNonzero(), KSPGetInitialGuessNonzero(), KSP

External Links

source
PETSc.LibPETSc.KSPGetInitialGuessNonzeroMethod
flag::PetscBool = KSPGetInitialGuessNonzero(petsclib::PetscLibType,ksp::PetscKSP)

Determines whether the KSP solver is using a zero initial guess.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • flag - PETSC_TRUE if guess is nonzero, else PETSC_FALSE

Level: intermediate

-seealso: , KSPSetInitialGuessNonzero(), KSP

External Links

source
PETSc.LibPETSc.KSPGetIterationNumberMethod
its::PetscInt = KSPGetIterationNumber(petsclib::PetscLibType,ksp::PetscKSP)

Gets the current iteration number; if the KSPSolve() is complete, returns the number of iterations used.

Not Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • its - number of iterations

Level: intermediate

-seealso: , KSP, KSPGetResidualNorm(), KSPBuildResidual(), KSPGetTotalIterations()

External Links

source
PETSc.LibPETSc.KSPGetMatSolveBatchSizeMethod
bs::PetscInt = KSPGetMatSolveBatchSize(petsclib::PetscLibType,ksp::PetscKSP)

Gets the maximum number of columns treated simultaneously in KSPMatSolve().

Input Parameter:

  • ksp - iterative solver context

Output Parameter:

  • bs - batch size

Level: advanced

-seealso: , KSPMatSolve(), KSPSetMatSolveBatchSize(), -mat_mumps_icntl_27, -matmatmult_Bbn

External Links

source
PETSc.LibPETSc.KSPGetMinimumIterationsMethod
minit::PetscInt = KSPGetMinimumIterations(petsclib::PetscLibType,ksp::PetscKSP)

Gets the minimum number of iterations to use, regardless of the tolerances, that was set with KSPSetMinimumIterations() or `

Not Collective

Input Parameter:

  • ksp - the Krylov subspace context

Output Parameter:

  • minit - minimum number of iterations to use

Level: intermediate

-seealso: , KSPGetTolerances(), KSPConvergedDefault(), KSPSetConvergenceTest(), KSP, KSPSetTolerances(), KSPSetMinimumIterations()

External Links

source
PETSc.LibPETSc.KSPGetMonitorContextMethod
KSPGetMonitorContext(petsclib::PetscLibType,ksp::PetscKSP, ctx::Cvoid)

Gets the monitoring context, as set by KSPMonitorSet() for the FIRST monitor only.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • ctx - monitoring context

Level: intermediate

-seealso: , KSPMonitorResidual(), KSP

External Links

source
PETSc.LibPETSc.KSPGetNestLevelMethod
level::PetscInt = KSPGetNestLevel(petsclib::PetscLibType,ksp::PetscKSP)

gets the amount of nesting the KSP has

Not Collective

Input Parameter:

  • ksp - the KSP

Output Parameter:

  • level - the nest level

Level: developer

-seealso: , KSPSetUp(), KSPSolve(), KSPDestroy(), KSP, KSPGMRES, KSPType, KSPSetNestLevel(), PCSetKSPNestLevel(), PCGetKSPNestLevel()

External Links

source
PETSc.LibPETSc.KSPGetNormTypeMethod
normtype::KSPNormType = KSPGetNormType(petsclib::PetscLibType,ksp::PetscKSP)

Gets the KSPNormType that is used for convergence testing during KSPSolve() for this KSP context

Not Collective

Input Parameter:

  • ksp - Krylov solver context

Output Parameter:

  • normtype - the KSPNormType that is used for convergence testing

Level: advanced

-seealso: , KSPNormType, KSPSetNormType(), KSPConvergedSkip()

External Links

source
PETSc.LibPETSc.KSPGetOperatorsMethod
Amat, PMat = KSPGetOperators(petsclib::PetscLibType,ksp::PetscKSP)

Gets the matrix associated with the linear system and a (possibly) different one used to construct the preconditioner from the KSP context

Collective

Input Parameter:

  • ksp - the KSP context

Output Parameters:

  • Amat - the matrix that defines the linear system
  • Pmat - the matrix to be used in constructing the preconditioner, usually the same as Amat.

Level: intermediate

-seealso: , KSP, KSPSolve(), KSPGetPC(), PCSetOperators(), KSPSetOperators(), KSPGetOperatorsSet()

External Links

source
PETSc.LibPETSc.KSPGetOperatorsSetMethod
mat::PetscBool,pmat::PetscBool = KSPGetOperatorsSet(petsclib::PetscLibType,ksp::PetscKSP)

Determines if the matrix associated with the linear system and possibly a different one from which the preconditioner will be built have been set in the KSP with KSPSetOperators()

Not Collective, though the results on all processes will be the same

Input Parameter:

  • ksp - the KSP context

Output Parameters:

  • mat - the matrix associated with the linear system was set
  • pmat - matrix from which the preconditioner will be built, usually the same as mat was set

Level: intermediate

-seealso: , KSP, PCSetOperators(), KSPGetOperators(), KSPSetOperators(), PCGetOperators(), PCGetOperatorsSet()

External Links

source
PETSc.LibPETSc.KSPGetOptionsPrefixMethod
prefix::String = KSPGetOptionsPrefix(petsclib::PetscLibType,ksp::PetscKSP)

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

Not Collective

Input Parameter:

  • ksp - the Krylov context

Output Parameter:

  • prefix - pointer to the prefix string used is returned

Level: advanced

-seealso: , KSP, KSPSetFromOptions(), KSPSetOptionsPrefix(), KSPAppendOptionsPrefix()

External Links

source
PETSc.LibPETSc.KSPGetPCMethod
KSPGetPC(petsclib::PetscLibType,ksp::PetscKSP, pc::PC)

Returns a pointer to the preconditioner context with the KSP

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • pc - preconditioner context

Level: beginner

-seealso: , KSPSetPC(), KSP, PC

External Links

source
PETSc.LibPETSc.KSPGetPCSideMethod
KSPGetPCSide(petsclib::PetscLibType,ksp::PetscKSP, side::PCSide)

Gets the preconditioning side.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

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

-seealso: , KSPSetPCSide(), KSP

External Links

source
PETSc.LibPETSc.KSPGetResidualHistoryMethod
a::Vector{PetscReal},na::PetscInt = KSPGetResidualHistory(petsclib::PetscLibType,ksp::PetscKSP)

Gets the array used to hold the residual history and the number of residuals it contains.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameters:

  • a - pointer to array to hold history (or NULL)
  • na - number of used entries in a (or NULL). Note this has different meanings depending on the reset argument to KSPSetResidualHistory()

Level: advanced

-seealso: , KSPSetResidualHistory(), KSP, KSPGetIterationNumber(), KSPSTCG, KSPBCGSL

External Links

source
PETSc.LibPETSc.KSPGetResidualNormMethod
rnorm::PetscReal = KSPGetResidualNorm(petsclib::PetscLibType,ksp::PetscKSP)

Gets the last (possibly approximate and/or preconditioned) residual norm that has been computed.

Not Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • rnorm - residual norm

Level: intermediate

-seealso: , KSP, KSPSetNormType(), KSPBuildResidual(), KSPNormType

External Links

source
PETSc.LibPETSc.KSPGetReusePreconditionerMethod
flag::PetscBool = KSPGetReusePreconditioner(petsclib::PetscLibType,ksp::PetscKSP)

Determines if the KSP reuses the current preconditioner even if the Mat operator in the KSP has changed.

Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • flag - the boolean flag indicating if the current preconditioner should be reused

Level: intermediate

-seealso: , KSPCreate(), KSPSolve(), KSPDestroy(), KSPSetReusePreconditioner(), KSP

External Links

source
PETSc.LibPETSc.KSPGetRhsMethod
r::PetscVec = KSPGetRhs(petsclib::PetscLibType,ksp::PetscKSP)

Gets the right be solved.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

  • r - right-hand-side vector

Level: developer

-seealso: , KSPGetSolution(), KSPSolve(), KSP

External Links

source
PETSc.LibPETSc.KSPGetSolutionMethod
v::PetscVec = KSPGetSolution(petsclib::PetscLibType,ksp::PetscKSP)

Gets the location of the solution for the linear system to be solved.

Not Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Return Value:

  • v - solution vector

Level: developer

-seealso: , KSPGetRhs(), KSPBuildSolution(), KSPSolve(), KSP

External Links

source
PETSc.LibPETSc.KSPGetTolerancesMethod
rtol::PetscReal,abstol::PetscReal,dtol::PetscReal,maxits::PetscInt = KSPGetTolerances(petsclib::PetscLibType,ksp::PetscKSP)

Gets the relative, absolute, divergence, and maximum iteration tolerances used by the default KSP convergence tests.

Not Collective

Input Parameter:

  • ksp - the Krylov subspace context

Output Parameters:

  • rtol - the relative convergence tolerance
  • abstol - the absolute convergence tolerance
  • dtol - the divergence tolerance
  • maxits - maximum number of iterations

Level: intermediate

-seealso: , KSPSetTolerances(), KSP, KSPSetMinimumIterations(), KSPGetMinimumIterations()

External Links

source
PETSc.LibPETSc.KSPGetTotalIterationsMethod
its::PetscInt = KSPGetTotalIterations(petsclib::PetscLibType,ksp::PetscKSP)

Gets the total number of iterations this KSP object has performed since was created, counted over all linear solves

Not Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • its - total number of iterations

Level: intermediate

-seealso: , KSP, KSPBuildResidual(), KSPGetResidualNorm(), KSPGetIterationNumber()

External Links

source
PETSc.LibPETSc.KSPGetTypeMethod
type::KSPType = KSPGetType(petsclib::PetscLibType,ksp::PetscKSP)

Gets the KSP type as a string from the KSP object.

Not Collective

Input Parameter:

  • ksp - Krylov context

Output Parameter:

  • type - name of the KSP method

Level: intermediate

-seealso: , KSPType, KSP, KSPSetType()

External Links

source
PETSc.LibPETSc.KSPInitialResidualMethod
KSPInitialResidual(petsclib::PetscLibType,ksp::PetscKSP, vsoln::PetscVec, vt1::PetscVec, vt2::PetscVec, vres::PetscVec, vb::PetscVec)

Computes the residual. Either b preconditioning or C(b - Ax) with left preconditioning; the latter residual is often called the "preconditioned residual".

Collective

Input Parameters:

  • ksp - the KSP solver object
  • vsoln - solution to use in computing residual
  • vt1 - temporary work vector
  • vt2 - temporary work vector
  • vb - right-hand-side vector

Output Parameter:

  • vres - calculated residual

Level: developer

-seealso: , KSP, KSPSolve(), KSPMonitor()

External Links

source
PETSc.LibPETSc.KSPInitializePackageMethod
KSPInitializePackage(petsclib::PetscLibType)

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

Level: developer

-seealso: , PetscInitialize(), KSPFinalizePackage()

External Links

source
PETSc.LibPETSc.KSPLGMRESSetAugDimMethod
KSPLGMRESSetAugDim(petsclib::PetscLibType,ksp::PetscKSP, dim::PetscInt)

Set the number of error approximations to include in the approximation space (default is 2) for KSPLGMRES

Collective

Input Parameters:

  • ksp - the KSP context
  • dim - the number of vectors to use

Options Database Key:

  • -ksp_lgmres_augment dim - the number of error approximations to include

Level: intermediate

-seealso: , KSPLGMRES, KSPLGMRESSetConstant()

External Links

source
PETSc.LibPETSc.KSPLGMRESSetConstantMethod
KSPLGMRESSetConstant(petsclib::PetscLibType,ksp::PetscKSP)

keep the error approximation space a constant size for every restart cycle

Collective

Input Parameters:

  • ksp - the KSP context

Options Database Key:

  • -ksp_lgmres_constant - set the size to be constant

Level: intermediate

-seealso: , KSPLGMRES, KSPLGMRESSetAugDim()

External Links

source
PETSc.LibPETSc.KSPLSQRConvergedDefaultMethod
KSPLSQRConvergedDefault(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, reason::KSPConvergedReason, ctx::Cvoid)

Determines convergence of the KSPLSQR Krylov method, including a check on the residual norm of the normal equations.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm residual value (may be estimated)
  • ctx - convergence context which must have been created by KSPConvergedDefaultCreate()

Output Parameter:

  • reason - the convergence reason

Level: advanced

-seealso: , KSPLSQR, KSPSetConvergenceTest(), KSPSetTolerances(), KSPConvergedSkip(), KSPConvergedReason, KSPGetConvergedReason(), KSPConvergedDefaultSetUIRNorm(), KSPConvergedDefaultSetUMIRNorm(), KSPConvergedDefaultCreate(), KSPConvergedDefaultDestroy(), KSPConvergedDefault(), KSPLSQRGetNorms(), KSPLSQRSetExactMatNorm()

External Links

source
PETSc.LibPETSc.KSPLSQRGetNormsMethod
arnorm::PetscReal,anorm::PetscReal = KSPLSQRGetNorms(petsclib::PetscLibType,ksp::PetscKSP)

Get the norm estimates that KSPLSQR computes internally during KSPSolve().

Not Collective

Input Parameter:

  • ksp - iterative context

Output Parameters:

  • arnorm - good estimate of (APmat^{-T})r, where r = A x - b, used in specific stopping criterion
  • anorm - poor estimate of A*Pmat^{-T}_{frobenius} used in specific stopping criterion

Level: intermediate

-seealso: , KSPSolve(), KSPLSQR, KSPLSQRSetExactMatNorm()

External Links

source
PETSc.LibPETSc.KSPLSQRGetStandardErrorVecMethod
KSPLSQRGetStandardErrorVec(petsclib::PetscLibType,ksp::PetscKSP, se::PetscVec)

Get vector of standard error estimates. Only available if -ksplsqrsetstandarderror was set to true or KSPLSQRSetComputeStandardErrorVec(ksp, PETSC_TRUE) was called. Otherwise returns NULL.

Not Collective

Input Parameter:

  • ksp - iterative context

Output Parameter:

  • se - vector of standard estimates

Level: intermediate

-seealso: , KSPSolve(), KSPLSQR, KSPLSQRSetComputeStandardErrorVec()

External Links

source
PETSc.LibPETSc.KSPLSQRMonitorResidualMethod
KSPLSQRMonitorResidual(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the residual norm, as well as the normal equation residual norm, at each iteration of an iterative solver for the KSPLSQR solver

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_lsqr_monitor - Activates KSPLSQRMonitorResidual()

Level: intermediate

-seealso: , KSPLSQR, KSPMonitorSet(), KSPMonitorResidual(), KSPMonitorTrueResidualMaxNorm(), KSPLSQRMonitorResidualDrawLG()

External Links

source
PETSc.LibPETSc.KSPLSQRMonitorResidualDrawLGMethod
KSPLSQRMonitorResidualDrawLG(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the true residual norm at each iteration of an iterative solver for the KSPLSQR solver

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_lsqr_monitor draw::draw_lg - Activates KSPMonitorTrueResidualDrawLG()

Level: intermediate

-seealso: , KSPLSQR, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPLSQRMonitorResidual(), KSPLSQRMonitorResidualDrawLGCreate()

External Links

source
PETSc.LibPETSc.KSPLSQRMonitorResidualDrawLGCreateMethod
vf::PetscViewerAndFormat = KSPLSQRMonitorResidualDrawLGCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the line graph object for the KSPLSQR residual and normal equation residual norm

Collective

Input Parameters:

  • viewer - The PetscViewer
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The PetscViewerAndFormat

Level: intermediate

-seealso: , KSPLSQR, KSPMonitorSet(), KSPLSQRMonitorResidual(), KSPLSQRMonitorResidualDrawLG()

External Links

source
PETSc.LibPETSc.KSPLSQRSetComputeStandardErrorVecMethod
KSPLSQRSetComputeStandardErrorVec(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Compute a vector of standard error estimates during KSPSolve() for KSPLSQR.

Logically Collective

Input Parameters:

  • ksp - iterative context
  • flg - compute the vector of standard estimates or not

Level: intermediate

-seealso: , KSPSolve(), KSPLSQR, KSPLSQRGetStandardErrorVec()

External Links

source
PETSc.LibPETSc.KSPLSQRSetExactMatNormMethod
KSPLSQRSetExactMatNorm(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Compute exact matrix norm instead of iteratively refined estimate.

Not Collective

Input Parameters:

  • ksp - iterative context
  • flg - compute exact matrix norm or not

Level: intermediate

-seealso: , KSPSolve(), KSPLSQR, KSPLSQRGetNorms(), KSPLSQRConvergedDefault()

External Links

source
PETSc.LibPETSc.KSPLoadMethod
KSPLoad(petsclib::PetscLibType,newdm::PetscKSP, viewer::PetscViewer)

Loads a KSP that has been stored in a PETSCVIEWERBINARY with KSPView().

Collective

Input Parameters:

  • newdm - the newly loaded KSP, this needs to have been created with KSPCreate() or

some related function before a call to KSPLoad().

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

Level: intermediate

-seealso: , KSP, PetscViewerBinaryOpen(), KSPView(), MatLoad(), VecLoad()

External Links

source
PETSc.LibPETSc.KSPMINRESGetUseQLPMethod
qlp::PetscBool = KSPMINRESGetUseQLP(petsclib::PetscLibType,ksp::PetscKSP)

Get the flag that indicates if the QLP variant is being used

Logically Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • qlp - a Boolean indicating if the QLP variant is used

Level: beginner

-seealso: , KSP, KSPMINRES, KSPMINRESSetUseQLP()

External Links

source
PETSc.LibPETSc.KSPMINRESSetRadiusMethod
KSPMINRESSetRadius(petsclib::PetscLibType,ksp::PetscKSP, radius::PetscReal)

Set the maximum solution norm allowed for use with trust region methods

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • radius - the value

Level: beginner

Options Database Key:

  • -ksp_minres_radius <real> - maximum allowed solution norm

-seealso: , KSP, KSPMINRES, KSPMINRESSetUseQLP()

External Links

source
PETSc.LibPETSc.KSPMINRESSetUseQLPMethod
KSPMINRESSetUseQLP(petsclib::PetscLibType,ksp::PetscKSP, qlp::PetscBool)

Use the QLP variant of KSPMINRES

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • qlp - a Boolean indicating if the QLP variant should be used

Level: beginner

-seealso: , KSP, KSPMINRES, KSPMINRESGetUseQLP()

External Links

source
PETSc.LibPETSc.KSPMatSolveMethod
KSPMatSolve(petsclib::PetscLibType,ksp::PetscKSP, B::PetscMat, X::PetscMat)

Solves a linear system with multiple right

Input Parameters:

  • ksp - iterative solver
  • B - block of right-hand sides

Output Parameter:

  • X - block of solutions

Level: intermediate

-seealso: , KSPSolve(), MatMatSolve(), KSPMatSolveTranspose(), MATDENSE, KSPHPDDM, PCBJACOBI, PCASM, KSPSetMatSolveBatchSize()

External Links

source
PETSc.LibPETSc.KSPMatSolveTransposeMethod
KSPMatSolveTranspose(petsclib::PetscLibType,ksp::PetscKSP, B::PetscMat, X::PetscMat)

Solves a linear system with the transposed matrix with multiple right

Input Parameters:

  • ksp - iterative solver
  • B - block of right-hand sides

Output Parameter:

  • X - block of solutions

Level: intermediate

-seealso: , KSPSolveTranspose(), MatMatTransposeSolve(), KSPMatSolve(), MATDENSE, KSPHPDDM, PCBJACOBI, PCASM

External Links

source
PETSc.LibPETSc.KSPMonitorMethod
KSPMonitor(petsclib::PetscLibType,ksp::PetscKSP, it::PetscInt, rnorm::PetscReal)

runs the user provided monitor routines, if they exist

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • it - iteration number
  • rnorm - relative norm of the residual

Level: developer

-seealso: , KSPMonitorSet()

External Links

source
PETSc.LibPETSc.KSPMonitorCancelMethod
KSPMonitorCancel(petsclib::PetscLibType,ksp::PetscKSP)

Clears all monitors for a KSP object.

Logically Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Options Database Key:

  • -ksp_monitor_cancel - Cancels all monitors that have been hardwired into a code by calls to KSPMonitorSet(), but does not cancel those set via the options database.

Level: intermediate

-seealso: , KSPMonitorResidual(), KSPMonitorSet(), KSP

External Links

source
PETSc.LibPETSc.KSPMonitorDynamicToleranceMethod
KSPMonitorDynamicTolerance(petsclib::PetscLibType,ksp::PetscKSP, its::PetscInt, fnorm::PetscReal, ctx::Cvoid)

A monitor that changes the inner tolerance of nested preconditioners in every outer iteration in an adaptive way.

Collective

Input Parameters:

  • ksp - iterative context
  • its - iteration number (not used)
  • fnorm - the current residual norm
  • ctx - context used by monitor

Options Database Key:

  • -sub_ksp_dynamic_tolerance <coef> - coefficient of dynamic tolerance for inner solver, default is 1.0

Level: advanced

-seealso: , KSP, KSPMonitorDynamicToleranceCreate(), KSPMonitorDynamicToleranceDestroy(), KSPMonitorDynamicToleranceSetCoefficient()

External Links

source
PETSc.LibPETSc.KSPMonitorDynamicToleranceCreateMethod
ctx::Cvoid = KSPMonitorDynamicToleranceCreate(petsclib::PetscLibType)

Creates the context used by KSPMonitorDynamicTolerance()

Logically Collective

Output Parameter:

  • ctx - a void pointer

Options Database Key:

  • -sub_ksp_dynamic_tolerance <coef> - coefficient of dynamic tolerance for inner solver, default is 1.0

Level: advanced

-seealso: , KSP, KSPMonitorDynamicTolerance(), KSPMonitorDynamicToleranceDestroy(), KSPMonitorDynamicToleranceSetCoefficient()

External Links

source
PETSc.LibPETSc.KSPMonitorDynamicToleranceSetCoefficientMethod
coeff::PetscReal = KSPMonitorDynamicToleranceSetCoefficient(petsclib::PetscLibType,ctx::Cvoid)

Sets the coefficient in the context used by KSPMonitorDynamicTolerance()

Logically Collective

Output Parameters:

  • ctx - the context for KSPMonitorDynamicTolerance()
  • coeff - the coefficient, default is 1.0

Options Database Key:

  • -sub_ksp_dynamic_tolerance <coef> - coefficient of dynamic tolerance for inner solver, default is 1.0

Level: advanced

-seealso: , KSP, KSPMonitorDynamicTolerance(), KSPMonitorDynamicToleranceDestroy(), KSPMonitorDynamicToleranceCreate()

External Links

source
PETSc.LibPETSc.KSPMonitorErrorMethod
KSPMonitorError(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the error norm, as well as the (possibly preconditioned) residual norm, at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_error - Activates KSPMonitorError()

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorResidual(), KSPMonitorTrueResidualMaxNorm()

External Links

source
PETSc.LibPETSc.KSPMonitorErrorDrawMethod
KSPMonitorErrorDraw(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the error at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_error draw - Activates KSPMonitorErrorDraw()

Level: intermediate

-seealso: , PETSCVIEWERDRAW, KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorErrorDrawLG()

External Links

source
PETSc.LibPETSc.KSPMonitorErrorDrawLGMethod
KSPMonitorErrorDrawLG(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the error and residual norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_error draw::draw_lg - Activates KSPMonitorTrueResidualDrawLG()

Level: intermediate

-seealso: , PETSCVIEWERDRAW, KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorErrorDraw()

External Links

source
PETSc.LibPETSc.KSPMonitorErrorDrawLGCreateMethod
vf::PetscViewerAndFormat = KSPMonitorErrorDrawLGCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the context for the error and preconditioned residual plotter KSPMonitorErrorDrawLG()

Collective

Input Parameters:

  • viewer - The PetscViewer
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The viewer context

Level: intermediate

-seealso: , PETSCVIEWERDRAW, KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorErrorDrawLG()

External Links

source
PETSc.LibPETSc.KSPMonitorRegisterMethod
KSPMonitorRegister(petsclib::PetscLibType,name::String, vtype::PetscViewerType, format::PetscViewerFormat, monitor::KSPMonitorRegisterFn, create::KSPMonitorRegisterCreateFn, destroy::KSPMonitorRegisterDestroyFn)

Registers a Krylov subspace solver monitor routine that may be accessed with KSPMonitorSetFromOptions()

Not Collective

Input Parameters:

  • name - name of a new monitor type
  • vtype - A PetscViewerType for the output
  • format - A PetscViewerFormat for the output
  • monitor - Monitor routine, see KSPMonitorRegisterFn
  • create - Creation routine, or NULL
  • destroy - Destruction routine, or NULL

Level: advanced

-seealso: , KSP, KSPMonitorSet(), KSPMonitorRegisterAll(), KSPMonitorSetFromOptions()

External Links

source
PETSc.LibPETSc.KSPMonitorResidualMethod
KSPMonitorResidual(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Print the (possibly preconditioned, possibly approximate) residual norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - (preconditioned) residual norm value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor - Activates KSPMonitorResidual() to print the norm value at each iteration

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorResidualView(), KSPMonitorResidualDrawLG(), KSPMonitorResidualRange(), KSPMonitorTrueResidualDraw(), KSPMonitorTrueResidualDrawLG(), KSPMonitorTrueResidualMax(), KSPMonitorSingularValue(), KSPMonitorSolutionDrawLG(), KSPMonitorSolutionDraw(), KSPMonitorSolution(), KSPMonitorErrorDrawLG(), KSPMonitorErrorDraw(), KSPMonitorError()

External Links

source
PETSc.LibPETSc.KSPMonitorResidualDrawLGMethod
KSPMonitorResidualDrawLG(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the (possibly preconditioned) residual norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor draw::draw_lg - Activates KSPMonitorResidualDrawLG()

Level: intermediate

-seealso: , KSP, PETSCVIEWERDRAW, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorResidualView(), KSPMonitorResidual()

External Links

source
PETSc.LibPETSc.KSPMonitorResidualDrawLGCreateMethod
vf::PetscViewerAndFormat = KSPMonitorResidualDrawLGCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the context for the (possibly preconditioned) residual norm monitor KSPMonitorResidualDrawLG()

Collective

Input Parameters:

  • viewer - The PetscViewer of type PETSCVIEWERDRAW
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The viewer context

Level: intermediate

-seealso: , KSP, PETSCVIEWERDRAW, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorResidualDrawLG(), PetscViewerFormat, PetscViewer, PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.KSPMonitorResidualRangeMethod
KSPMonitorResidualRange(petsclib::PetscLibType,ksp::PetscKSP, it::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the percentage of residual elements that are more than 10 percent of the maximum value.

Collective

Input Parameters:

  • ksp - iterative context
  • it - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_range - Activates KSPMonitorResidualRange()

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorResidual()

External Links

source
PETSc.LibPETSc.KSPMonitorResidualViewMethod
KSPMonitorResidualView(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the (possibly preconditioned) residual at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor viewertype - Activates KSPMonitorResidualView()

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorResidual(), KSPMonitorResidualDrawLG()

External Links

source
PETSc.LibPETSc.KSPMonitorSAWsMethod
KSPMonitorSAWs(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, ctx::Cvoid)

monitor KSP solution using SAWs

Logically Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • ctx - created with KSPMonitorSAWsCreate()

Level: advanced

-seealso: , KSP, KSPMonitorSet(), KSPMonitorSAWsCreate(), KSPMonitorSAWsDestroy(), KSPMonitorSingularValue(), KSPComputeExtremeSingularValues(), PetscViewerSAWsOpen()

External Links

source
PETSc.LibPETSc.KSPMonitorSAWsCreateMethod
ctx::Cvoid = KSPMonitorSAWsCreate(petsclib::PetscLibType,ksp::PetscKSP)

create an SAWs monitor context for KSP

Collective

Input Parameter:

  • ksp - KSP to monitor

Output Parameter:

  • ctx - context for monitor

Level: developer

-seealso: , KSP, KSPMonitorSet(), KSPMonitorSAWs(), KSPMonitorSAWsDestroy()

External Links

source
PETSc.LibPETSc.KSPMonitorSAWsDestroyMethod
KSPMonitorSAWsDestroy(petsclib::PetscLibType,ctx::Cvoid)

destroy a monitor context created with KSPMonitorSAWsCreate()

Collective

Input Parameter:

  • ctx - monitor context

Level: developer

-seealso: , KSP, KSPMonitorSet(), KSPMonitorSAWsCreate()

External Links

source
PETSc.LibPETSc.KSPMonitorSNESResidualMethod
KSPMonitorSNESResidual(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the SNES residual norm, as well as the KSP residual norm, at each iteration of a KSPSolve() called within a SNESSolve().

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -snes_monitor_ksp - Activates KSPMonitorSNESResidual()

Level: intermediate

-seealso: , SNES, KSPMonitorSet(), KSPMonitorResidual(), KSPMonitorTrueResidualMaxNorm(), KSPMonitor(), SNESMonitor(), PetscViewerAndFormat()

External Links

source
PETSc.LibPETSc.KSPMonitorSNESResidualDrawLGMethod
KSPMonitorSNESResidualDrawLG(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the linear KSP residual norm and the SNES residual norm of a KSPSolve() called within a SNESSolve().

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context, created with KSPMonitorSNESResidualDrawLGCreate()

Options Database Key:

  • -snes_monitor_ksp draw::draw_lg - Activates KSPMonitorSNESResidualDrawLG()

Level: intermediate

-seealso: , KSPMonitorSet(), KSPMonitorTrueResidual(), SNESMonitor(), KSPMonitor(), KSPMonitorSNESResidualDrawLGCreate()

External Links

source
PETSc.LibPETSc.KSPMonitorSNESResidualDrawLGCreateMethod
vf::PetscViewerAndFormat = KSPMonitorSNESResidualDrawLGCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the PetscViewer used by KSPMonitorSNESResidualDrawLG()

Collective

Input Parameters:

  • viewer - The PetscViewer
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The viewer context

Level: intermediate

-seealso: , KSP, SNES, PetscViewerFormat, PetscViewerAndFormat, KSPMonitorSet(), KSPMonitorTrueResidual()

External Links

source
PETSc.LibPETSc.KSPMonitorSetMethod
KSPMonitorSet(petsclib::PetscLibType,ksp::PetscKSP, monitor::KSPMonitorFn, ctx::Cvoid, monitordestroy::PetscCtxDestroyFn)

Sets an ADDITIONAL function to be called at every iteration to monitor, i.e. display in some way, perhaps by printing in the terminal, the residual norm computed in a KSPSolve()

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • monitor - pointer to function (if this is NULL, it turns off monitoring, see KSPMonitorFn
  • ctx - [optional] context for private data for the monitor routine (use NULL if no context is needed)
  • monitordestroy - [optional] routine that frees monitor context (may be NULL), see PetscCtxDestroyFn for the calling sequence

Options Database Keys:

  • -ksp_monitor - sets KSPMonitorResidual()
  • -ksp_monitor hdf5:filename - sets KSPMonitorResidualView() and saves residual
  • -ksp_monitor draw - sets KSPMonitorResidualView() and plots residual
  • -ksp_monitor draw::draw_lg - sets KSPMonitorResidualDrawLG() and plots residual
  • -ksp_monitor_pause_final - Pauses any graphics when the solve finishes (only works for internal monitors)
  • -ksp_monitor_true_residual - sets KSPMonitorTrueResidual()
  • -ksp_monitor_true_residual draw::draw_lg - sets KSPMonitorTrueResidualDrawLG() and plots residual
  • -ksp_monitor_max - sets KSPMonitorTrueResidualMax()
  • -ksp_monitor_singular_value - sets KSPMonitorSingularValue()
  • -ksp_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to KSPMonitorSet(), but

does not cancel those set via the options database.

Level: beginner

-seealso: , KSPMonitorResidual(), KSPMonitorRegister(), KSPMonitorCancel(), KSP, PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.KSPMonitorSetFromOptionsMethod
KSPMonitorSetFromOptions(petsclib::PetscLibType,ksp::PetscKSP, opt::String, name::String, ctx::Cvoid)

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

Collective

Input Parameters:

  • ksp - KSP object you wish to monitor
  • opt - the command line option for this monitor
  • name - the monitor type one is seeking
  • ctx - An optional user context for the monitor, or NULL

Level: developer

-seealso: , KSPMonitorRegister(), KSPMonitorSet(), 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.KSPMonitorSingularValueMethod
KSPMonitorSingularValue(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the two norm of the true residual and estimation of the extreme singular values of the preconditioned problem at each iteration.

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • n - the iteration
  • rnorm - the two norm of the residual
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_singular_value - Activates KSPMonitorSingularValue()

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPComputeExtremeSingularValues(), KSPMonitorSingularValueCreate()

External Links

source
PETSc.LibPETSc.KSPMonitorSingularValueCreateMethod
vf::PetscViewerAndFormat = KSPMonitorSingularValueCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the singular value monitor context needed by KSPMonitorSingularValue()

Collective

Input Parameters:

  • viewer - The PetscViewer
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The viewer context

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorSingularValue(), PetscViewer

External Links

source
PETSc.LibPETSc.KSPMonitorSolutionMethod
KSPMonitorSolution(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Print the solution norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_solution - Activates KSPMonitorSolution()

Level: intermediate

-seealso: , KSPMonitorSet(), KSPMonitorTrueResidual()

External Links

source
PETSc.LibPETSc.KSPMonitorSolutionDrawMethod
KSPMonitorSolutionDraw(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the solution at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_solution draw - Activates KSPMonitorSolutionDraw()

Level: intermediate

-seealso: , KSPMonitorSet(), KSPMonitorTrueResidual()

External Links

source
PETSc.LibPETSc.KSPMonitorSolutionDrawLGMethod
KSPMonitorSolutionDrawLG(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the solution norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_solution draw::draw_lg - Activates KSPMonitorSolutionDrawLG()

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorSolutionDrawLGCreate()

External Links

source
PETSc.LibPETSc.KSPMonitorSolutionDrawLGCreateMethod
vf::PetscViewerAndFormat = KSPMonitorSolutionDrawLGCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the context for the KSP monitor KSPMonitorSolutionDrawLG()

Collective

Input Parameters:

  • viewer - The PetscViewer
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The viewer context

Level: intermediate

-seealso: , KSPMonitorSet(), KSPMonitorTrueResidual()

External Links

source
PETSc.LibPETSc.KSPMonitorTrueResidualMethod
KSPMonitorTrueResidual(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the true residual norm, as well as the (possibly preconditioned, possibly approximate) residual norm, at each iteration of a KSPSolve() iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_true_residual - Activates KSPMonitorTrueResidual() to print both norm values at each iteration

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorResidual(), KSPMonitorTrueResidualMaxNorm(), PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.KSPMonitorTrueResidualDrawLGMethod
KSPMonitorTrueResidualDrawLG(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the true residual norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_true_residual draw::draw_lg - Activates KSPMonitorTrueResidualDrawLG()

Level: intermediate

-seealso: , PETSCVIEWERDRAW, KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorTrueResidualDraw(), KSPMonitorResidual, KSPMonitorTrueResidualDrawLGCreate()

External Links

source
PETSc.LibPETSc.KSPMonitorTrueResidualDrawLGCreateMethod
vf::PetscViewerAndFormat = KSPMonitorTrueResidualDrawLGCreate(petsclib::PetscLibType,viewer::PetscViewer, format::PetscViewerFormat, ctx::Cvoid)

Creates the context for the true residual monitor KSPMonitorTrueResidualDrawLG()

Collective

Input Parameters:

  • viewer - The PetscViewer of type PETSCVIEWERDRAW
  • format - The viewer format
  • ctx - An optional user context

Output Parameter:

  • vf - The viewer context

Level: intermediate

-seealso: , PETSCVIEWERDRAW, KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.KSPMonitorTrueResidualMaxMethod
KSPMonitorTrueResidualMax(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Prints the true residual max norm at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context

Options Database Key:

  • -ksp_monitor_true_residual_max - Activates KSPMonitorTrueResidualMax()

Level: intermediate

-seealso: , KSP, KSPMonitorSet(), KSPMonitorResidual(), KSPMonitorTrueResidualMaxNorm()

External Links

source
PETSc.LibPETSc.KSPMonitorTrueResidualViewMethod
KSPMonitorTrueResidualView(petsclib::PetscLibType,ksp::PetscKSP, n::PetscInt, rnorm::PetscReal, vf::PetscViewerAndFormat)

Plots the true residual at each iteration of an iterative solver.

Collective

Input Parameters:

  • ksp - iterative context
  • n - iteration number
  • rnorm - 2-norm (preconditioned) residual value (may be estimated).
  • vf - The viewer context of type PETSCVIEWERDRAW

Options Database Key:

  • -ksp_monitor_true_residual viewertype - Activates KSPMonitorTrueResidualView()

Level: intermediate

-seealso: , PETSCVIEWERDRAW, KSP, KSPMonitorSet(), KSPMonitorTrueResidual(), KSPMonitorResidual(), KSPMonitorTrueResidualDrawLG(), PetscViewerAndFormat

External Links

source
PETSc.LibPETSc.KSPPIPEFCGGetMmaxMethod
mmax::PetscInt = KSPPIPEFCGGetMmax(petsclib::PetscLibType,ksp::PetscKSP)

get the maximum number of previous directions KSPPIPEFCG will store

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • mmax - the maximum number of previous directions allowed for orthogonalization

Level: intermediate

-seealso: , KSPPIPEFCG, KSPPIPEFCGGetTruncationType(), KSPPIPEFCGGetNprealloc(), KSPPIPEFCGSetMmax(), KSPFCGGetMmax(), KSPFCGSetMmax()

External Links

source
PETSc.LibPETSc.KSPPIPEFCGGetNpreallocMethod
nprealloc::PetscInt = KSPPIPEFCGGetNprealloc(petsclib::PetscLibType,ksp::PetscKSP)

get the number of directions to preallocate by KSPPIPEFCG

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • nprealloc - the number of directions preallocated

Level: advanced

-seealso: , KSPPIPEFCG, KSPPIPEFCGGetTruncationType(), KSPPIPEFCGSetNprealloc(), KSPPIPEFCGSetMmax(), KSPPIPEFCGGetMmax()

External Links

source
PETSc.LibPETSc.KSPPIPEFCGGetTruncationTypeMethod
truncstrat::KSPFCDTruncationType = KSPPIPEFCGGetTruncationType(petsclib::PetscLibType,ksp::PetscKSP)

get the truncation strategy employed by KSPPIPEFCG

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • truncstrat - the strategy type

Level: intermediate

-seealso: , KSPPIPEFCG, KSPPIPEFCGSetTruncationType, KSPFCDTruncationType, KSP_FCD_TRUNC_TYPE_STANDARD, KSP_FCD_TRUNC_TYPE_NOTAY

External Links

source
PETSc.LibPETSc.KSPPIPEFCGSetMmaxMethod
KSPPIPEFCGSetMmax(petsclib::PetscLibType,ksp::PetscKSP, mmax::PetscInt)

set the maximum number of previous directions KSPPIPEFCG will store for orthogonalization

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • mmax - the maximum number of previous directions to orthogonalize against

Options Database Key:

  • -ksp_pipefcg_mmax <N> - maximum number of previous directions

Level: intermediate

-seealso: , KSPPIPEFCG, KSPPIPEFCGSetTruncationType(), KSPPIPEFCGSetNprealloc(), KSPFCGSetMmax(), KSPFCGGetMmax()

External Links

source
PETSc.LibPETSc.KSPPIPEFCGSetNpreallocMethod
KSPPIPEFCGSetNprealloc(petsclib::PetscLibType,ksp::PetscKSP, nprealloc::PetscInt)

set the number of directions to preallocate with KSPPIPEFCG

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • nprealloc - the number of vectors to preallocate

Options Database Key:

  • -ksp_pipefcg_nprealloc <N> - the number of vectors to preallocate

Level: advanced

-seealso: , KSPPIPEFCG, KSPPIPEFCGSetTruncationType(), KSPPIPEFCGGetNprealloc(), KSPPIPEFCGSetMmax(), KSPPIPEFCGGetMmax()

External Links

source
PETSc.LibPETSc.KSPPIPEFCGSetTruncationTypeMethod
KSPPIPEFCGSetTruncationType(petsclib::PetscLibType,ksp::PetscKSP, truncstrat::KSPFCDTruncationType)

specify how many of its stored previous directions KSPPIPEFCG uses during orthoganalization

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • truncstrat - the choice of strategy

-seealso: , KSPPIPEFCG, KSPPIPEFCGGetTruncationType, KSPFCDTruncationType, KSP_FCD_TRUNC_TYPE_STANDARD, KSP_FCD_TRUNC_TYPE_NOTAY

External Links

source
PETSc.LibPETSc.KSPPIPEFGMRESSetShiftMethod
KSPPIPEFGMRESSetShift(petsclib::PetscLibType,ksp::PetscKSP, shift::PetscScalar)

Set the shift parameter for the flexible, pipelined KSPPIPEFGMRES solver.

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • shift - the shift

Options Database Key:

  • -ksp_pipefgmres_shift <shift> - set the shift parameter

Level: intermediate

-seealso: , KSPPIPEFGMRES, KSPComputeEigenvalues()

External Links

source
PETSc.LibPETSc.KSPPIPEGCRGetMmaxMethod
mmax::PetscInt = KSPPIPEGCRGetMmax(petsclib::PetscLibType,ksp::PetscKSP)

get the maximum number of previous directions KSPPIPEGCR will store

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • mmax - the maximum number of previous directions allowed for orthogonalization

Level: intermediate

-seealso: , KSPPIPEGCR, KSPPIPEGCRGetTruncationType(), KSPPIPEGCRGetNprealloc(), KSPPIPEGCRSetMmax()

External Links

source
PETSc.LibPETSc.KSPPIPEGCRGetNpreallocMethod
nprealloc::PetscInt = KSPPIPEGCRGetNprealloc(petsclib::PetscLibType,ksp::PetscKSP)

get the number of directions preallocate by KSPPIPEGCR

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • nprealloc - the number of directions preallocated

Level: advanced

-seealso: , KSPPIPEGCR, KSPPIPEGCRGetTruncationType(), KSPPIPEGCRSetNprealloc()

External Links

source
PETSc.LibPETSc.KSPPIPEGCRGetTruncationTypeMethod
truncstrat::KSPFCDTruncationType = KSPPIPEGCRGetTruncationType(petsclib::PetscLibType,ksp::PetscKSP)

get the truncation strategy employed by KSPPIPEGCR

Not Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • truncstrat - the strategy type

-seealso: , KSPPIPEGCR, KSPPIPEGCRSetTruncationType, KSPPIPEGCRTruncationType, KSPFCDTruncationType, KSP_FCD_TRUNC_TYPE_STANDARD, KSP_FCD_TRUNC_TYPE_NOTAY

External Links

source
PETSc.LibPETSc.KSPPIPEGCRGetUnrollWMethod
unroll_w::PetscBool = KSPPIPEGCRGetUnrollW(petsclib::PetscLibType,ksp::PetscKSP)

Get information on KSPPIPEGCR if it uses unrolling the w vector

Logically Collective

Input Parameter:

  • ksp - the Krylov space context

Output Parameter:

  • unroll_w - KSPPIPEGCR uses unrolling (bool)

Level: intermediate

-seealso: , KSPPIPEGCR, KSPPIPEGCRGetTruncationType(), KSPPIPEGCRGetNprealloc(), KSPPIPEGCRSetUnrollW()

External Links

source
PETSc.LibPETSc.KSPPIPEGCRSetMmaxMethod
KSPPIPEGCRSetMmax(petsclib::PetscLibType,ksp::PetscKSP, mmax::PetscInt)

set the maximum number of previous directions KSPPIPEGCR will store for orthogonalization

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • mmax - the maximum number of previous directions to orthogonalize against

Options Database Key:

  • -ksp_pipegcr_mmax <mmax> - maximum number of previous directions

Level: intermediate

-seealso: , KSPPIPEGCR, KSPPIPEGCRSetTruncationType(), KSPPIPEGCRSetNprealloc()

External Links

source
PETSc.LibPETSc.KSPPIPEGCRSetModifyPCMethod
KSPPIPEGCRSetModifyPC(petsclib::PetscLibType,ksp::PetscKSP, fnc::KSPFlexibleModifyPCFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Sets the routine used by KSPPIPEGCR to modify the preconditioner at each iteration

Logically Collective

Input Parameters:

  • ksp - iterative context obtained from KSPCreate()
  • function - user defined function to modify the preconditioner, see KSPFlexibleModifyPCFn
  • ctx - user provided context for the modify preconditioner function
  • destroy - the function to use to destroy the user provided application context.

Level: intermediate

-seealso: , KSPFlexibleSetModifyPC(), KSPFlexibleModifyPCFn, KSPPIPEGCR

External Links

source
PETSc.LibPETSc.KSPPIPEGCRSetNpreallocMethod
KSPPIPEGCRSetNprealloc(petsclib::PetscLibType,ksp::PetscKSP, nprealloc::PetscInt)

set the number of directions to preallocate with KSPPIPEGCR

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • nprealloc - the number of vectors to preallocate

Level: advanced

Options Database Key:

  • -ksp_pipegcr_nprealloc <N> - number of vectors to preallocate

-seealso: , KSPPIPEGCR, KSPPIPEGCRGetTruncationType(), KSPPIPEGCRGetNprealloc()

External Links

source
PETSc.LibPETSc.KSPPIPEGCRSetTruncationTypeMethod
KSPPIPEGCRSetTruncationType(petsclib::PetscLibType,ksp::PetscKSP, truncstrat::KSPFCDTruncationType)

specify how many of its stored previous directions KSPPIPEGCR uses during orthogonalization

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • truncstrat - the choice of strategy

-seealso: , KSPPIPEGCR, KSPPIPEGCRTruncationType, KSPFCDTruncationType, KSP_FCD_TRUNC_TYPE_STANDARD, KSP_FCD_TRUNC_TYPE_NOTAY

External Links

source
PETSc.LibPETSc.KSPPIPEGCRSetUnrollWMethod
KSPPIPEGCRSetUnrollW(petsclib::PetscLibType,ksp::PetscKSP, unroll_w::PetscBool)

Set to PETSC_TRUE to use KSPPIPEGCR with unrolling of the w vector

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • unroll_w - use unrolling

Level: intermediate

Options Database Key:

  • -ksp_pipegcr_unroll_w <bool> - use unrolling

-seealso: , KSPPIPEGCR, KSPPIPEGCRSetTruncationType(), KSPPIPEGCRSetNprealloc(), KSPPIPEGCRGetUnrollW()

External Links

source
PETSc.LibPETSc.KSPPythonGetTypeMethod
pyname::String = KSPPythonGetType(petsclib::PetscLibType,ksp::PetscKSP)

Get the type of a KSP object implemented in Python.

Not Collective

Input Parameter:

  • ksp - the linear solver KSP context.

Output Parameter:

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

Level: intermediate

-seealso: , KSPCreate(), KSPSetType(), KSPPYTHON, PetscPythonInitialize(), KSPPythonSetType()

External Links

source
PETSc.LibPETSc.KSPPythonSetTypeMethod
KSPPythonSetType(petsclib::PetscLibType,ksp::PetscKSP, pyname::String)

Initialize a KSP object to a type implemented in Python.

Collective

Input Parameters:

  • ksp - the linear solver KSP context.
  • pyname - full dotted Python name [package].module[.{class|function}]

Options Database Key:

  • -ksp_python_type <pyname> - python class

Level: intermediate

-seealso: , KSPCreate(), KSPSetType(), KSPPYTHON, PetscPythonInitialize()

External Links

source
PETSc.LibPETSc.KSPQCGGetQuadraticMethod
quadratic::PetscReal = KSPQCGGetQuadratic(petsclib::PetscLibType,ksp::PetscKSP)

Gets the value of the quadratic function, evaluated at the new iterate

Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • quadratic - the quadratic function evaluated at the new iterate

Level: advanced

-seealso: , KSPQCG

External Links

source
PETSc.LibPETSc.KSPQCGGetTrialStepNormMethod
tsnorm::PetscReal = KSPQCGGetTrialStepNorm(petsclib::PetscLibType,ksp::PetscKSP)

Gets the norm of a trial step vector in KSPQCG. The WCG step may be constrained, so this is not necessarily the length of the ultimate step taken in KSPQCG.

Not Collective

Input Parameter:

  • ksp - the iterative context

Output Parameter:

  • tsnorm - the norm

Level: advanced

-seealso: , KSPQCG, KSPQCGSetTrustRegionRadius()

External Links

source
PETSc.LibPETSc.KSPQCGSetTrustRegionRadiusMethod
KSPQCGSetTrustRegionRadius(petsclib::PetscLibType,ksp::PetscKSP, delta::PetscReal)

Sets the radius of the trust region for KSPQCG

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • delta - the trust region radius (Infinity is the default)

Options Database Key:

  • -ksp_qcg_trustregionradius <delta> - trust region radius

Level: advanced

-seealso: , KSPQCG, KSPQCGGetTrialStepNorm()

External Links

source
PETSc.LibPETSc.KSPRegisterMethod
KSPRegister(petsclib::PetscLibType,sname::String, fnc::external)

Adds a method, KSPType, to the Krylov subspace solver package.

Not Collective, No Fortran Support

Input Parameters:

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

Level: advanced

-seealso: , KSP, KSPType, KSPSetType, KSPRegisterAll()

External Links

source
PETSc.LibPETSc.KSPResetMethod
KSPReset(petsclib::PetscLibType,ksp::PetscKSP)

Removes any allocated Vec and Mat from the KSP data structures.

Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Level: intermediate

-seealso: , KSPCreate(), KSPSetUp(), KSPSolve(), KSP

External Links

source
PETSc.LibPETSc.KSPResetFromOptionsMethod
KSPResetFromOptions(petsclib::PetscLibType,ksp::PetscKSP)

Sets KSP parameters from user options ONLY if the KSP was previously set from options

Collective

Input Parameter:

  • ksp - the KSP context

Level: advanced

-seealso: , KSPSetFromOptions(), KSPSetOptionsPrefix()

External Links

source
PETSc.LibPETSc.KSPResetViewersMethod
KSPResetViewers(petsclib::PetscLibType,ksp::PetscKSP)

Resets all the viewers set from the options database during KSPSetFromOptions()

Collective

Input Parameter:

  • ksp - the KSP iterative solver context obtained from KSPCreate()

Level: beginner

-seealso: , KSPCreate(), KSPSetUp(), KSPSolve(), KSPSetFromOptions(), KSP

External Links

source
PETSc.LibPETSc.KSPRichardsonSetScaleMethod
KSPRichardsonSetScale(petsclib::PetscLibType,ksp::PetscKSP, scale::PetscReal)

Set the damping factor; if this routine is not called, the factor defaults to 1.0.

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • scale - the damping factor

Options Database Key:

  • -ksp_richardson_scale <scale> - Set the scale factor

Level: intermediate

-seealso: , KSPRICHARDSON, KSPRichardsonSetSelfScale()

External Links

source
PETSc.LibPETSc.KSPRichardsonSetSelfScaleMethod
KSPRichardsonSetSelfScale(petsclib::PetscLibType,ksp::PetscKSP, scale::PetscBool)

Sets Richardson to automatically determine optimal scaling at each iteration to minimize the 2 preconditioned residual

Logically Collective

Input Parameters:

  • ksp - the iterative context
  • scale - PETSC_TRUE or the default of PETSC_FALSE

Options Database Key:

  • -ksp_richardson_self_scale - Use self-scaling

Level: intermediate

-seealso: , KSPRICHARDSON, KSPRichardsonSetScale()

External Links

source
PETSc.LibPETSc.KSPSetCheckNormIterationMethod
KSPSetCheckNormIteration(petsclib::PetscLibType,ksp::PetscKSP, it::PetscInt)

Sets the first iteration at which the norm of the residual will be computed and used in the convergence test of KSPSolve() for the given KSP context

Logically Collective

Input Parameters:

  • ksp - Krylov solver context
  • it - use -1 to check at all iterations

Level: advanced

-seealso: , KSP, KSPSetUp(), KSPSolve(), KSPDestroy(), KSPConvergedSkip(), KSPSetNormType(), KSPSetLagNorm()

External Links

source
PETSc.LibPETSc.KSPSetComputeEigenvaluesMethod
KSPSetComputeEigenvalues(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Sets a flag so that the extreme eigenvalues values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flg - PETSC_TRUE or PETSC_FALSE

Level: advanced

-seealso: , KSPComputeEigenvalues(), KSPComputeEigenvaluesExplicitly(), KSP, KSPSetComputeRitz()

External Links

source
PETSc.LibPETSc.KSPSetComputeInitialGuessMethod
KSPSetComputeInitialGuess(petsclib::PetscLibType,ksp::PetscKSP, func::Union{KSPComputeInitialGuessFn, Ptr}, ctx::Union{Cvoid, Ptr})

set routine to compute the initial guess of the linear system

Logically Collective

Input Parameters:

  • ksp - the KSP context
  • func - function to compute the initial guess, see KSPComputeInitialGuessFn for calling sequence
  • ctx - optional context

Level: beginner

-seealso: , KSP, KSPSolve(), KSPSetComputeRHS(), KSPSetComputeOperators(), DMKSPSetComputeInitialGuess(), KSPSetInitialGuessNonzero(), KSPComputeInitialGuessFn

External Links

source
PETSc.LibPETSc.KSPSetComputeOperatorsMethod
KSPSetComputeOperators(petsclib::PetscLibType,ksp::PetscKSP, func::Union{KSPComputeOperatorsFn, Ptr}, ctx::Union{Cvoid, Ptr})

set routine to compute the linear operators

Logically Collective

Input Parameters:

  • ksp - the KSP context
  • func - function to compute the operators, see KSPComputeOperatorsFn for the calling sequence
  • ctx - optional context

Level: beginner

-seealso: , KSP, KSPSetOperators(), KSPSetComputeRHS(), DMKSPSetComputeOperators(), KSPSetComputeInitialGuess(), KSPComputeOperatorsFn

External Links

source
PETSc.LibPETSc.KSPSetComputeRHSMethod
KSPSetComputeRHS(petsclib::PetscLibType,ksp::PetscKSP, func::Union{KSPComputeRHSFn,Ptr}, ctx::Union{Cvoid, Ptr})

set routine to compute the right

Logically Collective

Input Parameters:

  • ksp - the KSP context
  • func - function to compute the right-hand side, see KSPComputeRHSFn for the calling sequence
  • ctx - optional context

Level: beginner

-seealso: , KSP, KSPSolve(), DMKSPSetComputeRHS(), KSPSetComputeOperators(), KSPSetOperators(), KSPComputeRHSFn

External Links

source
PETSc.LibPETSc.KSPSetComputeRitzMethod
KSPSetComputeRitz(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Sets a flag so that the Ritz or harmonic Ritz pairs will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flg - PETSC_TRUE or PETSC_FALSE

Level: advanced

-seealso: , KSPComputeRitz(), KSP, KSPComputeEigenvalues(), KSPComputeExtremeSingularValues()

External Links

source
PETSc.LibPETSc.KSPSetComputeSingularValuesMethod
KSPSetComputeSingularValues(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Sets a flag so that the extreme singular values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flg - PETSC_TRUE or PETSC_FALSE

Options Database Key:

  • -ksp_monitor_singular_value - Activates KSPSetComputeSingularValues()

Level: advanced

-seealso: , KSPComputeExtremeSingularValues(), KSPMonitorSingularValue(), KSP, KSPSetComputeRitz()

External Links

source
PETSc.LibPETSc.KSPSetConvergedNegativeCurvatureMethod
KSPSetConvergedNegativeCurvature(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Allows to declare convergence and return KSP_CONVERGED_NEG_CURVE when negative curvature is detected

Collective

Input Parameters:

  • ksp - iterative context
  • flg - the Boolean value

Options Database Key:

  • -ksp_converged_neg_curve <bool> - Declare convergence if negative curvature is detected

Level: advanced

-seealso: , KSP, KSPConvergedReason, KSPGetConvergedNegativeCurvature()

External Links

source
PETSc.LibPETSc.KSPSetConvergenceTestMethod
KSPSetConvergenceTest(petsclib::PetscLibType,ksp::PetscKSP, converge::KSPConvergenceTestFn, ctx::Cvoid, destroy::PetscCtxDestroyFn)

Sets the function to be used to determine convergence of KSPSolve()

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • converge - pointer to the function, see KSPConvergenceTestFn
  • ctx - context for private data for the convergence routine (may be NULL)
  • destroy - a routine for destroying the context (may be NULL)

Level: advanced

-seealso: , KSP, KSPConvergenceTestFn, KSPConvergedDefault(), KSPGetConvergenceContext(), KSPSetTolerances(), KSPGetConvergenceTest(), KSPGetAndClearConvergenceTest()

External Links

source
PETSc.LibPETSc.KSPSetDMMethod
KSPSetDM(petsclib::PetscLibType,ksp::PetscKSP, dm::PetscDM)

Sets the DM that may be used by some preconditioners and that may be used to construct the linear system

Logically Collective

Input Parameters:

  • ksp - the KSP
  • dm - the DM, cannot be NULL to remove a previously set DM

Level: intermediate

-seealso: , KSP, DM, KSPGetDM(), KSPSetDMActive(), KSPSetComputeOperators(), KSPSetComputeRHS(), KSPSetComputeInitialGuess(), DMKSPSetComputeOperators(), DMKSPSetComputeRHS(), DMKSPSetComputeInitialGuess()

External Links

source
PETSc.LibPETSc.KSPSetDMActiveMethod
KSPSetDMActive(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Indicates the DM should be used to generate the linear system matrix and right

Logically Collective

Input Parameters:

  • ksp - the KSP
  • flg - use the DM

Level: intermediate

-seealso: , KSP, DM, KSPGetDM(), KSPSetDM(), SNESSetDM(), KSPSetComputeOperators(), KSPSetComputeRHS(), KSPSetComputeInitialGuess()

External Links

source
PETSc.LibPETSc.KSPSetDiagonalScaleMethod
KSPSetDiagonalScale(petsclib::PetscLibType,ksp::PetscKSP, scale::PetscBool)

Tells KSP to symmetrically diagonally scale the system before solving. This actually CHANGES the matrix (and right-hand side).

Logically Collective

Input Parameters:

  • ksp - the KSP context
  • scale - PETSC_TRUE or PETSC_FALSE

Options Database Keys:

  • -ksp_diagonal_scale - perform a diagonal scaling before the solve
  • -ksp_diagonal_scale_fix - scale the matrix back AFTER the solve

Level: advanced

-seealso: , KSPGetDiagonalScale(), KSPSetDiagonalScaleFix(), KSP

External Links

source
PETSc.LibPETSc.KSPSetDiagonalScaleFixMethod
KSPSetDiagonalScaleFix(petsclib::PetscLibType,ksp::PetscKSP, fix::PetscBool)

Tells KSP to diagonally scale the system back after solving.

Logically Collective

Input Parameters:

  • ksp - the KSP context
  • fix - PETSC_TRUE to scale back after the system solve, PETSC_FALSE to not

rescale (default)

Level: intermediate

-seealso: , KSPGetDiagonalScale(), KSPSetDiagonalScale(), KSPGetDiagonalScaleFix(), KSP

External Links

source
PETSc.LibPETSc.KSPSetErrorHistoryMethod
KSPSetErrorHistory(petsclib::PetscLibType,ksp::PetscKSP, a::Vector{PetscReal}, na::PetscCount, reset::PetscBool)

Sets the array used to hold the error history. If set, this array will contain the error norms computed at each iteration of the solver.

Not Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • a - array to hold history
  • na - size of a
  • reset - PETSC_TRUE indicates the history counter is reset to zero for each new linear solve

Level: advanced

-seealso: , KSPGetErrorHistory(), KSPSetResidualHistory(), KSP

External Links

source
PETSc.LibPETSc.KSPSetErrorIfNotConvergedMethod
KSPSetErrorIfNotConverged(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Causes KSPSolve() to generate an error if the solver has not converged as soon as the error is detected.

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flg - PETSC_TRUE indicates you want the error generated

Options Database Key:

  • -ksp_error_if_not_converged <true,false> - generate an error and stop the program

Level: intermediate

-seealso: , KSPGetErrorIfNotConverged(), KSP

External Links

source
PETSc.LibPETSc.KSPSetFromOptionsMethod
KSPSetFromOptions(petsclib::PetscLibType,ksp::PetscKSP)

Sets KSP options from the options database. This routine must be called before KSPSetUp() if the user is to be allowed to set the Krylov type.

Collective

Input Parameter:

  • ksp - the Krylov space context

Options Database Keys:

  • -ksp_rtol rtol - relative tolerance used in default determination of convergence, i.e.

if residual norm decreases by this factor than convergence is declared

  • -ksp_atol abstol - absolute tolerance used in default convergence test, i.e. if residual

norm is less than this then convergence is declared

  • -ksp_divtol tol - if residual norm increases by this factor than divergence is declared

  • -ksp_max_it - maximum number of linear iterations

  • -ksp_min_it - minimum number of linear iterations to use, defaults to zero

  • -ksp_reuse_preconditioner <true,false> - reuse the previously computed preconditioner

  • -ksp_converged_use_initial_residual_norm - see KSPConvergedDefaultSetUIRNorm()

  • -ksp_converged_use_min_initial_residual_norm - see KSPConvergedDefaultSetUMIRNorm()

  • -ksp_converged_maxits - see KSPConvergedDefaultSetConvergedMaxits()

  • -ksp_norm_type <none,preconditioned,unpreconditioned,natural> - see KSPSetNormType()

  • -ksp_check_norm_iteration it - do not compute residual norm until iteration number it (does compute at 0th iteration)

works only for KSPBCGS, KSPIBCGS, and KSPCG

  • -ksp_lag_norm - compute the norm of the residual for the ith iteration on the i+1 iteration;

this means that one can use the norm of the residual for convergence test WITHOUT an extra MPI_Allreduce() limiting global synchronizations. This will require 1 more iteration of the solver than usual.

  • -ksp_guess_type - Type of initial guess generator for repeated linear solves
  • -ksp_fischer_guess <model,size> - uses the Fischer initial guess generator for repeated linear solves
  • -ksp_constant_null_space - assume the operator (matrix) has the constant vector in its null space
  • -ksp_test_null_space - tests the null space set with MatSetNullSpace() to see if it truly is a null space
  • -ksp_knoll - compute initial guess by applying the preconditioner to the right-hand side
  • -ksp_monitor_cancel - cancel all previous convergene monitor routines set
  • -ksp_monitor - print residual norm at each iteration
  • -ksp_monitor draw::draw_lg - plot residual norm at each iteration, see KSPMonitorResidual()
  • -ksp_monitor_true_residual - print the true l2 residual norm at each iteration, see KSPMonitorTrueResidual()
  • -all_ksp_monitor <optional filename> - print residual norm at each iteration for ALL KSP solves, regardless of their prefix. This is

useful for PCFIELDSPLIT, PCMG, etc that have inner solvers and you wish to track the convergence of all the solvers

  • -ksp_monitor_solution [ascii binary or draw][:filename][:format option] - plot solution at each iteration
  • -ksp_monitor_singular_value - monitor extreme singular values at each iteration
  • -ksp_converged_reason - view the convergence state at the end of the solve
  • -ksp_use_explicittranspose - transpose the system explicitly in KSPSolveTranspose()
  • -ksp_error_if_not_converged - stop the program as soon as an error is detected in a KSPSolve(), KSP_DIVERGED_ITS

is not treated as an error on inner solves

  • -ksp_converged_rate - view the convergence rate at the end of the solve

Level: beginner

-seealso: , KSP, KSPSetOptionsPrefix(), KSPResetFromOptions(), KSPSetUseFischerGuess()

External Links

source
PETSc.LibPETSc.KSPSetGuessMethod
KSPSetGuess(petsclib::PetscLibType,ksp::PetscKSP, guess::KSPGuess)

Set the initial guess object KSPGuess to be used by the KSP object to generate initial guesses

Logically Collective

Input Parameters:

  • ksp - the Krylov context
  • guess - the object created with KSPGuessCreate()

Level: advanced

-seealso: , KSP, KSPGuess, KSPSetOptionsPrefix(), KSPAppendOptionsPrefix(), KSPSetUseFischerGuess(), KSPGetGuess()

External Links

source
PETSc.LibPETSc.KSPSetInitialGuessKnollMethod
KSPSetInitialGuessKnoll(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Tells the iterative solver to use PCApply() on the right hand side vector to compute the initial guess (The Knoll trick)

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flg - PETSC_TRUE or PETSC_FALSE

Level: advanced

-seealso: , KSPGetInitialGuessKnoll(), KSPGuess, KSPSetInitialGuessNonzero(), KSPGetInitialGuessNonzero(), KSP

External Links

source
PETSc.LibPETSc.KSPSetInitialGuessNonzeroMethod
KSPSetInitialGuessNonzero(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Tells the iterative solver that the initial guess is nonzero; otherwise KSP assumes the initial guess is to be zero (and thus zeros it out before solving).

Logically Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flg - PETSC_TRUE indicates the guess is non-zero, PETSC_FALSE indicates the guess is zero

Options Database Key:

  • -ksp_initial_guess_nonzero <true,false> - use nonzero initial guess

Level: beginner

-seealso: , KSPGetInitialGuessNonzero(), KSPGuessSetType(), KSPGuessType, KSP

External Links

source
PETSc.LibPETSc.KSPSetLagNormMethod
KSPSetLagNorm(petsclib::PetscLibType,ksp::PetscKSP, flg::PetscBool)

Lags the residual norm calculation so that it is computed as part of the MPI_Allreduce() used for computing the inner products needed for the next iteration.

Logically Collective

Input Parameters:

  • ksp - Krylov solver context
  • flg - PETSC_TRUE or PETSC_FALSE

Options Database Key:

  • -ksp_lag_norm - lag the calculated residual norm

Level: advanced

-seealso: , KSPSetUp(), KSPSolve(), KSPDestroy(), KSPConvergedSkip(), KSPSetNormType(), KSPSetCheckNormIteration()

External Links

source
PETSc.LibPETSc.KSPSetMatSolveBatchSizeMethod
KSPSetMatSolveBatchSize(petsclib::PetscLibType,ksp::PetscKSP, bs::PetscInt)

Sets the maximum number of columns treated simultaneously in KSPMatSolve().

Logically Collective

Input Parameters:

  • ksp - the KSP iterative solver
  • bs - batch size

Level: advanced

-seealso: , KSPMatSolve(), KSPGetMatSolveBatchSize(), -mat_mumps_icntl_27, -matmatmult_Bbn

External Links

source
PETSc.LibPETSc.KSPSetMinimumIterationsMethod
KSPSetMinimumIterations(petsclib::PetscLibType,ksp::PetscKSP, minit::PetscInt)

Sets the minimum number of iterations to use, regardless of the tolerances

Logically Collective

Input Parameters:

  • ksp - the Krylov subspace context
  • minit - minimum number of iterations to use

Options Database Key:

  • -ksp_min_it <minits> - Sets minit

Level: intermediate

-seealso: , KSPGetTolerances(), KSPConvergedDefault(), KSPSetConvergenceTest(), KSP, KSPSetTolerances(), KSPGetMinimumIterations()

External Links

source
PETSc.LibPETSc.KSPSetNestLevelMethod
KSPSetNestLevel(petsclib::PetscLibType,ksp::PetscKSP, level::PetscInt)

sets the amount of nesting the KSP has. That is the number of levels of KSP above this KSP in a linear solve.

Collective

Input Parameters:

  • ksp - the KSP
  • level - the nest level

Level: developer

-seealso: , KSPSetUp(), KSPSolve(), KSPDestroy(), KSP, KSPGMRES, KSPType, KSPGetNestLevel(), PCSetKSPNestLevel(), PCGetKSPNestLevel()

External Links

source
PETSc.LibPETSc.KSPSetNormTypeMethod
KSPSetNormType(petsclib::PetscLibType,ksp::PetscKSP, normtype::KSPNormType)

Sets the type of residual norm that is used for convergence testing in KSPSolve() for the given KSP context

Logically Collective

Input Parameters:

  • ksp - Krylov solver context
  • normtype - one of

-seealso: , KSPSetUp(), KSPSolve(), KSPDestroy(), KSPConvergedSkip(), KSPSetCheckNormIteration(), KSPSetPCSide(), KSPGetPCSide(), KSPNormType

External Links

source
PETSc.LibPETSc.KSPSetOperatorsMethod
KSPSetOperators(petsclib::PetscLibType,ksp::PetscKSP, Amat::PetscMat, Pmat::PetscMat)

Sets the matrix associated with the linear system and a (possibly) different one from which the preconditioner will be built into the KSP context. The matrix will then be used during KSPSolve()

Collective

Input Parameters:

  • ksp - the KSP context
  • Amat - the matrix that defines the linear system
  • Pmat - the matrix to be used in constructing the preconditioner, usually the same as Amat.

Level: beginner

-seealso: , KSP, Mat, KSPSolve(), KSPGetPC(), PCGetOperators(), PCSetOperators(), KSPGetOperators(), KSPSetComputeOperators(), KSPSetComputeInitialGuess(), KSPSetComputeRHS()

External Links

source
PETSc.LibPETSc.KSPSetOptionsPrefixMethod
KSPSetOptionsPrefix(petsclib::PetscLibType,ksp::PetscKSP, prefix::String)

Sets the prefix used for searching for all KSP options in the database.

Logically Collective

Input Parameters:

  • ksp - the Krylov context
  • prefix - the prefix string to prepend to all KSP option requests

Level: intermediate

-seealso: , KSP, KSPAppendOptionsPrefix(), KSPGetOptionsPrefix(), KSPSetFromOptions()

External Links

source
PETSc.LibPETSc.KSPSetPCMethod
KSPSetPC(petsclib::PetscLibType,ksp::PetscKSP, pc::PC)

Sets the preconditioner to be used to calculate the application of the preconditioner on a vector into a KSP.

Collective

Input Parameters:

  • ksp - the KSP iterative solver obtained from KSPCreate()
  • pc - the preconditioner object (if NULL it returns the PC currently held by the KSP)

Level: developer

-seealso: , KSPGetPC(), KSP

External Links

source
PETSc.LibPETSc.KSPSetPCSideMethod
KSPSetPCSide(petsclib::PetscLibType,ksp::PetscKSP, side::PCSide)

Sets the preconditioning side.

Logically Collective

Input Parameter:

  • ksp - iterative solver obtained from KSPCreate()

Output Parameter:

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

-seealso: , KSPGetPCSide(), KSPSetNormType(), KSPGetNormType(), KSP, KSPSetPreSolve(), KSPSetPostSolve()

External Links

source
PETSc.LibPETSc.KSPSetPostSolveMethod
KSPSetPostSolve(petsclib::PetscLibType,ksp::PetscKSP, postsolve::KSPPSolveFn, ctx::Cvoid)

Sets a function that is called at the end of each KSPSolve() (whether it converges or not). Used in conjunction with KSPSetPreSolve().

Logically Collective

Input Parameters:

  • ksp - the solver object
  • postsolve - the function to call after the solve, seeKSPPSolveFn
  • ctx - an optional context needed by the function

Level: developer

-seealso: , KSPPSolveFn, KSPSetUp(), KSPSolve(), KSPDestroy(), KSP, KSPSetPreSolve(), PCEISENSTAT

External Links

source
PETSc.LibPETSc.KSPSetPreSolveMethod
KSPSetPreSolve(petsclib::PetscLibType,ksp::PetscKSP, presolve::KSPPSolveFn, ctx::Cvoid)

Sets a function that is called at the beginning of each KSPSolve(). Used in conjunction with KSPSetPostSolve().

Logically Collective

Input Parameters:

  • ksp - the solver object
  • presolve - the function to call before the solve, seeKSPPSolveFn
  • ctx - an optional context needed by the function

Level: developer

-seealso: , KSPPSolveFn, KSPSetUp(), KSPSolve(), KSPDestroy(), KSP, KSPSetPostSolve(), PCEISENSTAT, PCPreSolve(), PCPostSolve()

External Links

source
PETSc.LibPETSc.KSPSetResidualHistoryMethod
KSPSetResidualHistory(petsclib::PetscLibType,ksp::PetscKSP, a::Vector{PetscReal}, na::PetscCount, reset::PetscBool)

Sets the array used to hold the residual history. If set, this array will contain the residual norms computed at each iteration of the solver.

Not Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • a - array to hold history
  • na - size of a
  • reset - PETSC_TRUE indicates the history counter is reset to zero

for each new linear solve

Level: advanced

-seealso: , KSPGetResidualHistory(), KSP

External Links

source
PETSc.LibPETSc.KSPSetReusePreconditionerMethod
KSPSetReusePreconditioner(petsclib::PetscLibType,ksp::PetscKSP, flag::PetscBool)

reuse the current preconditioner for future KSPSolve(), do not construct a new preconditioner even if the Mat operator in the KSP has different values

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flag - PETSC_TRUE to reuse the current preconditioner, or PETSC_FALSE to construct a new preconditioner

Options Database Key:

  • -ksp_reuse_preconditioner <true,false> - reuse the previously computed preconditioner

Level: intermediate

-seealso: , KSPCreate(), KSPSolve(), KSPDestroy(), KSP, KSPGetReusePreconditioner(), SNESSetLagPreconditioner(), SNES

External Links

source
PETSc.LibPETSc.KSPSetSkipPCSetFromOptionsMethod
KSPSetSkipPCSetFromOptions(petsclib::PetscLibType,ksp::PetscKSP, flag::PetscBool)

prevents KSPSetFromOptions() from calling PCSetFromOptions(). This is used if the same PC is shared by more than one KSP so its options are not reset for each KSP

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • flag - PETSC_TRUE to skip calling the PCSetFromOptions()

Level: developer

-seealso: , KSPCreate(), KSPSolve(), KSPDestroy(), PCSetReusePreconditioner(), KSP

External Links

source
PETSc.LibPETSc.KSPSetSupportedNormMethod
KSPSetSupportedNorm(petsclib::PetscLibType,ksp::PetscKSP, normtype::KSPNormType, pcside::PCSide, priority::PetscInt)

Sets a norm and preconditioner side supported by a KSPType

Logically Collective

Input Parameters:

  • ksp - Krylov method
  • normtype - supported norm type of the type KSPNormType
  • pcside - preconditioner side, of the type PCSide that can be used with this KSPNormType
  • priority - positive integer preference for this combination; larger values have higher priority

Level: developer

-seealso: , KSP, KSPNormType, PCSide, KSPSetNormType(), KSPSetPCSide()

External Links

source
PETSc.LibPETSc.KSPSetTolerancesMethod
KSPSetTolerances(petsclib::PetscLibType,ksp::PetscKSP, rtol::PetscReal, abstol::PetscReal, dtol::PetscReal, maxits::PetscInt)

Sets the relative, absolute, divergence, and maximum iteration tolerances used by the default KSP convergence testers.

Logically Collective

Input Parameters:

  • ksp - the Krylov subspace context
  • rtol - the relative convergence tolerance, relative decrease in the (possibly preconditioned) residual norm
  • abstol - the absolute convergence tolerance absolute size of the (possibly preconditioned) residual norm
  • dtol - the divergence tolerance, amount (possibly preconditioned) residual norm can increase before KSPConvergedDefault() concludes that the method is diverging
  • maxits - maximum number of iterations to use

Options Database Keys:

  • -ksp_atol <abstol> - Sets abstol
  • -ksp_rtol <rtol> - Sets rtol
  • -ksp_divtol <dtol> - Sets dtol
  • -ksp_max_it <maxits> - Sets maxits

Level: intermediate

-seealso: , KSPGetTolerances(), KSPConvergedDefault(), KSPSetConvergenceTest(), KSP, KSPSetMinimumIterations()

External Links

source
PETSc.LibPETSc.KSPSetTypeMethod
KSPSetType(petsclib::PetscLibType,ksp::PetscKSP, type::KSPType)

Sets the algorithm/method to be used to solve the linear system with the given KSP

Logically Collective

Input Parameters:

  • ksp - the Krylov space context
  • type - a known method

Options Database Key:

  • -ksp_type <method> - Sets the method; see KSPGType or use -help for a list of available methods (for instance, cg or gmres)

Level: intermediate

-seealso: , PCSetType(), KSPType, KSPRegister(), KSPCreate(), KSP

External Links

source
PETSc.LibPETSc.KSPSetUpMethod
KSPSetUp(petsclib::PetscLibType,ksp::PetscKSP)

Sets up the internal data structures for the later use KSPSolve() the KSP linear iterative solver.

Collective

Input Parameter:

  • ksp - iterative solver, KSP, obtained from KSPCreate()

Level: developer

-seealso: , KSPCreate(), KSPSolve(), KSPDestroy(), KSP, KSPSetUpOnBlocks()

External Links

source
PETSc.LibPETSc.KSPSetUpOnBlocksMethod
KSPSetUpOnBlocks(petsclib::PetscLibType,ksp::PetscKSP)

Sets up the preconditioner for each block in the block Jacobi PCJACOBI, overlapping Schwarz PCASM, and fieldsplit PCFIELDSPLIT preconditioners

Collective

Input Parameter:

  • ksp - the KSP context

Level: advanced

-seealso: , PCSetUpOnBlocks(), KSPSetUp(), PCSetUp(), KSP

External Links

source
PETSc.LibPETSc.KSPSetUseExplicitTransposeMethod
flg::PetscBool = KSPSetUseExplicitTranspose(petsclib::PetscLibType,ksp::PetscKSP)

Determines the explicit transpose of the operator is formed in KSPSolveTranspose(). In some configurations (like GPUs) it may be explicitly formed since the solve is much more efficient.

Logically Collective

Input Parameter:

  • ksp - the KSP context

Output Parameter:

  • flg - PETSC_TRUE to transpose the system in KSPSolveTranspose(), PETSC_FALSE to not transpose (default)

Level: advanced

-seealso: , KSPSolveTranspose(), KSP

External Links

source
PETSc.LibPETSc.KSPSetUseFischerGuessMethod
KSPSetUseFischerGuess(petsclib::PetscLibType,ksp::PetscKSP, model::PetscInt, size::PetscInt)

Use the Paul Fischer algorithm or its variants to compute initial guesses for a set of solves with related right

Logically Collective

Input Parameters:

  • ksp - the Krylov context
  • model - use model 1, model 2, model 3, or any other number to turn it off
  • size - size of subspace used to generate initial guess

Options Database Key:

  • -ksp_fischer_guess <model,size> - uses the Fischer initial guess generator for repeated linear solves

Level: advanced

-seealso: , KSP, KSPSetOptionsPrefix(), KSPAppendOptionsPrefix(), KSPSetGuess(), KSPGetGuess(), KSPGuess

External Links

source
PETSc.LibPETSc.KSPSetWorkVecsMethod
KSPSetWorkVecs(petsclib::PetscLibType,ksp::PetscKSP, nw::PetscInt)

Sets a number of work vectors into a KSP object

Collective

Input Parameters:

  • ksp - iterative context
  • nw - number of work vectors to allocate

Level: developer

-seealso: , KSP, KSPCreateVecs()

External Links

source
PETSc.LibPETSc.KSPSolveMethod
KSPSolve(petsclib::PetscLibType,ksp::PetscKSP, b::PetscVec, x::PetscVec)

Solves a linear system associated with KSP object

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • b - the right-hand side vector
  • x - the solution (this may be the same vector as b, then b will be overwritten with the answer)

Options Database Keys:

  • -ksp_view_eigenvalues - compute preconditioned operators eigenvalues
  • -ksp_view_eigenvalues_explicit - compute the eigenvalues by forming the dense operator and using LAPACK
  • -ksp_view_mat binary - save matrix to the default binary viewer
  • -ksp_view_pmat binary - save matrix used to build preconditioner to the default binary viewer
  • -ksp_view_rhs binary - save right-hand side vector to the default binary viewer
  • -ksp_view_solution binary - save computed solution vector to the default binary viewer

(can be read later with src/ksp/tutorials/ex10.c for testing solvers)

  • -ksp_view_mat_explicit - for matrix-free operators, computes the matrix entries and views them
  • -ksp_view_preconditioned_operator_explicit - computes the product of the preconditioner and matrix as an explicit matrix and views it
  • -ksp_converged_reason - print reason for converged or diverged, also prints number of iterations
  • -ksp_view_final_residual - print 2-norm of true linear system residual at the end of the solution process
  • -ksp_error_if_not_converged - stop the program as soon as an error is detected in a KSPSolve()
  • -ksp_view_pre - print the ksp data structure before the system solution
  • -ksp_view - print the ksp data structure at the end of the system solution

Level: beginner

-seealso: , KSPCreate(), KSPSetUp(), KSPDestroy(), KSPSetTolerances(), KSPConvergedDefault(), KSPSolveTranspose(), KSPGetIterationNumber(), MatNullSpaceCreate(), MatSetNullSpace(), MatSetTransposeNullSpace(), KSP, KSPConvergedReasonView(), KSPCheckSolve(), KSPSetErrorIfNotConverged()

External Links

source
PETSc.LibPETSc.KSPSolveTransposeMethod
KSPSolveTranspose(petsclib::PetscLibType,ksp::PetscKSP, b::PetscVec, x::PetscVec)

Solves a linear system with the transpose of the matrix associated with the KSP object, A^T x = b.

Collective

Input Parameters:

  • ksp - iterative solver obtained from KSPCreate()
  • b - right-hand side vector
  • x - solution vector

Level: developer

-seealso: , KSPCreate(), KSPSetUp(), KSPDestroy(), KSPSetTolerances(), KSPConvergedDefault(), KSPSolve(), KSP, KSPSetOperators()

External Links

source
PETSc.LibPETSc.KSPUnwindPreconditionerMethod
KSPUnwindPreconditioner(petsclib::PetscLibType,ksp::PetscKSP, vsoln::PetscVec, vt1::PetscVec)

Unwinds the preconditioning in the solution. That is, takes solution to the preconditioned problem and gets the solution to the original problem from it.

Collective

Input Parameters:

  • ksp - iterative context
  • vsoln - solution vector
  • vt1 - temporary work vector

Output Parameter:

  • vsoln - contains solution on output

Level: advanced

-seealso: , KSP, KSPSetPCSide()

External Links

source
PETSc.LibPETSc.KSPViewMethod
KSPView(petsclib::PetscLibType,ksp::PetscKSP, viewer::PetscViewer)

Prints the various parameters currently set in the KSP object. For example, the convergence tolerances and KSPType. Also views the PC and Mat contained by the KSP with PCView() and MatView().

Collective

Input Parameters:

  • ksp - the Krylov space context
  • viewer - visualization context

Options Database Key:

  • -ksp_view - print the KSP data structure at the end of each KSPSolve() call

Level: beginner

-seealso: , KSP, PetscViewer, PCView(), PetscViewerASCIIOpen(), KSPViewFromOptions()

External Links

source
PETSc.LibPETSc.KSPViewFromOptionsMethod
KSPViewFromOptions(petsclib::PetscLibType,A::PetscKSP, obj::PetscObject, name::String)

View (print) a KSP object based on values in the options database. Also views the PC and Mat contained by the KSP with PCView() and MatView().

Collective

Input Parameters:

  • A - Krylov solver context
  • obj - Optional object that provides the options prefix used to query the options database
  • name - command line option

Level: intermediate

-seealso: , KSP, KSPView(), PetscObjectViewFromOptions(), KSPCreate()

External Links

source
PETSc.LibPETSc.KSPGuessCreateMethod
guess::KSPGuess = KSPGuessCreate(petsclib::PetscLibType,comm::MPI_Comm)

Creates a KSPGuess context.

Collective

Input Parameter:

  • comm - MPI communicator

Output Parameter:

  • guess - location to put the KSPGuess context

Options Database Keys:

  • -ksp_guess_type <method> - Turns on generation of initial guesses and sets the method; use -help for a list of available methods
  • -ksp_guess_view <viewer> - view the KSPGuess object
  • -ksp_guess_fischer_model <a,b> - set details for the Fischer models
  • -ksp_guess_fischer_monitor - monitor the fischer models
  • -ksp_guess_fischer_tol <tol> - set the tolerance for the Fischer models
  • -ksp_guess_pod_size <size> - Number of snapshots
  • -ksp_guess_pod_monitor true - monitor the pod initial guess processing
  • -ksp_guess_pod_tol <tol> - Tolerance to retain eigenvectors
  • -ksp_guess_pod_Ainner true - Use the operator as inner product (must be SPD)

Level: developer

-seealso: , KSPSolve(), KSPGuessDestroy(), KSPGuess, KSPGuessType, KSP

External Links

source
PETSc.LibPETSc.KSPGuessDestroyMethod
KSPGuessDestroy(petsclib::PetscLibType,guess::KSPGuess)

Destroys KSPGuess context.

Collective

Input Parameter:

  • guess - initial guess object

Level: developer

-seealso: , KSPGuessCreate(), KSPGuess, KSPGuessType

External Links

source
PETSc.LibPETSc.KSPGuessFischerSetModelMethod
KSPGuessFischerSetModel(petsclib::PetscLibType,guess::KSPGuess, model::PetscInt, size::PetscInt)

Set the Paul Fischer algorithm or its variants to compute the initial guess for a KSPSolve()

Logically Collective

Input Parameters:

  • guess - the initial guess context
  • model - use model 1, model 2, model 3, or any other number to turn it off
  • size - size of subspace used to generate initial guess

Options Database Key:

  • -ksp_guess_fischer_model <model,size> - uses the Fischer initial guess generator for repeated linear solves

Level: advanced

-seealso: , KSPGuess, KSPGuessCreate(), KSPSetUseFischerGuess(), KSPSetGuess(), KSPGetGuess(), KSP

External Links

source
PETSc.LibPETSc.KSPGuessFormGuessMethod
KSPGuessFormGuess(petsclib::PetscLibType,guess::KSPGuess, rhs::PetscVec, sol::PetscVec)

Form the initial guess

Collective

Input Parameters:

  • guess - the initial guess context
  • rhs - the current right-hand side vector
  • sol - the initial guess vector

Level: developer

-seealso: , KSPGuessCreate(), KSPGuess

External Links

source
PETSc.LibPETSc.KSPGuessGetTypeMethod
type::KSPGuessType = KSPGuessGetType(petsclib::PetscLibType,guess::KSPGuess)

Gets the KSPGuessType as a string from the KSPGuess object.

Not Collective

Input Parameter:

  • guess - the initial guess context

Output Parameter:

  • type - type of KSPGuess method

Level: developer

-seealso: , KSPGuess, KSPGuessSetType()

External Links

source
PETSc.LibPETSc.KSPGuessRegisterMethod
KSPGuessRegister(petsclib::PetscLibType,sname::String, fnc::external)

Registers a method for initial guess computation in Krylov subspace solver package.

Not Collective, No Fortran Support

Input Parameters:

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

-seealso: , KSPGuess, KSPGuessRegisterAll()

External Links

source
PETSc.LibPETSc.KSPGuessSetFromOptionsMethod
KSPGuessSetFromOptions(petsclib::PetscLibType,guess::KSPGuess)

Sets the options for a KSPGuess from the options database

Collective

Input Parameter:

  • guess - KSPGuess object

Options Database Keys:

  • -ksp_guess_type <method> - Turns on generation of initial guesses and sets the method; use -help for a list of available methods
  • -ksp_guess_view <viewer> - view the KSPGuess object
  • -ksp_guess_fischer_model <a,b> - set details for the Fischer models
  • -ksp_guess_fischer_monitor - monitor the Fischer models
  • -ksp_guess_fischer_tol <tol> - set the tolerance for the Fischer models
  • -ksp_guess_pod_size <size> - Number of snapshots
  • -ksp_guess_pod_monitor true - monitor the pod initial guess processing
  • -ksp_guess_pod_tol <tol> - Tolerance to retain eigenvectors
  • -ksp_guess_pod_Ainner true - Use the operator as inner product (must be SPD)

Level: developer

-seealso: , KSPGuess, KSPGetGuess(), KSPGuessSetType(), KSPGuessType

External Links

source
PETSc.LibPETSc.KSPGuessSetToleranceMethod
KSPGuessSetTolerance(petsclib::PetscLibType,guess::KSPGuess, tol::PetscReal)

Sets the relative tolerance used in either eigenvalue (POD) or singular value (Fischer type 3) calculations.

Collective

Input Parameters:

  • guess - KSPGuess object
  • tol - the tolerance

Options Database Key:

  • -ksp_guess_fischer_tol <tol> - set the tolerance for the Fischer models
  • -ksp_guess_pod_tol <tol> - set the tolerance for the Pod models

Level: developer

-seealso: , KSPGuess, KSPGuessType, KSPGuessSetFromOptions()

External Links

source
PETSc.LibPETSc.KSPGuessSetTypeMethod
KSPGuessSetType(petsclib::PetscLibType,guess::KSPGuess, type::KSPGuessType)

Sets the type of a KSPGuess. Each KSPGuessType provides a different algorithm for computing the initial guess.

Logically Collective

Input Parameters:

  • guess - the initial guess object for the Krylov method
  • type - a known KSPGuessType

Options Database Key:

  • -ksp_guess_type <method> - Turns on generation of initial guesses and sets the method; see KSPGuessType for a list of available types

Level: developer

-seealso: , KSP, KSPGuess, KSPGuessType, KSPGuessRegister(), KSPGuessCreate(), KSPGUESSFISCHER, KSPGUESSPOD

External Links

source
PETSc.LibPETSc.KSPGuessSetUpMethod
KSPGuessSetUp(petsclib::PetscLibType,guess::KSPGuess)

Setup the initial guess object

Collective

Input Parameter:

  • guess - the initial guess context

Level: developer

-seealso: , KSPGuessCreate(), KSPGuess

External Links

source
PETSc.LibPETSc.KSPGuessUpdateMethod
KSPGuessUpdate(petsclib::PetscLibType,guess::KSPGuess, rhs::PetscVec, sol::PetscVec)

Updates the guess object with the current solution and rhs vector

Collective

Input Parameters:

  • guess - the initial guess context
  • rhs - the corresponding rhs
  • sol - the computed solution

Level: developer

-seealso: , KSPGuessCreate(), KSPGuess

External Links

source
PETSc.LibPETSc.KSPGuessViewMethod
KSPGuessView(petsclib::PetscLibType,guess::KSPGuess, view::PetscViewer)

View the KSPGuess object

Logically Collective

Input Parameters:

  • guess - the initial guess object for the Krylov method
  • view - the viewer object

Options Database Key:

  • -ksp_guess_view viewer - view the KSPGuess object

Level: developer

-seealso: , KSP, KSPGuess, KSPGuessType, KSPGuessRegister(), KSPGuessCreate(), PetscViewer

External Links

source