Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaofan Chen
ogs
Commits
95606d68
Commit
95606d68
authored
3 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[MaL/LA/Eigen] LinearSorverOptionsParser templ. spezialisation.
parent
7ea11a0f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h
+109
-0
109 additions, 0 deletions
MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h
with
109 additions
and
0 deletions
MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h
0 → 100644
+
109
−
0
View file @
95606d68
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include
<memory>
#include
<vector>
#include
"BaseLib/ConfigTree.h"
#include
"BaseLib/Error.h"
#include
"EigenOption.h"
#include
"MathLib/LinAlg/LinearSolverOptions.h"
#include
"MathLib/LinAlg/LinearSolverOptionsParser.h"
namespace
MathLib
{
template
<
>
struct
LinearSolverOptionsParser
<
EigenLinearSolver
>
final
{
/// The method parses the linear solver options for Eigen.
/// @param prefix the prefix for the linear solver to distinguish different
/// linear solvers for instance in the staggered schema
/// @param solver_config the part of the property tree (usually created from
/// the linear solver section in the project file)
/// @return the first item of the returned tuple is the solver prefix as
/// string, the second item are all the options as an EigenOption object
std
::
tuple
<
std
::
string
,
EigenOption
>
parseNameAndOptions
(
std
::
string
const
&
prefix
,
BaseLib
::
ConfigTree
const
*
const
solver_config
)
const
{
if
(
!
solver_config
)
{
return
{
prefix
,
EigenOption
{}};
}
ignoreOtherLinearSolvers
(
*
solver_config
,
"eigen"
);
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen}
auto
const
config
=
solver_config
->
getConfigSubtreeOptional
(
"eigen"
);
if
(
!
config
)
{
OGS_FATAL
(
"OGS was compiled with Eigen but the config section in the "
"project file seems to be invalid"
);
}
EigenOption
options
;
if
(
auto
solver_type
=
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__solver_type}
config
->
getConfigParameterOptional
<
std
::
string
>
(
"solver_type"
))
{
options
.
solver_type
=
MathLib
::
EigenOption
::
getSolverType
(
*
solver_type
);
}
if
(
auto
precon_type
=
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__precon_type}
config
->
getConfigParameterOptional
<
std
::
string
>
(
"precon_type"
))
{
options
.
precon_type
=
MathLib
::
EigenOption
::
getPreconType
(
*
precon_type
);
}
if
(
auto
error_tolerance
=
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__error_tolerance}
config
->
getConfigParameterOptional
<
double
>
(
"error_tolerance"
))
{
options
.
error_tolerance
=
*
error_tolerance
;
}
if
(
auto
max_iteration_step
=
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__max_iteration_step}
config
->
getConfigParameterOptional
<
int
>
(
"max_iteration_step"
))
{
options
.
max_iterations
=
*
max_iteration_step
;
}
if
(
auto
scaling
=
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__scaling}
config
->
getConfigParameterOptional
<
bool
>
(
"scaling"
))
{
#ifdef USE_EIGEN_UNSUPPORTED
options
.
scaling
=
*
scaling
;
#else
OGS_FATAL
(
"The code is not compiled with the Eigen unsupported modules. "
"scaling is not available."
);
#endif
}
if
(
auto
restart
=
//! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__restart}
config
->
getConfigParameterOptional
<
int
>
(
"restart"
))
{
#ifdef USE_EIGEN_UNSUPPORTED
options
.
restart
=
*
restart
;
#else
OGS_FATAL
(
"The code is not compiled with the Eigen unsupported modules. "
"GMRES/GMRES option restart is not available."
);
#endif
}
return
{
prefix
,
options
};
}
};
}
// namespace MathLib
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment