Loading...
Searching...
No Matches
dolfin::PETScKrylovSolver Class Reference

`#include <PETScKrylovSolver.h>`

Inheritance diagram for dolfin::PETScKrylovSolver:
[legend]
Collaboration diagram for dolfin::PETScKrylovSolver:
[legend]

## Public Types

enum class | norm_type { none , default_norm , preconditioned , unpreconditioned , natural }

## Public Member Functions

| PETScKrylovSolver (MPI_Comm comm, std::string method="default", std::string preconditioner="default")
| PETScKrylovSolver (std::string method="default", std::string preconditioner="default")
| PETScKrylovSolver (MPI_Comm comm, std::string method, std::shared_ptr< PETScPreconditioner > preconditioner)
| PETScKrylovSolver (std::string method, std::shared_ptr< PETScPreconditioner > preconditioner)
| PETScKrylovSolver (KSP ksp)
| Create solver wrapper of a PETSc KSP object.
virtual | ~PETScKrylovSolver ()
| Destructor.
void | set_operator (std::shared_ptr< const GenericLinearOperator > A)
| Set operator (matrix).
void | set_operator (const PETScBaseMatrix &A)
void | set_operators (std::shared_ptr< const GenericLinearOperator > A, std::shared_ptr< const GenericLinearOperator > P)
| Set operator (matrix) and preconditioner matrix.
void | set_operators (const PETScBaseMatrix &A, const PETScBaseMatrix &P)
std::size_t | solve (GenericVector &x, const GenericVector &b)
| Solve linear system Ax = b and return number of iterations.
std::size_t | solve (GenericVector &x, const GenericVector &b, bool transpose)
std::size_t | solve (PETScVector &x, const PETScVector &b, bool transpose=false)
std::size_t | solve (const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)
| Solve linear system Ax = b and return number of iterations.
void | set_nonzero_guess (bool nonzero_guess)
void | set_reuse_preconditioner (bool reuse_pc)
void | set_tolerances (double relative, double absolute, double diverged, int max_iter)
void | set_norm_type (norm_type type)
norm_type | get_norm_type () const
| Get norm type used in convergence testing.
void | monitor (bool monitor_convergence)
| Monitor residual at each iteration.
void | set_options_prefix (std::string options_prefix)
std::string | get_options_prefix () const
void | set_from_options () const
| Set options from PETSc options database.
std::string | str (bool verbose) const
| Return informal string representation (pretty-print).
MPI_Comm | mpi_comm () const
| Return MPI communicator.
KSP | ksp () const
| Return PETSc KSP pointer.
std::string | parameter_type () const
| Return parameter type: "krylov_solver" or "lu_solver".
void | set_dm (DM dm)
| Set the DM.
void | set_dm_active (bool val)
| Activate/deactivate DM.
Public Member Functions inherited from dolfin::GenericLinearSolver
virtual void | update_parameters (const Parameters &parameters)
| Update solver parameters (useful for LinearSolver wrapper).
Public Member Functions inherited from dolfin::Variable
| Variable ()
| Create unnamed variable.
| Variable (const std::string name, const std::string label)
| Create variable with given name and label.
| Variable (const Variable &variable)
| Copy constructor.
virtual | ~Variable ()
| Destructor.
const Variable & | operator= (const Variable &variable)
| Assignment operator.
void | rename (const std::string name, const std::string label)
| Rename variable.
std::string | name () const
| Return name.
std::string | label () const
| Return label (description).
std::size_t | id () const
Public Member Functions inherited from dolfin::PETScObject
| PETScObject ()
| Constructor. Ensures that PETSc has been initialised.
virtual | ~PETScObject ()
| Destructor.

## Static Public Member Functions

static std::map< std::string, std::string > | methods ()
| Return a list of available solver methods.
static std::map< std::string, std::string > | preconditioners ()
| Return a list of available named preconditioners.
static Parameters | default_parameters ()
| Default parameter values.
Static Public Member Functions inherited from dolfin::PETScObject
static void | petsc_error (int error_code, std::string filename, std::string petsc_function)
| Print error message for PETSc calls that return an error.

## Friends

class | PETScSNESSolver
class | PETScTAOSolver

## Additional Inherited Members

Public Attributes inherited from dolfin::Variable
Parameters | parameters
| Parameters.
Static Protected Member Functions inherited from dolfin::GenericLinearSolver
static const GenericMatrix & | require_matrix (const GenericLinearOperator &A)
static std::shared_ptr< const GenericMatrix > | require_matrix (std::shared_ptr< const GenericLinearOperator > A)

## 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.

## Member Enumeration Documentation

## norm_type

enum class dolfin::PETScKrylovSolver::norm_type

strong

Norm types used in convergence testing. Not all solvers types support all norm types (see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetNormType.html). Note that 'default' is a reserved keyword, so we use 'default_norm'

## Constructor & Destructor Documentation

## PETScKrylovSolver() [1/4]

