Debian Codegraph @

dune/uggrid/gm/pargm.h

raw
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5 /*! \file pargm.h
6 * \ingroup gm
7 */
8
9
10 /****************************************************************************/
11 /* */
12 /* File: pargm.h */
13 /* */
14 /* Purpose: defines for parallel grid manager */
15 /* */
16 /* Author: Stefan Lang, Klaus Birken */
17 /* Institut fuer Computeranwendungen III */
18 /* Universitaet Stuttgart */
19 /* Pfaffenwaldring 27 */
20 /* 70550 Stuttgart */
21 /* email: [email protected] */
22 /* phone: 0049-(0)711-685-7003 */
23 /* fax : 0049-(0)711-685-7000 */
24 /* */
25 /* History: 960410 kb created from parallel.h */
26 /* */
27 /* Remarks: */
28 /* */
29 /****************************************************************************/
30
31
32 /****************************************************************************/
33 /* */
34 /* auto include mechanism and other include files */
35 /* */
36 /****************************************************************************/
37
38 #ifndef __PARGM_H__
39 #define __PARGM_H__
40
41 #include <dune/uggrid/low/namespace.h>
42 #include <dune/uggrid/low/ugtypes.h>
43
44 #ifdef ModelP
45 #include <dune/uggrid/parallel/ddd/include/ddd.h>
46 #include <dune/uggrid/parallel/ppif/ppif.h>
47 #endif
48
49
50 START_UGDIM_NAMESPACE
51
52 /****************************************************************************/
53 /* */
54 /* defines in the following order */
55 /* */
56 /* compile time constants defining static data size (i.e. arrays) */
57 /* other constants */
58 /* macros */
59 /* */
60 /****************************************************************************/
61
62 /* object priorities */
63 enum Priorities
64 {
65 PrioNone = 0,
66 PrioHGhost = 1,
67 PrioVGhost = 2,
68 PrioVHGhost = 3,
69 PrioBorder = 4,
70 PrioMaster = 5
71 };
72
73 /* define dynamic lists ids */
74 enum DynamicListId {ELEMENT_LIST,
75 NODE_LIST,
76 VECTOR_LIST,
77 VERTEX_LIST};
78
79 #ifdef ModelP
80
81 /* define number of priorities for objects */
82 enum {MAX_PRIOS = 6};
83 enum {ELEMENT_PRIOS = 4};
84 enum {NODE_PRIOS = 5};
85 enum {VECTOR_PRIOS = 5};
86 enum {VERTEX_PRIOS = 5};
87
88 /* define number of listparts for objects */
89 enum {MAX_LISTPARTS = 8};
90 enum {ELEMENT_LISTPARTS = 2};
91 enum {NODE_LISTPARTS = 3};
92 enum {VECTOR_LISTPARTS = 3};
93 enum {VERTEX_LISTPARTS = 3};
94
95 /* define mapping from object priority to position in linked list */
96 #define PRIO2LISTPART(listtype,prio) \
97 ((listtype == ELEMENT_LIST) ? ((prio == PrioHGhost) ? 0 : \
98 (prio == PrioVGhost) ? 0 : (prio == PrioVHGhost) ? 0 : \
99 (prio == PrioMaster) ? 1 : -1) : \
100 ((prio == PrioHGhost) ? 0 : (prio ==PrioVGhost) ? 0 : \
101 (prio == PrioVHGhost) ? 0 : \
102 (prio == PrioBorder) ? 2 : (prio == PrioMaster) ? 2 : -1))
103
104 /* define mapping from position in linked list to object priority */
105 #define LISTPART2PRIO(listtype,listpart,prios) \
106 { \
107 INT Entry; \
108 for (Entry=0; Entry<MAX_LISTPARTS; Entry++) prios[Entry] = -1; \
109 Entry = 0; \
110 if (listtype == ELEMENT_LIST) \
111 { \
112 if (listpart == 0) \
113 { \
114 prios[Entry++] = PrioHGhost; \
115 prios[Entry++] = PrioVGhost; \
116 prios[Entry++] = PrioVHGhost; \
117 } \
118 else if(listpart == 1) prios[Entry++] = PrioMaster; \
119 } \
120 else \
121 { \
122 if (listpart == 0) \
123 { \
124 prios[Entry++] = PrioHGhost; \
125 prios[Entry++] = PrioVGhost; \
126 prios[Entry++] = PrioVHGhost; \
127 } \
128 else if (listpart == 2) \
129 { \
130 prios[Entry++] = PrioBorder; \
131 prios[Entry++] = PrioMaster; \
132 } \
133 } \
134 }
135
136 /* define mapping from element priority to index in son array of father */
137 #define PRIO2INDEX(prio) \
138 ((prio==PrioHGhost || prio==PrioVGhost || prio==PrioVHGhost) ? 1 : \
139 (prio == PrioMaster) ? 0 : -1)
140
141 /* map pointer to structure onto a pointer to its DDD_HDR */
142 #define PARHDR(obj) (&((obj)->ddd))
143
144 #define GETGID(x) (( OBJT(x)==IEOBJ || OBJT(x)==BEOBJ) ? EGID((ELEMENT*)(x)) : \
145 ((OBJT(x)==IVOBJ || OBJT(x)==BVOBJ) ? VXGID((VERTEX *)(x)) :\
146 ((OBJT(x)==NDOBJ || OBJT(x)==VEOBJ || OBJT(x)==EDOBJ) ? \
147 GID((NODE *)(x)) : -1)))
148
149 #else /* not ModelP */
150
151 /* define number of priorities for objects */
152 enum {MAX_PRIOS = 1};
153 enum {ELEMENT_PRIOS = 1};
154 enum {NODE_PRIOS = 1};
155 enum {VECTOR_PRIOS = 1};
156 enum {VERTEX_PRIOS = 1};
157
158 /* define number of listparts for objects */
159 enum {MAX_LISTPARTS = 1};
160 enum {ELEMENT_LISTPARTS = 1};
161 enum {NODE_LISTPARTS = 1};
162 enum {VECTOR_LISTPARTS = 1};
163 enum {VERTEX_LISTPARTS = 1};
164
165 /** \brief define mapping from object priority to position in linked list */
166 #define PRIO2LISTPART(listtype,prio) 0
167
168 /* define mapping from position in linked list to object priority */
169 #define LISTPART2PRIO(listtype,listpart,prios) 0
170
171 /* define mapping from position in linked list to object priority */
172 #define PRIO2INDEX(prio) 0
173
174 #endif
175
176 /*
177 printing of IDs via printf()
178
179 use ID_FMT as format string, and ID_PRT as macro for printing.
180 example of usage:
181
182 printf("NodeId " ID_FMT "\n", ID_PRT(theNode));
183
184 ID_FFMT (fixed format) is a version of ID_FMT with fixed width.
185 ID_FFMTE (extended) is a version of ID_FFMT with additional information.
186
187 in ModelP, additionally the DDD_GlobalID is printed for each object.
188
189 NOTE: for vertices and elements, one must use the VID_ and EID_ macros,
190 respectively. this is due to differences in data structures
191 (unions -> PARHDRV/PARHDRE ->VID_/EID_)
192 */
193
194 #ifdef ModelP
195
196 #define ID_FMT "%ld/" GID_FMT
197 #define ID_FFMT "%9ld/" GID_FMT
198 #define ID_PRT(x) ((long)ID(x)),GID(x)
199 #define ID_FMTE "%ld/" GID_FMT "/%d"
200 #define ID_FFMTE "%9ld/" GID_FMT "/%02d"
201 #define ID_PRTE(x) ((long)ID(x)),GID(x),PRIO(x)
202 #define ID_FMTX "%d/%ld/" GID_FMT "/%d"
203 #define ID_FFMTX "%x/%9ld/" GID_FMT "/%02d"
204 #define ID_PRTX(x) KeyForObject((KEY_OBJECT *)x),((long)ID(x)),GID(x),PRIO(x)
205
206 #define VID_FMT ID_FMT
207 #define VID_FFMT ID_FFMT
208 #define VID_PRT(x) ((long)ID(x)),VXGID(x)
209 #define VID_FMTE ID_FMTE
210 #define VID_FFMTE ID_FFMTE
211 #define VID_PRTE(x) ((long)ID(x)),VXGID(x),VXPRIO(x)
212 #define VID_FMTX ID_FMTX "/%d"
213 #define VID_FFMTX ID_FFMTX "/%d"
214 #define VID_PRTX(x) KeyForObject((KEY_OBJECT *)x),((long)ID(x)),VXGID(x),VXPRIO(x),LEVEL(x)
215
216 #define EID_FMT ID_FMT
217 #define EID_FFMT ID_FFMT
218 #define EID_PRT(x) ((long)ID(x)),EGID(x)
219 #define EID_FMTE ID_FMTE
220 #define EID_FFMTE ID_FFMTE
221 #define EID_PRTE(x) ((long)ID(x)),EGID(x),EPRIO(x)
222 #define EID_FMTX ID_FMTX "/%d/%d/%d/%d"
223 #define EID_FFMTX ID_FFMTX "/%d"
224 #define EID_PRTX(x) KeyForObject((KEY_OBJECT *)x),((long)ID(x)),EGID(x),EPRIO(x),TAG(x),\
225 LEVEL(x),ECLASS(x),REFINECLASS(x)
226
227 #define VINDEX_FMT ID_FMT
228 #define VINDEX_FFMT ID_FFMT
229 #define VINDEX_PRT(x) ((long)VINDEX(x)),GID(x)
230 #define VINDEX_FMTE ID_FMTE
231 #define VINDEX_FFMTE ID_FFMTE
232 #define VINDEX_PRTE(x) ((long)VINDEX(x)),GID(x),PRIO(x)
233 #define VINDEX_FMTX ID_FMTX
234 #define VINDEX_FFMTX ID_FFMTX
235 #define VINDEX_PRTX(x) KeyForObject((KEY_OBJECT *)x),((long)VINDEX(x)),GID(x),PRIO(x)
236
237 #define EDID_FMT GID_FMT
238 #define EDID_FFMT EDID_FMT
239 #define EDID_PRT(x) GID(x)
240 #define EDID_FMTE GID_FMT "/%d"
241 #define EDID_FFMTE EDID_FMTE
242 #define EDID_PRTE(x) GID(x),PRIO(x)
243 #define EDID_FMTX "%x/" GID_FMT "/%d"
244 #define EDID_FFMTX EDID_FMTX
245 #define EDID_PRTX(x) x,GID(x),PRIO(x)
246
247
248 #define PFMT "%3d:"
249
250 /* PAR/ENDPAR parallel preprocessor statements */
251 /* to select code only valid for ModelP */
252 #define PAR(x) x
253 #define ENDPAR
254
255 #else
256
257 #define ID_FMT "%ld"
258 #define ID_FFMT "%9ld"
259 #define ID_PRT(x) ((long)ID(x))
260 #define ID_FMTE "%ld"
261 #define ID_FFMTE "%9ld"
262 #define ID_PRTE(x) ID_PRT(x)
263 #define ID_FMTX "%ld"
264 #define ID_FFMTX "%9ld"
265 #define ID_PRTX(x) ID_PRT(x)
266
267 #define VID_FMT ID_FMT
268 #define VID_FFMT ID_FFMT
269 #define VID_PRT(x) ID_PRT(x)
270 #define VID_FMTE ID_FMTE
271 #define VID_FFMTE ID_FFMTE
272 #define VID_PRTE(x) VID_PRT(x)
273 #define VID_FMTX ID_FMTX
274 #define VID_FFMTX ID_FFMTX
275 #define VID_PRTX(x) VID_PRT(x)
276
277 #define EID_FMT ID_FMT
278 #define EID_FFMT ID_FFMT
279 #define EID_PRT(x) ID_PRT(x)
280 #define EID_FMTE ID_FMTE
281 #define EID_FFMTE ID_FFMTE
282 #define EID_PRTE(x) EID_PRT(x)
283 #define EID_FMTX ID_FMTX
284 #define EID_FFMTX ID_FFMTX
285 #define EID_PRTX(x) EID_PRT(x)
286
287 #define VINDEX_FMT ID_FMT
288 #define VINDEX_FFMT ID_FFMT
289 #define VINDEX_PRT(x) ((long)VINDEX(x))
290 #define VINDEX_FMTE ID_FMTE
291 #define VINDEX_FFMTE ID_FFMTE
292 #define VINDEX_PRTE(x) VINDEX_PRT(x)
293 #define VINDEX_FMTX ID_FMTX
294 #define VINDEX_FFMTX ID_FFMTX
295 #define VINDEX_PRTX(x) VINDEX_PRT(x)
296
297 #define EDID_FMT "%08x"
298 #define EDID_FFMT EDID_FMT
299 #define EDID_PRT(x) (x)
300 #define EDID_FMTE "%08x"
301 #define EDID_FFMTE EDID_FMTE
302 #define EDID_PRTE(x) (x)
303 #define EDID_FMTX "%08x"
304 #define EDID_FFMTX EDID_FMTX
305 #define EDID_PRTX(x) (x)
306
307 #define PFMT "%1d:"
308 #define GID_FMT "%1d"
309
310 /* dummies for global id */
311 #define EGID(e) ID(e)
312 #define GID(e) ((OBJT(e)==VEOBJ) ? VINDEX((VECTOR *)e) : ID(e))
313 #define VGID(e) ID(e)
314
315 /* PAR/ENDPAR parallel preprocessor statements */
316 /* for serial case expanded to code x is ignored */
317 #define PAR(x)
318 #define ENDPAR
319
320 #define GetAllSons(e,s) GetSons(e,s)
321
322 /* dummy defines for serial case according to parallel defines in parallel.h */
323 /* dummies for elements */
324 #define EMASTER(p) 1
325 #define EGHOST(p) 0
326 #define EHGHOST(p) 0
327 #define EVGHOST(p) 0
328 #define EPRIO(p) 0
329 #define SETEPRIO(context, p,i) ;
330 #define EMASTERPRIO(p) 1
331 #define EPROCLIST(context, p) (&_proclist_)
332 #define ENCOPIES(context, p) 1
333 #define PARTITION(p) _partition_
334
335 /* dummies for nodes, vectors, edges */
336 #define MASTER(p) 1
337 #define GHOST(p) 0
338 #define HGHOST(p) 0
339 #define VGHOST(p) 0
340 #define PRIO(p) 0
341 #define EPRIO(p) 0
342 #define VXPRIO(p) 0
343 #define SETPRIO(context, p,i) ;
344 #define PROCLIST(context, p) (&_proclist_)
345 #define NCOPIES(context, p) 1
346
347 /* dummies for vertices */
348 #define SETVXPRIO(context, e,p) ;
349
350 /* ddd dummies */
351 #define DDD_OBJ void *
352 #define DDD_IdentifyBegin(context)
353 #define DDD_IdentifyEnd(context)
354 #define DDD_IdentifyNumber(context, o,p,n)
355 #define DDD_IFAOneway(context, p1,p2,p3,p4,p5,p6)
356
357 /* ppif dummies */
358 #define Broadcast(context, p,n) ((int)0)
359
360 /* dummys for reduction functions implemented in dune/uggrid/parallel/dddif/support.c */
361 #define UG_GlobalSumINT(context, x) x
362 #define UG_GlobalMaxINT(context, x) x
363 #define UG_GlobalMinINT(context, x) x
364 #define UG_GlobalSumNINT(context, x,y)
365 #define UG_GlobalMaxNINT(context, x,y)
366 #define UG_GlobalMinNINT(context, x,y)
367 #define UG_GlobalSumDOUBLE(context, x) x
368 #define UG_GlobalMaxDOUBLE(context, x) x
369 #define UG_GlobalMinDOUBLE(context, x) x
370 #define UG_GlobalSumNDOUBLE(context, x,y)
371 #define UG_GlobalMaxNDOUBLE(context, x,y)
372 #define UG_GlobalMinNDOUBLE(context, x,y)
373 #endif
374
375
376 /****************************************************************************/
377 /* */
378 /* exported global variables */
379 /* */
380 /****************************************************************************/
381
382 /****************************************************************************/
383 /* */
384 /* function declarations */
385 /* */
386 /****************************************************************************/
387
388 /* functions implemented in dune/uggrid/parallel/dddif/support.c */
389 #ifdef ModelP
390 INT UG_GlobalSumINT (const PPIF::PPIFContext& context, INT x);
391 INT UG_GlobalMaxINT (const PPIF::PPIFContext& context, INT x);
392 INT UG_GlobalMinINT (const PPIF::PPIFContext& context, INT x);
393 void UG_GlobalSumNINT (const PPIF::PPIFContext& context, INT n, INT *x);
394 void UG_GlobalMaxNINT (const PPIF::PPIFContext& context, INT n, INT *x);
395 void UG_GlobalMinNINT (const PPIF::PPIFContext& context, INT n, INT *x);
396 DOUBLE UG_GlobalSumDOUBLE (const PPIF::PPIFContext& context, DOUBLE i);
397 DOUBLE UG_GlobalMaxDOUBLE (const PPIF::PPIFContext& context, DOUBLE i);
398 DOUBLE UG_GlobalMinDOUBLE (const PPIF::PPIFContext& context, DOUBLE i);
399 void UG_GlobalSumNDOUBLE (const PPIF::PPIFContext& context, INT n, DOUBLE *x);
400 void UG_GlobalMaxNDOUBLE (const PPIF::PPIFContext& context, INT n, DOUBLE *x);
401 void UG_GlobalMinNDOUBLE (const PPIF::PPIFContext& context, INT n, DOUBLE *x);
402 #endif
403
404 END_UGDIM_NAMESPACE
405
406 #endif /* __PARGM_H__ */