Dune Core Modules (2.9.1)

solverregistry.hh
1// SPDX-FileCopyrightText: Copyright (C) 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
9#include <dune/istl/common/registry.hh>
10#include <dune/istl/preconditioner.hh>
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>
33 auto defaultPreconditionerBlockLevelCreator(){
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>
46 auto defaultPreconditionerCreator(){
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>
59 auto defaultIterativeSolverCreator(){
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
Hierarchical structure of string parameters.
Definition: parametertree.hh:37
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.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)