dune-fem 2.8.0
Loading...
Searching...
No Matches
idgridpart/indexset.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_IDGRIDPART_INDEXSET_HH
2#define DUNE_FEM_GRIDPART_IDGRIDPART_INDEXSET_HH
3
4#include <type_traits>
5#include <vector>
6
7#include <dune/geometry/type.hh>
8
11
13
14namespace Dune
15{
16
17 namespace Fem
18 {
19
20 // Internal forward declaration
21 // ----------------------------
22
23 template< class GridFamily >
24 class IdIndexSet;
25
26
27
28 namespace __IdIndexSet
29 {
30
31 // IndexSet
32 // --------
33
34 template< class GridFamily >
36 {
37 protected:
38 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
39
40 public:
41 typedef typename Traits::HostGridPartType::IndexSetType HostIndexSetType;
42
43 static const int dimension = HostIndexSetType::dimension;
44
45 template< int codim >
46 struct Codim
47 {
48 typedef typename Traits::template Codim< codim >::Entity Entity;
49 };
50
51 typedef typename HostIndexSetType::IndexType IndexType;
52
53 typedef typename HostIndexSetType::Types Types;
54
56 : hostIndexSet_( hostIndexSet )
57 {}
58
59 Types types ( int codim ) const
60 {
61 return hostIndexSet().types( codim );
62 }
63
64 const std::vector< GeometryType > &geomTypes ( int codim ) const
65 {
66 return hostIndexSet().geomTypes( codim );
67 }
68
69 template< class Entity >
70 bool contains ( const Entity &entity ) const
71 {
72 return hostIndexSet().contains( entity.impl().hostEntity() );
73 }
74
75 IndexType size ( GeometryType type ) const
76 {
77 return hostIndexSet().size( type );
78 }
79
80 IndexType size ( int codim ) const
81 {
82 return hostIndexSet().size( codim );
83 }
84
85 template< class Entity >
86 IndexType index ( const Entity &entity ) const
87 {
88 return index< Entity::codimension >( entity );
89 }
90
91 template< int codim >
92 IndexType index ( const typename Codim< codim >::Entity &entity ) const
93 {
94 return hostIndexSet().template index< codim >( entity.impl().hostEntity() );
95 }
96
97 template< class Entity >
98 IndexType subIndex ( const Entity &entity, int i, unsigned int cd ) const
99 {
100 return subIndex< Entity::codimension >( entity, i, cd );
101 }
102
103 template< int codim >
104 IndexType subIndex ( const typename Codim< codim >::Entity &entity, int i, unsigned int cd ) const
105 {
106 return hostIndexSet().template subIndex< codim >( entity.impl().hostEntity(), i, cd );
107 }
108
110 {
111 return hostIndexSet_;
112 }
113
114 void requestCodimensions( const std::vector< int >& codimensions ) const
115 {
116 hostIndexSet().requestCodimensions( codimensions );
117 }
118
119 protected:
120 HostIndexSetType &hostIndexSet () { return const_cast< HostIndexSetType & >( hostIndexSet_); }
121
122 private:
123 const HostIndexSetType &hostIndexSet_;
124 };
125
126
127
128 // ConsecutiveIndexSet
129 // -------------------
130
131 template< class GridFamily >
133 : public IndexSet< GridFamily >
134 {
136
137 public:
139
141
144 {}
145
146 void resize () { hostIndexSet().resize(); }
147
148 bool compress () { return hostIndexSet().compress(); }
149
150 void insertEntity ( const typename BaseType::template Codim< 0 >::Entity &entity )
151 {
152 hostIndexSet().insertEntity( entity.impl().hostEntity() );
153 }
154
155 void removeEntity ( const typename BaseType::template Codim< 0 >::Entity &entity )
156 {
157 hostIndexSet().removeEntity( entity.impl().hostEntity() );
158 }
159
160 void backup () const { hostIndexSet().backup(); }
161
162 void restore () { hostIndexSet().restore(); }
163
164 template< class T >
166 {
167 hostIndexSet().write( stream );
168 }
169
170 template< class T >
172 {
173 hostIndexSet().read( stream );
174 }
175
176 protected:
178 {
179 return const_cast< HostIndexSetType & >( BaseType::hostIndexSet() );
180 }
181 };
182
183
184
185 // AdaptiveIndexSet
186 // ----------------
187
188 template< class GridFamily >
190 : public ConsecutiveIndexSet< GridFamily >
191 {
193
194 public:
197 {}
198
199 int numberOfHoles ( GeometryType type ) const
200 {
201 return this->hostIndexSet().numberOfHoles( type );
202 }
203
204 int numberOfHoles ( int codim ) const
205 {
206 return this->hostIndexSet().numberOfHoles( codim );
207 }
208
209 int oldIndex ( int hole, GeometryType type ) const
210 {
211 return this->hostIndexSet().oldIndex( hole, type );
212 }
213
214 int oldIndex ( int hole, int codim ) const
215 {
216 return this->hostIndexSet().oldIndex( hole, codim );
217 }
218
219 int newIndex ( int hole, GeometryType type ) const
220 {
221 return this->hostIndexSet().newIndex( hole, type );
222 }
223
224 int newIndex ( int hole, int codim ) const
225 {
226 return this->hostIndexSet().newIndex( hole, codim );
227 }
228 };
229
230
231
232 // Implementation
233 // --------------
234
235 template< class GridFamily,
236 class HostIndexSet = typename std::remove_const< GridFamily >::type::Traits::HostGridPartType::IndexSetType,
240 {
241 typedef typename std::conditional< adaptive,
243 typename std::conditional< consecutive,
246 >::type
247 >::type Type;
248 };
249
250 } // namespace __IdIndexSet
251
252
253
254 // IdIndexSet
255 // ----------
256
257 template< class GridFamily >
259 : public __IdIndexSet::Implementation< GridFamily >::Type
260 {
262
263 friend struct Capabilities::isPersistentIndexSet< IdIndexSet< GridFamily > >;
264
265 public:
266 explicit IdIndexSet ( const typename BaseType::HostIndexSetType &hostIndexSet )
267 : BaseType ( hostIndexSet )
268 {}
269 };
270
271
272
273 namespace Capabilities
274 {
275
276 template< class GridFamily >
277 struct isConsecutiveIndexSet< IdIndexSet< GridFamily > >
278 : public isConsecutiveIndexSet< typename IdIndexSet< GridFamily >::HostIndexSetType >
279 {};
280
281 template< class GridFamily >
282 struct isAdaptiveIndexSet< IdIndexSet< GridFamily > >
283 : public isAdaptiveIndexSet< typename IdIndexSet< GridFamily >::HostIndexSetType >
284 {};
285
286 template< class GridFamily >
287 struct isPersistentIndexSet< IdIndexSet< GridFamily > >
288 {
289 private:
291 typedef typename IndexSetType::HostIndexSetType HostIndexSetType;
292
293 public:
295
296 static constexpr PersistentIndexSetInterface *map ( IndexSetType &indexSet ) noexcept
297 {
298 return isPersistentIndexSet< HostIndexSetType >::map( indexSet.hostIndexSet() );
299 }
300 };
301
302 } // namespace Capabilities
303
304 } // namespace Fem
305
306} // namespace Dune
307
308#endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_INDEXSET_HH
Definition: bindguard.hh:11
specialize with true if index set implements the interface for consecutive index sets
Definition: common/indexset.hh:42
specialize with true if index set implements the interface for adaptive index sets
Definition: common/indexset.hh:64
virtual base class for persistent index sets
Definition: persistentindexset.hh:35
capability for persistent index sets
Definition: persistentindexset.hh:92
static constexpr PersistentIndexSetInterface * map(IndexSet &indexSet) noexcept
please doc me
Definition: persistentindexset.hh:101
static const bool v
please doc me
Definition: persistentindexset.hh:98
Definition: idgridpart/indexset.hh:260
IdIndexSet(const typename BaseType::HostIndexSetType &hostIndexSet)
Definition: idgridpart/indexset.hh:266
Definition: idgridpart/indexset.hh:36
IndexSet(const HostIndexSetType &hostIndexSet)
Definition: idgridpart/indexset.hh:55
IndexType size(GeometryType type) const
Definition: idgridpart/indexset.hh:75
Traits::HostGridPartType::IndexSetType HostIndexSetType
Definition: idgridpart/indexset.hh:41
IndexType subIndex(const Entity &entity, int i, unsigned int cd) const
Definition: idgridpart/indexset.hh:98
static const int dimension
Definition: idgridpart/indexset.hh:43
HostIndexSetType & hostIndexSet()
Definition: idgridpart/indexset.hh:120
IndexType index(const Entity &entity) const
Definition: idgridpart/indexset.hh:86
std::remove_const< GridFamily >::type::Traits Traits
Definition: idgridpart/indexset.hh:38
HostIndexSetType::Types Types
Definition: idgridpart/indexset.hh:53
IndexType size(int codim) const
Definition: idgridpart/indexset.hh:80
void requestCodimensions(const std::vector< int > &codimensions) const
Definition: idgridpart/indexset.hh:114
Types types(int codim) const
Definition: idgridpart/indexset.hh:59
bool contains(const Entity &entity) const
Definition: idgridpart/indexset.hh:70
const std::vector< GeometryType > & geomTypes(int codim) const
Definition: idgridpart/indexset.hh:64
IndexType index(const typename Codim< codim >::Entity &entity) const
Definition: idgridpart/indexset.hh:92
HostIndexSetType::IndexType IndexType
Definition: idgridpart/indexset.hh:51
IndexType subIndex(const typename Codim< codim >::Entity &entity, int i, unsigned int cd) const
Definition: idgridpart/indexset.hh:104
const HostIndexSetType & hostIndexSet() const
Definition: idgridpart/indexset.hh:109
Definition: idgridpart/indexset.hh:47
Traits::template Codim< codim >::Entity Entity
Definition: idgridpart/indexset.hh:48
Definition: idgridpart/indexset.hh:134
ConsecutiveIndexSet(const HostIndexSetType &hostIndexSet)
Definition: idgridpart/indexset.hh:142
void removeEntity(const typename BaseType::template Codim< 0 >::Entity &entity)
Definition: idgridpart/indexset.hh:155
BaseType::HostIndexSetType HostIndexSetType
Definition: idgridpart/indexset.hh:138
void backup() const
Definition: idgridpart/indexset.hh:160
HostIndexSetType & hostIndexSet()
Definition: idgridpart/indexset.hh:177
void read(InStreamInterface< T > &stream)
Definition: idgridpart/indexset.hh:171
void insertEntity(const typename BaseType::template Codim< 0 >::Entity &entity)
Definition: idgridpart/indexset.hh:150
void restore()
Definition: idgridpart/indexset.hh:162
bool compress()
Definition: idgridpart/indexset.hh:148
void write(OutStreamInterface< T > &stream)
Definition: idgridpart/indexset.hh:165
void resize()
Definition: idgridpart/indexset.hh:146
Definition: idgridpart/indexset.hh:191
AdaptiveIndexSet(const typename BaseType::HostIndexSetType &hostIndexSet)
Definition: idgridpart/indexset.hh:195
int oldIndex(int hole, GeometryType type) const
Definition: idgridpart/indexset.hh:209
int newIndex(int hole, int codim) const
Definition: idgridpart/indexset.hh:224
int numberOfHoles(int codim) const
Definition: idgridpart/indexset.hh:204
int newIndex(int hole, GeometryType type) const
Definition: idgridpart/indexset.hh:219
int numberOfHoles(GeometryType type) const
Definition: idgridpart/indexset.hh:199
int oldIndex(int hole, int codim) const
Definition: idgridpart/indexset.hh:214
Definition: idgridpart/indexset.hh:240
std::conditional< adaptive, AdaptiveIndexSet< GridFamily >, typenamestd::conditional< consecutive, ConsecutiveIndexSet< GridFamily >, IndexSet< GridFamily > >::type >::type Type
Definition: idgridpart/indexset.hh:247
static constexpr PersistentIndexSetInterface * map(IndexSetType &indexSet) noexcept
Definition: idgridpart/indexset.hh:296
abstract interface for an output stream
Definition: streams.hh:46
abstract interface for an input stream
Definition: streams.hh:179