12#ifndef DUMUX_LINEAR_SOLVER_HH
13#define DUMUX_LINEAR_SOLVER_HH
15#include <dune/common/parallel/mpihelper.hh>
16#include <dune/common/exceptions.hh>
17#include <dune/istl/scalarproducts.hh>
46 verbosity_ = getParamFromGroup<int>(
paramGroup,
"LinearSolver.Verbosity", 0);
47 maxIter_ = getParamFromGroup<int>(
paramGroup,
"LinearSolver.MaxIterations", 250);
48 residReduction_ = getParamFromGroup<Scalar>(
paramGroup,
"LinearSolver.ResidualReduction", 1e-13);
49 relaxation_ = getParamFromGroup<Scalar>(
paramGroup,
"LinearSolver.Preconditioner.Relaxation", 1);
50 precondIter_ = getParamFromGroup<int>(
paramGroup,
"LinearSolver.Preconditioner.Iterations", 1);
51 precondVerbosity_ = getParamFromGroup<int>(
paramGroup,
"LinearSolver.Preconditioner.Verbosity", 0);
58 template<
class Matrix,
class Vector>
59 bool solve(
const Matrix& A, Vector& x,
const Vector& b)
61 DUNE_THROW(Dune::NotImplemented,
"Linear solver doesn't implement a solve method!");
64 template<
class Vector>
65 auto norm(
const Vector& x)
const
67 if (Dune::MPIHelper::getCommunication().size() > 1)
68 DUNE_THROW(Dune::NotImplemented,
"norm in parallel");
70 return Dune::SeqScalarProduct<Vector>().norm(x);
75 {
return "unknown solver"; }
79 {
return paramGroup_; }
83 {
return verbosity_; }
99 {
return residReduction_; }
103 { residReduction_ = r; }
107 {
return relaxation_; }
115 {
return precondIter_; }
119 { precondIter_ = i; }
123 {
return precondVerbosity_; }
127 { precondVerbosity_ = verbosityLevel; }
135 int precondVerbosity_;
136 const std::string paramGroup_;
Base class for linear solvers.
Definition: solver.hh:27
Scalar residReduction() const
the linear solver residual reduction
Definition: solver.hh:98
Scalar relaxation() const
the linear solver relaxation factor
Definition: solver.hh:106
bool solve(const Matrix &A, Vector &x, const Vector &b)
Solve the linear system Ax = b.
Definition: solver.hh:59
int precondVerbosity() const
the preconditioner verbosity
Definition: solver.hh:122
void setMaxIter(int i)
set the maximum number of linear solver iterations
Definition: solver.hh:94
int precondIter() const
the number of preconditioner iterations
Definition: solver.hh:114
auto norm(const Vector &x) const
Definition: solver.hh:65
int maxIter() const
the maximum number of linear solver iterations
Definition: solver.hh:90
void setPrecondIter(int i)
set the number of preconditioner iterations
Definition: solver.hh:118
void setVerbosity(int v)
set the verbosity level
Definition: solver.hh:86
void setPrecondVerbosity(int verbosityLevel)
set the preconditioner verbosity
Definition: solver.hh:126
const std::string & paramGroup() const
the parameter group for getting parameter from the parameter tree
Definition: solver.hh:78
void setRelaxation(Scalar r)
set the linear solver relaxation factor
Definition: solver.hh:110
LinearSolver(const std::string ¶mGroup="")
Construct the solver.
Definition: solver.hh:43
int verbosity() const
the verbosity level
Definition: solver.hh:82
std::string name() const
the name of the linear solver
Definition: solver.hh:74
void setResidualReduction(Scalar r)
set the linear solver residual reduction
Definition: solver.hh:102
double Scalar
Definition: solver.hh:31
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.