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>
36template <
class Gr
idView,
int codim = 0,
class Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<Gr
idView>>
41 using Entity =
typename GridView::template Codim<codim>::Entity;
50 , entityMap_(std::make_shared<EntityMap>(gridView.grid(), mapper_))
55 std::shared_ptr<const EntityMap> entityMap)
58 , entityMap_(entityMap)
69 using ctype =
typename GridView::ctype;
74 decltype(
auto)
size()
const
75 {
return gridView_.size(codim); }
81 decltype(
auto)
comm()
const
82 {
return gridView_.comm(); }
88 {
return entities(gridView_, Dune::Codim<codim>()).begin(); }
93 decltype(
auto)
end()
const
94 {
return entities(gridView_, Dune::Codim<codim>()).end(); }
100 {
return mapper_.index(e); }
111 std::shared_ptr<const EntityMap> entityMap_;
117namespace Dumux::Detail::GeometricEntity {
122template<
class GeoType>
126 using Geometry = GeoType;
131 EntityWrapper(
const Geometry& geo,
const std::size_t index) : geo_(geo), index_(index) {}
136 EntityWrapper(Geometry&& geo,
const std::size_t index) : geo_(std::move(geo)), index_(index) {}
141 const Geometry& geometry()
const
147 std::size_t index()
const
158template<
class ct,
int dimworld>
162 using Geometry = BoundingBoxGeometry<ct, dimworld>;
164 ProcessEntity(
const Geometry& geo, std::size_t index,
int rank)
165 : geo_(geo), index_(index), rank_(rank) {}
168 const Geometry& geometry()
const
172 std::size_t index()
const
196template<
class GeoType>
200 using Entity = Detail::GeometricEntity::EntityWrapper<GeoType>;
207 std::size_t
index = 0;
211 for (
auto&& g : geometries)
212 entities_.emplace_back(g,
index++);
220 std::size_t
index = 0;
221 for (
auto&& g : geometries)
222 entities_.emplace_back(g,
index++);
230 std::size_t
index = 0;
231 for (
auto&& g : geometries)
232 entities_.emplace_back(std::move(g),
index++);
243 using ctype =
typename Entity::Geometry::ctype;
249 {
return entities_.size(); }
255 {
return entities_.begin(); }
260 decltype(
auto)
end()
const
261 {
return entities_.end(); }
266 template<
class Entity>
268 {
return e.index(); }
274 { assert(
index < entities_.size());
return entities_[
index]; }
277 std::vector<Entity> entities_;
286template<
class GeoType, std::
size_t N>
287class FixedSizeGeometriesEntitySet
289 template<
class GT, std::size_t... I>
290 FixedSizeGeometriesEntitySet(GT&& gt, std::index_sequence<I...>)
291 : entities_{{
Entity(std::get<I>(gt), I)... }}
292 {
static_assert(
sizeof...(I) == N,
"Number of geometries must match the size of the entity set"); }
295 using Entity = Detail::GeometricEntity::EntityWrapper<GeoType>;
303 : FixedSizeGeometriesEntitySet(std::forward_as_tuple(std::forward<G>(g)...), std::make_index_sequence<N>{})
314 using ctype =
typename Entity::Geometry::ctype;
320 {
return entities_.size(); }
326 {
return entities_.begin(); }
331 decltype(
auto)
end()
const
332 {
return entities_.end(); }
337 template<
class Entity>
339 {
return e.index(); }
345 { assert(
index < entities_.size());
return entities_[
index]; }
348 std::array<Entity, N> entities_;
355template<
class GeoType>
357:
public FixedSizeGeometriesEntitySet<GeoType, 1>
359 using ParentType = FixedSizeGeometriesEntitySet<GeoType, 1>;
361 using ParentType::ParentType;
373template<
class ct,
int dimworld>
377 using Entity = Detail::GeometricEntity::ProcessEntity<ct, dimworld>;
393 : entities_(std::move(entities)) {}
399 {
return entities_.size(); }
405 {
return entities_.begin(); }
410 decltype(
auto)
end()
const
411 {
return entities_.end(); }
417 {
return e.index(); }
423 { assert(
index < entities_.size());
return entities_[
index]; }
429 { assert(
index < entities_.size());
return entities_[
index].rank(); }
432 std::vector<Entity> entities_;
A thin axis-aligned box geometry.
A map from indices to entities using grid entity seeds.
Definition entitymap.hh:27
std::size_t index(const Entity &e) const
get an entities index
Definition geometricentityset.hh:338
FixedSizeGeometriesEntitySet(G &&... g)
Constructor with one or more geometries as arguments.
Definition geometricentityset.hh:302
constexpr auto size() const
the number of entities in this set
Definition geometricentityset.hh:319
const Entity & entity(std::size_t index) const
get an entity from an index
Definition geometricentityset.hh:344
static constexpr int dimensionworld
Definition geometricentityset.hh:309
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition geometricentityset.hh:325
Detail::GeometricEntity::EntityWrapper< GeoType > Entity
Definition geometricentityset.hh:295
typename Entity::Geometry::ctype ctype
the coordinate type
Definition geometricentityset.hh:314
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition geometricentityset.hh:331
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition geometricentityset.hh:260
typename Entity::Geometry::ctype ctype
Definition geometricentityset.hh:243
Detail::GeometricEntity::EntityWrapper< Geometry > Entity
Definition geometricentityset.hh:200
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition geometricentityset.hh:254
decltype(auto) size() const
the number of entities in this set
Definition geometricentityset.hh:248
const Entity & entity(std::size_t index) const
get an entity from an index
Definition geometricentityset.hh:273
std::size_t index(const Entity &e) const
Definition geometricentityset.hh:267
GeometriesEntitySet(std::initializer_list< typename Entity::Geometry > &&geometries)
Constructor for initializer_list.
Definition geometricentityset.hh:205
GeometriesEntitySet(const std::vector< typename Entity::Geometry > &geometries)
Constructor for a vector of geometries.
Definition geometricentityset.hh:218
GeometriesEntitySet(std::vector< typename Entity::Geometry > &&geometries)
Constructor for a vector of geometries.
Definition geometricentityset.hh:228
static constexpr int dimensionworld
Definition geometricentityset.hh:238
static constexpr int dimensionworld
Definition geometricentityset.hh:64
typename GV::ctype ctype
Definition geometricentityset.hh:69
decltype(auto) comm() const
the communicator of the underlying grid view
Definition geometricentityset.hh:81
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper)
Definition geometricentityset.hh:47
std::size_t index(const Entity &e) const
get an entities index
Definition geometricentityset.hh:99
typename GV::template Codim< codim >::Entity Entity
Definition geometricentityset.hh:41
decltype(auto) size() const
the number of entities in this set
Definition geometricentityset.hh:74
GridViewGeometricEntitySet(const GridView &gridView)
Definition geometricentityset.hh:43
Entity entity(std::size_t index) const
get an entity from an index
Definition geometricentityset.hh:105
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition geometricentityset.hh:93
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper, std::shared_ptr< const EntityMap > entityMap)
Definition geometricentityset.hh:53
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition geometricentityset.hh:87
Detail::GeometricEntity::ProcessEntity< ctype, dimworld > Entity
Definition geometricentityset.hh:377
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition geometricentityset.hh:404
static constexpr int dimensionworld
Definition geometricentityset.hh:382
ctype ctype
Definition geometricentityset.hh:387
const Entity & entity(std::size_t index) const
get an entity from an index
Definition geometricentityset.hh:422
ProcessGeometricEntitySet(std::vector< Entity > &&entities)
Constructor from a vector of process partition entities.
Definition geometricentityset.hh:392
std::size_t size() const
the number of entities in this set
Definition geometricentityset.hh:398
int rank(std::size_t index) const
get the rank owning the entity with the given index
Definition geometricentityset.hh:428
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition geometricentityset.hh:410
std::size_t index(const Entity &e) const
get an entities index
Definition geometricentityset.hh:416
An interface for a geometric entity set with a single geometry.
Definition geometricentityset.hh:358
A map from indices to entities using grid entity seeds.
Definition common/pdesolver.hh:24