Dune Core Modules (unstable)

gridview.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_GRIDVIEW_HH
6#define DUNE_GRID_CONCEPTS_GRIDVIEW_HH
7
8#include <concepts>
9#include <cstddef>
10#include <utility>
11
13#include <dune/grid/common/gridenums.hh>
14#include <dune/grid/concepts/entityiterator.hh>
15#include <dune/grid/concepts/geometry.hh>
16#include <dune/grid/concepts/indexidset.hh>
17#include <dune/grid/concepts/intersection.hh>
18#include <dune/grid/concepts/intersectioniterator.hh>
19#include <dune/grid/concepts/archetypes/datahandle.hh>
20
21namespace Dune::Concept {
22namespace Impl {
23
24 template<class GV, int codim, Dune::PartitionIteratorType partition>
25 concept GridViewPartition =
26 EntityIterator<typename GV::template Codim<codim>::template Partition<partition>::Iterator> &&
27 requires(const GV gv)
28 {
29 { gv.template begin<codim,partition>() } -> std::same_as<typename GV::template Codim<codim>::template Partition<partition>::Iterator>;
30 { gv.template end<codim,partition>() } -> std::same_as<typename GV::template Codim<codim>::template Partition<partition>::Iterator>;
31 };
32
33 template<class GV, int codim>
34 concept GridViewAllPartitions =
35 GridViewPartition<GV,codim,Dune::PartitionIteratorType::InteriorBorder_Partition> &&
36 GridViewPartition<GV,codim,Dune::PartitionIteratorType::Overlap_Partition> &&
37 GridViewPartition<GV,codim,Dune::PartitionIteratorType::OverlapFront_Partition> &&
38 GridViewPartition<GV,codim,Dune::PartitionIteratorType::All_Partition> &&
39 GridViewPartition<GV,codim,Dune::PartitionIteratorType::Ghost_Partition>;
40
41 template<class GV, int codim>
42 concept GridViewCodim =
44 Geometry<typename GV::template Codim<codim>::LocalGeometry> &&
45 EntityIterator<typename GV::template Codim<codim>::Iterator> &&
46 requires(const GV gv)
47 {
48 { gv.template begin<codim>() } -> std::same_as<typename GV::template Codim<codim>::Iterator>;
49 { gv.template end<codim>() } -> std::same_as<typename GV::template Codim<codim>::Iterator>;
50 } && GridViewAllPartitions<GV,codim>;
51
52 template<class GV, class Grid, int codim>
54 void requireGridViewCodim()
55 requires GridViewCodim<GV,codim> {}
56
57 template<class GV, class Grid, int codim>
59 void requireGridViewCodim() {}
60
61 template <class GV, std::size_t... c>
62 void gridViewAllCodims(std::index_sequence<c...>)
63 requires requires {
64 (requireGridViewCodim<GV,typename GV::Grid,int(c)>(),...);
65 };
66
67} // end namespace Impl
68
74template<class GV>
75concept GridView = std::copyable<GV> &&
79requires(const GV gv, int codim, Dune::GeometryType type)
80{
81 typename GV::Traits;
82 typename GV::ctype;
83 { GV::conforming } -> std::convertible_to<bool>;
84 { GV::dimension } -> std::convertible_to<int>;
85 { GV::dimensionworld } -> std::convertible_to<int>;
86 { gv.grid() } -> std::same_as<const typename GV::Grid&>;
87 { gv.indexSet() } -> std::same_as<const typename GV::IndexSet&>;
88 { gv.size(codim) } -> std::convertible_to<int>;
89 { gv.size(type) } -> std::convertible_to<int>;
90 { gv.comm() } -> std::convertible_to<typename GV::Communication>;
91 { gv.overlapSize(codim) } -> std::convertible_to<int>;
92 { gv.ghostSize(codim) } -> std::convertible_to<int>;
93
94 requires requires(Archetypes::CommDataHandle<std::byte>& handle,
96 {
97 gv.communicate(handle, iface, dir);
98 };
99} &&
100(
102 requires(const GV gv, const typename GV::template Codim<0>::Entity& entity)
103 {
104 { gv.ibegin(entity) } -> std::same_as<typename GV::IntersectionIterator>;
105 { gv.iend(entity) } -> std::same_as<typename GV::IntersectionIterator>;
106 }
107) &&
108Impl::GridViewCodim<GV,0> &&
109requires (index_constant<1> from, index_constant<GV::dimension+1> to) {
110 Impl::gridViewAllCodims<GV>(range(from, to).to_integer_sequence());
111};
112
113} // end namespace Dune::Concept
114
115#endif // DUNE_GRID_CONCEPTS_GRIDVIEW_HH
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Geometry(const Implementation &impl)
copy constructor from implementation
Definition: geometry.hh:384
A set of traits classes to store static information about grid implementation.
Model of a grid view.
Definition: gridview.hh:75
Model of an index set.
Definition: indexidset.hh:55
Model of an intersection iterator.
Definition: intersectioniterator.hh:21
Model of an intersection.
Definition: intersection.hh:23
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
free standing function for setting up a range based for loop over an integer range for (auto i: range...
Definition: rangeutilities.hh:288
Namespace for concepts.
Definition: concept.hh:33
specialize with 'true' for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: capabilities.hh:74
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jan 9, 23:34, 2026)