opm-simulators
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 <dune/common/version.hh>
31 #include <dune/common/fvector.hh>
32 
33 #include <cmath>
34 #include <iostream>
35 #include <iomanip>
36 
37 namespace Opm {
38 namespace Linear {
39 
54 template <class Vector>
56 {
58  using real_type = typename Dune::FieldTraits<typename Vector::field_type>::real_type;
59 
60  using Scalar = real_type;
61 
62 public:
70  {}
71 
85  virtual void setInitial(const Vector& curSol, const Vector& curResid) = 0;
86 
103  virtual void update(const Vector& curSol, const Vector& changeIndicator, const Vector& curResid) = 0;
104 
109  virtual bool converged() const = 0;
110 
115  virtual bool failed() const
116  { return false; }
117 
123  virtual Scalar accuracy() const = 0;
124 
135  virtual void printInitial(std::ostream& = std::cout) const
136  {}
137 
146  virtual void print(Scalar, std::ostream& = std::cout) const
147  {}
148 };
149 
151 
152 }} // end namespace Linear, Opm
153 
154 #endif
virtual ~ConvergenceCriterion()
Destructor.
Definition: convergencecriterion.hh:69
Base class for all convergence criteria which only defines an virtual API.
Definition: convergencecriterion.hh:55
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
virtual bool converged() const =0
Returns true if and only if the convergence criterion is met.
virtual void print(Scalar, std::ostream &=std::cout) const
Prints the information about the convergence behaviour for the current iteration. ...
Definition: convergencecriterion.hh:146
virtual bool failed() const
Returns true if the convergence criterion cannot be met anymore because the solver has broken down...
Definition: convergencecriterion.hh:115
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 printInitial(std::ostream &=std::cout) const
Prints the initial information about the convergence behaviour.
Definition: convergencecriterion.hh:135
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.