OGS
LinearSolverOptionsParser.cpp
Go to the documentation of this file.
1
12
13#include "BaseLib/ConfigTree.h"
15
16namespace MathLib
17{
18std::tuple<std::string, std::string>
20 std::string solver_prefix, BaseLib::ConfigTree const* const config) const
21{
22 // Insert options into petsc database. Default options are given in the
23 // string below.
24 std::string petsc_options =
25 "-ksp_type cg -pc_type bjacobi -ksp_rtol 1e-16 -ksp_max_it 10000";
26
27 if (config)
28 {
29 ignoreOtherLinearSolvers(*config, "petsc");
30
32 if (auto const subtree = config->getConfigSubtreeOptional("petsc"))
33 {
34 if (auto const parameters =
36 subtree->getConfigParameterOptional<std::string>("parameters"))
37 {
38 petsc_options = *parameters;
39 }
40
41 if (auto const pre =
43 subtree->getConfigParameterOptional<std::string>("prefix"))
44 {
45 if (!pre->empty())
46 solver_prefix = *pre + "_";
47 }
48 }
49 }
50 return {solver_prefix, petsc_options};
51}
52} // namespace MathLib
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
void ignoreOtherLinearSolvers(const BaseLib::ConfigTree &config, const std::string &solver_name)