dune-grid 3.0-git
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
15namespace Dune
16{
17
18 namespace GeoGrid
19 {
20
21 // IndexSet
22 // --------
23
24 template< class Grid, class HostIndexSet >
26 : public Dune::IndexSet< Grid, IndexSet< Grid, HostIndexSet >, typename HostIndexSet::IndexType, typename HostIndexSet::Types >
27 {
30
31 typedef typename std::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
40 typedef typename Base::Types Types;
41
43 : hostIndexSet_( 0 )
44 {}
45
46 explicit IndexSet ( const HostIndexSet &hostIndexSet )
47 : hostIndexSet_( &hostIndexSet )
48 {}
49
50 IndexSet ( const This &other )
51 : hostIndexSet_( other.hostIndexSet_ )
52 {}
53
54 const This &operator= ( const This &other )
55 {
56 hostIndexSet_ = other.hostIndexSet_;
57 return *this;
58 }
59
60 using Base::index;
61 using Base::subIndex;
62
63 template< int cc >
64 IndexType index ( const typename Traits::template Codim< cc >::Entity &entity ) const
65 {
66 return Grid::getRealImplementation( entity ).index( hostIndexSet() );
67 }
68
69 template< int cc >
70 IndexType subIndex ( const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim ) const
71 {
72 return Grid::getRealImplementation( entity ).subIndex( hostIndexSet(), i, codim );
73 }
74
75 IndexType size ( GeometryType type ) const
76 {
77 return hostIndexSet().size( type );
78 }
79
80 int size ( int codim ) const
81 {
82 return hostIndexSet().size( codim );
83 }
84
85 template< class Entity >
86 bool contains ( const Entity &entity ) const
87 {
88 return Grid::getRealImplementation( entity ).isContained( hostIndexSet() );
89 }
90
91 Types types ( int codim ) const { return hostIndexSet().types( codim ); }
92
93 const std::vector< GeometryType > &geomTypes ( int codim ) const
94 {
95 return hostIndexSet().geomTypes( codim );
96 }
97
98 operator bool () const { return bool( hostIndexSet_ ); }
99
100 private:
101 const HostIndexSet &hostIndexSet () const
102 {
103 assert( *this );
104 return *hostIndexSet_;
105 }
106
107 const HostIndexSet *hostIndexSet_;
108 };
109
110 } // namespace GeoGrid
111
112} // namespace Dune
113
114#endif // #ifndef DUNE_GEOGRID_INDEXSETS_HH
Provides base classes for index and id sets.
Include standard header files.
Definition agrid.hh:60
Index Set Interface base class.
Definition indexidset.hh:76
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:149
TypesImp Types
iterator range for geometry types in domain
Definition indexidset.hh:93
IndexType index(const typename 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:111
IndexTypeImp IndexType
The type used for the indices.
Definition indexidset.hh:90
DUNE-conform implementation of the entity.
Definition geometrygrid/entity.hh:684
Definition geometrygrid/indexsets.hh:27
const This & operator=(const This &other)
Definition geometrygrid/indexsets.hh:54
Types types(int codim) const
Definition geometrygrid/indexsets.hh:91
static const int dimension
Definition geometrygrid/indexsets.hh:36
const std::vector< GeometryType > & geomTypes(int codim) const
Definition geometrygrid/indexsets.hh:93
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim) const
Definition geometrygrid/indexsets.hh:70
int size(int codim) const
Definition geometrygrid/indexsets.hh:80
bool contains(const Entity &entity) const
Definition geometrygrid/indexsets.hh:86
IndexSet(const HostIndexSet &hostIndexSet)
Definition geometrygrid/indexsets.hh:46
Base::Types Types
Definition geometrygrid/indexsets.hh:40
IndexSet()
Definition geometrygrid/indexsets.hh:42
IndexSet(const This &other)
Definition geometrygrid/indexsets.hh:50
Base::IndexType IndexType
Definition geometrygrid/indexsets.hh:38
IndexType size(GeometryType type) const
Definition geometrygrid/indexsets.hh:75
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
Definition geometrygrid/indexsets.hh:64