Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
solver.cc
Go to the documentation of this file.
1
21#include "rheolef/solver.h"
22#include "rheolef/pretty_name.h"
23
24#include "solver_gmres_cg.h"
25#include "solver_eigen.h"
26#include "solver_cholmod.h"
27#include "solver_umfpack.h"
28#include "solver_mumps.h"
29
30// no more supported:
31#include "solver_pastix.h" // portage pb on new version
32
33namespace rheolef {
34
35// ----------------------------------------------------------------------------
36// utility
37// ----------------------------------------------------------------------------
38template <class T, class M>
39std::string
41{
42 return typeid_name(typeid(*this).name(),false);
43}
44// ----------------------------------------------------------------------------
45// choose the best solver
46// ----------------------------------------------------------------------------
47template<class T, class M>
50{
51 using namespace std;
52 // --------------------------------------------------------------------------
53 // 1d, 2d => direct ; 3d => iterative
54 // --------------------------------------------------------------------------
55 bool is_direct = opt.iterative == 0 ||
56 (opt.iterative == solver_option::decide && a.pattern_dimension() <= 2);
57
58 // --------------------------------------------------------------------------
59 // iterative: no choice here, only the cg/gmres pair (choice on preconditioner)
60 // --------------------------------------------------------------------------
61 if (!is_direct) {
62 using rep = solver_gmres_cg_rep<T,M>;
63 return new_macro (rep(a,opt));
64 }
65 string lib = solver_option::used_library (a,opt);
66 // --------------------------------------------------------------------------
67 // direct & sequential
68 // * when symmetry: eigen, mumps, cholmod(bof)
69 // * when no-symmetry: umfpack, mumps, eigen
70 // direct & distributed: only mumps
71 // --------------------------------------------------------------------------
72#ifdef _RHEOLEF_HAVE_MUMPS
73 if (lib == "mumps") {
74 using rep = solver_mumps_rep<T,M>;
75 return new_macro (rep(a,opt));
76 }
77#endif // _RHEOLEF_HAVE_MUMPS
78
79#if defined(_RHEOLEF_HAVE_CHOLMOD)
80 if (lib == "suitesparse" && a.is_symmetric() && a.is_definite_positive()) {
81 using rep = solver_cholmod_rep<T,M>;
82 return new_macro (rep(a,opt));
83 }
84#endif // _RHEOLEF_HAVE_CHOLMOD
85
86#if defined(_RHEOLEF_HAVE_UMFPACK)
87 if (lib == "suitesparse") {
88 using rep = solver_umfpack_rep<T,M>;
89 return new_macro (rep(a,opt));
90 }
91#endif // _RHEOLEF_HAVE_UMFPACK
92
93#ifdef _RHEOLEF_HAVE_EIGEN
94 if (lib == "eigen") {
95 using rep = solver_eigen_rep<T,M>;
96 return new_macro (rep(a,opt));
97 }
98#endif // _RHEOLEF_HAVE_EIGEN
99
100 error_macro ("no direct solver available"); // should not apppend
101 return 0;
102}
103// ----------------------------------------------------------------------------
104// instanciation in library
105// ----------------------------------------------------------------------------
106#define _RHEOLEF_instanciation(T,M) \
107template solver_abstract_rep<T,M>* solver_abstract_rep<T,M>::make_solver_ptr (const csr<T,M>&, const solver_option&); \
108template std::string solver_abstract_rep<T,M>::name() const;
109
111#ifdef _RHEOLEF_HAVE_MPI
112_RHEOLEF_instanciation(Float,distributed)
113#endif // _RHEOLEF_HAVE_MPI
114#undef _RHEOLEF_instanciation
115
116} // namespace rheolef
#define _RHEOLEF_instanciation(T, M, A)
Definition asr.cc:223
see the Float page for the full documentation
see the csr page for the full documentation
Definition csr.h:317
virtual std::string name() const
Definition solver.cc:40
static solver_abstract_rep< T, M > * make_solver_ptr(const csr< T, M > &a, const solver_option &opt)
Definition solver.cc:49
see the solver_option page for the full documentation
static const long int decide
static std::string used_library(const csr< T, M > &a, const solver_option &sopt=solver_option())
#define error_macro(message)
Definition dis_macros.h:49
This file is part of Rheolef.
std::string typeid_name(const char *name, bool do_indent)
STL namespace.