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 #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 
18 
19 
20 namespace Dune {
21 namespace Functions {
22 
23 
24 
44 template<class PB>
46 {
47 
48 public:
49 
51  using PreBasis = PB;
52 
54  using PrefixPath = TypeTree::HybridTreePath<>;
55 
57  using GridView = typename PreBasis::GridView;
58 
60  using size_type = std::size_t;
61 
64 
67 
69  using SizePrefix = Dune::ReservedVector<std::size_t, PreBasis::multiIndexBufferSize>;
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 
96  template<class PreBasisFactory,
97  std::enable_if_t<Dune::IsCallable<PreBasisFactory(GridView), PreBasis>::value, int> = 0>
98  DefaultGlobalBasis(const GridView& gridView, PreBasisFactory&& factory) :
99  preBasis_(factory(gridView)),
100  prefixPath_()
101  {
102  static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
103  preBasis_.initializeIndices();
104  }
105 
107  const GridView& gridView() const
108  {
109  return preBasis_.gridView();
110  }
111 
113  const PreBasis& preBasis() const
114  {
115  return preBasis_;
116  }
117 
120  {
121  return preBasis_;
122  }
123 
130  void update(const GridView & gv)
131  {
132  preBasis_.update(gv);
133  preBasis_.initializeIndices();
134  }
135 
138  {
139  return preBasis_.dimension();
140  }
141 
143  size_type size() const
144  {
145  return preBasis_.size();
146  }
147 
149  size_type size(const SizePrefix& prefix) const
150  {
151  return preBasis_.size(prefix);
152  }
153 
156  {
157  return LocalView(*this);
158  }
159 
162  {
163  return *this;
164  }
165 
167  const PrefixPath& prefixPath() const
168  {
169  return prefixPath_;
170  }
171 
172 protected:
173  PreBasis preBasis_;
174  PrefixPath prefixPath_;
175 };
176 
177 
178 
179 template<class PreBasis>
180 DefaultGlobalBasis(PreBasis&&) -> DefaultGlobalBasis<std::decay_t<PreBasis>>;
181 
182 template<class GridView, class PreBasisFactory>
183 DefaultGlobalBasis(const GridView& gv, PreBasisFactory&& f) -> DefaultGlobalBasis<std::decay_t<decltype(f(gv))>>;
184 
185 
186 
187 namespace BasisFactory {
188 
189 template<class GridView, class PreBasisFactory>
190 auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
191 {
192  return DefaultGlobalBasis(preBasisFactory(gridView));
193 }
194 
195 } // end namespace BasisFactory
196 
197 // Backward compatibility
198 namespace [[deprecated("Will be removed after Dune 2.10")]] BasisBuilder {
199 
200  using namespace BasisFactory;
201 
202 }
203 
204 
205 } // end namespace Functions
206 } // end namespace Dune
207 
208 
209 
210 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
Dune::ReservedVector< std::size_t, PreBasis::multiIndexBufferSize > SizePrefix
Type used for prefixes handed to the size() method.
Definition: defaultglobalbasis.hh:69
std::size_t size_type
Type used for indices and size information.
Definition: defaultglobalbasis.hh:60
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:167
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: defaultglobalbasis.hh:57
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:161
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:51
void update(const GridView &gv)
Update the stored grid view.
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:63
typename LocalView::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
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:149
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:137
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:155
TypeTree::HybridTreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:54
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:113
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:82
DefaultGlobalBasis(const GridView &gridView, PreBasisFactory &&factory)
Constructor from a PreBasis factory.
Definition: defaultglobalbasis.hh:98
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:107
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:143
PreBasis & preBasis()
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:119
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:28
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:64
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:27
Definition: polynomial.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)