| 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: initddd.c */ |
| 8 |
/* */ |
| 9 |
/* Purpose: register ug structs for handling them by ddd */ |
| 10 |
/* */ |
| 11 |
/* Author: Stefan Lang, Klaus Birken */ |
| 12 |
/* Institut fuer Computeranwendungen III */ |
| 13 |
/* Universitaet Stuttgart */ |
| 14 |
/* Pfaffenwaldring 27 */ |
| 15 |
/* 70550 Stuttgart */ |
| 16 |
/* */ |
| 17 |
/* History: 09.05.95 begin, ugp version 3.0 */ |
| 18 |
/* */ |
| 19 |
/* Remarks: */ |
| 20 |
/* */ |
| 21 |
/****************************************************************************/ |
| 22 |
|
| 23 |
#ifdef ModelP |
| 24 |
|
| 25 |
/****************************************************************************/ |
| 26 |
/* */ |
| 27 |
/* include files */ |
| 28 |
/* system include files */ |
| 29 |
/* application include files */ |
| 30 |
/* */ |
| 31 |
/****************************************************************************/ |
| 32 |
|
| 33 |
#include <config.h> |
| 34 |
#include <cstddef> |
| 35 |
#include <cstdlib> |
| 36 |
|
| 37 |
#include "parallel.h" |
| 38 |
#include <dune/uggrid/low/debug.h> |
| 39 |
#include <dune/uggrid/low/namespace.h> |
| 40 |
#include <dune/uggrid/gm/ugm.h> /* for GetFreeOBJT() */ |
| 41 |
#include <dune/uggrid/parallel/ddd/include/memmgr.h> |
| 42 |
#include <dune/uggrid/ugdevices.h> |
| 43 |
|
| 44 |
/* UG namespaces: */ |
| 45 |
USING_UG_NAMESPACES |
| 46 |
|
| 47 |
/* PPIF namespace: */ |
| 48 |
using namespace PPIF; |
| 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 |
|
| 61 |
/* macro for easier definition of DDD_TYPEs */ |
| 62 |
#define ELDEF(type,member) offsetof(type,member), sizeof(type :: member) |
| 63 |
|
| 64 |
/* macro for easy definition of type mapping UG<->DDD */ |
| 65 |
#define MAP_TYPES(ugt,dddt) { int _ugt=(ugt); \ |
| 66 |
ddd_ctrl(context).ugtypes[(dddt)] = _ugt; \ |
| 67 |
ddd_ctrl(context).types[_ugt] = (dddt); \ |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
/****************************************************************************/ |
| 72 |
/* */ |
| 73 |
/* data structures used in this source file (exported data structures are */ |
| 74 |
/* in the corresponding include file!) */ |
| 75 |
/* */ |
| 76 |
/****************************************************************************/ |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
/****************************************************************************/ |
| 81 |
/* */ |
| 82 |
/* definition of exported global variables */ |
| 83 |
/* */ |
| 84 |
/****************************************************************************/ |
| 85 |
|
| 86 |
/* DDD interfaces needed for distributed computation */ |
| 87 |
DDD_IF NS_DIM_PREFIX ElementIF, NS_DIM_PREFIX ElementSymmIF, NS_DIM_PREFIX ElementVIF, NS_DIM_PREFIX ElementSymmVIF, |
| 88 |
NS_DIM_PREFIX ElementVHIF, NS_DIM_PREFIX ElementSymmVHIF; |
| 89 |
DDD_IF NS_DIM_PREFIX BorderNodeIF, NS_DIM_PREFIX BorderNodeSymmIF, NS_DIM_PREFIX OuterNodeIF, NS_DIM_PREFIX NodeVIF, |
| 90 |
NS_DIM_PREFIX NodeIF, NS_DIM_PREFIX NodeAllIF; |
| 91 |
DDD_IF NS_DIM_PREFIX BorderVectorIF, NS_DIM_PREFIX BorderVectorSymmIF, |
| 92 |
NS_DIM_PREFIX OuterVectorIF, NS_DIM_PREFIX OuterVectorSymmIF, |
| 93 |
NS_DIM_PREFIX VectorVIF, NS_DIM_PREFIX VectorVAllIF, NS_DIM_PREFIX VectorIF; |
| 94 |
/* DDD interfaces for node communication */ |
| 95 |
DDD_IF NS_DIM_PREFIX Node_InteriorBorder_All_IF; |
| 96 |
/* DDD interfaces for facet (side vector) communication */ |
| 97 |
DDD_IF NS_DIM_PREFIX Facet_InteriorBorder_All_IF; |
| 98 |
|
| 99 |
/* DDD interfaces for edge communication */ |
| 100 |
DDD_IF NS_DIM_PREFIX EdgeIF, NS_DIM_PREFIX BorderEdgeSymmIF, NS_DIM_PREFIX EdgeHIF, NS_DIM_PREFIX EdgeVHIF, |
| 101 |
NS_DIM_PREFIX EdgeSymmVHIF; |
| 102 |
|
| 103 |
|
| 104 |
/****************************************************************************/ |
| 105 |
/* */ |
| 106 |
/* definition of variables global to this source file only (static!) */ |
| 107 |
/* */ |
| 108 |
/****************************************************************************/ |
| 109 |
|
| 110 |
|
| 111 |
/****************************************************************************/ |
| 112 |
/* */ |
| 113 |
/* forward declarations of functions used before they are defined */ |
| 114 |
/* */ |
| 115 |
/****************************************************************************/ |
| 116 |
|
| 117 |
enum ElemTypeFlag { Inside, Boundary }; |
| 118 |
|
| 119 |
|
| 120 |
/****************************************************************************/ |
| 121 |
/* |
| 122 |
void ddd_InitGenericElement - |
| 123 |
|
| 124 |
SYNOPSIS: |
| 125 |
static void ddd_InitGenericElement (INT tag, DDD_TYPE dddType, int etype); |
| 126 |
|
| 127 |
PARAMETERS: |
| 128 |
. tag |
| 129 |
. dddType |
| 130 |
. etype |
| 131 |
|
| 132 |
DESCRIPTION: |
| 133 |
|
| 134 |
RETURN VALUE: |
| 135 |
void |
| 136 |
*/ |
| 137 |
/****************************************************************************/ |
| 138 |
|
| 139 |
static void ddd_InitGenericElement(DDD::DDDContext& context, INT tag, DDD_TYPE dddType, int etype) |
| 140 |
{ |
| 141 |
auto& dddctrl = ddd_ctrl(context); |
| 142 |
GENERAL_ELEMENT *desc = element_descriptors[tag]; |
| 143 |
UINT gbits = 0; |
| 144 |
|
| 145 |
size_t ps = sizeof(void *); |
| 146 |
size_t r = offsetof(generic_element,refs); |
| 147 |
|
| 148 |
/* compute global fields of control word entry */ |
| 149 |
gbits = ~(((1<<NSONS_LEN)-1)<<NSONS_SHIFT); |
| 150 |
PRINTDEBUG(dddif,1,("ddd_InitGenericElement(): gbits=%08x size=%d\n", |
| 151 |
gbits,sizeof(generic_element::control))); |
| 152 |
|
| 153 |
/* initialize base part (valid for all elements) */ |
| 154 |
DDD_TypeDefine(context, dddType, |
| 155 |
EL_DDDHDR, offsetof(generic_element,ddd), |
| 156 |
/* TODO: delete this */ |
| 157 |
/* EL_GDATA, ELDEF(generic_element,control), */ |
| 158 |
EL_GBITS, ELDEF(generic_element,control), &gbits, |
| 159 |
|
| 160 |
/* TODO: id muss umgerechnet werden! (?) */ |
| 161 |
EL_GDATA, ELDEF(generic_element,id), |
| 162 |
EL_GDATA, ELDEF(generic_element,flag), |
| 163 |
EL_GDATA, ELDEF(generic_element,property), |
| 164 |
|
| 165 |
/* LDATA, because Dune indices are local */ |
| 166 |
EL_LDATA, ELDEF(generic_element,levelIndex), |
| 167 |
EL_LDATA, ELDEF(generic_element,leafIndex), |
| 168 |
|
| 169 |
EL_GDATA, ELDEF(generic_element,lb1), |
| 170 |
EL_LDATA, ELDEF(generic_element,pred), |
| 171 |
EL_LDATA, ELDEF(generic_element,succ), |
| 172 |
EL_CONTINUE); |
| 173 |
|
| 174 |
|
| 175 |
/* initialize generic part */ |
| 176 |
/* NOTE: references to 'union element' are denoted by the ref-type |
| 177 |
dddType (i.e., the DDD_TYPE of the currently defined element itself). |
| 178 |
TODO: this should be replaced by a more explicit TypeGenericElement in |
| 179 |
later versions (code would be more readable). */ |
| 180 |
|
| 181 |
DDD_TypeDefine(context, dddType, |
| 182 |
EL_OBJPTR, r+n_offset[tag]*sizeof(void*), ps*desc->corners_of_elem, dddctrl.TypeNode, |
| 183 |
EL_OBJPTR, r+father_offset[tag]*sizeof(void*), ps, dddType, |
| 184 |
EL_LDATA, r+sons_offset[tag]*sizeof(void*), ps*2, |
| 185 |
EL_OBJPTR, r+nb_offset[tag]*sizeof(void*), ps*desc->sides_of_elem, dddType, |
| 186 |
EL_CONTINUE); |
| 187 |
|
| 188 |
|
| 189 |
/* optional components */ |
| 190 |
|
| 191 |
if (ddd_ctrl(context).elemData) |
| 192 |
DDD_TypeDefine(context, dddType, |
| 193 |
EL_OBJPTR, r+ 0 *sizeof(void*), ps*1, dddctrl.TypeVector, |
| 194 |
EL_CONTINUE); |
| 195 |
|
| 196 |
#ifdef UG_DIM_3 |
| 197 |
if (ddd_ctrl(context).sideData) |
| 198 |
DDD_TypeDefine(context, dddType, |
| 199 |
EL_OBJPTR, r+svector_offset[tag]*sizeof(void*), ps*desc->sides_of_elem, dddctrl.TypeVector, |
| 200 |
EL_CONTINUE); |
| 201 |
#endif |
| 202 |
|
| 203 |
if (etype==Inside) |
| 204 |
{ |
| 205 |
DDD_TypeDefine(context, dddType, EL_END, static_cast<size_t>(desc->inner_size)); |
| 206 |
|
| 207 |
/* init type mapping arrays */ |
| 208 |
MAP_TYPES(MAPPED_INNER_OBJT_TAG(tag), dddType); |
| 209 |
ddd_ctrl(context).dddObj[MAPPED_INNER_OBJT_TAG(tag)] = true; |
| 210 |
} |
| 211 |
else |
| 212 |
{ |
| 213 |
DDD_TypeDefine(context, dddType, |
| 214 |
EL_LDATA, r+side_offset[tag]*sizeof(void*), ps*desc->sides_of_elem, |
| 215 |
EL_END, static_cast<size_t>(desc->bnd_size)); |
| 216 |
|
| 217 |
/* init type mapping arrays */ |
| 218 |
MAP_TYPES(MAPPED_BND_OBJT_TAG(tag), dddType); |
| 219 |
ddd_ctrl(context).dddObj[MAPPED_BND_OBJT_TAG(tag)] = true; |
| 220 |
} |
| 221 |
|
| 222 |
/* set mergemode to maximum */ |
| 223 |
DDD_PrioMergeDefault(context, dddType, PRIOMERGE_MAXIMUM); |
| 224 |
/* TODO: set prios |
| 225 |
DDD_PrioMergeDefine(context, dddType, PrioHGhost, PrioVGhost, PrioVHGhost); |
| 226 |
DDD_PrioMergeDefine(context, dddType, PrioHGhost, PrioVHGhost, PrioVHGhost); |
| 227 |
DDD_PrioMergeDefine(context, dddType, PrioVGhost, PrioVHGhost, PrioVHGhost); |
| 228 |
DDD_PrioMergeDefine(context, dddType, PrioHGhost, PrioMaster, PrioMaster); |
| 229 |
DDD_PrioMergeDefine(context, dddType, PrioVGhost, PrioMaster, PrioMaster); |
| 230 |
DDD_PrioMergeDefine(context, dddType, PrioVHGhost, PrioMaster, PrioMaster); |
| 231 |
*/ |
| 232 |
|
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
/****************************************************************************/ |
| 237 |
/* */ |
| 238 |
/* Function: ddd_DeclareTypes */ |
| 239 |
/* */ |
| 240 |
/* Purpose: declare ug data structures as DDD_TYPES */ |
| 241 |
/* */ |
| 242 |
/* Input: void */ |
| 243 |
/* */ |
| 244 |
/* Output: void */ |
| 245 |
/* */ |
| 246 |
/* */ |
| 247 |
/****************************************************************************/ |
| 248 |
|
| 249 |
|
| 250 |
/****************************************************************************/ |
| 251 |
/* |
| 252 |
void ddd_DeclareTypes - declare ug data structures as DDD_TYPES |
| 253 |
|
| 254 |
SYNOPSIS: |
| 255 |
static void ddd_DeclareTypes (void); |
| 256 |
|
| 257 |
PARAMETERS: |
| 258 |
. void |
| 259 |
|
| 260 |
DESCRIPTION: |
| 261 |
This function declares ug data structures as DDD_TYPES |
| 262 |
|
| 263 |
RETURN VALUE: |
| 264 |
void |
| 265 |
*/ |
| 266 |
/****************************************************************************/ |
| 267 |
|
| 268 |
static void ddd_DeclareTypes(DDD::DDDContext& context) |
| 269 |
{ |
| 270 |
/* NOTE: (960410 KB) |
| 271 |
|
| 272 |
- handling of Vector and Matrix types may be |
| 273 |
wrong, types array entries might be used differently |
| 274 |
by ug (e.g., during allocation/deallocation). TODO ueberpruefen! |
| 275 |
(beziehung algebra.c <-> ugm.c) |
| 276 |
|
| 277 |
- UGTypes for elements will be computed later. therefore the |
| 278 |
initialization of types[] entries for elements |
| 279 |
is done (after the UGTypes are known) during ddd_InitGenericElement. |
| 280 |
TODO remove this clumsy exception! how? |
| 281 |
|
| 282 |
- variables TypeXXXX containing the proper DDD_TYPEs may be |
| 283 |
superfluous. It would be possible to replace all occurrences |
| 284 |
by macros like DDDType(VEOBJ), which would be implemented as |
| 285 |
#define DDDType(ugtype) (ddd_ctrl(context).types[ugtype]) |
| 286 |
TODO check this! |
| 287 |
pros: no double information. currently, TypeXXX may differ |
| 288 |
from corresponding ddd_ctrl(context).types[] entry. |
| 289 |
cons: will this be compatible with alloc/dealloc and TypeDefine |
| 290 |
of ug-general-elements? |
| 291 |
*/ |
| 292 |
|
| 293 |
|
| 294 |
auto& dddctrl = ddd_ctrl(context); |
| 295 |
|
| 296 |
/* 1. DDD objects (with DDD_HEADER) */ |
| 297 |
|
| 298 |
dddctrl.TypeVector = DDD_TypeDeclare(context, "Vector"); |
| 299 |
MAP_TYPES(VEOBJ, dddctrl.TypeVector); |
| 300 |
dddctrl.dddObj[VEOBJ] = true; |
| 301 |
|
| 302 |
dddctrl.TypeIVertex = DDD_TypeDeclare(context, "IVertex"); |
| 303 |
MAP_TYPES(IVOBJ, dddctrl.TypeIVertex); |
| 304 |
dddctrl.dddObj[IVOBJ] = true; |
| 305 |
|
| 306 |
dddctrl.TypeBVertex = DDD_TypeDeclare(context, "BVertex"); |
| 307 |
MAP_TYPES(BVOBJ, dddctrl.TypeBVertex); |
| 308 |
dddctrl.dddObj[BVOBJ] = true; |
| 309 |
|
| 310 |
dddctrl.TypeNode = DDD_TypeDeclare(context, "Node"); |
| 311 |
MAP_TYPES(NDOBJ, dddctrl.TypeNode); |
| 312 |
dddctrl.dddObj[NDOBJ] = true; |
| 313 |
|
| 314 |
#ifdef UG_DIM_2 |
| 315 |
dddctrl.TypeTrElem = DDD_TypeDeclare(context, "TrElem"); |
| 316 |
dddctrl.TypeTrBElem = DDD_TypeDeclare(context, "TrBElem"); |
| 317 |
dddctrl.TypeQuElem = DDD_TypeDeclare(context, "QuElem"); |
| 318 |
dddctrl.TypeQuBElem = DDD_TypeDeclare(context, "QuBElem"); |
| 319 |
#endif /* TWODIM */ |
| 320 |
|
| 321 |
#ifdef UG_DIM_3 |
| 322 |
dddctrl.TypeTeElem = DDD_TypeDeclare(context, "TeElem"); |
| 323 |
dddctrl.TypeTeBElem = DDD_TypeDeclare(context, "TeBElem"); |
| 324 |
dddctrl.TypePyElem = DDD_TypeDeclare(context, "PyElem"); |
| 325 |
dddctrl.TypePyBElem = DDD_TypeDeclare(context, "PyBElem"); |
| 326 |
dddctrl.TypePrElem = DDD_TypeDeclare(context, "PrElem"); |
| 327 |
dddctrl.TypePrBElem = DDD_TypeDeclare(context, "PrBElem"); |
| 328 |
dddctrl.TypeHeElem = DDD_TypeDeclare(context, "HeElem"); |
| 329 |
dddctrl.TypeHeBElem = DDD_TypeDeclare(context, "HeBElem"); |
| 330 |
#endif /* THREEDIM */ |
| 331 |
|
| 332 |
/* edge type not unique: */ |
| 333 |
/* edge is DDD object for 2D and 3D */ |
| 334 |
/* edge is DDD data object for 2D */ |
| 335 |
dddctrl.TypeEdge = DDD_TypeDeclare(context, "Edge"); |
| 336 |
MAP_TYPES(EDOBJ, dddctrl.TypeEdge); |
| 337 |
dddctrl.dddObj[EDOBJ] = true; |
| 338 |
|
| 339 |
/* 2. DDD data objects (without DDD_HEADER) */ |
| 340 |
|
| 341 |
dddctrl.TypeBndP = DDD_TypeDeclare(context, "BndP"); |
| 342 |
static const INT objtBndP = GetFreeOBJT(); |
| 343 |
MAP_TYPES(objtBndP, dddctrl.TypeBndP); |
| 344 |
|
| 345 |
dddctrl.TypeBndS = DDD_TypeDeclare(context, "BndS"); |
| 346 |
static const INT objtBndS = GetFreeOBJT(); |
| 347 |
MAP_TYPES(objtBndS, dddctrl.TypeBndS); |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
/****************************************************************************/ |
| 352 |
/* |
| 353 |
ddd_DefineTypes - define previously declared DDD_TYPES |
| 354 |
|
| 355 |
SYNOPSIS: |
| 356 |
static void ddd_DefineTypes (void); |
| 357 |
|
| 358 |
PARAMETERS: |
| 359 |
. void |
| 360 |
|
| 361 |
DESCRIPTION: |
| 362 |
This function defines previously declared DDD_TYPES |
| 363 |
Note: this function depends on previous definition of all necessary ug-generic-elements. |
| 364 |
|
| 365 |
RETURN VALUE: |
| 366 |
void |
| 367 |
*/ |
| 368 |
/****************************************************************************/ |
| 369 |
|
| 370 |
static void ddd_DefineTypes(DDD::DDDContext& context) |
| 371 |
{ |
| 372 |
auto& dddctrl = ddd_ctrl(context); |
| 373 |
INT size; |
| 374 |
UINT gbits = 0; |
| 375 |
|
| 376 |
/* 1. DDD objects (with DDD_HEADER) */ |
| 377 |
|
| 378 |
/* |
| 379 |
* A side vector's `VECTORSIDE` depends on which of the `objects` is used |
| 380 |
* as a representative. To ensure consistency, both are handled in the same |
| 381 |
* place (`ElementObjMkCons`). |
| 382 |
*/ |
| 383 |
gbits = ~(((1 << VECTORSIDE_LEN)-1) << VECTORSIDE_SHIFT); |
| 384 |
DDD_TypeDefine(context, dddctrl.TypeVector, |
| 385 |
EL_DDDHDR, offsetof(VECTOR,ddd), |
| 386 |
EL_GBITS, ELDEF(VECTOR,control), &gbits, |
| 387 |
|
| 388 |
/* object must be LDATA, because reftype may be a non-DDD-object */ |
| 389 |
/* (e.g., edge). therefore, 'object' must be updated by MKCONS- */ |
| 390 |
/* handler of associated object. 960404 KB */ |
| 391 |
/* TODO: decide whether LDATA or OBJPTR for different VectorTypes*/ |
| 392 |
/* EL_OBJPTR, ELDEF(VECTOR,object), TypeNode, */ |
| 393 |
EL_LDATA, ELDEF(VECTOR,object), |
| 394 |
EL_LDATA, ELDEF(VECTOR,pred), |
| 395 |
EL_LDATA, ELDEF(VECTOR,succ), |
| 396 |
EL_GDATA, ELDEF(VECTOR,index), |
| 397 |
EL_GDATA, ELDEF(VECTOR,leafIndex), |
| 398 |
|
| 399 |
/* TODO: value wird noch ausgelassen. Feld variabler Laenge? */ |
| 400 |
/* bei Entscheidung 'value': kein weiteres Feld |
| 401 |
bei ent. 'userdata *': EL_GDATA-feld */ |
| 402 |
EL_GDATA, ELDEF(VECTOR,value), |
| 403 |
EL_END, sizeof(VECTOR) |
| 404 |
); |
| 405 |
|
| 406 |
/* set mergemode to maximum */ |
| 407 |
DDD_PrioMergeDefault(context, dddctrl.TypeVector, PRIOMERGE_MAXIMUM); |
| 408 |
|
| 409 |
/* compute global fields it control word entry */ |
| 410 |
gbits = ~((((1<<ONEDGE_LEN)-1)<<ONEDGE_SHIFT) | |
| 411 |
(((1<<NOOFNODE_LEN)-1)<<NOOFNODE_SHIFT)); |
| 412 |
PRINTDEBUG(dddif,1,("ddd_DefineTypes(): TypeI/BVertex gbits=%08x size=%d\n", |
| 413 |
gbits,sizeof(ivertex::control))); |
| 414 |
|
| 415 |
DDD_TypeDefine(context, dddctrl.TypeIVertex, |
| 416 |
EL_DDDHDR, offsetof(ivertex,ddd), |
| 417 |
/* TODO: delete |
| 418 |
EL_GDATA, ELDEF(ivertex,control), |
| 419 |
*/ |
| 420 |
EL_GBITS, ELDEF(ivertex,control), &gbits, |
| 421 |
|
| 422 |
/* TODO: muss umgerechnet werden! */ |
| 423 |
EL_GDATA, ELDEF(ivertex,id), |
| 424 |
EL_GDATA, ELDEF(ivertex,x), |
| 425 |
EL_GDATA, ELDEF(ivertex,xi), |
| 426 |
EL_LDATA, ELDEF(ivertex,leafIndex), |
| 427 |
EL_LDATA, ELDEF(ivertex,pred), |
| 428 |
EL_LDATA, ELDEF(ivertex,succ), |
| 429 |
EL_LDATA, ELDEF(ivertex,data), |
| 430 |
|
| 431 |
/* TODO Does father have to be LDATA or OBJPTR? */ |
| 432 |
/* LDATA, father is valid only locally, */ |
| 433 |
/* and depends on vertical load balancing. */ |
| 434 |
#ifdef UG_DIM_2 |
| 435 |
/* TODO: ref-typ muss eigentlich {TypeTrElem,TypeTrBElem} sein! */ |
| 436 |
EL_OBJPTR, ELDEF(ivertex,father), dddctrl.TypeTrElem, |
| 437 |
#endif |
| 438 |
#ifdef UG_DIM_3 |
| 439 |
EL_LDATA, ELDEF(ivertex,father), |
| 440 |
#endif |
| 441 |
|
| 442 |
#ifdef TOPNODE |
| 443 |
/* TODO topnode wirklich OBJPTR? */ |
| 444 |
EL_LDATA, ELDEF(ivertex,topnode), |
| 445 |
#endif |
| 446 |
EL_END, sizeof(ivertex) |
| 447 |
); |
| 448 |
|
| 449 |
/* set mergemode to maximum */ |
| 450 |
DDD_PrioMergeDefault(context, dddctrl.TypeIVertex, PRIOMERGE_MAXIMUM); |
| 451 |
|
| 452 |
|
| 453 |
DDD_TypeDefine(context, dddctrl.TypeBVertex, |
| 454 |
EL_DDDHDR, offsetof(bvertex,ddd), |
| 455 |
/* TODO: delete |
| 456 |
EL_GDATA, ELDEF(bvertex,control), |
| 457 |
*/ |
| 458 |
EL_GBITS, ELDEF(bvertex,control), &gbits, |
| 459 |
|
| 460 |
/* TODO: muss umgerechnet werden! Nooeee! */ |
| 461 |
EL_GDATA, ELDEF(bvertex,id), |
| 462 |
EL_GDATA, ELDEF(bvertex,x), |
| 463 |
EL_GDATA, ELDEF(bvertex,xi), |
| 464 |
EL_LDATA, ELDEF(bvertex,leafIndex), |
| 465 |
EL_LDATA, ELDEF(bvertex,pred), |
| 466 |
EL_LDATA, ELDEF(bvertex,succ), |
| 467 |
EL_LDATA, ELDEF(bvertex,data), |
| 468 |
|
| 469 |
/* TODO Does father have to be LDATA or OBJPTR? */ |
| 470 |
/* LDATA, father is valid only locally, */ |
| 471 |
/* and depends on vertical load balancing. */ |
| 472 |
#ifdef UG_DIM_2 |
| 473 |
/* TODO: ref-typ muss eigentlich {TypeTrElem,TypeTrBElem} sein! */ |
| 474 |
EL_OBJPTR, ELDEF(bvertex,father), dddctrl.TypeTrElem, |
| 475 |
#endif |
| 476 |
#ifdef UG_DIM_3 |
| 477 |
EL_LDATA, ELDEF(bvertex,father), |
| 478 |
#endif |
| 479 |
|
| 480 |
#ifdef TOPNODE |
| 481 |
/* TODO topnode wirklich OBJPTR?, Nooeee! */ |
| 482 |
EL_LDATA, ELDEF(bvertex,topnode), |
| 483 |
#endif |
| 484 |
EL_LDATA, ELDEF(bvertex,bndp), /* different from IVertex */ |
| 485 |
EL_END, sizeof(bvertex) |
| 486 |
); |
| 487 |
|
| 488 |
/* set mergemode to maximum */ |
| 489 |
DDD_PrioMergeDefault(context, dddctrl.TypeBVertex, PRIOMERGE_MAXIMUM); |
| 490 |
|
| 491 |
|
| 492 |
DDD_TypeDefine(context, dddctrl.TypeNode, |
| 493 |
EL_DDDHDR, offsetof(NODE,ddd), |
| 494 |
EL_GDATA, ELDEF(NODE,control), |
| 495 |
|
| 496 |
/* TODO: muss umgerechnet werden! */ |
| 497 |
EL_GDATA, ELDEF(NODE,id), |
| 498 |
EL_LDATA, ELDEF(NODE,levelIndex), |
| 499 |
EL_GDATA, ELDEF(NODE,isLeaf), |
| 500 |
EL_LDATA, ELDEF(NODE,pred), |
| 501 |
EL_LDATA, ELDEF(NODE,succ), |
| 502 |
|
| 503 |
/* TODO What is start? */ |
| 504 |
EL_LDATA, ELDEF(NODE,start), |
| 505 |
|
| 506 |
/* father may be one of node or edge */ |
| 507 |
EL_OBJPTR, ELDEF(NODE,father), DDD_TYPE_BY_HANDLER, NFatherObjType, |
| 508 |
|
| 509 |
EL_OBJPTR, ELDEF(NODE,son), dddctrl.TypeNode, |
| 510 |
|
| 511 |
/* TODO: ref-typ muss eigentlich {TypeIVertex,TypeBVertex} sein! */ |
| 512 |
EL_OBJPTR, ELDEF(NODE,myvertex), dddctrl.TypeIVertex, |
| 513 |
EL_CONTINUE); |
| 514 |
|
| 515 |
DDD_TypeDefine(context, dddctrl.TypeNode, |
| 516 |
EL_END, sizeof(NODE)); |
| 517 |
|
| 518 |
/* set mergemode to maximum */ |
| 519 |
DDD_PrioMergeDefault(context, dddctrl.TypeNode, PRIOMERGE_MAXIMUM); |
| 520 |
|
| 521 |
|
| 522 |
#ifdef UG_DIM_2 |
| 523 |
ddd_InitGenericElement(context, TRIANGLE, dddctrl.TypeTrElem, Inside); |
| 524 |
ddd_InitGenericElement(context, TRIANGLE, dddctrl.TypeTrBElem, Boundary); |
| 525 |
ddd_InitGenericElement(context, QUADRILATERAL, dddctrl.TypeQuElem, Inside); |
| 526 |
ddd_InitGenericElement(context, QUADRILATERAL, dddctrl.TypeQuBElem, Boundary); |
| 527 |
#endif /* TWODIM */ |
| 528 |
|
| 529 |
#ifdef UG_DIM_3 |
| 530 |
ddd_InitGenericElement(context, TETRAHEDRON, dddctrl.TypeTeElem, Inside); |
| 531 |
ddd_InitGenericElement(context, TETRAHEDRON, dddctrl.TypeTeBElem, Boundary); |
| 532 |
ddd_InitGenericElement(context, PYRAMID, dddctrl.TypePyElem, Inside); |
| 533 |
ddd_InitGenericElement(context, PYRAMID, dddctrl.TypePyBElem, Boundary); |
| 534 |
ddd_InitGenericElement(context, PRISM, dddctrl.TypePrElem, Inside); |
| 535 |
ddd_InitGenericElement(context, PRISM, dddctrl.TypePrBElem, Boundary); |
| 536 |
ddd_InitGenericElement(context, HEXAHEDRON, dddctrl.TypeHeElem, Inside); |
| 537 |
ddd_InitGenericElement(context, HEXAHEDRON, dddctrl.TypeHeBElem, Boundary); |
| 538 |
#endif /* THREEDIM */ |
| 539 |
|
| 540 |
/* 2. DDD data objects (without DDD_HEADER) */ |
| 541 |
|
| 542 |
/* compute global fields it control word entry */ |
| 543 |
gbits = ~(((1<<NO_OF_ELEM_LEN)-1)<<NO_OF_ELEM_SHIFT); |
| 544 |
PRINTDEBUG(dddif,1,("ddd_DefineTypes(): TypeEdge gbits=%08x size=%d\n", |
| 545 |
gbits,sizeof(link::control))); |
| 546 |
|
| 547 |
DDD_TypeDefine(context, dddctrl.TypeEdge, |
| 548 |
/* link 0 data */ |
| 549 |
/*TODO: now unique |
| 550 |
#ifdef UG_DIM_2 |
| 551 |
EL_GDATA, ELDEF(EDGE,links[0].control), |
| 552 |
#endif |
| 553 |
#ifdef UG_DIM_3 |
| 554 |
EL_LDATA, ELDEF(EDGE,links[0].control), |
| 555 |
#endif |
| 556 |
*/ |
| 557 |
EL_GBITS, ELDEF(EDGE,links[0].control), &gbits, |
| 558 |
EL_LDATA, ELDEF(EDGE,links[0].next), |
| 559 |
EL_OBJPTR, ELDEF(EDGE,links[0].nbnode), dddctrl.TypeNode, |
| 560 |
|
| 561 |
/* link 1 data */ |
| 562 |
EL_GDATA, ELDEF(EDGE,links[1].control), |
| 563 |
EL_LDATA, ELDEF(EDGE,links[1].next), |
| 564 |
EL_OBJPTR, ELDEF(EDGE,links[1].nbnode), dddctrl.TypeNode, |
| 565 |
|
| 566 |
EL_LDATA, ELDEF(EDGE,levelIndex), |
| 567 |
EL_LDATA, ELDEF(EDGE,leafIndex), |
| 568 |
EL_GDATA, ELDEF(EDGE,id), |
| 569 |
EL_DDDHDR, offsetof(EDGE,ddd), |
| 570 |
|
| 571 |
EL_OBJPTR, ELDEF(EDGE,midnode), dddctrl.TypeNode, |
| 572 |
EL_CONTINUE); |
| 573 |
|
| 574 |
if (dddctrl.edgeData) |
| 575 |
DDD_TypeDefine(context, dddctrl.TypeEdge, |
| 576 |
EL_OBJPTR, ELDEF(EDGE,vector), dddctrl.TypeVector, |
| 577 |
EL_CONTINUE); |
| 578 |
|
| 579 |
/* See the corresponding line for TypeNode for an explanation of why |
| 580 |
* the object size is modified here. */ |
| 581 |
size = sizeof(EDGE) - ((ddd_ctrl(context).edgeData) ? 0 : sizeof(VECTOR*)); |
| 582 |
DDD_TypeDefine(context, dddctrl.TypeEdge, EL_END, size); |
| 583 |
|
| 584 |
/* set mergemode to maximum */ |
| 585 |
DDD_PrioMergeDefault(context, dddctrl.TypeEdge, PRIOMERGE_MAXIMUM); |
| 586 |
|
| 587 |
} |
| 588 |
|
| 589 |
|
| 590 |
/****************************************************************************/ |
| 591 |
/* |
| 592 |
ddd_IfInit - define the communication interfaces needed in ug for management by DDD |
| 593 |
|
| 594 |
SYNOPSIS: |
| 595 |
static void ddd_IfInit(DDD::DDDContext& context); |
| 596 |
|
| 597 |
PARAMETERS: |
| 598 |
. context |
| 599 |
|
| 600 |
DESCRIPTION: |
| 601 |
This function defines the communication interfaces needed in ug for management by DDD |
| 602 |
|
| 603 |
RETURN VALUE: |
| 604 |
void |
| 605 |
|
| 606 |
\note Not all of these interfaces are actually needed by Dune. |
| 607 |
Those can be removed. |
| 608 |
*/ |
| 609 |
/****************************************************************************/ |
| 610 |
|
| 611 |
static void ddd_IfInit(DDD::DDDContext& context) |
| 612 |
{ |
| 613 |
auto& dddctrl = ddd_ctrl(context); |
| 614 |
|
| 615 |
DDD_TYPE O[8]; |
| 616 |
int nO; |
| 617 |
DDD_PRIO A[8]; |
| 618 |
DDD_PRIO B[8]; |
| 619 |
|
| 620 |
|
| 621 |
/* define element interfaces */ |
| 622 |
#ifdef UG_DIM_2 |
| 623 |
O[0] = dddctrl.TypeTrElem; O[1] = dddctrl.TypeTrBElem; |
| 624 |
O[2] = dddctrl.TypeQuElem; O[3] = dddctrl.TypeQuBElem; |
| 625 |
nO = 4; |
| 626 |
#endif |
| 627 |
|
| 628 |
#ifdef UG_DIM_3 |
| 629 |
O[0] = dddctrl.TypeTeElem; O[1] = dddctrl.TypeTeBElem; |
| 630 |
O[2] = dddctrl.TypePyElem; O[3] = dddctrl.TypePyBElem; |
| 631 |
O[4] = dddctrl.TypePrElem; O[5] = dddctrl.TypePrBElem; |
| 632 |
O[6] = dddctrl.TypeHeElem; O[7] = dddctrl.TypeHeBElem; |
| 633 |
nO = 8; |
| 634 |
#endif |
| 635 |
|
| 636 |
A[0] = PrioMaster; |
| 637 |
B[0] = PrioHGhost; B[1] = PrioVHGhost; |
| 638 |
dddctrl.ElementIF = DDD_IFDefine(context, nO,O,1,A,2,B); |
| 639 |
DDD_IFSetName(context, dddctrl.ElementIF, "ElementIF: Master->HGhost/VHGhost"); |
| 640 |
|
| 641 |
A[0] = PrioMaster; A[1] = PrioHGhost; A[2] = PrioVHGhost; |
| 642 |
B[0] = PrioMaster; B[1] = PrioHGhost; B[2] = PrioVHGhost; |
| 643 |
dddctrl.ElementSymmIF = DDD_IFDefine(context, nO,O,3,A,3,B); |
| 644 |
DDD_IFSetName(context, dddctrl.ElementSymmIF, "ElementSymmIF: Master/HGhost/VHGhost"); |
| 645 |
|
| 646 |
A[0] = PrioMaster; |
| 647 |
B[0] = PrioVGhost; B[1] = PrioVHGhost; |
| 648 |
dddctrl.ElementVIF = DDD_IFDefine(context, nO,O,1,A,2,B); |
| 649 |
DDD_IFSetName(context, dddctrl.ElementVIF, "ElementVIF: Master->VGhost/VHGhost"); |
| 650 |
|
| 651 |
A[0] = PrioMaster; A[1] = PrioVGhost; A[2] = PrioVHGhost; |
| 652 |
B[0] = PrioMaster; B[1] = PrioVGhost; B[2] = PrioVHGhost; |
| 653 |
dddctrl.ElementSymmVIF = DDD_IFDefine(context, nO,O,3,A,3,B); |
| 654 |
DDD_IFSetName(context, dddctrl.ElementSymmVIF, "ElementSymmVIF: Master/VGhost/VHGhost"); |
| 655 |
|
| 656 |
A[0] = PrioMaster; |
| 657 |
B[0] = PrioVGhost; B[1] = PrioHGhost; B[2] = PrioVHGhost; |
| 658 |
dddctrl.ElementVHIF = DDD_IFDefine(context, nO,O,1,A,3,B); |
| 659 |
DDD_IFSetName(context, dddctrl.ElementVHIF, "ElementVHIF: Master->VGhost/HGhost/VHGhost"); |
| 660 |
|
| 661 |
A[0] = PrioMaster; A[1] = PrioVGhost; A[2] = PrioHGhost; A[3] = PrioVHGhost; |
| 662 |
B[0] = PrioMaster; B[1] = PrioVGhost; B[2] = PrioHGhost; B[3] = PrioVHGhost; |
| 663 |
dddctrl.ElementSymmVHIF = DDD_IFDefine(context, nO,O,4,A,4,B); |
| 664 |
DDD_IFSetName(context, dddctrl.ElementSymmVHIF, "ElementSymmVHIF: Master/VGhost/HGhost/VHGhost"); |
| 665 |
|
| 666 |
|
| 667 |
/* define node interfaces */ |
| 668 |
O[0] = dddctrl.TypeNode; |
| 669 |
|
| 670 |
A[0] = PrioBorder; |
| 671 |
B[0] = PrioMaster; |
| 672 |
dddctrl.BorderNodeIF = DDD_IFDefine(context, 1,O,1,A,1,B); |
| 673 |
DDD_IFSetName(context, dddctrl.BorderNodeIF, "BorderNodeIF: Border->Master"); |
| 674 |
|
| 675 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 676 |
B[0] = PrioMaster; B[1] = PrioBorder; |
| 677 |
dddctrl.BorderNodeSymmIF = DDD_IFDefine(context, 1,O,2,A,2,B); |
| 678 |
DDD_IFSetName(context, dddctrl.BorderNodeSymmIF, "BorderNodeSymmIF: Border/Master"); |
| 679 |
|
| 680 |
A[0] = PrioMaster; |
| 681 |
B[0] = PrioHGhost; B[1] = PrioVHGhost; |
| 682 |
dddctrl.OuterNodeIF = DDD_IFDefine(context, 1,O,1,A,2,B); |
| 683 |
DDD_IFSetName(context, dddctrl.OuterNodeIF, "OuterNodeIF: Master->HGhost/VGhost"); |
| 684 |
|
| 685 |
A[0] = PrioMaster; |
| 686 |
B[0] = PrioVGhost; B[1] = PrioVHGhost; |
| 687 |
dddctrl.NodeVIF = DDD_IFDefine(context, 1,O,1,A,2,B); |
| 688 |
DDD_IFSetName(context, dddctrl.NodeVIF, "NodeVIF: Master->VGhost/VHGhost"); |
| 689 |
|
| 690 |
A[0] = PrioMaster; |
| 691 |
B[0] = PrioVGhost; B[1] = PrioHGhost; B[2] = PrioVHGhost; |
| 692 |
dddctrl.NodeIF = DDD_IFDefine(context, 1,O,1,A,3,B); |
| 693 |
DDD_IFSetName(context, dddctrl.NodeIF, "NodeIF: Master->VGhost/HGhost/VHGhost"); |
| 694 |
|
| 695 |
A[0] = PrioMaster; A[1] = PrioBorder; A[2] = PrioVGhost; A[3] = PrioHGhost; A[4] = PrioVHGhost; |
| 696 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioVGhost; B[3] = PrioHGhost; B[4] = PrioVHGhost; |
| 697 |
dddctrl.NodeAllIF = DDD_IFDefine(context, 1,O,5,A,5,B); |
| 698 |
DDD_IFSetName(context, dddctrl.NodeAllIF, "NodeAllIF: All/All"); |
| 699 |
|
| 700 |
// The Dune InteriorBorder_All_Interface for nodes |
| 701 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 702 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioVGhost; B[3] = PrioHGhost; B[4] = PrioVHGhost; |
| 703 |
dddctrl.Node_InteriorBorder_All_IF = DDD_IFDefine(context, 1,O,2,A,5,B); |
| 704 |
DDD_IFSetName(context, dddctrl.Node_InteriorBorder_All_IF, "Node_InteriorBorder_All_IF: Master/Border->Master/Border/VGhost/HGhost/VHGhost"); |
| 705 |
|
| 706 |
/* define vector interfaces */ |
| 707 |
O[0] = dddctrl.TypeVector; |
| 708 |
|
| 709 |
A[0] = PrioBorder; |
| 710 |
B[0] = PrioMaster; |
| 711 |
dddctrl.BorderVectorIF = DDD_IFDefine(context, 1,O,1,A,1,B); |
| 712 |
DDD_IFSetName(context, dddctrl.BorderVectorIF, "BorderVectorIF: Border->Master"); |
| 713 |
|
| 714 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 715 |
B[0] = PrioMaster; B[1] = PrioBorder; |
| 716 |
dddctrl.BorderVectorSymmIF = DDD_IFDefine(context, 1,O,2,A,2,B); |
| 717 |
DDD_IFSetName(context, dddctrl.BorderVectorSymmIF, "BorderVectorSymmIF: Master/Border"); |
| 718 |
|
| 719 |
A[0] = PrioMaster; |
| 720 |
B[0] = PrioHGhost; B[1] = PrioVHGhost; |
| 721 |
dddctrl.OuterVectorIF = DDD_IFDefine(context, 1,O,1,A,2,B); |
| 722 |
DDD_IFSetName(context, dddctrl.OuterVectorIF, "OuterVectorIF: Master->HGhost/VHGhost"); |
| 723 |
|
| 724 |
A[0] = PrioMaster; A[1] = PrioBorder; A[2] = PrioHGhost; A[3] = PrioVHGhost; |
| 725 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioHGhost; B[3] = PrioVHGhost; |
| 726 |
dddctrl.OuterVectorSymmIF = DDD_IFDefine(context, 1,O,4,A,4,B); |
| 727 |
DDD_IFSetName(context, dddctrl.OuterVectorSymmIF, "OuterVectorSymmIF: Master/Border/HGhost/VHGhost"); |
| 728 |
|
| 729 |
A[0] = PrioMaster; |
| 730 |
B[0] = PrioVGhost; B[1] = PrioVHGhost; |
| 731 |
dddctrl.VectorVIF = DDD_IFDefine(context, 1,O,1,A,2,B); |
| 732 |
DDD_IFSetName(context, dddctrl.VectorVIF, "VectorVIF: Master->VGhost/VHGhost"); |
| 733 |
|
| 734 |
A[0] = PrioMaster; A[1] = PrioBorder; A[2] = PrioVGhost; A[3] = PrioVHGhost; |
| 735 |
B[0] = PrioMaster; B[1] = PrioBorder; |
| 736 |
dddctrl.VectorVAllIF = DDD_IFDefine(context, 1,O,4,A,2,B); |
| 737 |
DDD_IFSetName(context, dddctrl.VectorVAllIF, "VectorVAllIF: Master/Border/VGhost/VHGhost->Master/Border"); |
| 738 |
|
| 739 |
A[0] = PrioMaster; |
| 740 |
B[0] = PrioVGhost; B[1] = PrioVHGhost; B[2] = PrioHGhost; |
| 741 |
dddctrl.VectorIF = DDD_IFDefine(context, 1,O,1,A,3,B); |
| 742 |
DDD_IFSetName(context, dddctrl.VectorIF, "VectorIF: Master->VGhost/VHGhost/HGhost"); |
| 743 |
|
| 744 |
// The Dune InteriorBorder_All_Interface for facets |
| 745 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 746 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioVGhost; B[3] = PrioHGhost; B[4] = PrioVHGhost; |
| 747 |
dddctrl.Facet_InteriorBorder_All_IF = DDD_IFDefine(context, 1,O,2,A,5,B); |
| 748 |
DDD_IFSetName(context, dddctrl.Facet_InteriorBorder_All_IF, "Facet_InteriorBorder_All_IF: Master/Border->Master/Border/VGhost/HGhost/VHGhost"); |
| 749 |
|
| 750 |
// The Dune All_All_Interface for facets |
| 751 |
A[0] = PrioMaster; A[1] = PrioBorder; A[2] = PrioVGhost; A[3] = PrioHGhost; A[4] = PrioVHGhost; |
| 752 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioVGhost; B[3] = PrioHGhost; B[4] = PrioVHGhost; |
| 753 |
dddctrl.Facet_All_All_IF = DDD_IFDefine(context, 1,O,5,A,5,B); |
| 754 |
DDD_IFSetName(context, dddctrl.Facet_All_All_IF, "Facet_All_All_IF: Master/Border/VGhost/HGhost/VHGhost->Master/Border/VGhost/HGhost/VHGhost"); |
| 755 |
|
| 756 |
/* define vertex interfaces */ |
| 757 |
O[0] = dddctrl.TypeIVertex; O[1] = dddctrl.TypeBVertex; |
| 758 |
|
| 759 |
A[0] = PrioMaster; |
| 760 |
B[0] = PrioMaster; |
| 761 |
dddctrl.VertexIF = DDD_IFDefine(context, 2,O,1,A,1,B); |
| 762 |
DDD_IFSetName(context, dddctrl.VertexIF, "VertexIF: Master<->Master"); |
| 763 |
|
| 764 |
|
| 765 |
/* define edge interfaces */ |
| 766 |
O[0] = dddctrl.TypeEdge; |
| 767 |
|
| 768 |
A[0] = PrioMaster; |
| 769 |
B[0] = PrioMaster; |
| 770 |
dddctrl.EdgeIF = DDD_IFDefine(context, 1,O,1,A,1,B); |
| 771 |
DDD_IFSetName(context, dddctrl.EdgeIF, "EdgeIF: Master<->Master"); |
| 772 |
|
| 773 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 774 |
B[0] = PrioMaster; B[1] = PrioBorder; |
| 775 |
dddctrl.BorderEdgeSymmIF = DDD_IFDefine(context, 1,O,2,A,2,B); |
| 776 |
DDD_IFSetName(context, dddctrl.BorderEdgeSymmIF, "BorderEdgeSymmIF: Master/Border"); |
| 777 |
|
| 778 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 779 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioHGhost; B[3] = PrioVHGhost; |
| 780 |
dddctrl.EdgeHIF = DDD_IFDefine(context, 1,O,2,A,4,B); |
| 781 |
DDD_IFSetName(context, dddctrl.EdgeHIF, "EdgeHIF: Master/Border->Master/Border/PrioHGhost/PrioVHGhost"); |
| 782 |
|
| 783 |
A[0] = PrioMaster; A[1] = PrioBorder; |
| 784 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioVGhost; B[3] = PrioHGhost; B[4] = PrioVHGhost; |
| 785 |
dddctrl.EdgeVHIF = DDD_IFDefine(context, 1,O,2,A,5,B); |
| 786 |
DDD_IFSetName(context, dddctrl.EdgeVHIF, "EdgeVHIF: Master/Border->Master/Border/VGhost/HGhost/VHGhost"); |
| 787 |
|
| 788 |
A[0] = PrioMaster; A[1] = PrioBorder; A[2] = PrioVGhost; A[3] = PrioHGhost; A[4] = PrioVHGhost; |
| 789 |
B[0] = PrioMaster; B[1] = PrioBorder; B[2] = PrioVGhost; B[3] = PrioHGhost; B[4] = PrioVHGhost; |
| 790 |
dddctrl.EdgeSymmVHIF = DDD_IFDefine(context, 1,O,5,A,5,B); |
| 791 |
DDD_IFSetName(context, dddctrl.EdgeSymmVHIF, "EdgeSymmVHIF: Master/Border/VGhost/HGhost/VHGhost"); |
| 792 |
|
| 793 |
} |
| 794 |
|
| 795 |
|
| 796 |
/****************************************************************************/ |
| 797 |
/* |
| 798 |
InitDDDTypes - define DDD_TYPEs |
| 799 |
|
| 800 |
SYNOPSIS: |
| 801 |
static void InitDDDTypes (DDD::DDDContext& context); |
| 802 |
|
| 803 |
PARAMETERS: |
| 804 |
. context |
| 805 |
|
| 806 |
DESCRIPTION: |
| 807 |
This function must be called once before creation of DDD-objects. It depends on correct and complete initialization of all ug-generic-elements, therefore it must be called after completion of InitElementTypes(). As InitElementTypes() will be called whenever new Multigrids are created/opened, an execution guard prevents this function from multiple execution. |
| 808 |
|
| 809 |
RETURN VALUE: |
| 810 |
void |
| 811 |
*/ |
| 812 |
/****************************************************************************/ |
| 813 |
|
| 814 |
static void InitDDDTypes(DDD::DDDContext& context) |
| 815 |
{ |
| 816 |
auto& dddctrl = ddd_ctrl(context); |
| 817 |
|
| 818 |
/* prevent from multiple execution */ |
| 819 |
if (dddctrl.allTypesDefined) |
| 820 |
return; |
| 821 |
dddctrl.allTypesDefined = true; |
| 822 |
|
| 823 |
ddd_DefineTypes(context); |
| 824 |
|
| 825 |
|
| 826 |
/* display ddd types */ |
| 827 |
IFDEBUG(dddif,1) |
| 828 |
DDD_TypeDisplay(context, dddctrl.TypeVector); |
| 829 |
DDD_TypeDisplay(context, dddctrl.TypeIVertex); |
| 830 |
DDD_TypeDisplay(context, dddctrl.TypeBVertex); |
| 831 |
DDD_TypeDisplay(context, dddctrl.TypeNode); |
| 832 |
DDD_TypeDisplay(context, dddctrl.TypeEdge); |
| 833 |
|
| 834 |
#ifdef UG_DIM_2 |
| 835 |
DDD_TypeDisplay(context, dddctrl.TypeTrElem); |
| 836 |
DDD_TypeDisplay(context, dddctrl.TypeTrBElem); |
| 837 |
DDD_TypeDisplay(context, dddctrl.TypeQuElem); |
| 838 |
DDD_TypeDisplay(context, dddctrl.TypeQuBElem); |
| 839 |
#endif |
| 840 |
|
| 841 |
#ifdef UG_DIM_3 |
| 842 |
DDD_TypeDisplay(context, dddctrl.TypeTeElem); |
| 843 |
DDD_TypeDisplay(context, dddctrl.TypeTeBElem); |
| 844 |
DDD_TypeDisplay(context, dddctrl.TypePyElem); |
| 845 |
DDD_TypeDisplay(context, dddctrl.TypePyBElem); |
| 846 |
DDD_TypeDisplay(context, dddctrl.TypePrElem); |
| 847 |
DDD_TypeDisplay(context, dddctrl.TypePrBElem); |
| 848 |
DDD_TypeDisplay(context, dddctrl.TypeHeElem); |
| 849 |
DDD_TypeDisplay(context, dddctrl.TypeHeBElem); |
| 850 |
#endif |
| 851 |
|
| 852 |
/* display dependent types */ |
| 853 |
#ifdef UG_DIM_2 |
| 854 |
DDD_TypeDisplay(context, dddctrl.TypeEdge); |
| 855 |
#endif |
| 856 |
ENDDEBUG |
| 857 |
|
| 858 |
ddd_HandlerInit(context, HSET_XFER); |
| 859 |
} |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
/****************************************************************************/ |
| 864 |
/* |
| 865 |
InitCurrMG - initialize the current multigrid which is handled by DDD |
| 866 |
|
| 867 |
SYNOPSIS: |
| 868 |
void InitCurrMG (MULTIGRID *MG); |
| 869 |
|
| 870 |
PARAMETERS: |
| 871 |
. MG |
| 872 |
|
| 873 |
DESCRIPTION: |
| 874 |
This function initializes the current multigrid which is handled by DDD |
| 875 |
|
| 876 |
RETURN VALUE: |
| 877 |
void |
| 878 |
*/ |
| 879 |
/****************************************************************************/ |
| 880 |
|
| 881 |
|
| 882 |
void NS_DIM_PREFIX InitCurrMG (MULTIGRID *MG) |
| 883 |
{ |
| 884 |
auto& dddctrl = ddd_ctrl(MG->dddContext()); |
| 885 |
dddctrl.currMG = MG; |
| 886 |
|
| 887 |
dddctrl.nodeData = 0; |
| 888 |
dddctrl.edgeData = 0; |
| 889 |
dddctrl.elemData = 0; |
| 890 |
dddctrl.sideData = VEC_DEF_IN_OBJ_OF_MG(dddctrl.currMG,SIDEVEC); |
| 891 |
|
| 892 |
InitDDDTypes(MG->dddContext()); |
| 893 |
} |
| 894 |
|
| 895 |
|
| 896 |
/****************************************************************************/ |
| 897 |
/* |
| 898 |
CheckInitParallel - check for correct initialization of dddif subsystem |
| 899 |
|
| 900 |
SYNOPSIS: |
| 901 |
static int CheckInitParallel (void); |
| 902 |
|
| 903 |
PARAMETERS: |
| 904 |
. void |
| 905 |
|
| 906 |
DESCRIPTION: |
| 907 |
This function performs checks for correct initialization of dddif subsystem |
| 908 |
|
| 909 |
RETURN VALUE: |
| 910 |
int |
| 911 |
error value |
| 912 |
*/ |
| 913 |
/****************************************************************************/ |
| 914 |
|
| 915 |
|
| 916 |
static int CheckInitParallel(const DDD::DDDContext& context) |
| 917 |
{ |
| 918 |
int i; |
| 919 |
|
| 920 |
/* check for valid UGTYPE for given DDD_TYPE */ |
| 921 |
if (OBJT_MAX == MAXOBJECTS) |
| 922 |
{ |
| 923 |
printf("ERROR in InitParallel: OBJT_MAX!=MAXOBJECTS\n"); |
| 924 |
return(__LINE__); |
| 925 |
} |
| 926 |
|
| 927 |
for(i=1; i<MAXDDDTYPES && UGTYPE(context, i)>=0; i++) |
| 928 |
{ |
| 929 |
/* check for valid UGTYPE for given DDD_TYPE */ |
| 930 |
if (UGTYPE(context, i) > OBJT_MAX) |
| 931 |
{ |
| 932 |
printf("ERROR in InitParallel: OBJT=%d > OBJT_MAX=%d\n", |
| 933 |
UGTYPE(context, i), OBJT_MAX); |
| 934 |
return(__LINE__); |
| 935 |
} |
| 936 |
|
| 937 |
/* check for correct mapping and re-mapping */ |
| 938 |
if (DDDTYPE(context, UGTYPE(context, i))!=i) |
| 939 |
{ |
| 940 |
printf("ERROR in InitParallel: invalid type mapping for OBJT=%d\n", |
| 941 |
UGTYPE(context, i)); |
| 942 |
return(__LINE__); |
| 943 |
} |
| 944 |
} |
| 945 |
|
| 946 |
/* no errors */ |
| 947 |
return(0); |
| 948 |
} |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
/****************************************************************************/ |
| 953 |
/* |
| 954 |
InitDDD - initialize the ddd library |
| 955 |
|
| 956 |
SYNOPSIS: |
| 957 |
int InitDDD (int *argc, char ***argv); |
| 958 |
|
| 959 |
PARAMETERS: |
| 960 |
. argc - pointer to number of arguments |
| 961 |
. argv - pointer to list of argument pointers |
| 962 |
|
| 963 |
DESCRIPTION: |
| 964 |
This function initializes the ddd library by defining the ug internal issues: format of handled structs, description of handlers, definition of interfaces |
| 965 |
|
| 966 |
RETURN VALUE: |
| 967 |
int |
| 968 |
*/ |
| 969 |
/****************************************************************************/ |
| 970 |
|
| 971 |
int NS_DIM_PREFIX InitDDD(DDD::DDDContext& context) |
| 972 |
{ |
| 973 |
auto& dddctrl = ddd_ctrl(context); |
| 974 |
|
| 975 |
INT err; |
| 976 |
int i; |
| 977 |
|
| 978 |
/* init DDD and set options */ |
| 979 |
DDD_Init(context); |
| 980 |
|
| 981 |
/* we are using varsized DDD objects, turn warnings off */ |
| 982 |
DDD_SetOption(context, OPT_WARNING_VARSIZE_OBJ, OPT_OFF); |
| 983 |
DDD_SetOption(context, OPT_WARNING_SMALLSIZE, OPT_OFF); |
| 984 |
|
| 985 |
/* no internal free list */ |
| 986 |
DDD_SetOption(context, OPT_CPLMGR_USE_FREELIST, OPT_OFF); |
| 987 |
|
| 988 |
/* show messages during transfer, for debugging */ |
| 989 |
DDD_SetOption(context, OPT_DEBUG_XFERMESGS, OPT_OFF); |
| 990 |
|
| 991 |
/* TODO: remove this, reference collision with Edge orientation |
| 992 |
in 3D */ |
| 993 |
DDD_SetOption(context, OPT_WARNING_REF_COLLISION, OPT_OFF); |
| 994 |
|
| 995 |
/* treat identify tokens for one object as set */ |
| 996 |
DDD_SetOption(context, OPT_IDENTIFY_MODE, IDMODE_SETS); |
| 997 |
|
| 998 |
/* dont delete objects when another copy comes in during Xfer */ |
| 999 |
DDD_SetOption(context, OPT_XFER_PRUNE_DELETE, OPT_ON); |
| 1000 |
|
| 1001 |
/* initialize type mapping arrays */ |
| 1002 |
for(i=0; i<MAXOBJECTS; i++) |
| 1003 |
{ |
| 1004 |
dddctrl.types[i] = -1; |
| 1005 |
dddctrl.dddObj[i] = false; |
| 1006 |
} |
| 1007 |
for(i=0; i<MAXDDDTYPES; i++) |
| 1008 |
{ |
| 1009 |
dddctrl.ugtypes[i] = -1; |
| 1010 |
} |
| 1011 |
|
| 1012 |
/* declare DDD_TYPES, definition must be done later */ |
| 1013 |
ddd_DeclareTypes(context); |
| 1014 |
dddctrl.allTypesDefined = false; |
| 1015 |
|
| 1016 |
DomInitParallel(dddctrl.TypeBndP,dddctrl.TypeBndS); |
| 1017 |
|
| 1018 |
ddd_IfInit(context); |
| 1019 |
|
| 1020 |
/* check for correct initialization */ |
| 1021 |
if ((err=CheckInitParallel(context))!=0) |
| 1022 |
{ |
| 1023 |
SetHiWrd(err,__LINE__); |
| 1024 |
return(err); |
| 1025 |
} |
| 1026 |
|
| 1027 |
return 0; /* no error */ |
| 1028 |
} |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
/****************************************************************************/ |
| 1033 |
/* |
| 1034 |
ExitDDD - exit the parallel application on ddd level |
| 1035 |
|
| 1036 |
SYNOPSIS: |
| 1037 |
int ExitDDD (void); |
| 1038 |
|
| 1039 |
PARAMETERS: |
| 1040 |
. void |
| 1041 |
|
| 1042 |
DESCRIPTION: |
| 1043 |
This function exits the parallel application on ddd level |
| 1044 |
|
| 1045 |
RETURN |
| 1046 |
N VALUE: |
| 1047 |
void |
| 1048 |
*/ |
| 1049 |
/****************************************************************************/ |
| 1050 |
|
| 1051 |
int NS_DIM_PREFIX ExitDDD(DDD::DDDContext& context) |
| 1052 |
{ |
| 1053 |
DDD_Exit(context); |
| 1054 |
|
| 1055 |
return 0; /* no error */ |
| 1056 |
} |
| 1057 |
|
| 1058 |
#endif /* ModelP */ |