OGS
EigenOption.cpp
Go to the documentation of this file.
1
11#include "EigenOption.h"
12
13#include "BaseLib/Error.h"
14
15namespace MathLib
16{
18{
21 max_iterations = static_cast<int>(1e6);
22 error_tolerance = 1.e-16;
23#ifdef USE_EIGEN_UNSUPPORTED
24 scaling = false;
25 restart = 30;
26 l = 2;
27 s = 4;
28 angle = 0.7;
29 smoothing = false;
30 residualupdate = false;
31#endif
32}
33
35 const std::string& solver_name)
36{
37 if (solver_name == "CG")
38 {
39 return SolverType::CG;
40 }
41 if (solver_name == "LeastSquareCG")
42 {
44 }
45 if (solver_name == "BiCGSTAB")
46 {
48 }
49 if (solver_name == "BiCGSTABL")
50 {
52 }
53 if (solver_name == "IDRS")
54 {
55 return SolverType::IDRS;
56 }
57 if (solver_name == "IDRSTABL")
58 {
60 }
61 if (solver_name == "SparseLU")
62 {
64 }
65 if (solver_name == "PardisoLU")
66 {
68 }
69 if (solver_name == "GMRES")
70 {
71 return SolverType::GMRES;
72 }
73
74 OGS_FATAL("Unknown Eigen solver type `{:s}'", solver_name);
75}
76
78 const std::string& precon_name)
79{
80 if (precon_name == "NONE")
81 {
82 return PreconType::NONE;
83 }
84 if (precon_name == "DIAGONAL")
85 {
87 }
88 if (precon_name == "LeastSquareDIAGONAL")
89 {
91 }
92 if (precon_name == "ILUT")
93 {
94 return PreconType::ILUT;
95 }
96
97 OGS_FATAL("Unknown Eigen preconditioner type `{:s}'", precon_name);
98}
99
100std::string EigenOption::getSolverName(SolverType const solver_type)
101{
102 switch (solver_type)
103 {
104 case SolverType::CG:
105 return "CG";
107 return "LeastSquareCG";
109 return "BiCGSTAB";
111 return "BiCGSTABL";
112 case SolverType::IDRS:
113 return "IDRS";
115 return "IDRSTABL";
117 return "SparseLU";
119 return "PardisoLU";
121 return "GMRES";
122 }
123 return "Invalid";
124}
125
126std::string EigenOption::getPreconName(PreconType const precon_type)
127{
128 switch (precon_type)
129 {
130 case PreconType::NONE:
131 return "NONE";
133 return "DIAGONAL";
135 return "LeastSquareDIAGONAL";
136 case PreconType::ILUT:
137 return "ILUT";
138 }
139 return "Invalid";
140}
141
142} // namespace MathLib
#define OGS_FATAL(...)
Definition Error.h:26
static const double s
PreconType precon_type
Preconditioner type.
Definition EigenOption.h:46
static std::string getSolverName(SolverType const solver_type)
return a linear solver name from the solver type
PreconType
Preconditioner type.
Definition EigenOption.h:36
static PreconType getPreconType(const std::string &precon_name)
SolverType solver_type
Linear solver type.
Definition EigenOption.h:44
double error_tolerance
Error tolerance.
Definition EigenOption.h:50
SolverType
Solver type.
Definition EigenOption.h:22
static SolverType getSolverType(const std::string &solver_name)
static std::string getPreconName(PreconType const precon_type)
return a preconditioner name from the preconditioner type
int max_iterations
Maximum iteration count.
Definition EigenOption.h:48