dune-alugrid  2.6-git
macrogridview.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 #ifndef DUNE_ALUGRID_MACROGRIDVIEW_HH
4 #define DUNE_ALUGRID_MACROGRIDVIEW_HH
5 
6 #include <type_traits>
7 
8 #include <dune/common/version.hh>
9 #include <dune/common/exceptions.hh>
10 
11 #include <dune/grid/common/capabilities.hh>
12 #include <dune/grid/common/gridview.hh>
13 
14 namespace Dune
15 {
16 
17  template< class GridImp, PartitionIteratorType pitype >
18  class MacroGridView;
19 
20  template< class GridImp, PartitionIteratorType pitype >
22  {
24 
26  typedef typename std::remove_const<GridImp>::type Grid;
27 
29  typedef typename Grid :: Traits :: LevelIndexSet IndexSet;
30 
32  typedef typename Grid :: Traits :: LevelIntersection Intersection;
33 
35  typedef typename Grid :: Traits :: LevelIntersectionIterator
37 
39  typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
40 
41  template< int cd >
42  struct Codim
43  {
44  typedef typename Grid :: Traits
45  :: template Codim< cd > :: template Partition< pitype > :: LevelIterator
47 
48  typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
49 
50 #if ! DUNE_VERSION_NEWER(DUNE_GRID,2,5)
51  typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
53 #endif
54 
55  typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
56  typedef typename Grid :: template Codim< cd > :: LocalGeometry
58 
60  template< PartitionIteratorType pit >
61  struct Partition
62  {
64  typedef typename Grid :: template Codim< cd >
65  :: template Partition< pit > :: LevelIterator
67  };
68  };
69 
70  enum { conforming = Capabilities :: isLevelwiseConforming< Grid > :: v };
71  };
72 
73 
74  template< class GridImp, PartitionIteratorType pitype >
76  {
78 
79  public:
80 
81 
83 
85  typedef typename Traits::Grid Grid;
86 
88  typedef typename Traits :: IndexSet IndexSet;
89 
92 
95 
98 
100  template< int cd >
101  struct Codim : public Traits :: template Codim<cd> {};
102 
103  enum {
106  };
107 
109  typedef typename Grid::ctype ctype;
110 
111  enum {
112  dimension = Grid :: dimension
113  };
114 
115  enum {
116  dimensionworld = Grid :: dimensionworld
117  };
118 
120  : grid_( &grid ),
121  level_( 0 )
122  {}
123 
125  const Grid &grid () const
126  {
127  assert( grid_ );
128  return *grid_;
129  }
130 
132  const IndexSet &indexSet () const
133  {
134  return grid().levelIndexSet( level_ );
135  }
136 
138  int size ( int codim ) const
139  {
140  return grid().size( level_, codim );
141  }
142 
144  int size ( const GeometryType &type ) const
145  {
146  return grid().size( level_, type );
147  }
148 
150  template< int cd >
151  typename Codim< cd > :: Iterator begin () const
152  {
153  return grid().template lbegin< cd, pitype >( level_ );
154  }
155 
157  template< int cd, PartitionIteratorType pit >
158  typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
159  {
160  return grid().template lbegin< cd, pit >( level_ );
161  }
162 
164  template< int cd >
165  typename Codim< cd > :: Iterator end () const
166  {
167  return grid().template lend< cd, pitype >( level_ );
168  }
169 
171  template< int cd, PartitionIteratorType pit >
172  typename Codim< cd > :: template Partition< pit > :: Iterator end () const
173  {
174  return grid().template lend< cd, pit >( level_ );
175  }
176 
179  ibegin ( const typename Codim< 0 > :: Entity &entity ) const
180  {
181  assert( entity.level() == level_ );
182  return grid().ilevelbegin( entity );
183  }
184 
187  iend ( const typename Codim< 0 > :: Entity &entity ) const
188  {
189  assert( entity.level() == level_ );
190  return grid().ilevelend( entity );
191  }
192 
195  {
196  return grid().comm();
197  }
198 
200  int overlapSize(int codim) const
201  {
202  return grid().overlapSize(level_, codim);
203  }
204 
206  int ghostSize(int codim) const
207  {
208  return grid().ghostSize(level_, codim);
209  }
210 
212  template< class DataHandleImp, class DataType >
213  void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
214  InterfaceType iftype,
215  CommunicationDirection dir ) const
216  {
217  return grid().communicate( data, iftype, dir, level_ );
218  }
219 
221  //
222  // extra interface methods for load balancing
223  //
225 
227  int master ( const typename Codim< 0 > :: Entity &entity ) const
228  {
229  return Grid::getRealImplementation( entity ).master();
230  }
231 
233  int macroId ( const typename Codim< 0 > :: Entity &entity ) const
234  {
235  return Grid::getRealImplementation( entity ).macroId();
236  }
237 
239  int weight ( const typename Codim< 0 > :: Entity &entity ) const
240  {
241  return Grid::getRealImplementation( entity ).weight();
242  }
243 
246  int weight ( const Intersection &intersection ) const
247  {
248  return Grid::getRealImplementation( intersection ).weight();
249  }
250 
251  DUNE_DEPRECATED
252  int weight ( const IntersectionIterator &intersectionIterator ) const // should perhaps be intersection but that class a default is used...
253  {
254  return weight( *intersectionIterator );
255  }
256 
257  protected:
258  const Grid *grid_;
259  const int level_;
260  };
261 }
262 
263 #endif
Definition: alu3dinclude.hh:80
Definition: macrogridview.hh:76
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition: macrogridview.hh:172
int weight(const typename Codim< 0 > ::Entity &entity) const
return weight associated with the given macro entity
Definition: macrogridview.hh:239
Traits ::IndexSet IndexSet
type of the index set
Definition: macrogridview.hh:88
Traits ::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: macrogridview.hh:94
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: macrogridview.hh:194
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition: macrogridview.hh:206
const IndexSet & indexSet() const
obtain the index set
Definition: macrogridview.hh:132
int macroId(const typename Codim< 0 > ::Entity &entity) const
return unique id of macro entity for usage with graph partitioning software
Definition: macrogridview.hh:233
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition: macrogridview.hh:158
MacroGridViewTraits< GridImp, pitype > Traits
Definition: macrogridview.hh:82
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition: macrogridview.hh:151
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition: macrogridview.hh:125
int weight(const IntersectionIterator &intersectionIterator) const
Definition: macrogridview.hh:252
@ dimension
The dimension of the grid.
Definition: macrogridview.hh:112
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition: macrogridview.hh:200
Grid::ctype ctype
type used for coordinates in grid
Definition: macrogridview.hh:109
const int level_
Definition: macrogridview.hh:259
Traits ::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: macrogridview.hh:97
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: macrogridview.hh:213
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: macrogridview.hh:179
MacroGridView(const Grid &grid)
Definition: macrogridview.hh:119
Traits::Grid Grid
type of the grid
Definition: macrogridview.hh:85
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition: macrogridview.hh:165
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: macrogridview.hh:144
@ conforming
Export if this grid view is conforming *‍/.
Definition: macrogridview.hh:105
int size(int codim) const
obtain number of entities in a given codimension
Definition: macrogridview.hh:138
int master(const typename Codim< 0 > ::Entity &entity) const
return master rank for entities with partitionType != InteriorEntity
Definition: macrogridview.hh:227
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: macrogridview.hh:187
const Grid * grid_
Definition: macrogridview.hh:258
Traits ::Intersection Intersection
type of the intersection
Definition: macrogridview.hh:91
int weight(const Intersection &intersection) const
return weight associated with the macro intersection, i.e. the graph edge between the two neighboring...
Definition: macrogridview.hh:246
@ dimensionworld
The dimension of the world the grid lives in.
Definition: macrogridview.hh:116
Definition: macrogridview.hh:22
MacroGridView< GridImp, pitype > GridViewImp
Definition: macrogridview.hh:23
Grid ::Traits ::LevelIntersection Intersection
type of the intersection
Definition: macrogridview.hh:32
Grid ::Traits ::LevelIndexSet IndexSet
type of the index set
Definition: macrogridview.hh:29
Grid ::Traits ::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition: macrogridview.hh:39
std::remove_const< GridImp >::type Grid
type of the grid
Definition: macrogridview.hh:26
@ conforming
Definition: macrogridview.hh:70
Grid ::Traits ::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: macrogridview.hh:36
Definition: macrogridview.hh:43
Grid ::template Codim< cd >::Geometry Geometry
Definition: macrogridview.hh:55
Grid ::Traits ::template Codim< cd >::EntityPointer EntityPointer
Definition: macrogridview.hh:52
Grid ::Traits ::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition: macrogridview.hh:46
Grid ::template Codim< cd >::LocalGeometry LocalGeometry
Definition: macrogridview.hh:57
Grid ::Traits ::template Codim< cd >::Entity Entity
Definition: macrogridview.hh:48
Define types needed to iterate over entities of a given partition type.
Definition: macrogridview.hh:62
Grid ::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: macrogridview.hh:66
Codim Structure.
Definition: macrogridview.hh:101