AMDiS 2.11-git
The Adaptive Multi-Dimensional Simulation Toolbox
 
Loading...
Searching...
No Matches
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
43 using Communication = typename Grid::Traits::Communication;
44
45 template <int cd>
46 struct Codim
47 {
48 using Entity = typename Grid::Traits::template Codim<cd>::Entity;
49 using Geometry = typename Grid::template Codim<cd>::Geometry;
50 using LocalGeometry = typename Grid::template Codim<cd>::LocalGeometry;
51
53 template <Dune::PartitionIteratorType pit>
54 struct Partition
55 {
58 };
59
60 using Iterator = typename Partition<Dune::All_Partition>::Iterator;
61 };
62
63 enum { conforming = Dune::Capabilities::isLevelwiseConforming<Grid>::v };
64 };
65
66
67 template <class GridImp>
69 {
70 public:
72 using Grid = typename Traits::Grid;
73 using IndexSet = typename Traits::IndexSet;
74 using Intersection = typename Traits::Intersection;
75 using IntersectionIterator = typename Traits::IntersectionIterator;
76 using Communication = typename Traits::Communication;
77
78 template <int cd>
79 using Codim = typename Traits::template Codim<cd>;
80
81 enum { conforming = Traits::conforming };
82
83 public:
84 DefaultLevelGridView(Grid const& grid, int level)
85 : grid_(&grid)
86 , level_(level)
87 {}
88
90 Grid const& grid() const
91 {
92 assert(grid_);
93 return *grid_;
94 }
95
97 IndexSet const& indexSet() const
98 {
99 return grid().levelIndexSet(level_);
100 }
101
103 int size(int codim) const
104 {
105 return grid().size(level_, codim);
106 }
107
109 int size(Dune::GeometryType const& type) const
110 {
111 return grid().size(level_, type);
112 }
113
115 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
116 typename Codim<cd>::template Partition<pit>::Iterator begin() const
117 {
118 return grid().template lbegin<cd, pit>(level_);
119 }
120
122 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
123 typename Codim<cd>::template Partition<pit>::Iterator end() const
124 {
125 return grid().template lend<cd, pit>(level_);
126 }
127
129 IntersectionIterator ibegin(typename Codim<0>::Entity const& entity) const
130 {
131 return grid().ilevelbegin(entity);
132 }
133
135 IntersectionIterator iend(typename Codim<0>::Entity const& entity) const
136 {
137 return grid().ilevelend(entity);
138 }
139
141 bool isConforming() const
142 {
143 return grid().isLevelwiseConforming(level_);
144 }
145
147 Communication const& comm() const
148 {
149 return grid().comm();
150 }
151
153 int overlapSize(int codim) const
154 {
155 return grid().overlapSize(level_, codim);
156 }
157
159 int ghostSize(int codim) const
160 {
161 return grid().ghostSize(level_, codim);
162 }
163
165 template <class DataHandleImp, class DataType>
166 void communicate(Dune::CommDataHandleIF<DataHandleImp, DataType>& data,
167 Dune::InterfaceType iftype,
168 Dune::CommunicationDirection dir) const
169 {
170 return grid().communicate(data, iftype, dir, level_);
171 }
172
173 private:
174 Grid const* grid_;
175 int level_;
176 };
177
178
179 template <class GridImp>
181 {
183
185 using Grid = std::remove_const_t<GridImp>;
186
188 using IndexSet = typename Grid::Traits::LeafIndexSet;
189
191 using Intersection = typename Grid::Traits::LeafIntersection;
192
194 using IntersectionIterator = typename Grid::Traits::LeafIntersectionIterator;
195
197 using Communication = typename Grid::Traits::Communication;
198
199 template <int cd>
200 struct Codim
201 {
202 using Entity = typename Grid::Traits::template Codim<cd>::Entity;
203 using Geometry = typename Grid::template Codim<cd>::Geometry;
204 using LocalGeometry = typename Grid::template Codim<cd>::LocalGeometry;
205
207 template <Dune::PartitionIteratorType pit>
209 {
212 };
213
214 using Iterator = typename Partition<Dune::All_Partition>::Iterator;
215 };
216
217 enum { conforming = Dune::Capabilities::isLeafwiseConforming<Grid>::v };
218 };
219
220
221 template <class GridImp>
223 {
224 public:
226 using Grid = typename Traits::Grid;
227 using IndexSet = typename Traits::IndexSet;
228 using Intersection = typename Traits::Intersection;
229 using IntersectionIterator = typename Traits::IntersectionIterator;
230 using Communication = typename Traits::Communication;
231
232 template <int cd>
233 using Codim = typename Traits::template Codim<cd>;
234
235 enum { conforming = Traits::conforming };
236
237 public:
238 DefaultLeafGridView(Grid const& grid)
239 : grid_(&grid)
240 {}
241
243 Grid const& grid() const
244 {
245 assert(grid_);
246 return *grid_;
247 }
248
250 IndexSet const& indexSet() const
251 {
252 return grid().leafIndexSet();
253 }
254
256 int size(int codim) const
257 {
258 return grid().size(codim);
259 }
260
262 int size(Dune::GeometryType const& type) const
263 {
264 return grid().size(type);
265 }
266
267
269 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
270 typename Codim<cd>::template Partition<pit>::Iterator begin() const
271 {
272 return grid().template leafbegin<cd, pit>();
273 }
274
276 template <int cd, Dune::PartitionIteratorType pit = Dune::All_Partition>
277 typename Codim<cd>::template Partition<pit>::Iterator end() const
278 {
279 return grid().template leafend<cd, pit>();
280 }
281
283 IntersectionIterator ibegin(typename Codim<0>::Entity const& entity) const
284 {
285 return grid().ileafbegin(entity);
286 }
287
289 IntersectionIterator iend(typename Codim<0>::Entity const& entity) const
290 {
291 return grid().ileafend(entity);
292 }
293
295 bool isConforming() const
296 {
297 return grid().isLeafwiseConforming();
298 }
299
301 Communication const& comm() const
302 {
303 return grid().comm();
304 }
305
307 int overlapSize(int codim) const
308 {
309 return grid().overlapSize(codim);
310 }
311
313 int ghostSize(int codim) const
314 {
315 return grid().ghostSize(codim);
316 }
317
319 template <class DataHandleImp, class DataType>
320 void communicate(Dune::CommDataHandleIF<DataHandleImp, DataType>& data,
321 Dune::InterfaceType iftype,
322 Dune::CommunicationDirection dir) const
323 {
324 return grid().communicate(data, iftype, dir);
325 }
326
327 private:
328 Grid const* grid_;
329 };
330
331} // end namespace AMDiS
Definition DefaultGridView.hpp:223
IntersectionIterator ibegin(typename Codim< 0 >::Entity const &entity) const
Obtain begin intersection iterator with respect to this view.
Definition DefaultGridView.hpp:283
IndexSet const & indexSet() const
Obtain the index set.
Definition DefaultGridView.hpp:250
int size(Dune::GeometryType const &type) const
Obtain number of entities with a given geometry type.
Definition DefaultGridView.hpp:262
void communicate(Dune::CommDataHandleIF< DataHandleImp, DataType > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate data on this view.
Definition DefaultGridView.hpp:320
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition DefaultGridView.hpp:313
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition DefaultGridView.hpp:307
Codim< cd >::template Partition< pit >::Iterator end() const
Obtain end iterator for this view.
Definition DefaultGridView.hpp:277
bool isConforming() const
Return true if current state of grid view represents a conforming grid.
Definition DefaultGridView.hpp:295
IntersectionIterator iend(typename Codim< 0 >::Entity const &entity) const
Obtain end intersection iterator with respect to this view.
Definition DefaultGridView.hpp:289
Communication const & comm() const
Obtain collective communication object.
Definition DefaultGridView.hpp:301
Grid const & grid() const
obtain a const reference to the underlying hierarchic grid
Definition DefaultGridView.hpp:243
Codim< cd >::template Partition< pit >::Iterator begin() const
Obtain begin iterator for this view.
Definition DefaultGridView.hpp:270
int size(int codim) const
Obtain number of entities in a given codimension.
Definition DefaultGridView.hpp:256
Definition DefaultGridView.hpp:69
IntersectionIterator ibegin(typename Codim< 0 >::Entity const &entity) const
Obtain begin intersection iterator with respect to this view.
Definition DefaultGridView.hpp:129
IndexSet const & indexSet() const
Obtain the index set.
Definition DefaultGridView.hpp:97
int size(Dune::GeometryType const &type) const
Obtain number of entities with a given geometry type.
Definition DefaultGridView.hpp:109
void communicate(Dune::CommDataHandleIF< DataHandleImp, DataType > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate data on this view.
Definition DefaultGridView.hpp:166
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition DefaultGridView.hpp:159
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition DefaultGridView.hpp:153
Codim< cd >::template Partition< pit >::Iterator end() const
Obtain end iterator for this view.
Definition DefaultGridView.hpp:123
bool isConforming() const
Return true if current state of grid view represents a conforming grid.
Definition DefaultGridView.hpp:141
IntersectionIterator iend(typename Codim< 0 >::Entity const &entity) const
Obtain end intersection iterator with respect to this view.
Definition DefaultGridView.hpp:135
Communication const & comm() const
Obtain collective communication object.
Definition DefaultGridView.hpp:147
Grid const & grid() const
Obtain a const reference to the underlying hierarchic grid.
Definition DefaultGridView.hpp:90
Codim< cd >::template Partition< pit >::Iterator begin() const
Obtain begin iterator for this view.
Definition DefaultGridView.hpp:116
int size(int codim) const
Obtain number of entities in a given codimension.
Definition DefaultGridView.hpp:103
Define types needed to iterate over entities of a given partition type.
Definition DefaultGridView.hpp:209
typename Grid::template Codim< cd >::template Partition< pit >::LeafIterator Iterator
iterator over a given codim and partition type
Definition DefaultGridView.hpp:211
Definition DefaultGridView.hpp:201
Definition DefaultGridView.hpp:181
std::remove_const_t< GridImp > Grid
type of the grid
Definition DefaultGridView.hpp:185
typename Grid::Traits::LeafIntersection Intersection
type of the intersection
Definition DefaultGridView.hpp:191
typename Grid::Traits::LeafIndexSet IndexSet
type of the index set
Definition DefaultGridView.hpp:188
typename Grid::Traits::Communication Communication
type of the collective communication
Definition DefaultGridView.hpp:197
typename Grid::Traits::LeafIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition DefaultGridView.hpp:194
Define types needed to iterate over entities of a given partition type.
Definition DefaultGridView.hpp:55
typename Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition DefaultGridView.hpp:57
Definition DefaultGridView.hpp:47
Definition DefaultGridView.hpp:27
std::remove_const_t< GridImp > Grid
type of the grid
Definition DefaultGridView.hpp:31
typename Grid::Traits::Communication Communication
type of the collective communication
Definition DefaultGridView.hpp:43
typename Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition DefaultGridView.hpp:37
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