3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
dumux/linear/solver.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_LINEAR_SOLVER_HH
25#define DUMUX_LINEAR_SOLVER_HH
26
27#include <dune/common/exceptions.hh>
29
30namespace Dumux {
31
37{
38public:
41 using Scalar = double;
42
52 LinearSolver(const std::string& paramGroup = "")
53 : paramGroup_(paramGroup)
54 {
55 verbosity_ = getParamFromGroup<int>(paramGroup, "LinearSolver.Verbosity");
56 maxIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.MaxIterations");
57 residReduction_ = getParamFromGroup<double>(paramGroup, "LinearSolver.ResidualReduction");
58 relaxation_ = getParamFromGroup<double>(paramGroup, "LinearSolver.PreconditionerRelaxation");
59 precondIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.PreconditionerIterations");
60 }
61
66 template<class Matrix, class Vector>
67 bool solve(const Matrix& A, Vector& x, const Vector& b)
68 {
69 DUNE_THROW(Dune::NotImplemented, "Linear solver doesn't implement a solve method!");
70 }
71
73 std::string name() const
74 { return "unknown solver"; }
75
77 const std::string& paramGroup() const
78 { return paramGroup_; }
79
81 int verbosity() const
82 { return verbosity_; }
83
85 void setVerbosity(int v)
86 { verbosity_ = v; }
87
89 int maxIter() const
90 { return maxIter_; }
91
93 void setMaxIter(int i)
94 { maxIter_ = i; }
95
97 double residReduction() const
98 { return residReduction_; }
99
101 void setResidualReduction(double r)
102 { residReduction_ = r; }
103
105 double relaxation() const
106 { return relaxation_; }
107
109 void setRelaxation(double r)
110 { relaxation_ = r; }
111
113 int precondIter() const
114 { return precondIter_; }
115
117 void setPrecondIter(int i)
118 { precondIter_ = i; }
119
120private:
121 int verbosity_;
122 int maxIter_;
123 double residReduction_;
124 double relaxation_;
125 int precondIter_;
126 const std::string paramGroup_;
127};
128
129} // end namespace Dumux
130
131#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Base class for linear solvers.
Definition: dumux/linear/solver.hh:37
bool solve(const Matrix &A, Vector &x, const Vector &b)
Solve the linear system Ax = b.
Definition: dumux/linear/solver.hh:67
void setResidualReduction(double r)
set the linear solver residual reduction
Definition: dumux/linear/solver.hh:101
void setMaxIter(int i)
set the maximum number of linear solver iterations
Definition: dumux/linear/solver.hh:93
int precondIter() const
the number of preconditioner iterations
Definition: dumux/linear/solver.hh:113
double residReduction() const
the linear solver residual reduction
Definition: dumux/linear/solver.hh:97
int maxIter() const
the maximum number of linear solver iterations
Definition: dumux/linear/solver.hh:89
void setPrecondIter(int i)
set the number of preconditioner iterations
Definition: dumux/linear/solver.hh:117
void setVerbosity(int v)
set the verbosity level
Definition: dumux/linear/solver.hh:85
const std::string & paramGroup() const
the parameter group for getting parameter from the parameter tree
Definition: dumux/linear/solver.hh:77
void setRelaxation(double r)
set the linear solver relaxation factor
Definition: dumux/linear/solver.hh:109
LinearSolver(const std::string &paramGroup="")
Contruct the solver.
Definition: dumux/linear/solver.hh:52
int verbosity() const
the verbosity level
Definition: dumux/linear/solver.hh:81
std::string name() const
the name of the linear solver
Definition: dumux/linear/solver.hh:73
double Scalar
Definition: dumux/linear/solver.hh:41
double relaxation() const
the linear solver relaxation factor
Definition: dumux/linear/solver.hh:105