14#ifndef DUMUX_GEOMETRY_GEOMETRIC_ENTITY_SET_HH
15#define DUMUX_GEOMETRY_GEOMETRIC_ENTITY_SET_HH
21#include <initializer_list>
23#include <dune/grid/common/mcmgmapper.hh>
24#include <dune/geometry/multilineargeometry.hh>
35template <
class Gr
idView,
int codim = 0,
class Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<Gr
idView>>
40 using Entity =
typename GridView::template Codim<codim>::Entity;
49 , entityMap_(std::make_shared<
EntityMap>(gridView.grid(), mapper_))
54 std::shared_ptr<const EntityMap> entityMap)
57 , entityMap_(entityMap)
68 using ctype =
typename GridView::ctype;
73 decltype(
auto)
size()
const
74 {
return gridView_.size(codim); }
80 {
return entities(gridView_, Dune::Codim<codim>()).begin(); }
85 decltype(
auto)
end()
const
86 {
return entities(gridView_, Dune::Codim<codim>()).end(); }
92 {
return mapper_.index(e); }
98 { assert(index < entityMap_->
size());
return (*entityMap_)[
index]; }
103 std::shared_ptr<const EntityMap> entityMap_;
109namespace Dumux::Detail::GeometricEntity {
114template<
class GeoType>
118 using Geometry = GeoType;
123 EntityWrapper(
const Geometry& geo,
const std::size_t index) : geo_(geo), index_(index) {}
128 EntityWrapper(Geometry&& geo,
const std::size_t index) : geo_(std::move(geo)), index_(index) {}
133 const Geometry& geometry()
const
139 std::size_t index()
const
158template<
class GeoType>
162 using Entity = Detail::GeometricEntity::EntityWrapper<GeoType>;
169 std::size_t
index = 0;
173 for (
auto&& g : geometries)
174 entities_.emplace_back(g,
index++);
182 std::size_t
index = 0;
183 for (
auto&& g : geometries)
184 entities_.emplace_back(g,
index++);
192 std::size_t
index = 0;
193 for (
auto&& g : geometries)
194 entities_.emplace_back(std::move(g),
index++);
205 using ctype =
typename Entity::Geometry::ctype;
211 {
return entities_.size(); }
217 {
return entities_.begin(); }
222 decltype(
auto)
end()
const
223 {
return entities_.end(); }
228 template<
class Entity>
230 {
return e.index(); }
236 { assert(
index < entities_.size());
return entities_[
index]; }
239 std::vector<Entity> entities_;
248template<
class GeoType, std::
size_t N>
251 template<
class GT, std::size_t... I>
253 : entities_{{
Entity(std::get<I>(gt), I)... }}
254 {
static_assert(
sizeof...(I) == N,
"Number of geometries must match the size of the entity set"); }
257 using Entity = Detail::GeometricEntity::EntityWrapper<GeoType>;
276 using ctype =
typename Entity::Geometry::ctype;
282 {
return entities_.size(); }
288 {
return entities_.begin(); }
293 decltype(
auto)
end()
const
294 {
return entities_.end(); }
299 template<
class Entity>
301 {
return e.index(); }
307 { assert(
index < entities_.size());
return entities_[
index]; }
310 std::array<Entity, N> entities_;
317template<
class GeoType>
323 using ParentType::ParentType;
A map from indices to entities using grid entity seeds.
Definition: entitymap.hh:27
An interface for a fixed-size set of geometric entities.
Definition: geometricentityset.hh:250
std::size_t index(const Entity &e) const
get an entities index
Definition: geometricentityset.hh:300
FixedSizeGeometriesEntitySet(G &&... g)
Constructor with one or more geometries as arguments.
Definition: geometricentityset.hh:264
constexpr auto size() const
the number of entities in this set
Definition: geometricentityset.hh:281
const Entity & entity(std::size_t index) const
get an entity from an index
Definition: geometricentityset.hh:306
static constexpr int dimensionworld
The world dimension of the entity set.
Definition: geometricentityset.hh:271
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition: geometricentityset.hh:287
Detail::GeometricEntity::EntityWrapper< GeoType > Entity
Definition: geometricentityset.hh:257
typename Entity::Geometry::ctype ctype
the coordinate type
Definition: geometricentityset.hh:276
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition: geometricentityset.hh:293
An interface for a set of geometric entities.
Definition: geometricentityset.hh:160
@ dimensionworld
Definition: geometricentityset.hh:200
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition: geometricentityset.hh:222
typename Entity::Geometry::ctype ctype
the coordinate type
Definition: geometricentityset.hh:205
Detail::GeometricEntity::EntityWrapper< GeoType > Entity
Definition: geometricentityset.hh:162
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition: geometricentityset.hh:216
decltype(auto) size() const
the number of entities in this set
Definition: geometricentityset.hh:210
const Entity & entity(std::size_t index) const
get an entity from an index
Definition: geometricentityset.hh:235
std::size_t index(const Entity &e) const
get an entities index
Definition: geometricentityset.hh:229
GeometriesEntitySet(std::initializer_list< typename Entity::Geometry > &&geometries)
Constructor for initializer_list.
Definition: geometricentityset.hh:167
GeometriesEntitySet(const std::vector< typename Entity::Geometry > &geometries)
Constructor for a vector of geometries.
Definition: geometricentityset.hh:180
GeometriesEntitySet(std::vector< typename Entity::Geometry > &&geometries)
Constructor for a vector of geometries.
Definition: geometricentityset.hh:190
An interface for a set of geometric entities based on a GridView.
Definition: geometricentityset.hh:37
typename GridView::ctype ctype
the coordinate type
Definition: geometricentityset.hh:68
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper)
Definition: geometricentityset.hh:46
std::size_t index(const Entity &e) const
get an entities index
Definition: geometricentityset.hh:91
typename GridView::template Codim< codim >::Entity Entity
Definition: geometricentityset.hh:40
decltype(auto) size() const
the number of entities in this set
Definition: geometricentityset.hh:73
GridViewGeometricEntitySet(const GridView &gridView)
Definition: geometricentityset.hh:42
Entity entity(std::size_t index) const
get an entity from an index
Definition: geometricentityset.hh:97
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition: geometricentityset.hh:85
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper, std::shared_ptr< const EntityMap > entityMap)
Definition: geometricentityset.hh:52
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition: geometricentityset.hh:79
@ dimensionworld
Definition: geometricentityset.hh:63
An interface for a geometric entity set with a single geometry.
Definition: geometricentityset.hh:320
A map from indices to entities using grid entity seeds.
Definition: common/pdesolver.hh:24