OGS 6.2.0-97-g4a610c866
EigenOption.cpp
Go to the documentation of this file.
1 
10 #include "EigenOption.h"
11 #include "BaseLib/Error.h"
12 
13 namespace MathLib
14 {
15 
17 {
20  max_iterations = static_cast<int>(1e6);
21  error_tolerance = 1.e-16;
22 #ifdef USE_EIGEN_UNSUPPORTED
23  scaling = false;
24 #endif
25 }
26 
27 EigenOption::SolverType EigenOption::getSolverType(const std::string &solver_name)
28 {
29  if (solver_name == "CG")
30  {
31  return SolverType::CG;
32  }
33  if (solver_name == "BiCGSTAB")
34  {
35  return SolverType::BiCGSTAB;
36  }
37  if (solver_name == "SparseLU")
38  {
39  return SolverType::SparseLU;
40  }
41  if (solver_name == "PardisoLU")
42  {
43  return SolverType::PardisoLU;
44  }
45  if (solver_name == "GMRES")
46  {
47  return SolverType::GMRES;
48  }
49 
50  OGS_FATAL("Unknown Eigen solver type `%s'", solver_name.c_str());
51 }
52 
53 EigenOption::PreconType EigenOption::getPreconType(const std::string &precon_name)
54 {
55  if (precon_name == "NONE")
56  {
57  return PreconType::NONE;
58  }
59  if (precon_name == "DIAGONAL")
60  {
61  return PreconType::DIAGONAL;
62  }
63  if (precon_name == "ILUT")
64  {
65  return PreconType::ILUT;
66  }
67 
68  OGS_FATAL("Unknown Eigen preconditioner type `%s'", precon_name.c_str());
69 }
70 
72 {
73  switch (solver_type) {
74  case SolverType::CG:
75  return "CG";
77  return "BiCGSTAB";
79  return "SparseLU";
81  return "PardisoLU";
82  case SolverType::GMRES:
83  return "GMRES";
84  }
85  return "Invalid";
86 }
87 
89 {
90  switch (precon_type) {
91  case PreconType::NONE:
92  return "NONE";
94  return "DIAGONAL";
95  case PreconType::ILUT:
96  return "ILUT";
97  }
98  return "Invalid";
99 }
100 
101 } // namespace MathLib
static PreconType getPreconType(const std::string &precon_name)
Definition: EigenOption.cpp:53
static std::string getPreconName(PreconType const precon_type)
return a preconditioner name from the preconditioner type
Definition: EigenOption.cpp:88
PreconType
Preconditioner type.
Definition: EigenOption.h:31
double error_tolerance
Error tolerance.
Definition: EigenOption.h:45
SolverType
Solver type.
Definition: EigenOption.h:21
static SolverType getSolverType(const std::string &solver_name)
Definition: EigenOption.cpp:27
int max_iterations
Maximum iteration count.
Definition: EigenOption.h:43
static std::string getSolverName(SolverType const solver_type)
return a linear solver name from the solver type
Definition: EigenOption.cpp:71
PreconType precon_type
Preconditioner type.
Definition: EigenOption.h:41
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
SolverType solver_type
Linear solver type.
Definition: EigenOption.h:39