dune-grid  3.0-git
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/bartonnackmanifcheck.hh>
9 
87 namespace Dune
88 {
106  template <typename G, typename MapperImp, typename IndexType=int>
107  class Mapper {
108  public:
109 
111  typedef IndexType Index;
112 
118  template<class EntityType>
119  Index index (const EntityType& e) const
120  {
121  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
122  return asImp().index(e);
123  }
124 
125 
133  Index subIndex (const typename G::Traits::template Codim<0>::Entity& e,
134  int i,
135  unsigned int codim) const
136  {
137  CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e,i,codim)));
138  return asImp().subIndex(e,i,codim);
139  }
140 
149  int size () const
150  {
151  CHECK_INTERFACE_IMPLEMENTATION((asImp().size()));
152  return asImp().size();
153  }
154 
155 
163  template<class EntityType>
164  bool contains (const EntityType& e, int& result) const
165  {
166  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,result )));
167  return asImp().contains(e,result );
168  }
169 
170 
180  bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int cc, int& result) const
181  {
182  CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,i,cc,result)))
183  return asImp().contains(e,i,cc,result);
184  }
185 
188  void update ()
189  {
190  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().update()));
191  }
192 
193  private:
195  MapperImp& asImp () {return static_cast<MapperImp &> (*this);}
197  const MapperImp& asImp () const {return static_cast<const MapperImp &>(*this);}
198  };
199 
202 #undef CHECK_INTERFACE_IMPLEMENTATION
203 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
204 
205 }
206 #endif
Dune
Include standard header files.
Definition: agrid.hh:59
Dune::Mapper::subIndex
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:133
Dune::Mapper::size
int size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mapper.hh:149
Dune::Mapper::contains
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:164
Dune::Mapper::index
Index index(const EntityType &e) const
Map entity to array index.
Definition: mapper.hh:119
Dune::Mapper::contains
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:180
Dune::Mapper::update
void update()
Reinitialize mapper after grid has been modified.
Definition: mapper.hh:188
Dune::Mapper
Mapper interface.
Definition: mapper.hh:107
Dune::Mapper::Index
IndexType Index
Number type used for indices.
Definition: mapper.hh:111