/usr/include/dune/grid/uggrid/ugwrapper.hh is in libdune-grid-dev 2.4.1-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 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/** \file
* \brief Encapsulates some UG macros and functions
*/
/** \todo Here only to provide the constant DBL_EPSILON. There's maybe a better way? */
#include "float.h"
namespace Dune {
/** \brief Encapsulates a few UG methods and macros
*
* This class provides a wrapper to several methods and macros from
* UG. There are two reasons for doing this. First, we don't want
* to call UG macros directly from DUNE, because they pollute the
* namespace and therefore we undefine them all. Secondly, UG methods
* appear in the namespaces UG::D2 and UG::D3, but we need the dimension
* as a template parameter.
*/
#if UG_DIM == 2
template<int dim>
class UG_NS {};
#endif
template<>
class UG_NS< UG_DIM > {
public:
// //////////////////////////////////////////////
// Types exported by UG
// //////////////////////////////////////////////
#if UG_DIM == 2
#define UG_NAMESPACE UG::D2
#else
#define UG_NAMESPACE UG::D3
#endif
enum Priorities {
PrioNone = UG_NAMESPACE::PrioNone,
PrioMaster = UG_NAMESPACE::PrioMaster,
PrioBorder = UG_NAMESPACE::PrioBorder,
PrioHGhost = UG_NAMESPACE::PrioHGhost,
PrioVGhost = UG_NAMESPACE::PrioVGhost,
PrioVHGhost = UG_NAMESPACE::PrioVHGhost
};
typedef UG_NAMESPACE ::RefinementRule RefinementRule;
typedef UG_NAMESPACE ::CoeffProcPtr CoeffProcPtr;
typedef UG_NAMESPACE ::UserProcPtr UserProcPtr;
typedef UG_NAMESPACE ::BndSegFuncPtr BndSegFuncPtr;
/** \brief This is actually a type of the UG algebra, not the grid.
* We need it to implement face indices and ids in 3d, since UG
* doesn't actually have objects for faces in 3d grids. */
typedef UG_NAMESPACE ::vector Vector;
/** \brief UG type for a hierarchical grid */
typedef UG_NAMESPACE ::multigrid MultiGrid;
/** \brief UG type for a level grid */
typedef UG_NAMESPACE ::grid Grid;
typedef UG_NAMESPACE ::edge Edge;
typedef UG_NAMESPACE ::node Node;
typedef UG_NAMESPACE ::element Element;
typedef UG_NAMESPACE ::vertex Vertex;
/** \brief Point on a UG boundary patch */
typedef UG_NAMESPACE ::BNDP BNDP;
/** \brief Types of the subentities parametrized by the codimension. Gets specialized below */
template <int codim>
class Entity;
// Type used for local and global ids
#ifdef ModelP
typedef UG_NAMESPACE::DDD_GID UG_ID_TYPE;
#else
typedef UG::INT UG_ID_TYPE;
#endif
#ifdef ModelP
/* DDD Interfaces */
typedef UG_NAMESPACE::DDD_IF_DIR DDD_IF_DIR;
typedef UG_NAMESPACE::DDD_IF DDD_IF;
typedef UG_NAMESPACE::DDD_OBJ DDD_OBJ;
typedef UG_NAMESPACE::DDD_HEADER DDD_HEADER;
static void DDD_IFOneway(DDD_IF dddIf,
DDD_IF_DIR dddIfDir,
size_t s,
UG_NAMESPACE::ComProcPtr gather,
UG_NAMESPACE::ComProcPtr scatter)
{
UG_NAMESPACE::DDD_IFOneway(dddIf, dddIfDir, s, gather, scatter);
}
static int *DDD_InfoProcList(DDD_HEADER *hdr)
{
return UG_NAMESPACE::DDD_InfoProcList(hdr);
}
static DDD_IF_DIR IF_FORWARD()
{
return UG_NAMESPACE::IF_FORWARD;
}
static DDD_IF_DIR IF_BACKWARD()
{
return UG_NAMESPACE::IF_BACKWARD;
}
/*! Master->HGhost/VHGhost */
static DDD_IF &ElementIF()
{
return UG_NAMESPACE::ElementIF;
}
/*! ElementSymmIF: Master/HGhost/VHGhost */
static DDD_IF &ElementSymmIF()
{
return UG_NAMESPACE::ElementSymmIF;
}
/*! ElementVIF: Master->VGhost/VHGhost */
static DDD_IF &ElementVIF()
{
return UG_NAMESPACE::ElementVIF;
}
/*! ElementSymmVIF: Master/VGhost/VHGhost" */
static DDD_IF &ElementSymmVIF()
{
return UG_NAMESPACE::ElementSymmVIF;
}
/*! Master->VGhost/HGhost/VHGhost */
static DDD_IF &ElementVHIF()
{
return UG_NAMESPACE::ElementVHIF;
}
/*! ElementSymmVHIF: Master/VGhost/HGhost/VHGhost */
static DDD_IF &ElementSymmVHIF()
{
return UG_NAMESPACE::ElementSymmVHIF;
}
/*! BorderNodeIF: Border->Master */
static DDD_IF &BorderNodeIF()
{
return UG_NAMESPACE::BorderNodeIF;
}
/*! BorderNodeSymmIF: Border/Master */
static DDD_IF &BorderNodeSymmIF()
{
return UG_NAMESPACE::BorderNodeSymmIF;
}
/*! OuterNodeIF: Master->HGhost/VGhost */
static DDD_IF &OuterNodeIF()
{
return UG_NAMESPACE::OuterNodeIF;
}
/*! NodeVIF: Master->VGhost/VHGhost */
static DDD_IF &NodeVIF()
{
return UG_NAMESPACE::NodeVIF;
}
/*! NodeIF: Master->VGhost/HGhost/VHGhost */
static DDD_IF &NodeIF()
{
return UG_NAMESPACE::NodeIF;
}
/*! NodeAllIF: All/All */
static DDD_IF &NodeAllIF()
{
return UG_NAMESPACE::NodeAllIF;
}
/*! BorderVectorIF: Border->Master */
static DDD_IF &BorderVectorIF()
{
return UG_NAMESPACE::BorderVectorIF;
}
/*! BorderVectorSymmIF: Master/Border */
static DDD_IF &BorderVectorSymmIF()
{
return UG_NAMESPACE::BorderVectorSymmIF;
}
/*! OuterVectorIF: Master->HGhost/VHGhost */
static DDD_IF &OuterVectorIF()
{
return UG_NAMESPACE::OuterVectorIF;
}
/*! OuterVectorSymmIF: Master/Border/HGhost/VHGhost */
static DDD_IF &OuterVectorSymmIF()
{
return UG_NAMESPACE::OuterVectorSymmIF;
}
/*! VectorVIF: Master->VGhost/VHGhost */
static DDD_IF &VectorVIF()
{
return UG_NAMESPACE::VectorVIF;
}
/*! VectorVAllIF: Master/Border/VGhost/VHGhost->Master/Border */
static DDD_IF &VectorVAllIF()
{
return UG_NAMESPACE::VectorVAllIF;
}
/*! VectorIF: Master->VGhost/VHGhost/HGhost */
static DDD_IF &VectorIF()
{
return UG_NAMESPACE::VectorIF;
}
/*! Master->HGhost/VHGhost */
static DDD_IF &EdgeIF()
{
return UG_NAMESPACE::EdgeIF;
}
/*! EdgeSymmIF: Master/HGhost/VHGhost */
static DDD_IF &BorderEdgeSymmIF()
{
return UG_NAMESPACE::BorderEdgeSymmIF;
}
/*! EdgeHIF: Master/HGhost/VHGhost */
static DDD_IF &EdgeHIF()
{
return UG_NAMESPACE::EdgeHIF;
}
/*! EdgeVHIF: Master->VGhost/HGhost/VHGhost */
static DDD_IF &EdgeVHIF()
{
return UG_NAMESPACE::EdgeVHIF;
}
/*! EdgeSymmVHIF: Master/VGhost/HGhost/VHGhost */
static DDD_IF &EdgeSymmVHIF()
{
return UG_NAMESPACE::EdgeSymmVHIF;
}
/** \brief Encapsulates the UG EPRIO macro */
static int EPriority(const UG_NS< UG_DIM >::Element* element)
{
return EPRIO(element);
}
/** \brief Returns the priority of the side vector */
static int Priority(const UG_NS< UG_DIM >::Vector* side)
{
return PARHDR(side)->prio;
}
/** \brief Returns the priority of the edge (the UG EPRIO macro) */
static int Priority(const UG_NS< UG_DIM >::Edge* edge)
{
return PARHDR(edge)->prio;
}
/** \brief Returns the priority of the node (the UG EPRIO macro) */
static int Priority(const UG_NS< UG_DIM >::Node* node)
{
return PARHDR(node)->prio;
}
static DDD_HEADER* ParHdr(UG_NS< UG_DIM >::Vector *side)
{
return PARHDR(side);
}
static DDD_HEADER* ParHdr(UG_NS< UG_DIM >::Edge *edge)
{
return PARHDR(edge);
}
static DDD_HEADER* ParHdr(UG_NS< UG_DIM >::Node *node)
{
return PARHDR(node);
}
/** \brief This entry tells the UG load balancer what rank this particular element
* is supposed to be sent to.
*/
static UG::INT& Partition(UG_NS< UG_DIM >::Element* element)
{
return PARTITION(element);
}
#endif
// //////////////////////////////////////////////
// Constants exported by UG
// //////////////////////////////////////////////
enum {GM_REFINE_NOT_CLOSED = UG_NAMESPACE ::GM_REFINE_NOT_CLOSED};
enum {GM_COPY_ALL = UG_NAMESPACE ::GM_COPY_ALL};
enum {GM_REFINE_TRULY_LOCAL = UG_NAMESPACE ::GM_REFINE_TRULY_LOCAL};
enum {GM_REFINE_PARALLEL = UG_NAMESPACE ::GM_REFINE_PARALLEL};
enum {GM_REFINE_NOHEAPTEST = UG_NAMESPACE ::GM_REFINE_NOHEAPTEST};
/** \brief Control word entries */
enum {NEWEL_CE = UG_NAMESPACE ::NEWEL_CE,
COARSEN_CE = UG_NAMESPACE ::COARSEN_CE,
ECLASS_CE = UG_NAMESPACE ::ECLASS_CE,
MARK_CE = UG_NAMESPACE ::MARK_CE,
REFINE_CE = UG_NAMESPACE ::REFINE_CE};
/** \brief Refinement rules */
enum {NO_REFINEMENT = UG_NAMESPACE ::NO_REFINEMENT,
RED = UG_NAMESPACE ::RED,
COARSE = UG_NAMESPACE ::COARSE};
enum {RED_CLASS = UG_NAMESPACE ::RED_CLASS};
enum {GM_OK = UG_NAMESPACE ::GM_OK};
enum {MAX_SONS = UG_NAMESPACE ::MAX_SONS};
/** \brief The PFIRSTNODE macro which returns the first node in a
* grid even in a parallel setting.
*/
static UG_NS< UG_DIM >::Node* PFirstNode(const UG_NS< UG_DIM >::Grid* grid) {
using UG_NAMESPACE ::PrioHGhost;
using UG_NAMESPACE ::PrioVGhost;
using UG_NAMESPACE ::PrioVHGhost;
using UG_NAMESPACE ::PrioMaster;
using UG_NAMESPACE ::PrioBorder;
using UG_NAMESPACE ::ELEMENT_LIST;
using UG_NAMESPACE ::NODE_LIST;
return PFIRSTNODE(grid);
}
/** \brief The FIRSTNODE macro which returns the first node in a
* grid even in a parallel setting.
*/
static UG_NS< UG_DIM >::Node* FirstNode(UG_NS< UG_DIM >::Grid* grid) {
using UG_NAMESPACE ::PrioHGhost;
using UG_NAMESPACE ::PrioVGhost;
using UG_NAMESPACE ::PrioVHGhost;
using UG_NAMESPACE ::PrioMaster;
using UG_NAMESPACE ::PrioBorder;
using UG_NAMESPACE ::ELEMENT_LIST;
using UG_NAMESPACE ::NODE_LIST;
return FIRSTNODE(grid);
}
/** \brief The PFIRSTELEMENT macro which returns the first element in a
* grid even in a parallel setting.
*/
static UG_NS< UG_DIM >::Element* PFirstElement(const UG_NS< UG_DIM >::Grid* grid) {
using UG_NAMESPACE ::PrioHGhost;
using UG_NAMESPACE ::PrioVGhost;
using UG_NAMESPACE ::PrioVHGhost;
using UG_NAMESPACE ::PrioMaster;
using UG_NAMESPACE ::PrioBorder;
using UG_NAMESPACE ::ELEMENT_LIST;
using UG_NAMESPACE ::NODE_LIST;
return PFIRSTELEMENT(grid);
}
/** \brief The FIRSTELEMENT macro which returns the first element in a
* grid even in a parallel setting.
*/
static UG_NS< UG_DIM >::Element* FirstElement(UG_NS< UG_DIM >::Grid* grid) {
using UG_NAMESPACE ::PrioHGhost;
using UG_NAMESPACE ::PrioVGhost;
using UG_NAMESPACE ::PrioVHGhost;
using UG_NAMESPACE ::PrioMaster;
using UG_NAMESPACE ::PrioBorder;
using UG_NAMESPACE ::ELEMENT_LIST;
return FIRSTELEMENT(grid);
}
/** \brief Returns pointers to the coordinate arrays of a UG element */
static void Corner_Coordinates(const UG_NS< UG_DIM >::Element* theElement, double* x[]) {
using UG_NAMESPACE ::NODE;
using UG_NAMESPACE ::TRIANGLE;
using UG_NAMESPACE ::QUADRILATERAL;
using UG_NAMESPACE ::TETRAHEDRON;
using UG_NAMESPACE ::PYRAMID;
using UG_NAMESPACE ::PRISM;
using UG_NAMESPACE ::n_offset;
using UG::UINT;
int n DUNE_UNUSED;
CORNER_COORDINATES(theElement, n, x);
}
/** \brief Returns pointers to the coordinate arrays of a UG node */
static void Corner_Coordinates(const UG_NS< UG_DIM >::Node* theNode, double* x[]) {
x[0] = theNode->myvertex->iv.x;
}
/** \brief Returns pointers to the coordinate arrays of a UG edge */
static void Corner_Coordinates(const UG_NS< UG_DIM >::Edge* theEdge, double* x[]) {
x[0] = theEdge->links[0].nbnode->myvertex->iv.x;
x[1] = theEdge->links[1].nbnode->myvertex->iv.x;
}
/** \brief Returns pointers to the coordinate arrays of a UG vector */
static void Corner_Coordinates(const UG_NS< UG_DIM >::Vector* theVector, double* x[]) {
UG_NS< UG_DIM >::Element* center;
unsigned int side;
UG_NS< UG_DIM >::GetElementAndSideFromSideVector(theVector, center, side);
for (int i = 0; i < Corners_Of_Side(center, side); i++)
{
unsigned idxInElem = Corner_Of_Side(center, side, i);
x[i] = Corner(center, idxInElem)->myvertex->iv.x;
}
}
static int GlobalToLocal(int n, const double** cornerCoords,
const double* EvalPoint, double* localCoord) {
if (UG_DIM==2)
// in 2d we can call this only for triangles and quadrilaterals
assert(n==3 or n==4);
else
// in 3d: tetrahedra, pyramids, prisms, hexahedra
assert(n==4 or n==5 or n==6 or n==8);
return UG_NAMESPACE ::UG_GlobalToLocal(n, cornerCoords, EvalPoint, localCoord);
}
/** \brief Computes the element volume */
static double Area_Of_Element(int n, const double** cornerCoords) {
double area = 0.0;
using UG::DOUBLE;
using UG_NAMESPACE ::DOUBLE_VECTOR;
#if UG_DIM == 2
AREA_OF_ELEMENT_2D(n,cornerCoords,area);
#else
AREA_OF_ELEMENT_3D(n,cornerCoords,area);
#endif
return area;
}
static int myLevel (const UG_NS< UG_DIM >::Element* theElement) {
using UG::UINT;
return LEVEL(theElement);
}
static int myLevel (const UG_NS< UG_DIM >::Node* theNode) {
using UG::UINT;
return LEVEL(theNode);
}
static int myLevel (const UG_NS< UG_DIM >::Edge* theEdge) {
using UG::UINT;
return LEVEL(theEdge);
}
static int myLevel (const UG_NS< UG_DIM >::Vector* theVector) {
return myLevel((UG_NS< UG_DIM >::Element*)VOBJECT(theVector));
}
//! return true if element has an exact copy on the next level
static bool hasCopy (const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::ELEMENT;
using UG_NAMESPACE ::control_entries;
using UG::UINT;
using UG_NAMESPACE ::REFINECLASS_CE;
using UG_NAMESPACE ::YELLOW_CLASS;
return REFINECLASS(theElement) == YELLOW_CLASS;
}
//! Returns true if element is on level 0 or has been created by red refinement
static bool isRegular (const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::ELEMENT;
using UG_NAMESPACE ::control_entries;
using UG::UINT;
return ECLASS(theElement) == RED_CLASS;
}
//! \todo Please doc me!
static int Sides_Of_Elem(const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
return SIDES_OF_ELEM(theElement);
}
//! Encapsulates the NBELEM macro
static UG_NS<UG_DIM>::Element* NbElem(const UG_NS< UG_DIM >::Element* theElement, int nb) {
using UG_NAMESPACE ::ELEMENT;
using UG_NAMESPACE ::nb_offset;
using UG::UINT;
return NBELEM(theElement, nb);
}
static size_t boundarySegmentIndex(const UG_NS< UG_DIM >::Element* theElement, int nb) {
using UG_NAMESPACE ::BNDS;
using UG::UINT;
using UG_NAMESPACE ::side_offset;
BNDS* bnds = ELEM_BNDS(theElement,nb);
size_t id = UG_NAMESPACE ::GetBoundarySegmentId(bnds);
return id;
}
//! Returns true if the i-th side of the element is on the domain boundary
static bool Side_On_Bnd(const UG_NS< UG_DIM >::Element* theElement, int i) {
using UG_NAMESPACE ::BNDS;
using UG_NAMESPACE ::BEOBJ;
using UG_NAMESPACE ::side_offset;
using UG::UINT;
using UG_NAMESPACE ::GM_OBJECTS;
return OBJT(theElement)==BEOBJ && SIDE_ON_BND(theElement, i);
}
//! Returns true if at least one face of the element is a boundary face
static bool isBoundaryElement(const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::BEOBJ;
using UG_NAMESPACE ::GM_OBJECTS;
using UG::UINT;
return OBJT(theElement)==BEOBJ;
}
//! \todo Please doc me!
static int Edges_Of_Elem(const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
return EDGES_OF_ELEM(theElement);
}
//! \todo Please doc me!
static int Corners_Of_Elem(const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
return CORNERS_OF_ELEM(theElement);
}
/** \Brief the 'number of corners' of a vertex, i.e., 1. Here for consistency
\return 1
*/
static int Corners_Of_Elem(const UG_NS< UG_DIM >::Node* theNode) {
return 1;
}
//! Return number of corners of a given side
static int Corners_Of_Side(const UG_NS< UG_DIM >::Element* theElement, int side) {
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
return CORNERS_OF_SIDE(theElement, side);
}
//! Return local number of a given corner of a given element side
static int Corner_Of_Side(const UG_NS< UG_DIM >::Element* theElement, int side, int corner) {
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
return CORNER_OF_SIDE(theElement, side, corner);
}
//! Return local number of a given corner of a given element edge
static int Corner_Of_Edge(const UG_NS< UG_DIM >::Element* theElement, int edge, int corner) {
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
return CORNER_OF_EDGE(theElement, edge, corner);
}
//! Return number of sons of an element
static int nSons(const UG_NAMESPACE ::element* element) {
return UG_NAMESPACE ::ReadCW(element, UG_NAMESPACE ::NSONS_CE);
}
static int GetSons(const UG_NAMESPACE ::element* element, UG_NAMESPACE ::element* sonList[MAX_SONS]) {
return UG_NAMESPACE ::GetSons(element, sonList);
}
/** \todo Remove the const casts */
static int GetNodeContext(const UG_NAMESPACE ::element* element, const UG_NAMESPACE ::node** context) {
return UG_NAMESPACE ::GetNodeContext(element, const_cast<UG_NAMESPACE ::node**>(context));
}
//! Encapsulates the GRID_ATTR macro
static int Grid_Attr(const UG_NS< UG_DIM >::Grid* grid) {
return GRID_ATTR(grid);
}
static int MarkForRefinement(UG_NAMESPACE ::element* element, int rule, int data) {
return UG_NAMESPACE ::MarkForRefinement(element, (UG_NAMESPACE ::RefinementRule)rule, data);
}
//! Encapsulates the TAG macro
static unsigned int Tag(const UG_NS< UG_DIM >::Element* theElement) {
using UG::UINT;
return TAG(theElement);
}
//! Doesn't ever get called, but needs to be there to calm the compiler
static unsigned int Tag(const UG_NS< UG_DIM >::Node* theNode) {
DUNE_THROW(GridError, "Called method Tag() for a vertex. This should never happen!");
return 0;
}
//! get corner in local coordinates, corner number in UG's numbering system
template<class T>
static void getCornerLocal (const UG_NS< UG_DIM >::Element* theElement, int corner, FieldVector<T, UG_DIM>& local)
{
using UG_NAMESPACE ::element_descriptors;
using UG::UINT;
for (int i=0; i<UG_DIM; i++)
local[i] = LOCAL_COORD_OF_TAG(TAG(theElement),corner)[i];
}
//! Next element in the UG element lists
static UG_NS< UG_DIM >::Element* succ(const UG_NS< UG_DIM >::Element* theElement) {
return theElement->ge.succ;
}
//! Next element in the UG nodes lists
static UG_NS< UG_DIM >::Node* succ(const UG_NS< UG_DIM >::Node* theNode) {
return theNode->succ;
}
//! Calm the compiler
static void* succ(const void* theWhatever) {
DUNE_THROW(NotImplemented, "No successor available for this kind of object");
return 0;
}
//! Return true if the element is a ghost element
#ifdef ModelP
static bool isGhost(const UG_NS< UG_DIM >::Element* theElement) {
if (EPRIO(theElement) == PrioHGhost
|| EPRIO(theElement) == PrioVGhost
|| EPRIO(theElement) == PrioVHGhost)
return true;
else
return false;
}
#endif
//! Return true if the element is a leaf element
static bool isLeaf(const UG_NS< UG_DIM >::Element* theElement) {
using UG ::UINT;
using UG_NAMESPACE ::CONTROL_ENTRY;
using UG_NAMESPACE ::control_entries;
return LEAFELEM(theElement);
}
//! Return true if the node is a leaf node
static bool isLeaf(const UG_NS< UG_DIM >::Node* theNode) {
return theNode->isLeaf;
}
//! Return true if the edge is a leaf edge
static bool isLeaf(const UG_NS< UG_DIM >::Edge* theEdge) {
return theEdge->leafIndex > -1;
}
//! Return true if the side vector is a leaf side vector
static bool isLeaf(const UG_NS< UG_DIM >::Vector* theVector) {
using UG_NAMESPACE ::VECTOR;
using UG::UINT;
// Since the vector cannot be asked directly,
// the corresponding element is asked.
return isLeaf((UG_NS< UG_DIM >::Element*)VOBJECT(theVector));
}
// /////////////////////////////////////////////
// Level indices
// /////////////////////////////////////////////
//! Gets the level index of a UG element
static int& levelIndex(UG_NS< UG_DIM >::Element* theElement) {
return theElement->ge.levelIndex;
}
//! Gets the level index of a UG element
static const int& levelIndex(const UG_NS< UG_DIM >::Element* theElement) {
return theElement->ge.levelIndex;
}
//! Gets the level index of a UG sidevector
static UG::UINT& levelIndex(Vector* theVector) {
#if UG_DIM == 2
DUNE_THROW(GridError, "levelIndex in side vector only in 3D!");
#endif
return theVector->index;
}
//! Gets the level index of a UG sidevector
static const UG::UINT& levelIndex(const Vector* theVector) {
#if UG_DIM == 2
DUNE_THROW(GridError, "levelIndex in side vector only in 3D!");
#endif
return theVector->index;
}
//! Gets the level index of a UG edge
static int& levelIndex(UG_NS< UG_DIM >::Edge* theEdge) {
return theEdge->levelIndex;
}
//! Gets the level index of a UG edge
static const int& levelIndex(const UG_NS< UG_DIM >::Edge* theEdge) {
return theEdge->levelIndex;
}
//! Gets the level index of a UG node
static int& levelIndex(UG_NS< UG_DIM >::Node* theNode) {
return theNode->levelIndex;
}
//! Gets the level index of a UG node
static const int& levelIndex(const UG_NS< UG_DIM >::Node* theNode) {
return theNode->levelIndex;
}
// /////////////////////////////////////////////
// Leaf indices
// /////////////////////////////////////////////
//! Gets the leaf index of a UG element
static int& leafIndex(UG_NS< UG_DIM >::Element* theElement) {
return theElement->ge.leafIndex;
}
//! Gets the leaf index of a UG element
static const int& leafIndex(const UG_NS< UG_DIM >::Element* theElement) {
return theElement->ge.leafIndex;
}
//! Gets the leaf index of a UG sidevector
static UG::UINT& leafIndex(Vector* theVector) {
// theVector->skip is actually something other than an index.
// We use it anyways.
return theVector->skip;
}
//! Gets the leaf index of a UG sidevector
static const UG::UINT& leafIndex(const Vector* theVector) {
// theVector->skip is actually something other than an index.
// We use it anyways.
return theVector->skip;
}
//! Gets the leaf index of a UG edge
static int& leafIndex(UG_NS< UG_DIM >::Edge* theEdge) {
return theEdge->leafIndex;
}
//! Gets the leaf index of a UG edge
static const int& leafIndex(const UG_NS< UG_DIM >::Edge* theEdge) {
return theEdge->leafIndex;
}
//! Gets the leaf index of a UG node
static int& leafIndex(UG_NS< UG_DIM >::Node* theNode) {
return theNode->myvertex->iv.leafIndex;
}
//! Gets the leaf index of a UG node
static const int& leafIndex(const UG_NS< UG_DIM >::Node* theNode) {
return theNode->myvertex->iv.leafIndex;
}
// /////////////////////////////////////////////
// IDs
// /////////////////////////////////////////////
//! Gets the index of a UG element
static unsigned int id(const UG_NS< UG_DIM >::Element* theElement) {
return theElement->ge.id;
}
//! Gets the index of a UG node
static unsigned int id(const UG_NS< UG_DIM >::Node* theNode) {
#if UG_DIM == 2
return theNode->myvertex->iv.id | 0x80000000;
#else
return theNode->myvertex->iv.id | 0xC0000000;
#endif
}
/** \brief Compute global coordinates of a point in local coordinates for an element */
static void Local_To_Global(int n, double** y,
const FieldVector<double, UG_DIM>& local,
FieldVector<double, UG_DIM>& global) {
using UG::DOUBLE;
LOCAL_TO_GLOBAL(n,y,local,global);
}
/** \brief Compute global coordinates of a point in local coordinates for a vertex */
static void Local_To_Global(int n, double** y,
const FieldVector<double,0>& local,
FieldVector<double, UG_DIM>& global) {
for (int i=0; i<UG_DIM; i++)
global[i] = y[0][i];
}
/**
* \param n Number of corners of the element
* \param x Coordinates of the corners of the element
* \param local Local evaluation point
*
* \return The return type is int because the macro INVERSE_TRANSFORMATION
* returns 1 on failure.
*/
static int Transformation(int n, double** x,
const FieldVector<double, UG_DIM>& local, FieldMatrix<double,UG_DIM,UG_DIM>& mat) {
using UG_NAMESPACE ::DOUBLE_VECTOR;
using UG::DOUBLE;
double det;
#ifndef SMALL_D
const double SMALL_D = DBL_EPSILON*10;
#endif
INVERSE_TRANSFORMATION(n, x, local, mat, det);
return 0;
}
/** \brief Dummy method for vertices */
static int Transformation(int n, double** x,
const FieldVector<double, 0>& local, FieldMatrix<double,UG_DIM,0>& mat) {
return 0;
}
/**
* \param n Number of corners of the element
* \param x Coordinates of the corners of the element
* \param local Local evaluation point
*
* \return The return type is int because the macro TRANSFORMATION
* returns 1 on failure.
*/
static int JacobianTransformation(int n, double** x,
const FieldVector<double, UG_DIM>& local, FieldMatrix<double,UG_DIM,UG_DIM>& mat) {
using UG_NAMESPACE ::DOUBLE_VECTOR;
using UG::DOUBLE;
TRANSFORMATION(n, x, local, mat);
return 0;
}
/** \brief Dummy method for vertices */
static int JacobianTransformation(int n, double** x,
const FieldVector<double, 0>& local, FieldMatrix<double,0,UG_DIM>& mat) {
return 0;
}
/** \brief Compute the integration element on an element face
\param nc Number of corners of the element face
\param co_global Coordinates of the corners of the face
\param ip_local Local coordinates where integration element is to be evaluated
*/
static UG::DOUBLE SurfaceElement(int nc,
const UG::DOUBLE co_global[MAX_CORNERS_OF_ELEM][ UG_DIM ],
const UG::DOUBLE ip_local[ UG_DIM ]) {
UG::DOUBLE result;
if (UG_NAMESPACE ::SurfaceElement(UG_DIM, nc, co_global, ip_local, &result))
DUNE_THROW(GridError, "UG_D" << UG_DIM << "::SurfaceElement returned error code!");
return result;
}
//! Returns the i-th corner of a UG element
static UG_NS< UG_DIM >::Node* Corner(const UG_NS< UG_DIM >::Element* theElement, int i) {
using UG_NAMESPACE ::NODE;
using UG_NAMESPACE ::n_offset;
using UG::UINT;
return CORNER(theElement, i);
}
//! Returns the i-th edge of a UG element
static UG_NS< UG_DIM >::Edge* ElementEdge(const UG_NS< UG_DIM >::Element* theElement, int i) {
using UG_NAMESPACE ::NODE;
using UG_NAMESPACE ::n_offset;
using UG::UINT;
using UG_NAMESPACE ::element_descriptors;
return GetEdge(CORNER(theElement, CORNER_OF_EDGE(theElement, i, 0)),
CORNER(theElement, CORNER_OF_EDGE(theElement, i, 1)));
}
//! get edge from node i to node j (in UG's numbering !
static UG_NS< UG_DIM >::Edge* GetEdge (UG_NS< UG_DIM >::Node* nodei, UG_NS< UG_DIM >::Node* nodej) {
return UG_NAMESPACE ::GetEdge(nodei,nodej);
}
//! access side vector from element (this is just a dummy to compile code also in 2d)
static Vector* SideVector (const UG_NS< UG_DIM >::Element* theElement, int i)
{
#if UG_DIM == 2
DUNE_THROW(GridError, "side vector only in 3D!");
#else
using UG::D3::VECTOR;
using UG::D3::svector_offset;
using UG::UINT;
return SVECTOR(theElement,i);
#endif
}
//! Access element from side vector
static void GetElementAndSideFromSideVector(const UG_NS< UG_DIM >::Vector* theVector,
UG_NS< UG_DIM >::Element*& theElement,
unsigned int& side)
{
using UG_NAMESPACE ::VECTOR;
using UG::UINT;
theElement = (UG_NS< UG_DIM >::Element*)VOBJECT(theVector);
side = VECTORSIDE(theVector);
}
/** \brief Return a pointer to the father of the given element */
static UG_NS< UG_DIM >::Element* EFather(const UG_NS< UG_DIM >::Element* theElement) {
using UG_NAMESPACE ::ELEMENT;
using UG_NAMESPACE ::father_offset;
using UG::UINT;
return EFATHER(theElement);
}
//! get father element of vertex
static UG_NS< UG_DIM >::Element* NFather(UG_NS< UG_DIM >::Node* theNode) {
return theNode->myvertex->iv.father;
}
//! get father node of vertex
static UG_NS< UG_DIM >::Node* NodeNodeFather(UG_NS< UG_DIM >::Node* theNode) {
using UG_NAMESPACE ::NDOBJ;
using UG_NAMESPACE ::GM_OBJECTS;
using UG::UINT;
if (theNode->father==0)
return 0; // no father at all
if (OBJT(theNode->father)==NDOBJ)
return (UG_NAMESPACE ::node*) theNode->father;
else
return 0; // may be edge or element
}
static unsigned int ReadCW(void* obj, int ce) {
return UG_NAMESPACE ::ReadCW(obj, ce);
}
static void WriteCW(void* obj, int ce, int n) {
UG_NAMESPACE ::WriteCW(obj, ce, n);
}
//! \todo Please doc me!
static int InitUg(int* argcp, char*** argvp) {
return UG_NAMESPACE ::InitUg(argcp, argvp);
}
static void ExitUg() {
UG_NAMESPACE ::ExitUg();
}
static int DisposeMultiGrid(UG_NAMESPACE ::multigrid* mg) {
return UG_NAMESPACE ::DisposeMultiGrid(mg);
}
//! \todo Please doc me!
static void* CreateBoundaryValueProblem(const char* BVPname,
int numOfCoeffFunc,
UG_NAMESPACE ::CoeffProcPtr coeffs[],
int numOfUserFct,
UG_NAMESPACE ::UserProcPtr userfct[]) {
return UG_NAMESPACE ::CreateBoundaryValueProblem(BVPname, 0, numOfCoeffFunc, coeffs,
numOfUserFct, userfct);
}
//! Set the current boundary value problem
static void Set_Current_BVP(void** thisBVP) {
UG_NAMESPACE ::Set_Current_BVP(thisBVP);
}
//! Get UG boundary value problem from its name
static void** BVP_GetByName(const char* name) {
return UG_NAMESPACE ::BVP_GetByName(name);
}
//! Dispose of a boundary value problem
static int BVP_Dispose(void** BVP) {
return UG_NAMESPACE ::BVP_Dispose(BVP);
}
/** \brief Create new point on the grid boundary by giving local coordinates.
Global coordinates are computed automatically using the domain boundary information.
The point is not inserted as a new vertex in the grid!
*/
static BNDP *BNDP_CreateBndP(UG::HEAP *Heap,
BNDP *theBndP0,
BNDP *theBndP1,
UG::DOUBLE lcoord) {
return UG_NAMESPACE::BNDP_CreateBndP(Heap, theBndP0, theBndP1, lcoord);
}
/** \brief Get global position of a point on the grid boundary */
static UG::INT BNDP_Global(BNDP *theBndP,
UG::DOUBLE *global) {
return UG_NAMESPACE::BNDP_Global(theBndP, global);
}
/** \brief Delete a grid boundary point */
static UG::INT BNDP_Dispose(UG::HEAP *Heap,
BNDP *theBndP) {
return UG_NAMESPACE::BNDP_Dispose(Heap, theBndP);
}
//! Get UG multigrid object from its name
static UG_NS< UG_DIM >::MultiGrid* GetMultigrid(const char* name) {
return UG_NAMESPACE ::GetMultigrid(name);
}
/** \brief Load-balance the grid by recursive coordinate bisection */
static void lbs(const char *argv, UG_NAMESPACE ::multigrid *theMG) {
#ifdef ModelP
return UG_NAMESPACE ::lbs(argv, theMG);
#endif
}
//! An UG-internal load balancing method
static int TransferGridFromLevel(UG_NAMESPACE ::multigrid *theMG, int level) {
#ifdef ModelP
return UG_NAMESPACE ::TransferGridFromLevel(theMG,level);
#else
return 0;
#endif
}
static int ConfigureCommand(int argc, const char** argv) {
/** \todo Can we remove the cast? */
return UG_NAMESPACE ::ConfigureCommand(argc, (char**)argv);
}
static int NewCommand(int argc, char** argv) {
return UG_NAMESPACE ::NewCommand(argc, argv);
}
static int CreateFormatCmd(int argc, char** argv) {
return UG_NAMESPACE ::CreateFormatCmd(argc, argv);
}
static void* CreateDomain(const char* name, const double* midPoint, double radius,
int segments, int corners, int convex) {
return UG_NAMESPACE ::CreateDomain(name, midPoint, radius, segments, corners, convex);
}
static void RemoveDomain(const char* name) {
UG_NAMESPACE ::RemoveDomain(name);
}
static void* InsertInnerNode(UG_NAMESPACE ::grid* grid, const double* pos) {
return UG_NAMESPACE ::InsertInnerNode(grid, pos);
}
static void* CreateBoundarySegment(const char *name, int left, int right,
int index, int res,
UG::INT *point,
const double *alpha, const double *beta,
UG_NAMESPACE ::BndSegFuncPtr boundarySegmentFunction,
void *userData) {
return UG_NAMESPACE ::CreateBoundarySegment(name, // internal name of the boundary segment
left, // id of left subdomain
right, // id of right subdomain
index, // Index of the segment
UG_NAMESPACE ::NON_PERIODIC, // I don't know what this means
res, // Resolution, only for the UG graphics
point,
alpha,
beta,
boundarySegmentFunction,
userData);
}
static void* CreateLinearSegment(const char *name,
int left, int right,
int index, int numVertices,
const UG::INT* cornerIndices,
double cornerCoordinates[2][ UG_DIM ])
{
return UG_NAMESPACE ::CreateLinearSegment(name, // internal name of the boundary segment
left, // id of left subdomain
right, // id of right subdomain
index, // Index of the segment
numVertices,
cornerIndices,
cornerCoordinates);
}
};
template <>
class UG_NS< UG_DIM >::Entity<0>
{
public:
typedef UG_NAMESPACE ::element T;
};
template <>
class UG_NS< UG_DIM >::Entity< UG_DIM - 1 >
{
public:
typedef UG_NAMESPACE ::edge T;
};
#if UG_DIM == 3
template <>
class UG_NS< UG_DIM >::Entity<1>
{
public:
typedef UG_NAMESPACE ::vector T;
};
#endif
template <>
class UG_NS< UG_DIM >::Entity< UG_DIM > {
public:
typedef UG_NAMESPACE ::node T;
};
#undef UG_NAMESPACE
} // namespace Dune
|