dune-grid  2.11
concepts/grid.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_GRID_HH
6 #define DUNE_GRID_CONCEPTS_GRID_HH
7 
8 #include <concepts>
9 #include <cstddef>
10 #include <type_traits>
11 #include <utility>
12 
13 #include <dune/common/indices.hh>
14 #include <dune/geometry/type.hh>
25 
26 
35 namespace Dune::Concept {
36 namespace Impl {
37 
38  template<class G, int codim, Dune::PartitionIteratorType partition>
39  concept GridCodimPartition =
40  EntityIterator<typename G::template Codim<codim>::template Partition<partition>::LevelIterator> &&
41  EntityIterator<typename G::template Codim<codim>::template Partition<partition>::LeafIterator>;
42 
43  template<class G, int codim>
44  concept GridCodimAllPartitions =
45  (
47  ) || (
48  GridCodimPartition<G,codim,Dune::PartitionIteratorType::Interior_Partition> &&
49  GridCodimPartition<G,codim,Dune::PartitionIteratorType::InteriorBorder_Partition> &&
50  GridCodimPartition<G,codim,Dune::PartitionIteratorType::Overlap_Partition> &&
51  GridCodimPartition<G,codim,Dune::PartitionIteratorType::OverlapFront_Partition> &&
52  GridCodimPartition<G,codim,Dune::PartitionIteratorType::All_Partition> &&
53  GridCodimPartition<G,codim,Dune::PartitionIteratorType::Ghost_Partition>
54  );
55 
56  template<class G, int codim>
57  concept GridCodim =
58  (
60  ) || (
62  Geometry<typename G::template Codim<codim>::LocalGeometry> &&
65  std::same_as<typename G::template Codim<codim>::Entity, typename G::template Codim<0>::Entity::template Codim<codim>::Entity> &&
68  requires(const G cg, const typename G::template Codim<codim>::EntitySeed& seed)
69  {
71 
73  requires(G g, Archetypes::CommDataHandle<std::byte>& handle)
74  {
75  { g.loadBalance(handle) } -> std::convertible_to<bool>;
76  };
77  } && GridCodimAllPartitions<G,codim>
78  );
79 
80  template<class G, std::size_t... c>
81  void gridAllCodims(std::index_sequence<c...>)
82  requires (GridCodim<G,int(c)> &&...);
83 
84 } // end namespace Impl
85 
86 
108 template<class G>
109 concept Grid =
120 requires(const G cg, int level, int codim, Dune::GeometryType type)
121 {
122  // static constants
123  { G::dimension } -> std::convertible_to<int>;
124  { G::dimensionworld } -> std::convertible_to<int>;
125 
126  // type and concepts requirements
127  requires std::same_as<G,typename G::LeafGridView::Grid>;
128  requires std::same_as<G,typename G::LevelGridView::Grid>;
129  typename G::ctype;
130  typename G::HierarchicIterator;
131 
132  // const methods
133  { cg.maxLevel() } -> std::convertible_to<int>;
134  { cg.size(level, codim) } -> std::convertible_to<int>;
135  { cg.size(codim) } -> std::convertible_to<int>;
136  { cg.size(level, type) } -> std::convertible_to<int>;
137  { cg.size(type) } -> std::convertible_to<int>;
138  { cg.numBoundarySegments() } -> std::convertible_to<std::size_t>;
139  { cg.levelGridView(level) } -> std::same_as<typename G::LevelGridView>;
140  { cg.leafGridView() } -> std::same_as<typename G::LeafGridView>;
141  { cg.globalIdSet() } -> std::same_as<const typename G::GlobalIdSet&>;
142  { cg.localIdSet() } -> std::same_as<const typename G::LocalIdSet&>;
143  { cg.levelIndexSet(level) } -> std::same_as<const typename G::LevelIndexSet&>;
144  { cg.leafIndexSet() } -> std::same_as<const typename G::LeafIndexSet&>;
145  { cg.comm() } -> std::convertible_to<typename G::Communication>;
146 
147  // mutable methods
148  requires requires(G g, int refCount, const typename G::template Codim<0>::Entity& entity)
149  {
150  { g.mark(refCount,entity) } -> std::convertible_to<bool>;
151  { g.getMark(entity) } -> std::convertible_to<int>;
152  { g.preAdapt() } -> std::convertible_to<bool>;
153  { g.adapt() } -> std::convertible_to<bool>;
154  { g.loadBalance() } -> std::convertible_to<bool>;
155  g.globalRefine(refCount);
156  g.postAdapt();
157  };
158 } &&
159 Impl::GridCodim<G,0> &&
160 requires (index_constant<1> from, index_constant<G::dimension+1> to) {
161  Impl::gridAllCodims<G>(range(from, to).to_integer_sequence());
162 };
163 
164 } // end namespace Dune::Concept
165 
166 #endif // DUNE_GRID_CONCEPTS_GRID_HH
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
Index Set Interface base class.
Definition: common/grid.hh:348
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:375
EntitySeed()
Construct an empty (i.e. isValid() == false) seed.
Definition: common/entityseed.hh:40
Specialize with &#39;true&#39; for all codims that a grid implements entities for. (default=false) ...
Definition: common/capabilities.hh:57
Geometry(const Implementation &impl)
copy constructor from implementation
Definition: common/geometry.hh:384
Entity()
Definition: common/entity.hh:181
Grid view abstract base class.
Definition: common/gridview.hh:65
Definition: concepts/datahandle.hh:14
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:347
specialize with &#39;true&#39; for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: common/capabilities.hh:73
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:28
specialize with &#39;true&#39; for all codims that a grid can communicate data on (default=false) ...
Definition: common/capabilities.hh:96
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:132
A set of traits classes to store static information about grid implementation.
concept EntitySeed
Model of an entity seed.
Definition: concepts/entity.hh:25
Id Set Interface.
Definition: common/grid.hh:349