Dune Core Modules (2.8.0)

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 <utility>
7
9
87namespace Dune
88{
106 template <typename G, typename MapperImp, typename IndexType=int>
107 class Mapper
108 {
109 public:
110
112 using Index = IndexType;
113
119 template<class EntityType>
120 Index index (const EntityType& e) const
121 {
122 CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e)));
123 return asImp().index(e);
124 }
125
126
134 Index subIndex (const typename G::Traits::template Codim<0>::Entity& e,
135 int i,
136 unsigned int codim) const
137 {
138 CHECK_INTERFACE_IMPLEMENTATION((asImp().map(e,i,codim)));
139 return asImp().subIndex(e,i,codim);
140 }
141
150 auto size () const
151 {
152 CHECK_INTERFACE_IMPLEMENTATION((asImp().size()));
153 return asImp().size();
154 }
155
156
164 template<class EntityType>
165 bool contains (const EntityType& e, IndexType& result) const
166 {
167 CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,result )));
168 return asImp().contains(e,result );
169 }
170
171
181 bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int cc, IndexType& result) const
182 {
183 CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(e,i,cc,result)))
184 return asImp().contains(e,i,cc,result);
185 }
186
189 template <class GridView>
190 void update (GridView&& gridView)
191 {
192 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().update(std::forward<GridView>(gridView))));
193 }
194
197 [[deprecated("Use update(gridView) instead! Will be removed after release 2.8. Mappers have to implement update(gridView).")]]
198 void update ()
199 {
201 }
202
203 private:
205 MapperImp& asImp () {return static_cast<MapperImp &> (*this);}
207 const MapperImp& asImp () const {return static_cast<const MapperImp &>(*this);}
208 };
209
212#undef CHECK_INTERFACE_IMPLEMENTATION
213#undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
214
215}
216#endif
Provides check for implementation of interface methods when using static polymorphism,...
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:59
Grid view abstract base class.
Definition: gridview.hh:63
Mapper interface.
Definition: mapper.hh:108
auto size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mapper.hh:150
void update(GridView &&gridView)
Reinitialize mapper after grid has been modified.
Definition: mapper.hh:190
void update()
Reinitialize mapper after grid has been modified.
Definition: mapper.hh:198
Index index(const EntityType &e) const
Map entity to array index.
Definition: mapper.hh:120
IndexType Index
Number type used for indices.
Definition: mapper.hh:112
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:134
bool contains(const typename G::Traits::template Codim< 0 >::Entity &e, int i, int cc, IndexType &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:181
bool contains(const EntityType &e, IndexType &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:165
Dune namespace.
Definition: alignedallocator.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.111.3 (Nov 21, 23:30, 2024)