Dune Core Modules (2.9.0)

concepts.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_CONCEPTS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_CONCEPTS_HH
5
6
9
10#include <dune/functions/common/utility.hh>
11
12#include <dune/functions/functionspacebases/nodes.hh>
13
14
15namespace Dune {
16namespace Functions {
17namespace Concept {
18
19using namespace Dune::Concept;
20
21
22struct HasResize
23{
24 template<class C>
25 auto require(C&& c) -> decltype(
26 c.resize(0)
27 );
28};
29
30
31
32struct HasSizeMethod
33{
34 template<class C>
35 auto require(C&& c) -> decltype(
36 c.size()
37 );
38};
39
40
41
42struct HasIndexAccess
43{
44 template<class C, class I>
45 auto require(C&& c, I&& i) -> decltype(
46 c[i]
47 );
48};
49
50
51// Concept for a BasisNode in a local ansatz tree
52struct BasisNode
53{
54 template<class N>
55 auto require(const N& node) -> decltype(
56 requireType<typename N::size_type>(),
57 requireConvertible<typename N::size_type>(node.size()),
58 requireConvertible<typename N::size_type>(node.localIndex(std::declval<typename N::size_type>())),
59 requireConvertible<typename N::size_type>(node.treeIndex()),
60 requireBaseOf<BasisNodeMixin, N>()
61 );
62};
63
64
65
66// Concept for a LeafBasisNode in a local ansatz tree
67template<class GridView>
68struct LeafBasisNode : Refines<BasisNode>
69{
70 template<class N>
71 auto require(const N& node) -> decltype(
72 requireType<typename N::Element>(),
73 requireType<typename N::FiniteElement>(),
74 requireConvertible<typename N::Element>(node.element()),
75 requireConvertible<const typename N::FiniteElement&>(node.finiteElement()),
76 requireSameType<typename N::Element, typename GridView::template Codim<0>::Entity>(),
77 requireBaseOf<Dune::Functions::LeafBasisNode, N>()
78 );
79};
80
81
82template<class GridView>
83struct BasisTree;
84
85// Concept for a PowerBasisNode in a local ansatz tree
86template<class GridView>
87struct PowerBasisNode : Refines<BasisNode>
88{
89 template<class N>
90 auto require(const N& node) -> decltype(
91 requireBaseOf<Dune::Functions::PowerBasisNode<typename N::ChildType, N::degree()>, N>(),
92 requireConcept<BasisTree<GridView>, typename N::ChildType>()
93 );
94};
95
96
97// Concept for a CompositeBasisNode in a local ansatz tree
98template<class GridView>
99struct CompositeBasisNode : Refines<BasisNode>
100{
101 template<class N>
102 auto require(const N& node) -> decltype(
103 requireBaseOf<ExpandTuple<Dune::Functions::template CompositeBasisNode, typename N::ChildTypes>, N>(),
104 requireConceptForTupleEntries<BasisTree<GridView>, typename N::ChildTypes>()
105 );
106};
107
108
109// Concept for a full local BasisTree
110template<class GridView>
111struct BasisTree : Refines<BasisNode>
112{
113 template<class N>
114 auto require(const N& node) -> decltype(
115 requireConcept<typename std::conditional< N::isLeaf, LeafBasisNode<GridView>, BasisNode>::type, N>(),
116 requireConcept<typename std::conditional< N::isPower, PowerBasisNode<GridView>, BasisNode>::type, N>(),
117 requireConcept<typename std::conditional< N::isComposite, CompositeBasisNode<GridView>, BasisNode>::type, N>()
118 );
119};
120
121
122// Concept for a PreBasis
123template<class GridView>
124struct PreBasis
125{
126private:
127 template<class PB>
129
130public:
131 template<class PB>
132 auto require(const PB& preBasis) -> decltype(
133 requireType<typename PB::GridView>(),
134 requireType<typename PB::size_type>(),
135 requireType<typename PB::Node>(),
136 requireConvertible<decltype(PB::maxMultiIndexSize), typename PB::size_type>(),
137 requireConvertible<decltype(PB::maxMultiIndexSize), typename PB::size_type>(),
138 requireConvertible<decltype(PB::multiIndexBufferSize), typename PB::size_type>(),
139 requireTrue<PB::minMultiIndexSize <= PB::maxMultiIndexSize>(),
140 requireTrue<PB::maxMultiIndexSize <= PB::multiIndexBufferSize>(),
141 requireSameType<typename PB::GridView, GridView>(),
142 const_cast<PB&>(preBasis).initializeIndices(),
143 requireConvertible<typename PB::GridView>(preBasis.gridView()),
144 requireConvertible<typename PB::Node>(preBasis.makeNode()),
145 requireConvertible<typename PB::size_type>(preBasis.size()),
146 requireConvertible<typename PB::size_type>(preBasis.size(std::declval<MultiIndex<PB>>())),
147 requireConvertible<typename PB::size_type>(preBasis.dimension()),
148 requireConvertible<typename PB::size_type>(preBasis.maxNodeSize()),
149 requireSameType<decltype(const_cast<PB&>(preBasis).update(preBasis.gridView())),void>(),
150 requireConcept<BasisTree<typename PB::GridView>>(preBasis.makeNode()),
151 requireConvertible<typename std::vector<MultiIndex<PB>>::iterator>(
152 preBasis.indices(
153 preBasis.makeNode(),
154 std::declval<typename std::vector<MultiIndex<PB>>::iterator>()))
155 );
156};
157
158
159
160// Concept for a LocalView
161template<class GlobalBasis>
162struct LocalView
163{
164 template<class V>
165 auto require(const V& localView) -> decltype(
166 requireType<typename V::size_type>(),
167 requireType<typename V::MultiIndex>(),
168 requireType<typename V::GlobalBasis>(),
169 requireType<typename V::Tree>(),
170 requireType<typename V::GridView>(),
171 requireType<typename V::Element>(),
172 requireSameType<typename V::GlobalBasis, GlobalBasis>(),
173 requireSameType<typename V::GridView, typename GlobalBasis::GridView>(),
174 requireSameType<typename V::size_type, typename GlobalBasis::size_type>(),
175 requireSameType<typename V::Element, typename GlobalBasis::GridView::template Codim<0>::Entity>(),
176 const_cast<V&>(localView).bind(std::declval<typename V::Element>()),
177 const_cast<V&>(localView).unbind(),
178 requireConvertible<bool>(localView.bound()),
179 requireConvertible<typename V::Tree>(localView.tree()),
180 requireConvertible<typename V::size_type>(localView.size()),
181 requireConvertible<typename V::MultiIndex>(localView.index(std::declval<typename V::size_type>())),
182 requireConvertible<typename V::size_type>(localView.maxSize()),
183 requireConvertible<typename V::GlobalBasis>(localView.globalBasis()),
184 requireConcept<BasisTree<typename V::GridView>>(localView.tree()),
185 0
186 );
187};
188
189
190
191// Concept for a GlobalBasis
192template<class GridView>
193struct GlobalBasis
194{
195 template<class B>
196 auto require(const B& basis) -> decltype(
197 requireType<typename B::GridView>(),
198 requireType<typename B::size_type>(),
199 requireType<typename B::MultiIndex>(),
200 requireType<typename B::SizePrefix>(),
201 requireType<typename B::LocalView>(),
202 requireSameType<typename B::GridView, GridView>(),
203 requireConvertible<typename B::GridView>(basis.gridView()),
204 requireConvertible<typename B::LocalView>(basis.localView()),
205 requireConvertible<typename B::size_type>(basis.size()),
206 requireConvertible<typename B::size_type>(basis.size(std::declval<typename B::SizePrefix>())),
207 requireConvertible<typename B::size_type>(basis.dimension()),
208 requireSameType<decltype(const_cast<B&>(basis).update(basis.gridView())),void>(),
209 requireConcept<LocalView<B>>(basis.localView())
210 );
211};
212
213
214
215} // namespace Dune::Functions::Concept
216} // namespace Dune::Functions
217} // namespace Dune
218
219
220#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_CONCEPTS_HH
A Vector class with statically reserved memory.
Definition: reservedvector.hh:47
Infrastructure for concepts.
std::size_t degree(const Node &node)
Returns the degree of node as run time information.
Definition: nodeinterface.hh:85
Namespace for concepts.
Definition: concept.hh:34
Dune namespace.
Definition: alignedallocator.hh:13
An stl-compliant random-access container which stores everything on the stack.
Base class for refined concepts.
Definition: concept.hh:54
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)