Go to the documentation of this file.
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>
35 template<
class MI,
class TP,
class IMS,
class SPB, std::
size_t C>
51 template<
class MI,
class IMS,
class SPB, std::
size_t C>
54 static const std::size_t children = C;
56 template<
class,
class,
class,
class, std::
size_t>
74 using SubNode =
typename SubPreBasis::template
Node<decltype(TypeTree::push_back(TP(), 0))>;
95 using SubMultiIndex = MI;
104 template<
class... SFArgs,
145 for (std::size_t i=0; i<children; ++i)
184 if (prefix.size() == 0)
192 typename SubPreBasis::SizePrefix subPrefix;
193 subPrefix.push_back(prefix[0] / children);
194 for(std::size_t i=1; i<prefix.size(); ++i)
195 subPrefix.push_back(prefix[i]);
204 if (prefix.size() == 0)
212 typename SubPreBasis::SizePrefix subPrefix;
213 subPrefix.push_back(prefix[0] % children);
214 for(std::size_t i=1; i<prefix.size(); ++i)
215 subPrefix.push_back(prefix[i]);
221 if (prefix.size() == 0)
223 typename SubPreBasis::SizePrefix subPrefix;
224 for(std::size_t i=1; i<prefix.size(); ++i)
225 subPrefix.push_back(prefix[i]);
231 if (prefix.size() == 0)
234 typename SubPreBasis::SizePrefix subPrefix;
235 for(std::size_t i=0; i<prefix.size()-1; ++i)
236 subPrefix.push_back(prefix[i]);
241 subPrefix.push_back(prefix.back());
268 template<
class MI,
class TP,
class IMS,
class SPB, std::
size_t C>
271 static const std::size_t children = C;
291 using SubNodeIndexSet =
typename PreBasis::SubPreBasis::template IndexSet<SubTreePath>;
294 preBasis_(&preBasis),
295 subNodeIndexSet_(preBasis_->subPreBasis_.template indexSet<
SubTreePath>())
300 using namespace TypeTree::Indices;
302 subNodeIndexSet_.bind(node.child(_0));
308 subNodeIndexSet_.unbind();
313 return node_->size();
317 template<
typename It>
323 template<
typename It>
326 using namespace Dune::TypeTree::Indices;
327 size_type subTreeSize = node_->child(_0).size();
329 auto next = subNodeIndexSet_.indices(multiIndices);
332 for (std::size_t i = 0; i<subTreeSize; ++i)
333 multiIndices[i][0] *= children;
334 for (std::size_t child = 1; child<children; ++child)
336 for (std::size_t i = 0; i<subTreeSize; ++i)
342 (*next) = multiIndices[i];
343 (*next)[0] = multiIndices[i][0]+child;
350 template<
typename It>
353 using namespace Dune::TypeTree::Indices;
354 size_type subTreeSize = node_->child(_0).size();
355 size_type firstIndexEntrySize = preBasis_->subPreBasis_.size({});
357 auto next = subNodeIndexSet_.indices(multiIndices);
358 for (std::size_t child = 1; child<children; ++child)
360 for (std::size_t i = 0; i<subTreeSize; ++i)
366 (*next) = multiIndices[i];
367 (*next)[0] += child*firstIndexEntrySize;
376 M.resize(M.size()+1);
377 for(std::size_t i=M.size()-1; i>0; --i)
382 template<
typename It>
385 using namespace Dune::TypeTree::Indices;
386 size_type subTreeSize = node_->child(_0).size();
388 auto next = subNodeIndexSet_.indices(multiIndices);
390 for (std::size_t i = 0; i<subTreeSize; ++i)
391 multiIndexPushFront(multiIndices[i], 0);
392 for (std::size_t child = 1; child<children; ++child)
394 for (std::size_t i = 0; i<subTreeSize; ++i)
400 (*next) = multiIndices[i];
408 template<
typename It>
411 using namespace Dune::TypeTree::Indices;
412 size_type subTreeSize = node_->child(_0).size();
414 auto next = subNodeIndexSet_.indices(multiIndices);
416 for (std::size_t i = 0; i<subTreeSize; ++i)
417 multiIndices[i].push_back(0);
418 for (std::size_t child = 1; child<children; ++child)
420 for (std::size_t i = 0; i<subTreeSize; ++i)
424 (*next) = multiIndices[i];
425 (*next).back() = child;
433 const PreBasis* preBasis_;
434 SubNodeIndexSet subNodeIndexSet_;
440 namespace BasisBuilder {
444 template<std::
size_t k,
class IndexMergingStrategy,
class ChildPreBasisFactory>
445 class PowerPreBasisFactory
447 static const bool isBlocked = std::is_same<IndexMergingStrategy,BlockedLexicographic>::value or std::is_same<IndexMergingStrategy,LeafBlockedInterleaved>::value;
449 static const std::size_t maxChildIndexSize = ChildPreBasisFactory::requiredMultiIndexSize;
453 static const std::size_t requiredMultiIndexSize = isBlocked ? (maxChildIndexSize+1) : maxChildIndexSize;
455 PowerPreBasisFactory(
const ChildPreBasisFactory& childPreBasisFactory) :
456 childPreBasisFactory_(childPreBasisFactory)
459 PowerPreBasisFactory(ChildPreBasisFactory&& childPreBasisFactory) :
460 childPreBasisFactory_(std::move(childPreBasisFactory))
463 template<
class MultiIndex,
class Gr
idView>
464 auto makePreBasis(
const GridView& gridView)
const
466 auto childPreBasis = childPreBasisFactory_.template makePreBasis<MultiIndex>(gridView);
467 using ChildPreBasis = decltype(childPreBasis);
469 return PowerPreBasis<MultiIndex, IndexMergingStrategy, ChildPreBasis, k>(std::move(childPreBasis));
473 ChildPreBasisFactory childPreBasisFactory_;
492 template<std::
size_t k,
class ChildPreBasisFactory,
class IndexMergingStrategy>
495 return Imp::PowerPreBasisFactory<k, IndexMergingStrategy, ChildPreBasisFactory>(std::forward<ChildPreBasisFactory>(childPreBasisFactory));
508 template<std::
size_t k,
class ChildPreBasisFactory>
509 auto power(ChildPreBasisFactory&& childPreBasisFactory)
511 return Imp::PowerPreBasisFactory<k, LeafBlockedInterleaved, ChildPreBasisFactory>(std::forward<ChildPreBasisFactory>(childPreBasisFactory));
522 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
typename SubPreBasis::template Node< decltype(TypeTree::push_back(TP(), 0))> SubNode
Definition: powerbasis.hh:74
Base class for index merging strategies to simplify detection.
Definition: basistags.hh:44
void bind(const Node &node)
Definition: powerbasis.hh:298
Interleaved merging of direct children with blocking (i.e. creating blocks at the leaves containing o...
Definition: basistags.hh:180
Definition: polynomial.hh:7
It indices(It multiIndices, BasisBuilder::FlatInterleaved) const
Definition: powerbasis.hh:324
Node< TP > node(const TP &tp) const
Create tree node with given root tree path.
Definition: powerbasis.hh:142
static const void multiIndexPushFront(MultiIndex &M, size_type M0)
Definition: powerbasis.hh:374
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: powerbasis.hh:126
void unbind()
Definition: powerbasis.hh:305
typename PreBasis::SubPreBasis::template IndexSet< SubTreePath > SubNodeIndexSet
Definition: powerbasis.hh:291
IMS IndexMergingStrategy
Definition: powerbasis.hh:280
It indices(It multiIndices, BasisBuilder::BlockedLexicographic) const
Definition: powerbasis.hh:383
typename SPB::GridView GridView
The grid view that the FE basis is defined on.
Definition: powerbasis.hh:65
std::size_t size_type
Type used for indices and size information.
Definition: powerbasis.hh:68
SubPreBasis subPreBasis_
Definition: powerbasis.hh:263
auto power(ChildPreBasisFactory &&childPreBasisFactory)
Create a factory builder that can build a PowerPreBasis.
Definition: powerbasis.hh:509
SPB SubPreBasis
Definition: powerbasis.hh:275
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: powerbasis.hh:120
typename TypeTree::Child< Node, 0 >::TreePath SubTreePath
Definition: powerbasis.hh:289
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: powerbasis.hh:283
Dune::ReservedVector< size_type, SubPreBasis::SizePrefix::max_size()+1 > SizePrefix
Type used for prefixes handed to the size() method.
Definition: powerbasis.hh:91
IndexSet< TP > indexSet() const
Create tree node index set with given root tree path.
Definition: powerbasis.hh:160
PowerNodeIndexSet(const PreBasis &preBasis)
Definition: powerbasis.hh:293
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: powerbasis.hh:88
It indices(It multiIndices, BasisBuilder::LeafBlockedInterleaved) const
Definition: powerbasis.hh:409
std::size_t size_type
Definition: powerbasis.hh:279
void initializeIndices()
Initialize the global indices.
Definition: powerbasis.hh:114
typename PreBasis::template Node< TP > Node
Definition: powerbasis.hh:287
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: powerbasis.hh:251
Lexicographic merging of direct children without blocking.
Definition: basistags.hh:78
It indices(It it) const
Maps from subtree index set [0..size-1] to a globally unique multi index in global basis.
Definition: powerbasis.hh:318
It indices(It multiIndices, BasisBuilder::FlatLexicographic) const
Definition: powerbasis.hh:351
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: powerbasis.hh:257
PowerPreBasis(SFArgs &&... sfArgs)
Constructor for given child pre-basis objects.
Definition: powerbasis.hh:107
Lexicographic merging of direct children with blocking (i.e. creating one block per direct child).
Definition: basistags.hh:146
A pre-basis for power bases.
Definition: powerbasis.hh:52
typename SPB::GridView GridView
The grid view that the FE space is defined on.
Definition: powerbasis.hh:278
SPB SubPreBasis
The child pre-basis.
Definition: powerbasis.hh:62
IMS IndexMergingStrategy
Strategy used to merge the global indices of the child factories.
Definition: powerbasis.hh:71
size_type size() const
Same as size(prefix) with empty prefix.
Definition: powerbasis.hh:166
Definition: concepts.hh:153
typename std::enable_if< std::is_constructible< T, Args... >::value, int >::type enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:26
Interleaved merging of direct children without blocking.
Definition: basistags.hh:112
typename SubPreBasis::template IndexSet< decltype(TypeTree::push_back(TP(), 0))> SubIndexSet
Definition: powerbasis.hh:77
Definition: powerbasis.hh:36
size_type size() const
Definition: powerbasis.hh:311
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: powerbasis.hh:172