Dune Core Modules (2.8.0)

solverregistry.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_ISTL_SOLVERREGISTRY_HH
5#define DUNE_ISTL_SOLVERREGISTRY_HH
6
7#include <dune/istl/common/registry.hh>
8#include <dune/istl/preconditioner.hh>
9#include <dune/istl/solver.hh>
10
11#define DUNE_REGISTER_DIRECT_SOLVER(name, ...) \
12 DUNE_REGISTRY_PUT(DirectSolverTag, name, __VA_ARGS__)
13
14#define DUNE_REGISTER_PRECONDITIONER(name, ...) \
15 DUNE_REGISTRY_PUT(PreconditionerTag, name, __VA_ARGS__)
16
17#define DUNE_REGISTER_ITERATIVE_SOLVER(name, ...) \
18 DUNE_REGISTRY_PUT(IterativeSolverTag, name, __VA_ARGS__)
19
20namespace Dune{
25 namespace {
26 struct DirectSolverTag {};
27 struct PreconditionerTag {};
28 struct IterativeSolverTag {};
29 }
30 template<template<class,class,class,int>class Preconditioner, int blockLevel=1>
31 auto defaultPreconditionerBlockLevelCreator(){
32 return [](auto typeList, const auto& matrix, const Dune::ParameterTree& config)
33 {
34 using Matrix = typename Dune::TypeListElement<0, decltype(typeList)>::type;
35 using Domain = typename Dune::TypeListElement<1, decltype(typeList)>::type;
36 using Range = typename Dune::TypeListElement<2, decltype(typeList)>::type;
37 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner
38 = std::make_shared<Preconditioner<Matrix, Domain, Range, blockLevel>>(matrix, config);
39 return preconditioner;
40 };
41 }
42
43 template<template<class,class,class>class Preconditioner>
44 auto defaultPreconditionerCreator(){
45 return [](auto typeList, const auto& matrix, const Dune::ParameterTree& config)
46 {
47 using Matrix = typename Dune::TypeListElement<0, decltype(typeList)>::type;
48 using Domain = typename Dune::TypeListElement<1, decltype(typeList)>::type;
49 using Range = typename Dune::TypeListElement<2, decltype(typeList)>::type;
50 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner
51 = std::make_shared<Preconditioner<Matrix, Domain, Range>>(matrix, config);
52 return preconditioner;
53 };
54 }
55
56 template<template<class...>class Solver>
57 auto defaultIterativeSolverCreator(){
58 return [](auto typeList,
59 const auto& linearOperator,
60 const auto& scalarProduct,
61 const auto& preconditioner,
62 const Dune::ParameterTree& config)
63 {
64 using Domain = typename Dune::TypeListElement<0, decltype(typeList)>::type;
65 using Range = typename Dune::TypeListElement<1, decltype(typeList)>::type;
66 std::shared_ptr<Dune::InverseOperator<Domain, Range>> solver
67 = std::make_shared<Solver<Domain>>(linearOperator, scalarProduct, preconditioner, config);
68 return solver;
69 };
70 }
71
72 /* This exception is thrown, when the requested solver is in the factory but
73 cannot be instantiated for the required template parameters
74 */
75 class UnsupportedType : public NotImplemented {};
76
77 class InvalidSolverFactoryConfiguration : public InvalidStateException{};
78} // end namespace Dune
79
80#endif // DUNE_ISTL_SOLVERREGISTRY_HH
Hierarchical structure of string parameters.
Definition: parametertree.hh:35
Dune namespace.
Definition: alignedallocator.hh:11
constexpr std::size_t blockLevel()
Determine the block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:174
Define general, extensible interface for inverse operators.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)