dune-alugrid 3.0.0
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/exceptions.hh>
9
10#include <dune/grid/common/capabilities.hh>
11#include <dune/grid/common/gridview.hh>
12
13namespace Dune
14{
15
16 template< class GridImp, PartitionIteratorType pitype >
17 class MacroGridView;
18
19 template< class GridImp, PartitionIteratorType pitype >
21 {
23
25 typedef typename std::remove_const<GridImp>::type Grid;
26
28 typedef typename Grid :: Traits :: LevelIndexSet IndexSet;
29
31 typedef typename Grid :: Traits :: LevelIntersection Intersection;
32
34 typedef typename Grid :: Traits :: LevelIntersectionIterator
36
38 typedef typename Grid :: Traits :: CollectiveCommunication CollectiveCommunication;
39
40 template< int cd >
41 struct Codim
42 {
43 typedef typename Grid :: Traits
44 :: template Codim< cd > :: template Partition< pitype > :: LevelIterator
46
47 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
48 typedef typename Grid :: Traits :: template Codim< cd > :: EntityPointer
50
51 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
52 typedef typename Grid :: template Codim< cd > :: LocalGeometry
54
56 template< PartitionIteratorType pit >
57 struct Partition
58 {
60 typedef typename Grid :: template Codim< cd >
61 :: template Partition< pit > :: LevelIterator
63 };
64 };
65
66 enum { conforming = Capabilities :: isLevelwiseConforming< Grid > :: v };
67 };
68
69
70 template< class GridImp, PartitionIteratorType pitype >
72 {
73 typedef MacroGridView< GridImp, pitype > ThisType;
74
75 public:
76
77
79
81 typedef typename Traits::Grid Grid;
82
84 typedef typename Traits :: IndexSet IndexSet;
85
87 typedef typename Traits :: Intersection Intersection;
88
90 typedef typename Traits :: IntersectionIterator IntersectionIterator;
91
93 typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
94
96 template< int cd >
97 struct Codim : public Traits :: template Codim<cd> {};
98
99 enum {
101 conforming = Traits :: conforming
102 };
103
105 typedef typename Grid::ctype ctype;
106
107 enum {
108 dimension = Grid :: dimension
109 };
110
111 enum {
112 dimensionworld = Grid :: dimensionworld
113 };
114
116 : grid_( &grid ),
117 level_( 0 )
118 {}
119
121 const Grid &grid () const
122 {
123 assert( grid_ );
124 return *grid_;
125 }
126
128 const IndexSet &indexSet () const
129 {
130 return grid().levelIndexSet( level_ );
131 }
132
134 int size ( int codim ) const
135 {
136 return grid().size( level_, codim );
137 }
138
140 int size ( const GeometryType &type ) const
141 {
142 return grid().size( level_, type );
143 }
144
146 template< int cd >
147 typename Codim< cd > :: Iterator begin () const
148 {
149 return grid().template lbegin< cd, pitype >( level_ );
150 }
151
153 template< int cd, PartitionIteratorType pit >
154 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
155 {
156 return grid().template lbegin< cd, pit >( level_ );
157 }
158
160 template< int cd >
161 typename Codim< cd > :: Iterator end () const
162 {
163 return grid().template lend< cd, pitype >( level_ );
164 }
165
167 template< int cd, PartitionIteratorType pit >
168 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
169 {
170 return grid().template lend< cd, pit >( level_ );
171 }
172
175 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
176 {
177 assert( entity.level() == level_ );
178 return grid().ilevelbegin( entity );
179 }
180
183 iend ( const typename Codim< 0 > :: Entity &entity ) const
184 {
185 assert( entity.level() == level_ );
186 return grid().ilevelend( entity );
187 }
188
191 {
192 return grid().comm();
193 }
194
196 int overlapSize(int codim) const
197 {
198 return grid().overlapSize(level_, codim);
199 }
200
202 int ghostSize(int codim) const
203 {
204 return grid().ghostSize(level_, codim);
205 }
206
208 template< class DataHandleImp, class DataType >
209 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
210 InterfaceType iftype,
211 CommunicationDirection dir ) const
212 {
213 return grid().communicate( data, iftype, dir, level_ );
214 }
215
217 //
218 // extra interface methods for load balancing
219 //
221
223 int master ( const typename Codim< 0 > :: Entity &entity ) const
224 {
225 return Grid::getRealImplementation( entity ).master();
226 }
227
229 int macroId ( const typename Codim< 0 > :: Entity &entity ) const
230 {
231 return Grid::getRealImplementation( entity ).macroId();
232 }
233
235 int weight ( const typename Codim< 0 > :: Entity &entity ) const
236 {
237 return Grid::getRealImplementation( entity ).weight();
238 }
239
242 int weight ( const Intersection &intersection ) const
243 {
244 return Grid::getRealImplementation( intersection ).weight();
245 }
246
247 DUNE_DEPRECATED
248 int weight ( const IntersectionIterator &intersectionIterator ) const // should perhaps be intersection but that class a default is used...
249 {
250 return weight( *intersectionIterator );
251 }
252
253 protected:
254 const Grid *grid_;
255 const int level_;
256 };
257}
258
259#endif
Definition alu3dinclude.hh:80
Definition macrogridview.hh:72
@ dimensionworld
The dimension of the world the grid lives in.
Definition macrogridview.hh:112
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition macrogridview.hh:90
int weight(const typename Codim< 0 > ::Entity &entity) const
return weight associated with the given macro entity
Definition macrogridview.hh:235
int ghostSize(int codim) const
Return size of the ghost region for a given codim on the grid view.
Definition macrogridview.hh:202
Codim< cd >::Iterator end() const
obtain end iterator for this view
Definition macrogridview.hh:161
const IndexSet & indexSet() const
obtain the index set
Definition macrogridview.hh:128
@ conforming
Export if this grid view is conforming *‍/.
Definition macrogridview.hh:101
int macroId(const typename Codim< 0 > ::Entity &entity) const
return unique id of macro entity for usage with graph partitioning software
Definition macrogridview.hh:229
MacroGridViewTraits< GridImp, pitype > Traits
Definition macrogridview.hh:78
int weight(const IntersectionIterator &intersectionIterator) const
Definition macrogridview.hh:248
int overlapSize(int codim) const
Return size of the overlap region for a given codim on the grid view.
Definition macrogridview.hh:196
Grid::ctype ctype
type used for coordinates in grid
Definition macrogridview.hh:105
Codim< cd >::template Partition< pit >::Iterator begin() const
obtain begin iterator for this view
Definition macrogridview.hh:154
const int level_
Definition macrogridview.hh:255
@ dimension
The dimension of the grid.
Definition macrogridview.hh:108
const Grid & grid() const
obtain a const reference to the underlying hierarchic grid
Definition macrogridview.hh:121
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition macrogridview.hh:209
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition macrogridview.hh:175
MacroGridView(const Grid &grid)
Definition macrogridview.hh:115
Traits::Intersection Intersection
type of the intersection
Definition macrogridview.hh:87
Traits::Grid Grid
type of the grid
Definition macrogridview.hh:81
Codim< cd >::Iterator begin() const
obtain begin iterator for this view
Definition macrogridview.hh:147
Codim< cd >::template Partition< pit >::Iterator end() const
obtain end iterator for this view
Definition macrogridview.hh:168
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition macrogridview.hh:140
const CollectiveCommunication & comm() const
obtain collective communication object
Definition macrogridview.hh:190
int size(int codim) const
obtain number of entities in a given codimension
Definition macrogridview.hh:134
int master(const typename Codim< 0 > ::Entity &entity) const
return master rank for entities with partitionType != InteriorEntity
Definition macrogridview.hh:223
Traits::IndexSet IndexSet
type of the index set
Definition macrogridview.hh:84
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition macrogridview.hh:183
const Grid * grid_
Definition macrogridview.hh:254
Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition macrogridview.hh:93
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:242
Definition macrogridview.hh:21
MacroGridView< GridImp, pitype > GridViewImp
Definition macrogridview.hh:22
Grid::Traits::CollectiveCommunication CollectiveCommunication
type of the collective communication
Definition macrogridview.hh:38
Grid::Traits::LevelIntersection Intersection
type of the intersection
Definition macrogridview.hh:31
Grid::Traits::LevelIndexSet IndexSet
type of the index set
Definition macrogridview.hh:28
Grid::Traits::LevelIntersectionIterator IntersectionIterator
type of the intersection iterator
Definition macrogridview.hh:35
std::remove_const< GridImp >::type Grid
type of the grid
Definition macrogridview.hh:25
@ conforming
Definition macrogridview.hh:66
Definition macrogridview.hh:42
Grid::template Codim< cd >::Geometry Geometry
Definition macrogridview.hh:51
Grid::template Codim< cd >::LocalGeometry LocalGeometry
Definition macrogridview.hh:53
Grid::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator Iterator
Definition macrogridview.hh:45
Grid::Traits::template Codim< cd >::Entity Entity
Definition macrogridview.hh:47
Grid::Traits::template Codim< cd >::EntityPointer EntityPointer
Definition macrogridview.hh:49
Define types needed to iterate over entities of a given partition type.
Definition macrogridview.hh:58
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition macrogridview.hh:62
Codim Structure.
Definition macrogridview.hh:97