1#ifndef DUNE_FEM_GRIDPART_IDGRIDPART_INDEXSET_HH
2#define DUNE_FEM_GRIDPART_IDGRIDPART_INDEXSET_HH
9#include <dune/fem/gridpart/common/indexset.hh>
10#include <dune/fem/gridpart/common/persistentindexset.hh>
12#include <dune/fem/io/streams/streams.hh>
23 template<
class Gr
idFamily >
28 namespace __IdIndexSet
34 template<
class Gr
idFamily >
38 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
41 typedef typename Traits::HostGridPartType::IndexSetType HostIndexSetType;
43 static const int dimension = HostIndexSetType::dimension;
48 typedef typename Traits::template Codim< codim >::Entity Entity;
51 typedef typename HostIndexSetType::IndexType IndexType;
53 typedef typename HostIndexSetType::Types Types;
55 explicit IndexSet (
const HostIndexSetType &hostIndexSet )
56 : hostIndexSet_( &hostIndexSet )
59 Types types (
int codim )
const
61 return hostIndexSet().types( codim );
64 const std::vector< GeometryType > &geomTypes (
int codim )
const
66 return hostIndexSet().geomTypes( codim );
69 template<
class Entity >
70 bool contains (
const Entity &entity )
const
72 return hostIndexSet().contains( entity.impl().hostEntity() );
75 IndexType
size ( GeometryType type )
const
77 return hostIndexSet().size( type );
80 IndexType
size (
int codim )
const
82 return hostIndexSet().size( codim );
85 template<
class Entity >
86 IndexType index (
const Entity &entity )
const
88 return index< Entity::codimension >( entity );
92 IndexType index (
const typename Codim< codim >::Entity &entity )
const
94 return hostIndexSet().template index< codim >( entity.impl().hostEntity() );
97 template<
class Entity >
98 IndexType subIndex (
const Entity &entity,
int i,
unsigned int cd )
const
100 return subIndex< Entity::codimension >( entity, i, cd );
103 template<
int codim >
104 IndexType subIndex (
const typename Codim< codim >::Entity &entity,
int i,
unsigned int cd )
const
106 return hostIndexSet().template subIndex< codim >( entity.impl().hostEntity(), i, cd );
109 const HostIndexSetType &hostIndexSet ()
const
111 assert( hostIndexSet_ );
112 return *hostIndexSet_;
115 void requestCodimensions(
const std::vector< int >& codimensions )
const
117 hostIndexSet().requestCodimensions( codimensions );
121 HostIndexSetType &hostIndexSet ()
123 assert( hostIndexSet_ );
124 return const_cast< HostIndexSetType &
>(*hostIndexSet_);
127 const HostIndexSetType *hostIndexSet_;
135 template<
class Gr
idFamily >
136 class ConsecutiveIndexSet
137 :
public IndexSet< GridFamily >
139 typedef IndexSet< GridFamily > BaseType;
142 typedef typename BaseType::HostIndexSetType HostIndexSetType;
144 using BaseType::hostIndexSet;
146 explicit ConsecutiveIndexSet (
const HostIndexSetType &hostIndexSet )
147 : BaseType ( hostIndexSet )
150 void resize () { hostIndexSet().resize(); }
152 bool compress () {
return hostIndexSet().compress(); }
154 void insertEntity (
const typename BaseType::template Codim< 0 >::Entity &entity )
156 hostIndexSet().insertEntity( entity.impl().hostEntity() );
159 void removeEntity (
const typename BaseType::template Codim< 0 >::Entity &entity )
161 hostIndexSet().removeEntity( entity.impl().hostEntity() );
164 void backup ()
const { hostIndexSet().backup(); }
166 void restore () { hostIndexSet().restore(); }
169 void write ( OutStreamInterface< T > &stream )
171 hostIndexSet().write( stream );
175 void read ( InStreamInterface< T > &stream )
177 hostIndexSet().read( stream );
181 HostIndexSetType &hostIndexSet ()
183 return const_cast< HostIndexSetType&
>( BaseType::hostIndexSet() );
192 template<
class Gr
idFamily >
193 class AdaptiveIndexSet
194 :
public ConsecutiveIndexSet< GridFamily >
196 typedef ConsecutiveIndexSet< GridFamily > BaseType;
199 explicit AdaptiveIndexSet (
const typename BaseType::HostIndexSetType &hostIndexSet )
200 : BaseType ( hostIndexSet )
203 int numberOfHoles ( GeometryType type )
const
205 return this->hostIndexSet().numberOfHoles( type );
208 int numberOfHoles (
int codim )
const
210 return this->hostIndexSet().numberOfHoles( codim );
213 int oldIndex (
int hole, GeometryType type )
const
215 return this->hostIndexSet().oldIndex( hole, type );
218 int oldIndex (
int hole,
int codim )
const
220 return this->hostIndexSet().oldIndex( hole, codim );
223 int newIndex (
int hole, GeometryType type )
const
225 return this->hostIndexSet().newIndex( hole, type );
228 int newIndex (
int hole,
int codim )
const
230 return this->hostIndexSet().newIndex( hole, codim );
239 template<
class GridFamily,
240 class HostIndexSet =
typename std::remove_const< GridFamily >::type::Traits::HostGridPartType::IndexSetType,
241 bool consecutive = Capabilities::isConsecutiveIndexSet< HostIndexSet >::v,
242 bool adaptive = Capabilities::isAdaptiveIndexSet< HostIndexSet >::v >
243 struct Implementation
245 typedef typename std::conditional< adaptive,
246 AdaptiveIndexSet< GridFamily >,
247 typename std::conditional< consecutive,
248 ConsecutiveIndexSet< GridFamily >,
249 IndexSet< GridFamily >
261 template<
class Gr
idFamily >
263 :
public __IdIndexSet::Implementation< GridFamily >::Type
265 typedef typename __IdIndexSet::Implementation< GridFamily >::Type BaseType;
267 friend struct Capabilities::isPersistentIndexSet< IdIndexSet< GridFamily > >;
270 explicit IdIndexSet (
const typename BaseType::HostIndexSetType &hostIndexSet )
271 : BaseType ( hostIndexSet )
277 namespace Capabilities
280 template<
class Gr
idFamily >
281 struct isConsecutiveIndexSet< IdIndexSet< GridFamily > >
282 :
public isConsecutiveIndexSet< typename IdIndexSet< GridFamily >::HostIndexSetType >
285 template<
class Gr
idFamily >
286 struct isAdaptiveIndexSet< IdIndexSet< GridFamily > >
287 :
public isAdaptiveIndexSet< typename IdIndexSet< GridFamily >::HostIndexSetType >
290 template<
class Gr
idFamily >
291 struct isPersistentIndexSet< IdIndexSet< GridFamily > >
294 typedef IdIndexSet< GridFamily > IndexSetType;
295 typedef typename IndexSetType::HostIndexSetType HostIndexSetType;
300 static constexpr PersistentIndexSetInterface *
map ( IndexSetType &indexSet )
noexcept
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
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
A unique label for each type of element that can occur in a grid.