dune-grid 2.10
Loading...
Searching...
No Matches
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>
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>
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>
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
Include standard header files.
Definition agrid.hh:60
Index Set Interface base class.
Definition common/indexidset.hh:78
Id Set Interface.
Definition common/indexidset.hh:447
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
GridImp * grid_
Definition identitygridindexsets.hh:83
std::remove_const< GridImp >::type::HostGridType HostGrid
Definition identitygridindexsets.hh:29
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
static constexpr int dim
Definition identitygridindexsets.hh:32
HostGrid::LevelGridView::IndexSet::Types Types
Definition identitygridindexsets.hh:30
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
int level_
Definition identitygridindexsets.hh:85
void update(const GridImp &grid, int level)
Set up the index set.
Definition identitygridindexsets.hh:76
Definition identitygridindexsets.hh:96
IdentityGridLeafIndexSet(const GridImp &grid)
constructor stores reference to a grid and level
Definition identitygridindexsets.hh:111
static constexpr int dim
Definition identitygridindexsets.hh:107
std::size_t size(int codim) const
get number of entities of given codim
Definition identitygridindexsets.hh:148
bool contains(const EntityType &e) const
Return true if the given entity is contained in the index set.
Definition identitygridindexsets.hh:161
std::size_t size(GeometryType type) const
get number of entities of given type
Definition identitygridindexsets.hh:141
HostGrid::LevelGridView::IndexSet::Types Types
Definition identitygridindexsets.hh:101
int index(const typename std::remove_const< GridImp >::type::template Codim< codim >::Entity &e) const
get index of an entity
Definition identitygridindexsets.hh:122
int subIndex(const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e, int i, int codim) const
get index of subEntity of a codim 0 entity
Definition identitygridindexsets.hh:134
Types types(int codim) const
Deliver all geometry types used in this grid.
Definition identitygridindexsets.hh:154
GridImp * grid_
Definition identitygridindexsets.hh:175
void update(const GridImp &grid)
Definition identitygridindexsets.hh:169
Definition identitygridindexsets.hh:185
IdentityGridGlobalIdSet(const GridImp &g)
constructor stores reference to a grid
Definition identitygridindexsets.hh:192
void update()
Definition identitygridindexsets.hh:224
const GridImp * grid_
Definition identitygridindexsets.hh:227
HostGrid::Traits::GlobalIdSet::IdType IdType
define the type used for persistent indices
Definition identitygridindexsets.hh:195
IdType subId(const typename std::remove_const< GridImp >::type::Traits::template Codim< 0 >::Entity &e, int i, int codim) const
get id of subEntity
Definition identitygridindexsets.hh:216
IdType id(const typename std::remove_const< GridImp >::type::Traits::template Codim< cd >::Entity &e) const
get id of an entity
Definition identitygridindexsets.hh:204
Definition identitygridindexsets.hh:237
IdType subId(const typename std::remove_const< GridImp >::type::template Codim< 0 >::Entity &e, int i, int codim) const
get id of subEntity
Definition identitygridindexsets.hh:270
IdentityGridLocalIdSet(const GridImp &g)
constructor stores reference to a grid
Definition identitygridindexsets.hh:249
const GridImp * grid_
Definition identitygridindexsets.hh:281
void update()
Definition identitygridindexsets.hh:278
IdType id(const typename std::remove_const< GridImp >::type::Traits::template Codim< cd >::Entity &e) const
get id of an entity
Definition identitygridindexsets.hh:258
HostGrid::Traits::LocalIdSet::IdType IdType
define the type used for persistent local ids
Definition identitygridindexsets.hh:245
Provides base classes for index and id sets.