| 1 |
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 4 |
// vi: set et ts=4 sw=2 sts=2: |
| 5 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: pgmcheck.c */ |
| 8 |
/* */ |
| 9 |
/* Purpose: functions for checking parallel consistency */ |
| 10 |
/* */ |
| 11 |
/* Author: Stefan Lang */ |
| 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: 980204 sl begin */ |
| 21 |
/* */ |
| 22 |
/* Remarks: */ |
| 23 |
/* */ |
| 24 |
/****************************************************************************/ |
| 25 |
|
| 26 |
#ifdef ModelP |
| 27 |
|
| 28 |
/****************************************************************************/ |
| 29 |
/* */ |
| 30 |
/* include files */ |
| 31 |
/* system include files */ |
| 32 |
/* application include files */ |
| 33 |
/* */ |
| 34 |
/****************************************************************************/ |
| 35 |
|
| 36 |
#include <config.h> |
| 37 |
#include <cstdlib> |
| 38 |
|
| 39 |
#include "parallel.h" |
| 40 |
#include <dune/uggrid/ugdevices.h> |
| 41 |
#include <dune/uggrid/gm/evm.h> |
| 42 |
#include <dune/uggrid/gm/gm.h> |
| 43 |
#include <dune/uggrid/gm/refine.h> |
| 44 |
#include <dune/uggrid/gm/shapes.h> |
| 45 |
#include <dune/uggrid/gm/ugm.h> |
| 46 |
#include <dune/uggrid/low/debug.h> |
| 47 |
#include <dune/uggrid/low/namespace.h> |
| 48 |
|
| 49 |
/* UG namespaces: */ |
| 50 |
USING_UG_NAMESPACES |
| 51 |
|
| 52 |
/* PPIF namespace: */ |
| 53 |
using namespace PPIF; |
| 54 |
|
| 55 |
|
| 56 |
/****************************************************************************/ |
| 57 |
/* */ |
| 58 |
/* defines in the following order */ |
| 59 |
/* */ |
| 60 |
/* compile time constants defining static data size (i.e. arrays) */ |
| 61 |
/* other constants */ |
| 62 |
/* macros */ |
| 63 |
/* */ |
| 64 |
/****************************************************************************/ |
| 65 |
|
| 66 |
#define CHECK_OBJECT_PRIO(o,prio,master,ghost,id,s,_nerr_) \ |
| 67 |
do { \ |
| 68 |
if (USED(o)==1 && ! master (o)) \ |
| 69 |
{ \ |
| 70 |
UserWriteF("MASTER %s=" id ## _FMTX " has WRONG prio=%d\n", \ |
| 71 |
s, id ## _PRTX(o),prio(o)); \ |
| 72 |
_nerr_++; \ |
| 73 |
} \ |
| 74 |
if (USED( o )==0 && ! ghost ( o )) \ |
| 75 |
{ \ |
| 76 |
UserWriteF("GHOST %s=" id ## _FMTX " has WRONG prio=%d\n", \ |
| 77 |
s, id ## _PRTX( o ),prio(o)); \ |
| 78 |
_nerr_++; \ |
| 79 |
} \ |
| 80 |
} while (0) |
| 81 |
|
| 82 |
/****************************************************************************/ |
| 83 |
/* */ |
| 84 |
/* data structures used in this source file (exported data structures are */ |
| 85 |
/* in the corresponding include file!) */ |
| 86 |
/* */ |
| 87 |
/****************************************************************************/ |
| 88 |
|
| 89 |
|
| 90 |
/****************************************************************************/ |
| 91 |
/* */ |
| 92 |
/* definition of exported global variables */ |
| 93 |
/* */ |
| 94 |
/****************************************************************************/ |
| 95 |
|
| 96 |
|
| 97 |
/****************************************************************************/ |
| 98 |
/* */ |
| 99 |
/* definition of variables global to this source file only (static!) */ |
| 100 |
/* */ |
| 101 |
/****************************************************************************/ |
| 102 |
|
| 103 |
/* count for errors to report from communication scatter functions */ |
| 104 |
static INT check_distributed_objects_errors = 0; |
| 105 |
|
| 106 |
|
| 107 |
/****************************************************************************/ |
| 108 |
/* */ |
| 109 |
/* forward declarations of functions used before they are defined */ |
| 110 |
/* */ |
| 111 |
/****************************************************************************/ |
| 112 |
|
| 113 |
|
| 114 |
/****************************************************************************/ |
| 115 |
/* |
| 116 |
CheckProcListCons - |
| 117 |
|
| 118 |
SYNOPSIS: |
| 119 |
INT CheckProcListCons (const DDD_InfoProcListRange& proclist, DDD_PRIO uniqueTag); |
| 120 |
|
| 121 |
PARAMETERS: |
| 122 |
. proclist |
| 123 |
. uniqueTag |
| 124 |
|
| 125 |
DESCRIPTION: |
| 126 |
|
| 127 |
RETURN VALUE: |
| 128 |
INT |
| 129 |
*/ |
| 130 |
/****************************************************************************/ |
| 131 |
|
| 132 |
INT NS_DIM_PREFIX CheckProcListCons (const DDD_InfoProcListRange& proclist, DDD_PRIO uniqueTag) |
| 133 |
{ |
| 134 |
int nunique = 0; |
| 135 |
|
| 136 |
/* check uniqueness */ |
| 137 |
for (auto&& [proc, prio] : proclist) |
| 138 |
{ |
| 139 |
if (prio == uniqueTag) |
| 140 |
++nunique; |
| 141 |
} |
| 142 |
|
| 143 |
/* nunique must be 1 for master elements */ |
| 144 |
/* nunique can be 0/1 for (inner) nodes */ |
| 145 |
/* with PrioBorder/PrioMaster */ |
| 146 |
return nunique; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
/****************************************************************************/ |
| 152 |
/* |
| 153 |
ListProcList - |
| 154 |
|
| 155 |
SYNOPSIS: |
| 156 |
INT ListProcList (const DDD_InfoProcListRange& proclist, DDD_PRIO uniqueTag); |
| 157 |
|
| 158 |
PARAMETERS: |
| 159 |
. proclist |
| 160 |
. uniqueTag |
| 161 |
|
| 162 |
DESCRIPTION: |
| 163 |
|
| 164 |
RETURN VALUE: |
| 165 |
INT |
| 166 |
*/ |
| 167 |
/****************************************************************************/ |
| 168 |
|
| 169 |
static INT ListProcList (const DDD_InfoProcListRange& proclist, DDD_PRIO uniqueTag) |
| 170 |
{ |
| 171 |
for (auto&& [proc, prio] : proclist) |
| 172 |
{ |
| 173 |
if (prio == uniqueTag) |
| 174 |
UserWriteF(" proc=%d", proc); |
| 175 |
} |
| 176 |
return 0; |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
/****************************************************************************/ |
| 181 |
/* |
| 182 |
CheckVectorPrio - |
| 183 |
|
| 184 |
SYNOPSIS: |
| 185 |
INT CheckVectorPrio (ELEMENT *theElement, VECTOR *theVector); |
| 186 |
|
| 187 |
PARAMETERS: |
| 188 |
. theElement |
| 189 |
. theVector |
| 190 |
|
| 191 |
DESCRIPTION: |
| 192 |
|
| 193 |
RETURN VALUE: |
| 194 |
INT |
| 195 |
*/ |
| 196 |
/****************************************************************************/ |
| 197 |
|
| 198 |
static INT CheckVectorPrio (DDD::DDDContext& context, ELEMENT *theElement, VECTOR *theVector) |
| 199 |
{ |
| 200 |
INT nmaster; |
| 201 |
INT nerrors = 0; |
| 202 |
|
| 203 |
/* check vector prio */ |
| 204 |
CHECK_OBJECT_PRIO(theVector,PRIO,MASTER,GHOST,VINDEX,"Vector",nerrors); |
| 205 |
|
| 206 |
/* master copy has to be unique */ |
| 207 |
const auto& proclist = DDD_InfoProcListRange(context, PARHDR(theVector)); |
| 208 |
if ((nmaster = CheckProcListCons(proclist, PrioMaster)) > 1) |
| 209 |
{ |
| 210 |
UserWriteF("VECTOR=" ID_FMTX " ERROR: master copy not unique, nmaster=%d:", |
| 211 |
ID_PRTX(theVector),nmaster); |
| 212 |
ListProcList(proclist, PrioMaster); |
| 213 |
UserWriteF("\n"); |
| 214 |
nerrors++; |
| 215 |
} |
| 216 |
|
| 217 |
return nerrors; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
/****************************************************************************/ |
| 222 |
/* |
| 223 |
CheckNodePrio - |
| 224 |
|
| 225 |
SYNOPSIS: |
| 226 |
INT CheckNodePrio (ELEMENT *theElement, NODE *theNode); |
| 227 |
|
| 228 |
PARAMETERS: |
| 229 |
. theElement |
| 230 |
. theNode |
| 231 |
|
| 232 |
DESCRIPTION: |
| 233 |
|
| 234 |
RETURN VALUE: |
| 235 |
INT |
| 236 |
*/ |
| 237 |
/****************************************************************************/ |
| 238 |
|
| 239 |
static INT CheckNodePrio (DDD::DDDContext& context, ELEMENT *theElement, NODE *theNode) |
| 240 |
{ |
| 241 |
INT nmaster; |
| 242 |
INT nerrors = 0; |
| 243 |
|
| 244 |
/* check node prio */ |
| 245 |
CHECK_OBJECT_PRIO(theNode,PRIO,MASTER,GHOST,ID,"NODE",nerrors); |
| 246 |
|
| 247 |
/* master copy has to be unique */ |
| 248 |
const auto& proclist = DDD_InfoProcListRange(context, PARHDR(theNode)); |
| 249 |
if ((nmaster = CheckProcListCons(proclist, PrioMaster)) > 1) |
| 250 |
{ |
| 251 |
UserWriteF("NODE=" ID_FMTX " ERROR: master copy not unique, nmaster=%d:", |
| 252 |
ID_PRTX(theNode),nmaster); |
| 253 |
ListProcList(proclist, PrioMaster); |
| 254 |
UserWriteF("\n"); |
| 255 |
nerrors++; |
| 256 |
} |
| 257 |
|
| 258 |
return(nerrors); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
/****************************************************************************/ |
| 263 |
/* |
| 264 |
CheckEdgePrio - |
| 265 |
|
| 266 |
SYNOPSIS: |
| 267 |
INT CheckEdgePrio (ELEMENT *theElement, EDGE *theEdge); |
| 268 |
|
| 269 |
PARAMETERS: |
| 270 |
. theElement |
| 271 |
. theEdge |
| 272 |
|
| 273 |
DESCRIPTION: |
| 274 |
|
| 275 |
RETURN VALUE: |
| 276 |
INT |
| 277 |
*/ |
| 278 |
/****************************************************************************/ |
| 279 |
|
| 280 |
static INT CheckEdgePrio (DDD::DDDContext& context, ELEMENT *theElement, EDGE *theEdge) |
| 281 |
{ |
| 282 |
INT nerrors = 0; |
| 283 |
|
| 284 |
#ifdef UG_DIM_3 |
| 285 |
INT nmaster; |
| 286 |
|
| 287 |
/* check edge prio */ |
| 288 |
CHECK_OBJECT_PRIO(theEdge,PRIO,MASTER,GHOST,ID,"EDGE",nerrors); |
| 289 |
|
| 290 |
/* master copy has to be unique */ |
| 291 |
const auto& proclist = DDD_InfoProcListRange(context, PARHDR(theEdge)); |
| 292 |
if ((nmaster = CheckProcListCons(proclist, PrioMaster)) > 1) |
| 293 |
{ |
| 294 |
UserWriteF("EDGE=" EDID_FMTX " ERROR: master copy not unique, nmaster=%d:", |
| 295 |
EDID_PRTX(theEdge),nmaster); |
| 296 |
ListProcList(proclist, PrioMaster); |
| 297 |
UserWriteF("\n"); |
| 298 |
nerrors++; |
| 299 |
} |
| 300 |
#endif |
| 301 |
|
| 302 |
if (ddd_ctrl(context).edgeData) |
| 303 |
if (EDVECTOR(theEdge) != NULL) |
| 304 |
nerrors += CheckVectorPrio(context, theElement,EDVECTOR(theEdge)); |
| 305 |
|
| 306 |
return(nerrors); |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
/****************************************************************************/ |
| 311 |
/* |
| 312 |
CheckElementPrio - |
| 313 |
|
| 314 |
SYNOPSIS: |
| 315 |
INT CheckElementPrio (ELEMENT *theElement); |
| 316 |
|
| 317 |
PARAMETERS: |
| 318 |
. theElement |
| 319 |
|
| 320 |
DESCRIPTION: |
| 321 |
|
| 322 |
RETURN VALUE: |
| 323 |
INT |
| 324 |
*/ |
| 325 |
/****************************************************************************/ |
| 326 |
|
| 327 |
static INT CheckElementPrio (DDD::DDDContext& context, ELEMENT *theElement) |
| 328 |
{ |
| 329 |
INT i,nmaster,prio,valid_copy; |
| 330 |
INT nerrors = 0; |
| 331 |
NODE *theNode; |
| 332 |
EDGE *theEdge; |
| 333 |
ELEMENT *SonList[MAX_SONS]; |
| 334 |
|
| 335 |
const auto& me = context.me(); |
| 336 |
|
| 337 |
if (PARTITION(theElement)==me && !EMASTER(theElement)) |
| 338 |
{ |
| 339 |
UserWriteF(PFMT "#FATAL# MASTER ELEM=" EID_FMTX " has WRONG part=%d prio=%d\n", |
| 340 |
me,EID_PRTX(theElement),PARTITION(theElement),EPRIO(theElement)); |
| 341 |
nerrors++; |
| 342 |
} |
| 343 |
if (PARTITION(theElement)!=me && !EGHOST(theElement)) |
| 344 |
{ |
| 345 |
UserWriteF(PFMT "#FATAL# GHOST ELEM=" EID_FMTX " has WRONG part=%d prio=%d\n", |
| 346 |
me,EID_PRTX(theElement),PARTITION(theElement),EPRIO(theElement)); |
| 347 |
nerrors++; |
| 348 |
|
| 349 |
/* test ghost prio */ |
| 350 |
prio = 0; |
| 351 |
for (i=0; i<SIDES_OF_ELEM(theElement); i++) |
| 352 |
{ |
| 353 |
if (EMASTER(NBELEM(theElement,i))) prio = PrioHGhost; |
| 354 |
} |
| 355 |
if (GetSons(theElement,SonList) != 0) RETURN(1); |
| 356 |
if (SonList[0] != NULL) prio += PrioVGhost; |
| 357 |
|
| 358 |
if (EPRIO(theElement) != prio) |
| 359 |
{ |
| 360 |
UserWriteF(PFMT "ERROR GHOST ELEM=" EID_FMTX |
| 361 |
" has WRONG prio=%d should be prio=%d\n", |
| 362 |
me,EID_PRTX(theElement),EPRIO(theElement),prio); |
| 363 |
nerrors++; |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
/* check element prio */ |
| 368 |
CHECK_OBJECT_PRIO(theElement,EPRIO,EMASTER,EGHOST,EID,"ELEM",nerrors); |
| 369 |
|
| 370 |
/* master copy has to be unique */ |
| 371 |
const auto& proclist = DDD_InfoProcListRange(context, PARHDRE(theElement)); |
| 372 |
if ((nmaster = CheckProcListCons(proclist, PrioMaster)) != 1) |
| 373 |
{ |
| 374 |
UserWriteF("ELEM=" EID_FMTX " ERROR: master copy not unique, ", |
| 375 |
EID_PRTX(theElement),nmaster); |
| 376 |
if (EFATHER(theElement) != NULL) |
| 377 |
UserWriteF("Father=" EID_FMTX, EID_PRTX(EFATHER(theElement))); |
| 378 |
else |
| 379 |
UserWrite("Father=NULL"); |
| 380 |
UserWriteF(" nmaster=%d:",nmaster); |
| 381 |
ListProcList(proclist, PrioMaster); |
| 382 |
UserWriteF("\n"); |
| 383 |
nerrors++; |
| 384 |
} |
| 385 |
|
| 386 |
/* hghost copy needs to a master neighbor */ |
| 387 |
if (EHGHOST(theElement)) |
| 388 |
{ |
| 389 |
valid_copy = 0; |
| 390 |
for (i=0; i<SIDES_OF_ELEM(theElement); i++) |
| 391 |
{ |
| 392 |
if (NBELEM(theElement,i)!=NULL && EMASTER(NBELEM(theElement,i))) |
| 393 |
valid_copy = 1; |
| 394 |
} |
| 395 |
if (!valid_copy) |
| 396 |
{ |
| 397 |
UserWriteF("ELEM=" EID_FMTX " ERROR: hghost copy with no master neighbor!\n", |
| 398 |
EID_PRTX(theElement)); |
| 399 |
nerrors++; |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
/* vghost copy needs to a master Son */ |
| 404 |
if (EVGHOST(theElement)) |
| 405 |
{ |
| 406 |
if (GetSons(theElement,SonList) != 0) RETURN(1); |
| 407 |
if (SonList[0] == NULL) valid_copy = 0; |
| 408 |
else valid_copy = 1; |
| 409 |
if (!valid_copy) |
| 410 |
{ |
| 411 |
UserWriteF("ELEM=" EID_FMTX " ERROR: vghost copy with no master son!\n", |
| 412 |
EID_PRTX(theElement)); |
| 413 |
nerrors++; |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
if (ddd_ctrl(context).elemData) |
| 418 |
if (EVECTOR(theElement) != NULL) |
| 419 |
nerrors += CheckVectorPrio(context, theElement,EVECTOR(theElement)); |
| 420 |
|
| 421 |
#ifdef UG_DIM_3 |
| 422 |
if (ddd_ctrl(context).sideData) |
| 423 |
{ |
| 424 |
for (i=0; i<SIDES_OF_ELEM(theElement); i++) |
| 425 |
if (SVECTOR(theElement,i) != NULL) |
| 426 |
nerrors += CheckVectorPrio(context, theElement,SVECTOR(theElement,i)); |
| 427 |
} |
| 428 |
#endif |
| 429 |
|
| 430 |
for (i=0; i<CORNERS_OF_ELEM(theElement); i++) |
| 431 |
{ |
| 432 |
theNode = CORNER(theElement,i); |
| 433 |
nerrors += CheckNodePrio(context, theElement,theNode); |
| 434 |
} |
| 435 |
|
| 436 |
for (i=0; i<EDGES_OF_ELEM(theElement); i++) |
| 437 |
{ |
| 438 |
theEdge = GetEdge(CORNER(theElement,CORNER_OF_EDGE(theElement,i,0)), |
| 439 |
CORNER(theElement,CORNER_OF_EDGE(theElement,i,1))); |
| 440 |
ASSERT(theEdge != NULL); |
| 441 |
nerrors += CheckEdgePrio(context, theElement,theEdge); |
| 442 |
} |
| 443 |
|
| 444 |
return (nerrors); |
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
/****************************************************************************/ |
| 449 |
/* |
| 450 |
CheckDistributedObjects - Check the uniqueness of global ids |
| 451 |
|
| 452 |
SYNOPSIS: |
| 453 |
INT CheckDistributedObjects (GRID *theGrid); |
| 454 |
|
| 455 |
PARAMETERS: |
| 456 |
. theGrid |
| 457 |
|
| 458 |
DESCRIPTION: |
| 459 |
Compare the global ids of distributed objects which are identified. |
| 460 |
This is done for nodes and edges (3D). |
| 461 |
|
| 462 |
RETURN VALUE: |
| 463 |
INT |
| 464 |
*/ |
| 465 |
/****************************************************************************/ |
| 466 |
|
| 467 |
static int Gather_ElemObjectGids (DDD::DDDContext&, DDD_OBJ obj, void *data, DDD_PROC proc, DDD_PRIO prio) |
| 468 |
{ |
| 469 |
ELEMENT *theElement = (ELEMENT *)obj; |
| 470 |
|
| 471 |
/* copy node gids into buffer */ |
| 472 |
for (INT i=0; i<CORNERS_OF_ELEM(theElement); i++) |
| 473 |
{ |
| 474 |
((DDD_GID *)data)[i] = GID(CORNER(theElement,i)); |
| 475 |
} |
| 476 |
|
| 477 |
#ifdef UG_DIM_3 |
| 478 |
/* copy edge gids into buffer */ |
| 479 |
for (INT i=CORNERS_OF_ELEM(theElement),j=0; i<EDGES_OF_ELEM(theElement); i++,j++) |
| 480 |
{ |
| 481 |
EDGE *theEdge = GetEdge(CORNER_OF_EDGE_PTR(theElement,j,0), |
| 482 |
CORNER_OF_EDGE_PTR(theElement,j,1)); |
| 483 |
assert(theEdge!=NULL); |
| 484 |
((DDD_GID *)data)[i] = GID(theEdge); |
| 485 |
} |
| 486 |
#endif |
| 487 |
|
| 488 |
return 0; |
| 489 |
} |
| 490 |
|
| 491 |
static int Scatter_ElemObjectGids (DDD::DDDContext&, DDD_OBJ obj, void *data, DDD_PROC proc, DDD_PRIO prio) |
| 492 |
{ |
| 493 |
ELEMENT *theElement = (ELEMENT *)obj; |
| 494 |
|
| 495 |
/* compare node gids with buffer gids */ |
| 496 |
for (INT i=0; i<CORNERS_OF_ELEM(theElement); i++) |
| 497 |
{ |
| 498 |
NODE* theNode = CORNER(theElement,i); |
| 499 |
if (((DDD_GID *)data)[i] != GID(theNode)) |
| 500 |
{ |
| 501 |
UserWriteF("ELEM=" EID_FMTX " #ERROR#: NODE=" ID_FMTX " gids don't match " |
| 502 |
"local=%08x remote=%08x remoteproc/prio=%d/%d\n",EID_PRTX(theElement),ID_PRTX(theNode), |
| 503 |
GID(theNode),((DDD_GID *)data)[i],proc,prio); |
| 504 |
check_distributed_objects_errors++; |
| 505 |
assert(0); |
| 506 |
} |
| 507 |
} |
| 508 |
|
| 509 |
#ifdef UG_DIM_3 |
| 510 |
/* compare edge gids with buffer gids */ |
| 511 |
for (INT i=CORNERS_OF_ELEM(theElement),j=0; i<EDGES_OF_ELEM(theElement); i++,j++) |
| 512 |
{ |
| 513 |
EDGE* theEdge = GetEdge(CORNER_OF_EDGE_PTR(theElement,j,0), |
| 514 |
CORNER_OF_EDGE_PTR(theElement,j,1)); |
| 515 |
assert(theEdge!=NULL); |
| 516 |
if (((DDD_GID *)data)[i] != GID(theEdge)) |
| 517 |
{ |
| 518 |
UserWriteF("ELEM=" EID_FMTX " #ERROR#: EDGE=" ID_FMTX " gids don't match " |
| 519 |
"local=%08x remote=%08x remoteproc/prio=%d/%d\n",EID_PRTX(theElement),ID_PRTX(theEdge), |
| 520 |
GID(theEdge),((DDD_GID *)data)[i],proc,prio); |
| 521 |
check_distributed_objects_errors++; |
| 522 |
assert(0); |
| 523 |
} |
| 524 |
} |
| 525 |
#endif |
| 526 |
|
| 527 |
return 0; |
| 528 |
} |
| 529 |
|
| 530 |
#ifdef UG_DIM_3 |
| 531 |
static int Gather_EdgeObjectGids (DDD::DDDContext&, DDD_OBJ obj, void *data, DDD_PROC proc, DDD_PRIO prio) |
| 532 |
{ |
| 533 |
EDGE *theEdge = (EDGE *)obj; |
| 534 |
|
| 535 |
INT i = 0; |
| 536 |
|
| 537 |
NODE* theNode0 = NBNODE(LINK0(theEdge)); |
| 538 |
NODE* theNode1 = NBNODE(LINK1(theEdge)); |
| 539 |
NODE* MidNode = MIDNODE(theEdge); |
| 540 |
|
| 541 |
/* copy node gids into buffer */ |
| 542 |
((DDD_GID *)data)[i++] = GID(theNode0); |
| 543 |
((DDD_GID *)data)[i++] = GID(theNode1); |
| 544 |
if (MidNode != NULL) |
| 545 |
((DDD_GID *)data)[i++] = GID(MidNode)+1; |
| 546 |
else |
| 547 |
((DDD_GID *)data)[i++] = 0; |
| 548 |
|
| 549 |
return 0; |
| 550 |
} |
| 551 |
|
| 552 |
static int Scatter_EdgeObjectGids (DDD::DDDContext& context, DDD_OBJ obj, void *data, DDD_PROC proc, DDD_PRIO prio) |
| 553 |
{ |
| 554 |
DDD_GID remotegid; |
| 555 |
EDGE *theEdge = (EDGE *)obj; |
| 556 |
|
| 557 |
/* this check allows no edges copies of type VGHOST */ |
| 558 |
/* since then midnode might be NULL due to local */ |
| 559 |
/* load balancing situation */ |
| 560 |
const auto& proclist = DDD_InfoProcListRange(context, PARHDR(theEdge)); |
| 561 |
for (auto&& [proc, prio] : proclist) |
| 562 |
{ |
| 563 |
if (VGHOSTPRIO(prio)) |
| 564 |
return 0; |
| 565 |
} |
| 566 |
|
| 567 |
INT i = 0; |
| 568 |
|
| 569 |
NODE* theNode0 = NBNODE(LINK0(theEdge)); |
| 570 |
NODE* theNode1 = NBNODE(LINK1(theEdge)); |
| 571 |
NODE* MidNode = MIDNODE(theEdge); |
| 572 |
|
| 573 |
/* compare node0 gids with buffer gids */ |
| 574 |
if (((DDD_GID *)data)[i] != GID(theNode0)) |
| 575 |
{ |
| 576 |
UserWriteF("EDGE=" ID_FMTX " #ERROR#: NODE0=" ID_FMTX " gids don't match " |
| 577 |
"local=%08x remote=%08x remoteproc/prio=%d/%d\n", |
| 578 |
ID_PRTX(theEdge),ID_PRTX(theNode0), |
| 579 |
GID(theNode0),((DDD_GID *)data)[i],proc,prio); |
| 580 |
check_distributed_objects_errors++; |
| 581 |
assert(0); |
| 582 |
} |
| 583 |
i++; |
| 584 |
|
| 585 |
/* compare node1 gids with buffer gids */ |
| 586 |
if (((DDD_GID *)data)[i] != GID(theNode1)) |
| 587 |
{ |
| 588 |
UserWriteF("EDGE=" ID_FMTX " #ERROR#: NODE1=" ID_FMTX " gids don't match " |
| 589 |
"local=%08x remote=%08x remoteproc/prio=%d/%d\n", |
| 590 |
ID_PRTX(theEdge),ID_PRTX(theNode1), |
| 591 |
GID(theNode1),((DDD_GID *)data)[i],proc,prio); |
| 592 |
check_distributed_objects_errors++; |
| 593 |
assert(0); |
| 594 |
} |
| 595 |
i++; |
| 596 |
|
| 597 |
/* compare node0 gids with buffer gids */ |
| 598 |
if (((DDD_GID *)data)[i]>0) |
| 599 |
remotegid = ((DDD_GID *)data)[i]-1; |
| 600 |
|
| 601 |
if (MidNode != NULL) |
| 602 |
{ |
| 603 |
if (remotegid != GID(MidNode)) |
| 604 |
{ |
| 605 |
UserWriteF("EDGE=" ID_FMTX " #ERROR#: MIDNODE=" ID_FMTX " gids don't match " |
| 606 |
"local=%08x remote=%08x remoteproc/prio=%d/%d\n", |
| 607 |
ID_PRTX(theEdge),ID_PRTX(MidNode), |
| 608 |
GID(MidNode),remotegid,proc,prio); |
| 609 |
check_distributed_objects_errors++; |
| 610 |
assert(0); |
| 611 |
} |
| 612 |
} |
| 613 |
else |
| 614 |
{ |
| 615 |
|
| 616 |
if (remotegid != 0) |
| 617 |
{ |
| 618 |
UserWriteF("EDGE=" ID_FMTX " #ERROR#: MIDNODE=NULL gids don't match " |
| 619 |
"local=%08x remote=%08x remoteproc/prio=%d/%d\n", |
| 620 |
ID_PRTX(theEdge),0,remotegid,proc,prio); |
| 621 |
check_distributed_objects_errors++; |
| 622 |
assert(0); |
| 623 |
} |
| 624 |
} |
| 625 |
i++; |
| 626 |
|
| 627 |
return 0; |
| 628 |
} |
| 629 |
#endif |
| 630 |
|
| 631 |
static INT CheckDistributedObjects (GRID *theGrid) |
| 632 |
{ |
| 633 |
auto& context = theGrid->dddContext(); |
| 634 |
const auto& dddctrl = ddd_ctrl(context); |
| 635 |
|
| 636 |
INT nerrors; |
| 637 |
#ifdef UG_DIM_2 |
| 638 |
INT size = MAX_CORNERS_OF_ELEM; /* compare the 3/4 node ids */ |
| 639 |
#endif |
| 640 |
#ifdef UG_DIM_3 |
| 641 |
INT size = MAX_CORNERS_OF_ELEM+MAX_EDGES_OF_ELEM; /* compare 8 nodes + 12 edges */ |
| 642 |
#endif |
| 643 |
|
| 644 |
check_distributed_objects_errors = 0; |
| 645 |
|
| 646 |
// void DDD_IFAOnewayX (DDD::DDDContext&, DDD_IF, DDD_ATTR, DDD_IF_DIR, size_t, ComProcXPtr, ComProcXPtr); |
| 647 |
DDD_IFAOnewayX(context, |
| 648 |
dddctrl.ElementSymmVHIF,GRID_ATTR(theGrid),IF_BACKWARD,size*sizeof(DDD_GID), |
| 649 |
Gather_ElemObjectGids, Scatter_ElemObjectGids); |
| 650 |
|
| 651 |
#ifdef UG_DIM_3 |
| 652 |
if (0) |
| 653 |
DDD_IFAOnewayX(context, |
| 654 |
dddctrl.BorderEdgeSymmIF,GRID_ATTR(theGrid),IF_BACKWARD,3*sizeof(DDD_GID), |
| 655 |
Gather_EdgeObjectGids, Scatter_EdgeObjectGids); |
| 656 |
#endif |
| 657 |
|
| 658 |
nerrors = check_distributed_objects_errors; |
| 659 |
return(nerrors); |
| 660 |
} |
| 661 |
|
| 662 |
/****************************************************************************/ |
| 663 |
/* |
| 664 |
CheckInterfaces - |
| 665 |
|
| 666 |
SYNOPSIS: |
| 667 |
INT CheckInterfaces (GRID *theGrid); |
| 668 |
|
| 669 |
PARAMETERS: |
| 670 |
. theGrid |
| 671 |
|
| 672 |
DESCRIPTION: |
| 673 |
|
| 674 |
RETURN VALUE: |
| 675 |
INT |
| 676 |
*/ |
| 677 |
/****************************************************************************/ |
| 678 |
|
| 679 |
INT NS_DIM_PREFIX CheckInterfaces (GRID *theGrid) |
| 680 |
{ |
| 681 |
auto& context = theGrid->dddContext(); |
| 682 |
auto& dddctrl = ddd_ctrl(context); |
| 683 |
|
| 684 |
INT i,j; |
| 685 |
ELEMENT *theElement; |
| 686 |
NODE *theNode; |
| 687 |
EDGE *theEdge; |
| 688 |
int nerrors = 0; |
| 689 |
|
| 690 |
/* reset USED flag of all grid objects */ |
| 691 |
/* set USED flag of master grid objects */ |
| 692 |
for (j=0; j<2; j++) |
| 693 |
{ |
| 694 |
for (theElement =(j==0 ? PFIRSTELEMENT(theGrid) : FIRSTELEMENT(theGrid)); |
| 695 |
theElement!=NULL; |
| 696 |
theElement=SUCCE(theElement)) |
| 697 |
{ |
| 698 |
SETUSED(theElement,j); |
| 699 |
if (dddctrl.elemData) |
| 700 |
if (EVECTOR(theElement) != NULL) |
| 701 |
SETUSED(EVECTOR(theElement),j); |
| 702 |
#ifdef UG_DIM_3 |
| 703 |
if (dddctrl.sideData) |
| 704 |
{ |
| 705 |
for (i=0; i<SIDES_OF_ELEM(theElement); i++) |
| 706 |
if (SVECTOR(theElement,i) != NULL) |
| 707 |
SETUSED(SVECTOR(theElement,i),j); |
| 708 |
} |
| 709 |
#endif |
| 710 |
|
| 711 |
for (i=0; i<CORNERS_OF_ELEM(theElement); i++) |
| 712 |
{ |
| 713 |
theNode = CORNER(theElement,i); |
| 714 |
SETUSED(theNode,j); |
| 715 |
SETUSED(MYVERTEX(theNode),j); |
| 716 |
} |
| 717 |
|
| 718 |
for (i=0; i<EDGES_OF_ELEM(theElement); i++) |
| 719 |
{ |
| 720 |
theEdge = GetEdge(CORNER(theElement,CORNER_OF_EDGE(theElement,i,0)), |
| 721 |
CORNER(theElement,CORNER_OF_EDGE(theElement,i,1))); |
| 722 |
ASSERT(theEdge != NULL); |
| 723 |
SETUSED(theEdge,j); |
| 724 |
if (dddctrl.edgeData) |
| 725 |
if (EDVECTOR(theEdge) != NULL) |
| 726 |
SETUSED(EDVECTOR(theEdge),j); |
| 727 |
} |
| 728 |
} |
| 729 |
} |
| 730 |
|
| 731 |
/* check validity of priorities */ |
| 732 |
for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; |
| 733 |
theElement=SUCCE(theElement)) |
| 734 |
{ |
| 735 |
nerrors += CheckElementPrio(theGrid->dddContext(), theElement); |
| 736 |
} |
| 737 |
|
| 738 |
/* check uniqueness of global ids for distributed nodes and edges */ |
| 739 |
nerrors += CheckDistributedObjects(theGrid); |
| 740 |
|
| 741 |
/* check ddd interface consistency */ |
| 742 |
DDD_SetOption(theGrid->dddContext(), OPT_QUIET_CONSCHECK, OPT_ON); |
| 743 |
nerrors += DDD_ConsCheck(theGrid->dddContext()); |
| 744 |
DDD_SetOption(theGrid->dddContext(), OPT_QUIET_CONSCHECK, OPT_OFF); |
| 745 |
|
| 746 |
return(nerrors); |
| 747 |
} |
| 748 |
|
| 749 |
#endif |