Loading [MathJax]/extensions/tex2jax.js

DUNE PDELab (unstable)

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>
128 static constexpr bool hasStaticDegree() {
129 return requires() { N::degree(); };
130 }
131
132 template<class N>
133 auto require(const N& node) -> decltype(
134 requireConcept<std::conditional_t<N::isLeaf, LeafBasisNode<GridView>, BasisNode>, N>(),
135 requireConcept<std::conditional_t<N::isPower and hasStaticDegree<N>(), PowerBasisNode<GridView>, BasisNode>, N>(),
136 requireConcept<std::conditional_t<N::isPower and not hasStaticDegree<N>(), DynamicPowerBasisNode<GridView>, BasisNode>, N>(),
137 requireConcept<std::conditional_t<N::isComposite, CompositeBasisNode<GridView>, BasisNode>, N>()
138 );
139};
140
141
142// Concept for a PreBasis
143template<class GridView>
144struct PreBasis
145{
146private:
147 template<class PB>
149
150public:
151 template<class PB>
152 auto require(const PB& preBasis) -> decltype(
153 requireType<typename PB::GridView>(),
154 requireType<typename PB::size_type>(),
155 requireType<typename PB::Node>(),
156 requireConvertible<decltype(PB::maxMultiIndexSize), typename PB::size_type>(),
157 requireConvertible<decltype(PB::maxMultiIndexSize), typename PB::size_type>(),
158 requireConvertible<decltype(PB::multiIndexBufferSize), typename PB::size_type>(),
159 requireTrue<PB::minMultiIndexSize <= PB::maxMultiIndexSize>(),
160 requireTrue<PB::maxMultiIndexSize <= PB::multiIndexBufferSize>(),
161 requireSameType<typename PB::GridView, GridView>(),
162 const_cast<PB&>(preBasis).initializeIndices(),
163 requireConvertible<typename PB::GridView>(preBasis.gridView()),
164 requireConvertible<typename PB::Node>(preBasis.makeNode()),
165 requireConvertible<typename PB::size_type>(preBasis.size()),
166 requireConvertible<typename PB::size_type>(preBasis.size(std::declval<MultiIndex<PB>>())),
167 requireConvertible<typename PB::size_type>(preBasis.dimension()),
168 requireConvertible<typename PB::size_type>(preBasis.maxNodeSize()),
169 requireSameType<decltype(const_cast<PB&>(preBasis).update(preBasis.gridView())),void>(),
170 requireConcept<BasisTree<typename PB::GridView>>(preBasis.makeNode()),
171 requireConvertible<typename std::vector<MultiIndex<PB>>::iterator>(
172 preBasis.indices(
173 preBasis.makeNode(),
174 std::declval<typename std::vector<MultiIndex<PB>>::iterator>()))
175 );
176};
177
178
179
180// Concept for a LocalView
181template<class GlobalBasis>
182struct LocalView
183{
184 template<class V>
185 auto require(const V& localView) -> decltype(
186 requireType<typename V::size_type>(),
187 requireType<typename V::MultiIndex>(),
188 requireType<typename V::GlobalBasis>(),
189 requireType<typename V::Tree>(),
190 requireType<typename V::GridView>(),
191 requireType<typename V::Element>(),
192 requireSameType<typename V::GlobalBasis, GlobalBasis>(),
193 requireSameType<typename V::GridView, typename GlobalBasis::GridView>(),
194 requireSameType<typename V::size_type, typename GlobalBasis::size_type>(),
195 requireSameType<typename V::Element, typename GlobalBasis::GridView::template Codim<0>::Entity>(),
196 const_cast<V&>(localView).bind(std::declval<typename V::Element>()),
197 const_cast<V&>(localView).unbind(),
198 requireConvertible<bool>(localView.bound()),
199 requireConvertible<typename V::Tree>(localView.tree()),
200 requireConvertible<typename V::size_type>(localView.size()),
201 requireConvertible<typename V::MultiIndex>(localView.index(std::declval<typename V::size_type>())),
202 requireConvertible<typename V::size_type>(localView.maxSize()),
203 requireConvertible<typename V::GlobalBasis>(localView.globalBasis()),
204 requireConcept<BasisTree<typename V::GridView>>(localView.tree()),
205 0
206 );
207};
208
209
210
211// Concept for a GlobalBasis
212template<class GridView>
213struct GlobalBasis
214{
215 template<class B>
216 auto require(const B& basis) -> decltype(
217 requireType<typename B::GridView>(),
218 requireType<typename B::size_type>(),
219 requireType<typename B::MultiIndex>(),
220 requireType<typename B::SizePrefix>(),
221 requireType<typename B::LocalView>(),
222 requireSameType<typename B::GridView, GridView>(),
223 requireConvertible<typename B::GridView>(basis.gridView()),
224 requireConvertible<typename B::LocalView>(basis.localView()),
225 requireConvertible<typename B::size_type>(basis.size()),
226 requireConvertible<typename B::size_type>(basis.size(std::declval<typename B::SizePrefix>())),
227 requireConvertible<typename B::size_type>(basis.dimension()),
228 requireSameType<decltype(const_cast<B&>(basis).update(basis.gridView())),void>(),
229 requireConcept<LocalView<B>>(basis.localView())
230 );
231};
232
233
234
235} // namespace Dune::Functions::Concept
236} // namespace Dune::Functions
237} // namespace Dune
238
239
240#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 & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 4, 22:59, 2025)