Dune Core Modules (2.6.0)

identitygridindexsets.hh
Go to the documentation of this file.
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_IDENTITYGRID_INDEXSETS_HH
4#define DUNE_IDENTITYGRID_INDEXSETS_HH
5
11
12#include <vector>
13
14namespace Dune {
15
17 template<class GridImp>
19 public IndexSet<GridImp,
20 IdentityGridLevelIndexSet<GridImp>,
21 typename std::remove_const<GridImp>::type::HostGridType::LevelGridView::IndexSet::IndexType,
22 typename std::remove_const<GridImp>::type::HostGridType::LevelGridView::IndexSet::Types
23 >
24 {
25 public:
26
27 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
28 typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
29
30 enum {dim = GridImp::dimension};
31
33 template<int codim>
34 int index (const typename GridImp::Traits::template Codim<codim>::Entity& e) const
35 {
36 return grid_->hostgrid_->levelIndexSet(level_).template index<codim>(grid_->template getHostEntity<codim>(e));
37 }
38
39
41 template<int cc>
42 int subIndex (const typename GridImp::Traits::template Codim<cc>::Entity& e, int i, int codim) const
43 {
44 return grid_->hostgrid_->levelIndexSet(level_).subIndex(grid_->template getHostEntity<cc>(e), i, codim);
45 }
46
47
49 int size (int codim) const {
50 return grid_->hostgrid_->levelIndexSet(level_).size(codim);
51 }
52
53
55 int size (GeometryType type) const
56 {
57 return grid_->hostgrid_->levelIndexSet(level_).size(type);
58 }
59
60
62 const std::vector<GeometryType>& geomTypes (int codim) const
63 {
64 return grid_->hostgrid_->levelIndexSet(level_).geomTypes(codim);
65 }
66
68 Types types (int codim) const
69 {
70 return grid_->hostgrid_->levelIndexSet(level_).types(codim);
71 }
72
74 template<class EntityType>
75 bool contains (const EntityType& e) const
76 {
77 return grid_->hostgrid_->levelIndexSet(level_).contains(grid_->template getHostEntity<EntityType::codimension>(e));
78 }
79
81 void update(const GridImp& grid, int level)
82 {
83 grid_ = &grid;
84 level_ = level;
85 }
86
87
88 GridImp* grid_;
89
90 int level_;
91 };
92
93
94 template<class GridImp>
95 class IdentityGridLeafIndexSet :
96 public IndexSet<GridImp,
97 IdentityGridLeafIndexSet<GridImp>,
98 typename std::remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::IndexType,
99 typename std::remove_const<GridImp>::type::HostGridType::LeafGridView::IndexSet::Types
100 >
101 {
102 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
103
104 public:
105
106 typedef typename HostGrid::LevelGridView::IndexSet::Types Types;
107
108 /*
109 * We use the remove_const to extract the Type from the mutable class,
110 * because the const class is not instantiated yet.
111 */
112 enum {dim = std::remove_const<GridImp>::type::dimension};
113
114
116 IdentityGridLeafIndexSet (const GridImp& grid)
117 : grid_(&grid)
118 {}
119
120
122 /*
123 We use the RemoveConst to extract the Type from the mutable class,
124 because the const class is not instantiated yet.
125 */
126 template<int codim>
127 int index (const typename std::remove_const<GridImp>::type::template Codim<codim>::Entity& e) const
128 {
129 return grid_->hostgrid_->leafIndexSet().template index<codim>(grid_->template getHostEntity<codim>(e));
130 }
131
132
134 /*
135 We use the RemoveConst to extract the Type from the mutable class,
136 because the const class is not instantiated yet.
137 */
138 template<int cc>
139 int subIndex (const typename std::remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e, int i, int codim) const
140 {
141 return grid_->hostgrid_->leafIndexSet().subIndex(grid_->template getHostEntity<cc>(e),i, codim);
142 }
143
144
146 int size (GeometryType type) const
147 {
148 return grid_->hostgrid_->leafIndexSet().size(type);
149 }
150
151
153 int size (int codim) const
154 {
155 return grid_->hostgrid_->leafIndexSet().size(codim);
156 }
157
158
160 const std::vector<GeometryType>& geomTypes (int codim) const
161 {
162 return grid_->hostgrid_->leafIndexSet().geomTypes(codim);
163 }
164
166 Types types (int codim) const
167 {
168 return grid_->hostgrid_->leafIndexSet().types(codim);
169 }
170
172 template<class EntityType>
173 bool contains (const EntityType& e) const
174 {
175 return grid_->hostgrid_->leafIndexSet().contains(grid_->template getHostEntity<EntityType::codimension>(e));
176 }
177
178
179
181 void update(const GridImp& grid)
182 {
183 grid_ = &grid;
184 }
185
186
187 GridImp* grid_;
188 };
189
190
191
192
193 template <class GridImp>
194 class IdentityGridGlobalIdSet :
195 public IdSet<GridImp,IdentityGridGlobalIdSet<GridImp>,
196 typename std::remove_const<GridImp>::type::HostGridType::Traits::GlobalIdSet::IdType>
197 {
198
199 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
200
201
202 public:
204 IdentityGridGlobalIdSet (const GridImp& g) : grid_(&g) {}
205
207 typedef typename HostGrid::Traits::GlobalIdSet::IdType IdType;
208
209
211 /*
212 We use the remove_const to extract the Type from the mutable class,
213 because the const class is not instantiated yet.
214 */
215 template<int cd>
216 IdType id (const typename std::remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
217 {
218 // Return id of the host entity
219 return grid_->hostgrid_->globalIdSet().id(grid_->getRealImplementation(e).hostEntity_);
220 }
221
222
224 /*
225 We use the remove_const to extract the Type from the mutable class,
226 because the const class is not instantiated yet.
227 */
228 IdType subId (const typename std::remove_const<GridImp>::type::Traits::template Codim<0>::Entity& e, int i, int codim) const
229 {
230 // Return sub id of the host entity
231 return grid_->hostgrid_->globalIdSet().subId(grid_->getRealImplementation(e).hostEntity_,i, codim);
232 }
233
234
236 void update() {}
237
238
239 const GridImp* grid_;
240 };
241
242
243
244
245 template<class GridImp>
246 class IdentityGridLocalIdSet :
247 public IdSet<GridImp,IdentityGridLocalIdSet<GridImp>,
248 typename std::remove_const<GridImp>::type::HostGridType::Traits::LocalIdSet::IdType>
249 {
250 private:
251
252 typedef typename std::remove_const<GridImp>::type::HostGridType HostGrid;
253
254
255 public:
257 typedef typename HostGrid::Traits::LocalIdSet::IdType IdType;
258
259
261 IdentityGridLocalIdSet (const GridImp& g) : grid_(&g) {}
262
263
265 /*
266 We use the remove_const to extract the Type from the mutable class,
267 because the const class is not instantiated yet.
268 */
269 template<int cd>
270 IdType id (const typename std::remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
271 {
272 // Return id of the host entity
273 return grid_->hostgrid_->localIdSet().id(grid_->getRealImplementation(e).hostEntity_);
274 }
275
276
278 /*
279 * We use the remove_const to extract the Type from the mutable class,
280 * because the const class is not instantiated yet.
281 */
282 IdType subId (const typename std::remove_const<GridImp>::type::template Codim<0>::Entity& e, int i, int codim) const
283 {
284 // Return sub id of the host entity
285 return grid_->hostgrid_->localIdSet().subId(grid_->getRealImplementation(e).hostEntity_,i,codim);
286 }
287
288
290 void update() {}
291
292
293 const GridImp* grid_;
294 };
295
296
297} // namespace Dune
298
299
300#endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
IdType subId(const typename std::remove_const< GridImp >::type::Traits::template 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:468
IdType id(const Entity &e) const
Get id of an entity. This method is simpler to use than the one below.
Definition: indexidset.hh:448
Definition: identitygridindexsets.hh:24
bool contains(const EntityType &e) const
Return true if the given entity is contained in the index set.
Definition: identitygridindexsets.hh:75
int index(const typename GridImp::Traits::template Codim< codim >::Entity &e) const
get index of an entity
Definition: identitygridindexsets.hh:34
int size(int codim) const
get number of entities of given codim, type and on this level
Definition: identitygridindexsets.hh:49
int size(GeometryType type) const
get number of entities of given codim, type and on this level
Definition: identitygridindexsets.hh:55
const std::vector< GeometryType > & geomTypes(int codim) const
Deliver all geometry types used in this grid.
Definition: identitygridindexsets.hh:62
Types types(int codim) const
Deliver all geometry types used in this grid.
Definition: identitygridindexsets.hh:68
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:42
void update(const GridImp &grid, int level)
Set up the index set.
Definition: identitygridindexsets.hh:81
Index Set Interface base class.
Definition: indexidset.hh:76
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:151
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:111
Provides base classes for index and id sets.
Dune namespace.
Definition: alignedallocator.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)