dune-pdelab 2.7-git
Loading...
Searching...
No Matches
dunefunctionslocalfunctionspace.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_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLOCALFUNCTIONSPACE_HH
4#define DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLOCALFUNCTIONSPACE_HH
5
6#include<vector>
7
8#include <dune/common/stdstreams.hh>
9#include <dune/common/shared_ptr.hh>
10
11#include <dune/geometry/referenceelements.hh>
12
13#include <dune/localfunctions/common/interfaceswitch.hh>
14#include <dune/localfunctions/common/localkey.hh>
15
16#include <dune/typetree/typetree.hh>
17
20
21namespace Dune {
22 namespace PDELab {
23
27
28 namespace Experimental {
29
30 template<typename LFS>
32 : public TypeTree::LeafNode
33 {
34
35 const auto& finiteElement() const
36 {
37 return static_cast<const LFS*>(this)->tree().finiteElement();
38 }
39
40 template<typename Tree>
41 struct Traits
42 {
43 using FiniteElement = typename Tree::FiniteElement;
45 };
46 };
47
48 template<typename GFS, typename TreePath = TypeTree::HybridTreePath<>>
50 : public LeafLFSMixin<LocalFunctionSpace<GFS,TreePath>>
51 {
52
53 public:
54
55 using Basis = typename GFS::Basis;
56 using LocalView = typename Basis::LocalView;
57 using Tree = TypeTree::ChildForTreePath<typename LocalView::Tree,TreePath>;
58 using DOFIndex = typename GFS::Ordering::Traits::DOFIndex;
59
60 template<typename LFS, typename C, typename Tag, bool fast>
62
63 struct Traits
64 : public LeafLFSMixin<LocalFunctionSpace<GFS,TreePath>>::template Traits<Tree>
65 {
66
67 using GridFunctionSpace = GFS;
68 using GridView = typename GFS::Traits::GridView;
69 using SizeType = std::size_t;
70 using DOFIndex = typename GFS::Ordering::Traits::DOFIndex;
71 using ConstraintsType = typename GFS::Traits::ConstraintsType;
72
73 };
74
75 using size_type = std::size_t;
76
77 LocalFunctionSpace(std::shared_ptr<const GFS> gfs, TreePath tree_path = TreePath(), size_type offset = 0)
78 : _gfs(gfs)
79 , _local_view(gfs->basis().localView())
80 , _tree_path(tree_path)
81 , _tree(TypeTree::child(_local_view.tree(),tree_path))
82 {}
83
85 {
86 return 0;
87 }
88
90 size_type size () const
91 {
92 return _local_view.size();
93 }
94
96 {
97 // _dof_indices is always as large as the max local size of the root GFS
98 return _local_view.maxSize();
99 }
100
103 {
104 return _tree.localIndex(index);
105 }
106
107 // index: local dof index for the given element
109 {
110 auto refElement = Dune::ReferenceElements<double,Basis::GridView::dimension>::general(_local_view.element().type());
111
112 auto localKey = _local_view.tree().finiteElement().localCoefficients().localKey(index);
113
114 const auto& indexSet = _gfs->basis().gridView().indexSet();
115
116 // get geometry type of subentity
117 auto gt = refElement.type(localKey.subEntity(), localKey.codim());
118
119 // evaluate consecutive index of subentity
120 auto indexOnEntity = indexSet.subIndex(_local_view.element(),
121 localKey.subEntity(),
122 localKey.codim());
123
124
125 DOFIndex result;
126 GFS::Ordering::Traits::DOFIndexAccessor::store(result,gt,indexOnEntity,localKey.index());
127 return result;
128 }
129
130 // index: local dof index for the given element
132 {
134 result.set({_local_view.index(_tree.localIndex(index))});
135 return result;
136 }
137
139 const GFS& gridFunctionSpace() const
140 {
141 return *_gfs;
142 }
143
144 void bind(const typename GFS::Traits::EntitySet::template Codim<0>::Entity& e)
145 {
146 _local_view.bind(e);
147 }
148
149 const typename Traits::ConstraintsType& constraints() const
150 {
151 return _gfs->constraints();
152 }
153
154 const Tree& tree() const
155 {
156 return _tree;
157 }
158
159 private:
160
161 typename GFS::Ordering::Traits::ContainerIndex containerIndex(const DOFIndex& i) const
162 {
163 return _gfs->ordering().containerIndex(i);
164 }
165
166 std::shared_ptr<const GFS> _gfs;
167 LocalView _local_view;
168 TreePath _tree_path;
169 const Tree& _tree;
170
171 };
172
173 // forward declare GridFunctionSpace
174 template<typename DFBasis, typename V, typename CE=NoConstraints>
175 class GridFunctionSpace;
176
177
178 } // namespace Experimental
179
180
181 template<typename DFBasis, typename V, typename CE, typename TAG>
182 class LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>,TAG>
183 : public Experimental::LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>>
184 {
185
187
188 public:
189
190 LocalFunctionSpace(std::shared_ptr<const GFS> gfs)
191 : Experimental::LocalFunctionSpace<GFS>(gfs)
192 {}
193
195 : Experimental::LocalFunctionSpace<GFS>(stackobject_to_shared_ptr(gfs))
196 {}
197
198 };
199
200 template<typename DFBasis, typename V, typename CE>
201 class LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>,AnySpaceTag>
202 : public Experimental::LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>>
203 {
204
206
207 public:
208
209 LocalFunctionSpace(std::shared_ptr<const GFS> gfs)
210 : Experimental::LocalFunctionSpace<GFS>(gfs)
211 {}
212
214 : Experimental::LocalFunctionSpace<GFS>(stackobject_to_shared_ptr(gfs))
215 {}
216
217 };
218
220 } // namespace PDELab
221} // namespace Dune
222
223#endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLOCALFUNCTIONSPACE_HH
std::size_t index
Definition: interpolate.hh:97
const std::size_t offset
Definition: localfunctionspace.hh:75
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
A multi-index representing a degree of freedom in a GridFunctionSpace.
Definition: dofindex.hh:148
A class for representing multi-indices.
Definition: multiindex.hh:29
void set(typename ReservedVector< T, n >::value_type index)
Definition: multiindex.hh:152
Definition: dunefunctionslocalfunctionspace.hh:33
const auto & finiteElement() const
Definition: dunefunctionslocalfunctionspace.hh:35
Definition: dunefunctionslocalfunctionspace.hh:42
typename Tree::FiniteElement FiniteElement
Definition: dunefunctionslocalfunctionspace.hh:43
FiniteElement FiniteElementType
Definition: dunefunctionslocalfunctionspace.hh:44
Definition: dunefunctionslocalfunctionspace.hh:51
auto containerIndex(size_type index) const
Definition: dunefunctionslocalfunctionspace.hh:131
typename Basis::LocalView LocalView
Definition: dunefunctionslocalfunctionspace.hh:56
typename GFS::Basis Basis
Definition: dunefunctionslocalfunctionspace.hh:55
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: dunefunctionslocalfunctionspace.hh:139
DOFIndex dofIndex(size_type index) const
Definition: dunefunctionslocalfunctionspace.hh:108
const Tree & tree() const
Definition: dunefunctionslocalfunctionspace.hh:154
LocalFunctionSpace(std::shared_ptr< const GFS > gfs, TreePath tree_path=TreePath(), size_type offset=0)
Definition: dunefunctionslocalfunctionspace.hh:77
size_type size() const
get current size
Definition: dunefunctionslocalfunctionspace.hh:90
const Traits::ConstraintsType & constraints() const
Definition: dunefunctionslocalfunctionspace.hh:149
size_type localIndex(size_type index) const
map index in this local function space to root local function space
Definition: dunefunctionslocalfunctionspace.hh:102
void bind(const typename GFS::Traits::EntitySet::template Codim< 0 >::Entity &e)
Definition: dunefunctionslocalfunctionspace.hh:144
typename GFS::Ordering::Traits::DOFIndex DOFIndex
Definition: dunefunctionslocalfunctionspace.hh:58
size_type maxSize() const
Definition: dunefunctionslocalfunctionspace.hh:95
size_type subSpaceDepth() const
Definition: dunefunctionslocalfunctionspace.hh:84
std::size_t size_type
Definition: dunefunctionslocalfunctionspace.hh:75
TypeTree::ChildForTreePath< typename LocalView::Tree, TreePath > Tree
Definition: dunefunctionslocalfunctionspace.hh:57
Definition: dunefunctionslocalfunctionspace.hh:65
GFS GridFunctionSpace
Definition: dunefunctionslocalfunctionspace.hh:67
typename GFS::Ordering::Traits::DOFIndex DOFIndex
Definition: dunefunctionslocalfunctionspace.hh:70
typename GFS::Traits::GridView GridView
Definition: dunefunctionslocalfunctionspace.hh:68
typename GFS::Traits::ConstraintsType ConstraintsType
Definition: dunefunctionslocalfunctionspace.hh:71
std::size_t SizeType
Definition: dunefunctionslocalfunctionspace.hh:69
LocalFunctionSpace(std::shared_ptr< const GFS > gfs)
Definition: dunefunctionslocalfunctionspace.hh:190
LocalFunctionSpace(const GFS &gfs)
Definition: dunefunctionslocalfunctionspace.hh:194
LocalFunctionSpace(std::shared_ptr< const GFS > gfs)
Definition: dunefunctionslocalfunctionspace.hh:209
LocalFunctionSpace(const GFS &gfs)
Definition: dunefunctionslocalfunctionspace.hh:213
A grid function space.
Definition: gridfunctionspace.hh:191
Definition: lfsindexcache.hh:245
Create a local function space from a global function space.
Definition: localfunctionspace.hh:725
Definition: localfunctionspacetags.hh:40