DUNE PDELab (git)

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
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_CONCEPTS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_CONCEPTS_HH
9
10
13
14#include <dune/functions/common/utility.hh>
15
16#include <dune/functions/functionspacebases/nodes.hh>
17
18
19namespace Dune {
20namespace Functions {
21namespace Concept {
22
23using namespace Dune::Concept;
24
25
26struct HasResize
27{
28 template<class C>
29 auto require(C&& c) -> decltype(
30 c.resize(0)
31 );
32};
33
34
35
36struct HasSizeMethod
37{
38 template<class C>
39 auto require(C&& c) -> decltype(
40 c.size()
41 );
42};
43
44
45
46struct HasIndexAccess
47{
48 template<class C, class I>
49 auto require(C&& c, I&& i) -> decltype(
50 c[i]
51 );
52};
53
54
55// Concept for a BasisNode in a local ansatz tree
56struct BasisNode
57{
58 template<class N>
59 auto require(const N& node) -> decltype(
60 requireType<typename N::size_type>(),
61 requireConvertible<typename N::size_type>(node.size()),
62 requireConvertible<typename N::size_type>(node.localIndex(std::declval<typename N::size_type>())),
63 requireConvertible<typename N::size_type>(node.treeIndex()),
64 requireBaseOf<BasisNodeMixin, N>()
65 );
66};
67
68
69
70// Concept for a LeafBasisNode in a local ansatz tree
71template<class GridView>
72struct LeafBasisNode : Refines<BasisNode>
73{
74 template<class N>
75 auto require(const N& node) -> decltype(
76 requireType<typename N::Element>(),
77 requireType<typename N::FiniteElement>(),
78 requireConvertible<typename N::Element>(node.element()),
79 requireConvertible<const typename N::FiniteElement&>(node.finiteElement()),
80 requireSameType<typename N::Element, typename GridView::template Codim<0>::Entity>(),
81 requireBaseOf<Dune::Functions::LeafBasisNode, N>()
82 );
83};
84
85
86template<class GridView>
87struct BasisTree;
88
89// Concept for a PowerBasisNode in a local ansatz tree
90template<class GridView>
91struct PowerBasisNode : Refines<BasisNode>
92{
93 template<class N>
94 auto require(const N& node) -> decltype(
95 requireBaseOf<Dune::Functions::PowerBasisNode<typename N::ChildType, N::degree()>, N>(),
96 requireConcept<BasisTree<GridView>, typename N::ChildType>()
97 );
98};
99
100// Concept for a DynamicPowerBasisNode in a local ansatz tree
101template<class GridView>
102struct DynamicPowerBasisNode : Refines<BasisNode>
103{
104 template<class N>
105 auto require(const N& node) -> decltype(
106 requireBaseOf<Dune::Functions::DynamicPowerBasisNode<typename N::ChildType>, N>(),
107 requireConcept<BasisTree<GridView>, typename N::ChildType>()
108 );
109};
110
111// Concept for a CompositeBasisNode in a local ansatz tree
112template<class GridView>
113struct CompositeBasisNode : Refines<BasisNode>
114{
115 template<class N>
116 auto require(const N& node) -> decltype(
117 requireBaseOf<ExpandTuple<Dune::Functions::template CompositeBasisNode, typename N::ChildTypes>, N>(),
118 requireConceptForTupleEntries<BasisTree<GridView>, typename N::ChildTypes>()
119 );
120};
121
122
123// Concept for a full local BasisTree
124template<class GridView>
125struct BasisTree : Refines<BasisNode>
126{
127 template<class N, class NodeTag = typename N::NodeTag>
128 auto require(const N& node) -> decltype(
129 requireConcept<std::conditional_t<N::isLeaf, LeafBasisNode<GridView>, BasisNode>, N>(),
130 requireConcept<std::conditional_t<std::is_same_v<NodeTag, Dune::TypeTree::PowerNodeTag>,
131 PowerBasisNode<GridView>, BasisNode>, N>(),
132 requireConcept<std::conditional_t<std::is_same_v<NodeTag, Dune::TypeTree::DynamicPowerNodeTag>,
133 DynamicPowerBasisNode<GridView>, BasisNode>, N>(),
134 requireConcept<std::conditional_t<N::isComposite, CompositeBasisNode<GridView>, BasisNode>, N>()
135 );
136};
137
138
139// Concept for a PreBasis
140template<class GridView>
141struct PreBasis
142{
143private:
144 template<class PB>
146
147public:
148 template<class PB>
149 auto require(const PB& preBasis) -> decltype(
150 requireType<typename PB::GridView>(),
151 requireType<typename PB::size_type>(),
152 requireType<typename PB::Node>(),
153 requireConvertible<decltype(PB::maxMultiIndexSize), typename PB::size_type>(),
154 requireConvertible<decltype(PB::maxMultiIndexSize), typename PB::size_type>(),
155 requireConvertible<decltype(PB::multiIndexBufferSize), typename PB::size_type>(),
156 requireTrue<PB::minMultiIndexSize <= PB::maxMultiIndexSize>(),
157 requireTrue<PB::maxMultiIndexSize <= PB::multiIndexBufferSize>(),
158 requireSameType<typename PB::GridView, GridView>(),
159 const_cast<PB&>(preBasis).initializeIndices(),
160 requireConvertible<typename PB::GridView>(preBasis.gridView()),
161 requireConvertible<typename PB::Node>(preBasis.makeNode()),
162 requireConvertible<typename PB::size_type>(preBasis.size()),
163 requireConvertible<typename PB::size_type>(preBasis.size(std::declval<MultiIndex<PB>>())),
164 requireConvertible<typename PB::size_type>(preBasis.dimension()),
165 requireConvertible<typename PB::size_type>(preBasis.maxNodeSize()),
166 requireSameType<decltype(const_cast<PB&>(preBasis).update(preBasis.gridView())),void>(),
167 requireConcept<BasisTree<typename PB::GridView>>(preBasis.makeNode()),
168 requireConvertible<typename std::vector<MultiIndex<PB>>::iterator>(
169 preBasis.indices(
170 preBasis.makeNode(),
171 std::declval<typename std::vector<MultiIndex<PB>>::iterator>()))
172 );
173};
174
175
176
177// Concept for a LocalView
178template<class GlobalBasis>
179struct LocalView
180{
181 template<class V>
182 auto require(const V& localView) -> decltype(
183 requireType<typename V::size_type>(),
184 requireType<typename V::MultiIndex>(),
185 requireType<typename V::GlobalBasis>(),
186 requireType<typename V::Tree>(),
187 requireType<typename V::GridView>(),
188 requireType<typename V::Element>(),
189 requireSameType<typename V::GlobalBasis, GlobalBasis>(),
190 requireSameType<typename V::GridView, typename GlobalBasis::GridView>(),
191 requireSameType<typename V::size_type, typename GlobalBasis::size_type>(),
192 requireSameType<typename V::Element, typename GlobalBasis::GridView::template Codim<0>::Entity>(),
193 const_cast<V&>(localView).bind(std::declval<typename V::Element>()),
194 const_cast<V&>(localView).unbind(),
195 requireConvertible<bool>(localView.bound()),
196 requireConvertible<typename V::Tree>(localView.tree()),
197 requireConvertible<typename V::size_type>(localView.size()),
198 requireConvertible<typename V::MultiIndex>(localView.index(std::declval<typename V::size_type>())),
199 requireConvertible<typename V::size_type>(localView.maxSize()),
200 requireConvertible<typename V::GlobalBasis>(localView.globalBasis()),
201 requireConcept<BasisTree<typename V::GridView>>(localView.tree()),
202 0
203 );
204};
205
206
207
208// Concept for a GlobalBasis
209template<class GridView>
210struct GlobalBasis
211{
212 template<class B>
213 auto require(const B& basis) -> decltype(
214 requireType<typename B::GridView>(),
215 requireType<typename B::size_type>(),
216 requireType<typename B::MultiIndex>(),
217 requireType<typename B::SizePrefix>(),
218 requireType<typename B::LocalView>(),
219 requireSameType<typename B::GridView, GridView>(),
220 requireConvertible<typename B::GridView>(basis.gridView()),
221 requireConvertible<typename B::LocalView>(basis.localView()),
222 requireConvertible<typename B::size_type>(basis.size()),
223 requireConvertible<typename B::size_type>(basis.size(std::declval<typename B::SizePrefix>())),
224 requireConvertible<typename B::size_type>(basis.dimension()),
225 requireSameType<decltype(const_cast<B&>(basis).update(basis.gridView())),void>(),
226 requireConcept<LocalView<B>>(basis.localView())
227 );
228};
229
230
231
232} // namespace Dune::Functions::Concept
233} // namespace Dune::Functions
234} // namespace Dune
235
236
237#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:79
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 (Nov 24, 23:30, 2024)