DUNE-FUNCTIONS (unstable)

subspacebasis.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_SUBSPACEBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBSPACEBASIS_HH
9
10#include <dune/common/reservedvector.hh>
11#include <dune/common/typeutilities.hh>
12#include <dune/common/concept.hh>
13
14#include <dune/functions/common/type_traits.hh>
15#include <dune/functions/functionspacebases/subspacelocalview.hh>
16#include <dune/functions/functionspacebases/concepts.hh>
17
18
19
20namespace Dune {
21namespace Functions {
22
23
24
25namespace Impl {
26
27 template<class... Inner, class... Outer>
28 auto joinTreePaths(const TypeTree::HybridTreePath<Inner...>& inner, const TypeTree::HybridTreePath<Outer...> outer)
29 {
30 return TypeTree::HybridTreePath<Inner..., Outer...>(std::tuple_cat(inner._data, outer._data));
31 }
32
33 template<class InnerTP, class OuterTP>
34 using JoinTreePath_t = std::decay_t<decltype(joinTreePaths(std::declval<InnerTP>(), std::declval<OuterTP>()))>;
35
36}
37
38
39
40template<class RB, class TP>
41class SubspaceBasis
42{
43public:
44
45 using RootBasis = RB;
46
47 using RootLocalView = typename RootBasis::LocalView;
48
49 using PrefixPath = TP;
50
52 using GridView = typename RootBasis::GridView;
53
55 using MultiIndex = typename RootBasis::MultiIndex;
56
57 using size_type = std::size_t;
58
60 using LocalView = SubspaceLocalView<RootLocalView, PrefixPath>;
61
62 using SizePrefix = typename RootBasis::SizePrefix;
63
64
66 SubspaceBasis(const RootBasis& rootBasis, const PrefixPath& prefixPath) :
67 rootBasis_(&rootBasis),
68 prefixPath_(prefixPath)
69 {}
70
76 template<class RootRootBasis, class InnerTP, class OuterTP>
77 SubspaceBasis(const SubspaceBasis<RootRootBasis, InnerTP>& rootBasis, const OuterTP& prefixPath) :
78 SubspaceBasis(rootBasis.rootBasis(), Impl::joinTreePaths(rootBasis.prefixPath(), prefixPath))
79 {}
80
81
84 const GridView& gridView() const
85 {
86 return rootBasis_->gridView();
87 }
88
92 size_type dimension() const
93 {
94 return rootBasis_->dimension();
95 }
96
98 size_type size() const
99 {
100 return rootBasis_->size();
101 }
102
104 size_type size(const SizePrefix& prefix) const
105 {
106 return rootBasis_->size(prefix);
107 }
108
112 LocalView localView() const
113 {
114 return LocalView(*this, prefixPath_);
115 }
116
117 const RootBasis& rootBasis() const
118 {
119 return *rootBasis_;
120 }
121
122 const PrefixPath& prefixPath() const
123 {
124 return prefixPath_;
125 }
126
127protected:
128 const RootBasis* rootBasis_;
129 PrefixPath prefixPath_;
130};
131
132
133// CTAD guide for a non-SubspaceBasis root basis
134template<class RB, class TP>
135SubspaceBasis(const RB&, const TP) -> SubspaceBasis<RB, TP>;
136
137// CTAD guide for a SubspaceBasis root basis
138template<class RootRootBasis, class InnerTP, class OuterTP>
139SubspaceBasis(const SubspaceBasis<RootRootBasis, InnerTP>& rootBasis, const OuterTP& prefixPath)
140 -> SubspaceBasis<std::decay_t<decltype(rootBasis.rootBasis())>, Impl::JoinTreePath_t<InnerTP, OuterTP>>;
141
142
143
154template<class RootBasis, class... PrefixTreeIndices>
155auto subspaceBasis(const RootBasis& rootBasis, const TypeTree::HybridTreePath<PrefixTreeIndices...>& prefixPath)
156{
157 return SubspaceBasis(rootBasis, prefixPath);
158}
159
160template<class RootBasis, class... PrefixTreeIndices>
161auto subspaceBasis(const RootBasis& rootBasis, const PrefixTreeIndices&... prefixTreeIndices)
162{
163 return subspaceBasis(rootBasis, TypeTree::hybridTreePath(prefixTreeIndices...));
164}
165
166
167
168} // end namespace Functions
169} // end namespace Dune
170
171
172
173#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
Definition: polynomial.hh:17
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 14, 22:29, 2024)