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 == "BiCGSTAB")
42 {
44 }
45 if (solver_name == "BiCGSTABL")
46 {
48 }
49 if (solver_name == "IDRS")
50 {
51 return SolverType::IDRS;
52 }
53 if (solver_name == "IDRSTABL")
54 {
56 }
57 if (solver_name == "SparseLU")
58 {
60 }
61 if (solver_name == "PardisoLU")
62 {
64 }
65 if (solver_name == "GMRES")
66 {
67 return SolverType::GMRES;
68 }
69
70 OGS_FATAL("Unknown Eigen solver type `{:s}'", solver_name);
71}
72
74 const std::string& precon_name)
75{
76 if (precon_name == "NONE")
77 {
78 return PreconType::NONE;
79 }
80 if (precon_name == "DIAGONAL")
81 {
83 }
84 if (precon_name == "ILUT")
85 {
86 return PreconType::ILUT;
87 }
88
89 OGS_FATAL("Unknown Eigen preconditioner type `{:s}'", precon_name);
90}
91
92std::string EigenOption::getSolverName(SolverType const solver_type)
93{
94 switch (solver_type)
95 {
96 case SolverType::CG:
97 return "CG";
99 return "BiCGSTAB";
101 return "BiCGSTABL";
102 case SolverType::IDRS:
103 return "IDRS";
105 return "IDRSTABL";
107 return "SparseLU";
109 return "PardisoLU";
111 return "GMRES";
112 }
113 return "Invalid";
114}
115
116std::string EigenOption::getPreconName(PreconType const precon_type)
117{
118 switch (precon_type)
119 {
120 case PreconType::NONE:
121 return "NONE";
123 return "DIAGONAL";
124 case PreconType::ILUT:
125 return "ILUT";
126 }
127 return "Invalid";
128}
129
130} // namespace MathLib
#define OGS_FATAL(...)
Definition Error.h:26
static const double s
PreconType precon_type
Preconditioner type.
Definition EigenOption.h:44
static std::string getSolverName(SolverType const solver_type)
return a linear solver name from the solver type
PreconType
Preconditioner type.
Definition EigenOption.h:35
static PreconType getPreconType(const std::string &precon_name)
SolverType solver_type
Linear solver type.
Definition EigenOption.h:42
double error_tolerance
Error tolerance.
Definition EigenOption.h:48
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:46