DUNE PDELab (2.7)

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
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{
48public:
49
51 using PreBasis = PB;
52
55
57 using GridView = typename PreBasis::GridView;
58
60 using MultiIndex = typename PreBasis::MultiIndex;
61
63 using size_type = std::size_t;
64
67
69 using SizePrefix = typename PreBasis::SizePrefix;
70
79 template<class... T,
83 preBasis_(std::forward<T>(t)...),
84 prefixPath_()
85 {
86 static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
87 preBasis_.initializeIndices();
88 }
89
91 const GridView& gridView() const
92 {
93 return preBasis_.gridView();
94 }
95
97 const PreBasis& preBasis() const
98 {
99 return preBasis_;
100 }
101
104 {
105 return preBasis_;
106 }
107
114 void update(const GridView & gv)
115 {
116 preBasis_.update(gv);
117 preBasis_.initializeIndices();
118 }
119
122 {
123 return preBasis_.dimension();
124 }
125
128 {
129 return preBasis_.size();
130 }
131
133 size_type size(const SizePrefix& prefix) const
134 {
135 return preBasis_.size(prefix);
136 }
137
140 {
141 return LocalView(*this);
142 }
143
146 {
147 return *this;
148 }
149
151 const PrefixPath& prefixPath() const
152 {
153 return prefixPath_;
154 }
155
156protected:
157 PreBasis preBasis_;
158 PrefixPath prefixPath_;
159};
160
161
162
163namespace BasisFactory {
164
165template<class GridView, class PreBasisFactory>
166auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
167{
168 using RawPreBasisFactory = std::decay_t<PreBasisFactory>;
169 using MultiIndex = std::conditional_t<
170 (RawPreBasisFactory::requiredMultiIndexSize == 1),
171 FlatMultiIndex<std::size_t>,
173 auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
174 using PreBasis = std::decay_t<decltype(preBasis)>;
175
176 return DefaultGlobalBasis<PreBasis>(std::move(preBasis));
177}
178
179template<class MultiIndex, class GridView, class PreBasisFactory>
180auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
181{
182 auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
183 using PreBasis = std::decay_t<decltype(preBasis)>;
184
185 return DefaultGlobalBasis<PreBasis>(std::move(preBasis));
186}
187
188} // end namespace BasisFactory
189
190// Backward compatibility
191namespace BasisBuilder {
192
193 using namespace BasisFactory;
194
195}
196
197
198} // end namespace Functions
199} // end namespace Dune
200
201
202
203#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:63
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: defaultglobalbasis.hh:57
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:91
typename PreBasis::SizePrefix SizePrefix
Type used for prefixes handed to the size() method.
Definition: defaultglobalbasis.hh:69
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:51
PreBasis & preBasis()
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:103
void update(const GridView &gv)
Update the stored grid view.
Definition: defaultglobalbasis.hh:114
DefaultLocalView< DefaultGlobalBasis< PreBasis > > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: defaultglobalbasis.hh:66
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: defaultglobalbasis.hh:133
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:121
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:139
TypeTree::HybridTreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:54
typename PreBasis::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultglobalbasis.hh:60
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:82
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:127
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:97
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:145
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:151
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:25
Grid view abstract base class.
Definition: gridview.hh:60
A Vector class with statically reserved memory.
Definition: reservedvector.hh:43
Infrastructure for concepts.
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition: typeutilities.hh:43
typename std::enable_if< std::is_constructible< T, Args... >::value, int >::type enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:26
Dune namespace.
Definition: alignedallocator.hh:14
STL namespace.
An stl-compliant random-access container which stores everything on the stack.
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)