Loading...
Searching...
No Matches
convergencecriterion.hh
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef EWOMS_ISTL_CONVERGENCE_CRITERION_HH
#define EWOMS_ISTL_CONVERGENCE_CRITERION_HH
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
#include <cmath>
#include <iostream>
#include <iomanip>
namespace Opm {
namespace Linear {
template <class Vector>
class ConvergenceCriterion
{
using real_type = typename Dune::FieldTraits<typename Vector::field_type>::real_type;
using Scalar = real_type;
public:
virtual ~ConvergenceCriterion()
{}
virtual void setInitial(const Vector& curSol, const Vector& curResid) = 0;
virtual void update(const Vector& curSol, const Vector& changeIndicator, const Vector& curResid) = 0;
virtual bool converged() const = 0;
virtual bool failed() const
{ return false; }
virtual Scalar accuracy() const = 0;
virtual void printInitial(std::ostream& = std::cout) const
{}
virtual void print(Scalar, std::ostream& = std::cout) const
{}
};
}} // end namespace Linear, Opm
#endif
Opm::Linear::ConvergenceCriterion
Base class for all convergence criteria which only defines an virtual API.
Definition convergencecriterion.hh:56
Opm::Linear::ConvergenceCriterion::setInitial
virtual void setInitial(const Vector &curSol, const Vector &curResid)=0
Set the initial solution of the linear system of equations.
Opm::Linear::ConvergenceCriterion::update
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.
Opm::Linear::ConvergenceCriterion::accuracy
virtual Scalar accuracy() const =0
Returns the accuracy of the solution at the last update.
Opm::Linear::ConvergenceCriterion::failed
virtual bool failed() const
Returns true if the convergence criterion cannot be met anymore because the solver has broken down.
Definition convergencecriterion.hh:115
Opm::Linear::ConvergenceCriterion::~ConvergenceCriterion
virtual ~ConvergenceCriterion()
Destructor.
Definition convergencecriterion.hh:69
Opm::Linear::ConvergenceCriterion::converged
virtual bool converged() const =0
Returns true if and only if the convergence criterion is met.
Opm::Linear::ConvergenceCriterion::printInitial
virtual void printInitial(std::ostream &=std::cout) const
Prints the initial information about the convergence behaviour.
Definition convergencecriterion.hh:135
Opm::Linear::ConvergenceCriterion::print
virtual void print(Scalar, std::ostream &=std::cout) const
Prints the information about the convergence behaviour for the current iteration.
Definition convergencecriterion.hh:146
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43