![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
A linear solver class wrapping PETSc KSP solvers. More...
#include <linear_solver.hpp>
Public Types | |
| enum | Type { CG , GMRES , BiCGStab , MINRES , PrecondOnly } |
| Enumeration of available solver types. More... | |
| enum | PrecondType { NoPrecond , Jacobi , SOR , ASM , BlockJacobi , BoomerAMG , EuclidILU , LU , Cholesky , SuperLU , MUMPS , GAMG } |
| Enumeration of available preconditioner types. More... | |
Public Member Functions | |
| LinearSolver (Type solver_type=CG, PrecondType pc_type=Jacobi) | |
| Construct a LinearSolver with specified solver and preconditioner types. | |
| LinearSolver (const LinearSolver &)=delete | |
| LinearSolver & | operator= (const LinearSolver &)=delete |
| void | setType (Type solver_type) |
| Set the type of the linear solver. | |
| void | setPreconditioner (PrecondType pc_type) |
| Set the type of the preconditioner. | |
| void | setTolerances (PetscReal rtol, PetscReal abstol, PetscReal dtol, PetscInt maxits) |
| Set the solver tolerances. | |
| void | setRelativeTolerance (PetscReal rtol) |
| Set the relative tolerance. | |
| void | setAbsoluteTolerance (PetscReal abstol) |
| Set the absolute tolerance. | |
| void | setMaxIterations (PetscInt maxits) |
| Set the maximum iterations. | |
| void | setInitialGuessNonzero (bool nonzero) |
| Set the initial guess to nonzero. | |
| void | setGMRESRestart (PetscInt restart) |
| Set the GMRES restart parameter. | |
| void | setSORParameters (PetscReal omega, PetscInt iterations=1, PetscReal rtol=0.0) |
| Set the SOR parameters. | |
| void | setOptionsBoomerAMG (DataBoomerAMG data) |
| Set options for the BoomerAMG preconditioner. | |
| void | setOptionsGAMG (const DataGAMG &data) |
| Set options for the GAMG preconditioner. | |
| void | setOperators (const SparseMatrix &A) |
| Set the system matrix. | |
| void | setOperators (const SparseMatrix &A, const SparseMatrix &P) |
| Set the system matrix and preconditioner matrix. | |
| void | solve (const Vector &b, Vector &x) |
| Solve the linear system Ax = b. | |
| void | applyPreconditioner (const Vector &b, Vector &x) |
| Apply the preconditioner only, x = P^{-1} b: the result of solve() for type PrecondOnly, without its collective convergence check. Aborts if this rank's preconditioner failed (e.g. a zero pivot). | |
| PetscInt | getIterationCount () |
| Get the number of iterations taken by the solver. | |
| void | setNormType (KSPNormType type) |
| Set the norm type for convergence testing. | |
| PetscReal | getResidualNorm () |
| Get the residual norm after the solve. | |
| KSPConvergedReason | getConvergenceReason () |
| Get the convergence reason. | |
| PC | getPC () |
| Get the preconditioner. | |
| const auto & | getKSP () const |
| Get the KSP object. | |
| void | printConvergenceInfo () |
| Print convergence information. | |
| ~LinearSolver () | |
Protected Member Functions | |
| void | init (Type solver_type=CG, PrecondType pc_type=Jacobi) |
| void | setUp () |
| Set up the KSP, applying the solver specific level smoother. | |
Protected Attributes | |
| KSP | m_ksp |
| bool | m_point_block_smoother = false |
| Use point-block Jacobi on the GAMG levels, see DataGAMG. | |
A linear solver class wrapping PETSc KSP solvers.
This class provides an interface to set up and solve linear systems using various Krylov subspace methods and preconditioners available in PETSc. Default tolerances: relative 1e-8, absolute 1e-10, at most 1000 iterations. KSPSetFromOptions is not called, so -ksp_* command-line options are ignored.
|
explicit |
Construct a LinearSolver with specified solver and preconditioner types.
| solver_type | The type of the linear solver |
| pc_type | The type of the preconditioner |
|
delete |
| vulpes::la::LinearSolver::~LinearSolver | ( | ) |
Apply the preconditioner only, x = P^{-1} b: the result of solve() for type PrecondOnly, without its collective convergence check. Aborts if this rank's preconditioner failed (e.g. a zero pivot).
| KSPConvergedReason vulpes::la::LinearSolver::getConvergenceReason | ( | ) |
Get the convergence reason.
| PetscInt vulpes::la::LinearSolver::getIterationCount | ( | ) |
Get the number of iterations taken by the solver.
|
inline |
Get the KSP object.
| PC vulpes::la::LinearSolver::getPC | ( | ) |
Get the preconditioner.
| PetscReal vulpes::la::LinearSolver::getResidualNorm | ( | ) |
Get the residual norm after the solve.
|
protected |
|
delete |
| void vulpes::la::LinearSolver::printConvergenceInfo | ( | ) |
Print convergence information.
| void vulpes::la::LinearSolver::setAbsoluteTolerance | ( | PetscReal | abstol | ) |
Set the absolute tolerance.
| void vulpes::la::LinearSolver::setGMRESRestart | ( | PetscInt | restart | ) |
Set the GMRES restart parameter.
| void vulpes::la::LinearSolver::setInitialGuessNonzero | ( | bool | nonzero | ) |
Set the initial guess to nonzero.
| void vulpes::la::LinearSolver::setMaxIterations | ( | PetscInt | maxits | ) |
Set the maximum iterations.
| void vulpes::la::LinearSolver::setNormType | ( | KSPNormType | type | ) |
Set the norm type for convergence testing.
| void vulpes::la::LinearSolver::setOperators | ( | const SparseMatrix & | A | ) |
Set the system matrix.
| void vulpes::la::LinearSolver::setOperators | ( | const SparseMatrix & | A, |
| const SparseMatrix & | P ) |
Set the system matrix and preconditioner matrix.
| void vulpes::la::LinearSolver::setOptionsBoomerAMG | ( | DataBoomerAMG | data | ) |
Set options for the BoomerAMG preconditioner.
| void vulpes::la::LinearSolver::setOptionsGAMG | ( | const DataGAMG & | data | ) |
Set options for the GAMG preconditioner.
| void vulpes::la::LinearSolver::setPreconditioner | ( | PrecondType | pc_type | ) |
Set the type of the preconditioner.
| void vulpes::la::LinearSolver::setRelativeTolerance | ( | PetscReal | rtol | ) |
Set the relative tolerance.
| void vulpes::la::LinearSolver::setSORParameters | ( | PetscReal | omega, |
| PetscInt | iterations = 1, | ||
| PetscReal | rtol = 0.0 ) |
Set the SOR parameters.
| void vulpes::la::LinearSolver::setTolerances | ( | PetscReal | rtol, |
| PetscReal | abstol, | ||
| PetscReal | dtol, | ||
| PetscInt | maxits ) |
Set the solver tolerances.
| rtol | Relative tolerance |
| abstol | Absolute tolerance |
| dtol | Divergence tolerance |
| maxits | Maximum iterations |
| void vulpes::la::LinearSolver::setType | ( | Type | solver_type | ) |
Set the type of the linear solver.
| solver_type | The type of the linear solver |
|
protected |
Set up the KSP, applying the solver specific level smoother.
Solve the linear system Ax = b.
| b | The right-hand side vector |
| x | The solution vector |
|
protected |
|
protected |
Use point-block Jacobi on the GAMG levels, see DataGAMG.