Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Feel::Backend< T > Class Template Referenceabstract

#include <backend.hpp>

Detailed Description

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

base class for all linear algebra backends

Author
Christophe Prud'homme
See Also
+ Inheritance diagram for Feel::Backend< T >:

Public Types

Typedefs
typedef T value_type
 
typedef type_traits< T >::real_type real_type
 
typedef Vector< value_type > vector_type
 
typedef boost::shared_ptr
< vector_type
vector_ptrtype
 
typedef MatrixSparse< value_type > sparse_matrix_type
 
typedef boost::shared_ptr
< sparse_matrix_type
sparse_matrix_ptrtype
 
typedef MatrixShell< value_type > shell_matrix_type
 
typedef boost::shared_ptr
< shell_matrix_type
shell_matrix_ptrtype
 
typedef
sparse_matrix_type::graph_type 
graph_type
 
typedef
sparse_matrix_type::graph_ptrtype 
graph_ptrtype
 
typedef Backend< value_type > backend_type
 
typedef boost::shared_ptr
< backend_type
backend_ptrtype
 
typedef SolverNonLinear
< value_type > 
solvernonlinear_type
 
typedef boost::shared_ptr
< solvernonlinear_type
solvernonlinear_ptrtype
 
typedef boost::tuple< bool,
size_type, value_type > 
solve_return_type
 
typedef boost::tuple< bool,
size_type, value_type > 
nl_solve_return_type
 
typedef DataMap datamap_type
 
typedef boost::shared_ptr
< datamap_type
datamap_ptrtype
 

Public Member Functions

Accessors
std::string prefix () const
 
std::string kspType () const
 
std::string pcType () const
 
bool hasConstantNullSpace () const
 
std::string fieldsplitType () const
 
PreconditionerType pcEnumType () const
 
SolverType kspEnumType () const
 
FieldSplitType fieldSplitEnumType () const
 
std::string pcFactorMatSolverPackageType () const
 
MatSolverPackageType matSolverPackageEnumType () const
 
MatrixStructure precMatrixStructure () const
 
value_type rTolerance () const
 
value_type rToleranceSNES () const
 
value_type dTolerance () const
 
value_type sToleranceSNES () const
 
value_type aTolerance () const
 
value_type aToleranceSNES () const
 
size_type maxIterations () const
 
size_type maxIterationsSNES () const
 
value_type rtoleranceKSPinSNES () const
 
bool converged () const
 
size_type nIterations () const
 
bool transpose () const
 
WorldComm const & comm () const
 
bool showKSPMonitor () const
 
bool showSNESMonitor () const
 
bool showKSPConvergedReason () const
 
bool showSNESConvergedReason () const
 
bool reusePrec () const
 
bool reuseJac () const
 
bool reusePrecRebuildAtFirstNewtonStep () const
 
bool reuseJacRebuildAtFirstNewtonStep () const
 
BackendType type () const
 
Mutators
void setPrecMatrixStructure (MatrixStructure mstruct)
 
solvernonlinear_ptrtype nlSolver ()
 
void setTranspose (bool transpose)
 
void setShowKSPMonitor (bool b)
 
void setShowSNESMonitor (bool b)
 
void setShowKSPConvergedReason (bool b)
 
void setShowSNESConvergedReason (bool b)
 
void setReusePrec (bool b)
 
void setReuseJac (bool b)
 
void setReusePrecRebuildAtFirstNewtonStep (bool b)
 
void setReuseJacRebuildAtFirstNewtonStep (bool b)
 
Methods
virtual void clear ()
 
virtual real_type dot (vector_type const &x, vector_type const &y) const
 
real_type dot (vector_ptrtype const &x, vector_ptrtype const &y) const
 
virtual void prod (sparse_matrix_type const &A, vector_type const &x, vector_type &y) const =0
 
void prod (sparse_matrix_ptrtype const &A, vector_ptrtype const &x, vector_ptrtype &y) const
 
virtual solve_return_type solve (sparse_matrix_ptrtype const &A, sparse_matrix_ptrtype const &P, vector_ptrtype &x, vector_ptrtype const &b)=0
 
solve_return_type solve (sparse_matrix_ptrtype const &A, sparse_matrix_ptrtype const &P, vector_ptrtype &x, vector_ptrtype const &b, bool reuse_prec)
 
virtual nl_solve_return_type nlSolve (sparse_matrix_ptrtype &A, vector_ptrtype &x, vector_ptrtype &b, const double, const int)
 
virtual nl_solve_return_type nlSolve (sparse_matrix_ptrtype &A, vector_ptrtype &x, vector_ptrtype &b, const double, const int, bool reusePC, bool reuseJAC)
 
