Feel++ 0.91.0
|
#include <solverlinearpetsc.hpp>
Public Types | |
typedef super::value_type | value_type |
typedef super::real_type | real_type |
Public Member Functions | |
SolverLinearPetsc () | |
~SolverLinearPetsc () | |
void | clear () |
void | init () |
std::pair< unsigned int, real_type > | solve (MatrixSparse< T > const &mat, Vector< T > &x, Vector< T > const &b, const double tolerance, const unsigned int maxit, bool transpose) |
std::pair< unsigned int, real_type > | solve (MatrixSparse< T > const &mat, MatrixSparse< T > const &prec, Vector< T > &x, Vector< T > const &b, const double tolerance, const unsigned int maxit, bool transpose) |
PC | pc () |
void | getResidualHistory (std::vector< double > &hist) |
real_type | getInitialResidual () |
This class provides an interface to PETSc iterative solvers that is compatible with the libMesh
LinearSolver<>
Feel::SolverLinearPetsc< T >::SolverLinearPetsc | ( | ) | [inline] |
Constructor. Initializes Petsc data structures
Feel::SolverLinearPetsc< T >::~SolverLinearPetsc | ( | ) | [inline] |
Destructor.
void Feel::SolverLinearPetsc< T >::clear | ( | ) | [virtual] |
Release all memory and clear data structures.
Reimplemented from Feel::SolverLinear< T >.
SolverLinearPetsc< T >::real_type Feel::SolverLinearPetsc< T >::getInitialResidual | ( | ) |
Returns just the initial residual for the solve just completed with this interface. Use this method instead of the one above if you just want the starting residual and not the entire history.
void Feel::SolverLinearPetsc< T >::getResidualHistory | ( | std::vector< double > & | hist | ) |
Fills the input vector with the sequence of residual norms from the latest iterative solve.
void Feel::SolverLinearPetsc< T >::init | ( | ) | [virtual] |
Initialize data structures if not done so already.
Implements Feel::SolverLinear< T >.
Referenced by Feel::SolverLinearPetsc< double >::pc().
PC Feel::SolverLinearPetsc< T >::pc | ( | ) | [inline] |
Returns the raw PETSc preconditioner context pointer. This allows you to specify the PCShellSetApply() and PCShellSetSetUp() functions if you desire. Just don't do anything crazy like calling PCDestroy()!
std::pair<unsigned int, real_type> Feel::SolverLinearPetsc< T >::solve | ( | MatrixSparse< T > const & | mat, |
Vector< T > & | x, | ||
Vector< T > const & | b, | ||
const double | tolerance, | ||
const unsigned int | maxit, | ||
bool | transpose | ||
) | [inline, virtual] |
Call the Petsc solver. It calls the method below, using the same matrix for the system and preconditioner matrices.
mat | System Matrix |
prec | Preconditioning Matrix |
x | Solution vector |
b | RHS vector |
tolerance | Stopping tolerance |
maxit | maximum Number of Iterations |
transpose | true to solve the transpose system, false otherwise |
Implements Feel::SolverLinear< T >.
Referenced by Feel::SolverLinearPetsc< double >::solve().
std::pair< unsigned int, typename SolverLinearPetsc< T >::real_type > Feel::SolverLinearPetsc< T >::solve | ( | MatrixSparse< T > const & | mat, |
MatrixSparse< T > const & | prec, | ||
Vector< T > & | x, | ||
Vector< T > const & | b, | ||
const double | tolerance, | ||
const unsigned int | maxit, | ||
bool | transpose | ||
) | [virtual] |
This method allows you to call a linear solver while specifying the matrix to use as the (left) preconditioning matrix. Note that the linear solver will not compute a preconditioner in this case, and will instead premultiply by the matrix you provide.
In PETSc, this is accomplished by calling
PCSetType(_pc, PCMAT);
before invoking KSPSolve(). Note: this functionality is not implemented in the SolverLinear class since there is not a built-in analog to this method for LasPack -- You could probably implement it by hand if you wanted.
mat | System Matrix |
prec | Preconditioning Matrix |
x | Solution vector |
b | RHS vector |
tolerance | Stopping tolerance |
maxit | maximum Number of Iterations |
transpose | true to solve the transpose system, false otherwise |
Implements Feel::SolverLinear< T >.
References Feel::VectorPetsc< T >::close(), Feel::MatrixPetsc< T >::close(), Feel::MatrixPetsc< T >::mat(), and Feel::VectorPetsc< T >::vec().