6#ifndef DUNE_ISTL_SOLVERREGISTRY_HH
7#define DUNE_ISTL_SOLVERREGISTRY_HH
9#include <dune/istl/common/registry.hh>
10#include <dune/istl/preconditioner.hh>
15 [[deprecated(
"DUNE_REGISTER_ITERATIVE_SOLVER is deprecated. Please use DUNE_REGISTER_SOLVER instead.")]]
16 auto translateToOldIterativeSolverInterface(C oldCreator){
17 return [=](
auto optraits,
auto&&... args){
18 using OpTraits =
decltype(optraits);
19 using TL = TypeList<typename OpTraits::domain_type, typename OpTraits::range_type>;
20 return oldCreator(TL{}, args...);
25#define DUNE_REGISTER_DIRECT_SOLVER(name, ...) \
26 _Pragma ("GCC warning \"'DUNE_REGISTER_DIRECT_SOLVER' macro is deprecated and will be removed after the release of DUNE 2.9. Please use 'DUNE_REGISTER_SOLVER'\"") \
27 DUNE_REGISTER_SOLVER(name, __VA_ARGS__);
29#define DUNE_REGISTER_ITERATIVE_SOLVER(name, ...) \
30 _Pragma ("GCC warning \"'DUNE_REGISTER_ITERATIVE_SOLVER' macro is deprecated and will be removed after the release of DUNE 2.9. Please use 'DUNE_REGISTER_SOLVER'\"") \
31 DUNE_REGISTER_SOLVER(name, Impl::translateToOldIterativeSolverInterface(__VA_ARGS__));
33#define DUNE_REGISTER_PRECONDITIONER(name, ...) \
34 DUNE_REGISTRY_PUT(PreconditionerTag, name, __VA_ARGS__)
36#define DUNE_REGISTER_SOLVER(name, ...) \
37 DUNE_REGISTRY_PUT(SolverTag, name, __VA_ARGS__)
46 struct PreconditionerTag {};
54 auto defaultPreconditionerBlockLevelCreator(){
57 using OpInfo = std::decay_t<
decltype(opInfo)>;
58 using Matrix =
typename OpInfo::matrix_type;
59 using Domain =
typename OpInfo::domain_type;
60 using Range =
typename OpInfo::range_type;
61 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner;
62 if constexpr (OpInfo::isAssembled){
63 const auto& A = opInfo.getAssembledOpOrThrow(linearOperator);
66 = std::make_shared<Preconditioner<Matrix, Domain, Range, blockLevel>>(A, config);
68 DUNE_THROW(NoAssembledOperator,
"Could not obtain matrix from operator. Please pass in an AssembledLinearOperator.");
70 return preconditioner;
74 template<
template<
class,
class,
class>
class Preconditioner>
75 auto defaultPreconditionerCreator(){
78 using OpInfo = std::decay_t<
decltype(opInfo)>;
79 using Matrix =
typename OpInfo::matrix_type;
80 using Domain =
typename OpInfo::domain_type;
81 using Range =
typename OpInfo::range_type;
82 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner;
83 if constexpr (OpInfo::isAssembled){
84 const auto& A = opInfo.getAssembledOpOrThrow(linearOperator);
87 = std::make_shared<Preconditioner<Matrix, Domain, Range>>(A, config);
89 DUNE_THROW(NoAssembledOperator,
"Could not obtain matrix from operator. Please pass in an AssembledLinearOperator.");
91 return preconditioner;
95 template<
template<
class...>
class Solver>
96 auto defaultIterativeSolverCreator(){
97 return [](
auto opInfo,
98 const auto& linearOperator,
101 using OpInfo = std::decay_t<
decltype(opInfo)>;
102 using Operator =
typename OpInfo::operator_type;
103 using Domain =
typename OpInfo::domain_type;
104 using Range =
typename OpInfo::range_type;
105 std::shared_ptr<Operator> _op = std::dynamic_pointer_cast<Operator>(linearOperator);
107 std::shared_ptr<ScalarProduct<Range>> scalarProduct = opInfo.getScalarProduct(linearOperator);
108 std::shared_ptr<Dune::InverseOperator<Domain, Range>> solver
109 = std::make_shared<Solver<Domain>>(linearOperator, scalarProduct, preconditioner, config);
117 class UnsupportedType :
public NotImplemented {};
119 class InvalidSolverFactoryConfiguration :
public InvalidStateException{};
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:373
A generic dynamic dense matrix.
Definition: matrix.hh:561
This exception is thrown if the requested solver or preconditioner needs an assembled matrix.
Definition: solverregistry.hh:51
Hierarchical structure of string parameters.
Definition: parametertree.hh:37
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:33
#define DUNE_THROW(E,...)
Definition: exceptions.hh:312
std::shared_ptr< Preconditioner< typename Operator::domain_type, typename Operator::range_type > > getPreconditionerFromFactory(std::shared_ptr< Operator > op, const ParameterTree &config)
Construct a Preconditioner for a given Operator.
Definition: solverfactory.hh:175
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::size_t blockLevel()
Determine the block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:176
Define general, extensible interface for inverse operators.