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_GRID_YASPGRIDINDEXSET_HH
4
#define DUNE_GRID_YASPGRIDINDEXSET_HH
8
\brief level-wise, non-persistent, consecutive indices for YaspGrid
14
/** \brief Implementation of Level- and LeafIndexSets for YaspGrid
16
* \tparam GridImp The YaspGrid class we are an index set for
17
* \tparam isLeafIndexSet false: class functions as level index set,
18
* true: class functions as leaf index set
20
template<class GridImp, bool isLeafIndexSet>
22
: public IndexSet< GridImp, YaspIndexSet< GridImp, isLeafIndexSet >, unsigned int >
24
typedef YaspIndexSet< GridImp, isLeafIndexSet > This;
25
typedef IndexSet< GridImp, This, unsigned int > Base;
28
typedef typename Base::IndexType IndexType;
32
/** \brief Level grid view constructor stores reference to a grid and level */
33
YaspIndexSet ( const GridImp &g, int l )
37
assert(not isLeafIndexSet);
39
// contains a single element type;
40
for (int codim=0; codim<=GridImp::dimension; codim++)
41
mytypes[codim].push_back(GeometryType(GeometryType::cube,GridImp::dimension-codim));
44
/** \brief Level grid view constructor stores reference to a grid and level */
45
YaspIndexSet ( const GridImp &g )
48
assert(isLeafIndexSet);
50
// contains a single element type;
51
for (int codim=0; codim<=GridImp::dimension; codim++)
52
mytypes[codim].push_back(GeometryType(GeometryType::cube,GridImp::dimension-codim));
55
//! get index of an entity
57
IndexType index (const typename remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e) const
59
assert( cc == 0 || cc == GridImp::dimension );
60
return grid.getRealImplementation(e).compressedIndex();
63
//! get index of subentity of an entity
65
IndexType subIndex ( const typename remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e,
66
int i, unsigned int codim ) const
68
assert( cc == 0 || cc == GridImp::dimension );
69
if( cc == GridImp::dimension )
70
return grid.getRealImplementation(e).compressedIndex();
72
return grid.getRealImplementation(e).subCompressedIndex(i,codim);
75
//! get number of entities of given type and level (the level is known to the object)
76
int size (GeometryType type) const
78
return (isLeafIndexSet)
80
: grid.size( level, type );
83
//! return size of set for a given codim
84
int size (int codim) const
86
return (isLeafIndexSet)
88
: grid.size( level, codim );
91
//! return true if the given entity is contained in \f$E\f$.
92
template<class EntityType>
93
bool contains (const EntityType& e) const
95
return (isLeafIndexSet)
96
? e.level() == grid.maxLevel()
100
//! deliver all geometry types used in this grid
101
const std::vector<GeometryType>& geomTypes (int codim) const
103
return mytypes[codim];
109
std::vector<GeometryType> mytypes[remove_const<GridImp>::type::dimension+1];
114
#endif // DUNE_GRID_YASPGRIDINDEXSET_HH