OGS
MathLib::LinearSolverOptionsParser< PETScLinearSolver > Struct Referencefinal

Detailed Description

Definition at line 24 of file LinearSolverOptionsParser.h.

#include <LinearSolverOptionsParser.h>

Public Member Functions

std::tuple< std::string, std::string > parseNameAndOptions (std::string solver_prefix, BaseLib::ConfigTree const *const config) const
 

Member Function Documentation

◆ parseNameAndOptions()

std::tuple< std::string, std::string > MathLib::LinearSolverOptionsParser< PETScLinearSolver >::parseNameAndOptions ( std::string solver_prefix,
BaseLib::ConfigTree const *const config ) const

The method parses the linear solver options for PETSc.

Parameters
solver_prefixthe prefix for the linear solver to distinguish different linear solvers for instance in the staggered schema
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 passed as string to PETSc options database
Input File Parameter
prj__linear_solvers__linear_solver__petsc
Input File Parameter
prj__linear_solvers__linear_solver__petsc__parameters
Input File Parameter
prj__linear_solvers__linear_solver__petsc__prefix

Definition at line 19 of file LinearSolverOptionsParser.cpp.

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}
void ignoreOtherLinearSolvers(const BaseLib::ConfigTree &config, const std::string &solver_name)

References BaseLib::ConfigTree::getConfigSubtreeOptional(), and MathLib::ignoreOtherLinearSolvers().


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