OGS
PETScLinearSolver.h
Go to the documentation of this file.
1
17#pragma once
18
19#include <petscksp.h>
20
21#include <string>
22
23#include "PETScMatrix.h"
24#include "PETScVector.h"
25
26namespace MathLib
27{
36{
37public:
47 PETScLinearSolver(std::string const& prefix,
48 std::string const& petsc_options);
49
50 ~PETScLinearSolver() { KSPDestroy(&solver_); }
51 // TODO check if some args in LinearSolver interface can be made const&.
53
55 PetscInt getNumberOfIterations() const
56 {
57 PetscInt its = 0;
58 KSPGetIterationNumber(solver_, &its);
59 return its;
60 }
61
63 double getElapsedTime() const { return elapsed_ctime_; }
64
65private:
66 KSP solver_;
67 PC pc_;
68
69 double elapsed_ctime_ = 0.0;
70};
71
72} // namespace MathLib
Declaration of class PETScMatrix, which provides an interface to PETSc matrix routines.
Declaration of class PETScVector, which provides an interface to PETSc vector routines.
double elapsed_ctime_
Clock time.
PETScLinearSolver(std::string const &prefix, std::string const &petsc_options)
PetscInt getNumberOfIterations() const
Get number of iterations.
PC pc_
Preconditioner type.
bool solve(PETScMatrix &A, PETScVector &b, PETScVector &x)
double getElapsedTime() const
Get elapsed wall clock time.
Wrapper class for PETSc matrix routines for matrix.
Definition PETScMatrix.h:32
Wrapper class for PETSc vector.
Definition PETScVector.h:40