dune-istl 2.10
Loading...
Searching...
No Matches
solverregistry.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5
6#ifndef DUNE_ISTL_SOLVERREGISTRY_HH
7#define DUNE_ISTL_SOLVERREGISTRY_HH
8
11#include <dune/istl/solver.hh>
12
13#define DUNE_REGISTER_DIRECT_SOLVER(name, ...) \
14 DUNE_REGISTRY_PUT(DirectSolverTag, name, __VA_ARGS__)
15
16#define DUNE_REGISTER_PRECONDITIONER(name, ...) \
17 DUNE_REGISTRY_PUT(PreconditionerTag, name, __VA_ARGS__)
18
19#define DUNE_REGISTER_ITERATIVE_SOLVER(name, ...) \
20 DUNE_REGISTRY_PUT(IterativeSolverTag, name, __VA_ARGS__)
21
22namespace Dune{
27 namespace {
28 struct DirectSolverTag {};
29 struct PreconditionerTag {};
30 struct IterativeSolverTag {};
31 }
32 template<template<class,class,class,int>class Preconditioner, int blockLevel=1>
34 return [](auto typeList, const auto& matrix, const Dune::ParameterTree& config)
35 {
36 using Matrix = typename Dune::TypeListElement<0, decltype(typeList)>::type;
37 using Domain = typename Dune::TypeListElement<1, decltype(typeList)>::type;
38 using Range = typename Dune::TypeListElement<2, decltype(typeList)>::type;
39 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner
40 = std::make_shared<Preconditioner<Matrix, Domain, Range, blockLevel>>(matrix, config);
41 return preconditioner;
42 };
43 }
44
45 template<template<class,class,class>class Preconditioner>
47 return [](auto typeList, const auto& matrix, const Dune::ParameterTree& config)
48 {
49 using Matrix = typename Dune::TypeListElement<0, decltype(typeList)>::type;
50 using Domain = typename Dune::TypeListElement<1, decltype(typeList)>::type;
51 using Range = typename Dune::TypeListElement<2, decltype(typeList)>::type;
52 std::shared_ptr<Dune::Preconditioner<Domain, Range>> preconditioner
53 = std::make_shared<Preconditioner<Matrix, Domain, Range>>(matrix, config);
54 return preconditioner;
55 };
56 }
57
58 template<template<class...>class Solver>
60 return [](auto typeList,
61 const auto& linearOperator,
62 const auto& scalarProduct,
63 const auto& preconditioner,
64 const Dune::ParameterTree& config)
65 {
66 using Domain = typename Dune::TypeListElement<0, decltype(typeList)>::type;
67 using Range = typename Dune::TypeListElement<1, decltype(typeList)>::type;
68 std::shared_ptr<Dune::InverseOperator<Domain, Range>> solver
69 = std::make_shared<Solver<Domain>>(linearOperator, scalarProduct, preconditioner, config);
70 return solver;
71 };
72 }
73
74 /* This exception is thrown, when the requested solver is in the factory but
75 cannot be instantiated for the required template parameters
76 */
77 class UnsupportedType : public NotImplemented {};
78
79 class InvalidSolverFactoryConfiguration : public InvalidStateException{};
80} // end namespace Dune
81
82#endif // DUNE_ISTL_SOLVERREGISTRY_HH
Define general, extensible interface for inverse operators.
auto defaultIterativeSolverCreator()
Definition solverregistry.hh:59
auto defaultPreconditionerBlockLevelCreator()
Definition solverregistry.hh:33
auto defaultPreconditionerCreator()
Definition solverregistry.hh:46
Definition allocator.hh:11
constexpr std::size_t blockLevel()
Determine the block level of a possibly nested vector/matrix type.
Definition blocklevel.hh:176
A generic dynamic dense matrix.
Definition matrixutils.hh:30
Definition solverregistry.hh:77
Definition solverregistry.hh:79