3 #ifndef DUNE_GEOMETRY_TYPEINDEX_HH
4 #define DUNE_GEOMETRY_TYPEINDEX_HH
14 #include <dune/common/indices.hh>
15 #include <dune/common/hybridutilities.hh>
30 inline static constexpr std::size_t regular_size(std::size_t dim)
50 return (1 << dim) - ((1 << dim) >> 1);
59 inline static constexpr std::size_t
size(std::size_t dim)
62 return regular_size(dim) + 1;
73 return gt.
isNone() ? regular_size(gt.
dim()) : (gt.
id() >> 1);
78 return (
index == regular_size(dim)) ?
96 inline static constexpr std::size_t regular_offset(std::size_t dim)
103 return (1 << dim) >> 1;
111 inline static constexpr std::size_t
offset(std::size_t dim)
114 return regular_offset(dim) + dim;
123 inline static constexpr std::size_t
size(std::size_t maxdim)
145 template<
int dim,
class F>
146 static auto toGeometryTypeIdConstant(
const GeometryType& gt, F&& f) {
148 auto callWithId = [&](
auto index) {
150 return f(std::integral_constant<GeometryType::Id, id>{});
153 auto fallBack = [&]() {
return callWithId(Dune::Indices::_0); };
A unique label for each type of element that can occur in a grid.
constexpr GeometryType none(unsigned int dim)
Returns a GeometryType representing a singular of dimension dim.
Definition: type.hh:479
Definition: affinegeometry.hh:19
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
constexpr Id toId() const
Create an Id representation of this GeometryType.
Definition: type.hh:219
constexpr unsigned int dim() const
Return dimension of the type.
Definition: type.hh:369
constexpr unsigned int id() const
Return the topology id of the type.
Definition: type.hh:374
constexpr bool isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:364
Compute per-dimension indices for geometry types.
Definition: typeindex.hh:23
static constexpr std::size_t size(std::size_t dim)
Compute total number of geometry types for the given dimension.
Definition: typeindex.hh:59
static constexpr GeometryType type(std::size_t dim, std::size_t index)
compute the geometry type for the given local index and dimension
Definition: typeindex.hh:77
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type within its dimension.
Definition: typeindex.hh:71
Compute indices for geometry types, taking the dimension into account.
Definition: typeindex.hh:88
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:136
static constexpr std::size_t offset(std::size_t dim)
Compute the starting index for a given dimension including irregular geometry types.
Definition: typeindex.hh:111
static constexpr std::size_t size(std::size_t maxdim)
Compute total number of geometry types up to and including the given dimension.
Definition: typeindex.hh:123