12#ifndef DUMUX_ENTITY_INDEX_MAP_HH
13#define DUMUX_ENTITY_INDEX_MAP_HH
17#include <dune/geometry/dimension.hh>
25template <
class Gr
idView,
int codim = 0>
29 using Grid =
typename GridView::Traits::Grid;
30 using Entity =
typename Grid::template Codim<codim>::Entity;
31 using EntitySeed =
typename Grid::template Codim<codim>::EntitySeed;
36 , seeds_(std::move(seeds))
40 template<
class Mapper>
48 void update(std::vector<EntitySeed>&& seeds)
49 { seeds_.swap(std::move(seeds)); }
52 template<
class Mapper>
55 const auto& gv = grid_.leafGridView();
56 seeds_.resize(gv.size(codim));
57 for (
const auto& entity : entities(gv, Dune::Codim<codim>()))
58 seeds_[mapper.index(entity)] = entity.seed();
63 {
return grid_.entity(seeds_[i]); }
67 {
return seeds_.size(); }
71 std::vector<EntitySeed> seeds_;
74template<
class Gr
idView>
A map from indices to entities using grid entity seeds.
Definition: entitymap.hh:27
typename Grid::template Codim< codim >::EntitySeed EntitySeed
Definition: entitymap.hh:31
typename GridView::Traits::Grid Grid
Definition: entitymap.hh:29
std::size_t size() const
get the size of the map
Definition: entitymap.hh:66
EntityMap(const Grid &grid, std::vector< EntitySeed > &&seeds)
constructor moving a ready seed list in here
Definition: entitymap.hh:34
Entity operator[](std::size_t i) const
get an element from an index i
Definition: entitymap.hh:62
void update(std::vector< EntitySeed > &&seeds)
update the map after the grid changed
Definition: entitymap.hh:48
EntityMap(const Grid &grid, const Mapper &mapper)
constructor with all entities of codim
Definition: entitymap.hh:41
void update(const Mapper &mapper)
update the map after the grid changed
Definition: entitymap.hh:53
typename Grid::template Codim< codim >::Entity Entity
Definition: entitymap.hh:30