PETScKrylovSolver::PETScKrylovSolver | ( | MPI_Comm | comm,
|  | std::string | method = "default",
|  | std::string | preconditioner = "default" )

Create Krylov solver for a particular method and named preconditioner

## PETScKrylovSolver() [2/4]

PETScKrylovSolver::PETScKrylovSolver | ( | std::string | method = "default",
|  | std::string | preconditioner = "default" )

Create Krylov solver for a particular method and named preconditioner

## PETScKrylovSolver() [3/4]

PETScKrylovSolver::PETScKrylovSolver | ( | MPI_Comm | comm,
|  | std::string | method,
|  | std::shared_ptr< PETScPreconditioner > | preconditioner )

Create Krylov solver for a particular method and PETScPreconditioner (shared_ptr version)

## PETScKrylovSolver() [4/4]

PETScKrylovSolver::PETScKrylovSolver | ( | std::string | method,
|  | std::shared_ptr< PETScPreconditioner > | preconditioner )

Create Krylov solver for a particular method and PETScPreconditioner (shared_ptr version)

## Member Function Documentation

## get_options_prefix()

std::string PETScKrylovSolver::get_options_prefix | ( |  | ) | const

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

## parameter_type()

std::string dolfin::PETScKrylovSolver::parameter_type | ( |  | ) | const

inline virtual

Return parameter type: "krylov_solver" or "lu_solver".

Reimplemented from dolfin::GenericLinearSolver.

## set_nonzero_guess()

void PETScKrylovSolver::set_nonzero_guess | ( | bool | nonzero_guess | ) |

Use nonzero initial guess for solution function (nonzero_guess=true, the solution vector x will not be zeroed before the solver starts)

## set_norm_type()

void PETScKrylovSolver::set_norm_type | ( | norm_type | type | ) |

Set norm type used in convergence testing - not all solvers types support all norm types

## set_operator() [1/2]

void PETScKrylovSolver::set_operator | ( | const PETScBaseMatrix & | A | ) |

Set operator (PETScMatrix). This is memory-safe as PETSc will increase the reference count to the underlying PETSc object.

## set_operator() [2/2]

void PETScKrylovSolver::set_operator | ( | std::shared_ptr< const GenericLinearOperator > | A | ) |

virtual

Set operator (matrix).

Implements dolfin::GenericLinearSolver.

## set_operators() [1/2]

void PETScKrylovSolver::set_operators | ( | const PETScBaseMatrix & | A,
|  | const PETScBaseMatrix & | P )

Set operator and preconditioner matrix (PETScMatrix). This is memory-safe as PETSc will increase the reference count to the underlying PETSc objects.

## set_operators() [2/2]

void PETScKrylovSolver::set_operators | ( | std::shared_ptr< const GenericLinearOperator > | A,
|  | std::shared_ptr< const GenericLinearOperator > | P )

virtual

Set operator (matrix) and preconditioner matrix.

Reimplemented from dolfin::GenericLinearSolver.

## set_options_prefix()

void PETScKrylovSolver::set_options_prefix | ( | std::string | options_prefix | ) |

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

## set_reuse_preconditioner()

void PETScKrylovSolver::set_reuse_preconditioner | ( | bool | reuse_pc | ) |

Reuse preconditioner if true, even if matrix operator changes (by default preconditioner will be re-built if the matrix changes)

## set_tolerances()

void PETScKrylovSolver::set_tolerances | ( | double | relative,
|  | double | absolute,
|  | double | diverged,
|  | int | max_iter )

Set tolerances (relative residual, alsolute residial, maximum number of iterations)

## solve() [1/4]

std::size_t PETScKrylovSolver::solve | ( | const GenericLinearOperator & | A,
|  | GenericVector & | x,
|  | const GenericVector & | b )

virtual

Solve linear system Ax = b and return number of iterations.

Reimplemented from dolfin::GenericLinearSolver.

## solve() [2/4]

std::size_t PETScKrylovSolver::solve | ( | GenericVector & | x,
|  | const GenericVector & | b )

virtual

Solve linear system Ax = b and return number of iterations.

Implements dolfin::GenericLinearSolver.

## solve() [3/4]

std::size_t PETScKrylovSolver::solve | ( | GenericVector & | x,
|  | const GenericVector & | b,
|  | bool | transpose )

Solve linear system Ax = b and return number of iterations (A^t x = b if transpose is true)

## solve() [4/4]

std::size_t PETScKrylovSolver::solve | ( | PETScVector & | x,
|  | const PETScVector & | b,
|  | bool | transpose = false )

Solve linear system Ax = b and return number of iterations (A^t x = b if transpose is true)

## str()

std::string PETScKrylovSolver::str | ( | bool | verbose | ) | const

virtual

Return informal string representation (pretty-print).

Reimplemented from dolfin::Variable.

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

- /build/dolfin-wwk1CC/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/la/PETScKrylovSolver.h
- /build/dolfin-wwk1CC/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/la/PETScKrylovSolver.cpp