Go to the documentation of this file.
4 #ifndef DUNE_ISTL_SOLVER_HH
5 #define DUNE_ISTL_SOLVER_HH
10 #include <dune/common/exceptions.hh>
11 #include <dune/common/shared_ptr.hh>
12 #include <dune/common/simd.hh>
90 template<
class X,
class Y>
103 typedef typename FieldTraits<field_type>::real_type
real_type;
139 #ifdef DUNE_ISTL_SUPPORT_OLD_CATEGORY_INTERFACE
141 DUNE_THROW(Dune::Exception,
"It is necessary to implement the category method in a derived classes, in the future this method will pure virtual.");
159 s << std::setw(
normSpacing) <<
"Rate" << std::endl;
163 template <
typename CountType,
typename DataType>
165 const CountType& iter,
166 const DataType& norm,
167 const DataType& norm_old)
const
169 const DataType rate = norm/norm_old;
176 template <
typename CountType,
typename DataType>
178 const CountType& iter,
179 const DataType& norm)
const
194 template<
class X,
class Y>
223 _op(stackobject_to_shared_ptr(op)),
224 _prec(stackobject_to_shared_ptr(prec)),
256 _op(stackobject_to_shared_ptr(op)),
257 _prec(stackobject_to_shared_ptr(prec)),
258 _sp(stackobject_to_shared_ptr(sp)),
262 DUNE_THROW(
InvalidSolverCategory,
"LinearOperator and Preconditioner must have the same SolverCategory!");
264 DUNE_THROW(
InvalidSolverCategory,
"LinearOperator and ScalarProduct must have the same SolverCategory!");
289 this->
apply(x,b,res);
300 std::shared_ptr<LinearOperator<X,Y>>
_op;
301 std::shared_ptr<Preconditioner<X,Y>>
_prec;
302 std::shared_ptr<ScalarProduct<X>>
_sp;
316 template <
typename ISTLLinearSolver,
typename BCRSMatrix>
323 static const bool is_direct_solver
334 template <
bool is_direct_solver,
typename Dummy =
void>
346 template <
typename Dummy>
352 solver.setMatrix(matrix);
Definition: solvercategory.hh:52
int iterations
Number of iterations.
Definition: solver.hh:59
Category
Definition: solvercategory.hh:21
void clear()
Resets all data.
Definition: solver.hh:49
double reduction
Reduction achieved: .
Definition: solver.hh:62
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:23
SolverCategory::Category _category
Definition: solver.hh:306
Base class for all implementations of iterative solvers.
Definition: solver.hh:195
Y range_type
Type of the range of the operator to be inverted.
Definition: solver.hh:97
X::field_type field_type
The field type of the operator.
Definition: solver.hh:100
FieldTraits< field_type >::real_type real_type
The real type of the field type (is the same if using real numbers, but differs for std::complex)
Definition: solver.hh:103
double elapsed
Elapsed time in seconds.
Definition: solver.hh:74
int _maxit
Definition: solver.hh:304
virtual void apply(X &x, X &b, double reduction, InverseOperatorResult &res)
Apply inverse operator with given reduction factor.
Definition: solver.hh:285
virtual SolverCategory::Category category() const
Category of the solver (see SolverCategory::Category)
Definition: solver.hh:294
virtual SolverCategory::Category category() const =0
Category of the solver (see SolverCategory::Category)
static void setMatrix(ISTLLinearSolver &solver, const BCRSMatrix &matrix)
Definition: solver.hh:349
Abstract base class for all solvers.
Definition: solver.hh:91
X domain_type
Type of the domain of the operator to be inverted.
Definition: solver.hh:94
bool converged
True if convergence criterion has been met.
Definition: solver.hh:65
static Category category(const OP &op, decltype(op.category()) *=nullptr)
Helperfunction to extract the solver category either from an enum, or from the newly introduced virtu...
Definition: solvercategory.hh:32
virtual void apply(X &x, Y &b, InverseOperatorResult &res)=0
Apply inverse operator,.
@ iterationSpacing
Definition: solver.hh:152
void printOutput(std::ostream &s, const CountType &iter, const DataType &norm, const DataType &norm_old) const
helper function for printing solver output
Definition: solver.hh:164
Define base class for scalar product and norm.
Default implementation for the scalar case.
Definition: scalarproducts.hh:84
Define general, extensible interface for operators. The available implementation wraps a matrix.
Statistics about the application of an inverse operator.
Definition: solver.hh:40
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:422
IterativeSolver(LinearOperator< X, Y > &op, Preconditioner< X, Y > &prec, scalar_real_type reduction, int maxit, int verbose)
General constructor to initialize an iterative solver.
Definition: solver.hh:222
int _verbose
Definition: solver.hh:305
static void setMatrix(ISTLLinearSolver &, const BCRSMatrix &)
Definition: solver.hh:337
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:46
SimdScalar< real_type > scalar_real_type
scalar type underlying the field_type
Definition: solver.hh:106
@ normSpacing
Definition: solver.hh:152
InverseOperatorResult()
Default constructor.
Definition: solver.hh:43
Definition: solvertype.hh:13
std::shared_ptr< Preconditioner< X, Y > > _prec
Definition: solver.hh:301
IterativeSolver(LinearOperator< X, Y > &op, ScalarProduct< X > &sp, Preconditioner< X, Y > &prec, scalar_real_type reduction, int maxit, int verbose)
General constructor to initialize an iterative solver.
Definition: solver.hh:254
virtual ~InverseOperator()
Destructor.
Definition: solver.hh:148
static void setMatrix(ISTLLinearSolver &solver, const BCRSMatrix &matrix)
Definition: solver.hh:320
void printOutput(std::ostream &s, const CountType &iter, const DataType &norm) const
helper function for printing solver output
Definition: solver.hh:177
Implementation that works together with iterative ISTL solvers, e.g. Dune::CGSolver or Dune::BiCGSTAB...
Definition: solver.hh:335
std::shared_ptr< ScalarProduct< X > > _sp
Definition: solver.hh:302
Definition: allocator.hh:7
Templates characterizing the type of a solver.
double condition_estimate
Estimate of condition number.
Definition: solver.hh:71
scalar_real_type _reduction
Definition: solver.hh:303
double conv_rate
Convergence rate (average reduction per step)
Definition: solver.hh:68
Categories for the solvers.
Definition: solvercategory.hh:19
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
A linear operator.
Definition: operators.hh:64
Helper class for notifying a DUNE-ISTL linear solver about a change of the iteration matrix object in...
Definition: solver.hh:317
void printHeader(std::ostream &s) const
helper function for printing header of solver output
Definition: solver.hh:155
std::shared_ptr< LinearOperator< X, Y > > _op
Definition: solver.hh:300