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