AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
DefaultGridView.hpp
1#pragma once
2
3#include <dune/common/typetraits.hh>
4#include <dune/common/exceptions.hh>
5#include <dune/common/std/type_traits.hh>
6
7#include <dune/grid/common/capabilities.hh>
8#include <dune/grid/common/gridview.hh>
9
10namespace AMDiS
11{
12 /*
13 * NOTE: this is a modification of dune/grid/common/defaultgridview.hh since we
14 * want all implementation specific methods to be put into the grid class and not
15 * into the entity class. See ibegin(), iend().
16 */
17
18 template <class GridImp>
19 class DefaultLevelGridView;
20
21 template <class GridImp>
22 class DefaultLeafGridView;
23
24
25 template <class GridImp>
27 {
29
31 using Grid = std::remove_const_t<GridImp>;
32
34 using IndexSet = typename Grid::Traits::LevelIndexSet;
35
37 using Intersection = typename Grid::Traits::LevelIntersection;
38
40 using IntersectionIterator = typename Grid::Traits::LevelIntersectionIterator;
41
42 template <class G>
43 using CollectiveCommunication_t = typename G::Traits::Communication;
44 using CollectiveCommunication = Dune::Std::detected_t<CollectiveCommunication_t, Grid>;
45
47 template <class G>
48 using Communication_t = typename G::Traits::Communication;
49 using Communication = Dune::Std::detected_or_t<CollectiveCommunication, Communication_t, Grid>;
50
51 template <int cd>
52 struct Codim
53 {
54 using Entity = typename Grid::Traits::template Codim<cd>::Entity;
55 using Geometry = typename Grid::template Codim<cd>::Geometry;
56 using LocalGeometry = typename Grid::template Codim<cd>::LocalGeometry;
57
59 template <Dune::PartitionIteratorType pit>
60 struct Partition
61 {
64 };
65
66 using Iterator = typename Partition<Dune::All_Partition>::Iterator;
67 };
68
69 enum { conforming = Dune::Capabilities::isLevelwiseConforming<Grid>::v };
70 };
71
72
73 template <class GridImp>
75 {
76 public:
78 using Grid = typename Traits::Grid;
79 using IndexSet = typename Traits::IndexSet;
80 using Intersection = typename Traits::Intersection;
81 using IntersectionIterator = typename Traits::IntersectionIterator;
82 using CollectiveCommunication = typename Traits::CollectiveCommunication;
83 using Communication = typename Traits::Communication;
84
85 template <int cd>
86 using Codim = typename Traits::template Codim<cd>;
87
88 enum { conforming = Traits::conforming };
89
90 public:
91 DefaultLevelGridView(Grid const& grid, int level)
92 : grid_(&grid)
93 , level_(level)
94 {}
95
97 Grid const& grid() const
98 {
99 assert(grid_);
100 return *grid_;
101 }
102
104 IndexSet const& indexSet() const
105 {
106 return grid().levelIndexSet(level_);
107 }
108
110 int size(int codim) const
111 {
112 return grid().size(level_, codim);
113 }
114
116 int size(Dune::GeometryType const& type) const
117 {
118 return grid().size(level_, type);
119 }
120
122 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
123 typename Codim<cd>::template Partition<pit>::Iterator begin() const
124 {
125 return grid().template lbegin<cd, pit>(level_);
126 }
127
129 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
130 typename Codim<cd>::template Partition<pit>::Iterator end() const
131 {
132 return grid().template lend<cd, pit>(level_);
133 }
134
136 IntersectionIterator ibegin(typename Codim<0>::Entity const& entity) const
137 {
138 return grid().ilevelbegin(entity);
139 }
140
142 IntersectionIterator iend(typename Codim<0>::Entity const& entity) const
143 {
144 return grid().ilevelend(entity);
145 }
146
148 bool isConforming() const
149 {
150 return grid().isLevelwiseConforming(level_);
151 }
152
154 Communication const& comm() const
155 {
156 return grid().comm();
157 }
158
160 int overlapSize(int codim) const
161 {
162 return grid().overlapSize(level_, codim);
163 }
164
166 int ghostSize(int codim) const
167 {
168 return grid().ghostSize(level_, codim);
169 }
170
172 template <class DataHandleImp, class DataType>
173 void communicate(Dune::CommDataHandleIF<DataHandleImp, DataType>& data,
174 Dune::InterfaceType iftype,
175 Dune::CommunicationDirection dir) const
176 {
177 return grid().communicate(data, iftype, dir, level_);
178 }
179
180 private:
181 Grid const* grid_;
182 int level_;
183 };
184
185
186 template <class GridImp>
188 {
190
192 using Grid = std::remove_const_t<GridImp>;
193
195 using IndexSet = typename Grid::Traits::LeafIndexSet;
196
198 using Intersection = typename Grid::Traits::LeafIntersection;
199
201 using IntersectionIterator = typename Grid::Traits::LeafIntersectionIterator;
202
203 template <class G>
204 using CollectiveCommunication_t = typename G::Traits::Communication;
205 using CollectiveCommunication = Dune::Std::detected_t<CollectiveCommunication_t, Grid>;
206
208 template <class G>
209 using Communication_t = typename G::Traits::Communication;
210 using Communication = Dune::Std::detected_or_t<CollectiveCommunication, Communication_t, Grid>;
211
212 template <int cd>
213 struct Codim
214 {
215 using Entity = typename Grid::Traits::template Codim<cd>::Entity;
216 using Geometry = typename Grid::template Codim<cd>::Geometry;
217 using LocalGeometry = typename Grid::template Codim<cd>::LocalGeometry;
218
220 template <Dune::PartitionIteratorType pit>
222 {
225 };
226
227 using Iterator = typename Partition<Dune::All_Partition>::Iterator;
228 };
229
230 enum { conforming = Dune::Capabilities::isLeafwiseConforming<Grid>::v };
231 };
232
233
234 template <class GridImp>
236 {
237 public:
239 using Grid = typename Traits::Grid;
240 using IndexSet = typename Traits::IndexSet;
241 using Intersection = typename Traits::Intersection;
242 using IntersectionIterator = typename Traits::IntersectionIterator;
243 using CollectiveCommunication = typename Traits::CollectiveCommunication;
244 using Communication = typename Traits::Communication;
245
246 template <int cd>
247 using Codim = typename Traits::template Codim<cd>;
248
249 enum { conforming = Traits::conforming };
250
251 public:
252 DefaultLeafGridView(Grid const& grid)
253 : grid_(&grid)
254 {}
255
257 Grid const& grid() const
258 {
259 assert(grid_);
260 return *grid_;
261 }
262
264 IndexSet const& indexSet() const
265 {
266 return grid().leafIndexSet();
267 }
268
270 int size(int codim) const
271 {
272 return grid().size(codim);
273 }
274
276 int size(Dune::GeometryType const& type) const
277 {
278 return grid().size(type);
279 }
280
281
283 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
284 typename Codim<cd>::template Partition<pit>::Iterator begin() const
285 {
286 return grid().template leafbegin<cd, pit>();
287 }
288
290 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
291 typename Codim<cd>::template Partition<pit>::Iterator end() const
292 {
293 return grid().template leafend<cd, pit>();
294 }
295
297 IntersectionIterator ibegin(typename Codim<0>::Entity const& entity) const
298 {
299 return grid().ileafbegin(entity);
300 }
301
303 IntersectionIterator iend(typename Codim<0>::Entity const& entity) const
304 {
305 return grid().ileafend(entity);
306 }
307
309 bool isConforming() const
310 {
311 return grid().isLeafwiseConforming();
312 }
313
315 Communication const& comm() const
316 {
317 return grid().comm();
318 }
319
321 int overlapSize(int codim) const
322 {
323 return grid().overlapSize(codim);
324 }
325
327 int ghostSize(int codim) const
328 {
329 return grid().ghostSize(codim);
330 }
331
333 template <class DataHandleImp, class DataType>
334 void communicate(Dune::CommDataHandleIF<DataHandleImp, DataType>& data,
335 Dune::InterfaceType iftype,
336 Dune::CommunicationDirection dir) const
337 {
338 return grid().communicate(data, iftype, dir);
339 }
340
341 private:
342 Grid const* grid_;
343 };
344
345} // end namespace AMDiS
Definition: DefaultGridView.hpp:236
IntersectionIterator ibegin(typename Codim< 0 >::Entity const &entity) const
Obtain begin intersection iterator with respect to this view.
Definition: DefaultGridView.hpp:297
IndexSet const & indexSet() const
Obtain the index set.
Definition: DefaultGridView.hpp:264
int size(Dune::GeometryType const &type) const
Obtain number of entities with a given geometry type.
Definition: DefaultGridView.hpp:276
void communicate(Dune::CommDataHandleIF< DataHandleImp, DataType > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate data on this view.
Definition: DefaultGridView.hpp:334
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: DefaultGridView.hpp:327
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: DefaultGridView.hpp:321
Codim< cd >::template Partition< pit >::Iterator end() const
Obtain end iterator for this view.
Definition: DefaultGridView.hpp:291
bool isConforming() const
Return true if current state of grid view represents a conforming grid.
Definition: DefaultGridView.hpp:309
IntersectionIterator iend(typename Codim< 0 >::Entity const &entity) const
Obtain end intersection iterator with respect to this view.
Definition: DefaultGridView.hpp:303
Communication const & comm() const
Obtain collective communication object.
Definition: DefaultGridView.hpp:315
Grid const & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: DefaultGridView.hpp:257
Codim< cd >::template Partition< pit >::Iterator begin() const
Obtain begin iterator for this view.
Definition: DefaultGridView.hpp:284
int size(int codim) const
Obtain number of entities in a given codimension.
Definition: DefaultGridView.hpp:270
Definition: DefaultGridView.hpp:75
IntersectionIterator ibegin(typename Codim< 0 >::Entity const &entity) const
Obtain begin intersection iterator with respect to this view.
Definition: DefaultGridView.hpp:136
IndexSet const & indexSet() const
Obtain the index set.
Definition: DefaultGridView.hpp:104
int size(Dune::GeometryType const &type) const
Obtain number of entities with a given geometry type.
Definition: DefaultGridView.hpp:116
void communicate(Dune::CommDataHandleIF< DataHandleImp, DataType > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate data on this view.
Definition: DefaultGridView.hpp:173
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: DefaultGridView.hpp:166
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: DefaultGridView.hpp:160
Codim< cd >::template Partition< pit >::Iterator end() const
Obtain end iterator for this view.
Definition: DefaultGridView.hpp:130
bool isConforming() const
Return true if current state of grid view represents a conforming grid.
Definition: DefaultGridView.hpp:148
IntersectionIterator iend(typename Codim< 0 >::Entity const &entity) const
Obtain end intersection iterator with respect to this view.
Definition: DefaultGridView.hpp:142
Communication const & comm() const
Obtain collective communication object.
Definition: DefaultGridView.hpp:154
Grid const & grid() const
Obtain a const reference to the underlying hierarchic grid.
Definition: DefaultGridView.hpp:97
Codim< cd >::template Partition< pit >::Iterator begin() const
Obtain begin iterator for this view.
Definition: DefaultGridView.hpp:123
int size(int codim) const
Obtain number of entities in a given codimension.
Definition: DefaultGridView.hpp:110
Define types needed to iterate over entities of a given partition type.
Definition: DefaultGridView.hpp:222
typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition: DefaultGridView.hpp:224
Definition: DefaultGridView.hpp:214
Definition: DefaultGridView.hpp:188
std::remove_const_t< GridImp > Grid
type of the grid
Definition: DefaultGridView.hpp:192
typename Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition: DefaultGridView.hpp:198
typename Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition: DefaultGridView.hpp:195
typename G::Traits::Communication Communication_t
type of the collective communication
Definition: DefaultGridView.hpp:209
typename Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: DefaultGridView.hpp:201
Define types needed to iterate over entities of a given partition type.
Definition: DefaultGridView.hpp:61
typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: DefaultGridView.hpp:63
Definition: DefaultGridView.hpp:53
Definition: DefaultGridView.hpp:27
std::remove_const_t< GridImp > Grid
type of the grid
Definition: DefaultGridView.hpp:31
typename Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition: DefaultGridView.hpp:37
typename G::Traits::Communication Communication_t
type of the collective communication
Definition: DefaultGridView.hpp:48
typename Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: DefaultGridView.hpp:40
typename Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition: DefaultGridView.hpp:34