Dune Core Modules (2.4.2)

alu3dinclude.hh
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
24
25// all methods and classes of the ALUGrid are defined in the namespace
26#define ALU3DSPACE ALUGridSpace ::
27
29
30#include <dune/grid/alugrid/common/checkparallel.hh>
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
41#include <dune/grid/alugrid/3d/topology.hh>
42
43namespace 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
53namespace 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 >
67 struct ALU3dBasicImplTraits;
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 >
127 struct ALU3dCodimImplTraits;
128
129 template< class Comm >
130 struct ALU3dCodimImplTraits< tetra, Comm, 0 >
131 {
132 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
133 typedef typename ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType;
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 {
145 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
146 typedef typename ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType;
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 {
158 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
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 {
168 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
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 {
178 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
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 {
188 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
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 >
201 struct ALU3dImplTraits;
202
203 template< class Comm >
204 struct ALU3dImplTraits< tetra, Comm >
205 : public ALU3dBasicImplTraits< Comm >
206 {
207 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
208 typedef typename ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType;
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 {
254 typedef typename ALU3dBasicImplTraits< Comm >::GitterType GitterType;
255 typedef typename ALU3dBasicImplTraits< Comm >::GitterImplType GitterImplType;
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
299 typedef typename ALU3dBasicImplTraits< Comm >::VertexType VertexType;
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
332 typedef typename ALU3dBasicImplTraits< Comm >::VertexType VertexType;
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
373 class ALU3dGridItemList
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
399 typedef ALU3dGridItemList ALU3dGridItemListType;
400
402 // some helper functions
404
405 template< class Comm >
406 struct ALU3dGridFaceGetter
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
static int dune2aluFace(int index)
Maps face index from Dune onto ALU3dGrid reference element.
Definition: topology.hh:175
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Implements an utility class that provides MPI's collective communication methods.
Dune namespace.
Definition: alignment.hh:10
Definition: alu3dinclude.hh:330
Definition: alu3dinclude.hh:297
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)