1 #ifndef DUNE_PDELAB_COMMON_ELEMENTMAPPER_HH
2 #define DUNE_PDELAB_COMMON_ELEMENTMAPPER_HH
8 #include <dune/geometry/type.hh>
9 #include <dune/geometry/typeindex.hh>
10 #include <dune/grid/common/capabilities.hh>
19 template<
typename GV,
bool has_single_cell_type>
20 class ElementMapperBase
25 typedef typename GV::template Codim<0>::Entity Element;
26 typedef std::size_t size_type;
30 static const size_type
dim = GV::dimension;
31 typedef typename GV::IndexSet IndexSet;
38 std::fill(_gt_offsets.begin(),_gt_offsets.end(),0);
41 typedef std::vector<GeometryType> GTVector;
42 const GTVector& geometry_types = _index_set.geomTypes(0);
43 for (
typename GTVector::const_iterator it = geometry_types.begin(), end = geometry_types.end();
47 _gt_offsets[LocalGeometryTypeIndex::index(*it) + 1] = _index_set.size(*it);
51 std::partial_sum(_gt_offsets.begin(),_gt_offsets.end(),_gt_offsets.begin());
54 size_type map(
const Element&
e)
const
56 return _gt_offsets[LocalGeometryTypeIndex::index(e.type())] + _index_set.index(e);
59 ElementMapperBase(
const GV& gv)
60 : _gt_offsets(LocalGeometryTypeIndex::size(
dim) + 1)
61 , _index_set(gv.indexSet())
68 std::vector<size_type> _gt_offsets;
69 const IndexSet& _index_set;
75 class ElementMapperBase<GV,true>
80 typedef typename GV::template Codim<0>::Entity Element;
81 typedef typename GV::IndexSet IndexSet;
82 typedef std::size_t size_type;
87 size_type map(
const Element&
e)
const
89 return _index_set.index(e);
92 ElementMapperBase(
const GV& gv)
93 : _index_set(gv.indexSet())
98 const IndexSet& _index_set;
116 template<
typename GV>
118 :
public ElementMapperBase<GV,
119 Dune::Capabilities::hasSingleGeometryType<
125 typedef ElementMapperBase<
127 Dune::Capabilities::hasSingleGeometryType<
159 return BaseT::map(e);
168 #endif // DUNE_PDELAB_COMMON_ELEMENTMAPPER_HH
BaseT::Element Element
The type of the codim 0 entities of the GridView.
Definition: elementmapper.hh:138
ElementMapper(const GV &gv)
Construct a CellIndexProvider for the given GridView.
Definition: elementmapper.hh:144
static const int dim
Definition: adaptivity.hh:82
BaseT::size_type size_type
The type of the returned index.
Definition: elementmapper.hh:135
Class providing a consecutive index for codim 0 entities of a GridView.
Definition: elementmapper.hh:117
size_type map(const Element &e) const
Return the index of the given element.
Definition: elementmapper.hh:157
const E & e
Definition: interpolate.hh:172