DUNE-FUNCTIONS (unstable)

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
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_SUBENTITYDOFS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBENTITYDOFS_HH
9
10#include <vector>
11
12#include <dune/geometry/referenceelements.hh>
13
14#include <dune/common/typetree/traversal.hh>
15
16
17
18namespace Dune {
19namespace Functions {
20
21
22
45template<class GridView>
47{
48 static const int dim = GridView::dimension;
49
50public:
51
68 template<class LocalView>
69 SubEntityDOFs& bind(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
70 {
71 // fill vector with local indices of all DOFs contained in subentity
72 containedDOFs_.clear();
73 dofIsContained_.assign(localView.size(), false);
74
75 auto re = Dune::referenceElement<double,dim>(localView.element().type());
76
77 Dune::TypeTree::forEachLeafNode(localView.tree(), [&](auto&& node, auto&& /*treePath*/) {
78 if (node.empty())
79 return;
80 const auto& localCoefficients = node.finiteElement().localCoefficients();
81 std::size_t localSize = localCoefficients.size();
82 for(std::size_t i=0; i<localSize; ++i)
83 {
84 auto localKey = localCoefficients.localKey(i);
85 if (re.subEntities(subEntityIndex, subEntityCodim, localKey.codim()).contains(localKey.subEntity()))
86 {
87 containedDOFs_.push_back(node.localIndex(i));
88 dofIsContained_[node.localIndex(i)] = true;
89 }
90 }
91 });
92 return *this;
93 }
94
110 template<class LocalView, class Intersection>
111 SubEntityDOFs& bind(const LocalView& localView, const Intersection& intersection)
112 {
113 return bind(localView, intersection.indexInInside(), 1);
114 }
115
117 auto begin() const
118 {
119 return containedDOFs_.cbegin();
120 }
121
123 auto end() const
124 {
125 return containedDOFs_.cend();
126 }
127
129 auto size() const
130 {
131 return containedDOFs_.size();
132 }
133
135 decltype(auto) operator[](std::size_t i) const
136 {
137 return containedDOFs_[i];
138 }
139
141 bool contains(std::size_t localIndex) const
142 {
143 return dofIsContained_[localIndex];
144 }
145
146private:
147
148 std::vector<std::size_t> containedDOFs_;
149 std::vector<bool> dofIsContained_;
150};
151
152
153
166template<class T>
167auto subEntityDOFs(const T&)
168{
170}
171
172
173
193template<class LocalView>
194auto subEntityDOFs(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
195{
196 using GridView = typename LocalView::GridView;
198 subEntityDOFs.bind(localView, subEntityIndex, subEntityCodim);
199 return subEntityDOFs;
200}
201
202
203
222template<class LocalView, class Intersection>
223auto subEntityDOFs(const LocalView& localView, const Intersection& intersection)
224{
225 using GridView = typename LocalView::GridView;
227 subEntityDOFs.bind(localView, intersection);
228 return subEntityDOFs;
229}
230
231
232
233} // namespace Functions
234} // namespace Dune
235
236#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBENTITYDOFS_HH
Range of DOFs associated to sub-entity.
Definition: subentitydofs.hh:47
auto begin() const
Create begin iterator for access to range of contained local indices.
Definition: subentitydofs.hh:117
auto size() const
Return number of contained DOFs.
Definition: subentitydofs.hh:129
SubEntityDOFs & bind(const LocalView &localView, const Intersection &intersection)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:111
bool contains(std::size_t localIndex) const
Check if given local index is contained in this range of DOFs.
Definition: subentitydofs.hh:141
auto end() const
Create end iterator for access to range of contained local indices.
Definition: subentitydofs.hh:123
SubEntityDOFs & bind(const LocalView &localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:69
auto subEntityDOFs(const LocalView &localView, const Intersection &intersection)
Create bound SubEntityDOFs object.
Definition: subentitydofs.hh:223
Definition: monomialset.hh:19
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jan 9, 23:34, 2026)