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))
47 std::partial_sum(_gt_offsets.begin(),_gt_offsets.end(),_gt_offsets.begin());
50 size_type map(
const Element&
e)
const
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<
155 return BaseT::map(
e);
164 #endif // DUNE_PDELAB_COMMON_ELEMENTMAPPER_HH