DUNE PDELab (git)

indexidset.hh
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>
15#include <dune/grid/concepts/entity.hh>
16
17namespace Dune::Concept {
18namespace Impl {
19
20 template<class IS, int codim>
21 concept IndexSetEntityCodim = Entity<typename IS::template Codim<codim>::Entity> &&
22 requires(const IS is, int i, unsigned int cc, const typename IS::template Codim<codim>::Entity& entity)
23 {
24 { is.template index<codim>(entity) } -> std::same_as<typename IS::IndexType>;
25 { is.index(entity) } -> std::same_as<typename IS::IndexType>;
26 { is.template subIndex<codim>(entity,i,cc) } -> std::same_as<typename IS::IndexType>;
27 { is.subIndex(entity,i,cc) } -> std::same_as<typename IS::IndexType>;
28 { is.contains(entity) } -> std::convertible_to<bool>;
29 };
30
31 template<class IS, std::size_t... c>
32 void indexSetEntityAllCodims(std::integer_sequence<std::size_t,c...>)
33 requires (IndexSetEntityCodim<IS,int(c)> &&...);
34
35} // end namespace Impl
36
43template<class IS>
44concept IndexSet = requires(const IS is, Dune::GeometryType type, int codim)
45{
46 { IS::dimension } -> std::convertible_to<int>;
47
48 requires RandomAccessContainer<typename IS::Types>;
49 { is.types(codim) } -> std::same_as<typename IS::Types>;
50
51 requires std::integral<typename IS::IndexType>;
52 { is.size(type) } -> std::convertible_to<typename IS::IndexType>;
53 { is.size(codim) } -> std::convertible_to<typename IS::IndexType>;
54} &&
55Impl::IndexSetEntityCodim<IS,0> &&
57 Impl::indexSetEntityAllCodims<IS>(range(from, to).to_integer_sequence());
58};
59
60namespace Impl {
61
62 template<class IS, int codim>
63 concept IdSetEntityCodim = Entity<typename IS::template Codim<codim>::Entity> &&
64 requires(const IS is, const typename IS::template Codim<codim>::Entity& entity)
65 {
66 { is.template id<codim>(entity) } -> std::same_as<typename IS::IdType>;
67 { is.id(entity) } -> std::same_as<typename IS::IdType>;
68 };
69
70 template<class IS, std::size_t... c>
71 void idSetEntityAllCodims(std::integer_sequence<std::size_t,c...>)
72 requires (IdSetEntityCodim<IS,int(c)> &&...);
73
74} // end namespace Impl
75
82template<class IS>
83concept IdSet = requires(const IS is, const typename IS::template Codim<0>::Entity& entity, int i, unsigned int cc)
84{
85 requires Hashable<typename IS::IdType>;
86 requires std::totally_ordered<typename IS::IdType>;
87 { is.subId(entity,i,cc) } -> std::same_as<typename IS::IdType>;
88} &&
89Impl::IdSetEntityCodim<IS,0> &&
91 Impl::idSetEntityAllCodims<IS>(range(from, to).to_integer_sequence());
92};
93
94} // end namespace Dune::Concept
95
96#endif // DUNE_GRID_CONCEPTS_INDEX_SET_HH
Wrapper class for entities.
Definition: entity.hh:66
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Model of an id set.
Definition: indexidset.hh:83
Model of an index set.
Definition: indexidset.hh:44
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:29
Namespace for concepts.
Definition: concept.hh:34
Static tag representing a codimension.
Definition: dimension.hh:24
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)