dune-grid  2.3.0
geometrygrid/indexsets.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_GEOGRID_INDEXSETS_HH
4 #define DUNE_GEOGRID_INDEXSETS_HH
5 
6 #include <vector>
7 
8 #include <dune/common/typetraits.hh>
9 
12 
14 
15 namespace Dune
16 {
17 
18  namespace GeoGrid
19  {
20 
21  // IndexSet
22  // --------
23 
24  template< class Grid, class HostIndexSet >
25  class IndexSet
26  : public Dune::IndexSet< Grid, IndexSet< Grid, HostIndexSet >, typename HostIndexSet::IndexType >
27  {
30 
31  typedef typename remove_const< Grid >::type::Traits Traits;
32 
33  typedef typename Traits::HostGrid HostGrid;
34 
35  public:
36  static const int dimension = Traits::dimension;
37 
38  typedef typename Base::IndexType IndexType;
39 
41  : hostIndexSet_( 0 )
42  {}
43 
44  explicit IndexSet ( const HostIndexSet &hostIndexSet )
45  : hostIndexSet_( &hostIndexSet )
46  {}
47 
48  IndexSet ( const This &other )
49  : hostIndexSet_( other.hostIndexSet_ )
50  {}
51 
52  const This &operator= ( const This &other )
53  {
54  hostIndexSet_ = other.hostIndexSet_;
55  return *this;
56  }
57 
58  using Base::index;
59  using Base::subIndex;
60 
61  template< int cc >
62  IndexType index ( const typename Traits::template Codim< cc >::Entity &entity ) const
63  {
64  return Grid::getRealImplementation( entity ).index( hostIndexSet() );
65  }
66 
67  template< int cc >
68  IndexType subIndex ( const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim ) const
69  {
70  return Grid::getRealImplementation( entity ).subIndex( hostIndexSet(), i, codim );
71  }
72 
73  IndexType size ( GeometryType type ) const
74  {
75  return hostIndexSet().size( type );
76  }
77 
78  int size ( int codim ) const
79  {
80  return hostIndexSet().size( codim );
81  }
82 
83  template< class Entity >
84  bool contains ( const Entity &entity ) const
85  {
86  return Grid::getRealImplementation( entity ).isContained( hostIndexSet() );
87  }
88 
89  const std::vector< GeometryType > &geomTypes ( int codim ) const
90  {
91  return hostIndexSet().geomTypes( codim );
92  }
93 
94  operator bool () const { return bool( hostIndexSet_ ); }
95 
96  private:
97  const HostIndexSet &hostIndexSet () const
98  {
99  assert( *this );
100  return *hostIndexSet_;
101  }
102 
103  const HostIndexSet *hostIndexSet_;
104  };
105 
106  } // namespace GeoGrid
107 
108 } // namespace Dune
109 
110 #endif // #ifndef DUNE_GEOGRID_INDEXSETS_HH
Base::IndexType IndexType
Definition: geometrygrid/indexsets.hh:38
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Index Set Interface base class.
Definition: common/grid.hh:359
const This & operator=(const This &other)
Definition: geometrygrid/indexsets.hh:52
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:49
IndexTypeImp IndexType
The type used for the indices.
Definition: indexidset.hh:85
Provides base classes for index and id sets.
IndexType index(const typename remove_const< GridImp >::type::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:107
const std::vector< GeometryType > & geomTypes(int codim) const
Definition: geometrygrid/indexsets.hh:89
IndexType size(GeometryType type) const
Definition: geometrygrid/indexsets.hh:73
IndexSet(const HostIndexSet &hostIndexSet)
Definition: geometrygrid/indexsets.hh:44
int size(int codim) const
Definition: geometrygrid/indexsets.hh:78
static const int dimension
Definition: geometrygrid/indexsets.hh:36
bool contains(const Entity &entity) const
Definition: geometrygrid/indexsets.hh:84
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim) const
Definition: geometrygrid/indexsets.hh:68
IndexSet(const This &other)
Definition: geometrygrid/indexsets.hh:48
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:146
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
Definition: geometrygrid/indexsets.hh:62
IndexSet()
Definition: geometrygrid/indexsets.hh:40
Definition: geometrygrid/indexsets.hh:25