Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
domains/boundarypatch.hh
Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set ts=8 sw=2 et sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM 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_FUFEM_DOMAINS_BOUNDARYPATCH_HH
8#define DUNE_FUFEM_DOMAINS_BOUNDARYPATCH_HH
9
10#include <cstddef>
11#include <optional>
12
15
17
19
21
22
23
24namespace Dune::Fufem {
25
26
27
35template <class GV>
37{
38protected:
39
40 static const int dim = GV::dimension;
41
42 using Element = typename GV::template Codim<0>::Entity;
43 using Intersection = typename GV::Intersection;
45
46public:
47
51 using GridView = GV;
52
57
65
66 BoundaryPatch () = default;
67
68 BoundaryPatch (const BoundaryPatch&) = default;
69
71
73
75
86
90 void clear ()
91 {
93 }
94
98 void insertFace (const Element& element, int faceIndex)
99 {
100 this->faces_[mapper_->subIndex(element, faceIndex, 1)] = true;
101 }
102
106 void insertFace (const Intersection& intersection)
107 {
108 insertFace(intersection.inside(), intersection.indexInInside());
109 }
110
115 {
116 return iterator(*this, gridView().template begin<0>());
117 }
118
122 iterator end () const
123 {
124 return iterator(*this, gridView().template end<0>());
125 }
126
131 {
132 return faces_.count();
133 }
134
141 bool contains (const Element& element, int faceIndex) const
142 {
143 return this->faces_[mapper_->subIndex(element, faceIndex, 1)][0];
144 }
145
152 template <class IntersectionType>
153 bool contains (const IntersectionType& intersection) const
154 {
155 return contains(intersection.inside(), intersection.indexInInside());
156 }
157
164 bool contains (const Element& element, int subEntity, int codim) const
165 {
166 if (codim==0) // disregard element dofs
167 return false;
168 if (codim==1)
169 return contains(element, subEntity);
170 const auto& referenceElement = Dune::referenceElement(element);
171 for (int faceIndex : Dune::range(element.subEntities(1)))
172 if (contains(element, faceIndex))
173 for (int k : referenceElement.subEntities(faceIndex, 1, codim))
174 if (k == subEntity)
175 return true;
176 return false;
177 }
178
185 bool containsFaceOf (const Element& e) const
186 {
187 if (gridView().contains(e))
188 for (int faceIndex : Dune::range(e.subEntities(1)))
189 if (contains(e, faceIndex))
190 return true;
191 return false;
192 }
193
197 const GridView& gridView () const
198 {
199 return *gridView_;
200 }
201
205 bool isInitialized () const
206 {
207 return gridView_.has_value();
208 }
209
215 bool operator== (const BoundaryPatch& other) const
216 {
217 // There is no BitSetVector::operator==
218 if (faces_.size() != other.faces_.size())
219 return false;
220 for (auto i : Dune::range(faces_.size()))
221 if (faces_[i] != other.faces_[i])
222 return false;
223 return true;
224 }
225
226protected:
227
231};
232
233} // namespace Dune::Fufem
234
235
236
237#endif // DUNE_FUFEM_DOMAINS_BOUNDARYPATCH_HH
unspecified value type referenceElement(T &&... t)
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
Definition dunefunctionsboundaryfunctionalassembler.hh:29
MCMGLayout mcmgLayout(Dim< dim >)
size_type count() const
size_type size() const
void resize(int n, bool v=bool())
Encapsulate a subset of the boundary intersections of a GridView.
Definition domains/boundarypatch.hh:37
bool contains(const IntersectionType &intersection) const
Return true if the BoundaryPatch contains a certain boundary face.
Definition domains/boundarypatch.hh:153
static const int dim
Definition domains/boundarypatch.hh:40
std::size_t size() const
Returns the number of faces in the surface.
Definition domains/boundarypatch.hh:130
bool containsFaceOf(const Element &e) const
Return true if the BoundaryPatch contains a face of given element.
Definition domains/boundarypatch.hh:185
std::optional< Mapper > mapper_
Definition domains/boundarypatch.hh:230
typename Dune::MultipleCodimMultipleGeomTypeMapper< GV > Mapper
Definition domains/boundarypatch.hh:44
const GridView & gridView() const
Return reference to the carrier grid view.
Definition domains/boundarypatch.hh:197
bool operator==(const BoundaryPatch &other) const
Compare with another BoundaryPatch on the same GridView.
Definition domains/boundarypatch.hh:215
iterator end() const
Return iterator pointing after last boundary patch face.
Definition domains/boundarypatch.hh:122
Dune::Fufem::IntersectionSetIterator< BoundaryPatch > iterator
Export the appropriate iterator type.
Definition domains/boundarypatch.hh:56
BoundaryPatch & operator=(const BoundaryPatch &)=default
void insertFace(const Element &element, int faceIndex)
Insert a boundary face into the patch.
Definition domains/boundarypatch.hh:98
void insertFace(const Intersection &intersection)
Insert a boundary face into the patch.
Definition domains/boundarypatch.hh:106
typename GV::Intersection Intersection
Definition domains/boundarypatch.hh:43
BoundaryPatch(const BoundaryPatch &)=default
bool contains(const Element &element, int faceIndex) const
Return true if the BoundaryPatch contains a certain boundary face.
Definition domains/boundarypatch.hh:141
BoundaryPatch(const GridView &gridView)
Constructor for a given grid view.
Definition domains/boundarypatch.hh:61
bool isInitialized() const
Check if BoundaryPatch is initialized.
Definition domains/boundarypatch.hh:205
iterator begin() const
Return iterator pointing to first boundary patch face.
Definition domains/boundarypatch.hh:114
bool contains(const Element &element, int subEntity, int codim) const
Return true if the BoundaryPatch contains a certain subentity in some face.
Definition domains/boundarypatch.hh:164
void setGridView(const GridView &gridView)
Set the grid view and initialize the patch.
Definition domains/boundarypatch.hh:79
BoundaryPatch(BoundaryPatch &&)=default
std::optional< GridView > gridView_
Definition domains/boundarypatch.hh:229
void clear()
Clear the boundary patch, but don't disconnect it from the GridView.
Definition domains/boundarypatch.hh:90
typename GV::template Codim< 0 >::Entity Element
Definition domains/boundarypatch.hh:42
Dune::BitSetVector< 1 > faces_
Definition domains/boundarypatch.hh:228
GV GridView
GridView The grid view on which this boundary patch lives.
Definition domains/boundarypatch.hh:51
An iterator iterating over all intersections of an intersection set.
Definition intersectionsetiterator.hh:57
T has_value(T... args)