dune-functions 2.9.0
subentitydofs.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_SUBENTITYDOFS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBENTITYDOFS_HH
5
6#include <vector>
7
8#include <dune/geometry/referenceelements.hh>
9#include <dune/typetree/traversal.hh>
10
11
12
13namespace Dune {
14namespace Functions {
15
16
17
40template<class GridView>
42{
43 static const int dim = GridView::dimension;
44
45public:
46
63 template<class LocalView>
64 SubEntityDOFs& bind(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
65 {
66 // fill vector with local indices of all DOFs contained in subentity
67 containedDOFs_.clear();
68 dofIsContained_.assign(localView.size(), false);
69
70 auto re = Dune::referenceElement<double,dim>(localView.element().type());
71
72 Dune::TypeTree::forEachLeafNode(localView.tree(), [&](auto&& node, auto&& /*treePath*/) {
73 const auto& localCoefficients = node.finiteElement().localCoefficients();
74 std::size_t localSize = localCoefficients.size();
75 for(std::size_t i=0; i<localSize; ++i)
76 {
77 auto localKey = localCoefficients.localKey(i);
78 if (re.subEntities(subEntityIndex, subEntityCodim, localKey.codim()).contains(localKey.subEntity()))
79 {
80 containedDOFs_.push_back(node.localIndex(i));
81 dofIsContained_[node.localIndex(i)] = true;
82 }
83 }
84 });
85 return *this;
86 }
87
103 template<class LocalView, class Intersection>
104 SubEntityDOFs& bind(const LocalView& localView, const Intersection& intersection)
105 {
106 return bind(localView, intersection.indexInInside(), 1);
107 }
108
110 auto begin() const
111 {
112 return containedDOFs_.cbegin();
113 }
114
116 auto end() const
117 {
118 return containedDOFs_.cend();
119 }
120
122 auto size() const
123 {
124 return containedDOFs_.size();
125 }
126
128 decltype(auto) operator[](std::size_t i) const
129 {
130 return containedDOFs_[i];
131 }
132
134 bool contains(std::size_t localIndex) const
135 {
136 return dofIsContained_[localIndex];
137 }
138
139private:
140
141 std::vector<std::size_t> containedDOFs_;
142 std::vector<bool> dofIsContained_;
143};
144
145
146
159template<class T>
160auto subEntityDOFs(const T&)
161{
163}
164
165
166
186template<class LocalView>
187auto subEntityDOFs(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
188{
189 using GridView = typename LocalView::GridView;
191 subEntityDOFs.bind(localView, subEntityIndex, subEntityCodim);
192 return subEntityDOFs;
193}
194
195
196
215template<class LocalView, class Intersection>
216auto subEntityDOFs(const LocalView& localView, const Intersection& intersection)
217{
218 using GridView = typename LocalView::GridView;
220 subEntityDOFs.bind(localView, intersection);
221 return subEntityDOFs;
222}
223
224
225
226} // namespace Functions
227} // namespace Dune
228
229#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBENTITYDOFS_HH
auto subEntityDOFs(const LocalView &localView, const Intersection &intersection)
Create bound SubEntityDOFs object.
Definition: subentitydofs.hh:216
Definition: polynomial.hh:10
Range of DOFs associated to sub-entity.
Definition: subentitydofs.hh:42
auto begin() const
Create begin iterator for access to range of contained local indices.
Definition: subentitydofs.hh:110
auto size() const
Return number of contained DOFs.
Definition: subentitydofs.hh:122
SubEntityDOFs & bind(const LocalView &localView, const Intersection &intersection)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:104
bool contains(std::size_t localIndex) const
Check if given local index is contained in this range of DOFs.
Definition: subentitydofs.hh:134
auto end() const
Create end iterator for access to range of contained local indices.
Definition: subentitydofs.hh:116
SubEntityDOFs & bind(const LocalView &localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:64