OGS
MathLib::LinearSolverOptionsParser< EigenLinearSolver > Struct Referencefinal

Detailed Description

Definition at line 25 of file 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 20 of file LinearSolverOptionsParser.cpp.

23{
24 if (!solver_config)
25 {
26 return {prefix, EigenOption{}};
27 }
28
29 ignoreOtherLinearSolvers(*solver_config, "eigen");
31 auto const config = solver_config->getConfigSubtreeOptional("eigen");
32 if (!config)
33 {
35 "OGS was compiled with Eigen but the config section in the "
36 "project file seems to be invalid");
37 }
38
39 EigenOption options;
40
41 if (auto solver_type =
43 config->getConfigParameterOptional<std::string>("solver_type"))
44 {
45 options.solver_type = MathLib::EigenOption::getSolverType(*solver_type);
46 }
47 if (auto precon_type =
49 config->getConfigParameterOptional<std::string>("precon_type"))
50 {
51 options.precon_type = MathLib::EigenOption::getPreconType(*precon_type);
52 }
53 if (auto error_tolerance =
55 config->getConfigParameterOptional<double>("error_tolerance"))
56 {
57 options.error_tolerance = *error_tolerance;
58 }
59 if (auto max_iteration_step =
61 config->getConfigParameterOptional<int>("max_iteration_step"))
62 {
63 options.max_iterations = *max_iteration_step;
64 }
65 if (auto triangular_matrix_type =
67 config->getConfigParameterOptional<std::string>("triangular_matrix"))
68 {
69 options.triangular_matrix_type =
71 *triangular_matrix_type);
72 }
73 if (auto scaling =
75 config->getConfigParameterOptional<bool>("scaling"))
76 {
77#ifdef USE_EIGEN_UNSUPPORTED
78 options.scaling = *scaling;
79#else
81 "The code is not compiled with the Eigen unsupported modules. "
82 "scaling is not available.");
83#endif
84 }
85 if (auto restart =
87 config->getConfigParameterOptional<int>("restart"))
88 {
89#ifdef USE_EIGEN_UNSUPPORTED
90 options.restart = *restart;
91#else
93 "The code is not compiled with the Eigen unsupported modules. "
94 "GMRES/GMRES option restart is not available.");
95#endif
96 }
97 if (auto l =
99 config->getConfigParameterOptional<int>("l"))
100 {
101#ifdef USE_EIGEN_UNSUPPORTED
102 options.l = *l;
103#else
104 OGS_FATAL(
105 "The code is not compiled with the Eigen unsupported modules.");
106#endif
107 }
108 if (auto s =
110 config->getConfigParameterOptional<int>("s"))
111 {
112#ifdef USE_EIGEN_UNSUPPORTED
113 options.s = *s;
114#else
115 OGS_FATAL(
116 "The code is not compiled with the Eigen unsupported modules.");
117#endif
118 }
119 if (auto smoothing =
121 config->getConfigParameterOptional<int>("smoothing"))
122 {
123#ifdef USE_EIGEN_UNSUPPORTED
124 options.smoothing = *smoothing;
125#else
126 OGS_FATAL(
127 "The code is not compiled with the Eigen unsupported modules.");
128#endif
129 }
130 if (auto angle =
132 config->getConfigParameterOptional<int>("angle"))
133 {
134#ifdef USE_EIGEN_UNSUPPORTED
135 options.angle = *angle;
136#else
137 OGS_FATAL(
138 "The code is not compiled with the Eigen unsupported modules.");
139#endif
140 }
141 if (auto residualupdate =
143 config->getConfigParameterOptional<int>("residual_update"))
144 {
145#ifdef USE_EIGEN_UNSUPPORTED
146 options.residualupdate = *residualupdate;
147#else
148 OGS_FATAL(
149 "The code is not compiled with the Eigen unsupported modules.");
150#endif
151 }
152 return {prefix, options};
153}
#define OGS_FATAL(...)
Definition Error.h:26
static const double s
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: