dune-mmesh (unstable)

rangegenerators.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_MMESH_RANGEGENERATORS_HH
4#define DUNE_MMESH_RANGEGENERATORS_HH
5
6#include <dune/common/iteratorrange.hh>
7
8namespace Dune {
12template <typename Entity>
13inline auto incidentElements(const Entity& entity)
14#ifndef DOXYGEN_SHOULD_SKIP_THIS
15 -> IteratorRange<decltype(entity.impl().incidentBegin())>
16#endif /* DOXYGEN_SHOULD_SKIP_THIS */
17{
18 static_assert(Entity::mydimension <= 1,
19 "Incident element range iterator is only available for "
20 "vertices and edges!");
21 return IteratorRange<decltype(entity.impl().incidentBegin())>(
22 entity.impl().incidentBegin(), entity.impl().incidentEnd());
23}
24
28template <typename Vertex>
29inline auto incidentFacets(const Vertex& vertex)
30#ifndef DOXYGEN_SHOULD_SKIP_THIS
31 -> IteratorRange<decltype(vertex.impl().incidentFacetsBegin())>
32#endif /* DOXYGEN_SHOULD_SKIP_THIS */
33{
34 static_assert(
35 Vertex::mydimension == 0,
36 "Incident facet range iterator is only available for vertices!");
37 return IteratorRange<decltype(vertex.impl().incidentFacetsBegin())>(
38 vertex.impl().incidentFacetsBegin(), vertex.impl().incidentFacetsEnd());
39}
40
44template <typename Vertex>
45inline auto incidentVertices(const Vertex& vertex, bool includeInfinite = false)
46#ifndef DOXYGEN_SHOULD_SKIP_THIS
47 -> IteratorRange<
48 decltype(vertex.impl().incidentVerticesBegin(includeInfinite))>
49#endif /* DOXYGEN_SHOULD_SKIP_THIS */
50{
51 static_assert(
52 Vertex::mydimension == 0,
53 "Incident vertices range iterator is only available for vertices!");
54 return IteratorRange<decltype(vertex.impl().incidentVerticesBegin(
55 includeInfinite))>(vertex.impl().incidentVerticesBegin(includeInfinite),
56 vertex.impl().incidentVerticesEnd(includeInfinite));
57}
58
62template <typename GridView, int codim = 1>
63inline auto interfaceElements(const GridView& gv, bool includeBoundary = false)
64#ifndef DOXYGEN_SHOULD_SKIP_THIS
65 -> IteratorRange<
66 decltype(gv.grid().template interfaceBegin<codim>(includeBoundary))>
67#endif /* DOXYGEN_SHOULD_SKIP_THIS */
68{
69 return IteratorRange<decltype(gv.grid().template interfaceBegin<codim>(
70 includeBoundary))>(
71 gv.grid().template interfaceBegin<codim>(includeBoundary),
72 gv.grid().template interfaceEnd<codim>(includeBoundary));
73}
74
78template <typename GridView>
79inline auto interfaceVertices(const GridView& gv, bool includeBoundary = false)
80#ifndef DOXYGEN_SHOULD_SKIP_THIS
81 -> IteratorRange<
82 decltype(gv.grid().interfaceVerticesBegin(includeBoundary))>
83#endif /* DOXYGEN_SHOULD_SKIP_THIS */
84{
85 return IteratorRange<decltype(gv.grid().interfaceVerticesBegin(
86 includeBoundary))>(gv.grid().interfaceVerticesBegin(includeBoundary),
87 gv.grid().interfaceVerticesEnd(includeBoundary));
88}
89
93template <typename Vertex>
94inline auto incidentInterfaceVertices(const Vertex& vertex)
95#ifndef DOXYGEN_SHOULD_SKIP_THIS
96 -> IteratorRange<decltype(vertex.impl().incidentInterfaceVerticesBegin())>
97#endif /* DOXYGEN_SHOULD_SKIP_THIS */
98{
99 static_assert(Vertex::mydimension == 0,
100 "Incident interface vertices range iterator is only available "
101 "for interface vertices!");
102 return IteratorRange<
103 decltype(vertex.impl().incidentInterfaceVerticesBegin())>(
104 vertex.impl().incidentInterfaceVerticesBegin(),
105 vertex.impl().incidentInterfaceVerticesEnd());
106}
107
111template <typename Entity>
112inline auto incidentInterfaceElements(const Entity& entity)
113#ifndef DOXYGEN_SHOULD_SKIP_THIS
114 -> IteratorRange<decltype(entity.impl().incidentInterfaceElementsBegin())>
115#endif /* DOXYGEN_SHOULD_SKIP_THIS */
116{
117 static_assert(Entity::mydimension <= 1,
118 "Incident interface vertices range iterator is only available "
119 "for interface vertices and edges!");
120 return IteratorRange<
121 decltype(entity.impl().incidentInterfaceElementsBegin())>(
122 entity.impl().incidentInterfaceElementsBegin(),
123 entity.impl().incidentInterfaceElementsEnd());
124}
125
126} // namespace Dune
127
128#endif // DUNE_MMESH_RANGEGENERATORS_HH
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Mar 17, 23:30, 2025)