DUNE-FUNCTIONS (unstable)

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
10#include <dune/common/reservedvector.hh>
11#include <dune/common/typeutilities.hh>
12#include <dune/common/indices.hh>
13
14#include <dune/common/typetree/nodeconcepts.hh>
15
16#include <dune/functions/common/utility.hh>
17#include <dune/functions/common/type_traits.hh>
18#include <dune/functions/functionspacebases/basistags.hh>
19#include <dune/functions/functionspacebases/dynamicpowerbasis.hh>
20#include <dune/functions/functionspacebases/nodes.hh>
21#include <dune/functions/functionspacebases/concepts.hh>
23#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
24
25
26
27namespace Dune {
28namespace Functions {
29
30
31// *****************************************************************************
32// This is the reusable part of the power bases. It contains
33//
34// PowerPreBasis
35//
36// The pre-basis allows to create the others and is the owner of possible shared
37// state. These components do _not_ depend on the global basis and local view
38// and can be used without a global basis.
39// *****************************************************************************
40
51template<class IMS, class SPB, std::size_t C>
53 public DynamicPowerPreBasis<IMS,SPB>
54{
56
57public:
58
60 using SubPreBasis = SPB;
61
63 using Node = PowerBasisNode<typename SubPreBasis::Node, C>;
64
66 using size_type = typename Base::size_type;
67
70
72 inline static constexpr std::integral_constant<std::size_t,C> children = {};
73
79 template<class... SFArgs,
80 disableCopyMove<PowerPreBasis, SFArgs...> = 0,
81 enableIfConstructible<SubPreBasis, SFArgs...> = 0>
82 explicit PowerPreBasis(SFArgs&&... sfArgs) :
83 Base(std::size_t(C), std::forward<SFArgs>(sfArgs)...)
84 {}
85
89 Node makeNode() const
90 {
91 Node node{};
92 for (std::size_t i=0; i<children(); ++i)
93 node.setChild(i, Base::subPreBasis_.makeNode());
94 return node;
95 }
96
99 {
100 return size(Dune::ReservedVector<size_type, Base::multiIndexBufferSize>{});
101 }
102
104 template<class SizePrefix>
105 size_type size(const SizePrefix& prefix) const
106 {
107 return Base::sizeImpl(prefix, children, IndexMergingStrategy{});
108 }
109
111 template<class NodeType, typename It>
112 requires Dune::TypeTree::Concept::UniformInnerTreeNode<NodeType>
113 It indices(const NodeType& node, It it) const
114 {
115 return Base::indicesImpl(node, it, children, IndexMergingStrategy{});
116 }
117
120 {
121 return Base::containerDescriptorImpl(children);
122 }
123};
124
125
126
127namespace BasisFactory {
128
140template<std::size_t k, class ChildPreBasisFactory, class IndexMergingStrategy>
141auto power(ChildPreBasisFactory&& childPreBasisFactory, const IndexMergingStrategy&)
142{
143 return [childPreBasisFactory](const auto& gridView) {
144 auto childPreBasis = childPreBasisFactory(gridView);
146 };
147}
148
159template<std::size_t k, class ChildPreBasisFactory>
160[[deprecated("Using the method `power` without an explicit index merging strategy"
161 " will change its meaning after the release of dune-functions 2.11."
162 " Previously, the default merging strategy was `BlockedInterleaved`,"
163 " but this will change to `FlatInterleaved`."
164 " Change the call to `power(..., blockedInterleaved())` to retain the old behavior.")]]
165auto power(ChildPreBasisFactory&& childPreBasisFactory)
166{
167 return [childPreBasisFactory](const auto& gridView) {
168 auto childPreBasis = childPreBasisFactory(gridView);
170 };
171}
172
173} // end namespace BasisFactory
174
175
176} // end namespace Functions
177} // end namespace Dune
178
179
180#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
A pre-basis for dynamic power bases.
Definition: dynamicpowerbasis.hh:50
std::size_t size_type
Type used for indices and size information.
Definition: dynamicpowerbasis.hh:62
IMS IndexMergingStrategy
Strategy used to merge the global indices of the child factories.
Definition: dynamicpowerbasis.hh:65
SPB SubPreBasis
The child pre-basis.
Definition: dynamicpowerbasis.hh:56
DynamicPowerBasisNode< typename SubPreBasis::Node > Node
Template mapping root tree path to type of created tree node.
Definition: dynamicpowerbasis.hh:68
A pre-basis for power bases.
Definition: powerbasis.hh:54
SPB SubPreBasis
The child pre-basis.
Definition: powerbasis.hh:60
auto containerDescriptor() const
Return the associated container descriptor.
Definition: powerbasis.hh:119
PowerPreBasis(SFArgs &&... sfArgs)
Constructor for given child pre-basis objects for static size of the power-basis.
Definition: powerbasis.hh:82
size_type size() const
Same as size(prefix) with empty prefix.
Definition: powerbasis.hh:98
Node makeNode() const
Create tree node.
Definition: powerbasis.hh:89
static constexpr std::integral_constant< std::size_t, C > children
Number of children provided as an integral constant.
Definition: powerbasis.hh:72
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:113
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: powerbasis.hh:105
Lightweight representation of (hierarchical) size and block structure extracted from a basis to descr...
auto power(ChildPreBasisFactory &&childPreBasisFactory)
Create a factory builder that can build a PowerPreBasis.
Definition: powerbasis.hh:165
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:31
Definition: monomialset.hh:19
Base class for index merging strategies to simplify detection.
Definition: basistags.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jan 9, 23:34, 2026)