/usr/include/ug/shapes.h is in libdune-uggrid-dev 2.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | /*! \file shapes.h
* \ingroup gm
*/
/****************************************************************************/
/* */
/* File: shapes.h */
/* */
/* Purpose: header file for shape functions */
/* */
/* Author: Klaus Johannsen */
/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */
/* Universitaet Heidelberg */
/* Im Neuenheimer Feld 368 */
/* 6900 Heidelberg */
/* internet: ug@ica3.uni-stuttgart.de */
/* */
/* History: 28.11.95 begin, ug version 3.1 */
/* */
/* Remarks: */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* auto include mechanism and other include files */
/* */
/****************************************************************************/
#ifndef __SHAPES__
#define __SHAPES__
#include "gm.h"
#include "evm.h"
#include "namespace.h"
START_UGDIM_NAMESPACE
/****************************************************************************/
/* */
/* defines in the following order */
/* */
/* compile time constants defining static data size (i.e. arrays) */
/* other constants */
/* macros */
/* */
/****************************************************************************/
#ifdef __TWODIM__
#define DNDS(n,i,s,t,r) if (n==3)\
{\
switch (i)\
{\
case 0 : r=-1.0; break;\
case 1 : r=1.0; break;\
case 2 : r=0.0; break;\
}\
}\
else if (n==4)\
{\
switch (i)\
{\
case 0 : r=t-1; break;\
case 1 : r=1-t; break;\
case 2 : r=t; break;\
case 3 : r=-t; break;\
}\
}
#define DNDT(n,i,s,t,r) if (n==3)\
{\
switch (i)\
{\
case 0 : r=-1; break;\
case 1 : r=0; break;\
case 2 : r=1; break;\
}\
}\
else if (n==4)\
{\
switch (i)\
{\
case 0 : r=s-1; break;\
case 1 : r=-s; break;\
case 2 : r=s; break;\
case 3 : r=1-s; break;\
}\
}
#define CORNER_COORDINATES_TRIANGLE(e,n,x) \
{(n)=3; \
(x)[0]=CVECT(MYVERTEX(CORNER((e),0))); \
(x)[1]=CVECT(MYVERTEX(CORNER((e),1))); \
(x)[2]=CVECT(MYVERTEX(CORNER((e),2)));}
#define COPY_COORDINATES_TRIANGLE(e,n,x) \
{DOUBLE *cvect; \
(n) = 3; \
cvect=CVECT(MYVERTEX(CORNER((e),0))); \
V_DIM_COPY(cvect,x[0]); \
cvect=CVECT(MYVERTEX(CORNER((e),1))); \
V_DIM_COPY(cvect,x[1]); \
cvect=CVECT(MYVERTEX(CORNER((e),2))); \
V_DIM_COPY(cvect,x[2]); }
#define CORNER_COORDINATES_QUADRILATERAL(e,n,x) \
{(n)=4; \
(x)[0]=CVECT(MYVERTEX(CORNER((e),0))); \
(x)[1]=CVECT(MYVERTEX(CORNER((e),1))); \
(x)[2]=CVECT(MYVERTEX(CORNER((e),2))); \
(x)[3]=CVECT(MYVERTEX(CORNER((e),3)));}
#define COPY_COORDINATES_QUADRILATERAL(e,n,x) \
{DOUBLE *cvect; \
(n) = 4; \
cvect=CVECT(MYVERTEX(CORNER((e),0))); \
V_DIM_COPY(cvect,x[0]); \
cvect=CVECT(MYVERTEX(CORNER((e),1))); \
V_DIM_COPY(cvect,x[1]); \
cvect=CVECT(MYVERTEX(CORNER((e),2))); \
V_DIM_COPY(cvect,x[2]); \
cvect=CVECT(MYVERTEX(CORNER((e),3))); \
V_DIM_COPY(cvect,x[3]); }
#define CORNER_COORDINATES(e,n,x) \
{if (TAG((e))==TRIANGLE) \
CORNER_COORDINATES_TRIANGLE((e),(n),(x)) \
else CORNER_COORDINATES_QUADRILATERAL((e),(n),(x))}
#define COPY_CORNER_COORDINATES(e,n,x) \
{if (TAG((e))==TRIANGLE) \
COPY_COORDINATES_TRIANGLE((e),(n),(x)) \
else if (TAG((e))==QUADRILATERAL) \
COPY_COORDINATES_QUADRILATERAL((e),(n),(x))}
#endif /* __TWODIM__ */
#define LOCAL_TO_GLOBAL_TRIANGLE(x,local,global) \
{(global)[0] = (1.0-(local)[0]-(local)[1])*(x)[0][0] \
+(local)[0]*(x)[1][0] + (local)[1]*(x)[2][0]; \
(global)[1] = (1.0-(local)[0]-(local)[1])*(x)[0][1] \
+(local)[0]*(x)[1][1] + (local)[1]*(x)[2][1]; }
#define LOCAL_TO_GLOBAL_QUADRILATERAL(x,local,global) \
{(global)[0] = (1.0-(local)[0])*(1.0-(local)[1])*(x)[0][0] \
+ (local)[0]*(1.0-(local)[1])*(x)[1][0] \
+ (local)[0]*(local)[1]*(x)[2][0] \
+ (1.0-(local)[0])*(local)[1]*(x)[3][0]; \
(global)[1] = (1.0-(local)[0])*(1.0-(local)[1])*(x)[0][1] \
+ (local)[0]*(1.0-(local)[1])*(x)[1][1] \
+ (local)[0]*(local)[1]*(x)[2][1] \
+ (1.0-(local)[0])*(local)[1]*(x)[3][1];}
#define LOCAL_TO_GLOBAL_2D(n,x,local,global) \
{if ((n) == 3) LOCAL_TO_GLOBAL_TRIANGLE((x),(local),(global)) \
else if ((n) == 4) LOCAL_TO_GLOBAL_QUADRILATERAL((x),(local),(global))}
#define AREA_OF_TRIANGLE(x,area) {DOUBLE detJ; DOUBLE_VECTOR a,b; \
V2_SUBTRACT((x)[1],(x)[0],a); \
V2_SUBTRACT((x)[2],(x)[0],b); \
V2_VECTOR_PRODUCT(a,b,detJ); \
(area) = ABS(detJ) * 0.5;}
#define AREA_OF_QUADRILATERAL(x,area) {DOUBLE detJ,ar; DOUBLE_VECTOR a,b; \
V2_SUBTRACT((x)[1],(x)[0],a); \
V2_SUBTRACT((x)[2],(x)[0],b); \
V2_VECTOR_PRODUCT(a,b,detJ); \
ar = ABS(detJ) * 0.5; \
V2_SUBTRACT((x)[3],(x)[0],a); \
V2_VECTOR_PRODUCT(a,b,detJ); \
(area) = ABS(detJ) * 0.5 + ar;}
#define AREA_OF_ELEMENT_2D(n,x,area) \
{if ((n) == 3) AREA_OF_TRIANGLE((x),(area)) \
else if ((n) == 4) AREA_OF_QUADRILATERAL((x),(area)) }
#define AREA_OF_REF_2D(n,area) { if ( (n) == 3) (area) = 0.5; \
else if ( (n) == 4) (area) = 1.0; }
#define TRANSFORMATION_OF_TRIANGLE(x,M) \
{ V2_SUBTRACT((x)[1],(x)[0],(M)[0]); \
V2_SUBTRACT((x)[2],(x)[0],(M)[1]); }
#define TRANSFORMATION_OF_QUADRILATERAL(x,local,M) \
{ DOUBLE a; \
a = 1.0 - (local)[1]; \
(M)[0][0] = a*((x)[1][0]-x[0][0])+(local)[1]*((x)[2][0]-(x)[3][0]); \
(M)[0][1] = a*((x)[1][1]-x[0][1])+(local)[1]*((x)[2][1]-(x)[3][1]); \
a = 1.0 - (local)[0]; \
(M)[1][0] = a*((x)[3][0]-x[0][0])+(local)[0]*((x)[2][0]-(x)[1][0]); \
(M)[1][1] = a*((x)[3][1]-x[0][1])+(local)[0]*((x)[2][1]-(x)[1][1]); }
#define TRANSFORMATION_2D(n,x,local,M) \
{if ((n) == 3) {TRANSFORMATION_OF_TRIANGLE((x),(M));} \
else TRANSFORMATION_OF_QUADRILATERAL((x),(local),(M)); }
#define SIDE_NORMAL_2D(n,i,x,normal) \
{ DOUBLE s; DOUBLE_VECTOR y; \
V2_SUBTRACT(x[(i+1)%n],x[i],y); \
V2_EUKLIDNORM(y,s); \
V2_SCALE(1.0/s,y); \
V2_SUBTRACT(x[(i+1)%n],x[(i+2)%n],normal); \
V2_SCALAR_PRODUCT(normal,y,s); \
V2_LINCOMB(1.0,normal,-s,y,normal); \
V2_EUKLIDNORM(normal,s); \
V2_SCALE(1.0/s,normal);}
#ifdef __THREEDIM__
#define CORNER_COORDINATES_TETRAHEDRON(e,n,x) \
{(n) = 4; \
(x)[0]=CVECT(MYVERTEX(CORNER((e),0))); \
(x)[1]=CVECT(MYVERTEX(CORNER((e),1))); \
(x)[2]=CVECT(MYVERTEX(CORNER((e),2))); \
(x)[3]=CVECT(MYVERTEX(CORNER((e),3)));}
#define COPY_COORDINATES_TETRAHEDRON(e,n,x) \
{DOUBLE *cvect; \
(n) = 4; \
cvect=CVECT(MYVERTEX(CORNER((e),0))); \
V_DIM_COPY(cvect,x[0]); \
cvect=CVECT(MYVERTEX(CORNER((e),1))); \
V_DIM_COPY(cvect,x[1]); \
cvect=CVECT(MYVERTEX(CORNER((e),2))); \
V_DIM_COPY(cvect,x[2]); \
cvect=CVECT(MYVERTEX(CORNER((e),3))); \
V_DIM_COPY(cvect,x[3]); }
#define CORNER_COORDINATES_PYRAMID(e,n,x) \
{(n) = 5; \
(x)[0]=CVECT(MYVERTEX(CORNER((e),0))); \
(x)[1]=CVECT(MYVERTEX(CORNER((e),1))); \
(x)[2]=CVECT(MYVERTEX(CORNER((e),2))); \
(x)[3]=CVECT(MYVERTEX(CORNER((e),3))); \
(x)[4]=CVECT(MYVERTEX(CORNER((e),4)));}
#define COPY_COORDINATES_PYRAMID(e,n,x) \
{DOUBLE *cvect; \
(n) = 5; \
cvect=CVECT(MYVERTEX(CORNER((e),0))); \
V_DIM_COPY(cvect,x[0]); \
cvect=CVECT(MYVERTEX(CORNER((e),1))); \
V_DIM_COPY(cvect,x[1]); \
cvect=CVECT(MYVERTEX(CORNER((e),2))); \
V_DIM_COPY(cvect,x[2]); \
cvect=CVECT(MYVERTEX(CORNER((e),3))); \
V_DIM_COPY(cvect,x[3]); \
cvect=CVECT(MYVERTEX(CORNER((e),4))); \
V_DIM_COPY(cvect,x[4]); }
#define CORNER_COORDINATES_PRISM(e,n,x) \
{(n) = 6; \
(x)[0]=CVECT(MYVERTEX(CORNER((e),0))); \
(x)[1]=CVECT(MYVERTEX(CORNER((e),1))); \
(x)[2]=CVECT(MYVERTEX(CORNER((e),2))); \
(x)[3]=CVECT(MYVERTEX(CORNER((e),3))); \
(x)[4]=CVECT(MYVERTEX(CORNER((e),4))); \
(x)[5]=CVECT(MYVERTEX(CORNER((e),5)));}
#define COPY_COORDINATES_PRISM(e,n,x) \
{DOUBLE *cvect; \
(n) = 6; \
cvect=CVECT(MYVERTEX(CORNER((e),0))); \
V_DIM_COPY(cvect,x[0]); \
cvect=CVECT(MYVERTEX(CORNER((e),1))); \
V_DIM_COPY(cvect,x[1]); \
cvect=CVECT(MYVERTEX(CORNER((e),2))); \
V_DIM_COPY(cvect,x[2]); \
cvect=CVECT(MYVERTEX(CORNER((e),3))); \
V_DIM_COPY(cvect,x[3]); \
cvect=CVECT(MYVERTEX(CORNER((e),4))); \
V_DIM_COPY(cvect,x[4]); \
cvect=CVECT(MYVERTEX(CORNER((e),5))); \
V_DIM_COPY(cvect,x[5]); }
#define CORNER_COORDINATES_HEXAHEDRON(e,n,x) \
{(n) = 8; \
(x)[0]=CVECT(MYVERTEX(CORNER((e),0))); \
(x)[1]=CVECT(MYVERTEX(CORNER((e),1))); \
(x)[2]=CVECT(MYVERTEX(CORNER((e),2))); \
(x)[3]=CVECT(MYVERTEX(CORNER((e),3))); \
(x)[4]=CVECT(MYVERTEX(CORNER((e),4))); \
(x)[5]=CVECT(MYVERTEX(CORNER((e),5))); \
(x)[6]=CVECT(MYVERTEX(CORNER((e),6))); \
(x)[7]=CVECT(MYVERTEX(CORNER((e),7)));}
#define COPY_COORDINATES_HEXAHEDRON(e,n,x) \
{DOUBLE *cvect; \
(n) = 8; \
cvect=CVECT(MYVERTEX(CORNER((e),0))); \
V_DIM_COPY(cvect,x[0]); \
cvect=CVECT(MYVERTEX(CORNER((e),1))); \
V_DIM_COPY(cvect,x[1]); \
cvect=CVECT(MYVERTEX(CORNER((e),2))); \
V_DIM_COPY(cvect,x[2]); \
cvect=CVECT(MYVERTEX(CORNER((e),3))); \
V_DIM_COPY(cvect,x[3]); \
cvect=CVECT(MYVERTEX(CORNER((e),4))); \
V_DIM_COPY(cvect,x[4]); \
cvect=CVECT(MYVERTEX(CORNER((e),5))); \
V_DIM_COPY(cvect,x[5]); \
cvect=CVECT(MYVERTEX(CORNER((e),6))); \
V_DIM_COPY(cvect,x[6]); \
cvect=CVECT(MYVERTEX(CORNER((e),7))); \
V_DIM_COPY(cvect,x[7]); }
#define CORNER_COORDINATES(e,n,x) \
{if (TAG((e))==TETRAHEDRON) CORNER_COORDINATES_TETRAHEDRON((e),(n),(x))\
else if (TAG((e))==PYRAMID) CORNER_COORDINATES_PYRAMID((e),(n),(x)) \
else if (TAG((e))==PRISM) CORNER_COORDINATES_PRISM((e),(n),(x)) \
else CORNER_COORDINATES_HEXAHEDRON((e),(n),(x))}
#define COPY_CORNER_COORDINATES(e,n,x) \
{if (TAG((e))==TETRAHEDRON) COPY_COORDINATES_TETRAHEDRON((e),(n),(x))\
else if (TAG((e))==PYRAMID) COPY_COORDINATES_PYRAMID((e),(n),(x)) \
else if (TAG((e))==PRISM) COPY_COORDINATES_PRISM((e),(n),(x)) \
else if (TAG((e))==HEXAHEDRON) COPY_COORDINATES_HEXAHEDRON((e),(n),(x))}
#endif /* __THREEDIM__ */
#define LOCAL_TO_GLOBAL_TETRAHEDRON(x,local,global) \
{(global)[0] = (1.0-(local)[0]-(local)[1]-(local)[2])*(x)[0][0] \
+(local)[0]*(x)[1][0] + (local)[1]*(x)[2][0] + (local)[2]*(x)[3][0]; \
(global)[1] = (1.0-(local)[0]-(local)[1]-(local)[2])*(x)[0][1] \
+(local)[0]*(x)[1][1] + (local)[1]*(x)[2][1] + (local)[2]*(x)[3][1]; \
(global)[2] = (1.0-(local)[0]-(local)[1]-(local)[2])*(x)[0][2] \
+(local)[0]*(x)[1][2] + (local)[1]*(x)[2][2] + (local)[2]*(x)[3][2]; }
#define LOCAL_TO_GLOBAL_PYRAMID(x,local,global) \
{DOUBLE a,b,a0,a1,a2,a3; \
a = 1.0 - (local)[0]; \
b = 1.0 - (local)[1]; \
if ((local)[0] > (local)[1]) { \
a0 = a * b - (local)[2] * b; \
a1 = (local)[0] * b - (local)[2]*(local)[1]; \
a2 = (local)[0] * (local)[1] + (local)[2]*(local)[1]; \
a3 = a * (local)[1] - (local)[2] * (local)[1]; \
(global)[0] = \
a0*(x)[0][0]+a1*(x)[1][0]+a2*(x)[2][0]+a3*(x)[3][0]+(local)[2]*(x)[4][0]; \
(global)[1] = \
a0*(x)[0][1]+a1*(x)[1][1]+a2*(x)[2][1]+a3*(x)[3][1]+(local)[2]*(x)[4][1]; \
(global)[2] = \
a0*(x)[0][2]+a1*(x)[1][2]+a2*(x)[2][2]+a3*(x)[3][2]+(local)[2]*(x)[4][2];}\
else { \
a0 = a * b - (local)[2] * a; \
a1 = (local)[0] * b - (local)[2]*(local)[0]; \
a2 = (local)[0] * (local)[1] + (local)[2]*(local)[0]; \
a3 = a * (local)[1] - (local)[2] * (local)[0]; \
(global)[0] = \
a0*(x)[0][0]+a1*(x)[1][0]+a2*(x)[2][0]+a3*(x)[3][0]+(local)[2]*(x)[4][0]; \
(global)[1] = \
a0*(x)[0][1]+a1*(x)[1][1]+a2*(x)[2][1]+a3*(x)[3][1]+(local)[2]*(x)[4][1]; \
(global)[2] = \
a0*(x)[0][2]+a1*(x)[1][2]+a2*(x)[2][2]+a3*(x)[3][2]+(local)[2]*(x)[4][2];}}
#define LOCAL_TO_GLOBAL_PRISM(x,local,global) \
{DOUBLE a,b,a0,a1,a2,a3,a4,a5; \
a = 1.0 - (local)[0] - (local)[1]; \
b = 1.0 - (local)[2]; \
a0 = a * b; \
a1 = (local)[0] * b; \
a2 = (local)[1] * b; \
a3 = a * (local)[2]; \
a4 = (local)[0] * (local)[2]; \
a5 = (local)[1] * (local)[2]; \
(global)[0] = \
a0*(x)[0][0]+a1*(x)[1][0]+a2*(x)[2][0]+a3*(x)[3][0]+ \
a4*(x)[4][0]+a5*(x)[5][0]; \
(global)[1] = \
a0*(x)[0][1]+a1*(x)[1][1]+a2*(x)[2][1]+a3*(x)[3][1]+ \
a4*(x)[4][1]+a5*(x)[5][1]; \
(global)[2] = \
a0*(x)[0][2]+a1*(x)[1][2]+a2*(x)[2][2]+a3*(x)[3][2]+ \
a4*(x)[4][2]+a5*(x)[5][2]; }
#define LOCAL_TO_GLOBAL_HEXAHEDRON(x,local,global) \
{DOUBLE a,b,c,a0,a1,a2,a3,a4,a5,a6,a7; \
a = 1.0 - (local)[0]; \
b = 1.0 - (local)[1]; \
c = 1.0 - (local)[2]; \
a0 = a * b * c; \
a1 = (local)[0] * b * c; \
a2 = (local)[0] * (local)[1] * c; \
a3 = a * (local)[1] * c; \
a4 = a * b * (local)[2]; \
a5 = (local)[0] * b * (local)[2]; \
a6 = (local)[0] * (local)[1] * (local)[2]; \
a7 = a * (local)[1] * (local)[2]; \
(global)[0] = \
a0*(x)[0][0]+a1*(x)[1][0]+a2*(x)[2][0]+a3*(x)[3][0]+ \
a4*(x)[4][0]+a5*(x)[5][0]+a6*(x)[6][0]+a7*(x)[7][0]; \
(global)[1] = \
a0*(x)[0][1]+a1*(x)[1][1]+a2*(x)[2][1]+a3*(x)[3][1]+ \
a4*(x)[4][1]+a5*(x)[5][1]+a6*(x)[6][1]+a7*(x)[7][1]; \
(global)[2] = \
a0*(x)[0][2]+a1*(x)[1][2]+a2*(x)[2][2]+a3*(x)[3][2]+ \
a4*(x)[4][2]+a5*(x)[5][2]+a6*(x)[6][2]+a7*(x)[7][2]; }
#define LOCAL_TO_GLOBAL_3D(n,x,local,global) \
{if ((n) == 4) LOCAL_TO_GLOBAL_TETRAHEDRON((x),(local),(global)) \
else if ((n) == 5) LOCAL_TO_GLOBAL_PYRAMID((x),(local),(global)) \
else if ((n) == 6) LOCAL_TO_GLOBAL_PRISM((x),(local),(global)) \
else if ((n) == 8) LOCAL_TO_GLOBAL_HEXAHEDRON((x),(local),(global))}
#define AREA_OF_TETRAHEDRON(x,area) {DOUBLE detJ; DOUBLE_VECTOR a,b,c; \
V3_SUBTRACT((x)[1],(x)[0],a); \
V3_SUBTRACT((x)[2],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[3],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
(area) = ABS(detJ)/6.0;}
#define AREA_OF_PYRAMID(x,area) {DOUBLE detJ,ar; DOUBLE_VECTOR a,b,c,d;\
V3_SUBTRACT((x)[1],(x)[0],a); \
V3_SUBTRACT((x)[2],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[4],(x)[0],d); \
V3_SCALAR_PRODUCT(c,d,detJ); \
ar = ABS(detJ)/6.0; \
V3_SUBTRACT((x)[3],(x)[0],a); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SCALAR_PRODUCT(c,d,detJ); \
(area) = ABS(detJ)/6.0 + ar;}
#define AREA_OF_PRISM(x,area) {DOUBLE detJ,ar; DOUBLE_VECTOR a,b,c; \
V3_SUBTRACT((x)[1],(x)[0],a); \
V3_SUBTRACT((x)[2],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[3],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar = ABS(detJ)/6.0; \
V3_SUBTRACT((x)[2],(x)[1],a); \
V3_SUBTRACT((x)[3],(x)[1],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[4],(x)[1],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar += ABS(detJ)/6.0; \
V3_SUBTRACT((x)[2],(x)[5],a); \
V3_SUBTRACT((x)[3],(x)[5],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[4],(x)[5],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
(area) = ABS(detJ)/6.0 + ar;}
#define AREA_OF_HEXAHEDRON(x,area) {DOUBLE detJ,ar; DOUBLE_VECTOR a,b,c; \
V3_SUBTRACT((x)[1],(x)[0],a); \
V3_SUBTRACT((x)[2],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[5],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar = ABS(detJ)/6.0; \
V3_SUBTRACT((x)[2],(x)[0],a); \
V3_SUBTRACT((x)[5],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[6],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar += ABS(detJ)/6.0; \
V3_SUBTRACT((x)[4],(x)[0],a); \
V3_SUBTRACT((x)[5],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[6],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar += ABS(detJ)/6.0; \
V3_SUBTRACT((x)[2],(x)[0],a); \
V3_SUBTRACT((x)[3],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[6],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar += ABS(detJ)/6.0; \
V3_SUBTRACT((x)[3],(x)[0],a); \
V3_SUBTRACT((x)[4],(x)[0],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[6],(x)[0],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
ar += ABS(detJ)/6.0; \
V3_SUBTRACT((x)[3],(x)[7],a); \
V3_SUBTRACT((x)[4],(x)[7],b); \
V3_VECTOR_PRODUCT(a,b,c); \
V3_SUBTRACT((x)[6],(x)[7],a); \
V3_SCALAR_PRODUCT(a,c,detJ); \
(area) = ABS(detJ)/6.0 + ar;}
#define AREA_OF_ELEMENT_3D(n,x,area) \
{if ((n) == 4) {AREA_OF_TETRAHEDRON((x),(area));} \
else if ((n) == 5) {AREA_OF_PYRAMID((x),(area));} \
else if ((n) == 6) {AREA_OF_PRISM((x),(area));} \
else if ((n) == 8) {AREA_OF_HEXAHEDRON((x),(area));}}
#define AREA_OF_REF_3D(n,area) { if ( (n) == 4) \
(area) = 0.16666666666666666; \
else if ( (n) == 5) \
(area) = 0.33333333333333333; \
else if ( (n) == 6) \
(area) = 0.5; \
else if ( (n) == 8) \
(area) = 1.0; }
#define TRANSFORMATION_OF_TETRAHEDRON(x,M) \
{ V3_SUBTRACT((x)[1],(x)[0],(M)[0]); \
V3_SUBTRACT((x)[2],(x)[0],(M)[1]); \
V3_SUBTRACT((x)[3],(x)[0],(M)[2]);}
#define TRANSFORMATION_OF_PYRAMID(x,local,M) \
{ DOUBLE a,b,c; \
a = (x)[0][0]-(x)[1][0]+(x)[2][0]-(x)[3][0]; \
b = (x)[0][1]-(x)[1][1]+(x)[2][1]-(x)[3][1]; \
c = (x)[0][2]-(x)[1][2]+(x)[2][2]-(x)[3][2]; \
if ((local)[0] > (local)[1]) { \
(M)[0][0] = (x)[1][0]-(x)[0][0]+(local)[1]*a; \
(M)[0][1] = (x)[1][1]-(x)[0][1]+(local)[1]*b; \
(M)[0][2] = (x)[1][2]-(x)[0][2]+(local)[1]*c; \
(M)[1][0] = (x)[3][0]-(x)[0][0]+((local)[0]+(local)[2])*a; \
(M)[1][1] = (x)[3][1]-(x)[0][1]+((local)[0]+(local)[2])*b; \
(M)[1][2] = (x)[3][2]-(x)[0][2]+((local)[0]+(local)[2])*c; \
(M)[2][0] = (x)[4][0]-(x)[0][0]+(local)[1]*a; \
(M)[2][1] = (x)[4][1]-(x)[0][1]+(local)[1]*b; \
(M)[2][2] = (x)[4][2]-(x)[0][2]+(local)[1]*c;} \
else { \
(M)[0][0] = (x)[1][0]-(x)[0][0]+((local)[1]+(local)[2])*a; \
(M)[0][1] = (x)[1][1]-(x)[0][1]+((local)[1]+(local)[2])*b; \
(M)[0][2] = (x)[1][2]-(x)[0][2]+((local)[1]+(local)[2])*c; \
(M)[1][0] = (x)[3][0]-(x)[0][0]+(local)[0]*a; \
(M)[1][1] = (x)[3][1]-(x)[0][1]+(local)[0]*b; \
(M)[1][2] = (x)[3][2]-(x)[0][2]+(local)[0]*c; \
(M)[2][0] = (x)[4][0]-(x)[0][0]+(local)[0]*a; \
(M)[2][1] = (x)[4][1]-(x)[0][1]+(local)[0]*b; \
(M)[2][2] = (x)[4][2]-(x)[0][2]+(local)[0]*c;} }
#define TRANSFORMATION_OF_PRISM(x,local,M) \
{ DOUBLE a0,a1,a2,b0,b1,b2; \
a0 = (x)[0][0]-(x)[1][0]-(x)[3][0]+(x)[4][0]; \
a1 = (x)[0][1]-(x)[1][1]-(x)[3][1]+(x)[4][1]; \
a2 = (x)[0][2]-(x)[1][2]-(x)[3][2]+(x)[4][2]; \
b0 = (x)[0][0]-(x)[2][0]-(x)[3][0]+(x)[5][0]; \
b1 = (x)[0][1]-(x)[2][1]-(x)[3][1]+(x)[5][1]; \
b2 = (x)[0][2]-(x)[2][2]-(x)[3][2]+(x)[5][2]; \
(M)[0][0] = (x)[1][0]-(x)[0][0]+(local)[2]*a0; \
(M)[0][1] = (x)[1][1]-(x)[0][1]+(local)[2]*a1; \
(M)[0][2] = (x)[1][2]-(x)[0][2]+(local)[2]*a2; \
(M)[1][0] = (x)[2][0]-(x)[0][0]+(local)[2]*b0; \
(M)[1][1] = (x)[2][1]-(x)[0][1]+(local)[2]*b1; \
(M)[1][2] = (x)[2][2]-(x)[0][2]+(local)[2]*b2; \
(M)[2][0] = (x)[3][0]-(x)[0][0]+(local)[0]*a0+(local)[1]*b0; \
(M)[2][1] = (x)[3][1]-(x)[0][1]+(local)[0]*a1+(local)[1]*b1; \
(M)[2][2] = (x)[3][2]-(x)[0][2]+(local)[0]*a2+(local)[1]*b2;}
#define TRANSFORMATION_OF_HEXAHEDRON(x,local,M) \
{ DOUBLE a,b,c,a0,a1,a2,a3; \
a = 1.0 - (local)[0]; \
b = 1.0 - (local)[1]; \
c = 1.0 - (local)[2]; \
a0 = b * c; \
a1 = (local)[1] * c; \
a2 = (local)[1] * (local)[2]; \
a3 = b * (local)[2]; \
(M)[0][0] = a0*((x)[1][0]-x[0][0])+a1*((x)[2][0]-(x)[3][0]) \
+ a2*((x)[6][0]-x[7][0])+a3*((x)[5][0]-(x)[4][0]); \
(M)[0][1] = a0*((x)[1][1]-x[0][1])+a1*((x)[2][1]-(x)[3][1]) \
+ a2*((x)[6][1]-x[7][1])+a3*((x)[5][1]-(x)[4][1]); \
(M)[0][2] = a0*((x)[1][2]-x[0][2])+a1*((x)[2][2]-(x)[3][2]) \
+ a2*((x)[6][2]-x[7][2])+a3*((x)[5][2]-(x)[4][2]); \
a0 = a * c; \
a1 = (local)[0] * c; \
a2 = (local)[0] * (local)[2]; \
a3 = a * (local)[2]; \
(M)[1][0] = a0*((x)[3][0]-x[0][0])+a1*((x)[2][0]-(x)[1][0]) \
+ a2*((x)[6][0]-x[5][0])+a3*((x)[7][0]-(x)[4][0]); \
(M)[1][1] = a0*((x)[3][1]-x[0][1])+a1*((x)[2][1]-(x)[1][1]) \
+ a2*((x)[6][1]-x[5][1])+a3*((x)[7][1]-(x)[4][1]); \
(M)[1][2] = a0*((x)[3][2]-x[0][2])+a1*((x)[2][2]-(x)[1][2]) \
+ a2*((x)[6][2]-x[5][2])+a3*((x)[7][2]-(x)[4][2]); \
a0 = a * b; \
a1 = (local)[0] * b; \
a2 = (local)[0] * (local)[1]; \
a3 = a * (local)[1]; \
(M)[2][0] = a0*((x)[4][0]-x[0][0])+a1*((x)[5][0]-(x)[1][0]) \
+ a2*((x)[6][0]-x[2][0])+a3*((x)[7][0]-(x)[3][0]); \
(M)[2][1] = a0*((x)[4][1]-x[0][1])+a1*((x)[5][1]-(x)[1][1]) \
+ a2*((x)[6][1]-x[2][1])+a3*((x)[7][1]-(x)[3][1]); \
(M)[2][2] = a0*((x)[4][2]-x[0][2])+a1*((x)[5][2]-(x)[1][2]) \
+ a2*((x)[6][2]-x[2][2])+a3*((x)[7][2]-(x)[3][2]); }
#define TRANSFORMATION_3D(n,x,local,M) \
{if ((n) == 4) {TRANSFORMATION_OF_TETRAHEDRON((x),(M));} \
else if ((n) == 5) {TRANSFORMATION_OF_PYRAMID((x),(local),(M));} \
else if ((n) == 6) {TRANSFORMATION_OF_PRISM((x),(local),(M));} \
else TRANSFORMATION_OF_HEXAHEDRON((x),(local),(M));}
#define SIDE_NORMAL_3D(n,i,x,normal) \
{ DOUBLE s; DOUBLE_VECTOR a,b; \
V3_SUBTRACT(x[CORNER_OF_SIDE_REF((n),(i),1)], \
x[CORNER_OF_SIDE_REF((n),(i),0)],a); \
V3_SUBTRACT(x[CORNER_OF_SIDE_REF((n),(i),2)], \
x[CORNER_OF_SIDE_REF((n),(i),0)],b); \
V3_VECTOR_PRODUCT(a,b,(normal)); \
V3_EUKLIDNORM((normal),s); \
V3_SCALE(1.0/s,(normal));}
#ifdef __TWODIM__
#define LOCAL_TO_GLOBAL(n,x,local,global) LOCAL_TO_GLOBAL_2D(n,x,local,global)
#define AREA_OF_ELEMENT(n,x,area) AREA_OF_ELEMENT_2D(n,x,area)
#define AREA_OF_REF(n,area) AREA_OF_REF_2D(n,area)
#define TRANSFORMATION(n,x,local,M) TRANSFORMATION_2D(n,x,local,M)
#define SIDE_NORMAL(n,i,x,normal) SIDE_NORMAL_2D(n,i,x,normal)
#endif /* __TWODIM__ */
#ifdef __THREEDIM__
#define TRANSFORMATION_BND(n,x,local,M) TRANSFORMATION_2D(n,x,local,M)
#define LOCAL_TO_GLOBAL_BND(n,x,local,global) LOCAL_TO_GLOBAL_2D(n,x,local,global)
#define AREA_OF_ELEMENT_BND(n,x,area) AREA_OF_ELEMENT_2D(n,x,area)
#define AREA_OF_REF_BND(n,area) AREA_OF_REF_2D(n,area)
#define LOCAL_TO_GLOBAL(n,x,local,global) LOCAL_TO_GLOBAL_3D(n,x,local,global)
#define AREA_OF_ELEMENT(n,x,area) AREA_OF_ELEMENT_3D(n,x,area)
#define AREA_OF_REF(n,area) AREA_OF_REF_3D(n,area)
#define TRANSFORMATION(n,x,local,M) TRANSFORMATION_3D(n,x,local,M)
#define SIDE_NORMAL(n,i,x,normal) SIDE_NORMAL_3D(n,i,x,normal)
#endif /* __THREEDIM__ */
#define INVERSE_TRANSFORMATION(n,x,local,Jinv,Jdet) \
{ DOUBLE_VECTOR J[DIM]; \
TRANSFORMATION((n),(x),(local),J); \
M_DIM_INVERT(J,(Jinv),(Jdet)); }
/****************************************************************************/
/* */
/* data structures exported by the corresponding source file */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* definition of exported global variables */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* function declarations */
/* */
/****************************************************************************/
DOUBLE GN (INT n, INT i, const DOUBLE *ip_local);
INT GNs (INT n, const DOUBLE *ip_local, DOUBLE *result);
INT DimGNs (INT dim, INT n, const DOUBLE *ip_local, DOUBLE *result);
INT D_GN (INT n, INT i, const DOUBLE *ip_local, DOUBLE *derivative);
DOUBLE *LMP (INT n);
INT UG_GlobalToLocal (INT n, const DOUBLE **Corners, const DOUBLE *EvalPoint, DOUBLE *LocalCoord);
INT UG_GlobalToLocalBnd (INT n, const DOUBLE **Corners,
const DOUBLE *EvalPoint, DOUBLE *LocalCoord);
INT LocalCornerCoordinates (INT dim, INT tag, INT corner, DOUBLE *result);
/*****************************************************************************
* This function delivers the coordinates of the corners in the refernence
* element.
* Parameters are:
* dim space dimension, 2D can be called in 3D
* tag identifies element type, i.e. 3=TRIANGLE, 4=QUADRILATERAL here
* corner number of the corner
* result array to place result
*/
INT InterpolateFEFunction (INT dim, INT tag, DOUBLE ip_local[DIM],
DOUBLE nodal_values[MAX_CORNERS_OF_ELEM], DOUBLE *result);
/*****************************************************************************
* This function interpolates a finite element function given by
* nodal values at some point in the interior of the element. The coordinates
* of this point must be given in local coordinates.
* Parameters are:
* dim space dimension, 2D can be called in 3D
* tag identifies element type, i.e. 3=TRIANGLE, 4=QUADRILATERAL here
* ip_local local coordinates of interpolation point
* nodal_values array of nodal values of function to interpolate
* result pointer where to place result (one DOUBLE value)
*/
INT LinearTrafo (INT dim, INT tag);
/*****************************************************************************
* This function returns true if transformation from reference element
* to an arbitrary element is linear. This can be used to avoid
* recomputation of the Jacobian of the transformation.
* Parameters are:
* dim space dimension, 2D can be called in 3D
* tag identifies element type, i.e. 3=TRIANGLE, 4=QUADRILATERAL here
*/
INT JacobianInverse (INT dim, INT tag, DOUBLE co_global[MAX_CORNERS_OF_ELEM][DIM],
DOUBLE ip_local[DIM], DOUBLE Jinv[DIM][DIM], DOUBLE *detJ);
/*****************************************************************************
* Compute inverse of the jacobian of transformation of reference element
* to some element given by global coordinates of corners. The determinant
* of the jacobian (no its inverse!) is also provided as a result.
* Parameters are:
* dim space dimension, 2D can be called in 3D
* tag identifies element type, i.e. 3=TRIANGLE, 4=QUADRILATERAL here
* co_global global coordinates of the corners of the element
* ip_local local coordinates of interpolation point
* Jinv place to store the inverse of jacobian
* detJ place to store determinant
*/
INT GradientFEFunction (INT dim, INT tag, DOUBLE ip_local[DIM], DOUBLE Jinv[DIM][DIM],
DOUBLE nodal_values[MAX_CORNERS_OF_ELEM], DOUBLE result[DIM]);
/*****************************************************************************
* Compute gradient in global coordinates of some finite element function
* given by nodal values at some point within the element.
* Parameters are:
* dim space dimension, 2D can be called in 3D
* tag identifies element type, i.e. 3=TRIANGLE, 4=QUADRILATERAL here
* ip_local local coordinates of interpolation point
* Jinv inverse of jacobian of transformation computed by fct above
* nodal_values array of nodal values of function to interpolate
* result pointer where to place result (a vector)
*/
INT SurfaceElement (INT dim, INT nc,
const DOUBLE co_global[MAX_CORNERS_OF_ELEM][DIM],
const DOUBLE ip_local[DIM], DOUBLE *result);
#ifdef __TWODIM__
DOUBLE dNds (INT n, INT i, DOUBLE s, DOUBLE t);
DOUBLE dNdt (INT n, INT i, DOUBLE s, DOUBLE t);
INT Derivatives (INT n, const DOUBLE *px, const DOUBLE *py, DOUBLE ips, DOUBLE ipt, DOUBLE *dNdx, DOUBLE *dNdy, DOUBLE *detJ);
INT Gradients (INT n, const DOUBLE **theCorners, DOUBLE ips, DOUBLE ipt, DOUBLE_VECTOR Gradient[MAX_CORNERS_OF_ELEM], DOUBLE *DetJ);
INT L2GDerivative2d (INT n, const DOUBLE **Corners, const DOUBLE_VECTOR EvalPoint, DOUBLE *Derivative);
#endif
#ifdef __THREEDIM__
INT GetSkewedUIP (const DOUBLE_VECTOR *theCorners, const DOUBLE_VECTOR LIP[MAX_EDGES_OF_ELEM], const DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
DOUBLE N (const INT i, const DOUBLE *LocalCoord);
INT TetraDerivative (ELEMENT *theElement, const DOUBLE **theCorners, DOUBLE_VECTOR theGradient[MAX_CORNERS_OF_ELEM]);
INT TetraVolume (const DOUBLE **theCorners, DOUBLE *volume);
INT FV_TetInfo (const DOUBLE **theCorners, DOUBLE_VECTOR Area[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR GIP[MAX_EDGES_OF_ELEM]);
INT Side_TetInfo (DOUBLE **theCorners, INT side, DOUBLE_VECTOR Area, DOUBLE_VECTOR GIP[3]);
INT TetraSideNormals (ELEMENT *theElement, DOUBLE **theCorners, DOUBLE_VECTOR theNormals[MAX_SIDES_OF_ELEM]);
INT TetMaxSideAngle (ELEMENT *theElement, const DOUBLE **theCorners, DOUBLE *MaxAngle);
INT TetAngleAndLength (ELEMENT *theElement, const DOUBLE **theCorners, DOUBLE *Angle, DOUBLE *Length);
INT FV_AliTetInfo (const DOUBLE **CornerPoints, DOUBLE_VECTOR Area[6], DOUBLE_VECTOR conv, DOUBLE_VECTOR GIP[6], DOUBLE_VECTOR LIP[6]);
INT FV_TetInfo_for_conv (ELEMENT *theElement, const DOUBLE **CornerPoints, DOUBLE_VECTOR Area[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR GIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR LUIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv);
INT GFUIP (const DOUBLE **theCorners, const DOUBLE_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
INT GCUIP (const DOUBLE **theCorners, const DOUBLE_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
INT COPYIP (const DOUBLE **theCorners, const DOUBLE_VECTOR LIP[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR conv[MAX_EDGES_OF_ELEM], DOUBLE_VECTOR LUIP[MAX_EDGES_OF_ELEM]);
#endif
END_UGDIM_NAMESPACE
#endif
|