dune-grid  2.11
concepts/entity.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_CONCEPT_ENTITY_HH
6 #define DUNE_GRID_CONCEPT_ENTITY_HH
7 
8 #include <concepts>
9 #include <utility>
10 
11 #include <dune/common/rangeutilities.hh>
12 #include <dune/geometry/type.hh>
16 
17 namespace Dune::Concept {
18 
24 template<class S>
25 concept EntitySeed = std::semiregular<S> && requires(const S seed)
26 {
27  { S::codimension } -> std::convertible_to<int>;
28  { seed.isValid() } -> std::convertible_to<bool>;
29 };
30 
31 static_assert(EntitySeed< Archetypes::EntitySeed<0> >);
32 
33 
39 template<class E>
40 concept EntityGeneral = std::regular<E> &&
43 requires(const E e, unsigned int codim)
44 {
45  requires E::mydimension == (E::dimension - E::codimension);
46  { e.level() } -> std::convertible_to<int>;
47  { e.partitionType() } -> std::same_as<Dune::PartitionType>;
48  { e.geometry() } -> std::same_as<typename E::Geometry>;
49  { e.type() } -> std::same_as<Dune::GeometryType>;
50  { e.subEntities(codim) } -> std::convertible_to<unsigned int>;
51  { e.seed() } -> std::same_as<typename E::EntitySeed>;
52 };
53 
54 static_assert(EntityGeneral< Archetypes::Entity<2,0> >);
55 
56 
57 namespace Impl {
58 
59  // only check if Codim<cd>::Entity exists
60  template<class E, int codim>
61  concept EntityCodimExtended =
62  (
63  !requires
64  {
65  typename E::template Codim<codim>::Entity;
66  }
67  ) || (
68  EntityGeneral<typename E::template Codim<codim>::Entity> &&
69  requires(const E e, int subEntity)
70  {
71  { e.template subEntity<codim>(subEntity) } -> std::same_as<typename E::template Codim<codim>::Entity>;
72  }
73  );
74 
75  template<typename E, std::size_t... c>
76  void entityAllCodimsExtended(std::integer_sequence<std::size_t,c...>)
77  requires (EntityCodimExtended<E,int(c)> &&...);
78 
79 } // end namespace Impl
80 
88 template<class E>
89 concept EntityExtended = EntityGeneral<E> &&
91 requires(const E e, int maxLevel)
92 {
93  requires (E::codimension == 0);
94  { e.father() } -> std::same_as<E>;
95  { e.hasFather() } -> std::convertible_to<bool>;
96  { e.isLeaf() } -> std::convertible_to<bool>;
97  { e.isRegular() } -> std::convertible_to<bool>;
98  { e.geometryInFather() } -> std::same_as<typename E::LocalGeometry>;
99  { e.hbegin(maxLevel) } -> std::same_as<typename E::HierarchicIterator>;
100  { e.hend(maxLevel) } -> std::same_as<typename E::HierarchicIterator>;
101  { e.isNew() } -> std::convertible_to<bool>;
102  { e.mightVanish() } -> std::convertible_to<bool>;
103  { e.hasBoundaryIntersections() } -> std::convertible_to<bool>;
104 
106 } &&
107 Impl::EntityCodimExtended<E,0> &&
108 requires (index_constant<1> from, index_constant<E::dimension+1> to) {
109  Impl::entityAllCodimsExtended<E>(range(from, to).to_integer_sequence());
110 };
111 
118 template<class E>
119 concept Entity = EntityGeneral<E> && ((E::codimension != 0) || EntityExtended<E>);
120 
121 } // end namespace Dune::Concept
122 
123 
124 #endif // DUNE_GRID_CONCEPT_ENTITY_HH
Wrapper class for geometries.
Definition: common/geometry.hh:70
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:25
concept EntityExtended
Model of a grid entity with extended requirements for codimension 0.
Definition: concepts/entity.hh:89
concept EntityGeneral
Model of a grid entity for any codimension.
Definition: concepts/entity.hh:40
Definition: concepts/datahandle.hh:14
Wrapper class for entities.
Definition: common/entity.hh:65
bool isValid() const
check whether it is safe to create an Entity from this Seed
Definition: common/entityseed.hh:49