dune-functions 2.9.0
functionspacebases/concepts.hh
Go to the documentation of this file.
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
7#include <dune/common/concept.hh>
8#include <dune/common/reservedvector.hh>
9
11
13
14
15namespace Dune {
16namespace Functions {
17namespace Concept {
18
19using namespace Dune::Concept;
20
21
23{
24 template<class C>
25 auto require(C&& c) -> decltype(
26 c.resize(0)
27 );
28};
29
30
31
33{
34 template<class C>
35 auto require(C&& c) -> decltype(
36 c.size()
37 );
38};
39
40
41
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
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>
125{
126private:
127 template<class PB>
128 using MultiIndex = Dune::ReservedVector<typename PB::size_type, PB::multiIndexBufferSize>;
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>
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>
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
Definition: polynomial.hh:10
Definition: functionspacebases/concepts.hh:23
auto require(C &&c) -> decltype(c.resize(0))
Definition: functionspacebases/concepts.hh:33
auto require(C &&c) -> decltype(c.size())
Definition: functionspacebases/concepts.hh:43
auto require(C &&c, I &&i) -> decltype(c[i])
Definition: functionspacebases/concepts.hh:53
auto require(const N &node) -> decltype(requireType< typename N::size_type >(), requireConvertible< typename N::size_type >(node.size()), requireConvertible< typename N::size_type >(node.localIndex(std::declval< typename N::size_type >())), requireConvertible< typename N::size_type >(node.treeIndex()), requireBaseOf< BasisNodeMixin, N >())
Definition: functionspacebases/concepts.hh:69
auto require(const N &node) -> decltype(requireType< typename N::Element >(), requireType< typename N::FiniteElement >(), requireConvertible< typename N::Element >(node.element()), requireConvertible< const typename N::FiniteElement & >(node.finiteElement()), requireSameType< typename N::Element, typename GridView::template Codim< 0 >::Entity >(), requireBaseOf< Dune::Functions::LeafBasisNode, N >())
Definition: functionspacebases/concepts.hh:112
auto require(const N &node) -> decltype(requireConcept< typename std::conditional< N::isLeaf, LeafBasisNode< GridView >, BasisNode >::type, N >(), requireConcept< typename std::conditional< N::isPower, PowerBasisNode< GridView >, BasisNode >::type, N >(), requireConcept< typename std::conditional< N::isComposite, CompositeBasisNode< GridView >, BasisNode >::type, N >())
Definition: functionspacebases/concepts.hh:88
auto require(const N &node) -> decltype(requireBaseOf< Dune::Functions::PowerBasisNode< typename N::ChildType, N::degree()>, N >(), requireConcept< BasisTree< GridView >, typename N::ChildType >())
Definition: functionspacebases/concepts.hh:100
auto require(const N &node) -> decltype(requireBaseOf< ExpandTuple< Dune::Functions::template CompositeBasisNode, typename N::ChildTypes >, N >(), requireConceptForTupleEntries< BasisTree< GridView >, typename N::ChildTypes >())
Definition: functionspacebases/concepts.hh:125
auto require(const PB &preBasis) -> decltype(requireType< typename PB::GridView >(), requireType< typename PB::size_type >(), requireType< typename PB::Node >(), requireConvertible< decltype(PB::maxMultiIndexSize), typename PB::size_type >(), requireConvertible< decltype(PB::maxMultiIndexSize), typename PB::size_type >(), requireConvertible< decltype(PB::multiIndexBufferSize), typename PB::size_type >(), requireTrue< PB::minMultiIndexSize<=PB::maxMultiIndexSize >(), requireTrue< PB::maxMultiIndexSize<=PB::multiIndexBufferSize >(), requireSameType< typename PB::GridView, GridView >(), const_cast< PB & >(preBasis).initializeIndices(), requireConvertible< typename PB::GridView >(preBasis.gridView()), requireConvertible< typename PB::Node >(preBasis.makeNode()), requireConvertible< typename PB::size_type >(preBasis.size()), requireConvertible< typename PB::size_type >(preBasis.size(std::declval< MultiIndex< PB > >())), requireConvertible< typename PB::size_type >(preBasis.dimension()), requireConvertible< typename PB::size_type >(preBasis.maxNodeSize()), requireSameType< decltype(const_cast< PB & >(preBasis).update(preBasis.gridView())), void >(), requireConcept< BasisTree< typename PB::GridView > >(preBasis.makeNode()), requireConvertible< typename std::vector< MultiIndex< PB > >::iterator >(preBasis.indices(preBasis.makeNode(), std::declval< typename std::vector< MultiIndex< PB > >::iterator >())))
Definition: functionspacebases/concepts.hh:163
auto require(const V &localView) -> decltype(requireType< typename V::size_type >(), requireType< typename V::MultiIndex >(), requireType< typename V::GlobalBasis >(), requireType< typename V::Tree >(), requireType< typename V::GridView >(), requireType< typename V::Element >(), requireSameType< typename V::GlobalBasis, GlobalBasis >(), requireSameType< typename V::GridView, typename GlobalBasis::GridView >(), requireSameType< typename V::size_type, typename GlobalBasis::size_type >(), requireSameType< typename V::Element, typename GlobalBasis::GridView::template Codim< 0 >::Entity >(), const_cast< V & >(localView).bind(std::declval< typename V::Element >()), const_cast< V & >(localView).unbind(), requireConvertible< bool >(localView.bound()), requireConvertible< typename V::Tree >(localView.tree()), requireConvertible< typename V::size_type >(localView.size()), requireConvertible< typename V::MultiIndex >(localView.index(std::declval< typename V::size_type >())), requireConvertible< typename V::size_type >(localView.maxSize()), requireConvertible< typename V::GlobalBasis >(localView.globalBasis()), requireConcept< BasisTree< typename V::GridView > >(localView.tree()), 0)
Definition: functionspacebases/concepts.hh:194
auto require(const B &basis) -> decltype(requireType< typename B::GridView >(), requireType< typename B::size_type >(), requireType< typename B::MultiIndex >(), requireType< typename B::SizePrefix >(), requireType< typename B::LocalView >(), requireSameType< typename B::GridView, GridView >(), requireConvertible< typename B::GridView >(basis.gridView()), requireConvertible< typename B::LocalView >(basis.localView()), requireConvertible< typename B::size_type >(basis.size()), requireConvertible< typename B::size_type >(basis.size(std::declval< typename B::SizePrefix >())), requireConvertible< typename B::size_type >(basis.dimension()), requireSameType< decltype(const_cast< B & >(basis).update(basis.gridView())), void >(), requireConcept< LocalView< B > >(basis.localView()))
Definition: nodes.hh:193