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 for (
auto gt : _index_set.types(0))
43 _gt_offsets[LocalGeometryTypeIndex::index(gt) + 1] = _index_set.size(gt);
47 std::partial_sum(_gt_offsets.begin(),_gt_offsets.end(),_gt_offsets.begin());
50 size_type map(
const Element&
e)
const 52 return _gt_offsets[LocalGeometryTypeIndex::index(e.type())] + _index_set.index(e);
55 ElementMapperBase(
const GV& gv)
56 : _gt_offsets(LocalGeometryTypeIndex::size(dim) + 1)
57 , _index_set(gv.indexSet())
64 std::vector<size_type> _gt_offsets;
65 const IndexSet& _index_set;
71 class ElementMapperBase<GV,true>
76 typedef typename GV::template Codim<0>::Entity Element;
77 typedef typename GV::IndexSet IndexSet;
78 typedef std::size_t size_type;
83 size_type map(
const Element&
e)
const 85 return _index_set.index(e);
88 ElementMapperBase(
const GV& gv)
89 : _index_set(gv.indexSet())
94 const IndexSet& _index_set;
112 template<
typename GV>
114 :
public ElementMapperBase<GV,
115 Dune::Capabilities::hasSingleGeometryType<
121 typedef ElementMapperBase<
123 Dune::Capabilities::hasSingleGeometryType<
153 size_type
map(
const Element&
e)
const 155 return BaseT::map(e);
164 #endif // DUNE_PDELAB_COMMON_ELEMENTMAPPER_HH static const int dim
Definition: adaptivity.hh:83
Definition: adaptivity.hh:27
BaseT::Element Element
The type of the codim 0 entities of the GridView.
Definition: elementmapper.hh:134
Class providing a consecutive index for codim 0 entities of a GridView.
Definition: elementmapper.hh:113
const Entity & e
Definition: localfunctionspace.hh:111
BaseT::size_type size_type
The type of the returned index.
Definition: elementmapper.hh:131
ElementMapper(const GV &gv)
Construct a CellIndexProvider for the given GridView.
Definition: elementmapper.hh:140
size_type map(const Element &e) const
Return the index of the given element.
Definition: elementmapper.hh:153