14#ifndef DUMUX_GEOMETRY_GEOMETRIC_ENTITY_SET_HH
15#define DUMUX_GEOMETRY_GEOMETRIC_ENTITY_SET_HH
18#include <dune/grid/common/mcmgmapper.hh>
19#include <dune/geometry/multilineargeometry.hh>
30template <
class Gr
idView,
int codim = 0,
class Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<Gr
idView>>
35 using Entity =
typename GridView::template Codim<codim>::Entity;
44 , entityMap_(std::make_shared<
EntityMap>(gridView.grid(), mapper_))
49 std::shared_ptr<const EntityMap> entityMap)
52 , entityMap_(entityMap)
63 using ctype =
typename GridView::ctype;
68 decltype(
auto)
size()
const
69 {
return gridView_.size(codim); }
75 {
return entities(gridView_, Dune::Codim<codim>()).begin(); }
80 decltype(
auto)
end()
const
81 {
return entities(gridView_, Dune::Codim<codim>()).end(); }
87 {
return mapper_.index(e); }
93 { assert(index < entityMap_->
size());
return (*entityMap_)[
index]; }
98 std::shared_ptr<const EntityMap> entityMap_;
107template<
class GeoType>
116 using Geometry = GeoType;
121 EntityWrapper(
const Geometry& geo,
const std::size_t
index) : geo_(geo), index_(
index) {}
126 EntityWrapper(Geometry&& geo,
const std::size_t
index) : geo_(std::move(geo)), index_(
index) {}
131 const Geometry& geometry()
const
137 std::size_t
index()
const
153 std::size_t
index = 0;
157 for (
auto&& g : geometries)
158 entities_.emplace_back(g,
index++);
166 std::size_t
index = 0;
167 for (
auto&& g : geometries)
168 entities_.emplace_back(g,
index++);
176 std::size_t
index = 0;
177 for (
auto&& g : geometries)
178 entities_.emplace_back(std::move(g),
index++);
189 using ctype =
typename Entity::Geometry::ctype;
195 {
return entities_.size(); }
201 {
return entities_.begin(); }
206 decltype(
auto)
end()
const
207 {
return entities_.end(); }
212 template<
class Entity>
214 {
return e.index(); }
220 { assert(
index < entities_.size());
return entities_[
index]; }
223 std::vector<Entity> entities_;
A map from indices to entities using grid entity seeds.
Definition: entitymap.hh:27
An interface for a set of geometric entities.
Definition: geometricentityset.hh:109
@ dimensionworld
Definition: geometricentityset.hh:184
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition: geometricentityset.hh:206
typename Entity::Geometry::ctype ctype
the coordinate type
Definition: geometricentityset.hh:189
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition: geometricentityset.hh:200
decltype(auto) size() const
the number of entities in this set
Definition: geometricentityset.hh:194
const Entity & entity(std::size_t index) const
get an entity from an index
Definition: geometricentityset.hh:219
EntityWrapper Entity
Definition: geometricentityset.hh:146
std::size_t index(const Entity &e) const
get an entities index
Definition: geometricentityset.hh:213
GeometriesEntitySet(std::initializer_list< typename Entity::Geometry > &&geometries)
Constructor for initializer_list.
Definition: geometricentityset.hh:151
GeometriesEntitySet(const std::vector< typename Entity::Geometry > &geometries)
Constructor for a vector of geometries.
Definition: geometricentityset.hh:164
GeometriesEntitySet(std::vector< typename Entity::Geometry > &&geometries)
Constructor for a vector of geometries.
Definition: geometricentityset.hh:174
An interface for a set of geometric entities based on a GridView.
Definition: geometricentityset.hh:32
typename GridView::ctype ctype
the coordinate type
Definition: geometricentityset.hh:63
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper)
Definition: geometricentityset.hh:41
std::size_t index(const Entity &e) const
get an entities index
Definition: geometricentityset.hh:86
typename GridView::template Codim< codim >::Entity Entity
Definition: geometricentityset.hh:35
decltype(auto) size() const
the number of entities in this set
Definition: geometricentityset.hh:68
GridViewGeometricEntitySet(const GridView &gridView)
Definition: geometricentityset.hh:37
Entity entity(std::size_t index) const
get an entity from an index
Definition: geometricentityset.hh:92
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition: geometricentityset.hh:80
@ dimensionworld
Definition: geometricentityset.hh:58
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper, std::shared_ptr< const EntityMap > entityMap)
Definition: geometricentityset.hh:47
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition: geometricentityset.hh:74
A map from indices to entities using grid entity seeds.
Definition: common/pdesolver.hh:24