Dune Core Modules (2.9.0)

subentitydofs.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_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 
13 namespace Dune {
14 namespace Functions {
15 
16 
17 
40 template<class GridView>
42 {
43  static const int dim = GridView::dimension;
44 
45 public:
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 
139 private:
140 
141  std::vector<std::size_t> containedDOFs_;
142  std::vector<bool> dofIsContained_;
143 };
144 
145 
146 
159 template<class T>
160 auto subEntityDOFs(const T&)
161 {
163 }
164 
165 
166 
186 template<class LocalView>
187 auto 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 
215 template<class LocalView, class Intersection>
216 auto 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
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
bool contains(std::size_t localIndex) const
Check if given local index is contained in this range of DOFs.
Definition: subentitydofs.hh:134
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
SubEntityDOFs & bind(const LocalView &localView, const Intersection &intersection)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:104
auto end() const
Create end iterator for access to range of contained local indices.
Definition: subentitydofs.hh:116
Grid view abstract base class.
Definition: gridview.hh:66
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: intersection.hh:346
auto subEntityDOFs(const LocalView &localView, const Intersection &intersection)
Create bound SubEntityDOFs object.
Definition: subentitydofs.hh:216
constexpr static int dimension
The dimension of the grid.
Definition: gridview.hh:148
void forEachLeafNode(Tree &&tree, LeafFunc &&leafFunc)
Traverse tree and visit each leaf node.
Definition: traversal.hh:304
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 5, 22:29, 2024)