void attachPreconditioner (preconditioner_ptrtype preconditioner)
 
template<typename Observer >
void addDeleteObserver (Observer const &obs)
 
template<typename Observer >
void addDeleteObserver (boost::shared_ptr< Observer > const &obs)
 
void sendDeleteSignal ()
 

Protected Attributes

preconditioner_ptrtype M_preconditioner
 

Constructors, destructor

 Backend (WorldComm const &worldComm=Environment::worldComm())
 
 Backend (po::variables_map const &vm, std::string const &prefix="", WorldComm const &worldComm=Environment::worldComm())
 
 Backend (Backend const &)
 
virtual ~Backend ()
 
virtual sparse_matrix_ptrtype newMatrix (const size_type m, const size_type n, const size_type m_l, const size_type n_l, const size_type nnz=30, const size_type noz=10, size_type prop=NON_HERMITIAN)=0
 
virtual sparse_matrix_ptrtype newMatrix (const size_type m, const size_type n, const size_type m_l, const size_type n_l, graph_ptrtype const &graph, size_type matrix_properties=NON_HERMITIAN)=0
 
sparse_matrix_ptrtype newMatrix (const size_type m, const size_type n, const size_type m_l, const size_type n_l, graph_ptrtype const &graph, std::vector< std::vector< size_type > > indexSplit, size_type matrix_properties=NON_HERMITIAN)
 
virtual sparse_matrix_ptrtype newMatrix (datamap_ptrtype const &dm1, datamap_ptrtype const &dm2, size_type prop=NON_HERMITIAN, bool init=true)=0
 
sparse_matrix_ptrtype newMatrix (datamap_ptrtype const &domainmap, datamap_ptrtype const &imagemap, graph_ptrtype const &graph, size_type matrix_properties=NON_HERMITIAN, bool init=true)
 
virtual sparse_matrix_ptrtype newZeroMatrix (const size_type m, const size_type n, const size_type m_l, const size_type n_l)=0
 
virtual sparse_matrix_ptrtype newZeroMatrix (datamap_ptrtype const &dm1, datamap_ptrtype const &dm2)=0
 
template<typename DomainSpace , typename ImageSpace >
sparse_matrix_ptrtype newMatrix (DomainSpace const &dm, ImageSpace const &im, sparse_matrix_ptrtype const &M, size_type prop=NON_HERMITIAN)
 
sparse_matrix_ptrtype newBlockMatrixImpl (vf::BlocksBase< sparse_matrix_ptrtype > const &b, bool copy_values=true, bool diag_is_nonzero=true)
 
sparse_matrix_ptrtype newBlockMatrixImpl (vf::BlocksBase< boost::shared_ptr< GraphCSR > > const &b, bool copy_values=true, bool diag_is_nonzero=true)
 
template<typename BlockType = vector_ptrtype>
vector_ptrtype newBlockVectorImpl (vf::BlocksBase< BlockType > const &b, bool copy_values=true)
 
virtual vector_ptrtype newVector (datamap_ptrtype const &dm)=0
 
virtual vector_ptrtype newVector (const size_type n, const size_type n_local)=0
 
static backend_ptrtype build (BackendType=BACKEND_GMM, WorldComm const &worldComm=Environment::worldComm())
 
static backend_ptrtype build (po::variables_map const &vm, std::string const &prefix="", WorldComm const &worldComm=Environment::worldComm())
 

Member Function Documentation

template<typename T>
template<typename Observer >
void Feel::Backend< T >::addDeleteObserver ( Observer const &  obs)
inline

register a backend observer for the delete signal of backend

template<typename T>
template<typename Observer >
void Feel::Backend< T >::addDeleteObserver ( boost::shared_ptr< Observer > const &  obs)
inline

register a backend observer for the delete signal of backend that is a shared_ptr<>

template<typename T>
value_type Feel::Backend< T >::aTolerance ( ) const
inline
Returns
the absolute tolerance
template<typename T>
value_type Feel::Backend< T >::aToleranceSNES ( ) const
inline
Returns
the SNES absolute tolerance
template<typename T>
void Feel::Backend< T >::attachPreconditioner ( preconditioner_ptrtype  preconditioner)
inline

Attaches a Preconditioner object to be used by the solver

template<typename T >
Backend< T >::backend_ptrtype Feel::Backend< T >::build ( BackendType  bt = BACKEND_GMM,
WorldComm const &  worldComm = Environment::worldComm() 
)
static

Builds a Backend, if Petsc is available, use Petsc by default, otherwise use GMM which is distributed with feel

