dune-grid  2.4.1
mapper.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_COMMON_MAPPER_HH
4 #define DUNE_GRID_COMMON_MAPPER_HH
5 
6 #include <iostream>
7 
8 #include <dune/common/deprecated.hh>
9 #include <dune/common/bartonnackmanifcheck.hh>
10 
88 namespace Dune
89 {
107  template <typename G, typename MapperImp, typename IndexType=int>
108  class Mapper {
109  public:
110 
112  typedef IndexType Index;
113 
119  template<class EntityType>
120  Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'index' instead!") map (const EntityType& e) const
121  {
122  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
123  return asImp().map(e);
124  }
125 
126 
132  template<class EntityType>
133  Index index (const EntityType& e) const
134  {
135  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
136  return asImp().index(e);
137  }
138 
139 
147  Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'index' instead!") map (const typename G::Traits::template Codim<0>::Entity& e,
148  int i,
149  unsigned int codim) const
150  {
151  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e,i,codim)));
152  return asImp().map(e,i,codim);
153  }
154 
162  Index subIndex (const typename G::Traits::template Codim<0>::Entity& e,
163  int i,
164  unsigned int codim) const
165  {
166  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e,i,codim)));
167  return asImp().subIndex(e,i,codim);
168  }
169 
178  int size () const
179  {
180  CHECK_INTERFACE_IMPLEMENTATION((asImp().size()));
181  return asImp().size();
182  }
183 
184 
192  template<class EntityType>
193  bool contains (const EntityType& e, int& result) const
194  {
195  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,result )));
196  return asImp().contains(e,result );
197  }
198 
199 
209  bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int cc, int& result) const
210  {
211  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,i,cc,result)))
212  return asImp().contains(e,i,cc,result);
213  }
214 
217  void update ()
218  {
219  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().update()));
220  }
221 
222  private:
224  MapperImp& asImp () {return static_cast<MapperImp &> (*this);}
226  const MapperImp& asImp () const {return static_cast<const MapperImp &>(*this);}
227  };
228 
231 #undef CHECK_INTERFACE_IMPLEMENTATION
232 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
233 
234 }
235 #endif
void update()
Reinitialize mapper after grid has been modified.
Definition: mapper.hh:217
Wrapper class for entities.
Definition: common/entity.hh:61
bool contains(const EntityType &e, int &result) const
Returns true if the entity is contained in the index set and at the same time the array index is retu...
Definition: mapper.hh:193
Mapper interface.
Definition: mapper.hh:108
IndexType Index
Number type used for indices.
Definition: mapper.hh:112
bool contains(const typename G::Traits::template Codim< 0 >::Entity &e, int i, int cc, int &result) const
Returns true if the subentity is contained in the index set and at the same time the array index is r...
Definition: mapper.hh:209
int size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mapper.hh:178
Index map(const EntityType &e) const
Map entity to array index.
Definition: mapper.hh:120
Index index(const EntityType &e) const
Map entity to array index.
Definition: mapper.hh:133
Include standard header files.
Definition: agrid.hh:59
Index subIndex(const typename G::Traits::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity i of codim cc of a codim 0 entity to array index.
Definition: mapper.hh:162