dune-grid  2.11
concepts/indexidset.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GRID_CONCEPTS_INDEX_SET_HH
6 #define DUNE_GRID_CONCEPTS_INDEX_SET_HH
7 
8 #include <concepts>
9 #include <type_traits>
10 
11 #include <dune/common/indices.hh>
12 #include <dune/common/concepts/container.hh>
13 #include <dune/common/concepts/hashable.hh>
14 #include <dune/geometry/type.hh>
16 
17 namespace Dune::Concept {
18 namespace Impl {
19 
20  // only check if Codim<cd>::Entity exists
21  template<class IS, int codim>
22  concept IndexSetEntityCodim =
23  (
24  !requires
25  {
26  typename IS::template Codim<codim>::Entity;
27  }
28  ) || (
29  Entity<typename IS::template Codim<codim>::Entity> &&
30  requires(const IS is, int i, unsigned int cc, const typename IS::template Codim<codim>::Entity& entity)
31  {
32  { is.template index<codim>(entity) } -> std::same_as<typename IS::IndexType>;
33  { is.index(entity) } -> std::same_as<typename IS::IndexType>;
34  { is.template subIndex<codim>(entity,i,cc) } -> std::same_as<typename IS::IndexType>;
35  { is.subIndex(entity,i,cc) } -> std::same_as<typename IS::IndexType>;
36  { is.contains(entity) } -> std::convertible_to<bool>;
37  }
38  );
39 
40  template<class IS, std::size_t... c>
41  void indexSetEntityAllCodims(std::integer_sequence<std::size_t,c...>)
42  requires (IndexSetEntityCodim<IS,int(c)> &&...);
43 
44 } // end namespace Impl
45 
54 template<class IS>
55 concept IndexSet = requires(const IS is, Dune::GeometryType type, int codim)
56 {
57  { IS::dimension } -> std::convertible_to<int>;
58 
59  requires RandomAccessContainer<typename IS::Types>;
60  { is.types(codim) } -> std::convertible_to<typename IS::Types>;
61 
62  requires std::integral<typename IS::IndexType>;
63  { is.size(type) } -> std::convertible_to<typename IS::IndexType>;
64  { is.size(codim) } -> std::convertible_to<typename IS::IndexType>;
65 } &&
66 Impl::IndexSetEntityCodim<IS,0> &&
67 requires (index_constant<1> from, index_constant<IS::dimension+1> to) {
68  Impl::indexSetEntityAllCodims<IS>(range(from, to).to_integer_sequence());
69 };
70 
71 namespace Impl {
72 
73  // only check if Codim<cd>::Entity exists
74  template<class IS, int codim>
75  concept IdSetEntityCodim =
76  (
77  !requires
78  {
79  typename IS::template Codim<codim>::Entity;
80  }
81  ) || (
82  Entity<typename IS::template Codim<codim>::Entity> &&
83  requires(const IS is, const typename IS::template Codim<codim>::Entity& entity)
84  {
85  { is.template id<codim>(entity) } -> std::same_as<typename IS::IdType>;
86  { is.id(entity) } -> std::same_as<typename IS::IdType>;
87  }
88  );
89 
90  template<class IS, std::size_t... c>
91  void idSetEntityAllCodims(std::integer_sequence<std::size_t,c...>)
92  requires (IdSetEntityCodim<IS,int(c)> &&...);
93 
94 } // end namespace Impl
95 
104 template<class IS>
105 concept IdSet = requires(const IS is, const typename IS::template Codim<0>::Entity& entity, int i, unsigned int cc)
106 {
107  requires Hashable<typename IS::IdType>;
108  requires std::totally_ordered<typename IS::IdType>;
109  { is.subId(entity,i,cc) } -> std::same_as<typename IS::IdType>;
110 } &&
111 Impl::IdSetEntityCodim<IS,0> &&
112 requires (index_constant<1> from, index_constant<IS::dimension+1> to) {
113  Impl::idSetEntityAllCodims<IS>(range(from, to).to_integer_sequence());
114 };
115 
116 } // end namespace Dune::Concept
117 
118 #endif // DUNE_GRID_CONCEPTS_INDEX_SET_HH
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
Types types(int codim) const
obtain all geometry types of entities in domain
Definition: common/indexidset.hh:211
Index Set Interface base class.
Definition: common/grid.hh:348
IdType subId(const typename Codim< 0 >::Entity &e, int i, unsigned int codim) const
Get id of subentity i of co-dimension codim of a co-dimension 0 entity.
Definition: common/indexidset.hh:481
Definition: concepts/datahandle.hh:14
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:132
Id Set Interface.
Definition: common/grid.hh:349