template<typename T >
Backend< T >::backend_ptrtype Feel::Backend< T >::build ( po::variables_map const &  vm,
std::string const &  prefix = "",
WorldComm const &  worldComm = Environment::worldComm() 
)
static

Builds a Backend

template<typename T >
void Feel::Backend< T >::clear ( )
virtual

clean up

template<typename T>
WorldComm const& Feel::Backend< T >::comm ( ) const
inline
Returns
the communicator
template<typename T >
Backend< T >::real_type Feel::Backend< T >::dot ( vector_type const &  x,
vector_type const &  y 
) const
virtual
template<typename T>
real_type Feel::Backend< T >::dot ( vector_ptrtype const &  x,
vector_ptrtype const &  y 
) const
inline
Returns
$ r = x^T * y $

References Feel::Backend< T >::dot().

template<typename T>
value_type Feel::Backend< T >::dTolerance ( ) const
inline
Returns
the divergence tolerance
template<typename T >
FieldSplitType Feel::Backend< T >::fieldSplitEnumType ( ) const
Returns
enum fieldsplit type from options
template<typename T>
std::string Feel::Backend< T >::fieldsplitType ( ) const
inline
Returns
the type of fieldsplitType
template<typename T>
bool Feel::Backend< T >::hasConstantNullSpace ( ) const
inline

return true if the null space is the constant values, false otherwise

template<typename T >
SolverType Feel::Backend< T >::kspEnumType ( ) const
Returns
enum solver type from options
template<typename T>
std::string Feel::Backend< T >::kspType ( ) const
inline
Returns
the type of linear solver
template<typename T >
MatSolverPackageType Feel::Backend< T >::matSolverPackageEnumType ( ) const
Returns
enum MatSolverPackage type from options
template<typename T>
size_type Feel::Backend< T >::maxIterations ( ) const
inline
Returns
the maximum number of iterations
template<typename T>
size_type Feel::Backend< T >::maxIterationsSNES ( ) const
inline
Returns
the maximum number of SNES iterations
template<typename T>
sparse_matrix_ptrtype Feel::Backend< T >::newBlockMatrixImpl ( vf::BlocksBase< sparse_matrix_ptrtype > const &  b,
bool  copy_values = true,
bool  diag_is_nonzero = true 
)
inline

instantiate a new block matrix sparse

template<typename T>
template<typename BlockType = vector_ptrtype>
vector_ptrtype Feel::Backend< T >::newBlockVectorImpl ( vf::BlocksBase< BlockType > const &  b,
bool  copy_values = true 
)
inline

instantiate a new block matrix sparse

template<typename T>
virtual sparse_matrix_ptrtype Feel::Backend< T >::newMatrix ( const size_type  m,
const size_type  n,
const size_type  m_l,
const size_type  n_l,
const size_type  nnz = 30,
const size_type  noz = 10,
size_type  prop = NON_HERMITIAN 
)
pure virtual

instantiate a new sparse vector

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T>
virtual sparse_matrix_ptrtype Feel::Backend< T >::newMatrix ( const size_type  m,
const size_type  n,
const size_type  m_l,
const size_type  n_l,
graph_ptrtype const &  graph,
size_type  matrix_properties = NON_HERMITIAN 
)
pure virtual

instantiate a new sparse vector

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T>
sparse_matrix_ptrtype Feel::Backend< T >::newMatrix ( const size_type  m,
const size_type  n,
const size_type  m_l,
const size_type  n_l,
graph_ptrtype const &  graph,
std::vector< std::vector< size_type > >  indexSplit,
size_type  matrix_properties = NON_HERMITIAN 
)
inline

instantiate a new sparse vector

References Feel::Backend< T >::newMatrix().

template<typename T>
virtual sparse_matrix_ptrtype Feel::Backend< T >::newMatrix ( datamap_ptrtype const &  dm1,
datamap_ptrtype const &  dm2,
size_type  prop = NON_HERMITIAN,
bool  init = true 
)
pure virtual

instantiate a new sparse vector

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T>
sparse_matrix_ptrtype Feel::Backend< T >::newMatrix ( datamap_ptrtype const &  domainmap,
datamap_ptrtype const &  imagemap,
graph_ptrtype const &  graph,
size_type  matrix_properties = NON_HERMITIAN,
bool  init = true 
)
inline

instantiate a new sparse vector

References Feel::Backend< T >::newMatrix().

template<typename T>
virtual vector_ptrtype Feel::Backend< T >::newVector ( datamap_ptrtype const &  dm)
pure virtual

