3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH 4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH 6 #include <dune/common/reservedvector.hh> 7 #include <dune/common/typeutilities.hh> 9 #include <dune/typetree/powernode.hh> 10 #include <dune/typetree/utility.hh> 34 template<
class MI,
class TP,
class IMS,
class SF, std::
size_t C>
50 template<
class MI,
class IMS,
class SF, std::
size_t C>
53 static const std::size_t children = C;
55 template<
class,
class,
class,
class, std::
size_t>
90 using SizePrefix = Dune::ReservedVector<size_type, SubFactory::SizePrefix::max_size()+1>;
94 using SubMultiIndex = MI;
103 template<
class... SFArgs,
142 for (std::size_t i=0; i<children; ++i)
181 if (prefix.size() == 0)
189 typename SubFactory::SizePrefix subPrefix;
190 subPrefix.push_back(prefix[0] / children);
191 for(std::size_t i=1; i<prefix.size(); ++i)
192 subPrefix.push_back(prefix[i]);
201 if (prefix.size() == 0)
209 typename SubFactory::SizePrefix subPrefix;
210 subPrefix.push_back(prefix[0] % children);
211 for(std::size_t i=1; i<prefix.size(); ++i)
212 subPrefix.push_back(prefix[i]);
218 if (prefix.size() == 0)
220 typename SubFactory::SizePrefix subPrefix;
221 for(std::size_t i=1; i<prefix.size(); ++i)
222 subPrefix.push_back(prefix[i]);
228 if (prefix.size() == 0)
231 typename SubFactory::SizePrefix subPrefix;
232 for(std::size_t i=0; i<prefix.size()-1; ++i)
233 subPrefix.push_back(prefix[i]);
238 subPrefix.push_back(prefix.back());
265 template<
class MI,
class TP,
class IMS,
class SF, std::
size_t C>
268 static const std::size_t children = C;
288 using SubNodeIndexSet =
typename NodeFactory::SubFactory::template IndexSet<SubTreePath>;
291 nodeFactory_(&nodeFactory),
297 using namespace TypeTree::Indices;
299 subNodeIndexSet_.bind(node.child(_0));
305 subNodeIndexSet_.unbind();
310 return node_->size();
321 using namespace Dune::TypeTree::Indices;
322 size_type subTreeSize = node_->child(_0).size();
323 size_type subLocalIndex = localIndex % subTreeSize;
324 size_type component = localIndex / subTreeSize;
326 MultiIndex mi = subNodeIndexSet_.index(subLocalIndex);
327 mi[0] = mi[0]*children+component;
334 using namespace Dune::TypeTree::Indices;
335 size_type subTreeSize = node_->child(_0).size();
336 size_type subLocalIndex = localIndex % subTreeSize;
337 size_type component = localIndex / subTreeSize;
339 size_type firstLevelSize = nodeFactory_->subFactory_.size({});
341 MultiIndex mi = subNodeIndexSet_.index(subLocalIndex);
342 mi[0] += component*firstLevelSize;
349 using namespace Dune::TypeTree::Indices;
350 size_type subTreeSize = node_->child(_0).size();
351 size_type subLocalIndex = localIndex % subTreeSize;
352 size_type component = localIndex / subTreeSize;
354 auto subTreeMi = subNodeIndexSet_.index(subLocalIndex);
357 mi.push_back(component);
358 for(std::size_t i=0; i<subTreeMi.size(); ++i)
359 mi.push_back(subTreeMi[i]);
365 using namespace Dune::TypeTree::Indices;
366 size_type subTreeSize = node_->child(_0).size();
367 size_type subLocalIndex = localIndex % subTreeSize;
368 size_type component = localIndex / subTreeSize;
370 auto subTreeMi = subNodeIndexSet_.index(subLocalIndex);
373 for(std::size_t i=0; i<subTreeMi.size(); ++i)
374 mi.push_back(subTreeMi[i]);
375 mi.push_back(component);
387 namespace BasisBuilder {
391 template<std::
size_t k,
class IndexMergingStrategy,
class SubFactoryTag>
394 static const bool isBlocked = std::is_same<IndexMergingStrategy,BlockedLexicographic>::value or std::is_same<IndexMergingStrategy,LeafBlockedInterleaved>::value;
396 static const std::size_t requiredMultiIndexSize=SubFactoryTag::requiredMultiIndexSize + (std::size_t)(isBlocked);
398 template<
class MultiIndex,
class Gr
idView>
402 return {SubFactoryTag().template build<MultiIndex, GridView>(
gridView)};
422 template<std::
size_t k,
class SubFactoryTag,
class IndexMergingStrategy>
424 power(SubFactoryTag&& tag,
const IndexMergingStrategy& ims)
439 template<std::
size_t k,
class SubFactoryTag>
454 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH A factory for power bases.
Definition: powerbasis.hh:51
MultiIndex index(const size_type &localIndex) const
Definition: powerbasis.hh:313
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: powerbasis.hh:87
PowerNodeIndexSet(const NodeFactory &nodeFactory)
Definition: powerbasis.hh:290
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: powerbasis.hh:254
size_type size() const
Definition: powerbasis.hh:308
Lexicographic merging of direct children without blocking.
Definition: basistags.hh:61
MultiIndex index(const size_type &localIndex, BasisBuilder::FlatInterleaved) const
Definition: powerbasis.hh:319
SF SubFactory
Definition: powerbasis.hh:272
Imp::PowerNodeFactoryBuilder< k, LeafBlockedInterleaved, SubFactoryTag > power(SubFactoryTag &&tag)
Create a factory builder that can build a PowerNodeFactory.
Definition: powerbasis.hh:441
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: powerbasis.hh:123
Lexicographic merging of direct children with blocking (i.e. creating one block per direct child)...
Definition: basistags.hh:95
IMS IndexMergingStrategy
Strategy used to merge the global indices of the child factories.
Definition: powerbasis.hh:70
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: powerbasis.hh:248
typename SF::GridView GridView
The grid view that the FE space is defined on.
Definition: powerbasis.hh:275
Definition: powerbasis.hh:35
Definition: polynomial.hh:7
typename std::enable_if< std::is_constructible< T, Args... >::value, int >::type enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:26
MultiIndex index(const size_type &localIndex, BasisBuilder::FlatLexicographic) const
Definition: powerbasis.hh:332
PowerNodeFactory(SFArgs &&... sfArgs)
Constructor for given child factory objects.
Definition: powerbasis.hh:106
IMS IndexMergingStrategy
Definition: powerbasis.hh:277
size_type size() const
Same as size(prefix) with empty prefix.
Definition: powerbasis.hh:163
Definition: powerbasis.hh:392
void unbind()
Definition: powerbasis.hh:302
void initializeIndices()
Initialize the global indices.
Definition: powerbasis.hh:111
SF SubFactory
The child factory.
Definition: powerbasis.hh:61
IndexSet< TP > indexSet() const
Create tree node index set with given root tree path.
Definition: powerbasis.hh:157
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: powerbasis.hh:280
MultiIndex index(const size_type &localIndex, BasisBuilder::BlockedLexicographic) const
Definition: powerbasis.hh:347
MultiIndex index(const size_type &localIndex, BasisBuilder::LeafBlockedInterleaved) const
Definition: powerbasis.hh:363
typename NodeFactory::SubFactory::template IndexSet< SubTreePath > SubNodeIndexSet
Definition: powerbasis.hh:288
SubFactory subFactory_
Definition: powerbasis.hh:260
void bind(const Node &node)
Definition: powerbasis.hh:295
auto build(const GridView &gridView) -> PowerNodeFactory< MultiIndex, IndexMergingStrategy, decltype(SubFactoryTag().template build< MultiIndex, GridView >(std::declval< GridView >())), k >
Definition: powerbasis.hh:399
typename SubFactory::template IndexSet< decltype(TypeTree::push_back(TP(), 0))> SubIndexSet
Definition: powerbasis.hh:76
std::size_t size_type
Type used for indices and size information.
Definition: powerbasis.hh:67
typename NodeFactory::template Node< TP > Node
Definition: powerbasis.hh:284
typename SF::GridView GridView
The grid view that the FE basis is defined on.
Definition: powerbasis.hh:64
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: powerbasis.hh:117
Interleaved merging of direct children without blocking.
Definition: basistags.hh:78
Dune::ReservedVector< size_type, SubFactory::SizePrefix::max_size()+1 > SizePrefix
Type used for prefixes handed to the size() method.
Definition: powerbasis.hh:90
typename SubFactory::template Node< decltype(TypeTree::push_back(TP(), 0))> SubNode
Definition: powerbasis.hh:73
Node< TP > node(const TP &tp) const
Create tree node with given root tree path.
Definition: powerbasis.hh:139
typename TypeTree::Child< Node, 0 >::TreePath SubTreePath
Definition: powerbasis.hh:286
Interleaved merging of direct children with blocking (i.e. creating blocks at the leaves containing o...
Definition: basistags.hh:112
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: powerbasis.hh:169
std::size_t size_type
Definition: powerbasis.hh:276