1#ifndef DUNE_GEOMETRY_TYPEINDEXSET_HH
2#define DUNE_GEOMETRY_TYPEINDEXSET_HH
24 template<
int dim,
bool regular = false >
33 inline static constexpr std::size_t
size () noexcept
35 return (1 << dim) - ((1 << dim) >> 1);
38 inline static constexpr std::size_t index (
const GeometryType &type )
noexcept
40 return (type.id() >> 1);
45 return ((type.dim() == dim) && !type.isNone());
48 inline static GeometryType type ( std::size_t index )
noexcept
50 return GeometryType(
static_cast< unsigned int >( index ) << 1, dim );
55 class LocalGeometryTypeIndexSet< dim, false >
58 typedef LocalGeometryTypeIndexSet< dim, true > RegularTypeIndexSet;
61 inline static constexpr std::size_t
size () noexcept
63 return (RegularTypeIndexSet::size() + 1);
66 inline static constexpr std::size_t index (
const GeometryType &type )
noexcept
68 return (type.isNone() ? RegularTypeIndexSet::size() : type.id() >> 1);
71 inline static constexpr bool contains (
const GeometryType &type )
noexcept
73 return (type.dim() == dim);
76 inline static GeometryType type ( std::size_t index )
noexcept
78 return (index < RegularTypeIndexSet::size() ? RegularTypeIndexSet::type( index ) :
GeometryType( 0, dim,
true ));
94 template<
int maxdim,
bool regular = false >
97 template<
int maxdim >
103 inline static constexpr std::size_t
size () noexcept
105 return (1 << maxdim);
108 inline static constexpr std::size_t index (
const GeometryType &type )
noexcept
110 return ((1 << type.dim()) + type.id()) >> 1;
115 return ((type.dim() <= maxdim) && !type.isNone());
118 inline static GeometryType type ( std::size_t index )
noexcept
120 return GeometryType( (index << 1) & ~(1 << dim( index )), dim( index ) );
124 inline static constexpr int dim ( std::size_t index,
int d = maxdim )
126 return ((d <= 0) || ((index & (1 << (d-1))) != 0) ? d : dim( index, d-1 ));
130 template<
int maxdim >
131 class GlobalGeometryTypeIndexSet< maxdim, false >
134 typedef GlobalGeometryTypeIndexSet< maxdim, true > RegularTypeIndexSet;
137 inline static constexpr std::size_t
size () noexcept
139 return RegularTypeIndexSet::size() + (maxdim + 1);
142 inline static constexpr std::size_t index (
const GeometryType &type )
noexcept
144 return (type.isNone() ? RegularTypeIndexSet::size() + type.dim() : RegularTypeIndexSet::index( type ));
147 inline static constexpr bool contains (
const GeometryType &type )
noexcept
149 return (type.dim() <= maxdim);
152 inline static GeometryType type ( std::size_t index )
noexcept
154 return (index < RegularTypeIndexSet::size() ? RegularTypeIndexSet::type( index ) :
GeometryType( 0,
static_cast< int >( index - RegularTypeIndexSet::size() ),
true ));
170 template<
unsigned int topologyId,
int dim >
176 inline static constexpr std::size_t size ()
noexcept
181 inline static constexpr std::size_t index (
const GeometryType &type )
noexcept
186 inline static constexpr bool contains (
const GeometryType &type )
noexcept
191 inline static GeometryType type ( std::size_t index )
noexcept
202 template<
class TypeIndexSet >
207 bool operator== (
const Iterator &other )
const {
return (index == other.index); }
208 bool operator!= (
const Iterator &other )
const {
return (index != other.index); }
210 GeometryType operator* ()
const {
return TypeIndexSet::type( index ); }
212 Iterator &operator++ () { ++index;
return *
this; }
217 Iterator begin ()
const {
return Iterator{ 0 }; }
218 Iterator end ()
const {
return Iterator{ TypeIndexSet::size() }; }
Please doc me.
Definition: typeindexset.hh:95
Please doc me.
Definition: typeindexset.hh:25
Please doc me.
Definition: typeindexset.hh:172
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:238
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:260
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
A unique label for each type of element that can occur in a grid.