dune-grid 2.12-git
Loading...
Searching...
No Matches
common/gridview.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_COMMON_GRIDVIEW_HH
6#define DUNE_GRID_COMMON_GRIDVIEW_HH
7
8#include <typeinfo>
9
13
14#include <dune/geometry/type.hh>
15
18
19namespace Dune
20{
21
22 template< int, int, class, class >
23 class GridDefaultImplementation;
24
25
26
64 template< class ViewTraits >
66 {
68
69 public:
75 typedef typename ViewTraits :: GridViewImp Implementation;
76
77 typedef typename ViewTraits :: GridViewImp GridViewImp;
78
80 typedef ViewTraits Traits;
81
83 typedef typename Traits :: Grid Grid;
84
86 typedef typename Traits :: IndexSet IndexSet;
87
89 typedef typename Traits :: Intersection Intersection;
90
92 typedef typename Traits :: IntersectionIterator IntersectionIterator;
93
98 using Communication = typename Traits :: Communication;
99
103 template< int cd >
104 struct Codim {
106 typedef typename Traits :: template Codim<cd> :: Iterator Iterator;
107
109 typedef typename Traits :: template Codim<cd> :: Entity Entity;
110
112 typedef typename Traits :: template Codim<cd> :: Geometry Geometry;
113
115 typedef typename Traits :: template Codim<cd> :: LocalGeometry LocalGeometry;
116
118 template< PartitionIteratorType pit >
120 {
122 typedef typename Traits :: template Codim< cd >
124 };
125 }; //: public Traits :: template Codim<cd> {};
126
128 constexpr static bool conforming = Traits :: conforming;
129
131 typedef typename Grid::ctype ctype;
132
134 constexpr static int dimension = Grid :: dimension;
135
137 constexpr static int dimensionworld = Grid :: dimensionworld;
138
139 public:
140
141 //===========================================================
145 //===========================================================
148 : impl_( imp )
149 {}
151
153 GridView ( const ThisType &other )
154 : impl_( other.impl_ )
155 {}
156
158 ThisType &operator= ( const ThisType &other )
159 {
160 impl_ = other.impl_;
161 return *this;
162 }
163
164 public:
166 const Grid &grid () const
167 {
168 return impl().grid();
169 }
170
177 const IndexSet &indexSet () const
178 {
179 return impl().indexSet();
180 }
181
183 int size ( int codim ) const
184 {
185 return impl().size( codim );
186 }
187
193 int size ( const GeometryType &type ) const
194 {
195 return impl().size( type );
196 }
197
198 private:
199
200 template<class I>
201 using HasIsConformingMethod = decltype(std::declval<I>().isConforming());
202
203 public:
204
206 bool isConforming () const
207 {
208 // if implementation provides a method isConforming, call it
209 if constexpr (Std::is_detected_v<HasIsConformingMethod, Implementation>)
210 {
211 return impl().isConforming();
212 }
213 else
214 {
215 // otherwise default to static conforming flag
216 return bool(conforming);
217 }
218 }
219
226 template<class EntityType>
227 bool contains (const EntityType& e) const
228 {
229 return impl().indexSet().contains(e);
230 }
231
233 template< int cd >
234 typename Codim< cd > :: Iterator begin () const
235 {
236 return impl().template begin<cd>();
237 }
238
240 template< int cd >
241 typename Codim< cd > :: Iterator end () const
242 {
243 return impl().template end<cd>();
244 }
245
247 template< int cd , PartitionIteratorType pitype >
248 typename Codim< cd > :: template Partition< pitype > :: Iterator
249 begin () const
250 {
251 return impl().template begin<cd,pitype>();
252 }
253
255 template< int cd, PartitionIteratorType pitype >
256 typename Codim< cd > :: template Partition< pitype > :: Iterator
257 end () const
258 {
259 return impl().template end<cd,pitype>();
260 }
261
264 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
265 {
266 return impl().ibegin(entity);
267 }
268
271 iend ( const typename Codim< 0 > :: Entity &entity ) const
272 {
273 return impl().iend(entity);
274 }
275
277 const Communication &comm () const
278 {
279 return impl().comm();
280 }
281
283 int overlapSize(int codim) const
284 {
285 return impl().overlapSize(codim);
286 }
287
289 int ghostSize(int codim) const
290 {
291 return impl().ghostSize(codim);
292 }
293
337 template< class DataHandleImp, class DataType >
339 InterfaceType iftype,
340 CommunicationDirection dir ) const
341 {
342 typedef decltype( impl().communicate(data,iftype,dir) ) CommFuture;
343 return communicate( data,iftype, dir,
345 }
346
352 Implementation &impl () { return impl_; }
353
359 const Implementation &impl () const { return impl_; }
360
361 protected:
363 template< class DataHandleImp, class DataType >
365 InterfaceType iftype,
367 {
368 return impl().communicate(data,iftype,dir);
369 }
370
372 {
373 void printMessage() const
374 {
375 std::cerr << "WARNING: GridView::communicate of '" <<
376 typeid( Implementation ).name() << "' still returns void. Please update implementation to new interface returning a future object!" << std::endl;
377 }
378
379 bool ready () {
380 printMessage();
381 return true;
382 }
383 void wait () { printMessage(); }
384 bool valid () const { printMessage(); return true; }
385 };
386
388 template< class DataHandleImp, class DataType >
390 InterfaceType iftype,
392 {
393 impl().communicate(data,iftype,dir);
395 }
396
398 };
399
400} // namespace Dune
401
402#endif // #ifndef DUNE_GRID_COMMON_GRIDVIEW_HH
Describes the parallel communication interface class for MessageBuffers and DataHandles.
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
const IndexSet & indexSet() const
obtain the index set
Definition common/gridview.hh:177
Traits::Grid Grid
type of the grid
Definition common/gridview.hh:83
ThisType & operator=(const ThisType &other)
assignment operator
Definition common/gridview.hh:158
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition common/gridview.hh:234
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition common/gridview.hh:166
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition common/gridview.hh:241
Implementation & impl()
access to the underlying implementation
Definition common/gridview.hh:352
Traits::template Codim< cd >::Iterator Iterator
type of iterator returned by the grid view
Definition common/gridview.hh:106
static constexpr bool conforming
Export if this grid view is guaranteed conforming.
Definition common/gridview.hh:128
Traits::template Codim< cd >::template Partition< pit >::Iterator Iterator
iterator over a given codim and partition type
Definition common/gridview.hh:123
ViewTraits Traits
Traits class.
Definition common/gridview.hh:80
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition common/gridview.hh:92
const Implementation & impl() const
access to the underlying implementation
Definition common/gridview.hh:359
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition common/gridview.hh:264
Traits::IndexSet IndexSet
type of the index set
Definition common/gridview.hh:86
Implementation impl_
Definition common/gridview.hh:397
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition common/gridview.hh:283
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition common/gridview.hh:193
void printMessage() const
Definition common/gridview.hh:373
ViewTraits::GridViewImp GridViewImp
Definition common/gridview.hh:77
int size(int codim) const
obtain number of entities in a given codimension
Definition common/gridview.hh:183
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Communicate data on this view.
Definition common/gridview.hh:338
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir, std::integral_constant< bool, false >) const
Definition common/gridview.hh:364
bool valid() const
Definition common/gridview.hh:384
typename Traits ::Communication Communication
A type that is a model of Dune::Communication. It provides a portable way for communication on the se...
Definition common/gridview.hh:98
const Communication & comm() const
obtain communication object
Definition common/gridview.hh:277
static constexpr int dimension
The dimension of the grid.
Definition common/gridview.hh:134
ViewTraits::GridViewImp Implementation
type of underlying implementation
Definition common/gridview.hh:75
GridView(const Implementation &imp)
constructor (engine concept)
Definition common/gridview.hh:147
Codim< cd >::template Partition< pitype >::Iterator begin() const
obtain begin iterator for this view
Definition common/gridview.hh:249
bool ready()
Definition common/gridview.hh:379
Traits::Intersection Intersection
type of the intersection
Definition common/gridview.hh:89
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition common/gridview.hh:271
Traits::template Codim< cd >::Entity Entity
type of corresponding entity
Definition common/gridview.hh:109
Traits::template Codim< cd >::LocalGeometry LocalGeometry
type of the implementation for local geometries
Definition common/gridview.hh:115
Grid::ctype ctype
type used for coordinates in grid
Definition common/gridview.hh:131
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir, std::integral_constant< bool, true >) const
Definition common/gridview.hh:389
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition common/gridview.hh:137
Codim< cd >::template Partition< pitype >::Iterator end() const
obtain end iterator for this view
Definition common/gridview.hh:257
bool contains(const EntityType &e) const
Return true if the given entity is contained in this grid view.
Definition common/gridview.hh:227
void wait()
Definition common/gridview.hh:383
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition common/gridview.hh:206
GridView(const ThisType &other)
Copy constructor.
Definition common/gridview.hh:153
Traits::template Codim< cd >::Geometry Geometry
type of the geometry implementation
Definition common/gridview.hh:112
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition common/gridview.hh:289
Include standard header files.
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition datahandleif.hh:78
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition common/intersectioniterator.hh:83
ct ctype
Define type used for coordinates in grid module.
Definition common/grid.hh:538
Grid view abstract base class.
Definition common/gridview.hh:66
A struct that collects all associated types of one implementation from the Traits class.
Definition common/gridview.hh:104
Define types needed to iterate over entities of a given partition type.
Definition common/gridview.hh:120
Definition common/gridview.hh:372
T endl(T... args)