DUNE PDELab (2.8)

gridview.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_COMMON_GRIDVIEW_HH
4#define DUNE_GRID_COMMON_GRIDVIEW_HH
5
6#include <typeinfo>
7
8#include <dune/common/iteratorrange.hh>
9#include <dune/common/parallel/future.hh>
10
11#include <dune/geometry/type.hh>
12
14#include <dune/grid/common/rangegenerators.hh>
15
16namespace Dune
17{
18
19 template< int, int, class, class >
20 class GridDefaultImplementation;
21
22
23
61 template< class ViewTraits >
63 {
65
66 public:
72 typedef typename ViewTraits :: GridViewImp Implementation;
73
74 typedef typename ViewTraits :: GridViewImp GridViewImp;
75
77 typedef ViewTraits Traits;
78
80 typedef typename Traits :: Grid Grid;
81
83 typedef typename Traits :: IndexSet IndexSet;
84
86 typedef typename Traits :: Intersection Intersection;
87
89 typedef typename Traits :: IntersectionIterator IntersectionIterator;
90
92 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
93
97 template< int cd >
98 struct Codim {
100 typedef typename Traits :: template Codim<cd> :: Iterator Iterator;
101
103 typedef typename Traits :: template Codim<cd> :: Entity Entity;
104
106 typedef typename Traits :: template Codim<cd> :: Geometry Geometry;
107
109 typedef typename Traits :: template Codim<cd> :: LocalGeometry LocalGeometry;
110
112 template< PartitionIteratorType pit >
114 {
116 typedef typename Traits :: template Codim< cd >
118 };
119 }; //: public Traits :: template Codim<cd> {};
120
121 enum {
123 conforming = Traits :: conforming
124 };
125
127 typedef typename Grid::ctype ctype;
128
129 enum {
131 };
132
133 enum {
135 };
136
137 public:
138
139 //===========================================================
143 //===========================================================
146 : impl_( imp )
147 {}
149
151 GridView ( const ThisType &other )
152 : impl_( other.impl_ )
153 {}
154
156 ThisType &operator= ( const ThisType &other )
157 {
158 impl_ = other.impl_;
159 return *this;
160 }
161
162 public:
164 const Grid &grid () const
165 {
166 return impl().grid();
167 }
168
175 const IndexSet &indexSet () const
176 {
177 return impl().indexSet();
178 }
179
181 int size ( int codim ) const
182 {
183 return impl().size( codim );
184 }
185
187 int size ( const GeometryType &type ) const
188 {
189 return impl().size( type );
190 }
191
198 template<class EntityType>
199 bool contains (const EntityType& e) const
200 {
201 return impl().indexSet().contains(e);
202 }
203
205 template< int cd >
206 typename Codim< cd > :: Iterator begin () const
207 {
208 return impl().template begin<cd>();
209 }
210
212 template< int cd >
213 typename Codim< cd > :: Iterator end () const
214 {
215 return impl().template end<cd>();
216 }
217
219 template< int cd , PartitionIteratorType pitype >
220 typename Codim< cd > :: template Partition< pitype > :: Iterator
221 begin () const
222 {
223 return impl().template begin<cd,pitype>();
224 }
225
227 template< int cd, PartitionIteratorType pitype >
228 typename Codim< cd > :: template Partition< pitype > :: Iterator
229 end () const
230 {
231 return impl().template end<cd,pitype>();
232 }
233
236 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
237 {
238 return impl().ibegin(entity);
239 }
240
243 iend ( const typename Codim< 0 > :: Entity &entity ) const
244 {
245 return impl().iend(entity);
246 }
247
250 {
251 return impl().comm();
252 }
253
255 int overlapSize(int codim) const
256 {
257 return impl().overlapSize(codim);
258 }
259
261 int ghostSize(int codim) const
262 {
263 return impl().ghostSize(codim);
264 }
265
267 template< class DataHandleImp, class DataType >
269 InterfaceType iftype,
270 CommunicationDirection dir ) const
271 {
272 typedef decltype( impl().communicate(data,iftype,dir) ) CommFuture;
273 return communicate( data,iftype, dir,
274 std::integral_constant< bool, std::is_same< CommFuture, void > :: value >() );
275 }
276
282 Implementation &impl () { return impl_; }
283
289 const Implementation &impl () const { return impl_; }
290
291 protected:
293 template< class DataHandleImp, class DataType >
295 InterfaceType iftype,
296 CommunicationDirection dir, std::integral_constant< bool, false > ) const
297 {
298 return impl().communicate(data,iftype,dir);
299 }
300
301 struct DeprecatedMethodEmptyFuture : public Future<void>
302 {
303 void printMessage() const
304 {
305 std::cerr << "WARNING: GridView::communicate of '" <<
306 typeid( Implementation ).name() << "' still returns void. Please update implementation to new interface returning a future object!" << std::endl;
307 }
308
309 bool ready () {
310 printMessage();
311 return true;
312 }
313 void wait () { printMessage(); }
314 bool valid () const { printMessage(); return true; }
315 };
316
318 template< class DataHandleImp, class DataType >
320 InterfaceType iftype,
321 CommunicationDirection dir, std::integral_constant< bool, true > ) const
322 {
323 impl().communicate(data,iftype,dir);
324 return DeprecatedMethodEmptyFuture();
325 }
326
327 Implementation impl_;
328 };
329
330} // namespace Dune
331
332#endif // #ifndef DUNE_GRID_COMMON_GRIDVIEW_HH
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:76
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition: future.hh:26
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
Grid view abstract base class.
Definition: gridview.hh:63
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:392
@ dimension
The dimension of the grid.
Definition: grid.hh:386
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:521
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:81
Describes the parallel communication interface class for MessageBuffers and DataHandles.
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:175
Traits::Grid Grid
type of the grid
Definition: gridview.hh:80
ThisType & operator=(const ThisType &other)
assignment operator
Definition: gridview.hh:156
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:206
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: gridview.hh:164
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:213
Implementation & impl()
access to the underlying implementation
Definition: gridview.hh:282
Traits::template Codim< cd >::Iterator Iterator
type of iterator returned by the grid view
Definition: gridview.hh:100
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: gridview.hh:249
Traits::template Codim< cd >::template Partition< pit >::Iterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:117
ViewTraits Traits
Traits class.
Definition: gridview.hh:77
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:89
const Implementation & impl() const
access to the underlying implementation
Definition: gridview.hh:289
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: gridview.hh:236
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:83
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: gridview.hh:255
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: gridview.hh:92
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: gridview.hh:187
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:181
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Communicate data on this view.
Definition: gridview.hh:268
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir, std::integral_constant< bool, false >) const
Communicate data on this view.
Definition: gridview.hh:294
ViewTraits::GridViewImp Implementation
type of underlying implementation
Definition: gridview.hh:72
GridView(const Implementation &imp)
constructor (engine concept)
Definition: gridview.hh:145
Codim< cd >::template Partition< pitype >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:221
Traits::Intersection Intersection
type of the intersection
Definition: gridview.hh:86
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: gridview.hh:243
Traits::template Codim< cd >::Entity Entity
type of corresponding entity
Definition: gridview.hh:103
Traits::template Codim< cd >::LocalGeometry LocalGeometry
type of the implementation for local geometries
Definition: gridview.hh:109
Grid::ctype ctype
type used for coordinates in grid
Definition: gridview.hh:127
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir, std::integral_constant< bool, true >) const
Communicate data on this view.
Definition: gridview.hh:319
Codim< cd >::template Partition< pitype >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:229
bool contains(const EntityType &e) const
Return true if the given entity is contained in this grid view.
Definition: gridview.hh:199
GridView(const ThisType &other)
Copy constructor.
Definition: gridview.hh:151
Traits::template Codim< cd >::Geometry Geometry
type of the geometry implementation
Definition: gridview.hh:106
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: gridview.hh:261
@ dimension
The dimension of the grid.
Definition: gridview.hh:130
@ dimensionworld
The dimension of the world the grid lives in.
Definition: gridview.hh:134
@ conforming
Export if this grid view is conforming.
Definition: gridview.hh:123
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Dune namespace.
Definition: alignedallocator.hh:11
Static tag representing a codimension.
Definition: dimension.hh:22
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:114
A struct that collects all associated types of one implementation from the Traits class.
Definition: gridview.hh:98
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)