Dune Core Modules (2.5.0)

yaspgridindexsets.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_GRID_YASPGRIDINDEXSET_HH
4 #define DUNE_GRID_YASPGRIDINDEXSET_HH
5 
12 namespace Dune {
13 
20  template<class GridImp, bool isLeafIndexSet>
22  : public IndexSet< GridImp, YaspIndexSet< GridImp, isLeafIndexSet >, unsigned int >
23  {
26 
27  public:
28  typedef typename Base::IndexType IndexType;
29 
30  using Base::subIndex;
31 
33  YaspIndexSet ( const GridImp &g, int l )
34  : grid( g ),
35  level( l )
36  {
37  assert(not isLeafIndexSet);
38 
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));
42  }
43 
45  YaspIndexSet ( const GridImp &g )
46  : grid( g )
47  {
48  assert(isLeafIndexSet);
49 
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));
53  }
54 
56  template<int cc>
57  IndexType index (const typename std::remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e) const
58  {
59  return grid.getRealImplementation(e).compressedIndex();
60  }
61 
63  template< int cc >
64  IndexType subIndex ( const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e,
65  int i, unsigned int codim ) const
66  {
67  assert( cc == 0 || cc == GridImp::dimension );
68  if( cc == GridImp::dimension )
69  return grid.getRealImplementation(e).compressedIndex();
70  else
71  return grid.getRealImplementation(e).subCompressedIndex(i,codim);
72  }
73 
75  int size (GeometryType type) const
76  {
77  return (isLeafIndexSet)
78  ? grid.size( type )
79  : grid.size( level, type );
80  }
81 
83  int size (int codim) const
84  {
85  return (isLeafIndexSet)
86  ? grid.size( codim )
87  : grid.size( level, codim );
88  }
89 
91  template<class EntityType>
92  bool contains (const EntityType& e) const
93  {
94  return (isLeafIndexSet)
95  ? e.level() == grid.maxLevel()
96  : e.level() == level;
97  }
98 
99  std::vector< GeometryType > types ( int codim ) const { return mytypes[ codim ]; }
100 
102  const std::vector<GeometryType>& geomTypes (int codim) const
103  {
104  return mytypes[codim];
105  }
106 
107  private:
108  const GridImp& grid;
109  int level;
110  std::vector<GeometryType> mytypes[std::remove_const<GridImp>::type::dimension+1];
111  };
112 
113 } // namespace Dune
114 
115 #endif // DUNE_GRID_YASPGRIDINDEXSET_HH
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:268
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:274
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:151
IndexTypeImp IndexType
The type used for the indices.
Definition: indexidset.hh:90
Implementation of Level- and LeafIndexSets for YaspGrid.
Definition: yaspgridindexsets.hh:23
int size(GeometryType type) const
get number of entities of given type and level (the level is known to the object)
Definition: yaspgridindexsets.hh:75
YaspIndexSet(const GridImp &g)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:45
YaspIndexSet(const GridImp &g, int l)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:33
IndexType index(const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e) const
get index of an entity
Definition: yaspgridindexsets.hh:57
bool contains(const EntityType &e) const
return true if the given entity is contained in .
Definition: yaspgridindexsets.hh:92
IndexType subIndex(const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
get index of subentity of an entity
Definition: yaspgridindexsets.hh:64
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: yaspgridindexsets.hh:102
int size(int codim) const
return size of set for a given codim
Definition: yaspgridindexsets.hh:83
Dune namespace.
Definition: alignment.hh:11
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)