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
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_POWERBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
9
12#include <dune/common/indices.hh>
13
14#include <dune/functions/common/utility.hh>
15#include <dune/functions/common/type_traits.hh>
16#include <dune/functions/functionspacebases/basistags.hh>
17#include <dune/functions/functionspacebases/dynamicpowerbasis.hh>
18#include <dune/functions/functionspacebases/nodes.hh>
19#include <dune/functions/functionspacebases/concepts.hh>
20#include <dune/functions/functionspacebases/containerdescriptors.hh>
21#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
22
23
24
25namespace Dune {
26namespace Functions {
27
28
29// *****************************************************************************
30// This is the reusable part of the power bases. It contains
31//
32// PowerPreBasis
33//
34// The pre-basis allows to create the others and is the owner of possible shared
35// state. These components do _not_ depend on the global basis and local view
36// and can be used without a global basis.
37// *****************************************************************************
38
49template<class IMS, class SPB, std::size_t C>
51 public DynamicPowerPreBasis<IMS,SPB>
52{
54
55public:
56
58 using SubPreBasis = SPB;
59
61 using Node = PowerBasisNode<typename SubPreBasis::Node, C>;
62
64 using size_type = typename Base::size_type;
65
68
70 inline static constexpr std::integral_constant<std::size_t,C> children = {};
71
77 template<class... SFArgs,
78 disableCopyMove<PowerPreBasis, SFArgs...> = 0,
79 enableIfConstructible<SubPreBasis, SFArgs...> = 0>
80 explicit PowerPreBasis(SFArgs&&... sfArgs) :
81 Base(std::size_t(C), std::forward<SFArgs>(sfArgs)...)
82 {}
83
87 Node makeNode() const
88 {
89 Node node{};
90 for (std::size_t i=0; i<children(); ++i)
91 node.setChild(i, Base::subPreBasis_.makeNode());
92 return node;
93 }
94
97 {
99 }
100
102 template<class SizePrefix>
103 size_type size(const SizePrefix& prefix) const
104 {
105 return Base::sizeImpl(prefix, children, IndexMergingStrategy{});
106 }
107
109 template<class NodeType, typename It,
110 std::enable_if_t<NodeType::isPower, int> = 0>
111 It indices(const NodeType& node, It it) const
112 {
113 return Base::indicesImpl(node, it, children, IndexMergingStrategy{});
114 }
115
118 {
119 return Base::containerDescriptorImpl(children);
120 }
121};
122
123
124
125namespace BasisFactory {
126
139template<std::size_t k, class ChildPreBasisFactory, class IndexMergingStrategy>
140auto power(ChildPreBasisFactory&& childPreBasisFactory, const IndexMergingStrategy&)
141{
142 return [childPreBasisFactory](const auto& gridView) {
143 auto childPreBasis = childPreBasisFactory(gridView);
145 };
146}
147
158template<std::size_t k, class ChildPreBasisFactory>
159auto power(ChildPreBasisFactory&& childPreBasisFactory)
160{
161 return [childPreBasisFactory](const auto& gridView) {
162 auto childPreBasis = childPreBasisFactory(gridView);
164 };
165}
166
167} // end namespace BasisFactory
168
169// Backward compatibility
170namespace [[deprecated("Will be removed after Dune 2.10")]] BasisBuilder {
171
172 using namespace BasisFactory;
173
174}
175
176
177} // end namespace Functions
178} // end namespace Dune
179
180
181#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
A pre-basis for dynamic power bases.
Definition: dynamicpowerbasis.hh:48
std::size_t size_type
Type used for indices and size information.
Definition: dynamicpowerbasis.hh:60
IMS IndexMergingStrategy
Strategy used to merge the global indices of the child factories.
Definition: dynamicpowerbasis.hh:63
SPB SubPreBasis
The child pre-basis.
Definition: dynamicpowerbasis.hh:54
DynamicPowerBasisNode< typename SubPreBasis::Node > Node
Template mapping root tree path to type of created tree node.
Definition: dynamicpowerbasis.hh:66
A pre-basis for power bases.
Definition: powerbasis.hh:52
SPB SubPreBasis
The child pre-basis.
Definition: powerbasis.hh:58
auto containerDescriptor() const
Return the associated container descriptor.
Definition: powerbasis.hh:117
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:111
PowerPreBasis(SFArgs &&... sfArgs)
Constructor for given child pre-basis objects for static size of the power-basis.
Definition: powerbasis.hh:80
size_type size() const
Same as size(prefix) with empty prefix.
Definition: powerbasis.hh:96
Node makeNode() const
Create tree node.
Definition: powerbasis.hh:87
static constexpr std::integral_constant< std::size_t, C > children
Number of children provided as an integral constant.
Definition: powerbasis.hh:70
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: powerbasis.hh:103
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:31
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:48
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)