Dune Core Modules (2.9.1)

identitygridindexsets.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 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
62
64 const std::vector<GeometryType>& geomTypes (int codim) const
65 {
66 return grid_->hostgrid_->levelIndexSet(level_).geomTypes(codim);
67 }
68
70 Types types (int codim) const
71 {
72 return grid_->hostgrid_->levelIndexSet(level_).types(codim);
73 }
74
76 template<class EntityType>
77 bool contains (const EntityType& e) const
78 {
79 return grid_->hostgrid_->levelIndexSet(level_).contains(grid_->template getHostEntity<EntityType::codimension>(e));
80 }
81
83 void update(const GridImp& grid, int level)
84 {
85 grid_ = &grid;
86 level_ = level;
87 }
88
89
90 GridImp* grid_;
91
92 int level_;
93 };
94
95
96 template<class GridImp>
97 class IdentityGridLeafIndexSet :
98 public IndexSet<GridImp,
99 IdentityGridLeafIndexSet<GridImp>,
100 typename std::remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::IndexType,
101 typename std::remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::Types
102 >
103 {
104 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
105
106 public:
107
108 typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
109
110 /*
111 * We use the remove_const to extract the Type from the mutable class,
112 * because the const class is not instantiated yet.
113 */
114 constexpr static int dim = std::remove_const<GridImp>::type::dimension;
115
116
118 IdentityGridLeafIndexSet (const GridImp& grid)
119 : grid_(&grid)
120 {}
121
122
124 /*
125 We use the RemoveConst to extract the Type from the mutable class,
126 because the const class is not instantiated yet.
127 */
128 template<int codim>
129 int index (const typename std::remove_const<GridImp>::type::template Codim<codim>::Entity& e) const
130 {
131 return grid_->hostgrid_->leafIndexSet().template index<codim>(grid_->template getHostEntity<codim>(e));
132 }
133
134
136 /*
137 We use the RemoveConst to extract the Type from the mutable class,
138 because the const class is not instantiated yet.
139 */
140 template<int cc>
141 int subIndex (const typename std::remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e, int i, int codim) const
142 {
143 return grid_->hostgrid_->leafIndexSet().subIndex(grid_->template getHostEntity<cc>(e),i, codim);
144 }
145
146
148 std::size_t size (GeometryType type) const
149 {
150 return grid_->hostgrid_->leafIndexSet().size(type);
151 }
152
153
155 std::size_t size (int codim) const
156 {
157 return grid_->hostgrid_->leafIndexSet().size(codim);
158 }
159
160
162 const std::vector<GeometryType>& geomTypes (int codim) const
163 {
164 return grid_->hostgrid_->leafIndexSet().geomTypes(codim);
165 }
166
168 Types types (int codim) const
169 {
170 return grid_->hostgrid_->leafIndexSet().types(codim);
171 }
172
174 template<class EntityType>
175 bool contains (const EntityType& e) const
176 {
177 return grid_->hostgrid_->leafIndexSet().contains(grid_->template getHostEntity<EntityType::codimension>(e));
178 }
179
180
181
183 void update(const GridImp& grid)
184 {
185 grid_ = &grid;
186 }
187
188
189 GridImp* grid_;
190 };
191
192
193
194
195 template <class GridImp>
196 class IdentityGridGlobalIdSet :
197 public IdSet<GridImp,IdentityGridGlobalIdSet<GridImp>,
198 typename std::remove_const<GridImp>::type::HostGridType::Traits::GlobalIdSet::IdType>
199 {
200
201 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
202
203
204 public:
206 IdentityGridGlobalIdSet (const GridImp& g) : grid_(&g) {}
207
209 typedef typename HostGrid::Traits::GlobalIdSet::IdType IdType;
210
211
213 /*
214 We use the remove_const to extract the Type from the mutable class,
215 because the const class is not instantiated yet.
216 */
217 template<int cd>
218 IdType id (const typename std::remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
219 {
220 // Return id of the host entity
221 return grid_->hostgrid_->globalIdSet().id(e.impl().hostEntity_);
222 }
223
224
226 /*
227 We use the remove_const to extract the Type from the mutable class,
228 because the const class is not instantiated yet.
229 */
230 IdType subId (const typename std::remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i, int codim) const
231 {
232 // Return sub id of the host entity
233 return grid_->hostgrid_->globalIdSet().subId(e.impl().hostEntity_,i, codim);
234 }
235
236
238 void update() {}
239
240
241 const GridImp* grid_;
242 };
243
244
245
246
247 template<class GridImp>
248 class IdentityGridLocalIdSet :
249 public IdSet<GridImp,IdentityGridLocalIdSet<GridImp>,
250 typename std::remove_const<GridImp>::type::HostGridType::Traits::LocalIdSet::IdType>
251 {
252 private:
253
254 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
255
256
257 public:
259 typedef typename HostGrid::Traits::LocalIdSet::IdType IdType;
260
261
263 IdentityGridLocalIdSet (const GridImp& g) : grid_(&g) {}
264
265
267 /*
268 We use the remove_const to extract the Type from the mutable class,
269 because the const class is not instantiated yet.
270 */
271 template<int cd>
272 IdType id (const typename std::remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
273 {
274 // Return id of the host entity
275 return grid_->hostgrid_->localIdSet().id(e.impl().hostEntity_);
276 }
277
278
280 /*
281 * We use the remove_const to extract the Type from the mutable class,
282 * because the const class is not instantiated yet.
283 */
284 IdType subId (const typename std::remove_const<GridImp>::type::template Codim<0>::Entity& e, int i, int codim) const
285 {
286 // Return sub id of the host entity
287 return grid_->hostgrid_->localIdSet().subId(e.impl().hostEntity_,i,codim);
288 }
289
290
292 void update() {}
293
294
295 const GridImp* grid_;
296 };
297
298
299} // namespace Dune
300
301
302#endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:126
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:486
IdType id(const Entity &e) const
Get id of an entity. This method is simpler to use than the one below.
Definition: indexidset.hh:471
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:77
int index(const typename GridImp::Traits::template Codim< codim >::Entity &e) const
get index of an entity
Definition: identitygridindexsets.hh:36
const std::vector< GeometryType > & geomTypes(int codim) const
Deliver all geometry types used in this grid.
Definition: identitygridindexsets.hh:64
Types types(int codim) const
Deliver all geometry types used in this grid.
Definition: identitygridindexsets.hh:70
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:83
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
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)