DUNE PDELab (git)

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_COMMON_GRIDVIEW_HH
6#define DUNE_GRID_COMMON_GRIDVIEW_HH
7
8#include <typeinfo>
9
10#include <dune/common/std/type_traits.hh>
11#include <dune/common/iteratorrange.hh>
12#include <dune/common/parallel/future.hh>
13
14#include <dune/geometry/type.hh>
15
17#include <dune/grid/common/rangegenerators.hh>
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
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
189 int size ( const GeometryType &type ) const
190 {
191 return impl().size( type );
192 }
193
194 private:
195
196 template<class I>
197 using HasIsConformingMethod = decltype(std::declval<I>().isConforming());
198
199 public:
200
202 bool isConforming () const
203 {
204 // if implementation provides a method isConforming, call it
205 if constexpr (Std::is_detected_v<HasIsConformingMethod, Implementation>)
206 {
207 return impl().isConforming();
208 }
209 else
210 {
211 // otherwise default to static conforming flag
212 return bool(conforming);
213 }
214 }
215
222 template<class EntityType>
223 bool contains (const EntityType& e) const
224 {
225 return impl().indexSet().contains(e);
226 }
227
229 template< int cd >
230 typename Codim< cd > :: Iterator begin () const
231 {
232 return impl().template begin<cd>();
233 }
234
236 template< int cd >
237 typename Codim< cd > :: Iterator end () const
238 {
239 return impl().template end<cd>();
240 }
241
243 template< int cd , PartitionIteratorType pitype >
244 typename Codim< cd > :: template Partition< pitype > :: Iterator
245 begin () const
246 {
247 return impl().template begin<cd,pitype>();
248 }
249
251 template< int cd, PartitionIteratorType pitype >
252 typename Codim< cd > :: template Partition< pitype > :: Iterator
253 end () const
254 {
255 return impl().template end<cd,pitype>();
256 }
257
260 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
261 {
262 return impl().ibegin(entity);
263 }
264
267 iend ( const typename Codim< 0 > :: Entity &entity ) const
268 {
269 return impl().iend(entity);
270 }
271
273 const Communication &comm () const
274 {
275 return impl().comm();
276 }
277
279 int overlapSize(int codim) const
280 {
281 return impl().overlapSize(codim);
282 }
283
285 int ghostSize(int codim) const
286 {
287 return impl().ghostSize(codim);
288 }
289
291 template< class DataHandleImp, class DataType >
293 InterfaceType iftype,
294 CommunicationDirection dir ) const
295 {
296 typedef decltype( impl().communicate(data,iftype,dir) ) CommFuture;
297 return communicate( data,iftype, dir,
298 std::integral_constant< bool, std::is_same< CommFuture, void > :: value >() );
299 }
300
306 Implementation &impl () { return impl_; }
307
313 const Implementation &impl () const { return impl_; }
314
315 protected:
317 template< class DataHandleImp, class DataType >
319 InterfaceType iftype,
320 CommunicationDirection dir, std::integral_constant< bool, false > ) const
321 {
322 return impl().communicate(data,iftype,dir);
323 }
324
325 struct DeprecatedMethodEmptyFuture : public Future<void>
326 {
327 void printMessage() const
328 {
329 std::cerr << "WARNING: GridView::communicate of '" <<
330 typeid( Implementation ).name() << "' still returns void. Please update implementation to new interface returning a future object!" << std::endl;
331 }
332
333 bool ready () {
334 printMessage();
335 return true;
336 }
337 void wait () { printMessage(); }
338 bool valid () const { printMessage(); return true; }
339 };
340
342 template< class DataHandleImp, class DataType >
344 InterfaceType iftype,
345 CommunicationDirection dir, std::integral_constant< bool, true > ) const
346 {
347 impl().communicate(data,iftype,dir);
348 return DeprecatedMethodEmptyFuture();
349 }
350
351 Implementation impl_;
352 };
353
354} // namespace Dune
355
356#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:78
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition: future.hh:30
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Grid view abstract base class.
Definition: gridview.hh:66
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:390
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:518
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
Describes the parallel communication interface class for MessageBuffers and DataHandles.
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:177
Traits::Grid Grid
type of the grid
Definition: gridview.hh:83
ThisType & operator=(const ThisType &other)
assignment operator
Definition: gridview.hh:158
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:230
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: gridview.hh:166
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:237
Implementation & impl()
access to the underlying implementation
Definition: gridview.hh:306
Traits::template Codim< cd >::Iterator Iterator
type of iterator returned by the grid view
Definition: gridview.hh:106
static constexpr bool conforming
Export if this grid view is guaranteed conforming.
Definition: gridview.hh:128
Traits::template Codim< cd >::template Partition< pit >::Iterator Iterator
iterator over a given codim and partition type
Definition: gridview.hh:123
ViewTraits Traits
Traits class.
Definition: gridview.hh:80
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:92
const Implementation & impl() const
access to the underlying implementation
Definition: gridview.hh:313
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: gridview.hh:260
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:86
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: gridview.hh:279
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: gridview.hh:189
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:183
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Communicate data on this view.
Definition: gridview.hh:292
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir, std::integral_constant< bool, false >) const
Communicate data on this view.
Definition: gridview.hh:318
typename Traits ::Communication Communication
A type that is a model of Dune::Communication. It provides a portable way for communication on the se...
Definition: gridview.hh:98
const Communication & comm() const
obtain communication object
Definition: gridview.hh:273
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:134
ViewTraits::GridViewImp Implementation
type of underlying implementation
Definition: gridview.hh:75
GridView(const Implementation &imp)
constructor (engine concept)
Definition: gridview.hh:147
Codim< cd >::template Partition< pitype >::Iterator begin() const
obtain begin iterator for this view
Definition: gridview.hh:245
Traits::Intersection Intersection
type of the intersection
Definition: gridview.hh:89
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: gridview.hh:267
Traits::template Codim< cd >::Entity Entity
type of corresponding entity
Definition: gridview.hh:109
Traits::template Codim< cd >::LocalGeometry LocalGeometry
type of the implementation for local geometries
Definition: gridview.hh:115
Grid::ctype ctype
type used for coordinates in grid
Definition: gridview.hh:131
auto communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir, std::integral_constant< bool, true >) const
Communicate data on this view.
Definition: gridview.hh:343
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: gridview.hh:137
Codim< cd >::template Partition< pitype >::Iterator end() const
obtain end iterator for this view
Definition: gridview.hh:253
bool contains(const EntityType &e) const
Return true if the given entity is contained in this grid view.
Definition: gridview.hh:223
bool isConforming() const
return true if current state of grid view represents a conforming grid
Definition: gridview.hh:202
GridView(const ThisType &other)
Copy constructor.
Definition: gridview.hh:153
Traits::template Codim< cd >::Geometry Geometry
type of the geometry implementation
Definition: gridview.hh:112
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: gridview.hh:285
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
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Define types needed to iterate over entities of a given partition type.
Definition: gridview.hh:120
A struct that collects all associated types of one implementation from the Traits class.
Definition: gridview.hh:104
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 (Nov 12, 23:30, 2024)