3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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
53 LinearSolver(const std::string& paramGroup = "")
54 : paramGroup_(paramGroup)
55 {
56 verbosity_ = getParamFromGroup<int>(paramGroup, "LinearSolver.Verbosity", 0);
57 maxIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.MaxIterations", 250);
58 residReduction_ = getParamFromGroup<double>(paramGroup, "LinearSolver.ResidualReduction", 1e-13);
59 relaxation_ = getParamFromGroup<double>(paramGroup, "LinearSolver.Preconditioner.Relaxation", 1);
60 precondIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.Preconditioner.Iterations", 1);
61 precondVerbosity_ = getParamFromGroup<int>(paramGroup, "LinearSolver.Preconditioner.Verbosity", 0);
62 }
63
68 template<class Matrix, class Vector>
69 bool solve(const Matrix& A, Vector& x, const Vector& b)
70 {
71 DUNE_THROW(Dune::NotImplemented, "Linear solver doesn't implement a solve method!");
72 }
73
75 std::string name() const
76 { return "unknown solver"; }
77
79 const std::string& paramGroup() const
80 { return paramGroup_; }
81
83 int verbosity() const
84 { return verbosity_; }
85
87 void setVerbosity(int v)
88 { verbosity_ = v; }
89
91 int maxIter() const
92 { return maxIter_; }
93
95 void setMaxIter(int i)
96 { maxIter_ = i; }
97
99 double residReduction() const
100 { return residReduction_; }
101
103 void setResidualReduction(double r)
104 { residReduction_ = r; }
105
107 double relaxation() const
108 { return relaxation_; }
109
111 void setRelaxation(double r)
112 { relaxation_ = r; }
113
115 int precondIter() const
116 { return precondIter_; }
117
119 void setPrecondIter(int i)
120 { precondIter_ = i; }
121
124 { return precondVerbosity_; }
125
127 void setPrecondVerbosity(int verbosityLevel)
128 { precondVerbosity_ = verbosityLevel; }
129
130private:
131 int verbosity_;
132 int maxIter_;
133 double residReduction_;
134 double relaxation_;
135 int precondIter_;
136 int precondVerbosity_;
137 const std::string paramGroup_;
138};
139
140} // end namespace Dumux
141
142#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Definition: adapt.hh:29
Base class for linear solvers.
Definition: solver.hh:37
bool solve(const Matrix &A, Vector &x, const Vector &b)
Solve the linear system Ax = b.
Definition: solver.hh:69
int precondVerbosity() const
the preconditioner verbosity
Definition: solver.hh:123
void setResidualReduction(double r)
set the linear solver residual reduction
Definition: solver.hh:103
void setMaxIter(int i)
set the maximum number of linear solver iterations
Definition: solver.hh:95
int precondIter() const
the number of preconditioner iterations
Definition: solver.hh:115
double residReduction() const
the linear solver residual reduction
Definition: solver.hh:99
int maxIter() const
the maximum number of linear solver iterations
Definition: solver.hh:91
void setPrecondIter(int i)
set the number of preconditioner iterations
Definition: solver.hh:119
void setVerbosity(int v)
set the verbosity level
Definition: solver.hh:87
void setPrecondVerbosity(int verbosityLevel)
set the preconditioner verbosity
Definition: solver.hh:127
const std::string & paramGroup() const
the parameter group for getting parameter from the parameter tree
Definition: solver.hh:79
void setRelaxation(double r)
set the linear solver relaxation factor
Definition: solver.hh:111
LinearSolver(const std::string &paramGroup="")
Contruct the solver.
Definition: solver.hh:53
int verbosity() const
the verbosity level
Definition: solver.hh:83
std::string name() const
the name of the linear solver
Definition: solver.hh:75
double Scalar
Definition: solver.hh:41
double relaxation() const
the linear solver relaxation factor
Definition: solver.hh:107