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#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 const auto& localCoefficients = node.finiteElement().localCoefficients();
78 std::size_t localSize = localCoefficients.size();
79 for(std::size_t i=0; i<localSize; ++i)
80 {
81 auto localKey = localCoefficients.localKey(i);
82 if (re.subEntities(subEntityIndex, subEntityCodim, localKey.codim()).contains(localKey.subEntity()))
83 {
84 containedDOFs_.push_back(node.localIndex(i));
85 dofIsContained_[node.localIndex(i)] = true;
86 }
87 }
88 });
89 return *this;
90 }
91
107 template<class LocalView, class Intersection>
108 SubEntityDOFs& bind(const LocalView& localView, const Intersection& intersection)
109 {
110 return bind(localView, intersection.indexInInside(), 1);
111 }
112
114 auto begin() const
115 {
116 return containedDOFs_.cbegin();
117 }
118
120 auto end() const
121 {
122 return containedDOFs_.cend();
123 }
124
126 auto size() const
127 {
128 return containedDOFs_.size();
129 }
130
132 decltype(auto) operator[](std::size_t i) const
133 {
134 return containedDOFs_[i];
135 }
136
138 bool contains(std::size_t localIndex) const
139 {
140 return dofIsContained_[localIndex];
141 }
142
143private:
144
145 std::vector<std::size_t> containedDOFs_;
146 std::vector<bool> dofIsContained_;
147};
148
149
150
163template<class T>
164auto subEntityDOFs(const T&)
165{
167}
168
169
170
190template<class LocalView>
191auto subEntityDOFs(const LocalView& localView, std::size_t subEntityIndex, std::size_t subEntityCodim)
192{
193 using GridView = typename LocalView::GridView;
195 subEntityDOFs.bind(localView, subEntityIndex, subEntityCodim);
196 return subEntityDOFs;
197}
198
199
200
219template<class LocalView, class Intersection>
220auto subEntityDOFs(const LocalView& localView, const Intersection& intersection)
221{
222 using GridView = typename LocalView::GridView;
224 subEntityDOFs.bind(localView, intersection);
225 return subEntityDOFs;
226}
227
228
229
230} // namespace Functions
231} // namespace Dune
232
233#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:114
auto size() const
Return number of contained DOFs.
Definition: subentitydofs.hh:126
SubEntityDOFs & bind(const LocalView &localView, const Intersection &intersection)
Bind SubEntityDOFs object to LocalView and sub-entity.
Definition: subentitydofs.hh:108
bool contains(std::size_t localIndex) const
Check if given local index is contained in this range of DOFs.
Definition: subentitydofs.hh:138
auto end() const
Create end iterator for access to range of contained local indices.
Definition: subentitydofs.hh:120
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
auto subEntityDOFs(const LocalView &localView, const Intersection &intersection)
Create bound SubEntityDOFs object.
Definition: subentitydofs.hh:220
Definition: polynomial.hh:17
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)