DUNE-FUNCTIONS (unstable)

defaultglobalbasis.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_DEFAULTGLOBALBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
9
10#include <cstddef>
11#include <type_traits>
12#include <utility>
13
14#include <dune/common/reservedvector.hh>
15#include <dune/common/typeutilities.hh>
16#include <dune/common/concept.hh>
17
18#include <dune/common/typetree/treepath.hh>
19
20#include <dune/functions/common/type_traits.hh>
21#include <dune/functions/functionspacebases/defaultlocalview.hh>
22#include <dune/functions/functionspacebases/concepts.hh>
24
25
26
27namespace Dune {
28namespace Functions {
29
30
31
51template<class PB>
53{
54
55public:
56
58 using PreBasis = PB;
59
61 using PrefixPath = TypeTree::TreePath<>;
62
64 using GridView = typename PreBasis::GridView;
65
67 using size_type = std::size_t;
68
71
74
76 using SizePrefix = Dune::ReservedVector<std::size_t, PreBasis::multiIndexBufferSize>;
77
86 template<class... T,
87 disableCopyMove<DefaultGlobalBasis, T...> = 0,
90 preBasis_(std::forward<T>(t)...),
91 prefixPath_()
92 {
93 static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
94 preBasis_.initializeIndices();
95 }
96
103 template<class PreBasisFactory,
104 std::enable_if_t<Dune::IsCallable<PreBasisFactory(GridView), PreBasis>::value, int> = 0>
105 DefaultGlobalBasis(const GridView& gridView, PreBasisFactory&& factory) :
106 preBasis_(factory(gridView)),
107 prefixPath_()
108 {
109 static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
110 preBasis_.initializeIndices();
111 }
112
114 const GridView& gridView() const
115 {
116 return preBasis_.gridView();
117 }
118
120 const PreBasis& preBasis() const
121 {
122 return preBasis_;
123 }
124
127 {
128 return preBasis_;
129 }
130
137 void update(const GridView & gv)
138 {
139 preBasis_.update(gv);
140 preBasis_.initializeIndices();
141 }
142
145 {
146 return preBasis_.dimension();
147 }
148
151 {
152 return preBasis_.size();
153 }
154
156 size_type size(const SizePrefix& prefix) const
157 {
158 return preBasis_.size(prefix);
159 }
160
163 {
164 return LocalView(*this);
165 }
166
169 {
170 return *this;
171 }
172
174 const PrefixPath& prefixPath() const
175 {
176 return prefixPath_;
177 }
178
181 {
182 if constexpr (requires(PreBasis pb){ pb.containerDescriptor(); })
183 return preBasis_.containerDescriptor();
184 else
186 }
187
188protected:
189 PreBasis preBasis_;
190 PrefixPath prefixPath_;
191};
192
193
194
195template<class PreBasis>
196DefaultGlobalBasis(PreBasis&&) -> DefaultGlobalBasis<std::decay_t<PreBasis>>;
197
198template<class GridView, class PreBasisFactory>
199DefaultGlobalBasis(const GridView& gv, PreBasisFactory&& f) -> DefaultGlobalBasis<std::decay_t<decltype(f(gv))>>;
200
201
202
203namespace BasisFactory {
204
205template<class GridView, class PreBasisFactory>
206auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
207{
208 return DefaultGlobalBasis(preBasisFactory(gridView));
209}
210
211} // end namespace BasisFactory
212
213
214} // end namespace Functions
215} // end namespace Dune
216
217
218
219#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:53
Dune::ReservedVector< std::size_t, PreBasis::multiIndexBufferSize > SizePrefix
Type used for prefixes handed to the size() method.
Definition: defaultglobalbasis.hh:76
std::size_t size_type
Type used for indices and size information.
Definition: defaultglobalbasis.hh:67
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: defaultglobalbasis.hh:64
TypeTree::TreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:61
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:114
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:58
PreBasis & preBasis()
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:126
void update(const GridView &gv)
Update the stored grid view.
Definition: defaultglobalbasis.hh:137
DefaultLocalView< DefaultGlobalBasis< PreBasis > > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: defaultglobalbasis.hh:70
typename LocalView::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultglobalbasis.hh:73
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: defaultglobalbasis.hh:156
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:144
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:162
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:89
DefaultGlobalBasis(const GridView &gridView, PreBasisFactory &&factory)
Constructor from a PreBasis factory.
Definition: defaultglobalbasis.hh:105
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:150
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:120
auto containerDescriptor() const
Return the associated container descriptor.
Definition: defaultglobalbasis.hh:180
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:168
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:174
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:32
std::conditional_t<(PreBasis::minMultiIndexSize==PreBasis::maxMultiIndexSize), StaticMultiIndex< size_type, PreBasis::maxMultiIndexSize >, Dune::ReservedVector< size_type, PreBasis::multiIndexBufferSize > > MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultlocalview.hh:68
Lightweight representation of (hierarchical) size and block structure extracted from a basis to descr...
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
Fallback container descriptor if nothing else fits.
Definition: containerdescriptors.hh:52
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jan 9, 23:34, 2026)