DUNE PDELab (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
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
9
10#include <cstddef>
11#include <type_traits>
12#include <utility>
13
17
18#include <dune/functions/common/type_traits.hh>
19#include <dune/functions/functionspacebases/defaultlocalview.hh>
20#include <dune/functions/functionspacebases/concepts.hh>
21#include <dune/functions/functionspacebases/containerdescriptors.hh>
22
23
24
25namespace Dune {
26namespace Functions {
27
28
29
49template<class PB>
51{
52
53public:
54
56 using PreBasis = PB;
57
60
62 using GridView = typename PreBasis::GridView;
63
65 using size_type = std::size_t;
66
69
72
75
84 template<class... T,
88 preBasis_(std::forward<T>(t)...),
89 prefixPath_()
90 {
91 static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
92 preBasis_.initializeIndices();
93 }
94
101 template<class PreBasisFactory,
102 std::enable_if_t<Dune::IsCallable<PreBasisFactory(GridView), PreBasis>::value, int> = 0>
103 DefaultGlobalBasis(const GridView& gridView, PreBasisFactory&& factory) :
104 preBasis_(factory(gridView)),
105 prefixPath_()
106 {
107 static_assert(models<Concept::PreBasis<GridView>, PreBasis>(), "Type passed to DefaultGlobalBasis does not model the PreBasis concept.");
108 preBasis_.initializeIndices();
109 }
110
112 const GridView& gridView() const
113 {
114 return preBasis_.gridView();
115 }
116
118 const PreBasis& preBasis() const
119 {
120 return preBasis_;
121 }
122
125 {
126 return preBasis_;
127 }
128
135 void update(const GridView & gv)
136 {
137 preBasis_.update(gv);
138 preBasis_.initializeIndices();
139 }
140
143 {
144 return preBasis_.dimension();
145 }
146
149 {
150 return preBasis_.size();
151 }
152
154 size_type size(const SizePrefix& prefix) const
155 {
156 return preBasis_.size(prefix);
157 }
158
161 {
162 return LocalView(*this);
163 }
164
167 {
168 return *this;
169 }
170
172 const PrefixPath& prefixPath() const
173 {
174 return prefixPath_;
175 }
176
179 {
180 if constexpr (requires(PreBasis pb){ pb.containerDescriptor(); })
181 return preBasis_.containerDescriptor();
182 else
184 }
185
186protected:
187 PreBasis preBasis_;
188 PrefixPath prefixPath_;
189};
190
191
192
193template<class PreBasis>
194DefaultGlobalBasis(PreBasis&&) -> DefaultGlobalBasis<std::decay_t<PreBasis>>;
195
196template<class GridView, class PreBasisFactory>
197DefaultGlobalBasis(const GridView& gv, PreBasisFactory&& f) -> DefaultGlobalBasis<std::decay_t<decltype(f(gv))>>;
198
199
200
201namespace BasisFactory {
202
203template<class GridView, class PreBasisFactory>
204auto makeBasis(const GridView& gridView, PreBasisFactory&& preBasisFactory)
205{
206 return DefaultGlobalBasis(preBasisFactory(gridView));
207}
208
209} // end namespace BasisFactory
210
211
212} // end namespace Functions
213} // end namespace Dune
214
215
216
217#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:51
std::size_t size_type
Type used for indices and size information.
Definition: defaultglobalbasis.hh:65
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: defaultglobalbasis.hh:62
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: defaultglobalbasis.hh:112
PB PreBasis
Pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:56
PreBasis & preBasis()
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:124
void update(const GridView &gv)
Update the stored grid view.
Definition: defaultglobalbasis.hh:135
DefaultLocalView< DefaultGlobalBasis< PreBasis > > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition: defaultglobalbasis.hh:68
typename LocalView::MultiIndex MultiIndex
Type used for global numbering of the basis vectors.
Definition: defaultglobalbasis.hh:71
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition: defaultglobalbasis.hh:154
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: defaultglobalbasis.hh:142
LocalView localView() const
Return local view for basis.
Definition: defaultglobalbasis.hh:160
TypeTree::HybridTreePath<> PrefixPath
The empty prefix path that identifies the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:59
DefaultGlobalBasis(T &&... t)
Constructor.
Definition: defaultglobalbasis.hh:87
DefaultGlobalBasis(const GridView &gridView, PreBasisFactory &&factory)
Constructor from a PreBasis factory.
Definition: defaultglobalbasis.hh:103
size_type size() const
Return number of possible values for next position in empty multi index.
Definition: defaultglobalbasis.hh:148
const PreBasis & preBasis() const
Obtain the pre-basis providing the implementation details.
Definition: defaultglobalbasis.hh:118
auto containerDescriptor() const
Return the associated container descriptor.
Definition: defaultglobalbasis.hh:178
const DefaultGlobalBasis & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition: defaultglobalbasis.hh:166
const PrefixPath & prefixPath() const
Return empty path, because this is the root in the local ansatz tree.
Definition: defaultglobalbasis.hh:172
The restriction of a finite element basis to a single element.
Definition: defaultlocalview.hh:32
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:68
Grid view abstract base class.
Definition: gridview.hh:66
A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:81
A Vector class with statically reserved memory.
Definition: reservedvector.hh:49
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:45
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:31
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
An stl-compliant random-access container which stores everything on the stack.
Fallback container descriptor if nothing else fits.
Definition: containerdescriptors.hh:52
Check if a type is callable with ()-operator and given arguments.
Definition: typetraits.hh:162
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Oct 3, 22:29, 2025)