Feel++ 0.91.0
Public Types | Public Member Functions

Feel::SolverLinearPetsc< T > Class Template Reference

#include <solverlinearpetsc.hpp>

Inheritance diagram for Feel::SolverLinearPetsc< T >:
Feel::SolverLinear< T >

List of all members.

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 ()

Detailed Description

template<typename T>
class Feel::SolverLinearPetsc< T >

This class provides an interface to PETSc iterative solvers that is compatible with the libMesh LinearSolver<>

Author:
Benjamin Kirk, 2002-2005
Christophe Prud'homme, 2005

Constructor & Destructor Documentation

template<typename T >
Feel::SolverLinearPetsc< T >::SolverLinearPetsc ( ) [inline]

Constructor. Initializes Petsc data structures

template<typename T >
Feel::SolverLinearPetsc< T >::~SolverLinearPetsc ( ) [inline]

Destructor.


Member Function Documentation

template<typename T >
void Feel::SolverLinearPetsc< T >::clear ( ) [virtual]

Release all memory and clear data structures.

Reimplemented from Feel::SolverLinear< T >.

template<typename 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.

template<typename T >
void Feel::SolverLinearPetsc< T >::getResidualHistory ( std::vector< double > &  hist)

Fills the input vector with the sequence of residual norms from the latest iterative solve.

template<typename T >
void Feel::SolverLinearPetsc< T >::init ( ) [virtual]

Initialize data structures if not done so already.

Implements Feel::SolverLinear< T >.

Referenced by Feel::SolverLinearPetsc< double >::pc().

template<typename T>
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()!

template<typename T>
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.

Parameters:
matSystem Matrix
precPreconditioning Matrix
xSolution vector
bRHS vector
toleranceStopping tolerance
maxitmaximum Number of Iterations
transposetrue to solve the transpose system, false otherwise

Implements Feel::SolverLinear< T >.

Referenced by Feel::SolverLinearPetsc< double >::solve().

template<typename T>
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.

Parameters:
matSystem Matrix
precPreconditioning Matrix
xSolution vector
bRHS vector
toleranceStopping tolerance
maxitmaximum Number of Iterations
transposetrue 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().