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_SUBSPACEBASIS_HH
4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBSPACEBASIS_HH
5
6 #include <dune/common/reservedvector.hh>
7 #include <dune/common/typeutilities.hh>
8 #include <dune/common/concept.hh>
9
10 #include <dune/functions/common/type_traits.hh>
11 #include <dune/functions/functionspacebases/subspacelocalview.hh>
12 #include <dune/functions/functionspacebases/concepts.hh>
13
14
15
16 namespace Dune {
17 namespace Functions {
18
19
20
21 template<class RB, class TP>
22 class SubspaceBasis
23 {
24 public:
25
26 using RootBasis = RB;
27
28 using RootLocalView = typename RootBasis::LocalView;
29
30 using PrefixPath = TP;
31
32 //! The grid view that the FE space is defined on
33 using GridView = typename RootBasis::GridView;
34
35 //! Type used for global numbering of the basis vectors
36 using MultiIndex = typename RootBasis::MultiIndex;
37
38 using size_type = std::size_t;
39
40 //! Type of the local view on the restriction of the basis to a single element
41 using LocalView = SubspaceLocalView<RootLocalView, PrefixPath>;
42
43 using SizePrefix = typename RootBasis::SizePrefix;
44
45
46 /** \brief Constructor for a given grid view object */
SubspaceBasis(const RootBasis & rootBasis,const PrefixPath & prefixPath)47 SubspaceBasis(const RootBasis& rootBasis, const PrefixPath& prefixPath) :
48 rootBasis_(&rootBasis),
49 prefixPath_(prefixPath)
50 {
51 // static_assert(models<Concept::NodeFactory<GridView>, NodeFactory>(), "Type passed to DefaultGlobalBasis does not model the NodeFactory concept.");
52 }
53
54 /** \brief Obtain the grid view that the basis is defined on
55 */
gridView() const56 const GridView& gridView() const
57 {
58 return rootBasis_->gridView();
59 }
60
61 /**
62 * \todo This method has been added to the interface without prior discussion.
63 */
dimension() const64 size_type dimension() const
65 {
66 return rootBasis_->dimension();
67 }
68
69 //! Return number of possible values for next position in empty multi index
size() const70 size_type size() const
71 {
72 return rootBasis_->size();
73 }
74
75 //! Return number possible values for next position in multi index
size(const SizePrefix & prefix) const76 size_type size(const SizePrefix& prefix) const
77 {
78 return rootBasis_->size(prefix);
79 }
80
81 /** \brief Return local view for basis
82 *
83 */
localView() const84 LocalView localView() const
85 {
86 return LocalView(*this, prefixPath_);
87 }
88
rootBasis() const89 const RootBasis& rootBasis() const
90 {
91 return *rootBasis_;
92 }
93
prefixPath() const94 const PrefixPath& prefixPath() const
95 {
96 return prefixPath_;
97 }
98
99 protected:
100 const RootBasis* rootBasis_;
101 PrefixPath prefixPath_;
102 };
103
104
105 template<class RootBasis, class... PrefixTreeIndices>
subspaceBasis(const RootBasis & rootBasis,const TypeTree::HybridTreePath<PrefixTreeIndices...> & prefixPath)106 auto subspaceBasis(const RootBasis& rootBasis, const TypeTree::HybridTreePath<PrefixTreeIndices...>& prefixPath)
107 {
108 using PrefixPath = TypeTree::HybridTreePath<PrefixTreeIndices...>;
109 return SubspaceBasis<RootBasis, PrefixPath>{rootBasis, prefixPath};
110 }
111
112 template<class RootBasis, class... PrefixTreeIndices>
subspaceBasis(const RootBasis & rootBasis,const PrefixTreeIndices &...prefixTreeIndices)113 auto subspaceBasis(const RootBasis& rootBasis, const PrefixTreeIndices&... prefixTreeIndices)
114 {
115 return subspaceBasis(rootBasis, TypeTree::hybridTreePath(prefixTreeIndices...));
116 }
117
118
119
120 } // end namespace Functions
121 } // end namespace Dune
122
123
124
125 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTGLOBALBASIS_HH
126