| 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 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: parallel.h */ |
| 8 |
/* */ |
| 9 |
/* Purpose: defines for parallel ugp version 3 */ |
| 10 |
/* */ |
| 11 |
/* Author: Stefan Lang, Klaus Birken */ |
| 12 |
/* Institut fuer Computeranwendungen III */ |
| 13 |
/* Universitaet Stuttgart */ |
| 14 |
/* Pfaffenwaldring 27 */ |
| 15 |
/* 70550 Stuttgart */ |
| 16 |
/* email: [email protected] */ |
| 17 |
/* phone: 0049-(0)711-685-7003 */ |
| 18 |
/* fax : 0049-(0)711-685-7000 */ |
| 19 |
/* */ |
| 20 |
/* History: 09.05.95 begin, ugp version 3.0 */ |
| 21 |
/* */ |
| 22 |
/* Remarks: */ |
| 23 |
/* */ |
| 24 |
/****************************************************************************/ |
| 25 |
|
| 26 |
|
| 27 |
/****************************************************************************/ |
| 28 |
/* */ |
| 29 |
/* auto include mechanism and other include files */ |
| 30 |
/* */ |
| 31 |
/****************************************************************************/ |
| 32 |
|
| 33 |
#ifndef __PARALLEL_H__ |
| 34 |
#define __PARALLEL_H__ |
| 35 |
|
| 36 |
#include <memory> |
| 37 |
|
| 38 |
#ifdef ModelP |
| 39 |
# include <dune/uggrid/parallel/ddd/dddcontext.hh> |
| 40 |
# include <dune/uggrid/parallel/ppif/ppif.h> |
| 41 |
#endif |
| 42 |
|
| 43 |
#include <dune/uggrid/low/heaps.h> |
| 44 |
#include <dune/uggrid/low/namespace.h> |
| 45 |
|
| 46 |
#ifdef ModelP |
| 47 |
#include <dune/uggrid/parallel/ddd/include/ddd.h> |
| 48 |
#endif |
| 49 |
|
| 50 |
#include <dune/uggrid/gm/gm.h> |
| 51 |
#include <dune/uggrid/gm/pargm.h> |
| 52 |
|
| 53 |
START_UGDIM_NAMESPACE |
| 54 |
|
| 55 |
/****************************************************************************/ |
| 56 |
/* */ |
| 57 |
/* defines in the following order */ |
| 58 |
/* */ |
| 59 |
/* compile time constants defining static data size (i.e. arrays) */ |
| 60 |
/* other constants */ |
| 61 |
/* macros */ |
| 62 |
/* */ |
| 63 |
/****************************************************************************/ |
| 64 |
|
| 65 |
#ifndef DUNE_UGGRID_HAVE_DDDCONTEXT |
| 66 |
# define DUNE_UGGRID_HAVE_DDDCONTEXT 1 |
| 67 |
#endif |
| 68 |
|
| 69 |
#define MAXDDDTYPES 32 |
| 70 |
|
| 71 |
enum HandlerSets |
| 72 |
{ |
| 73 |
HSET_XFER = 0, |
| 74 |
HSET_REFINE |
| 75 |
}; |
| 76 |
|
| 77 |
|
| 78 |
#ifdef ModelP |
| 79 |
|
| 80 |
/* CE for nodes */ |
| 81 |
/* not used, kb 961216 |
| 82 |
#define KEEP_VECTOR 0*/ /* this is a node with vector */ |
| 83 |
/*#define DEL_VECTOR 1*/ /* this is a node without vector */ |
| 84 |
|
| 85 |
/* status output from different parallel phases */ |
| 86 |
/* |
| 87 |
#define STAT_OUT |
| 88 |
*/ |
| 89 |
|
| 90 |
/* define DDD_PRIO_ENV to change priority using fast PrioBegin/End env. */ |
| 91 |
/* |
| 92 |
#define DDD_PRIO_ENV |
| 93 |
*/ |
| 94 |
#ifdef DDD_PRIO_ENV |
| 95 |
#define DDD_PrioritySet(context, h,p) {ObjectPriorityUpdate(context, (DDD_OBJ)h,p); DDD_PrioChange(context, h,p);} |
| 96 |
#endif |
| 97 |
|
| 98 |
#define UGTYPE(context, t) (ddd_ctrl(context).ugtypes[(t)]) |
| 99 |
#define DDDTYPE(context, t) (ddd_ctrl(context).types[(t)]) |
| 100 |
#define HAS_DDDHDR(context, t) (ddd_ctrl(context).dddObj[(t)]) |
| 101 |
|
| 102 |
#define DDD_DOMAIN_DATA DDD_USER_DATA+1 |
| 103 |
#define DDD_EXTRA_DATA DDD_USER_DATA+2 |
| 104 |
|
| 105 |
/* macros for ddd object info */ |
| 106 |
/* for elements */ |
| 107 |
#define EPRIO(e) (Priorities)DDD_InfoPriority(PARHDRE(e)) |
| 108 |
#define SETEPRIO(context, e,p) DDD_PrioritySet(context, PARHDRE(e),p) |
| 109 |
#define SETEPRIOX(context, e,p) if (EPRIO(e)!=p) DDD_PrioritySet(context, PARHDRE(e),p) |
| 110 |
#define EMASTER(e) (EPRIO(e) == PrioMaster) |
| 111 |
#define EGHOST(e) (EPRIO(e)==PrioHGhost || EPRIO(e)==PrioVGhost ||\ |
| 112 |
EPRIO(e)==PrioVHGhost) |
| 113 |
#define EVHGHOST(e) (EPRIO(e)==PrioVHGhost) |
| 114 |
#define EVGHOST(e) (EPRIO(e)==PrioVGhost || EPRIO(e)==PrioVHGhost) |
| 115 |
#define EHGHOST(e) (EPRIO(e)==PrioHGhost || EPRIO(e)==PrioVHGhost) |
| 116 |
#define EGID(e) DDD_InfoGlobalId(PARHDRE(e)) |
| 117 |
#define EPROCLIST(context, e) DDD_InfoProcListRange(context, PARHDRE(e)) |
| 118 |
#define EPROCPRIO(context, e,p) DDD_InfoProcPrio(context, PARHDRE(e),p) |
| 119 |
#define ENCOPIES(context, e) DDD_InfoNCopies(context, PARHDRE(e)) |
| 120 |
#define EATTR(e) DDD_InfoAttr(PARHDRE(e)) |
| 121 |
#define XFEREDELETE(context, e) DDD_XferDeleteObj(context, PARHDRE(e)) |
| 122 |
#define XFERECOPY(context, e,dest,prio) DDD_XferCopyObj(context, PARHDRE(e),dest,prio) |
| 123 |
#define XFERECOPYX(context, e,dest,prio,size) DDD_XferCopyObjX(context, PARHDRE(e),dest,prio,size) |
| 124 |
|
| 125 |
/* for nodes, vectors, edges (edges only 3D) */ |
| 126 |
#define PRIO(e) DDD_InfoPriority(PARHDR(e)) |
| 127 |
#define SETPRIO(context, e,p) DDD_PrioritySet(context, PARHDR(e),p) |
| 128 |
#define SETPRIOX(context, e,p) if (PRIO(e)!=p) DDD_PrioritySet(context, PARHDR(e),p) |
| 129 |
#define MASTER(e) (PRIO(e)==PrioMaster || PRIO(e)==PrioBorder) |
| 130 |
#define GHOST(e) (PRIO(e)==PrioHGhost || PRIO(e)==PrioVGhost ||\ |
| 131 |
PRIO(e)==PrioVHGhost) |
| 132 |
#define VHGHOST(e) (PRIO(e)==PrioVHGhost) |
| 133 |
#define VGHOST(e) (PRIO(e)==PrioVGhost || PRIO(e)==PrioVHGhost) |
| 134 |
#define HGHOST(e) (PRIO(e)==PrioHGhost || PRIO(e)==PrioVHGhost) |
| 135 |
#define GID(e) DDD_InfoGlobalId(PARHDR(e)) |
| 136 |
#define PROCLIST(context, e) DDD_InfoProcListRange(context, PARHDR(e)) |
| 137 |
#define PROCPRIO(context, e,p) DDD_InfoProcPrio(context, PARHDR(e),p) |
| 138 |
#define NCOPIES(context, e) DDD_InfoNCopies(context, PARHDR(e)) |
| 139 |
#define ATTR(e) DDD_InfoAttr(PARHDR(e)) |
| 140 |
#define XFERDELETE(context, e) DDD_XferDeleteObj(context, PARHDR(e)) |
| 141 |
#define XFERCOPY(context, e,dest,prio) DDD_XferCopyObj(context, PARHDR(e),dest,prio) |
| 142 |
#define XFERCOPYX(context, e,dest,prio,size) DDD_XferCopyObjX(context, PARHDR(e),dest,prio,size) |
| 143 |
|
| 144 |
/* for vertices */ |
| 145 |
#define VXPRIO(e) DDD_InfoPriority(PARHDRV(e)) |
| 146 |
#define SETVXPRIO(context, e,p) DDD_PrioritySet(context, PARHDRV(e),p) |
| 147 |
#define SETVXPRIOX(context, e,p) if (VXPRIO(e)!=p) DDD_PrioritySet(context, PARHDRV(e),p) |
| 148 |
#define VXMASTER(e) (VXPRIO(e)==PrioMaster || VXPRIO(e)==PrioBorder) |
| 149 |
#define VXGHOST(e) (VXPRIO(e)==PrioHGhost || VXPRIO(e)==PrioVGhost ||\ |
| 150 |
VXPRIO(e)==PrioVHGhost) |
| 151 |
#define VXVHGHOST(e) (VXPRIO(e)==PrioVHGhost) |
| 152 |
#define VXVGHOST(e) (VXPRIO(e)==PrioVGhost || VXPRIO(e)==PrioVHGhost) |
| 153 |
#define VXHGHOST(e) (VXPRIO(e)==PrioHGhost || VXPRIO(e)==PrioVHGhost) |
| 154 |
#define VXGID(e) DDD_InfoGlobalId(PARHDRV(e)) |
| 155 |
#define VXPROCLIST(context, e) DDD_InfoProcListRange(context, PARHDRV(e)) |
| 156 |
#define VXPROCPRIO(context, e,p) DDD_InfoProcPrio(context, PARHDRV(e),p) |
| 157 |
#define VXNCOPIES(context, e) DDD_InfoNCopies(context, PARHDRV(e)) |
| 158 |
#define VXATTR(e) DDD_InfoAttr(PARHDRV(e)) |
| 159 |
#define XFERVXDELETE(context, e) DDD_XferDeleteObj(context, PARHDRV(e)) |
| 160 |
#define XFERVXCOPY(context, e,dest,prio) DDD_XferCopyObj(context, PARHDRV(e),dest,prio,size) |
| 161 |
#define XFERVXCOPYX(context, e,dest,prio,size) DDD_XferCopyObjX(context, PARHDRV(e),dest,prio,size) |
| 162 |
|
| 163 |
/* macros for priorities */ |
| 164 |
/* for elements */ |
| 165 |
#define EMASTERPRIO(p) (p==PrioMaster) |
| 166 |
#define EGHOSTPRIO(p) (p==PrioHGhost || p==PrioVGhost || p==PrioVHGhost) |
| 167 |
#define EVHGHOSTPRIO(p) (p==PrioVHGhost) |
| 168 |
#define EVGHOSTPRIO(p) (p==PrioVGhost || p==PrioVHGhost) |
| 169 |
#define EHGHOSTPRIO(p) (p==PrioHGhost || p==PrioVHGhost) |
| 170 |
|
| 171 |
/* for nodes, vertices, vectors, edges (edges only 3D) */ |
| 172 |
#define MASTERPRIO(p) (p==PrioMaster || p==PrioBorder) |
| 173 |
#define GHOSTPRIO(p) (p==PrioHGhost || p==PrioVGhost || p==PrioVHGhost) |
| 174 |
#define VHGHOSTPRIO(p) (p==PrioVHGhost) |
| 175 |
#define VGHOSTPRIO(p) (p==PrioVGhost || p==PrioVHGhost) |
| 176 |
#define HGHOSTPRIO(p) (p==PrioHGhost || p==PrioVHGhost) |
| 177 |
|
| 178 |
#define EGID_FMT DDD_GID_FMT |
| 179 |
#define GID_FMT DDD_GID_FMT |
| 180 |
|
| 181 |
/* This exchanges in the load balancing the connections too. |
| 182 |
#define __EXCHANGE_CONNECTIONS__ */ |
| 183 |
|
| 184 |
#endif /* ModelP */ |
| 185 |
|
| 186 |
|
| 187 |
/****************************************************************************/ |
| 188 |
/* */ |
| 189 |
/* data structures exported by the corresponding source file */ |
| 190 |
/* */ |
| 191 |
/****************************************************************************/ |
| 192 |
|
| 193 |
|
| 194 |
/****************************************************************************/ |
| 195 |
/* */ |
| 196 |
/* definition of exported global variables */ |
| 197 |
/* */ |
| 198 |
/****************************************************************************/ |
| 199 |
|
| 200 |
#ifdef ModelP |
| 201 |
/* DDD Interfaces */ |
| 202 |
extern DDD_IF ElementIF, ElementSymmIF, ElementVIF, ElementSymmVIF, |
| 203 |
ElementVHIF, ElementSymmVHIF; |
| 204 |
extern DDD_IF BorderNodeIF, BorderNodeSymmIF, OuterNodeIF, NodeVIF, |
| 205 |
NodeIF, NodeAllIF, Node_InteriorBorder_All_IF; |
| 206 |
extern DDD_IF BorderVectorIF, BorderVectorSymmIF, |
| 207 |
OuterVectorIF, OuterVectorSymmIF, |
| 208 |
VectorVIF, VectorVAllIF, VectorIF; |
| 209 |
extern DDD_IF Facet_All_All_IF, |
| 210 |
Facet_InteriorBorder_All_IF; |
| 211 |
extern DDD_IF EdgeIF, BorderEdgeSymmIF, EdgeHIF, EdgeVHIF, |
| 212 |
EdgeSymmVHIF; |
| 213 |
|
| 214 |
/* DDD Global Controls */ |
| 215 |
struct DDD_CTRL |
| 216 |
{ |
| 217 |
/* data from ug */ |
| 218 |
MULTIGRID *currMG; |
| 219 |
int nodeData; |
| 220 |
int edgeData; |
| 221 |
int elemData; |
| 222 |
int sideData; |
| 223 |
|
| 224 |
INT ugtypes[MAXDDDTYPES]; /* dddtype -> ugtype */ |
| 225 |
DDD_TYPE types[MAXOBJECTS]; /* ugtype -> dddtype */ |
| 226 |
bool dddObj[MAXOBJECTS]; |
| 227 |
|
| 228 |
/* status of DDDIF */ |
| 229 |
bool allTypesDefined; |
| 230 |
|
| 231 |
/* DDD objects */ |
| 232 |
DDD_TYPE TypeVector; |
| 233 |
DDD_TYPE TypeIVertex, TypeBVertex; |
| 234 |
DDD_TYPE TypeNode; |
| 235 |
|
| 236 |
DDD_TYPE TypeUnknown; |
| 237 |
|
| 238 |
#ifdef UG_DIM_2 |
| 239 |
DDD_TYPE TypeTrElem, TypeTrBElem, TypeQuElem, TypeQuBElem; |
| 240 |
#endif |
| 241 |
|
| 242 |
#ifdef UG_DIM_3 |
| 243 |
DDD_TYPE TypeTeElem, TypeTeBElem; |
| 244 |
DDD_TYPE TypePyElem, TypePyBElem; |
| 245 |
DDD_TYPE TypePrElem, TypePrBElem; |
| 246 |
DDD_TYPE TypeHeElem, TypeHeBElem; |
| 247 |
#endif |
| 248 |
|
| 249 |
/* DDD data objects */ |
| 250 |
DDD_TYPE TypeBndP; |
| 251 |
DDD_TYPE TypeEdge; |
| 252 |
DDD_TYPE TypeBndS; |
| 253 |
|
| 254 |
/* DDD Interfaces */ |
| 255 |
DDD_IF ElementIF, ElementSymmIF, ElementVIF, ElementSymmVIF, |
| 256 |
ElementVHIF, ElementSymmVHIF; |
| 257 |
DDD_IF BorderNodeIF, BorderNodeSymmIF, OuterNodeIF, NodeVIF, |
| 258 |
NodeIF, NodeAllIF, Node_InteriorBorder_All_IF; |
| 259 |
DDD_IF BorderVectorIF, BorderVectorSymmIF, |
| 260 |
OuterVectorIF, OuterVectorSymmIF, |
| 261 |
VectorVIF, VectorVAllIF, VectorIF; |
| 262 |
DDD_IF Facet_All_All_IF, |
| 263 |
Facet_InteriorBorder_All_IF; |
| 264 |
DDD_IF VertexIF; |
| 265 |
DDD_IF EdgeIF, BorderEdgeSymmIF, EdgeHIF, EdgeVHIF, |
| 266 |
EdgeSymmVHIF; |
| 267 |
}; |
| 268 |
|
| 269 |
#endif |
| 270 |
|
| 271 |
/****************************************************************************/ |
| 272 |
/* */ |
| 273 |
/* function declarations */ |
| 274 |
/* */ |
| 275 |
/****************************************************************************/ |
| 276 |
|
| 277 |
#ifdef ModelP |
| 278 |
|
| 279 |
/** |
| 280 |
* accessor function for DDD user context |
| 281 |
*/ |
| 282 |
inline |
| 283 |
const DDD_CTRL& ddd_ctrl(const DDD::DDDContext& context) |
| 284 |
{ |
| 285 |
return *static_cast<const DDD_CTRL*>(context.data()); |
| 286 |
} |
| 287 |
|
| 288 |
/** |
| 289 |
* accessor function for DDD user context |
| 290 |
*/ |
| 291 |
inline |
| 292 |
DDD_CTRL& ddd_ctrl(DDD::DDDContext& context) |
| 293 |
{ |
| 294 |
return *static_cast<DDD_CTRL*>(context.data()); |
| 295 |
} |
| 296 |
|
| 297 |
/* from initddd.c */ |
| 298 |
int InitDDD(DDD::DDDContext& context); |
| 299 |
int ExitDDD(DDD::DDDContext& context); |
| 300 |
void InitCurrMG (MULTIGRID *); |
| 301 |
|
| 302 |
/* from debugger.c */ |
| 303 |
void ddd_pstat (DDD::DDDContext& context, char *); |
| 304 |
|
| 305 |
/* from lb.c */ |
| 306 |
void lbs (const char *argv, MULTIGRID *theMG); |
| 307 |
|
| 308 |
/* from handler.c */ |
| 309 |
void ddd_HandlerInit (DDD::DDDContext& context, INT); |
| 310 |
DDD_TYPE NFatherObjType (DDD::DDDContext& context, DDD_OBJ obj, DDD_OBJ ref); |
| 311 |
void ObjectPriorityUpdate (DDD::DDDContext& context, DDD_OBJ obj, DDD_PRIO newPrio); |
| 312 |
|
| 313 |
/* from lbrcb.c */ |
| 314 |
void BalanceGridRCB (MULTIGRID *, int); |
| 315 |
|
| 316 |
/* from gridcons.c */ |
| 317 |
void ConstructConsistentGrid (GRID *theGrid); |
| 318 |
void ConstructConsistentMultiGrid (MULTIGRID *theMG); |
| 319 |
|
| 320 |
/* from pgmcheck.c */ |
| 321 |
INT CheckProcListCons(const DDD_InfoProcListRange& proclist, DDD_PRIO uniqueTag); |
| 322 |
INT CheckInterfaces (GRID *theGrid); |
| 323 |
|
| 324 |
/* from priority.c */ |
| 325 |
INT SetGridBorderPriorities (GRID *theGrid); |
| 326 |
void SetGhostObjectPriorities (GRID *theGrid); |
| 327 |
|
| 328 |
/* from trans.c */ |
| 329 |
int TransferGrid (MULTIGRID *theMG); |
| 330 |
int TransferGridFromLevel (MULTIGRID *theMG, INT level); |
| 331 |
|
| 332 |
/* from identify.c */ |
| 333 |
void IdentifyInit (MULTIGRID *theMG); |
| 334 |
void IdentifyExit (void); |
| 335 |
INT Identify_Objects_of_ElementSide (GRID *theGrid, ELEMENT *theElement, INT i); |
| 336 |
INT Identify_SonNodesAndSonEdges (GRID *theGrid); |
| 337 |
|
| 338 |
/* from overlap.c */ |
| 339 |
|
| 340 |
INT UpdateGridOverlap (GRID *theGrid); |
| 341 |
INT ConnectGridOverlap (GRID *theGrid); |
| 342 |
INT ConnectVerticalOverlap (MULTIGRID *theMG); |
| 343 |
|
| 344 |
/* from priority.c */ |
| 345 |
void SetGhostObjectPriorities (GRID *theGrid); |
| 346 |
INT SetBorderPriorities (GRID *theGrid); |
| 347 |
INT SetGridBorderPriorities (GRID *theGrid); |
| 348 |
|
| 349 |
/* from partition.c */ |
| 350 |
INT CheckPartitioning (MULTIGRID *theMG); |
| 351 |
INT RestrictPartitioning (MULTIGRID *theMG); |
| 352 |
|
| 353 |
/* from pgmcheck.c */ |
| 354 |
INT CheckInterfaces (GRID *theGrid); |
| 355 |
|
| 356 |
/* |
| 357 |
* COMPATIBILITY FUNCTIONS FOR OLDER dune-grid RELEASES |
| 358 |
*/ |
| 359 |
|
| 360 |
/** |
| 361 |
* get global DDD context. |
| 362 |
* This only exists for compatibility with old versions of dune-grid. |
| 363 |
*/ |
| 364 |
DDD::DDDContext& globalDDDContext(); |
| 365 |
|
| 366 |
/** |
| 367 |
* set global DDD context. |
| 368 |
* This only exists for compatibility with old versions of dune-grid. |
| 369 |
*/ |
| 370 |
void globalDDDContext(const std::shared_ptr<DDD::DDDContext>& context); |
| 371 |
|
| 372 |
/** |
| 373 |
* invalidate global DDD context. |
| 374 |
* This only exists for compatibility with old versions of dune-grid. |
| 375 |
*/ |
| 376 |
void globalDDDContext(std::nullptr_t); |
| 377 |
|
| 378 |
using ComProcPtr = int (*)(DDD_OBJ, void *); |
| 379 |
|
| 380 |
#endif /* ModelP */ |
| 381 |
|
| 382 |
END_UGDIM_NAMESPACE |
| 383 |
|
| 384 |
#endif /* __PARALLEL_H__ */ |