dune-functions  2.7.0
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 <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 
18 
19 
20 
21 namespace Dune {
22 namespace Functions {
23 
24 
25 
45 template<class PB>
47 {
48 public:
49 
51  using PreBasis = PB;
52 
54  using PrefixPath = TypeTree::HybridTreePath<>;
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,
80  disableCopyMove<DefaultGlobalBasis, T...> = 0,
82  DefaultGlobalBasis(T&&... 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 
127  size_type size() const
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 
156 protected:
159 };
160 
161 
162 
163 namespace BasisFactory {
164 
165 template<class GridView, class PreBasisFactory>
166 auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
167 {
168  using RawPreBasisFactory = std::decay_t<PreBasisFactory>;
169  using MultiIndex = std::conditional_t<
170  (RawPreBasisFactory::requiredMultiIndexSize == 1),
172  Dune::ReservedVector<std::size_t, RawPreBasisFactory::requiredMultiIndexSize>>;
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 
179 template<class MultiIndex, class GridView, class PreBasisFactory>
180 auto 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
191 namespace 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
Dune::Functions::DefaultGlobalBasis::MultiIndex
typename PreBasis::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultglobalbasis.hh:60
Dune::Functions::DefaultGlobalBasis::rootBasis
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:145
Dune::Functions::DefaultGlobalBasis::preBasis_
PreBasis preBasis_
Definition: defaultglobalbasis.hh:157
Dune::Functions::DefaultGlobalBasis::size
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:127
Dune::Functions::DefaultLocalView
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:24
Dune::Functions::DefaultGlobalBasis::preBasis
PreBasis & preBasis()
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:103
Dune::Functions::DefaultGlobalBasis::update
void update(const GridView &gv)
Update the stored grid view.
Definition: defaultglobalbasis.hh:114
Dune::Functions::DefaultGlobalBasis::PrefixPath
TypeTree::HybridTreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:54
Dune::Functions::FlatMultiIndex
A multi-index class with only one level.
Definition: flatmultiindex.hh:31
Dune::Functions::DefaultGlobalBasis::dimension
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:121
Dune::Functions::DefaultGlobalBasis::gridView
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:91
Dune::Functions::BasisFactory::makeBasis
auto makeBasis(const GridView &gridView, PreBasisFactory &&preBasisFactory)
Definition: defaultglobalbasis.hh:180
Dune::Functions::DefaultGlobalBasis
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
Dune::Functions::DefaultGlobalBasis::size_type
std::size_t size_type
Type used for indices and size information.
Definition: defaultglobalbasis.hh:63
Dune::Functions::DefaultGlobalBasis::localView
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:139
Dune::Functions::enableIfConstructible
typename std::enable_if< std::is_constructible< T, Args... >::value, int >::type enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:26
Dune::Functions::DefaultGlobalBasis::GridView
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: defaultglobalbasis.hh:57
Dune::Functions::DefaultGlobalBasis::SizePrefix
typename PreBasis::SizePrefix SizePrefix
Type used for prefixes handed to the size() method.
Definition: defaultglobalbasis.hh:69
Dune::Functions::DefaultGlobalBasis::size
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: defaultglobalbasis.hh:133
Dune
Definition: polynomial.hh:10
Dune::Functions::DefaultGlobalBasis::PreBasis
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:51
Dune::Functions::Concept::PreBasis
Definition: functionspacebases/concepts.hh:143
Dune::Functions::DefaultGlobalBasis::preBasis
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:97
flatmultiindex.hh
type_traits.hh
Dune::Functions::DefaultGlobalBasis::prefixPath
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:151
Dune::Functions::DefaultGlobalBasis::prefixPath_
PrefixPath prefixPath_
Definition: defaultglobalbasis.hh:158
Dune::Functions::DefaultGlobalBasis::DefaultGlobalBasis
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:82
Dune::Functions::DefaultGlobalBasis::LocalView
DefaultLocalView< DefaultGlobalBasis< PreBasis > > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: defaultglobalbasis.hh:66
defaultlocalview.hh
concepts.hh