Dune Core Modules (2.9.0)

macrogridview.hh
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
10
12#include <dune/grid/common/gridview.hh>
13
14namespace Dune
15{
16
17 template< class GridImp, PartitionIteratorType pitype >
18 class MacroGridView;
19
20 template< class GridImp, PartitionIteratorType pitype >
21 struct MacroGridViewTraits
22 {
23 typedef MacroGridView< GridImp, pitype > GridViewImp;
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
36 IntersectionIterator;
37
39 typedef typename Grid :: Traits :: Communication Communication;
40
41 template< int cd >
42 struct Codim
43 {
44 typedef typename Grid :: Traits
45 :: template Codim< cd > :: template Partition< pitype > :: LevelIterator
46 Iterator;
47
48 typedef typename Grid :: Traits :: template Codim< cd > :: Entity Entity;
49
50 typedef typename Grid :: template Codim< cd > :: Geometry Geometry;
51 typedef typename Grid :: template Codim< cd > :: LocalGeometry
52 LocalGeometry;
53
55 template< PartitionIteratorType pit >
56 struct Partition
57 {
59 typedef typename Grid :: template Codim< cd >
60 :: template Partition< pit > :: LevelIterator
62 };
63 };
64
65 enum { conforming = Capabilities :: isLevelwiseConforming< Grid > :: v };
66 };
67
68
69 template< class GridImp, PartitionIteratorType pitype >
70 class MacroGridView
71 {
72 typedef MacroGridView< GridImp, pitype > ThisType;
73
74 public:
75
76
77 typedef MacroGridViewTraits< GridImp, pitype > 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 :: Communication Communication;
93
95 template< int cd >
96 struct Codim : public Traits :: template Codim<cd> {};
97
98 enum {
100 conforming = Traits :: conforming
101 };
102
104 typedef typename Grid::ctype ctype;
105
106 enum {
107 dimension = Grid :: dimension
108 };
109
110 enum {
111 dimensionworld = Grid :: dimensionworld
112 };
113
114 MacroGridView ( const Grid &grid )
115 : grid_( &grid ),
116 level_( 0 )
117 {}
118
120 const Grid &grid () const
121 {
122 assert( grid_ );
123 return *grid_;
124 }
125
127 const IndexSet &indexSet () const
128 {
129 return grid().levelIndexSet( level_ );
130 }
131
133 bool isConforming() const
134 {
135 // the macro level is always conforming
136 return true;
137 }
138
140 int size ( int codim ) const
141 {
142 return grid().size( level_, codim );
143 }
144
146 int size ( const GeometryType &type ) const
147 {
148 return grid().size( level_, type );
149 }
150
152 template< int cd >
153 typename Codim< cd > :: Iterator begin () const
154 {
155 return grid().template lbegin< cd, pitype >( level_ );
156 }
157
159 template< int cd, PartitionIteratorType pit >
160 typename Codim< cd > :: template Partition< pit > :: Iterator begin () const
161 {
162 return grid().template lbegin< cd, pit >( level_ );
163 }
164
166 template< int cd >
167 typename Codim< cd > :: Iterator end () const
168 {
169 return grid().template lend< cd, pitype >( level_ );
170 }
171
173 template< int cd, PartitionIteratorType pit >
174 typename Codim< cd > :: template Partition< pit > :: Iterator end () const
175 {
176 return grid().template lend< cd, pit >( level_ );
177 }
178
180 IntersectionIterator
181 ibegin ( const typename Codim< 0 > :: Entity &entity ) const
182 {
183 assert( entity.level() == level_ );
184 return grid().ilevelbegin( entity );
185 }
186
188 IntersectionIterator
189 iend ( const typename Codim< 0 > :: Entity &entity ) const
190 {
191 assert( entity.level() == level_ );
192 return grid().ilevelend( entity );
193 }
194
196 const Communication &comm () const
197 {
198 return grid().comm();
199 }
200
202 int overlapSize(int codim) const
203 {
204 return grid().overlapSize(level_, codim);
205 }
206
208 int ghostSize(int codim) const
209 {
210 return grid().ghostSize(level_, codim);
211 }
212
214 template< class DataHandleImp, class DataType >
215 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
216 InterfaceType iftype,
217 CommunicationDirection dir ) const
218 {
219 return grid().communicate( data, iftype, dir, level_ );
220 }
221
223 //
224 // extra interface methods for load balancing
225 //
227
229 int master ( const typename Codim< 0 > :: Entity &entity ) const
230 {
231 return entity.impl().master();
232 }
233
235 int macroId ( const typename Codim< 0 > :: Entity &entity ) const
236 {
237 return entity.impl().macroId();
238 }
239
241 int weight ( const typename Codim< 0 > :: Entity &entity ) const
242 {
243 return entity.impl().weight();
244 }
245
248 int weight ( const Intersection &intersection ) const
249 {
250 return intersection.impl().weight();
251 }
252
253 protected:
254 const Grid *grid_;
255 const int level_;
256 };
257}
258
259#endif
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:532
A few common exception classes.
A set of traits classes to store static information about grid implementation.
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
@ conforming
use only conforming bisection refinement
Definition: declaration.hh:25
Define types needed to iterate over entities of a given partition type.
Definition: macrogridview.hh:57
Grid::template Codim< cd >::template Partition< pit >::LevelIterator Iterator
iterator over a given codim and partition type
Definition: macrogridview.hh:61
Codim Structure.
Definition: macrogridview.hh:96
Various macros to work with Dune module version numbers.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)