DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
KrylovSolver Class Reference

#include <petsc.h>

Public Member Functions

 KrylovSolver (MPI_Comm comm)
 Create a Krylov solver.
 KrylovSolver (KSP ksp, bool inc_ref_count)
 Create solver wrapper of a PETSc KSP object.
 KrylovSolver (const KrylovSolver &solver)=delete
 KrylovSolver (KrylovSolver &&solver) noexcept
 Move constructor.
 ~KrylovSolver ()
 Destructor.
KrylovSolveroperator= (const KrylovSolver &)=delete
KrylovSolveroperator= (KrylovSolver &&solver) noexcept
 Move assignment.
void set_operator (const Mat A)
 Set operator (Mat).
void set_operators (const Mat A, const Mat P)
 Set operator and preconditioner matrix (Mat).
KSPConvergedReason solve (Vec x, const Vec b, bool transpose=false)
 Solve linear system Ax = b (A^t x = b if transpose is true).
void set_options_prefix (std::string_view options_prefix)
std::string get_options_prefix () const
void set_from_options () const
 Set options from PETSc options database.
KSP ksp () const
 Return PETSc KSP pointer.

Detailed Description

This class implements Krylov methods for linear systems of the form Ax = b. It is a wrapper for the Krylov solvers of PETSc.

Constructor & Destructor Documentation

◆ KrylovSolver() [1/2]

KrylovSolver ( MPI_Comm comm)
explicit

Create a Krylov solver.

Parameters
[in]commMPI communicator.

◆ KrylovSolver() [2/2]

KrylovSolver ( KSP ksp,
bool inc_ref_count )

Create solver wrapper of a PETSc KSP object.

Parameters
[in]kspPETSc KSP object, which must already have been created. The reference count of ksp is always decreased when this KrylovSolver is destroyed.
[in]inc_ref_countTrue if the reference count of ksp should be incremented.

Member Function Documentation

◆ get_options_prefix()

std::string get_options_prefix ( ) const

Returns the prefix used by PETSc when searching the PETSc options database

◆ set_options_prefix()

void set_options_prefix ( std::string_view options_prefix)

Sets the prefix used by PETSc when searching the PETSc options database

◆ solve()

KSPConvergedReason solve ( Vec x,
const Vec b,
bool transpose = false )
nodiscard

Solve linear system Ax = b (A^t x = b if transpose is true).

Non-convergence is not treated as an error (a warning is logged); check the returned convergence reason.

Returns
The PETSc convergence reason (positive on convergence, negative on divergence).

The documentation for this class was generated from the following files: