dune-functions  2.6-dev
defaultglobalbasis.hh
Go to the documentation of this file.
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 <dune/common/reservedvector.hh>
7 #include <dune/common/typeutilities.hh>
8 #include <dune/common/concept.hh>
9 
14 
15 
16 
17 namespace Dune {
18 namespace Functions {
19 
20 
21 
41 template<class PB>
43 {
44 public:
45 
47  using PreBasis = PB;
48 
50  using PrefixPath = TypeTree::HybridTreePath<>;
51 
53  using GridView = typename PreBasis::GridView;
54 
56  using MultiIndex = typename PreBasis::MultiIndex;
57 
59  using size_type = std::size_t;
60 
63 
65  using NodeIndexSet = typename PreBasis::template IndexSet<PrefixPath>;
66 
68  using SizePrefix = typename PreBasis::SizePrefix;
69 
72 
73 
82  template<class... T,
83  disableCopyMove<DefaultGlobalBasis, T...> = 0,
85  DefaultGlobalBasis(T&&... t) :
86  preBasis_(std::forward<T>(t)...),
87  prefixPath_()
88  {
89  static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
90  preBasis_.initializeIndices();
91  }
92 
94  const GridView& gridView() const
95  {
96  return preBasis_.gridView();
97  }
98 
100  const PreBasis& preBasis() const
101  {
102  return preBasis_;
103  }
104 
111  void update(const GridView & gv)
112  {
113  preBasis_.update(gv);
114  preBasis_.initializeIndices();
115  }
116 
119  {
120  return preBasis_.dimension();
121  }
122 
124  size_type size() const
125  {
126  return preBasis_.size();
127  }
128 
130  size_type size(const SizePrefix& prefix) const
131  {
132  return preBasis_.size(prefix);
133  }
134 
137  {
138  return LocalView(*this);
139  }
140 
143  {
144  return LocalIndexSet(preBasis_.template indexSet<PrefixPath>());
145  }
146 
148  const DefaultGlobalBasis& rootBasis() const
149  {
150  return *this;
151  }
152 
154  const PrefixPath& prefixPath() const
155  {
156  return prefixPath_;
157  }
158 
159 protected:
160  PreBasis preBasis_;
162 };
163 
164 
165 
166 namespace BasisBuilder {
167 
168 template<class GridView, class PreBasisFactory>
169 auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
170 {
171  using MultiIndex = typename Dune::ReservedVector<std::size_t, PreBasisFactory::requiredMultiIndexSize>;
172  auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
173  using PreBasis = std::decay_t<decltype(preBasis)>;
174 
175  return DefaultGlobalBasis<PreBasis>(std::move(preBasis));
176 }
177 
178 template<class MultiIndex, class GridView, class PreBasisFactory>
179 auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
180 {
181  auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
182  using PreBasis = std::decay_t<decltype(preBasis)>;
183 
184  return DefaultGlobalBasis<PreBasis>(std::move(preBasis));
185 }
186 
187 } // end namespace BasisBuilder
188 
189 
190 
191 } // end namespace Functions
192 } // end namespace Dune
193 
194 
195 
196 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
PreBasis preBasis_
Definition: defaultglobalbasis.hh:160
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:85
typename PreBasis::SizePrefix SizePrefix
Type used for prefixes handed to the size() method.
Definition: defaultglobalbasis.hh:68
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: defaultglobalbasis.hh:53
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:154
PrefixPath prefixPath_
Definition: defaultglobalbasis.hh:161
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:42
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:136
typename PreBasis::template IndexSet< PrefixPath > NodeIndexSet
Node index set provided by PreBasis.
Definition: defaultglobalbasis.hh:65
std::size_t size_type
Type used for indices and size information.
Definition: defaultglobalbasis.hh:59
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:22
Definition: concepts.hh:153
auto makeBasis(const GridView &gridView, PreBasisFactory &&preBasisFactory)
Definition: defaultglobalbasis.hh:179
typename PreBasis::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultglobalbasis.hh:56
Definition: defaultlocalindexset.hh:17
DefaultLocalIndexSet< LocalView, NodeIndexSet > LocalIndexSet
Type of local indixes set exported by localIndexSet()
Definition: defaultglobalbasis.hh:71
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:94
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:124
Definition: polynomial.hh:7
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:118
void update(const GridView &gv)
Update the stored grid view.
Definition: defaultglobalbasis.hh:111
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:47
TypeTree::HybridTreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:50
LocalIndexSet localIndexSet() const
Return local index set for basis.
Definition: defaultglobalbasis.hh:142
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:148
STL namespace.
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: defaultglobalbasis.hh:130
DefaultLocalView< DefaultGlobalBasis< PreBasis > > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: defaultglobalbasis.hh:62
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:100
typename std::enable_if< std::is_constructible< T, Args... >::value, int >::type enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:26