All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
convergencecriterion.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  This file is part of the Open Porous Media project (OPM).
5 
6  OPM 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 2 of the License, or
9  (at your option) any later version.
10 
11  OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef EWOMS_ISTL_CONVERGENCE_CRITERION_HH
28 #define EWOMS_ISTL_CONVERGENCE_CRITERION_HH
29 
30 #include <opm/common/Unused.hpp>
31 
32 #include <dune/common/version.hh>
33 #include <dune/common/fvector.hh>
34 
35 #include <cmath>
36 #include <iostream>
37 #include <iomanip>
38 
39 namespace Ewoms {
40 namespace Linear {
41 
56 template <class Vector>
58 {
60  typedef typename Dune::FieldTraits<typename Vector::field_type>::real_type real_type;
61 
62  typedef real_type Scalar;
63 
64 public:
72  {}
73 
87  virtual void setInitial(const Vector& curSol, const Vector& curResid) = 0;
88 
105  virtual void update(const Vector& curSol, const Vector& changeIndicator, const Vector& curResid) = 0;
106 
111  virtual bool converged() const = 0;
112 
117  virtual bool failed() const
118  { return false; }
119 
125  virtual Scalar accuracy() const = 0;
126 
137  virtual void printInitial(std::ostream& os OPM_UNUSED= std::cout) const
138  {}
139 
148  virtual void print(Scalar iter OPM_UNUSED, std::ostream& os OPM_UNUSED = std::cout) const
149  {}
150 };
151 
153 
154 }} // end namespace Linear, Ewoms
155 
156 #endif
Base class for all convergence criteria which only defines an virtual API.
Definition: convergencecriterion.hh:57
virtual void printInitial(std::ostream &os OPM_UNUSED=std::cout) const
Prints the initial information about the convergence behaviour.
Definition: convergencecriterion.hh:137
virtual Scalar accuracy() const =0
Returns the accuracy of the solution at the last update.
virtual void setInitial(const Vector &curSol, const Vector &curResid)=0
Set the initial solution of the linear system of equations.
virtual ~ConvergenceCriterion()
Destructor.
Definition: convergencecriterion.hh:71
virtual bool failed() const
Returns true if the convergence criterion cannot be met anymore because the solver has broken down...
Definition: convergencecriterion.hh:117
virtual void update(const Vector &curSol, const Vector &changeIndicator, const Vector &curResid)=0
Update the internal members of the convergence criterion with the current solution.
virtual void print(Scalar iter OPM_UNUSED, std::ostream &os OPM_UNUSED=std::cout) const
Prints the information about the convergence behaviour for the current iteration. ...
Definition: convergencecriterion.hh:148
virtual bool converged() const =0
Returns true if and only if the convergence criterion is met.