dune-grid  2.4.1
alu3dinclude.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_ALU3DINCLUDE_HH
4 #define DUNE_ALU3DINCLUDE_HH
5 
7 // compile imp.cc into lib (1 yes, 0 no)
8 // if you change this, you'll get what you deserve
10 #define COMPILE_ALUGRID_LIB 0
11 
12 #if COMPILE_ALUGRID_LIB
13  #define COMPILE_ALUGRID_INLINE 0
14 #else
15  #define COMPILE_ALUGRID_INLINE 1
16 #endif
17 
18 #if COMPILE_ALUGRID_INLINE
19 #define alu_inline inline
20 #else
21 #define alu_inline
22 #endif
23 
25 // all methods and classes of the ALUGrid are defined in the namespace
26 #define ALU3DSPACE ALUGridSpace ::
27 
28 #include <dune/common/parallel/mpicollectivecommunication.hh>
29 
31 
32 // if MPI was found include all headers
33 #if ALU3DGRID_PARALLEL
34 #include <alugrid_parallel.h>
35 #else
36 // if not, include only headers for serial version
37 #include <alugrid_serial.h>
38 #endif
39 
40 //- local includes
42 
43 namespace ALUGridSpace
44 {
45 
46  static const int ProcessorBoundary_t = Gitter::hbndseg_STI::closure;
47 
48  // general GatherScatter type
49  typedef GatherScatter GatherScatterType;
50 
51 }
52 
53 namespace Dune
54 {
55 
56  // typedef of ALU3dGridElementType see topology.hh
57 
58  // i.e. double or float
59  typedef double alu3d_ctype;
60 
61 
62 
63  // ALU3dBasicImplTraits
64  // --------------------
65 
66  template< class Comm >
68 
69  template<>
70  struct ALU3dBasicImplTraits< No_Comm >
71  {
72  typedef ALU3DSPACE Gitter GitterType;
73  typedef ALU3DSPACE GitterDuneImpl GitterImplType;
74 
75  typedef GitterType::helement_STI HElementType; // Interface Element
76  typedef GitterType::hface_STI HFaceType; // Interface Face
77  typedef GitterType::hedge_STI HEdgeType; // Interface Edge
78  typedef GitterType::vertex_STI VertexType; // Interface Vertex
79  typedef GitterType::hbndseg_STI HBndSegType;
80  typedef GitterType::ghostpair_STI GhostPairType;
81 
82  typedef HElementType PllElementType;
83 
84  typedef GitterType::Geometric::hedge1_GEO GEOEdgeType;
85 
87  template <class BndFaceType>
88  static bool isGhost( const BndFaceType* ghost )
89  {
90  return false ;
91  }
92  };
93 
94 #if ALU3DGRID_PARALLEL
95  template<>
96  struct ALU3dBasicImplTraits< MPI_Comm >
97  {
98  typedef ALU3DSPACE GitterDunePll GitterType;
99  typedef ALU3DSPACE GitterDunePll GitterImplType;
100 
101  typedef GitterType::helement_STI HElementType; // Interface Element
102  typedef GitterType::hface_STI HFaceType; // Interface Face
103  typedef GitterType::hedge_STI HEdgeType; // Interface Edge
104  typedef GitterType::vertex_STI VertexType; // Interface Vertex
105  typedef GitterType::hbndseg_STI HBndSegType;
106  typedef GitterType::ghostpair_STI GhostPairType;
107 
108  typedef ALU3DSPACE ElementPllXIF_t PllElementType;
109 
110  typedef GitterType::Geometric::hedge1_GEO GEOEdgeType;
111 
112  // method for ghost check
113  template <class BndFaceType>
114  static bool isGhost( const BndFaceType* ghost )
115  {
116  return ( ghost != 0 );
117  }
118  };
119 #endif // #if ALU3DGRID_PARALLEL
120 
121 
122 
123  // ALU3dCodimImplTraits
124  // --------------------
125 
126  template< ALU3dGridElementType elType, class Comm, int codim >
128 
129  template< class Comm >
130  struct ALU3dCodimImplTraits< tetra, Comm, 0 >
131  {
134 
135  typedef typename GitterType::helement_STI InterfaceType;
136  typedef typename GitterType::Geometric::hasFace3 EntitySeedType;
137  typedef typename GitterImplType::Objects::tetra_IMPL ImplementationType;
138  typedef typename GitterType::hbndseg_STI GhostInterfaceType;
139  typedef typename GitterImplType::Objects::Hbnd3Default GhostImplementationType;
140  };
141 
142  template< class Comm >
143  struct ALU3dCodimImplTraits< hexa, Comm, 0 >
144  {
147 
148  typedef typename GitterType::helement_STI InterfaceType;
149  typedef typename GitterType::Geometric::hasFace4 EntitySeedType;
150  typedef typename GitterImplType::Objects::hexa_IMPL ImplementationType;
151  typedef typename GitterType::hbndseg_STI GhostInterfaceType;
152  typedef typename GitterImplType::Objects::Hbnd4Default GhostImplementationType;
153  };
154 
155  template< class Comm >
156  struct ALU3dCodimImplTraits< tetra, Comm, 1 >
157  {
159 
160  typedef typename GitterType::hface_STI InterfaceType;
161  typedef InterfaceType EntitySeedType;
162  typedef typename GitterType::Geometric::hface3_GEO ImplementationType;
163  };
164 
165  template< class Comm >
166  struct ALU3dCodimImplTraits< hexa, Comm, 1 >
167  {
169 
170  typedef typename GitterType::hface_STI InterfaceType;
171  typedef InterfaceType EntitySeedType;
172  typedef typename GitterType::Geometric::hface4_GEO ImplementationType;
173  };
174 
175  template< ALU3dGridElementType elType, class Comm >
176  struct ALU3dCodimImplTraits< elType, Comm, 2 >
177  {
179 
180  typedef typename GitterType::hedge_STI InterfaceType;
181  typedef InterfaceType EntitySeedType;
182  typedef typename GitterType::Geometric::hedge1_GEO ImplementationType;
183  };
184 
185  template< ALU3dGridElementType elType, class Comm >
186  struct ALU3dCodimImplTraits< elType, Comm, 3 >
187  {
189 
190  typedef typename GitterType::vertex_STI InterfaceType;
191  typedef InterfaceType EntitySeedType;
192  typedef typename GitterType::Geometric::VertexGeo ImplementationType;
193  };
194 
195 
196 
197  // ALU3dImplTraits
198  // ---------------
199 
200  template< ALU3dGridElementType elType, class Comm >
202 
203  template< class Comm >
204  struct ALU3dImplTraits< tetra, Comm >
205  : public ALU3dBasicImplTraits< Comm >
206  {
209 
210  typedef typename GitterType::Geometric::hface3_GEO GEOFaceType;
211  typedef typename GitterType::Geometric::VertexGeo GEOVertexType;
212  typedef typename GitterImplType::Objects::tetra_IMPL IMPLElementType;
213  typedef typename GitterType::Geometric::tetra_GEO GEOElementType;
214  typedef typename GitterType::Geometric::periodic3_GEO GEOPeriodicType;
215  typedef typename GitterType::Geometric::hasFace3 HasFaceType;
216  typedef typename GitterType::Geometric::Hface3Rule HfaceRuleType;
217  typedef typename GitterImplType::Objects::Hbnd3Default BNDFaceType;
218  typedef typename GitterImplType::Objects::hbndseg3_IMPL ImplBndFaceType;
219 
220  typedef typename GitterType::Geometric::TetraRule MarkRuleType;
221 
222  // refinement and coarsening enum
223  enum { bisect_element_t =
224 #ifdef ALUGRID_PERIODIC_BOUNDARY_PARALLEL
225  MarkRuleType::bisect
226 #else
227  MarkRuleType::iso8
228 #endif
229  };
230  enum { refine_element_t = MarkRuleType::iso8 };
231  enum { coarse_element_t = MarkRuleType::crs };
232  enum { nosplit_element_t = MarkRuleType::nosplit };
233 
234  typedef std::pair< GEOFaceType *, int > NeighbourFaceType;
235  typedef std::pair< HasFaceType *, int > NeighbourPairType;
236 
237  template< int codim >
238  struct Codim
239  : public ALU3dCodimImplTraits< tetra, Comm, codim >
240  {};
241 
242  // access of faces
243  template <class Elem>
244  static const GEOFaceType* getFace( const Elem& elem, const int aluFace )
245  {
246  return elem.myhface3( aluFace );
247  }
248  };
249 
250  template< class Comm >
251  struct ALU3dImplTraits< hexa, Comm >
252  : public ALU3dBasicImplTraits< Comm >
253  {
256 
257  typedef typename GitterType::Geometric::hface4_GEO GEOFaceType;
258  typedef typename GitterType::Geometric::VertexGeo GEOVertexType;
259  typedef typename GitterImplType::Objects::hexa_IMPL IMPLElementType;
260  typedef typename GitterType::Geometric::hexa_GEO GEOElementType;
261  typedef typename GitterType::Geometric::periodic4_GEO GEOPeriodicType;
262  typedef typename GitterType::Geometric::hasFace4 HasFaceType;
263  typedef typename GitterType::Geometric::Hface4Rule HfaceRuleType;
264  typedef typename GitterImplType::Objects::Hbnd4Default BNDFaceType;
265  typedef typename GitterImplType::Objects::hbndseg4_IMPL ImplBndFaceType;
266 
267  typedef typename GitterType::Geometric::HexaRule MarkRuleType;
268 
269  // refinement and coarsening enum
270  enum { refine_element_t = MarkRuleType::iso8 };
271  enum { bisect_element_t = MarkRuleType::iso8 };
272  enum { coarse_element_t = MarkRuleType::crs };
273  enum { nosplit_element_t = MarkRuleType::nosplit };
274 
275  typedef std::pair< GEOFaceType *, int > NeighbourFaceType;
276  typedef std::pair< HasFaceType *, int > NeighbourPairType;
277 
278  template< int codim >
279  struct Codim
280  : public ALU3dCodimImplTraits< hexa, Comm, codim >
281  {};
282 
283  // access of faces
284  template <class Elem>
285  static const GEOFaceType* getFace( const Elem& elem, const int aluFace )
286  {
287  return elem.myhface4( aluFace );
288  }
289  };
290 
291 
292 
295  template< class Comm >
297  {
298  // level vertex iterator list
300  typedef std::vector< VertexType * > VertexListType;
301  typedef typename VertexListType::iterator IteratorType;
302 
304  : up2Date_( false )
305  {}
306 
307  size_t size () const { return vertexList_.size(); }
308 
309  bool up2Date () const { return up2Date_; }
310  void unsetUp2Date () { up2Date_ = false; }
311 
312  // make grid walkthrough and calc global size
313  template <class GridType>
314  void setupVxList (const GridType & grid, int level);
315 
316  IteratorType begin () { return vertexList_.begin(); }
317  IteratorType end () { return vertexList_.end(); }
318 
319  VertexListType & getItemList() { return vertexList_; }
320  private:
321  bool up2Date_;
322  VertexListType vertexList_;
323  };
324 
325 
328  template< class Comm >
330  {
331  // level vertex iterator list
333  typedef std::pair< VertexType *, int > ItemType;
334  typedef std::vector< ItemType > VertexListType;
335  typedef typename VertexListType::iterator IteratorType;
336 
338  : up2Date_( false )
339  {}
340 
341  size_t size () const { return vertexList_.size(); }
342 
343  bool up2Date () const { return up2Date_; }
344  void unsetUp2Date () { up2Date_ = false; }
345 
346  // make grid walkthrough and calc global size
347  template <class GridType>
348  void setupVxList (const GridType & grid);
349 
350  IteratorType begin () { return vertexList_.begin(); }
351  IteratorType end () { return vertexList_.end(); }
352 
353  VertexListType & getItemList() { return vertexList_; }
354 
355  int getLevel ( const VertexType &vertex ) const
356  {
357  const int idx = vertex.getIndex();
358  assert( idx >= 0 );
359  assert( idx < (int)size());
360  const ItemType & p = vertexList_[idx];
361  if( p.first == 0 )
362  return vertex.level();
363  else
364  return p.second;
365  }
366  private:
367  bool up2Date_;
368  VertexListType vertexList_;
369  };
370 
371 
372 
374  {
375  public:
376  // level vertex iterator list
377  typedef std::vector < void * > ItemListType;
378  typedef ItemListType :: iterator IteratorType;
379 
380  ALU3dGridItemList () : up2Date_(false) {}
381 
382  size_t size () const { return itemList_.size(); }
383 
384  bool up2Date () const { return up2Date_; }
385  void unsetUp2Date () { up2Date_ = false; }
386 
387  void markAsUp2Date() { up2Date_ = true; }
388 
389  IteratorType begin () { return itemList_.begin(); }
390  IteratorType end () { return itemList_.end(); }
391 
392  ItemListType & getItemList() { return itemList_; }
393 
394  private:
395  bool up2Date_;
396  ItemListType itemList_;
397  };
398 
400 
402  // some helper functions
404 
405  template< class Comm >
407  {
408  static const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
409  getFace( const typename ALU3dImplTraits< tetra, Comm >::GEOElementType& elem, int index)
410  {
411  assert(index >= 0 && index < 4);
412  return elem.myhface3( ElementTopologyMapping< tetra >::dune2aluFace(index) );
413  }
414 
415  static const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType*
416  getFace( const typename ALU3dImplTraits< hexa, Comm >::GEOElementType &elem, int index )
417  {
418  assert(index >= 0 && index < 6);
419  return elem.myhface4( ElementTopologyMapping< hexa >::dune2aluFace(index) );
420  }
421  };
422 
423 } // end namespace Dune
424 
425 #endif // #ifndef DUNE_ALU3DINCLUDE_HH
Definition: alu3dinclude.hh:329
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:132
GitterType::Geometric::hedge1_GEO GEOEdgeType
Definition: alu3dinclude.hh:84
static const ALU3dImplTraits< tetra, Comm >::GEOFaceType * getFace(const typename ALU3dImplTraits< tetra, Comm >::GEOElementType &elem, int index)
Definition: alu3dinclude.hh:409
Definition: alu3dinclude.hh:201
bool up2Date() const
Definition: alu3dinclude.hh:343
InterfaceType EntitySeedType
Definition: alu3dinclude.hh:181
GitterType::hbndseg_STI GhostInterfaceType
Definition: alu3dinclude.hh:151
InterfaceType EntitySeedType
Definition: alu3dinclude.hh:191
GitterType::Geometric::hasFace3 HasFaceType
Definition: alu3dinclude.hh:215
VertexListType & getItemList()
Definition: alu3dinclude.hh:353
GitterImplType::Objects::hbndseg4_IMPL ImplBndFaceType
Definition: alu3dinclude.hh:265
GitterImplType::Objects::hexa_IMPL ImplementationType
Definition: alu3dinclude.hh:150
std::pair< GEOFaceType *, int > NeighbourFaceType
Definition: alu3dinclude.hh:234
static const GEOFaceType * getFace(const Elem &elem, const int aluFace)
Definition: alu3dinclude.hh:285
GitterType::Geometric::VertexGeo GEOVertexType
Definition: alu3dinclude.hh:258
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:158
ALU3dGridItemList ALU3dGridItemListType
Definition: alu3dinclude.hh:399
GitterType::Geometric::hface4_GEO ImplementationType
Definition: alu3dinclude.hh:172
GitterType::Geometric::periodic4_GEO GEOPeriodicType
Definition: alu3dinclude.hh:261
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:145
GitterType::Geometric::periodic3_GEO GEOPeriodicType
Definition: alu3dinclude.hh:214
GitterType::Geometric::hface3_GEO ImplementationType
Definition: alu3dinclude.hh:162
void unsetUp2Date()
Definition: alu3dinclude.hh:385
GitterImplType::Objects::hexa_IMPL IMPLElementType
Definition: alu3dinclude.hh:259
ALU3dBasicImplTraits< Comm >::VertexType VertexType
Definition: alu3dinclude.hh:332
size_t size() const
Definition: alu3dinclude.hh:341
IteratorType end()
Definition: alu3dinclude.hh:390
Definition: alu3dinclude.hh:43
InterfaceType EntitySeedType
Definition: alu3dinclude.hh:161
ALU3dGridItemList()
Definition: alu3dinclude.hh:380
GitterImplType::Objects::tetra_IMPL ImplementationType
Definition: alu3dinclude.hh:137
GitterType::helement_STI InterfaceType
Definition: alu3dinclude.hh:148
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:254
Definition: alu3dinclude.hh:127
Ghost ghost
PartitionSet for the ghost partition.
Definition: partitionset.hh:238
static const int ProcessorBoundary_t
Definition: alu3dinclude.hh:46
GitterType::helement_STI HElementType
Definition: alu3dinclude.hh:75
IteratorType begin()
Definition: alu3dinclude.hh:316
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:168
VertexListType::iterator IteratorType
Definition: alu3dinclude.hh:335
GitterType::Geometric::VertexGeo ImplementationType
Definition: alu3dinclude.hh:192
GatherScatter GatherScatterType
Definition: alu3dinclude.hh:49
void unsetUp2Date()
Definition: alu3dinclude.hh:310
ALU3DSPACE GitterDuneImpl GitterImplType
Definition: alu3dinclude.hh:73
GitterType::hedge_STI InterfaceType
Definition: alu3dinclude.hh:180
GitterImplType::Objects::Hbnd3Default BNDFaceType
Definition: alu3dinclude.hh:217
Definition: alu3dinclude.hh:296
GitterType::Geometric::Hface3Rule HfaceRuleType
Definition: alu3dinclude.hh:216
std::pair< VertexType *, int > ItemType
Definition: alu3dinclude.hh:333
GitterType::hedge_STI HEdgeType
Definition: alu3dinclude.hh:77
GitterType::hface_STI HFaceType
Definition: alu3dinclude.hh:76
GitterImplType::Objects::tetra_IMPL IMPLElementType
Definition: alu3dinclude.hh:212
Definition: topology.hh:13
GitterType::Geometric::hasFace4 EntitySeedType
Definition: alu3dinclude.hh:149
GitterType::Geometric::hexa_GEO GEOElementType
Definition: alu3dinclude.hh:260
void setupVxList(const GridType &grid)
GitterType::hface_STI InterfaceType
Definition: alu3dinclude.hh:170
ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType
Definition: alu3dinclude.hh:208
void setupVxList(const GridType &grid, int level)
GitterType::vertex_STI VertexType
Definition: alu3dinclude.hh:78
GitterImplType::Objects::Hbnd4Default BNDFaceType
Definition: alu3dinclude.hh:264
Definition: alu3dinclude.hh:373
int getLevel(const VertexType &vertex) const
Definition: alu3dinclude.hh:355
ALU3dGridVertexList()
Definition: alu3dinclude.hh:303
InterfaceType EntitySeedType
Definition: alu3dinclude.hh:171
void unsetUp2Date()
Definition: alu3dinclude.hh:344
std::pair< HasFaceType *, int > NeighbourPairType
Definition: alu3dinclude.hh:235
GitterType::hbndseg_STI HBndSegType
Definition: alu3dinclude.hh:79
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:178
GitterImplType::Objects::Hbnd4Default GhostImplementationType
Definition: alu3dinclude.hh:152
GitterType::Geometric::hface4_GEO GEOFaceType
Definition: alu3dinclude.hh:257
IteratorType end()
Definition: alu3dinclude.hh:317
size_t size() const
Definition: alu3dinclude.hh:382
ItemListType::iterator IteratorType
Definition: alu3dinclude.hh:378
GitterType::Geometric::Hface4Rule HfaceRuleType
Definition: alu3dinclude.hh:263
VertexListType::iterator IteratorType
Definition: alu3dinclude.hh:301
ALU3DSPACE Gitter GitterType
Definition: alu3dinclude.hh:72
std::pair< GEOFaceType *, int > NeighbourFaceType
Definition: alu3dinclude.hh:275
#define ALU3DSPACE
Definition: alu3dinclude.hh:26
GitterType::Geometric::hedge1_GEO ImplementationType
Definition: alu3dinclude.hh:182
double alu3d_ctype
Definition: alu3dinclude.hh:59
GitterType::Geometric::hasFace4 HasFaceType
Definition: alu3dinclude.hh:262
Definition: common.hh:179
IteratorType begin()
Definition: alu3dinclude.hh:350
GitterType::Geometric::hface3_GEO GEOFaceType
Definition: alu3dinclude.hh:210
bool up2Date() const
Definition: alu3dinclude.hh:384
IteratorType begin()
Definition: alu3dinclude.hh:389
ALU3dBasicImplTraits< Comm >::VertexType VertexType
Definition: alu3dinclude.hh:299
size_t size() const
Definition: alu3dinclude.hh:307
GitterImplType::Objects::hbndseg3_IMPL ImplBndFaceType
Definition: alu3dinclude.hh:218
static const ALU3dImplTraits< hexa, Comm >::GEOFaceType * getFace(const typename ALU3dImplTraits< hexa, Comm >::GEOElementType &elem, int index)
Definition: alu3dinclude.hh:416
Definition: topology.hh:40
GitterType::Geometric::tetra_GEO GEOElementType
Definition: alu3dinclude.hh:213
IteratorType end()
Definition: alu3dinclude.hh:351
void markAsUp2Date()
Definition: alu3dinclude.hh:387
GitterType::vertex_STI InterfaceType
Definition: alu3dinclude.hh:190
GitterType::Geometric::HexaRule MarkRuleType
Definition: alu3dinclude.hh:267
Definition: topology.hh:13
VertexListType & getItemList()
Definition: alu3dinclude.hh:319
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:188
bool up2Date() const
Definition: alu3dinclude.hh:309
static const GEOFaceType * getFace(const Elem &elem, const int aluFace)
Definition: alu3dinclude.hh:244
GitterType::hface_STI InterfaceType
Definition: alu3dinclude.hh:160
GitterType::Geometric::VertexGeo GEOVertexType
Definition: alu3dinclude.hh:211
std::pair< HasFaceType *, int > NeighbourPairType
Definition: alu3dinclude.hh:276
std::vector< void * > ItemListType
Definition: alu3dinclude.hh:377
Definition: alu3dinclude.hh:67
Include standard header files.
Definition: agrid.hh:59
GitterType::ghostpair_STI GhostPairType
Definition: alu3dinclude.hh:80
ALU3dBasicImplTraits< Comm >::GitterType GitterType
Definition: alu3dinclude.hh:207
GitterType::Geometric::TetraRule MarkRuleType
Definition: alu3dinclude.hh:220
HElementType PllElementType
Definition: alu3dinclude.hh:82
GitterType::helement_STI InterfaceType
Definition: alu3dinclude.hh:135
GitterImplType::Objects::Hbnd3Default GhostImplementationType
Definition: alu3dinclude.hh:139
ItemListType & getItemList()
Definition: alu3dinclude.hh:392
Definition: alu3dinclude.hh:406
ALU3dGridLeafVertexList()
Definition: alu3dinclude.hh:337
std::vector< VertexType * > VertexListType
Definition: alu3dinclude.hh:300
ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType
Definition: alu3dinclude.hh:133
GitterType::Geometric::hasFace3 EntitySeedType
Definition: alu3dinclude.hh:136
static bool isGhost(const BndFaceType *ghost)
method for ghost check
Definition: alu3dinclude.hh:88
GitterType::hbndseg_STI GhostInterfaceType
Definition: alu3dinclude.hh:138
ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType
Definition: alu3dinclude.hh:255
std::vector< ItemType > VertexListType
Definition: alu3dinclude.hh:334
ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType
Definition: alu3dinclude.hh:146