solver.cc
Go to the documentation of this file.
#include "rheolef/solver.h"
#include "rheolef/pretty_name.h"
#include "solver_gmres_cg.h"
#include "solver_eigen.h"
#include "solver_cholmod.h"
#include "solver_umfpack.h"
#include "solver_mumps.h"
// no more supported:
#include "solver_pastix.h" // portage pb on new version
namespace rheolef {
// ----------------------------------------------------------------------------
// utility
// ----------------------------------------------------------------------------
template <class T, class M>
std::string
solver_abstract_rep<T,M>::name() const
{
return typeid_name(typeid(*this).name(),false);
}
// ----------------------------------------------------------------------------
// choose the best solver
// ----------------------------------------------------------------------------
template<class T, class M>
solver_abstract_rep<T,M>*
solver_abstract_rep<T,M>::make_solver_ptr (const csr<T,M>& a, const solver_option& opt)
{
using namespace std;
// --------------------------------------------------------------------------
// 1d, 2d => direct ; 3d => iterative
// --------------------------------------------------------------------------
bool is_direct = opt.iterative == 0 ||
(opt.iterative == solver_option::decide && a.pattern_dimension() <= 2);
// --------------------------------------------------------------------------
// iterative: no choice here, only the cg/gmres pair (choice on preconditioner)
// --------------------------------------------------------------------------
if (!is_direct) {
using rep = solver_gmres_cg_rep<T,M>;
return new_macro (rep(a,opt));
}
string lib = solver_option::used_library (a,opt);
// --------------------------------------------------------------------------
// direct & sequential
// * when symmetry: eigen, mumps, cholmod(bof)
// * when no-symmetry: umfpack, mumps, eigen
// direct & distributed: only mumps
// --------------------------------------------------------------------------
#ifdef _RHEOLEF_HAVE_MUMPS
if (lib == "mumps") {
using rep = solver_mumps_rep<T,M>;
return new_macro (rep(a,opt));
}
#endif // _RHEOLEF_HAVE_MUMPS
#if defined(_RHEOLEF_HAVE_CHOLMOD)
if (lib == "suitesparse" && a.is_symmetric() && a.is_definite_positive()) {
using rep = solver_cholmod_rep<T,M>;
return new_macro (rep(a,opt));
}
#endif // _RHEOLEF_HAVE_CHOLMOD
#if defined(_RHEOLEF_HAVE_UMFPACK)
if (lib == "suitesparse") {
using rep = solver_umfpack_rep<T,M>;
return new_macro (rep(a,opt));
}
#endif // _RHEOLEF_HAVE_UMFPACK
#ifdef _RHEOLEF_HAVE_EIGEN
if (lib == "eigen") {
using rep = solver_eigen_rep<T,M>;
return new_macro (rep(a,opt));
}
#endif // _RHEOLEF_HAVE_EIGEN
error_macro ("no direct solver available"); // should not apppend
return 0;
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T,M) \
template solver_abstract_rep<T,M>* solver_abstract_rep<T,M>::make_solver_ptr (const csr<T,M>&, const solver_option&); \
template std::string solver_abstract_rep<T,M>::name() const;
_RHEOLEF_instanciation(Float,sequential)
#ifdef _RHEOLEF_HAVE_MPI
_RHEOLEF_instanciation(Float,distributed)
#endif // _RHEOLEF_HAVE_MPI
#undef _RHEOLEF_instanciation
} // namespace rheolef
rheolef::typeid_name
std::string typeid_name(const char *name, bool do_indent)
Definition: pretty_name.cc:78
solver_umfpack.h
solver_eigen.h
rheolef::_RHEOLEF_instanciation
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float
rheolef::solver_abstract_rep::make_solver_ptr
static solver_abstract_rep< T, M > * make_solver_ptr(const csr< T, M > &a, const solver_option &opt)
Definition: solver.cc:49
rheolef::solver_abstract_rep
Definition: solver.h:191
solver_mumps.h
solver_pastix.h
a
Definition: diffusion_isotropic.h:25
rheolef::solver_abstract_rep::name
virtual std::string name() const
Definition: solver.cc:40
rheolef::csr< T, M >
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
rheolef::solver_option::used_library
static std::string used_library(const csr< T, M > &a, const solver_option &sopt=solver_option())
Definition: solver_option.h:281
Float
see the Float page for the full documentation
rheolef::solver_mumps_rep
Definition: solver_mumps.h:39
solver_cholmod.h
rheolef::solver_umfpack_rep
Definition: solver_umfpack.h:40
rheolef::solver_gmres_cg_rep
Definition: solver_gmres_cg.h:27
solver_gmres_cg.h
rheolef::solver_option::iterative
long int iterative
Definition: solver_option.h:159
rheolef::solver_cholmod_rep
Definition: solver_cholmod.h:40
rheolef::distributed
distributed
Definition: asr.cc:228
rheolef::solver_eigen_rep
Definition: solver_eigen.h:42
rheolef::std
Definition: vec_expr_v2.h:391
rheolef::solver_option::decide
static const long int decide
Definition: solver_option.h:158
rheolef::solver_option
see the solver_option page for the full documentation
Definition: solver_option.h:155