OGS 6.1.0-1721-g6382411ad
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  return SolverType::CG;
31  if (solver_name == "BiCGSTAB")
32  return SolverType::BiCGSTAB;
33  if (solver_name == "SparseLU")
34  return SolverType::SparseLU;
35  if (solver_name == "PardisoLU")
36  return SolverType::PardisoLU;
37  if (solver_name == "GMRES")
38  return SolverType::GMRES;
39 
40  OGS_FATAL("Unknown Eigen solver type `%s'", solver_name.c_str());
41 }
42 
43 EigenOption::PreconType EigenOption::getPreconType(const std::string &precon_name)
44 {
45  if (precon_name == "NONE")
46  return PreconType::NONE;
47  if (precon_name == "DIAGONAL")
48  return PreconType::DIAGONAL;
49  if (precon_name == "ILUT")
50  return PreconType::ILUT;
51 
52  OGS_FATAL("Unknown Eigen preconditioner type `%s'", precon_name.c_str());
53 }
54 
56 {
57  switch (solver_type) {
58  case SolverType::CG:
59  return "CG";
61  return "BiCGSTAB";
63  return "SparseLU";
65  return "PardisoLU";
66  case SolverType::GMRES:
67  return "GMRES";
68  }
69  return "Invalid";
70 }
71 
73 {
74  switch (precon_type) {
75  case PreconType::NONE:
76  return "NONE";
78  return "DIAGONAL";
79  case PreconType::ILUT:
80  return "ILUT";
81  }
82  return "Invalid";
83 }
84 
85 } //MathLib
static PreconType getPreconType(const std::string &precon_name)
Definition: EigenOption.cpp:43
static std::string getPreconName(PreconType const precon_type)
return a preconditioner name from the preconditioner type
Definition: EigenOption.cpp:72
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:55
PreconType precon_type
Preconditioner type.
Definition: EigenOption.h:41
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
SolverType solver_type
Linear solver type.
Definition: EigenOption.h:39