DUNE PDELab (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#include <dune/typetree/traversal.hh>
14
15
16
17namespace Dune {
18namespace Functions {
19
20
21
44template<class GridView>
46{
47 static const int dim = GridView::dimension;
48
49public:
50
67 template<class LocalView>
68 SubEntityDOFs& bind(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
69 {
70 // fill vector with local indices of all DOFs contained in subentity
71 containedDOFs_.clear();
72 dofIsContained_.assign(localView.size(), false);
73
74 auto re = Dune::referenceElement<double,dim>(localView.element().type());
75
76 Dune::TypeTree::forEachLeafNode(localView.tree(), [&](auto&& node, auto&& /*treePath*/) {
77 if (node.empty())
78 return;
79 const auto& localCoefficients = node.finiteElement().localCoefficients();
80 std::size_t localSize = localCoefficients.size();
81 for(std::size_t i=0; i<localSize; ++i)
82 {
83 auto localKey = localCoefficients.localKey(i);
84 if (re.subEntities(subEntityIndex, subEntityCodim, localKey.codim()).contains(localKey.subEntity()))
85 {
86 containedDOFs_.push_back(node.localIndex(i));
87 dofIsContained_[node.localIndex(i)] = true;
88 }
89 }
90 });
91 return *this;
92 }
93
109 template<class LocalView, class Intersection>
110 SubEntityDOFs& bind(const LocalView& localView, const Intersection& intersection)
111 {
112 return bind(localView, intersection.indexInInside(), 1);
113 }
114
116 auto begin() const
117 {
118 return containedDOFs_.cbegin();
119 }
120
122 auto end() const
123 {
124 return containedDOFs_.cend();
125 }
126
128 auto size() const
129 {
130 return containedDOFs_.size();
131 }
132
134 decltype(auto) operator[](std::size_t i) const
135 {
136 return containedDOFs_[i];
137 }
138
140 bool contains(std::size_t localIndex) const
141 {
142 return dofIsContained_[localIndex];
143 }
144
145private:
146
147 std::vector<std::size_t> containedDOFs_;
148 std::vector<bool> dofIsContained_;
149};
150
151
152
165template<class T>
166auto subEntityDOFs(const T&)
167{
169}
170
171
172
192template<class LocalView>
193auto subEntityDOFs(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
194{
195 using GridView = typename LocalView::GridView;
197 subEntityDOFs.bind(localView, subEntityIndex, subEntityCodim);
198 return subEntityDOFs;
199}
200
201
202
221template<class LocalView, class Intersection>
222auto subEntityDOFs(const LocalView& localView, const Intersection& intersection)
223{
224 using GridView = typename LocalView::GridView;
226 subEntityDOFs.bind(localView, intersection);
227 return subEntityDOFs;
228}
229
230
231
232} // namespace Functions
233} // namespace Dune
234
235#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_SUBENTITYDOFS_HH
Range of DOFs associated to sub-entity.
Definition: subentitydofs.hh:46
auto begin() const
Create begin iterator for access to range of contained local indices.
Definition: subentitydofs.hh:116
auto size() const
Return number of contained DOFs.
Definition: subentitydofs.hh:128
SubEntityDOFs & bind(const LocalView &localView, const Intersection &intersection)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:110
bool contains(std::size_t localIndex) const
Check if given local index is contained in this range of DOFs.
Definition: subentitydofs.hh:140
auto end() const
Create end iterator for access to range of contained local indices.
Definition: subentitydofs.hh:122
SubEntityDOFs & bind(const LocalView &localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:68
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:351
auto subEntityDOFs(const LocalView &localView, const Intersection &intersection)
Create bound SubEntityDOFs object.
Definition: subentitydofs.hh:222
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:134
void forEachLeafNode(Tree &&tree, LeafFunc &&leafFunc)
Traverse tree and visit each leaf node.
Definition: traversal.hh:289
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Sep 3, 22:42, 2025)