17#ifndef OPM_ABSTRACTISTLSOLVER_HEADER_INCLUDED
18#define OPM_ABSTRACTISTLSOLVER_HEADER_INCLUDED
20#include <opm/common/Exceptions.hpp>
21#include <opm/simulators/linalg/FlowLinearSolverParameters.hpp>
22#include <opm/simulators/linalg/PropertyTree.hpp>
43template <
class SparseMatrixAdapter,
class Vector>
48 using CommunicationType = Dune::OwnerOverlapCopyCommunication<int, int>;
50 using CommunicationType = Dune::Communication<int>;
53 using Matrix =
typename SparseMatrixAdapter::IstlMatrix;
90 virtual void prepare(
const Matrix& M, Vector& b) = 0;
103 virtual void prepare(
const SparseMatrixAdapter& M, Vector& b) = 0;
134 virtual void setMatrix(
const SparseMatrixAdapter& M) = 0;
170 virtual const CommunicationType*
comm()
const = 0;
195 if (!result.converged) {
196 if (result.reduction < parameters.relaxed_linear_solver_reduction_) {
197 std::stringstream ss;
198 ss <<
"Full linear solver tolerance not achieved. The reduction is:" << result.reduction <<
" after "
199 << result.iterations <<
" iterations ";
200 OpmLog::warning(ss.str());
205 if (!parameters.ignoreConvergenceFailure_ && !result.converged) {
206 const std::string msg(
"Convergence failure for linear solver.");
207 OPM_THROW_NOLOG(NumericalProblem, msg);
210 return result.converged;
Abstract interface for ISTL solvers.
Definition AbstractISTLSolver.hpp:45
virtual bool solve(Vector &x)=0
Solve the system of equations Ax = b.
virtual void getResidual(Vector &b) const =0
Get the residual vector.
virtual void prepare(const Matrix &M, Vector &b)=0
Prepare the solver with the given matrix and right-hand side vector.
virtual void setActiveSolver(int num)=0
Set the active solver by its index.
virtual int iterations() const =0
Get the number of iterations used in the last solve.
virtual void setMatrix(const SparseMatrixAdapter &M)=0
Set the matrix for the solver.
virtual void eraseMatrix()=0
Signals that the memory for the matrix internally in the solver could be erased.
virtual int numAvailableSolvers() const =0
Get the number of available solvers.
virtual int getSolveCount() const =0
Get the count of how many times the solver has been called.
virtual void prepare(const SparseMatrixAdapter &M, Vector &b)=0
Prepare the solver with the given sparse matrix and right-hand side vector.
virtual void setResidual(Vector &b)=0
Set the residual vector.
virtual const CommunicationType * comm() const =0
Get the communication object used by the solver.
static bool checkConvergence(const Dune::InverseOperatorResult &result, const FlowLinearSolverParameters ¶meters)
Check the convergence of the linear solver.
Definition AbstractISTLSolver.hpp:192
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
This class carries all parameters for the NewtonIterationBlackoilInterleaved class.
Definition FlowLinearSolverParameters.hpp:98