instantiate a new vector

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T>
virtual vector_ptrtype Feel::Backend< T >::newVector ( const size_type  n,
const size_type  n_local 
)
pure virtual

instantiate a new vector

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T>
virtual sparse_matrix_ptrtype Feel::Backend< T >::newZeroMatrix ( const size_type  m,
const size_type  n,
const size_type  m_l,
const size_type  n_l 
)
pure virtual

instantiate a new sparse vector

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T >
Backend< T >::nl_solve_return_type Feel::Backend< T >::nlSolve ( sparse_matrix_ptrtype &  A,
vector_ptrtype &  x,
vector_ptrtype &  b,
const double  tol,
const int  its 
)
virtual

solve for the nonlinear problem $F( u ) = 0$

template<typename T >
Backend< T >::nl_solve_return_type Feel::Backend< T >::nlSolve ( sparse_matrix_ptrtype &  A,
vector_ptrtype &  x,
vector_ptrtype &  b,
const double  tol,
const int  its,
bool  reusePC,
bool  reuseJAC 
)
virtual

solve for the nonlinear problem $F( u ) = 0$ with an adaptive strategy to reuse the preconditioner

template<typename T>
solvernonlinear_ptrtype Feel::Backend< T >::nlSolver ( )
inline
Returns
the non linear solver
template<typename T >
PreconditionerType Feel::Backend< T >::pcEnumType ( ) const
Returns
enum pc type from options
template<typename T>
std::string Feel::Backend< T >::pcFactorMatSolverPackageType ( ) const
inline
Returns
the type of pcFactorMatSolverPackageType
template<typename T>
std::string Feel::Backend< T >::pcType ( ) const
inline
Returns
the type of preconditioner
template<typename T>
MatrixStructure Feel::Backend< T >::precMatrixStructure ( ) const
inline
Returns
the type of preconditioner associated to the matrix
template<typename T>
std::string Feel::Backend< T >::prefix ( ) const
inline
Returns
prefix of backend
template<typename T>
virtual void Feel::Backend< T >::prod ( sparse_matrix_type const &  A,
vector_type const &  x,
vector_type y 
) const
pure virtual
Returns
$ y = A * x $

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T>
void Feel::Backend< T >::prod ( sparse_matrix_ptrtype const &  A,
vector_ptrtype const &  x,
vector_ptrtype &  y 
) const
inline
Returns
$ y = A * x $

References Feel::Backend< T >::prod().

template<typename T>
value_type Feel::Backend< T >::rTolerance ( ) const
inline
Returns
the relative tolerance
template<typename T>
value_type Feel::Backend< T >::rtoleranceKSPinSNES ( ) const
inline
Returns
the KSP relative tolerance in SNES
template<typename T>
value_type Feel::Backend< T >::rToleranceSNES ( ) const
inline
Returns
the relative tolerance SNES
template<typename T>
void Feel::Backend< T >::sendDeleteSignal ( )
inline

send the delete signal to all observers

template<typename T>
void Feel::Backend< T >::setPrecMatrixStructure ( MatrixStructure  mstruct)
inline

set the type of preconditioner associated to the matrix

template<typename T>
virtual solve_return_type Feel::Backend< T >::solve ( sparse_matrix_ptrtype const &  A,
sparse_matrix_ptrtype const &  P,
vector_ptrtype &  x,
vector_ptrtype const &  b 
)
pure virtual

solve for $P A x = P b$ where $P$ is an approximation of the inverse of $A$.

Parameters
Amatrix to inverse
rhsright hand side vector
solutionsolution of the system
Ppreconditioner
maxitmaximum number of iterations
tolerancetolerance on the residual
transposeif true solve the transpose problem
Warning
some parameter may not be meaningful for all backends

Implemented in Feel::BackendEigen< T, _Options >.

template<typename T >
Backend< T >::solve_return_type Feel::Backend< T >::solve ( sparse_matrix_ptrtype const &  A,
sparse_matrix_ptrtype const &  P,
vector_ptrtype &  x,
vector_ptrtype const &  b,
bool  reuse_prec 
)

solve for $P A x = P b$ where $P$ is an approximation of the inverse of $A$ using an adaptive preconditioning strategy.

Parameters
Amatrix to inverse
rhsright hand side vector
solutionsolution of the system
Ppreconditioner
maxitmaximum number of iterations
tolerancetolerance on the residual
transposeif true solve the transpose problem
Warning
some parameter may not be meaningful for all backends
template<typename T>
value_type Feel::Backend< T >::sToleranceSNES ( ) const
inline
Returns
the SNES step length tolerance

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

Generated on Sun Oct 20 2013 08:25:07 for Feel++ by doxygen 1.8.4