DUNE-FEM (unstable)

indexset.hh
1#ifndef DUNE_FEM_GRIDPART_COMMON_INDEXSET_HH
2#define DUNE_FEM_GRIDPART_COMMON_INDEXSET_HH
3
4#include <type_traits>
5#include <utility>
6#include <vector>
7
9
10#include <dune/fem/io/streams/streams.hh>
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 // Internal forward declaration
19 // ----------------------------
20 template< class Traits >
21 class IndexSet;
22 template< class Traits >
23 class ConsecutiveIndexSet;
24 template< class Traits >
25 class AdaptiveIndexSet;
26
27
28 namespace Capabilities
29 {
30
37 template< class IndexSet >
39 {
40 template< class Traits >
41 static std::true_type __isDuneFemIndexSet ( const Dune::Fem::IndexSet< Traits > & );
42
43 static std::false_type __isDuneFemIndexSet ( ... );
44
45 public:
46 static const bool v = decltype( __isDuneFemIndexSet( std::declval< IndexSet >() ) )::value;
47 };
48
49
50 // isConsecutiveIndexSet
51 // ---------------------
52
59 template< class IndexSet >
61 {
62 template< class Traits >
63 static std::true_type __isConsecutive ( const ConsecutiveIndexSet< Traits > & );
64
65 static std::false_type __isConsecutive ( ... );
66
67 public:
68 static const bool v = decltype( __isConsecutive( std::declval< IndexSet >() ) )::value;
69 };
70
71
72 // isAdaptiveIndexSet
73 // ------------------
74
81 template< class IndexSet >
83 {
84 template< class Traits >
85 static std::true_type __isAdaptive ( const AdaptiveIndexSet< Traits > & );
86
87 static std::false_type __isAdaptive ( ... );
88
89 public:
90 static const bool v = decltype( __isAdaptive( std::declval< IndexSet >() ) )::value;
91 };
92
93
94
95#ifndef DOXYGEN
96
97 template< class IndexSet >
98 struct isConsecutiveIndexSet< const IndexSet >
99 : public isConsecutiveIndexSet< IndexSet >
100 {};
101
102 template< class IndexSet >
103 struct isAdaptiveIndexSet< const IndexSet >
104 : public isAdaptiveIndexSet< IndexSet >
105 {};
106
107#endif // #ifndef DOXYGEN
108
109 } // namespace Capabilites
110
111
112
113 // IndexSet
114 // --------
115
121 template< class Traits >
123 {
124 public:
126 static const int dimension = Traits::dimension;
127
128 template< int codim >
129 struct Codim
130 {
132 typedef typename Traits::template Codim< codim >::Entity Entity;
133 };
134
136 typedef typename Traits::IndexType IndexType;
137
139 typedef typename Traits::Types Types;
140
141 protected:
142 IndexSet () = default;
143
144 public:
146 Types types ( int codim ) const
147 {
148 return impl().types( codim );
149 }
150
152 template< class Entity >
153 bool contains ( const Entity &entity ) const
154 {
155 return impl().contains( entity );
156 }
157
160 {
161 return impl().size( type );
162 }
163
165 IndexType size ( int codim ) const
166 {
167 return impl().size( codim );
168 }
169
171 template< class Entity >
172 IndexType index ( const Entity &entity ) const
173 {
174 return index< Entity::codimension >( entity );
175 }
176
178 template< int codim >
179 IndexType index ( const typename Codim< codim >::Entity &entity ) const
180 {
181 return impl().template index< codim >( entity );
182 }
183
185 template< class Entity >
186 IndexType subIndex ( const Entity &entity, int i, unsigned int cd ) const
187 {
188 return subIndex< Entity::codimension >( entity, i, cd );
189 }
190
192 template< int codim >
193 IndexType subIndex ( const typename Codim< codim >::Entity &entity, int i, unsigned int cd ) const
194 {
195 return impl().template subIndex< codim >( entity, i, cd );
196 }
197
199 void requestCodimensions ( const std::vector< int >& codimensions ) const
200 {
201 }
202
203 protected:
204 const typename Traits::IndexSetType &impl () const
205 {
206 return static_cast< const typename Traits::IndexSetType & >( *this );
207 }
208 };
209
210 // ConsecutiveIndexSet
211 // -------------------
212
218 template< class Traits >
220 : public IndexSet< Traits >
221 {
223
224 protected:
225 using BaseType::impl;
226
227 ConsecutiveIndexSet () = default;
228
229 public:
235 void resize () { impl().resize(); }
236
238 bool compress () { return impl().compress(); }
239
241 void insertEntity ( const typename BaseType::template Codim< 0 >::Entity &entity )
242 {
243 impl().insertEntity( entity );
244 }
245
247 void removeEntity ( const typename BaseType::template Codim< 0 >::Entity &entity )
248 {
249 impl().removeEntity( entity );
250 }
251
253 void backup () const { impl().backup(); }
254
256 void restore () { impl().restore(); }
257
259 template< class T >
260 void write ( OutStreamInterface< T > &stream ) const
261 {
262 impl().write( stream );
263 }
264
266 template< class T >
268 {
269 impl().read( stream );
270 }
271
274 protected:
275 typename Traits::IndexSetType &impl ()
276 {
277 const typename Traits::IndexSetType &impl = BaseType::impl();
278 return const_cast< typename Traits::IndexSetType & >( impl );
279 }
280 };
281
282
283
284 // AdaptiveIndexSet
285 // ----------------
286
292 template< class Traits >
294 : public ConsecutiveIndexSet< Traits >
295 {
297
298 protected:
299 using BaseType::impl;
300
301 AdaptiveIndexSet () = default;
302
303 public:
309 int numberOfHoles ( GeometryType type ) const
310 {
311 return impl().numberOfHoles( type );
312 }
313
315 int oldIndex ( int hole, GeometryType type ) const
316 {
317 return impl().oldIndex( hole, type );
318 }
319
321 int newIndex ( int hole, GeometryType type ) const
322 {
323 return impl().newIndex( hole, type );
324 }
325
328 };
329
330 } // namespace Fem
331
332} // namespace Dune
333
334#endif // #ifndef DUNE_FEM_GRIDPART_COMMON_INDEXSET_HH
Wrapper class for entities.
Definition: entity.hh:66
extended interface for adaptive, consecutive index sets
Definition: indexset.hh:295
int numberOfHoles(GeometryType type) const
return number of holes for given type
Definition: indexset.hh:309
int oldIndex(int hole, GeometryType type) const
return old index for given hole and type
Definition: indexset.hh:315
int newIndex(int hole, GeometryType type) const
return new index for given hole and type
Definition: indexset.hh:321
specialize with true if index set implements the interface for adaptive index sets
Definition: indexset.hh:83
extended interface for consecutive index sets
Definition: indexset.hh:221
void write(OutStreamInterface< T > &stream) const
please doc me
Definition: indexset.hh:260
bool compress()
please doc me
Definition: indexset.hh:238
void backup() const
please doc me
Definition: indexset.hh:253
void resize()
please doc me
Definition: indexset.hh:235
void insertEntity(const typename BaseType::template Codim< 0 >::Entity &entity)
please doc me
Definition: indexset.hh:241
void removeEntity(const typename BaseType::template Codim< 0 >::Entity &entity)
please doc me
Definition: indexset.hh:247
void restore()
please doc me
Definition: indexset.hh:256
void read(InStreamInterface< T > &stream)
please doc me
Definition: indexset.hh:267
abstract interface for an input stream
Definition: streams.hh:190
interface documentation for (grid part) index sets
Definition: indexset.hh:123
IndexType subIndex(const typename Codim< codim >::Entity &entity, int i, unsigned int cd) const
return index for given subentity
Definition: indexset.hh:193
IndexType index(const typename Codim< codim >::Entity &entity) const
return index for given entity
Definition: indexset.hh:179
Traits::Types Types
geometry type range type
Definition: indexset.hh:139
bool contains(const Entity &entity) const
return true if entity has index
Definition: indexset.hh:153
void requestCodimensions(const std::vector< int > &codimensions) const
receive request for codimension support in case index set is adaptive
Definition: indexset.hh:199
IndexType size(GeometryType type) const
return number of entities of given type
Definition: indexset.hh:159
IndexType subIndex(const Entity &entity, int i, unsigned int cd) const
return index for given subentity
Definition: indexset.hh:186
Types types(int codim) const
return range of geometry types
Definition: indexset.hh:146
IndexType size(int codim) const
return number of entities of given codimension
Definition: indexset.hh:165
IndexType index(const Entity &entity) const
return index for given entity
Definition: indexset.hh:172
static const int dimension
grid dimension
Definition: indexset.hh:126
Traits::IndexType IndexType
index type
Definition: indexset.hh:136
abstract interface for an output stream
Definition: streams.hh:48
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Dune namespace.
Definition: alignedallocator.hh:13
specialize with true if index set implements the interface for consecutive index sets
Definition: indexset.hh:61
specialize with true if index set implements the dune-fem interface for index sets
Definition: indexset.hh:39
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)