OGS
MathLib::LinearSolverOptionsParser< EigenLinearSolver > Struct Referencefinal

Detailed Description

Definition at line 18 of file Eigen/LinearSolverOptionsParser.h.

#include <LinearSolverOptionsParser.h>

Public Member Functions

std::tuple< std::string, EigenOptionparseNameAndOptions (std::string const &prefix, BaseLib::ConfigTree const *const solver_config) const

Member Function Documentation

◆ parseNameAndOptions()

std::tuple< std::string, EigenOption > MathLib::LinearSolverOptionsParser< EigenLinearSolver >::parseNameAndOptions ( std::string const & prefix,
BaseLib::ConfigTree const *const solver_config ) const

The method parses the linear solver options for Eigen.

Parameters
prefixthe prefix for the linear solver to distinguish different linear solvers for instance in the staggered schema
solver_configthe part of the property tree (usually created from the linear solver section in the project file)
Returns
the first item of the returned tuple is the solver prefix as string, the second item are all the options as an EigenOption object
Input File Parameter
prj__linear_solvers__linear_solver__eigen
Input File Parameter
prj__linear_solvers__linear_solver__eigen__solver_type
Input File Parameter
prj__linear_solvers__linear_solver__eigen__precon_type
Input File Parameter
prj__linear_solvers__linear_solver__eigen__error_tolerance
Input File Parameter
prj__linear_solvers__linear_solver__eigen__max_iteration_step
Input File Parameter
prj__linear_solvers__linear_solver__eigen__triangular_matrix
Input File Parameter
prj__linear_solvers__linear_solver__eigen__scaling
Input File Parameter
prj__linear_solvers__linear_solver__eigen__restart
Input File Parameter
prj__linear_solvers__linear_solver__eigen__l
Input File Parameter
prj__linear_solvers__linear_solver__eigen__s
Input File Parameter
prj__linear_solvers__linear_solver__eigen__smoothing
Input File Parameter
prj__linear_solvers__linear_solver__eigen__angle
Input File Parameter
prj__linear_solvers__linear_solver__eigen__residual_update

Definition at line 13 of file Eigen/LinearSolverOptionsParser.cpp.

16{
17 if (!solver_config)
18 {
19 return {prefix, EigenOption{}};
20 }
21
24 auto const config = solver_config->getConfigSubtreeOptional("eigen");
25 if (!config)
26 {
28 "OGS was compiled with Eigen but the config section in the "
29 "project file seems to be invalid");
30 }
31
33
34 if (auto solver_type =
36 config->getConfigParameterOptional<std::string>("solver_type"))
37 {
39 }
40 if (auto precon_type =
42 config->getConfigParameterOptional<std::string>("precon_type"))
43 {
45 }
46 if (auto error_tolerance =
48 config->getConfigParameterOptional<double>("error_tolerance"))
49 {
50 options.error_tolerance = *error_tolerance;
51 }
52 if (auto max_iteration_step =
54 config->getConfigParameterOptional<int>("max_iteration_step"))
55 {
56 options.max_iterations = *max_iteration_step;
57 }
58 if (auto triangular_matrix_type =
60 config->getConfigParameterOptional<std::string>("triangular_matrix"))
61 {
62 options.triangular_matrix_type =
65 }
66 if (auto scaling =
68 config->getConfigParameterOptional<bool>("scaling"))
69 {
70#ifdef USE_EIGEN_UNSUPPORTED
71 options.scaling = *scaling;
72#else
74 "The code is not compiled with the Eigen unsupported modules. "
75 "scaling is not available.");
76#endif
77 }
78 if (auto restart =
80 config->getConfigParameterOptional<int>("restart"))
81 {
82#ifdef USE_EIGEN_UNSUPPORTED
83 options.restart = *restart;
84#else
86 "The code is not compiled with the Eigen unsupported modules. "
87 "GMRES/GMRES option restart is not available.");
88#endif
89 }
90 if (auto l =
92 config->getConfigParameterOptional<int>("l"))
93 {
94#ifdef USE_EIGEN_UNSUPPORTED
95 options.l = *l;
96#else
98 "The code is not compiled with the Eigen unsupported modules.");
99#endif
100 }
101 if (auto s =
103 config->getConfigParameterOptional<int>("s"))
104 {
105#ifdef USE_EIGEN_UNSUPPORTED
106 options.s = *s;
107#else
108 OGS_FATAL(
109 "The code is not compiled with the Eigen unsupported modules.");
110#endif
111 }
112 if (auto smoothing =
114 config->getConfigParameterOptional<int>("smoothing"))
115 {
116#ifdef USE_EIGEN_UNSUPPORTED
117 options.smoothing = *smoothing;
118#else
119 OGS_FATAL(
120 "The code is not compiled with the Eigen unsupported modules.");
121#endif
122 }
123 if (auto angle =
125 config->getConfigParameterOptional<int>("angle"))
126 {
127#ifdef USE_EIGEN_UNSUPPORTED
128 options.angle = *angle;
129#else
130 OGS_FATAL(
131 "The code is not compiled with the Eigen unsupported modules.");
132#endif
133 }
134 if (auto residualupdate =
136 config->getConfigParameterOptional<int>("residual_update"))
137 {
138#ifdef USE_EIGEN_UNSUPPORTED
139 options.residualupdate = *residualupdate;
140#else
141 OGS_FATAL(
142 "The code is not compiled with the Eigen unsupported modules.");
143#endif
144 }
145 return {prefix, options};
146}
#define OGS_FATAL(...)
Definition Error.h:19
void ignoreOtherLinearSolvers(const BaseLib::ConfigTree &config, const std::string &solver_name)
static TriangularMatrixType getTriangularMatrixType(const std::string &triangular_matrix_name)
static PreconType getPreconType(const std::string &precon_name)
static SolverType getSolverType(const std::string &solver_name)

References MathLib::EigenOption::error_tolerance, BaseLib::ConfigTree::getConfigSubtreeOptional(), MathLib::EigenOption::getPreconType(), MathLib::EigenOption::getSolverType(), MathLib::EigenOption::getTriangularMatrixType(), MathLib::ignoreOtherLinearSolvers(), MathLib::EigenOption::max_iterations, OGS_FATAL, MathLib::EigenOption::precon_type, MathLib::s, MathLib::EigenOption::solver_type, and MathLib::EigenOption::triangular_matrix_type.


The documentation for this struct was generated from the following files: