DUNE PDELab (git)

powerbasis.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_POWERBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
5
8#include <dune/common/indices.hh>
9
10#include <dune/functions/common/utility.hh>
11#include <dune/functions/common/type_traits.hh>
12#include <dune/functions/functionspacebases/basistags.hh>
13#include <dune/functions/functionspacebases/dynamicpowerbasis.hh>
14#include <dune/functions/functionspacebases/nodes.hh>
15#include <dune/functions/functionspacebases/concepts.hh>
16#include <dune/functions/functionspacebases/containerdescriptors.hh>
17#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
18
19
20
21namespace Dune {
22namespace Functions {
23
24
25// *****************************************************************************
26// This is the reusable part of the power bases. It contains
27//
28// PowerPreBasis
29//
30// The pre-basis allows to create the others and is the owner of possible shared
31// state. These components do _not_ depend on the global basis and local view
32// and can be used without a global basis.
33// *****************************************************************************
34
45template<class IMS, class SPB, std::size_t C>
47 public DynamicPowerPreBasis<IMS,SPB>
48{
50
51public:
52
54 using SubPreBasis = SPB;
55
57 using Node = PowerBasisNode<typename SubPreBasis::Node, C>;
58
60 using size_type = typename Base::size_type;
61
64
66 inline static constexpr std::integral_constant<std::size_t,C> children = {};
67
73 template<class... SFArgs,
74 disableCopyMove<PowerPreBasis, SFArgs...> = 0,
75 enableIfConstructible<SubPreBasis, SFArgs...> = 0>
76 explicit PowerPreBasis(SFArgs&&... sfArgs) :
77 Base(std::size_t(C), std::forward<SFArgs>(sfArgs)...)
78 {}
79
83 Node makeNode() const
84 {
85 Node node{};
86 for (std::size_t i=0; i<children(); ++i)
87 node.setChild(i, Base::subPreBasis_.makeNode());
88 return node;
89 }
90
93 {
95 }
96
98 template<class SizePrefix>
99 size_type size(const SizePrefix& prefix) const
100 {
101 return Base::sizeImpl(prefix, children, IndexMergingStrategy{});
102 }
103
105 template<class NodeType, typename It,
106 std::enable_if_t<NodeType::isPower, int> = 0>
107 It indices(const NodeType& node, It it) const
108 {
109 return Base::indicesImpl(node, it, children, IndexMergingStrategy{});
110 }
111
114 {
115 return Base::containerDescriptorImpl(children);
116 }
117};
118
119
120
121namespace BasisFactory {
122
135template<std::size_t k, class ChildPreBasisFactory, class IndexMergingStrategy>
136auto power(ChildPreBasisFactory&& childPreBasisFactory, const IndexMergingStrategy&)
137{
138 return [childPreBasisFactory](const auto& gridView) {
139 auto childPreBasis = childPreBasisFactory(gridView);
141 };
142}
143
154template<std::size_t k, class ChildPreBasisFactory>
155auto power(ChildPreBasisFactory&& childPreBasisFactory)
156{
157 return [childPreBasisFactory](const auto& gridView) {
158 auto childPreBasis = childPreBasisFactory(gridView);
160 };
161}
162
163} // end namespace BasisFactory
164
165// Backward compatibility
166namespace [[deprecated("Will be removed after Dune 2.10")]] BasisBuilder {
167
168 using namespace BasisFactory;
169
170}
171
172
173} // end namespace Functions
174} // end namespace Dune
175
176
177#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
A pre-basis for dynamic power bases.
Definition: dynamicpowerbasis.hh:44
std::size_t size_type
Type used for indices and size information.
Definition: dynamicpowerbasis.hh:56
IMS IndexMergingStrategy
Strategy used to merge the global indices of the child factories.
Definition: dynamicpowerbasis.hh:59
SPB SubPreBasis
The child pre-basis.
Definition: dynamicpowerbasis.hh:50
DynamicPowerBasisNode< typename SubPreBasis::Node > Node
Template mapping root tree path to type of created tree node.
Definition: dynamicpowerbasis.hh:62
A pre-basis for power bases.
Definition: powerbasis.hh:48
SPB SubPreBasis
The child pre-basis.
Definition: powerbasis.hh:54
auto containerDescriptor() const
Return the associated container descriptor.
Definition: powerbasis.hh:113
It indices(const NodeType &node, It it) const
Maps from subtree index set [0..size-1] to a globally unique multi index in global basis.
Definition: powerbasis.hh:107
PowerPreBasis(SFArgs &&... sfArgs)
Constructor for given child pre-basis objects for static size of the power-basis.
Definition: powerbasis.hh:76
size_type size() const
Same as size(prefix) with empty prefix.
Definition: powerbasis.hh:92
Node makeNode() const
Create tree node.
Definition: powerbasis.hh:83
static constexpr std::integral_constant< std::size_t, C > children
Number of children provided as an integral constant.
Definition: powerbasis.hh:66
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: powerbasis.hh:99
A Vector class with statically reserved memory.
Definition: reservedvector.hh:47
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition: typeutilities.hh:45
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:27
Dune namespace.
Definition: alignedallocator.hh:13
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition: math.hh:75
STL namespace.
An stl-compliant random-access container which stores everything on the stack.
Base class for index merging strategies to simplify detection.
Definition: basistags.hh:44
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)