1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // vi: set et ts=4 sw=2 sts=2: 3 #ifndef UG_STD_INTERNAL_H 4 #define UG_STD_INTERNAL_H 5 6 #include <dune/uggrid/low/dimension.h> 7 #include <dune/uggrid/low/namespace.h> 8 9 #include "domain.h" 10 #include "std_domain.h" 11 12 START_UGDIM_NAMESPACE 13 14 /****************************************************************************/ 15 /* */ 16 /* defines in the following order */ 17 /* */ 18 /* compile time constants defining static data size (i.e. arrays) */ 19 /* other constants */ 20 /* macros */ 21 /* */ 22 /****************************************************************************/ 23 24 typedef DOUBLE COORD_BND_VECTOR[DIM_OF_BND]; 25 26 enum PatchType {POINT_PATCH_TYPE, 27 #ifdef __THREEDIM__ 28 LINE_PATCH_TYPE, 29 #endif 30 LINEAR_PATCH_TYPE, 31 PARAMETRIC_PATCH_TYPE}; 32 33 /** @name Macros for DOMAIN_PART_INFO */ 34 /*@{*/ 35 #define DPI_SD2P_PTR(p) ((p)->sd2part) 36 #define DPI_SD2P(p,sd) ((p)->sd2part[sd]) 37 #define DPI_SG2P_PTR(p) ((p)->sg2part) 38 #define DPI_SG2P(p,sg) ((p)->sg2part[sg]) 39 #define DPI_LN2P_PTR(p) ((p)->ln2part) 40 #define DPI_LN2P(p,c0,c1) ((p)->ln2part[c0][c1]) 41 #define DPI_PT2P_PTR(p) ((p)->pt2part) 42 #define DPI_PT2P(p,pt) ((p)->pt2part[pt]) 43 /*@}*/ 44 45 /** @name Macros for DOMAIN */ 46 /*@{*/ 47 #define DOMAIN_NSEGMENT(p) ((p)->numOfSegments) 48 #define DOMAIN_NCORNER(p) ((p)->numOfCorners) 49 #define DOMAIN_NPARTS(p) ((p)->nParts) 50 #define DOMAIN_PARTINFO(p) ((p)->dpi) 51 /*@}*/ 52 53 /** @name Macros for STD_BVP */ 54 /*@{*/ 55 #define STD_BVP_DOMAIN(p) ((p)->Domain) 56 57 #define STD_BVP_NSIDES(p) ((p)->nsides) 58 #define STD_BVP_SIDEOFFSET(p) ((p)->sideoffset) 59 #define STD_BVP_PATCH(p,i) ((p)->patches[i]) 60 61 #define STD_BVP_NSUBDOM(p) ((p)->numOfSubdomains) 62 #define STD_BVP_NDOMPART(p) ((p)->nDomainParts) 63 #define STD_BVP_S2P_PTR(p) ((p)->s2p) 64 #define STD_BVP_S2P(p,s) ((p)->s2p[s]) 65 66 #define GetSTD_BVP(p) ((STD_BVP *)(p)) 67 /*@}*/ 68 69 /****************************************************************************/ 70 /* */ 71 /* macros for patches */ 72 /* */ 73 /****************************************************************************/ 74 75 /** @name Macros for patches */ 76 /*@{*/ 77 enum {PATCH_FIXED, 78 PATCH_BND_OF_FREE, 79 PATCH_FREE}; 80 81 #define PATCH_TYPE(p) (p)->ge.type 82 #define PATCH_STATE(p) (p)->ge.state 83 #define PATCH_IS_FREE(p) ((p)->ge.state==PATCH_FREE) 84 #define PATCH_IS_FIXED(p) ((p)->ge.state==PATCH_FIXED) 85 #define PATCH_ID(p) (p)->ge.id 86 #define POINT_PATCH_N(p) (p)->po.npatches 87 #define POINT_PATCH_PID(p,i) (p)->po.pop[i].patch_id 88 #define POINT_PATCH_CID(p,i) (p)->po.pop[i].corner_id 89 #define LINE_PATCH_C0(p) ((p)->li.c0) 90 #define LINE_PATCH_C1(p) ((p)->li.c1) 91 #define LINE_PATCH_N(p) (p)->li.npatches 92 #define LINE_PATCH_PID(p,i) (p)->li.lop[i].patch_id 93 #define LINE_PATCH_CID0(p,i) (p)->li.lop[i].corner_id[0] 94 #define LINE_PATCH_CID1(p,i) (p)->li.lop[i].corner_id[1] 95 #define PARAM_PATCH_LEFT(p) (p)->pa.left 96 #define PARAM_PATCH_RIGHT(p) (p)->pa.right 97 #define PARAM_PATCH_POINTS(p,i) (p)->pa.points[i] 98 #define PARAM_PATCH_RANGE(p) (p)->pa.range 99 #define PARAM_PATCH_BS(p) (p)->pa.BndSegFunc 100 #define PARAM_PATCH_BSD(p) (p)->pa.bs_data 101 #define PARAM_PATCH_BC(p) (p)->pa.BndCond 102 #define PARAM_PATCH_BCD(p) (p)->pa.bc_data 103 #define LINEAR_PATCH_LEFT(p) (p)->lp.left 104 #define LINEAR_PATCH_RIGHT(p) (p)->lp.right 105 #define LINEAR_PATCH_N(p) (p)->lp.corners 106 #define LINEAR_PATCH_POINTS(p,i) (p)->lp.points[i] 107 #define LINEAR_PATCH_POS(p,i) (p)->lp.pos[i] 108 109 #define BND_PATCH_ID(p) (((BND_PS *)p)->patch_id) 110 #define BND_DATA(p) (((BND_PS *)p)->data) 111 #define BND_N(p) (((BND_PS *)p)->n) 112 #define BND_LOCAL(p,i) (((BND_PS *)p)->local[i]) 113 #define BND_SIZE(p) ((((BND_PS *)p)->n-1)*sizeof(COORD_BND_VECTOR)+sizeof(BND_PS)) 114 #define M_BNDS_NSIZE(n) (((n)-1)*sizeof(M_BNDP)+sizeof(M_BNDS)) 115 #define M_BNDS_SIZE(p) M_BNDS_NSIZE(((M_BNDS *)(p))->n) 116 117 /*@}*/ 118 119 /****************************************************************************/ 120 /* */ 121 /* data structures exported by the corresponding source file */ 122 /* */ 123 /****************************************************************************/ 124 125 /****************************************************************************/ 126 /* */ 127 /* domain definition data structures */ 128 /* */ 129 /****************************************************************************/ 130 131 132 /*----------- definition of structs ----------------------------------------*/ 133 134 135 /** \brief Data type describing a domain. */ 136 struct domain { 137 138 /** \brief Fields for environment directory */ 139 NS_PREFIX ENVDIR d; 140 141 /** \brief Number of boundary segments */ 142 INT numOfSegments; 143 144 /** \brief Number of corner points */ 145 INT numOfCorners; 146 147 /** @name Description of domain parts */ 148 /*@{*/ 149 150 /** \brief Number of parts in the domain */ 151 INT nParts; 152 153 /** \brief Domain part info */ 154 const DOMAIN_PART_INFO *dpi; 155 /*@}*/ 156 }; 157 158 /** \brief Data structure defining part of the boundary of a domain */ 159 struct boundary_segment { 160 161 /** \brief Field for environment directory */ 162 NS_PREFIX ENVVAR v; 163 164 /** @name Fields for boundary segment */ 165 /*@{*/ 166 /** \brief Number of left and right subdomain */ 167 INT left,right; 168 169 /** \brief Unique id of that segment */ 170 INT id; 171 172 /** \brief Segment type, see above 173 * 174 * \todo See where???*/ 175 INT segType; 176 177 /** \brief Numbers of the vertices (ID) */ 178 INT points[CORNERS_OF_BND_SEG]; 179 180 /** \brief Parameter interval used*/ 181 DOUBLE alpha[DIM_OF_BND],beta[DIM_OF_BND]; 182 183 /** \brief Pointer to definition function */ 184 BndSegFuncPtr BndSegFunc; 185 186 /** \brief Can be used by application to find data */ 187 void *data; 188 /*@}*/ 189 }; 190 191 /** \brief ??? 192 * 193 * \todo Please doc me! 194 */ 195 struct linear_segment { 196 197 /** \brief Field for environment directory */ 198 NS_PREFIX ENVVAR v; 199 200 /* fields for boundary segment */ 201 /** \brief Number of left and right subdomain */ 202 INT left,right; 203 204 /** \brief Unique id of that segment */ 205 INT id; 206 207 /** \brief Number of corners */ 208 INT n; 209 210 /** \brief Numbers of the vertices (ID)*/ 211 INT points[CORNERS_OF_BND_SEG]; 212 213 /** \brief Coordinates */ 214 DOUBLE x[CORNERS_OF_BND_SEG][DIM]; 215 }; 216 217 /****************************************************************************/ 218 /* */ 219 /* problem data structure */ 220 /* */ 221 /****************************************************************************/ 222 223 /*----------- definition of structs ----------------------------------------*/ 224 225 /** \brief Data type describing a problem. */ 226 struct problem { 227 228 /** \brief Field for environment directory 229 * 230 * The problem is an environment directory. This directory is a subdirectory 231 * of the domain where this problem corresponds to. d also contains the 232 * name of the problem. 233 */ 234 NS_PREFIX ENVDIR d; 235 236 /* fields for problem */ 237 /** \brief Used to identify problem type 238 * 239 * Problem class identification number. This number is used to determine 240 * that the problem description coincides with the pde solved by the 241 * problem class library. 242 */ 243 INT problemID; 244 245 /** \brief Procedure to reinitialize problem 246 * 247 * Pointer to a user definable function that is executed when the reinit 248 * command is given in the UG shell. 249 */ 250 ConfigProcPtr ConfigProblem; 251 252 /** \brief Number of coefficient functions 253 * 254 * User definable coefficient functions come in two flavours. 255 * They are either of type CoeffProcPtr or of type UserProcPtr. 256 * numOfCoeffFct and numOfUserFct give the number of functions of each type that 257 * make up the problem description. 258 */ 259 INT numOfCoeffFct; 260 261 /** \brief Number of User functions 262 * 263 * User definable coefficient functions come in two flavours. 264 * They are either of type CoeffProcPtr or of type UserProcPtr. 265 * numOfCoeffFct and numOfUserFct give the number of functions of each type that 266 * make up the problem description. 267 */ 268 INT numOfUserFct; 269 270 /** \brief Coefficient functions 271 * 272 * Array that stores the pointers to coefficient and user functions. 273 * Since access to this array is provided through macros (see below) the layout 274 * is not important. Note that this array is allocated dynamically to the desired length. 275 */ 276 void *CU_ProcPtr[1]; 277 }; 278 279 /** \brief ??? 280 * 281 * \todo Please doc me! 282 */ 283 struct bndcond { 284 285 /** \brief Field for environment variable */ 286 NS_PREFIX ENVVAR v; 287 288 /* fields for boundary condition */ 289 /** \brief Corresponds to boundary segment id ! */ 290 INT id; 291 292 /** \brief Function defining boundary condition */ 293 BndCondProcPtr BndCond; 294 295 /** \brief Additional data for bnd cond */ 296 void *data; 297 }; 298 299 /****************************************************************************/ 300 /* */ 301 /* BoundaryValueProblem data structure */ 302 /* */ 303 /****************************************************************************/ 304 /** \brief ??? 305 * 306 * \todo Please doc me! 307 */ 308 struct std_BoundaryValueProblem 309 { 310 /** \brief Fields for environment directory */ 311 NS_PREFIX ENVDIR d; 312 313 /** \brief Domain pointer */ 314 struct domain *Domain; 315 316 /** \brief Problem pointer */ 317 struct problem *Problem; 318 319 /** \brief File name for boundary infos */ 320 char bnd_file[NS_PREFIX NAMESIZE]; 321 322 /** \brief File name for meshinfos */ 323 char mesh_file[NS_PREFIX NAMESIZE]; 324 325 /** @name Domain part */ 326 /*@{*/ 327 /** \brief Number of subdomains, exterior not counted */ 328 INT numOfSubdomains; 329 330 /** \brief Number of parts in the domain */ 331 INT nDomainParts; 332 333 /** \brief Pointer to table subbdom --> part */ 334 INT *s2p; 335 /*@}*/ 336 337 /** @name Boundary decription */ 338 /*@{*/ 339 INT ncorners; 340 INT nsides; 341 INT sideoffset; 342 343 /** \brief list of patches */ 344 union patch **patches; 345 /*@}*/ 346 347 /** @name Problem part */ 348 /*@{*/ 349 /** \brief Configuration function */ 350 ConfigProcPtr ConfigProc; 351 352 /** \brief Number of coefficient functions */ 353 INT numOfCoeffFct; 354 355 /** \brief Number of user functions */ 356 INT numOfUserFct; 357 358 /** \brief General bnd. cond. (if exists) */ 359 BndCondProcPtr GeneralBndCond; 360 361 /** \brief Coefficient functions */ 362 void *CU_ProcPtr[1]; 363 /*@}*/ 364 }; 365 366 /****************************************************************************/ 367 /* */ 368 /* Patch data structure */ 369 /* */ 370 /****************************************************************************/ 371 /** \brief ??? 372 * 373 * \todo Please doc me! 374 */ 375 struct generic_patch { 376 377 378 /** \brief Patch type */ 379 enum PatchType type; 380 381 /** \brief Fixed/bnd of free/free */ 382 INT state; 383 384 /** \brief Unique id used for load/store */ 385 INT id; 386 }; 387 388 /** \brief ??? 389 * 390 * \todo Please doc me! 391 */ 392 struct point_on_patch { 393 394 INT patch_id; 395 INT corner_id; 396 }; 397 /** \brief ??? 398 * 399 * \todo Please doc me! 400 */ 401 struct point_patch { 402 403 /** \brief Patch type */ 404 enum PatchType type; 405 406 /** \brief Fixed/bnd of free/free */ 407 INT state; 408 409 /** \brief Unique id used for load/store */ 410 INT id; 411 412 /** \brief Number of patches */ 413 INT npatches; 414 415 /** \brief Reference to surface */ 416 struct point_on_patch pop[1]; 417 }; 418 419 #ifdef __THREEDIM__ 420 /** \brief ??? 421 * 422 * \todo Please doc me! 423 */ 424 struct line_on_patch { 425 426 INT patch_id; 427 INT corner_id[2]; 428 }; 429 /** \brief ??? 430 * 431 * \todo Please doc me! 432 */ 433 struct line_patch { 434 435 /** \brief Patch type */ 436 enum PatchType type; 437 438 /** \brief Fixed/bnd of free/free */ 439 INT state; 440 441 /** \brief Unique id used for load/store */ 442 INT id; 443 444 /** \brief Number of patches */ 445 INT npatches; 446 447 /** \brief Corner 0 of line */ 448 INT c0; 449 450 /** \brief Corner 1 of line */ 451 INT c1; 452 453 /** \brief Reference to surface */ 454 struct line_on_patch lop[1]; 455 }; 456 #endif 457 /** \brief ??? 458 * 459 * \todo Please doc me! 460 */ 461 struct linear_patch { 462 463 /** \brief Patch type */ 464 enum PatchType type; 465 466 /** \brief Fixed/bnd of free/free */ 467 INT state; 468 469 /** \brief Unique id used for load/store */ 470 INT id; 471 472 /** \brief Id of left and right subdomain */ 473 INT left,right; 474 475 /** \brief Number of corners */ 476 INT corners; 477 478 /** \brief Ids of points */ 479 INT points[CORNERS_OF_BND_SEG]; 480 481 /** \brief Position */ 482 DOUBLE pos[CORNERS_OF_BND_SEG][DIM]; 483 }; 484 /** \brief ??? 485 * 486 * \todo Please doc me! 487 */ 488 struct parameter_patch { 489 490 /** \brief Patch type */ 491 enum PatchType type; 492 493 /** \brief Fixed/bnd of free/free */ 494 INT state; 495 496 /** \brief Unique id used for load/store */ 497 INT id; 498 499 /** \brief Id of left and right subdomain */ 500 INT left,right; 501 502 /** \brief Ids of points */ 503 INT points[CORNERS_OF_BND_SEG]; 504 505 /** \brief Parameter range */ 506 DOUBLE range[2][DIM_OF_BND]; 507 508 /** \brief Pointer to definition function */ 509 BndSegFuncPtr BndSegFunc; 510 511 /** \brief Can be used by applic to find data */ 512 void *bs_data; 513 514 /** @name Fields for boundary condition */ 515 /*@{*/ 516 /** \brief Function defining boundary condition */ 517 BndCondProcPtr BndCond; 518 519 /** \brief Additional data for bnd cond */ 520 void *bc_data; 521 /*@}*/ 522 }; 523 524 /** \brief ??? 525 * 526 * \todo Please doc me! 527 */ 528 union patch { 529 struct generic_patch ge; 530 struct point_patch po; 531 struct linear_patch lp; 532 struct parameter_patch pa; 533 #ifdef __THREEDIM__ 534 struct line_patch li; 535 #endif 536 } ; 537 538 /** \brief ??? 539 * 540 * \todo Please doc me! 541 */ 542 struct bnd_ps { 543 544 /** \brief Associated patch */ 545 INT patch_id; 546 547 /** \brief E.g. global coordinates, pointers... */ 548 void *data; 549 550 /** \brief Number of arguments */ 551 INT n; 552 553 /** \brief Parameter range */ 554 COORD_BND_VECTOR local[1]; 555 }; 556 557 /*----------- typedef for structs ------------------------------------------*/ 558 559 /* typedefs */ 560 #undef DOMAIN 561 typedef struct domain DOMAIN; 562 typedef struct linear_segment LINEAR_SEGMENT; 563 typedef struct boundary_segment BOUNDARY_SEGMENT; 564 typedef struct problem PROBLEM; 565 typedef struct bndcond BOUNDARY_CONDITION; 566 567 typedef struct std_BoundaryValueProblem STD_BVP; 568 typedef union patch PATCH; 569 typedef struct point_patch POINT_PATCH; 570 typedef struct line_patch LINE_PATCH; 571 typedef struct linear_patch LINEAR_PATCH; 572 typedef struct parameter_patch PARAMETER_PATCH; 573 typedef struct bnd_ps BND_PS; 574 575 /****************************************************************************/ 576 /* */ 577 /* definition of exported global variables */ 578 /* */ 579 /****************************************************************************/ 580 581 /****************************************************************************/ 582 /* */ 583 /* function declarations */ 584 /* */ 585 /****************************************************************************/ 586 587 DOMAIN *GetDomain (const char *name); 588 589 END_UGDIM_NAMESPACE 590 591 #endif 592