DUNE PDELab (git)

transformedindexbasis.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_TRANSFORMEDINDEXBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDINDEXBASIS_HH
5
6#include <tuple>
7#include <utility>
8
9#include <dune/common/hybridutilities.hh>
12#include <dune/common/hybridutilities.hh>
13
14#include <dune/typetree/compositenode.hh>
15#include <dune/typetree/utility.hh>
16
17#include <dune/functions/common/staticforloop.hh>
18#include <dune/functions/common/type_traits.hh>
19#include <dune/functions/common/utility.hh>
20#include <dune/functions/functionspacebases/basistags.hh>
21#include <dune/functions/functionspacebases/nodes.hh>
22#include <dune/functions/functionspacebases/concepts.hh>
23#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
24
25
26namespace Dune {
27namespace Functions {
28namespace Experimental {
29
30// *****************************************************************************
31// *****************************************************************************
32
49template<class RPB, class T>
51{
52 using Transformation = T;
53
55
56public:
57
58 using RawPreBasis = RPB;
59
61 using GridView = typename RawPreBasis::GridView;
62
64 using size_type = std::size_t;
65
67 using Node = typename RawPreBasis::Node;
68
69 static constexpr size_type maxMultiIndexSize = Transformation::maxIndexSize;
70 static constexpr size_type minMultiIndexSize = Transformation::minIndexSize;
71 static constexpr size_type multiIndexBufferSize = std::max(RawPreBasis::multiIndexBufferSize, maxMultiIndexSize);
72
78 template<class RPB_R, class T_R>
79 TransformedIndexPreBasis(RPB_R&& rawPreBasis, T_R&& transformation) :
80 rawPreBasis_(std::forward<RPB_R>(rawPreBasis)),
81 transformation_(std::forward<T_R>(transformation))
82 {}
83
86 {
87 rawPreBasis_.initializeIndices();
88 }
89
91 const GridView& gridView() const
92 {
93 return rawPreBasis_.gridView();
94 }
95
97 void update(const GridView& gv)
98 {
99 rawPreBasis_.update(gv);
100 }
101
113 {
114 return rawPreBasis_.makeNode();
115 }
116
119 {
121 }
122
124 template<class SizePrefix>
125 size_type size(const SizePrefix& prefix) const
126 {
127 return transformation_.size(prefix, rawPreBasis_);
128 }
129
132 {
133 return transformation_.containerDescriptor(rawPreBasis_);
134 }
135
138 {
139 return transformation_.dimension(rawPreBasis_);
140 }
141
144 {
145 return rawPreBasis_.maxNodeSize();
146 }
147
148 const RawPreBasis& rawPreBasis() const
149 {
150 return rawPreBasis_;
151 }
152
153 RawPreBasis& rawPreBasis()
154 {
155 return rawPreBasis_;
156 }
157
158 template<class MultiIndex>
159 void transformIndex(MultiIndex& multiIndex) const
160 {
161 transformation_.transformIndex(multiIndex, rawPreBasis_);
162 }
163
164 template<typename It>
165 It indices(const Node& node, It it) const
166 {
167 rawPreBasis().indices(node, it);
168 for(std::size_t i=0; i<node.size(); ++i)
169 {
170 transformIndex(*it);
171 ++it;
172 }
173 return it;
174 }
175
176protected:
177 RawPreBasis rawPreBasis_;
178 Transformation transformation_;
179};
180
181template<class RPB, class T>
182TransformedIndexPreBasis(RPB&&, T&&) -> TransformedIndexPreBasis<std::decay_t<RPB>, std::decay_t<T>>;
183
184
185} // end namespace Experimental
186
187
188namespace BasisFactory {
189namespace Experimental {
190
202template<class RawPreBasisFactory, class Transformation>
203auto transformIndices(
204 RawPreBasisFactory&& preBasisFactory,
205 Transformation&& transformation)
206{
207 return [
208 preBasisFactory=std::forward<RawPreBasisFactory>(preBasisFactory),
209 transformation =std::forward<Transformation>(transformation)
210 ](const auto& gridView) {
211 return Dune::Functions::Experimental::TransformedIndexPreBasis(preBasisFactory(gridView), std::move(transformation));
212 };
213}
214
215
216
235template<class IndexTransformation, class SizeImplementation, class ContainerDescriptorImplementation, std::size_t minIS, std::size_t maxIS>
237{
238public:
239
240 static constexpr std::size_t minIndexSize = minIS;
241 static constexpr std::size_t maxIndexSize = maxIS;
242
243 template<class IT_R, class SI_R, class CD_R>
244 GenericIndexingTransformation(IT_R&& indexTransformation, SI_R&& sizeImplementation, CD_R&& containerDescriptorImplementation) :
245 indexTransformation_(std::forward<IT_R>(indexTransformation)),
246 sizeImplementation_(std::forward<SI_R>(sizeImplementation)),
247 containerDescriptorImplementation_(std::forward<CD_R>(containerDescriptorImplementation))
248 {}
249
250 template<class MultiIndex, class PreBasis>
251 void transformIndex(MultiIndex& multiIndex, const PreBasis& preBasis) const
252 {
253 indexTransformation_(multiIndex, preBasis);
254 }
255
256 template<class Prefix, class PreBasis>
257 auto size(const Prefix& prefix, const PreBasis& preBasis) const
258 {
259 return sizeImplementation_(prefix, preBasis);
260 }
261
262 template<class PreBasis>
263 auto dimension(const PreBasis& preBasis) const
264 {
265 return preBasis.dimension();
266 }
267
268 template<class PreBasis>
269 auto containerDescriptor(const PreBasis& preBasis) const
270 {
271 return containerDescriptorImplementation_(preBasis);
272 }
273
274private:
275 IndexTransformation indexTransformation_;
276 SizeImplementation sizeImplementation_;
277 ContainerDescriptorImplementation containerDescriptorImplementation_;
278};
279
280
281
301template<class IndexTransformation, class SizeImplementation, class ContainerDescriptorImplementation, std::size_t minIndexSize, std::size_t maxIndexSize>
302auto indexTransformation(IndexTransformation&& indexTransformation,
303 SizeImplementation&& sizeImplementation,
304 ContainerDescriptorImplementation&& containerDescriptorImplementation,
307{
309 std::decay_t<IndexTransformation>,
310 std::decay_t<SizeImplementation>,
311 std::decay_t<ContainerDescriptorImplementation>,
312 minIndexSize, maxIndexSize>(
313 std::forward<IndexTransformation>(indexTransformation),
314 std::forward<SizeImplementation>(sizeImplementation),
315 std::forward<ContainerDescriptorImplementation>(containerDescriptorImplementation));
316}
317
319template<class IndexTransformation, class SizeImplementation,
320 std::size_t minIndexSize, std::size_t maxIndexSize>
321auto indexTransformation(IndexTransformation&& indexTrafo,
322 SizeImplementation&& sizeImpl,
325{
326 return indexTransformation(indexTrafo, sizeImpl,
327 [](auto&&) { return Dune::Functions::ContainerDescriptors::Unknown{}; },
328 minSize, maxSize);
329}
330
331} // end namespace Experimental
332} // end namespace BasisFactory
333} // end namespace Functions
334} // end namespace Dune
335
336
337#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDINDEXBASIS_HH
A generic implementation of a transformation.
Definition: transformedindexbasis.hh:237
A pre-basis transforming multi-indices.
Definition: transformedindexbasis.hh:51
void initializeIndices()
Initialize the global indices.
Definition: transformedindexbasis.hh:85
typename RawPreBasis::GridView GridView
The grid view that the FE basis is defined on.
Definition: transformedindexbasis.hh:61
typename RawPreBasis::Node Node
Template mapping root tree path to type of created tree node.
Definition: transformedindexbasis.hh:67
TransformedIndexPreBasis(RPB_R &&rawPreBasis, T_R &&transformation)
Constructor for given child pre-basis objects.
Definition: transformedindexbasis.hh:79
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: transformedindexbasis.hh:97
Node makeNode() const
Create tree node with given root tree path.
Definition: transformedindexbasis.hh:112
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: transformedindexbasis.hh:91
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: transformedindexbasis.hh:125
size_type size() const
Same as size(prefix) with empty prefix.
Definition: transformedindexbasis.hh:118
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: transformedindexbasis.hh:143
std::size_t size_type
Type used for indices and size information.
Definition: transformedindexbasis.hh:64
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: transformedindexbasis.hh:137
auto containerDescriptor() const
Return the container descriptor of the transformed pre-basis.
Definition: transformedindexbasis.hh:131
A Vector class with statically reserved memory.
Definition: reservedvector.hh:47
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:29
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
An stl-compliant random-access container which stores everything on the stack.
Fallback container descriptor if nothing else fits.
Definition: containerdescriptors.hh:46
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)