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>
13#define DUNE_REGISTER_PRECONDITIONER(name, ...) \
14 DUNE_REGISTRY_PUT(PreconditionerTag, name, __VA_ARGS__)
16#define DUNE_REGISTER_SOLVER(name, ...) \
17 DUNE_REGISTRY_PUT(SolverTag, name, __VA_ARGS__)
26 struct PreconditionerTag {};
34 auto defaultPreconditionerBlockLevelCreator(){
37 using OpInfo = std::decay_t<
decltype(opInfo)>;
38 using Matrix =
typename OpInfo::matrix_type;
39 using Domain =
typename OpInfo::domain_type;
40 using Range =
typename OpInfo::range_type;
41 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner;
42 if constexpr (OpInfo::isAssembled){
43 const auto& A = opInfo.getAssembledOpOrThrow(linearOperator);
46 = std::make_shared<Preconditioner<Matrix, Domain, Range, blockLevel>>(A, config);
48 DUNE_THROW(NoAssembledOperator,
"Could not obtain matrix from operator. Please pass in an AssembledLinearOperator.");
50 return preconditioner;
54 template<
template<
class,
class,
class>
class Preconditioner>
55 auto defaultPreconditionerCreator(){
58 using OpInfo = std::decay_t<
decltype(opInfo)>;
59 using Matrix =
typename OpInfo::matrix_type;
60 using Domain =
typename OpInfo::domain_type;
61 using Range =
typename OpInfo::range_type;
62 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner;
63 if constexpr (OpInfo::isAssembled){
64 const auto& A = opInfo.getAssembledOpOrThrow(linearOperator);
67 = std::make_shared<Preconditioner<Matrix, Domain, Range>>(A, config);
69 DUNE_THROW(NoAssembledOperator,
"Could not obtain matrix from operator. Please pass in an AssembledLinearOperator.");
71 return preconditioner;
75 template<
template<
class...>
class Solver>
76 auto defaultIterativeSolverCreator(){
77 return [](
auto opInfo,
78 const auto& linearOperator,
81 using OpInfo = std::decay_t<
decltype(opInfo)>;
82 using Operator =
typename OpInfo::operator_type;
83 using Domain =
typename OpInfo::domain_type;
84 using Range =
typename OpInfo::range_type;
85 std::shared_ptr<Operator> _op = std::dynamic_pointer_cast<Operator>(linearOperator);
87 std::shared_ptr<ScalarProduct<Range>> scalarProduct = opInfo.getScalarProduct(linearOperator);
88 std::shared_ptr<Dune::InverseOperator<Domain, Range>> solver
89 = std::make_shared<Solver<Domain>>(linearOperator, scalarProduct, preconditioner, config);
97 class UnsupportedType :
public NotImplemented {};
99 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:375
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:31
Hierarchical structure of string parameters.
Definition: parametertree.hh:37
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:33
Define general, extensible interface for inverse operators.
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
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:157
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