DUNE PDELab (git)

identitygridindexsets.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_IDENTITYGRID_INDEXSETS_HH
6#define DUNE_IDENTITYGRID_INDEXSETS_HH
7
13
14#include <vector>
15
16namespace Dune {
17
19 template<class GridImp>
21 public IndexSet<GridImp,
22 IdentityGridLevelIndexSet<GridImp>,
23 typename std::remove_const<GridImp>::type::HostGridType::LevelGridView::IndexSet::IndexType,
24 typename std::remove_const<GridImp>::type::HostGridType::LevelGridView::IndexSet::Types
25 >
26 {
27 public:
28
29 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
30 typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
31
32 constexpr static int dim = GridImp::dimension;
33
35 template<int codim>
36 int index (const typename GridImp::Traits::template Codim<codim>::Entity& e) const
37 {
38 return grid_->hostgrid_->levelIndexSet(level_).template index<codim>(grid_->template getHostEntity<codim>(e));
39 }
40
41
43 template<int cc>
44 int subIndex (const typename GridImp::Traits::template Codim<cc>::Entity& e, int i, int codim) const
45 {
46 return grid_->hostgrid_->levelIndexSet(level_).subIndex(grid_->template getHostEntity<cc>(e), i, codim);
47 }
48
49
51 std::size_t size (int codim) const {
52 return grid_->hostgrid_->levelIndexSet(level_).size(codim);
53 }
54
55
57 std::size_t size (GeometryType type) const
58 {
59 return grid_->hostgrid_->levelIndexSet(level_).size(type);
60 }
61
63 Types types (int codim) const
64 {
65 return grid_->hostgrid_->levelIndexSet(level_).types(codim);
66 }
67
69 template<class EntityType>
70 bool contains (const EntityType& e) const
71 {
72 return grid_->hostgrid_->levelIndexSet(level_).contains(grid_->template getHostEntity<EntityType::codimension>(e));
73 }
74
76 void update(const GridImp& grid, int level)
77 {
78 grid_ = &grid;
79 level_ = level;
80 }
81
82
83 GridImp* grid_;
84
85 int level_;
86 };
87
88
89 template<class GridImp>
90 class IdentityGridLeafIndexSet :
91 public IndexSet<GridImp,
92 IdentityGridLeafIndexSet<GridImp>,
93 typename std::remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::IndexType,
94 typename std::remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::Types
95 >
96 {
97 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
98
99 public:
100
101 typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
102
103 /*
104 * We use the remove_const to extract the Type from the mutable class,
105 * because the const class is not instantiated yet.
106 */
107 constexpr static int dim = std::remove_const<GridImp>::type::dimension;
108
109
111 IdentityGridLeafIndexSet (const GridImp& grid)
112 : grid_(&grid)
113 {}
114
115
117 /*
118 We use the RemoveConst to extract the Type from the mutable class,
119 because the const class is not instantiated yet.
120 */
121 template<int codim>
122 int index (const typename std::remove_const<GridImp>::type::template Codim<codim>::Entity& e) const
123 {
124 return grid_->hostgrid_->leafIndexSet().template index<codim>(grid_->template getHostEntity<codim>(e));
125 }
126
127
129 /*
130 We use the RemoveConst to extract the Type from the mutable class,
131 because the const class is not instantiated yet.
132 */
133 template<int cc>
134 int subIndex (const typename std::remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e, int i, int codim) const
135 {
136 return grid_->hostgrid_->leafIndexSet().subIndex(grid_->template getHostEntity<cc>(e),i, codim);
137 }
138
139
141 std::size_t size (GeometryType type) const
142 {
143 return grid_->hostgrid_->leafIndexSet().size(type);
144 }
145
146
148 std::size_t size (int codim) const
149 {
150 return grid_->hostgrid_->leafIndexSet().size(codim);
151 }
152
154 Types types (int codim) const
155 {
156 return grid_->hostgrid_->leafIndexSet().types(codim);
157 }
158
160 template<class EntityType>
161 bool contains (const EntityType& e) const
162 {
163 return grid_->hostgrid_->leafIndexSet().contains(grid_->template getHostEntity<EntityType::codimension>(e));
164 }
165
166
167
169 void update(const GridImp& grid)
170 {
171 grid_ = &grid;
172 }
173
174
175 GridImp* grid_;
176 };
177
178
179
180
181 template <class GridImp>
182 class IdentityGridGlobalIdSet :
183 public IdSet<GridImp,IdentityGridGlobalIdSet<GridImp>,
184 typename std::remove_const<GridImp>::type::HostGridType::Traits::GlobalIdSet::IdType>
185 {
186
187 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
188
189
190 public:
192 IdentityGridGlobalIdSet (const GridImp& g) : grid_(&g) {}
193
195 typedef typename HostGrid::Traits::GlobalIdSet::IdType IdType;
196
197
199 /*
200 We use the remove_const to extract the Type from the mutable class,
201 because the const class is not instantiated yet.
202 */
203 template<int cd>
204 IdType id (const typename std::remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
205 {
206 // Return id of the host entity
207 return grid_->hostgrid_->globalIdSet().id(e.impl().hostEntity_);
208 }
209
210
212 /*
213 We use the remove_const to extract the Type from the mutable class,
214 because the const class is not instantiated yet.
215 */
216 IdType subId (const typename std::remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i, int codim) const
217 {
218 // Return sub id of the host entity
219 return grid_->hostgrid_->globalIdSet().subId(e.impl().hostEntity_,i, codim);
220 }
221
222
224 void update() {}
225
226
227 const GridImp* grid_;
228 };
229
230
231
232
233 template<class GridImp>
234 class IdentityGridLocalIdSet :
235 public IdSet<GridImp,IdentityGridLocalIdSet<GridImp>,
236 typename std::remove_const<GridImp>::type::HostGridType::Traits::LocalIdSet::IdType>
237 {
238 private:
239
240 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
241
242
243 public:
245 typedef typename HostGrid::Traits::LocalIdSet::IdType IdType;
246
247
249 IdentityGridLocalIdSet (const GridImp& g) : grid_(&g) {}
250
251
253 /*
254 We use the remove_const to extract the Type from the mutable class,
255 because the const class is not instantiated yet.
256 */
257 template<int cd>
258 IdType id (const typename std::remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
259 {
260 // Return id of the host entity
261 return grid_->hostgrid_->localIdSet().id(e.impl().hostEntity_);
262 }
263
264
266 /*
267 * We use the remove_const to extract the Type from the mutable class,
268 * because the const class is not instantiated yet.
269 */
270 IdType subId (const typename std::remove_const<GridImp>::type::template Codim<0>::Entity& e, int i, int codim) const
271 {
272 // Return sub id of the host entity
273 return grid_->hostgrid_->localIdSet().subId(e.impl().hostEntity_,i,codim);
274 }
275
276
278 void update() {}
279
280
281 const GridImp* grid_;
282 };
283
284
285} // namespace Dune
286
287
288#endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
IdType subId(const typename Codim< 0 >::Entity &e, int i, unsigned int codim) const
Get id of subentity i of co-dimension codim of a co-dimension 0 entity.
Definition: indexidset.hh:481
IdType id(const Entity &e) const
Get id of an entity. This method is simpler to use than the one below.
Definition: indexidset.hh:466
Definition: identitygridindexsets.hh:26
bool contains(const EntityType &e) const
Return true if the given entity is contained in the index set.
Definition: identitygridindexsets.hh:70
int index(const typename GridImp::Traits::template Codim< codim >::Entity &e) const
get index of an entity
Definition: identitygridindexsets.hh:36
Types types(int codim) const
Deliver all geometry types used in this grid.
Definition: identitygridindexsets.hh:63
std::size_t size(GeometryType type) const
get number of entities of given codim, type and on this level
Definition: identitygridindexsets.hh:57
std::size_t size(int codim) const
get number of entities of given codim, type and on this level
Definition: identitygridindexsets.hh:51
int subIndex(const typename GridImp::Traits::template Codim< cc >::Entity &e, int i, int codim) const
get index of subEntity of a codim 0 entity
Definition: identitygridindexsets.hh:44
void update(const GridImp &grid, int level)
Set up the index set.
Definition: identitygridindexsets.hh:76
Index Set Interface base class.
Definition: indexidset.hh:78
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: indexidset.hh:153
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: indexidset.hh:113
Provides base classes for index and id sets.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)