DUNE-FUNCTIONS (2.8)

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#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
5
6#include <cstddef>
7#include <type_traits>
8#include <utility>
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/defaultlocalview.hh>
16#include <dune/functions/functionspacebases/concepts.hh>
17#include <dune/functions/functionspacebases/flatmultiindex.hh>
18
19
20
21namespace Dune {
22namespace Functions {
23
24
25
45template<class PB>
47{
48
49 [[deprecated("Warning: Using a PreBasis that does not provide an indices(node, iterator) method but only a NodeIndexSet is deprecated!")]]
50 static auto indicesInterfaceDeprecationWarning() {}
51
52public:
53
55 using PreBasis = PB;
56
58 using PrefixPath = TypeTree::HybridTreePath<>;
59
61 using GridView = typename PreBasis::GridView;
62
64 using MultiIndex = typename PreBasis::MultiIndex;
65
67 using size_type = std::size_t;
68
71
73 using SizePrefix = typename PreBasis::SizePrefix;
74
83 template<class... T,
84 disableCopyMove<DefaultGlobalBasis, T...> = 0,
87 preBasis_(std::forward<T>(t)...),
88 prefixPath_()
89 {
90 if constexpr (not Impl::preBasisHasIndices<PreBasis>{})
91 indicesInterfaceDeprecationWarning();
92 static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
93 preBasis_.initializeIndices();
94 }
95
97 const GridView& gridView() const
98 {
99 return preBasis_.gridView();
100 }
101
103 const PreBasis& preBasis() const
104 {
105 return preBasis_;
106 }
107
110 {
111 return preBasis_;
112 }
113
120 void update(const GridView & gv)
121 {
122 preBasis_.update(gv);
123 preBasis_.initializeIndices();
124 }
125
128 {
129 return preBasis_.dimension();
130 }
131
134 {
135 return preBasis_.size();
136 }
137
139 size_type size(const SizePrefix& prefix) const
140 {
141 return preBasis_.size(prefix);
142 }
143
146 {
147 return LocalView(*this);
148 }
149
152 {
153 return *this;
154 }
155
157 const PrefixPath& prefixPath() const
158 {
159 return prefixPath_;
160 }
161
162protected:
163 PreBasis preBasis_;
164 PrefixPath prefixPath_;
165};
166
167
168
169namespace BasisFactory {
170
171template<class GridView, class PreBasisFactory>
172auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
173{
174 using RawPreBasisFactory = std::decay_t<PreBasisFactory>;
175 using MultiIndex = std::conditional_t<
176 (RawPreBasisFactory::requiredMultiIndexSize == 1),
177 FlatMultiIndex<std::size_t>,
178 Dune::ReservedVector<std::size_t, RawPreBasisFactory::requiredMultiIndexSize>>;
179 auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
180 using PreBasis = std::decay_t<decltype(preBasis)>;
181
182 return DefaultGlobalBasis<PreBasis>(std::move(preBasis));
183}
184
185template<class MultiIndex, class GridView, class PreBasisFactory>
186auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
187{
188 auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
189 using PreBasis = std::decay_t<decltype(preBasis)>;
190
191 return DefaultGlobalBasis<PreBasis>(std::move(preBasis));
192}
193
194} // end namespace BasisFactory
195
196// Backward compatibility
197namespace BasisBuilder {
198
199 using namespace BasisFactory;
200
201}
202
203
204} // end namespace Functions
205} // end namespace Dune
206
207
208
209#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:47
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:61
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:97
typename PreBasis::SizePrefix SizePrefix
Type used for prefixes handed to the size() method.
Definition: defaultglobalbasis.hh:73
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:55
PreBasis & preBasis()
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:109
void update(const GridView &gv)
Update the stored grid view.
Definition: defaultglobalbasis.hh:120
DefaultLocalView< DefaultGlobalBasis< PreBasis > > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: defaultglobalbasis.hh:70
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: defaultglobalbasis.hh:139
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:127
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:145
TypeTree::HybridTreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:58
typename PreBasis::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultglobalbasis.hh:64
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:86
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:133
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:103
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:151
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:157
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:109
typename std::enable_if< std::is_constructible< T, Args... >::value, int >::type enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:26
Definition: polynomial.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)