AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Concepts.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <dune/functions/common/functionconcepts.hh>
6#include <dune/functions/functionspacebases/concepts.hh>
7
8#include <amdis/common/ConceptsBase.hpp>
9#include <amdis/common/Logical.hpp>
10#include <amdis/common/TypeTraits.hpp>
11
12namespace AMDiS
13{
20 namespace Traits
21 {
22 template <class A, class B>
23 struct IsSimilar
24 : std::is_same<remove_cvref_t<A>, remove_cvref_t<B>> {};
25
26 template <class A, class B>
27 struct IsSimilar<Types<A>, Types<B>>
28 : IsSimilar<A,B> {};
29
30 template <>
31 struct IsSimilar<Types<>, Types<>> : std::true_type {};
32
33 template <class A0, class... As, class B0, class... Bs>
34 struct IsSimilar<Types<A0,As...>, Types<B0,Bs...>>
35 : and_t<IsSimilar<A0, B0>::value, IsSimilar<Types<As...>, Types<Bs...>>::value> {};
36
37
38 template <class... Ts>
39 struct IsSame;
40
41 template <class T0, class... Ts>
42 struct IsSame<T0, Ts...>
43 : std::is_same<Types<T0,Ts...>, Types<Ts...,T0>> {};
44
45 template <>
46 struct IsSame<> : std::true_type {};
47
48
49 template <class T>
51 : std::false_type {};
52
53 template <class T>
54 struct IsReferenceWrapper<std::reference_wrapper<T>>
55 : std::true_type {};
56
57 } // end namespace Traits
58
59
60 namespace Concepts
61 {
62#ifndef DOXYGEN
63 namespace Definition
64 {
65 // f(args...)
66 struct Callable
67 {
68 template <class F, class... Args>
69 auto require(F&& f, Args&&... args) -> decltype(
70 f(FWD(args)...)
71 );
72 };
73
74 // idx[0]
76 {
77 template <class MI>
78 auto require(MI&& idx) -> decltype(
79 idx[0],
80 idx.size(),
81 idx.max_size()
82 );
83 };
84
86 {
87 template <class PBF, class GV>
88 auto require(PBF const& pbf, GV const& gridView) -> decltype(
89 pbf(gridView)
90 );
91 };
92
93 } // end namespace Definition
94#endif // DOXYGEN
95
96
98 template <class... Ts>
99 constexpr bool Same = Traits::IsSame<Ts...>::value;
100
101 template <class... Ts>
102 using Same_t = Traits::IsSame<Ts...>;
103
104
106 template <class A, class B>
108
109 template <class A, class B>
111
112
114
119 template <class F, class... Args>
120 constexpr bool Callable = models<Definition::Callable(F, Args...)>;
121
122 template <class F, class... Args>
123 using Callable_t = models_t<Definition::Callable(F, Args...)>;
124
125
127
132 template <class F, class Signature> // F, Signature=Return(Arg)
133 constexpr bool Functor = Dune::Functions::Concept::isFunction<F, Signature>();
134
135 template <class F, class Signature> // F, Signature=Return(Arg)
136 using Functor_t = bool_t<Functor<F,Signature>>;
137
138
140 template <class F, class... Args>
141 constexpr bool Predicate = Functor<F, bool(Args...)>;
142
143 template <class F, class... Args>
144 using Predicate_t = Functor_t<F, bool(Args...)>;
145
146
148 template <class MI>
149 constexpr bool MultiIndex = models<Definition::MultiIndex(MI)>;
150
151 template <class MI>
152 using MultiIndex_t = models_t<Definition::MultiIndex(MI)>;
153
154
156 template <class Range, class Index>
157 constexpr bool HasIndexAccess = models<Dune::Functions::Concept::HasIndexAccess(Range, Index)>;
158
159 template <class Range, class Index>
160 using HasIndexAccess_t = models_t<Dune::Functions::Concept::HasIndexAccess(Range, Index)>;
161
162
164 template <class N>
166
167 template <class N>
168 using BasisNode_t = models_t<Dune::Functions::Concept::BasisNode(N)>;
169
170
172 template <class Tree, class GV>
173 constexpr bool BasisTree = models<Dune::Functions::Concept::BasisTree<GV>(Tree)>;
174
175 template <class Tree, class GV>
176 using BasisTree_t = models_t<Dune::Functions::Concept::BasisTree<GV>(Tree)>;
177
178
180 template <class LV, class GB = typename LV::GlobalBasis>
181 constexpr bool LocalView = models<Dune::Functions::Concept::LocalView<GB>(LV)>;
182
183 template <class LV, class GB = typename LV::GlobalBasis>
184 using LocalView_t = models_t<Dune::Functions::Concept::LocalView<GB>(LV)>;
185
186
188 template <class GB, class GV = typename GB::GridView>
189 constexpr bool GlobalBasis = models<Dune::Functions::Concept::GlobalBasis<GV>(GB)>;
190
191 template <class GB, class GV = typename GB::GridView>
192 using GlobalBasis_t = models_t<Dune::Functions::Concept::GlobalBasis<GV>(GB)>;
193
194 template <class PBF, class GV>
195 constexpr bool PreBasisFactory = models<Definition::PreBasisFactory(PBF,GV)>;
196
197 template <class PBF, class GV>
198 using PreBasisFactory_t = models_t<Definition::PreBasisFactory(PBF,GV)>;
199
202 } // end namespace Concepts
203} // end namespace AMDiS
Global basis defined on a pre-basis.
Definition: GlobalBasis.hpp:48
The restriction of a finite element basis to a single element.
Definition: LocalView.hpp:16
constexpr bool MultiIndex
A multi-index type.
Definition: Concepts.hpp:149
constexpr bool Similar
Types are the same, up to decay of qualifiers.
Definition: Concepts.hpp:107
constexpr bool Predicate
A predicate is a function that returns a boolean.
Definition: Concepts.hpp:141
constexpr bool Same
Types are the same.
Definition: Concepts.hpp:99
constexpr bool BasisTree
A Dune::Functions::BasisTree type.
Definition: Concepts.hpp:173
constexpr bool BasisNode
A Dune::Functions::BasisNode type.
Definition: Concepts.hpp:165
constexpr bool Functor
A Functor is a function F with signature Signature.
Definition: Concepts.hpp:133
constexpr bool Callable
A Collable is a function F that can be called with arguments of type Args....
Definition: Concepts.hpp:120
constexpr bool HasIndexAccess
A Dune::Functions::HasIndexAccess type.
Definition: Concepts.hpp:157
Definition: Concepts.hpp:67
Definition: Concepts.hpp:76
Definition: Concepts.hpp:51
Definition: Concepts.hpp:39
Definition: Concepts.hpp:24
A variadic type list.
Definition: TypeTraits.hpp:146