/usr/include/dune/grid/yaspgrid.hh is in libdune-grid-dev 2.2.1-2.
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 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 | #ifndef DUNE_YASPGRID_HH
#define DUNE_YASPGRID_HH
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
// either include stdint.h or provide fallback for uint8_t
#if HAVE_STDINT_H
#include<stdint.h>
#else
typedef unsigned char uint8_t;
#endif
#include <dune/grid/common/grid.hh> // the grid base classes
#include <dune/grid/yaspgrid/grids.hh> // the yaspgrid base classes
#include <dune/grid/common/capabilities.hh> // the capabilities
#include <dune/common/misc.hh>
#include <dune/common/bigunsignedint.hh>
#include <dune/common/typetraits.hh>
#include <dune/common/collectivecommunication.hh>
#include <dune/common/mpihelper.hh>
#include <dune/geometry/genericgeometry/topologytypes.hh>
#include <dune/grid/common/indexidset.hh>
#include <dune/grid/common/datahandleif.hh>
#if HAVE_MPI
#include <dune/common/mpicollectivecommunication.hh>
#endif
/*! \file yaspgrid.hh
YaspGrid stands for yet another structured parallel grid.
It will implement the dune grid interface for structured grids with codim 0
and dim, with arbitrary overlap, parallel features with two overlap
models, periodic boundaries and fast a implementation allowing on-the-fly computations.
*/
namespace Dune {
//************************************************************************
/*! define name for floating point type used for coordinates in yaspgrid.
You can change the type for coordinates by changing this single typedef.
*/
typedef double yaspgrid_ctype;
static const yaspgrid_ctype yasptolerance=1E-13; // tolerance in coordinate computations
/* some sizes for building global ids
*/
const int yaspgrid_dim_bits = 24; // bits for encoding each dimension
const int yaspgrid_level_bits = 6; // bits for encoding level number
const int yaspgrid_codim_bits = 4; // bits for encoding codimension
//************************************************************************
// forward declaration of templates
template<int dim> class YaspGrid;
template<int mydim, int cdim, class GridImp> class YaspGeometry;
template<int codim, int dim, class GridImp> class YaspEntity;
template<int codim, class GridImp> class YaspEntityPointer;
template<int codim, class GridImp> class YaspEntitySeed;
template<int codim, PartitionIteratorType pitype, class GridImp> class YaspLevelIterator;
template<class GridImp> class YaspIntersectionIterator;
template<class GridImp> class YaspIntersection;
template<class GridImp> class YaspHierarchicIterator;
template<class GridImp> class YaspLevelIndexSet;
template<class GridImp> class YaspLeafIndexSet;
template<class GridImp> class YaspGlobalIdSet;
namespace FacadeOptions
{
template<int dim, int mydim, int cdim>
struct StoreGeometryReference<mydim, cdim, YaspGrid<dim>, YaspGeometry>
{
static const bool v = false;
};
template<int dim, int mydim, int cdim>
struct StoreGeometryReference<mydim, cdim, const YaspGrid<dim>, YaspGeometry>
{
static const bool v = false;
};
}
//========================================================================
// The transformation describing the refinement rule
template<int dim, class GridImp>
struct YaspFatherRelativeLocalElement {
static const array<YaspGeometry<dim,dim,GridImp>, (1<<dim) > _geo;
static array<YaspGeometry<dim,dim,GridImp>, (1<<dim) > initSons()
{
array<YaspGeometry<dim,dim,GridImp>, (1<<dim) > geo;
FieldVector<yaspgrid_ctype,dim> midpoint(0.25);
FieldVector<yaspgrid_ctype,dim> extension(0.5);
for (int i=0; i<(1<<dim); i++)
{
midpoint = 0.25;
for (int k=0; k<dim; k++)
{
if (i&(1<<k))
midpoint[k] = 0.75;
}
geo[i] = YaspGeometry<dim,dim,GridImp>(midpoint, extension);
}
return geo;
}
};
template<int dim, class GridImp>
const array<YaspGeometry<dim,dim,GridImp>, (1<<dim)>
YaspFatherRelativeLocalElement<dim, GridImp>::_geo =
YaspFatherRelativeLocalElement<dim, GridImp>::initSons();
//========================================================================
/*!
YaspGeometry realizes the concept of the geometric part of a mesh entity.
We have specializations for dim == dimworld (elements) and dim == 0
(vertices). The general version implements dim == dimworld-1 (faces)
and otherwise throws a GridError.
*/
//========================================================================
//! The general version implements dim==dimworld-1. If this is not the case an error is thrown
template<int mydim,int cdim, class GridImp>
class YaspGeometry : public GeometryDefaultImplementation<mydim,cdim,GridImp,YaspGeometry>
{
public:
//! define type used for coordinates in grid module
typedef typename GridImp::ctype ctype;
//! return the element type identifier
GeometryType type () const
{
return GeometryType(GeometryType::cube,mydim);
}
//! here we have always an affine geometry
bool affine() const { return true; }
//! return the number of corners of this element. Corners are numbered 0...n-1
int corners () const
{
return 1<<mydim;
}
//! access to coordinates of corners. Index is the number of the corner
FieldVector< ctype, cdim > corner ( const int i ) const
{
assert( i >= 0 && i < (int) coord_.N() );
FieldVector<ctype, cdim>& c = coord_[i];
int bit=0;
for (int k=0; k<cdim; k++) // run over all directions in world
{
if (k==missing)
{
c[k] = midpoint[k];
continue;
}
//k is not the missing direction
if (i&(1<<bit)) // check whether bit is set or not
c[k] = midpoint[k]+0.5*extension[k]; // bit is 1 in i
else
c[k] = midpoint[k]-0.5*extension[k]; // bit is 0 in i
bit++; // we have processed a direction
}
return c;
}
//! access to the center/centroid
FieldVector< ctype, cdim > center ( ) const
{
return midpoint;
}
//! maps a local coordinate within reference element to global coordinate in element
FieldVector<ctype, cdim> global (const FieldVector<ctype, mydim>& local) const
{
FieldVector<ctype, cdim> g;
int bit=0;
for (int k=0; k<cdim; k++)
if (k==missing)
g[k] = midpoint[k];
else
{
g[k] = midpoint[k] + (local[bit]-0.5)*extension[k];
bit++;
}
return g;
}
//! maps a global coordinate within the element to a local coordinate in its reference element
FieldVector<ctype, mydim> local (const FieldVector<ctype, cdim>& global) const
{
FieldVector<ctype, mydim> l; // result
int bit=0;
for (int k=0; k<cdim; k++)
if (k!=missing)
{
l[bit] = (global[k]-midpoint[k])/extension[k] + 0.5;
bit++;
}
return l;
}
//! return volume of geometry
ctype volume () const
{
ctype volume=1.0;
for (int k=0; k<cdim; k++)
if (k!=missing) volume *= extension[k];
return volume;
}
/*! determinant of the jacobian of the mapping
*/
ctype integrationElement (const FieldVector<ctype, mydim>& local) const
{
return volume();
}
//! Compute the transposed of the jacobi matrix
FieldMatrix<ctype,mydim,cdim>& jacobianTransposed (const FieldVector<ctype, mydim>& local) const
{
JT = 0.0;
int k=0;
for (int i=0; i<cdim; ++i)
{
if (i != missing)
{
JT[k][i] = extension[i]; // set diagonal element
k++;
}
}
return JT;
}
//! Compute the transposed of the inverse jacobi matrix
FieldMatrix<ctype,cdim,mydim>& jacobianInverseTransposed (const FieldVector<ctype, mydim>& local) const
{
Jinv = 0.0;
int k=0;
for (int i=0; i<cdim; ++i)
{
if (i != missing)
{
Jinv[i][k] = 1.0/extension[i]; // set diagonal element
k++;
}
}
return Jinv;
}
//! default constructor
YaspGeometry () {}
//! constructor from midpoint and extension and missing direction number
YaspGeometry (const FieldVector<ctype, cdim>& p, const FieldVector<ctype, cdim>& h, uint8_t& m)
: midpoint(p), extension(h), missing(m)
{
if (cdim!=mydim+1)
DUNE_THROW(GridError, "general YaspGeometry assumes cdim=mydim+1");
}
//! copy constructor (skipping temporary variables)
YaspGeometry (const YaspGeometry& other)
: midpoint(other.midpoint),
extension(other.extension),
missing(other.missing)
{
}
//! print function
void print (std::ostream& s) const
{
s << "YaspGeometry<"<<mydim<<","<<cdim<< "> ";
s << "midpoint";
for (int i=0; i<cdim; i++)
s << " " << midpoint[i];
s << " extension";
for (int i=0; i<cdim; i++)
s << " " << extension[i];
s << " missing is " << missing;
}
// const YaspGeometry<mydim,cdim,GridImp>&
// operator = (const YaspGeometry<mydim,cdim,GridImp>& g);
private:
// the element is fully defined by its midpoint the extension
// in each direction and the missing direction.
// Note cdim == mydim+1
FieldVector<ctype, cdim> midpoint; // the midpoint
FieldVector<ctype, cdim> extension; // the extension
uint8_t missing; // the missing, i.e. constant direction
// In addition we need memory in order to return references.
// Possibly we should change this in the interface ...
mutable FieldMatrix<ctype, mydim, cdim> JT; // the transposed of the jacobian
mutable FieldMatrix<ctype, cdim, mydim> Jinv; // the transposed of the jacobian inverse
mutable FieldMatrix<ctype, Power_m_p<2,mydim>::power, cdim> coord_; // the coordinates
};
//! specialize for dim=dimworld, i.e. a volume element
template<int mydim, class GridImp>
class YaspGeometry<mydim,mydim,GridImp> : public GeometryDefaultImplementation<mydim,mydim,GridImp,YaspGeometry>
{
public:
typedef typename GridImp::ctype ctype;
//! return the element type identifier
GeometryType type () const
{
return GeometryType(GeometryType::cube,mydim);
}
//! here we have always an affine geometry
bool affine() const { return true; }
//! return the number of corners of this element. Corners are numbered 0...n-1
int corners () const
{
return 1<<mydim;
}
//! access to coordinates of corners. Index is the number of the corner
const FieldVector<ctype, mydim>& operator[] (int i) const
{
return corner(i);
}
//! access to coordinates of corners. Index is the number of the corner
FieldVector< ctype, mydim > corner ( const int i ) const
{
assert( i >= 0 && i < (int) coord_.N() );
FieldVector<ctype, mydim>& c = coord_[i];
for (int k=0; k<mydim; k++)
if (i&(1<<k))
c[k] = midpoint[k]+0.5*extension[k]; // kth bit is 1 in i
else
c[k] = midpoint[k]-0.5*extension[k]; // kth bit is 0 in i
return c;
}
//! access to the center/centroid
FieldVector< ctype, mydim > center ( ) const
{
return midpoint;
}
//! maps a local coordinate within reference element to global coordinate in element
FieldVector<ctype, mydim> global (const FieldVector<ctype, mydim>& local) const
{
FieldVector<ctype,mydim> g;
for (int k=0; k<mydim; k++)
g[k] = midpoint[k] + (local[k]-0.5)*extension[k];
return g;
}
//! maps a global coordinate within the element to a local coordinate in its reference element
FieldVector<ctype, mydim> local (const FieldVector<ctype,mydim>& global) const
{
FieldVector<ctype, mydim> l; // result
for (int k=0; k<mydim; k++)
l[k] = (global[k]-midpoint[k])/extension[k] + 0.5;
return l;
}
/*! determinant of the jacobian of the mapping
*/
ctype integrationElement (const FieldVector<ctype, mydim>& local) const
{
return volume();
}
//! return volume of geometry
ctype volume () const
{
ctype vol=1.0;
for (int k=0; k<mydim; k++) vol *= extension[k];
return vol;
}
//! Compute the transposed of the jacobi matrix
FieldMatrix<ctype,mydim,mydim>& jacobianTransposed (const FieldVector<ctype, mydim>& local) const
{
for (int i=0; i<mydim; ++i)
{
JT[i] = 0.0; // set column to zero
JT[i][i] = extension[i]; // set diagonal element
}
return JT;
}
//! Compute the transposed of the inverse jacobi matrix
FieldMatrix<ctype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<ctype, mydim>& local) const
{
for (int i=0; i<mydim; ++i)
{
Jinv[i] = 0.0; // set column to zero
Jinv[i][i] = 1.0/extension[i]; // set diagonal element
}
return Jinv;
}
//! default constructor
YaspGeometry () {}
//! constructor from midpoint and extension
YaspGeometry (const FieldVector<ctype, mydim>& p, const FieldVector<ctype, mydim>& h)
: midpoint(p), extension(h)
{}
//! copy constructor (skipping temporary variables)
YaspGeometry (const YaspGeometry& other)
: midpoint(other.midpoint),
extension(other.extension)
{
}
//! print function
void print (std::ostream& s) const
{
s << "YaspGeometry<"<<mydim<<","<<mydim<< "> ";
s << "midpoint";
for (int i=0; i<mydim; i++)
s << " " << midpoint[i];
s << " extension";
for (int i=0; i<mydim; i++)
s << " " << extension[i];
}
// const YaspGeometry<mydim,mydim,GridImp>&
// operator = (const YaspGeometry<mydim,mydim,GridImp>& g);
private:
// the element is fully defined by midpoint and the extension
// in each direction. References are used because this information
// is known outside the element in many cases.
// Note mydim==cdim
FieldVector<ctype, mydim> midpoint; // the midpoint
FieldVector<ctype, mydim> extension; // the extension
// In addition we need memory in order to return references.
// Possibly we should change this in the interface ...
mutable FieldMatrix<ctype, mydim, mydim> Jinv,JT; // the transpose of the jacobian and its inverse inverse
mutable FieldMatrix<ctype, Power_m_p<2,mydim>::power, mydim> coord_; // the coordinates
};
//! specialization for dim=0, this is a vertex
template<int cdim, class GridImp>
class YaspGeometry<0,cdim,GridImp> : public GeometryDefaultImplementation<0,cdim,GridImp,YaspGeometry>
{
public:
typedef typename GridImp::ctype ctype;
//! return the element type identifier
GeometryType type () const
{
return GeometryType(GeometryType::cube,0);
}
//! here we have always an affine geometry
bool affine() const { return true; }
//! return the number of corners of this element. Corners are numbered 0...n-1
int corners () const
{
return 1;
}
//! access to coordinates of corners. Index is the number of the corner
const FieldVector<ctype, cdim>& operator[] (int i) const
{
return position;
}
//! access to coordinates of corners. Index is the number of the corner
FieldVector< ctype, cdim > corner ( const int i ) const
{
return position;
}
//! access to the center/centroid
FieldVector< ctype, cdim > center ( ) const
{
return position;
}
/*! determinant of the jacobian of the mapping
*/
ctype integrationElement (const FieldVector<ctype, 0>& local) const
{
return 1.0;
}
//! Compute the transposed of the jacobi matrix
FieldMatrix<ctype,0,cdim>& jacobianTransposed (const FieldVector<ctype, 0>& local) const
{
static FieldMatrix<ctype,0,cdim> JT(0.0);
return JT;
}
//! Compute the transposed of the inverse jacobi matrix
FieldMatrix<ctype,cdim,0>& jacobianInverseTransposed (const FieldVector<ctype, 0>& local) const
{
static FieldMatrix<ctype,cdim,0> Jinv(0.0);
return Jinv;
}
//! default constructor
YaspGeometry ()
{}
//! constructor
explicit YaspGeometry ( const FieldVector< ctype, cdim > &p )
: position( p )
{}
YaspGeometry ( const FieldVector< ctype, cdim > &p, const FieldVector< ctype, cdim > &, uint8_t &)
: position( p )
{}
//! print function
void print (std::ostream& s) const
{
s << "YaspGeometry<"<<0<<","<<cdim<< "> ";
s << "position " << position;
}
// const YaspGeometry<0,cdim,GridImp>&
// operator = (const YaspGeometry<0,cdim,GridImp>& g);
private:
FieldVector<ctype, cdim> position; //!< position of the vertex
};
// operator<< for all YaspGeometrys
template <int mydim, int cdim, class GridImp>
inline
std::ostream& operator<< (std::ostream& s, YaspGeometry<mydim,cdim,GridImp>& e)
{
e.print(s);
return s;
}
//========================================================================
/*!
YaspEntity realizes the concept a mesh entity.
We have specializations for codim==0 (elements) and
codim=dim (vertices).
The general version throws a GridError.
*/
//========================================================================
template<int codim, int dim, class GridImp>
class YaspSpecialEntity :
public GridImp::template Codim<codim>::Entity
{
public:
typedef typename GridImp::ctype ctype;
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
YaspSpecialEntity(const GridImp* yg, const YGLI& g, const TSI& it) :
GridImp::template Codim<codim>::Entity (YaspEntity<codim, dim, GridImp>(yg,g,it))
{}
YaspSpecialEntity(const YaspEntity<codim, dim, GridImp>& e) :
GridImp::template Codim<codim>::Entity (e)
{}
const TSI& transformingsubiterator () const
{
return this->realEntity.transformingsubiterator();
}
const YGLI& gridlevel () const
{
return this->realEntity.gridlevel();
}
const GridImp * yaspgrid() const
{
return this->realEntity.yaspgrid();
}
};
template<int codim, int dim, class GridImp>
class YaspEntity
: public EntityDefaultImplementation <codim,dim,GridImp,YaspEntity>
{
public:
typedef typename GridImp::ctype ctype;
typedef typename GridImp::template Codim<codim>::Geometry Geometry;
//! level of this element
int level () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
//! index is unique and consecutive per level and codim used for access to degrees of freedom
int index () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
//! geometry of this entity
Geometry geometry () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
//! return partition type attribute
PartitionType partitionType () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
const GridImp * yaspgrid() const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
YaspEntity (const GridImp* yg, const YGLI& g, const TSI& it)
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
// IndexSets needs access to the private index methods
friend class Dune::YaspLevelIndexSet<GridImp>;
friend class Dune::YaspLeafIndexSet<GridImp>;
friend class Dune::YaspGlobalIdSet<GridImp>;
typedef typename GridImp::PersistentIndexType PersistentIndexType;
//! globally unique, persistent index
PersistentIndexType persistentIndex () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
//! consecutive, codim-wise, level-wise index
int compressedIndex () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
//! consecutive, codim-wise, level-wise index
int compressedLeafIndex () const
{
DUNE_THROW(GridError, "YaspEntity not implemented");
}
};
// specialization for codim=0
template<int dim, class GridImp>
class YaspEntity<0,dim,GridImp>
: public EntityDefaultImplementation <0,dim,GridImp,YaspEntity>
{
enum { dimworld = GridImp::dimensionworld };
typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
public:
typedef typename GridImp::ctype ctype;
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef typename GridImp::template Codim< 0 >::Geometry Geometry;
typedef typename GridImp::template Codim< 0 >::LocalGeometry LocalGeometry;
template <int cd>
struct Codim
{
typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
};
typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
typedef typename GridImp::LevelIntersectionIterator LevelIntersectionIterator;
typedef typename GridImp::LeafIntersectionIterator LeafIntersectionIterator;
typedef typename GridImp::HierarchicIterator HierarchicIterator;
//! define the type used for persisitent indices
typedef typename GridImp::PersistentIndexType PersistentIndexType;
//! define type used for coordinates in grid module
typedef typename YGrid<dim,ctype>::iTupel iTupel;
// constructor
YaspEntity (const GridImp * yg, const YGLI& g, const TSI& it)
: _yg(yg), _it(it), _g(g)
{
}
//! level of this element
int level () const { return _g.level(); }
//! index is unique and consecutive per level
int index () const { return _it.superindex(); } // superindex works also for iteration over subgrids
//! globalIndex is unique and consecutive per global level
int globalIndex () const {
return _g.cell_global().index(_it.coord());
}
/** \brief Return the entity seed which contains sufficient information
* to generate the entity again and uses as less memory as possible
*/
EntitySeed seed () const {
return EntitySeed(_g.level(), _it.coord());
}
//! return partition type attribute
PartitionType partitionType () const
{
if (_g.cell_interior().inside(_it.coord())) return InteriorEntity;
if (_g.cell_overlap().inside(_it.coord())) return OverlapEntity;
DUNE_THROW(GridError, "Impossible GhostEntity " << _it.coord() << "\t"
<< _g.cell_interior().origin() << "/" << _g.cell_interior().size());
return GhostEntity;
}
//! geometry of this entity
Geometry geometry () const {
// the element geometry
GeometryImpl _geometry(_it.position(),_it.meshsize());
return Geometry( _geometry );
}
/*! Return number of subentities with codimension cc.
*/
template<int cc> int count () const
{
if (cc==dim) return 1<<dim;
if (cc==1) return 2*dim;
if (cc==dim-1) return dim*(1<<(dim-1));
if (cc==0) return 1;
DUNE_THROW(GridError, "codim " << cc << " (dim=" << dim << ") not (yet) implemented");
}
/*! Intra-element access to subentities of codimension cc > codim.
*/
template<int cc>
typename Codim<cc>::EntityPointer subEntity (int i) const
{
dune_static_assert( cc == dim || cc == 0 ,
"YaspGrid only supports Entities with codim=dim and codim=0");
// coordinates of the cell == coordinates of lower left corner
if (cc==dim)
{
iTupel coord = _it.coord();
// get corner from there
for (int k=0; k<dim; k++)
if (i&(1<<k)) (coord[k])++;
return YaspEntityPointer<cc,GridImp>(_yg,_g,_g.vertex_overlapfront().tsubbegin(coord));
}
if (cc==0)
{
return YaspEntityPointer<cc,GridImp>(_yg,_g,_it);
}
DUNE_THROW(GridError, "codim " << cc << " (dim=" << dim << ") not (yet) implemented");
}
//! Inter-level access to father element on coarser grid. Assumes that meshes are nested.
EntityPointer father () const
{
// check if coarse level exists
if (_g.level()<=0)
DUNE_THROW(GridError, "tried to call father on level 0");
// yes, get iterator to it
YGLI cg = _g.coarser();
// coordinates of the cell
iTupel coord = _it.coord();
// get coordinates on next coarser level
for (int k=0; k<dim; k++) coord[k] = coord[k]/2;
return YaspEntityPointer<0,GridImp>(_yg,cg,cg.cell_overlap().tsubbegin(coord));
}
//! returns true if father entity exists
bool hasFather () const
{
return (_g.level()>0);
}
/*! Location of this element relative to the reference element element of the father.
This is sufficient to interpolate all dofs in conforming case.
Nonconforming case may require access to neighbors of father and
computations with local coordinates.
On the fly case is somewhat inefficient since dofs are visited several times.
If we store interpolation matrices, this is tolerable. We assume that on-the-fly
implementation of numerical algorithms is only done for simple discretizations.
Assumes that meshes are nested.
*/
LocalGeometry geometryInFather () const
{
// determine which son we are
int son = 0;
for (int k=0; k<dim; k++)
if (_it.coord(k)%2)
son += (1<<k);
// configure one of the 2^dim transformations
return LocalGeometry( YaspFatherRelativeLocalElement<dim,GridImp>::_geo[son] );
}
const TSI& transformingsubiterator () const
{
return _it;
}
const YGLI& gridlevel () const
{
return _g;
}
const GridImp* yaspgrid () const
{
return _yg;
}
bool isLeaf() const
{
return (_g.level() == _g.mg()->maxlevel());
}
/**\brief Returns true, if the entity has been created during the last call to adapt()
*/
bool isNew () const { return _yg->adaptRefCount > 0 && _g.mg()->maxlevel() < _g.level() + _yg->adaptRefCount; }
/**\brief Returns true, if entity might disappear during the next call to adapt()
*/
bool mightVanish () const { return false; }
// { return _yg->adaptRefCount < 0 && _g.mg()->maxlevel() < _g.level() - _yg->adaptRefCount; }
//! returns intersection iterator for first intersection
IntersectionIterator ibegin () const
{
return YaspIntersectionIterator<GridImp>(*this,false);
}
//! returns intersection iterator for first intersection
LeafIntersectionIterator ileafbegin () const
{
// only if entity is leaf this iterator delivers intersections
return YaspIntersectionIterator<GridImp>(*this, ! isLeaf() );
}
//! returns intersection iterator for first intersection
LevelIntersectionIterator ilevelbegin () const
{
return ibegin();
}
//! Reference to one past the last neighbor
IntersectionIterator iend () const
{
return YaspIntersectionIterator<GridImp>(*this,true);
}
//! Reference to one past the last neighbor
LeafIntersectionIterator ileafend () const
{
return iend();
}
//! Reference to one past the last neighbor
LevelIntersectionIterator ilevelend () const
{
return iend();
}
/*! Inter-level access to son elements on higher levels<=maxlevel.
This is provided for sparsely stored nested unstructured meshes.
Returns iterator to first son.
*/
HierarchicIterator hbegin (int maxlevel) const
{
return YaspHierarchicIterator<GridImp>(_yg,_g,_it,maxlevel);
}
//! Returns iterator to one past the last son
HierarchicIterator hend (int maxlevel) const
{
return YaspHierarchicIterator<GridImp>(_yg,_g,_it,_g.level());
}
private:
// IndexSets needs access to the private index methods
friend class Dune::YaspLevelIndexSet<GridImp>;
friend class Dune::YaspLeafIndexSet<GridImp>;
friend class Dune::YaspGlobalIdSet<GridImp>;
//! globally unique, persistent index
PersistentIndexType persistentIndex () const
{
// get size of global grid
const iTupel& size = _g.cell_global().size();
// get coordinate correction for periodic boundaries
int coord[dim];
for (int i=0; i<dim; i++)
{
coord[i] = _it.coord(i);
if (coord[i]<0) coord[i] += size[i];
if (coord[i]>=size[i]) coord[i] -= size[i];
}
// encode codim
PersistentIndexType id(0);
// encode level
id = id << yaspgrid_level_bits;
id = id+PersistentIndexType(_g.level());
// encode coordinates
for (int i=dim-1; i>=0; i--)
{
id = id << yaspgrid_dim_bits;
id = id+PersistentIndexType(coord[i]);
}
return id;
}
//! consecutive, codim-wise, level-wise index
int compressedIndex () const
{
return _it.superindex();
}
//! consecutive, codim-wise, level-wise index
int compressedLeafIndex () const
{
return _it.superindex();
}
//! subentity persistent index
PersistentIndexType subPersistentIndex (int i, int cc) const
{
if (cc==0)
return persistentIndex();
// get position of cell, note that global origin is zero
// adjust for periodic boundaries
int coord[dim];
for (int k=0; k<dim; k++)
{
coord[k] = _it.coord(k);
if (coord[k]<0) coord[k] += _g.cell_global().size(k);
if (coord[k]>=_g.cell_global().size(k)) coord[k] -= _g.cell_global().size(k);
}
if (cc==dim)
{
// transform to vertex coordinates
for (int k=0; k<dim; k++)
if (i&(1<<k)) (coord[k])++;
// determine min number of trailing zeroes
int trailing = 1000;
for (int i=0; i<dim; i++)
{
// count trailing zeros
int zeros = 0;
for (int j=0; j<_g.level(); j++)
if (coord[i]&(1<<j))
break;
else
zeros++;
trailing = std::min(trailing,zeros);
}
// determine the level of this vertex
int level = _g.level()-trailing;
// encode codim
PersistentIndexType id(dim);
// encode level
id = id << yaspgrid_level_bits;
id = id+PersistentIndexType(level);
// encode coordinates
for (int i=dim-1; i>=0; i--)
{
id = id << yaspgrid_dim_bits;
id = id+PersistentIndexType(coord[i]>>trailing);
}
return id;
}
if (cc==1) // faces, i.e. for dim=2 codim=1 is treated as a face
{
// Idea: Use the doubled grid to assign coordinates to faces
// ivar is the direction that varies
int ivar=i/2;
// compute position from cell position
for (int k=0; k<dim; k++)
coord[k] = coord[k]*2 + 1; // the doubled grid
if (i%2)
coord[ivar] += 1;
else
coord[ivar] -= 1;
// encode codim
PersistentIndexType id(1);
// encode level
id = id << yaspgrid_level_bits;
id = id+PersistentIndexType(_g.level());
// encode coordinates
for (int i=dim-1; i>=0; i--)
{
id = id << yaspgrid_dim_bits;
id = id+PersistentIndexType(coord[i]);
}
return id;
}
// map to old numbering
static unsigned int edge[ 12 ] = { 0, 1, 2, 3, 4, 5, 8, 9, 6, 7, 10, 11 };
i = edge[i];
if (cc==dim-1) // edges, exist only for dim>2
{
// Idea: direction i is fixed, all others are vary, i.e. 2^(dim-1) possibilities per direction
// number of entities per direction
int m=1<<(dim-1);
// ifix is the direction that is fixed
int ifix=(dim-1)-(i/m);
// compute position from cell position
int bit=1;
for (int k=0; k<dim; k++)
{
coord[k] = coord[k]*2+1; // cell position in doubled grid
if (k==ifix) continue;
if ((i%m)&bit) coord[k] += 1; else coord[k] -= 1;
bit *= 2;
}
// encode codim
PersistentIndexType id(dim-1);
// encode level
id = id << yaspgrid_level_bits;
id = id+PersistentIndexType(_g.level());
// encode coordinates
for (int i=dim-1; i>=0; i--)
{
id = id << yaspgrid_dim_bits;
id = id+PersistentIndexType(coord[i]);
}
return id;
}
DUNE_THROW(GridError, "codim " << cc << " (dim=" << dim << ") not (yet) implemented");
}
//! subentity compressed index
int subCompressedIndex (int i, int cc) const
{
if (cc==0)
return compressedIndex();
// get cell position relative to origin of local cell grid
iTupel coord;
for (int k=0; k<dim; ++k)
coord[k] = _it.coord(k)-_g.cell_overlap().origin(k);
if (cc==dim) // vertices
{
// transform cell coordinate to corner coordinate
for (int k=0; k<dim; k++)
if (i&(1<<k)) (coord[k])++;
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
index = (index*(_g.cell_overlap().size(k)+1))+coord[k];
return index;
}
if (cc==1) // faces, i.e. for dim=2 codim=1 is treated as a face
{
// Idea: direction ivar varies, all others are fixed, i.e. 2 possibilities per direction
// ivar is the direction that varies
int ivar=i/2;
// compute position from cell position
if (i%2) coord[ivar] += 1;
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
if (k==ivar)
index = (index*(_g.cell_overlap().size(k)+1))+coord[k]; // one more
else
index = (index*(_g.cell_overlap().size(k)))+coord[k];
// add size of all subsets for smaller directions
for (int j=0; j<ivar; j++)
{
int n=_g.cell_overlap().size(j)+1;
for (int l=0; l<dim; l++)
if (l!=j) n *= _g.cell_overlap().size(l);
index += n;
}
return index;
}
// map to old numbering
static unsigned int edge[ 12 ] = { 0, 1, 2, 3, 4, 5, 8, 9, 6, 7, 10, 11 };
i = edge[i];
if (cc==dim-1) // edges, exist only for dim>2
{
// Idea: direction i is fixed, all others are vary, i.e. 2^(dim-1) possibilities per direction
// number of entities per direction
int m=1<<(dim-1);
// ifix is the direction that is fixed
int ifix=(dim-1)-(i/m);
// compute position from cell position
int bit=1;
for (int k=0; k<dim; k++)
{
if (k==ifix) continue;
if ((i%m)&bit) coord[k] += 1;
bit *= 2;
}
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
if (k!=ifix)
index = (index*(_g.cell_overlap().size(k)+1))+coord[k]; // one more
else
index = (index*(_g.cell_overlap().size(k)))+coord[k];
// add size of all subsets for smaller directions
for (int j=dim-1; j>ifix; j--)
{
int n=_g.cell_overlap().size(j);
for (int l=0; l<dim; l++)
if (l!=j) n *= _g.cell_overlap().size(l)+1;
index += n;
}
return index;
}
DUNE_THROW(GridError, "codim " << cc << " (dim=" << dim << ") not (yet) implemented");
}
//! subentity compressed index
int subCompressedLeafIndex (int i, int cc) const
{
if (cc==0)
return compressedIndex();
// get cell position relative to origin of local cell grid
iTupel coord;
for (int k=0; k<dim; ++k)
coord[k] = _it.coord(k)-_g.cell_overlap().origin(k);
if (cc==dim) // vertices
{
// transform cell coordinate to corner coordinate
for (int k=0; k<dim; k++)
if (i&(1<<k)) (coord[k])++;
// move coordinates up to maxlevel
for (int k=0; k<dim; k++)
coord[k] = coord[k]<<(_g.mg()->maxlevel()-_g.level());
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
index = (index*(_g.mg()->rbegin().cell_overlap().size(k)+1))+coord[k];
return index;
}
if (cc==1) // faces, i.e. for dim=2 codim=1 is treated as a face
{
// Idea: direction ivar varies, all others are fixed, i.e. 2 possibilities per direction
// ivar is the direction that varies
int ivar=i/2;
// compute position from cell position
if (i%2) coord[ivar] += 1;
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
if (k==ivar)
index = (index*(_g.cell_overlap().size(k)+1))+coord[k]; // one more
else
index = (index*(_g.cell_overlap().size(k)))+coord[k];
// add size of all subsets for smaller directions
for (int j=0; j<ivar; j++)
{
int n=_g.cell_overlap().size(j)+1;
for (int l=0; l<dim; l++)
if (l!=j) n *= _g.cell_overlap().size(l);
index += n;
}
return index;
}
// map to old numbering
static unsigned int edge[ 12 ] = { 0, 1, 2, 3, 4, 5, 8, 9, 6, 7, 10, 11 };
i = edge[i];
if (cc==dim-1) // edges, exist only for dim>2
{
// Idea: direction i is fixed, all others are vary, i.e. 2^(dim-1) possibilities per direction
// number of entities per direction
int m=1<<(dim-1);
// ifix is the direction that is fixed
int ifix=(dim-1)-(i/m);
// compute position from cell position
int bit=1;
for (int k=0; k<dim; k++)
{
if (k==ifix) continue;
if ((i%m)&bit) coord[k] += 1;
bit *= 2;
}
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
if (k!=ifix)
index = (index*(_g.cell_overlap().size(k)+1))+coord[k]; // one more
else
index = (index*(_g.cell_overlap().size(k)))+coord[k];
// add size of all subsets for smaller directions
for (int j=dim-1; j>ifix; j--)
{
int n=_g.cell_overlap().size(j);
for (int l=0; l<dim; l++)
if (l!=j) n *= _g.cell_overlap().size(l)+1;
index += n;
}
return index;
}
DUNE_THROW(GridError, "codim " << cc << " (dim=" << dim << ") not (yet) implemented");
}
const GridImp * _yg; // access to YaspGrid
const TSI& _it; // position in the grid level
const YGLI& _g; // access to grid level
};
// specialization for codim=dim (vertex)
template<int dim, class GridImp>
class YaspEntity<dim,dim,GridImp>
: public EntityDefaultImplementation <dim,dim,GridImp,YaspEntity>
{
enum { dimworld = GridImp::dimensionworld };
typedef typename GridImp::Traits::template Codim<dim>::GeometryImpl GeometryImpl;
public:
typedef typename GridImp::ctype ctype;
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef typename GridImp::template Codim<dim>::Geometry Geometry;
template <int cd>
struct Codim
{
typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
};
typedef typename GridImp::template Codim<dim>::EntityPointer EntityPointer;
typedef typename GridImp::template Codim<dim>::EntitySeed EntitySeed;
//! define the type used for persisitent indices
typedef typename GridImp::PersistentIndexType PersistentIndexType;
//! define type used for coordinates in grid module
typedef typename YGrid<dim,ctype>::iTupel iTupel;
// constructor
YaspEntity (const GridImp* yg, const YGLI& g, const TSI& it)
: _yg(yg), _it(it), _g(g)
{}
//! level of this element
int level () const {return _g.level();}
//! index is unique and consecutive per level
int index () const {return _it.superindex();}
//! globally unique, persistent index
int globalIndex () const { return _g.cell_global().index(_it.coord()); }
/** \brief Return the entity seed which contains sufficient information
* to generate the entity again and uses as less memory as possible
*/
EntitySeed seed () const {
return EntitySeed(_g.level(), _it.coord());
}
//! geometry of this entity
Geometry geometry () const {
GeometryImpl _geometry(_it.position());
return Geometry( _geometry );
}
//! return partition type attribute
PartitionType partitionType () const
{
if (_g.vertex_interior().inside(_it.coord())) return InteriorEntity;
if (_g.vertex_interiorborder().inside(_it.coord())) return BorderEntity;
if (_g.vertex_overlap().inside(_it.coord())) return OverlapEntity;
if (_g.vertex_overlapfront().inside(_it.coord())) return FrontEntity;
return GhostEntity;
}
private:
// IndexSets needs access to the private index methods
friend class Dune::YaspLevelIndexSet<GridImp>;
friend class Dune::YaspLeafIndexSet<GridImp>;
friend class Dune::YaspGlobalIdSet<GridImp>;
//! globally unique, persistent index
PersistentIndexType persistentIndex () const
{
// get coordinate and size of global grid
const iTupel& size = _g.vertex_global().size();
int coord[dim];
// correction for periodic boundaries
for (int i=0; i<dim; i++)
{
coord[i] = _it.coord(i);
if (coord[i]<0) coord[i] += size[i];
if (coord[i]>=size[i]) coord[i] -= size[i];
}
// determine min number of trailing zeroes
int trailing = 1000;
for (int i=0; i<dim; i++)
{
// count trailing zeros
int zeros = 0;
for (int j=0; j<_g.level(); j++)
if (coord[i]&(1<<j))
break;
else
zeros++;
trailing = std::min(trailing,zeros);
}
// determine the level of this vertex
int level = _g.level()-trailing;
// encode codim
PersistentIndexType id(dim);
// encode level
id = id << yaspgrid_level_bits;
id = id+PersistentIndexType(level);
// encode coordinates
for (int i=dim-1; i>=0; i--)
{
id = id << yaspgrid_dim_bits;
id = id+PersistentIndexType(coord[i]>>trailing);
}
return id;
}
//! consecutive, codim-wise, level-wise index
int compressedIndex () const { return _it.superindex();}
//! consecutive, codim-wise, level-wise index
int compressedLeafIndex () const
{
if (_g.level()==_g.mg()->maxlevel())
return _it.superindex();
// not on leaf level, interpolate to finest grid
int coord[dim];
for (int i=0; i<dim; i++) coord[i] = _it.coord(i)-(_g).vertex_overlap().origin(i);
// move coordinates up to maxlevel (multiply by 2 for each level
for (int k=0; k<dim; k++)
coord[k] = coord[k]*(1<<(_g.mg()->maxlevel()-_g.level()));
// do lexicographic numbering
int index = coord[dim-1];
for (int k=dim-2; k>=0; --k)
index = (index*(_g.mg()->rbegin().cell_overlap().size(k)+1))+coord[k];
return index;
}
public:
const TSI& transformingsubiterator() const { return _it; }
const YGLI& gridlevel() const { return _g; }
const GridImp * yaspgrid() const { return _yg; }
protected:
const GridImp * _yg; // access to YaspGrid
const TSI& _it; // position in the grid level
const YGLI& _g; // access to grid level
// temporary object
mutable FieldVector<ctype, dim> loc; // always computed before being returned
};
//========================================================================
/*!
YaspIntersection provides data about intersection with
neighboring codim 0 entities.
*/
//========================================================================
template<class GridImp>
class YaspIntersection
{
enum { dim=GridImp::dimension };
enum { dimworld=GridImp::dimensionworld };
typedef typename GridImp::ctype ctype;
YaspIntersection();
YaspIntersection& operator = (const YaspIntersection&);
typedef typename GridImp::Traits::template Codim< 1 >::GeometryImpl GeometryImpl;
typedef typename GridImp::Traits::template Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
public:
// types used from grids
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef typename GridImp::template Codim<0>::Entity Entity;
typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
typedef typename GridImp::template Codim<1>::Geometry Geometry;
typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
typedef YaspSpecialEntity<0,dim,GridImp> SpecialEntity;
typedef Dune::Intersection<const GridImp, Dune::YaspIntersectionIterator> Intersection;
// void update() const {
// const_cast<YaspIntersection*>(this)->update();
// }
void update() const {
if (_count == 2*_dir + _face || _count >= 2*dim)
return;
// cleanup old stuff
_outside.transformingsubiterator().move(_dir,1-2*_face); // move home
_pos_world[_dir] = _inside.transformingsubiterator().position(_dir);
// update face info
_dir = _count / 2;
_face = _count % 2;
// move transforming iterator
_outside.transformingsubiterator().move(_dir,-1+2*_face);
// make up faces
_pos_world[_dir] += (-0.5+_face)*_inside.transformingsubiterator().meshsize(_dir);
}
//! increment
void increment() {
_count += (_count < 2*dim);
}
//! equality
bool equals (const YaspIntersection& other) const
{
return _inside.equals(other._inside) && _count == other._count;
}
/*! return true if neighbor ist outside the domain. Still the neighbor might
exist in case of periodic boundary conditions, i.e. true is returned
if the neighbor is outside the periodic unit cell
*/
bool boundary () const
{
#if 1
return (_inside.transformingsubiterator().coord(_count/2) + 2*(_count%2) - 1 < _inside.gridlevel().cell_global().min(_count/2)
||
_inside.transformingsubiterator().coord(_count/2) + 2*(_count%2) - 1 > _inside.gridlevel().cell_global().max(_count/2));
#else
update();
// The transforming iterator can be safely moved beyond the boundary.
// So we only have to compare against the cell_global grid
return (_outside.transformingsubiterator().coord(_dir) < _inside.gridlevel().cell_global().min(_dir)
||
_outside.transformingsubiterator().coord(_dir) > _inside.gridlevel().cell_global().max(_dir));
#endif
}
//! return true if neighbor across intersection exists in this processor
bool neighbor () const
{
#if 1
return (_inside.transformingsubiterator().coord(_count/2) + 2*(_count%2) - 1 >= _inside.gridlevel().cell_overlap().min(_count/2)
&&
_inside.transformingsubiterator().coord(_count/2) + 2*(_count%2) - 1 <= _inside.gridlevel().cell_overlap().max(_count/2));
#else
update();
return (_outside.transformingsubiterator().coord(_dir) >= _inside.gridlevel().cell_overlap().min(_dir)
&&
_outside.transformingsubiterator().coord(_dir) <= _inside.gridlevel().cell_overlap().max(_dir));
#endif
}
//! Yasp is always conform
bool conforming () const
{
return true;
}
//! return EntityPointer to the Entity on the inside of this intersection
//! (that is the Entity where we started this Iterator)
EntityPointer inside() const
{
return _inside;
}
//! return EntityPointer to the Entity on the outside of this intersection
//! (that is the neighboring Entity)
EntityPointer outside() const
{
update();
return _outside;
}
//! identifier for boundary segment from macro grid
//! (attach your boundary condition as needed)
int boundaryId() const
{
if(boundary()) return indexInInside()+1;
return 0;
}
//! identifier for boundary segment from macro grid
//! (attach your boundary condition as needed)
int boundarySegmentIndex() const
{
if(! boundary())
DUNE_THROW(GridError, "called boundarySegmentIndex while boundary() == false");
update();
// size of local macro grid
const FieldVector<int, dim> & size = _inside.gridlevel().mg()->begin().cell_overlap().size();
const FieldVector<int, dim> & origin = _inside.gridlevel().mg()->begin().cell_overlap().origin();
FieldVector<int, dim> sides;
{
for (int i=0; i<dim; i++)
{
sides[i] =
((_inside.gridlevel().mg()->begin().cell_overlap().origin(i)
== _inside.gridlevel().mg()->begin().cell_global().origin(i))+
(_inside.gridlevel().mg()->begin().cell_overlap().origin(i) +
_inside.gridlevel().mg()->begin().cell_overlap().size(i)
== _inside.gridlevel().mg()->begin().cell_global().origin(i) +
_inside.gridlevel().mg()->begin().cell_global().size(i)));
}
}
// gobal position of the cell on macro grid
FieldVector<int, dim> pos = _inside.transformingsubiterator().coord();
pos /= (1<<_inside.level());
pos -= origin;
// compute unit-cube-face-sizes
FieldVector<int, dim> fsize;
{
int vol = 1;
for (int k=0; k<dim; k++)
vol *= size[k];
for (int k=0; k<dim; k++)
fsize[k] = vol/size[k];
}
// compute index in the unit-cube-face
int index = 0;
{
int localoffset = 1;
for (int k=dim-1; k>=0; k--)
{
if (k == _dir) continue;
index += (pos[k]) * localoffset;
localoffset *= size[k];
}
}
// add unit-cube-face-offsets
{
for (int k=0; k<_dir; k++)
index += sides[k] * fsize[k];
// add fsize if we are on the right face and there is a left-face-boundary on this processor
index += _face * (sides[_dir]>1) * fsize[_dir];
}
// int rank = 0;
// MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// std::cout << rank << "... size: " << size << " sides: " << sides
// << " fsize: " << fsize
// << " pos: " << pos << " face: " << int(_dir) << "/" << int(_face)
// << " index: " << index << std::endl;
return index;
}
//! return unit outer normal, this should be dependent on local coordinates for higher order boundary
FieldVector<ctype, dimworld> outerNormal (const FieldVector<ctype, dim-1>& local) const
{
return _faceInfo[_count].normal;
}
//! return unit outer normal, this should be dependent on local coordinates for higher order boundary
FieldVector<ctype, dimworld> unitOuterNormal (const FieldVector<ctype, dim-1>& local) const
{
return _faceInfo[_count].normal;
}
//! return unit outer normal at center of intersection geometry
FieldVector<ctype, dimworld> centerUnitOuterNormal () const
{
return _faceInfo[_count].normal;
}
//! return unit outer normal, this should be dependent on
//! local coordinates for higher order boundary
//! the normal is scaled with the integration element of the intersection.
FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const
{
FieldVector<ctype, dimworld> n = _faceInfo[_count].normal;
n *= geometry().volume();
return n;
}
/*! intersection of codimension 1 of this neighbor with element where iteration started.
Here returned element is in LOCAL coordinates of the element where iteration started.
*/
LocalGeometry geometryInInside () const
{
return LocalGeometry( _faceInfo[_count].geom_inside );
}
/*! intersection of codimension 1 of this neighbor with element where iteration started.
Here returned element is in LOCAL coordinates of neighbor
*/
LocalGeometry geometryInOutside () const
{
return LocalGeometry( _faceInfo[_count].geom_outside );
}
/*! intersection of codimension 1 of this neighbor with element where iteration started.
*/
Geometry geometry () const
{
update();
GeometryImpl
_is_global(_pos_world,_inside.transformingsubiterator().meshsize(),_dir);
return Geometry( _is_global );
}
/** \brief obtain the type of reference element for this intersection */
GeometryType type () const
{
static const GeometryType cube(GeometryType::cube, dim-1);
return cube;
}
//! local index of codim 1 entity in self where intersection is contained in
int indexInInside () const
{
return _count;
}
//! local index of codim 1 entity in neighbor where intersection is contained in
int indexInOutside () const
{
// flip the last bit
return _count^1;
}
//! make intersection iterator from entity, initialize to first neighbor
YaspIntersection (const YaspEntity<0,dim,GridImp>& myself, bool toend) :
_inside(myself.yaspgrid(), myself.gridlevel(),
myself.transformingsubiterator()),
_outside(myself.yaspgrid(), myself.gridlevel(),
myself.transformingsubiterator()),
// initialize to first neighbor
_count(0),
_dir(0),
_face(0),
_pos_world(myself.transformingsubiterator().position())
{
if (toend)
{
// initialize end iterator
_count = 2*dim;
return;
}
_count = 0;
// move transforming iterator
_outside.transformingsubiterator().move(_dir,-1);
// make up faces
_pos_world[0] -= 0.5*_inside.transformingsubiterator().meshsize(0);
}
//! copy constructor
YaspIntersection (const YaspIntersection& it) :
_inside(it._inside),
_outside(it._outside),
_count(it._count),
_dir(it._dir),
_face(it._face),
_pos_world(it._pos_world)
{}
//! copy operator
void assign (const YaspIntersection& it)
{
_inside = it._inside;
_outside = it._outside;
_count = it._count;
_dir = it._dir;
_face = it._face;
_pos_world = it._pos_world;
}
private:
/* EntityPointers (get automatically updated) */
mutable YaspEntityPointer<0,GridImp> _inside; //!< entitypointer to myself
mutable YaspEntityPointer<0,GridImp> _outside; //!< outside entitypointer
/* current position */
uint8_t _count; //!< valid neighbor count in 0 .. 2*dim-1
mutable uint8_t _dir; //!< count/2
mutable uint8_t _face; //!< count%2
/* current position */
mutable FieldVector<ctype, dimworld> _pos_world; //!< center of face in world coordinates
/* static data */
struct faceInfo
{
FieldVector<ctype, dimworld> normal;
LocalGeometryImpl geom_inside; //!< intersection in own local coordinates
LocalGeometryImpl geom_outside; //!< intersection in neighbors local coordinates
};
/* static face info */
static const array<faceInfo, 2*GridImp::dimension> _faceInfo;
static array<faceInfo, 2*dim> initFaceInfo()
{
const FieldVector<typename GridImp::ctype, GridImp::dimension> ext_local(1.0);
array<faceInfo, 2*dim> I;
for (uint8_t i=0; i<dim; i++)
{
// center of face
FieldVector<ctype, dim> a(0.5); a[i] = 0.0;
FieldVector<ctype, dim> b(0.5); b[i] = 1.0;
// normal vectors
I[2*i].normal = 0.0;
I[2*i+1].normal = 0.0;
I[2*i].normal[i] = -1.0;
I[2*i+1].normal[i] = +1.0;
// geometries
I[2*i].geom_inside =
LocalGeometryImpl(a, ext_local, i);
I[2*i].geom_outside =
LocalGeometryImpl(b, ext_local, i);
I[2*i+1].geom_inside =
LocalGeometryImpl(b, ext_local, i);
I[2*i+1].geom_outside =
LocalGeometryImpl(a, ext_local, i);
}
return I;
}
};
template<class GridImp>
const array<typename YaspIntersection<GridImp>::faceInfo, 2*GridImp::dimension>
YaspIntersection<GridImp>::_faceInfo =
YaspIntersection<GridImp>::initFaceInfo();
//========================================================================
/*!
YaspIntersectionIterator enables iteration over intersection with
neighboring codim 0 entities.
*/
//========================================================================
template<class GridImp>
class YaspIntersectionIterator : public MakeableInterfaceObject< Dune::Intersection<const GridImp, Dune::YaspIntersection > >
{
enum { dim=GridImp::dimension };
enum { dimworld=GridImp::dimensionworld };
typedef typename GridImp::ctype ctype;
YaspIntersectionIterator();
public:
// types used from grids
typedef Dune::Intersection<const GridImp, Dune::YaspIntersection> Intersection;
typedef MakeableInterfaceObject<Intersection> MakeableIntersection;
//! increment
void increment()
{
GridImp::getRealImplementation(*this).increment();
}
//! equality
bool equals (const YaspIntersectionIterator& other) const
{
return GridImp::getRealImplementation(*this).equals(
GridImp::getRealImplementation(other));
}
//! \brief dereferencing
const Intersection & dereference() const
{
return *this;
}
//! make intersection iterator from entity
YaspIntersectionIterator (const YaspEntity<0,dim,GridImp>& myself, bool toend) :
MakeableIntersection(YaspIntersection<GridImp>(myself, toend))
{}
//! copy constructor
YaspIntersectionIterator (const YaspIntersectionIterator& it) :
MakeableIntersection(it)
{}
//! assignment
YaspIntersectionIterator & operator = (const YaspIntersectionIterator& it)
{
GridImp::getRealImplementation(*this).assign(
GridImp::getRealImplementation(it));
return *this;
}
};
//========================================================================
/*!
YaspHierarchicIterator enables iteration over son entities of codim 0
*/
//========================================================================
template<class GridImp>
class YaspHierarchicIterator :
public YaspEntityPointer<0,GridImp>
{
enum { dim=GridImp::dimension };
enum { dimworld=GridImp::dimensionworld };
typedef typename GridImp::ctype ctype;
public:
// types used from grids
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef typename GridImp::template Codim<0>::Entity Entity;
typedef YaspSpecialEntity<0,dim,GridImp> SpecialEntity;
//! define type used for coordinates in grid module
typedef typename YGrid<dim,ctype>::iTupel iTupel;
//! constructor
YaspHierarchicIterator (const GridImp* yg, const YGLI& g, const TSI& it, int maxlevel) :
YaspEntityPointer<0,GridImp>(yg,g,it)
{
// now iterator points to current cell
StackElem se(this->_g);
se.coord = this->_it.coord();
stack.push(se);
// determine maximum level
_maxlevel = std::min(maxlevel,this->_g.mg()->maxlevel());
// if maxlevel not reached then push yourself and sons
if (this->_g.level()<_maxlevel)
{
push_sons();
}
// and make iterator point to first son if stack is not empty
if (!stack.empty())
pop_tos();
}
//! constructor
YaspHierarchicIterator (const YaspHierarchicIterator& it) :
YaspEntityPointer<0,GridImp>(it),
_maxlevel(it._maxlevel), stack(it.stack)
{}
//! increment
void increment ()
{
// sanity check: do nothing when stack is empty
if (stack.empty()) return;
// if maxlevel not reached then push sons
if (this->_g.level()<_maxlevel)
push_sons();
// in any case pop one element
pop_tos();
}
void print (std::ostream& s) const
{
s << "HIER: " << "level=" << this->_g.level()
<< " position=" << this->_it.coord()
<< " superindex=" << this->_it.superindex()
<< " maxlevel=" << this->_maxlevel
<< " stacksize=" << stack.size()
<< std::endl;
}
private:
int _maxlevel; //!< maximum level of elements to be processed
struct StackElem {
YGLI g; // grid level of the element
iTupel coord; // and the coordinates
StackElem(YGLI gg) : g(gg) {}
};
std::stack<StackElem> stack; //!< stack holding elements to be processed
// push sons of current element on the stack
void push_sons ()
{
// yes, process all 1<<dim sons
StackElem se(this->_g.finer());
for (int i=0; i<(1<<dim); i++)
{
for (int k=0; k<dim; k++)
if (i&(1<<k))
se.coord[k] = this->_it.coord(k)*2+1;
else
se.coord[k] = this->_it.coord(k)*2;
stack.push(se);
}
}
// make TOS the current element
void pop_tos ()
{
StackElem se = stack.top();
stack.pop();
this->_g = se.g;
this->_it.reinit(this->_g.cell_overlap(),se.coord);
}
};
//========================================================================
/*!
YaspEntitySeed describes the minimal information necessary to create a fully functional YaspEntity
*/
//========================================================================
template<int codim, class GridImp>
class YaspEntitySeed
{
//! know your own dimension
enum { dim=GridImp::dimension };
public:
//! codimension of entity pointer
enum { codimension = codim };
//! constructor
YaspEntitySeed (int level, FieldVector<int, dim> coord)
: _l(level), _c(coord)
{}
//! copy constructor
YaspEntitySeed (const YaspEntitySeed& rhs)
: _l(rhs._l), _c(rhs._c)
{}
int level () const { return _l; }
const FieldVector<int, dim> & coord() const { return _c; }
protected:
int _l; // grid level
FieldVector<int, dim> _c; // coord in the global grid
};
//========================================================================
/*!
YaspEntityPointer serves as a Reference or Pointer to a YaspGrid::Entity.
It can also be initialized from Yasp::LevelIterator, Yasp::LeafIterator,
Yasp::HierarchicIterator and Yasp::IntersectionIterator.
We have specializations for codim==0 (elements) and
codim=dim (vertices).
The general version throws a GridError.
*/
//========================================================================
template<int codim, class GridImp>
class YaspEntityPointer
{
//! know your own dimension
enum { dim=GridImp::dimension };
//! know your own dimension of world
enum { dimworld=GridImp::dimensionworld };
typedef typename GridImp::ctype ctype;
public:
typedef typename GridImp::template Codim<codim>::Entity Entity;
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef YaspSpecialEntity<codim,dim,GridImp> SpecialEntity;
typedef YaspEntityPointer<codim,GridImp> EntityPointerImp;
protected:
typedef YaspEntity<codim, dim, GridImp> YaspEntityImp;
public:
//! codimension of entity pointer
enum { codimension = codim };
//! constructor
YaspEntityPointer (const GridImp * yg, const YGLI & g, const TSI & it)
: _g(g), _it(it), _entity(yg, _g,_it)
{
if (codim>0 && codim<dim)
{
DUNE_THROW(GridError, "YaspEntityPointer: codim not implemented");
}
}
//! copy constructor
YaspEntityPointer (const YaspEntityImp& entity)
: _g(entity.gridlevel()),
_it(entity.transformingsubiterator()),
_entity(entity.yaspgrid(),_g,_it)
{
if (codim>0 && codim<dim)
{
DUNE_THROW(GridError, "YaspEntityPointer: codim not implemented");
}
}
//! copy constructor
YaspEntityPointer (const YaspEntityPointer& rhs)
: _g(rhs._g), _it(rhs._it), _entity(rhs._entity.yaspgrid(),_g,_it)
{
if (codim>0 && codim<dim)
{
DUNE_THROW(GridError, "YaspEntityPointer: codim not implemented");
}
}
//! equality
bool equals (const YaspEntityPointer& rhs) const
{
return (_it==rhs._it && _g == rhs._g);
}
//! dereferencing
Entity& dereference() const
{
return _entity;
}
//! ask for level of entity
int level () const {return _g.level();}
const YaspEntityPointer&
operator = (const YaspEntityPointer& rhs)
{
_g = rhs._g;
_it = rhs._it;
/* _entity = i._entity
* is done implicitely, as the entity is completely
* defined via the interator it belongs to
*/
return *this;
}
const TSI& transformingsubiterator () const
{
return _it;
}
const YGLI& gridlevel () const
{
return _g;
}
TSI& transformingsubiterator ()
{
return _it;
}
YGLI& gridlevel ()
{
return _g;
}
protected:
YGLI _g; // access to grid level
TSI _it; // position in the grid level
mutable SpecialEntity _entity; //!< virtual entity
};
//========================================================================
/*!
YaspLevelIterator enables iteration over entities of one grid level
We have specializations for codim==0 (elements) and
codim=dim (vertices).
The general version throws a GridError.
*/
//========================================================================
template<int codim, PartitionIteratorType pitype, class GridImp>
class YaspLevelIterator :
public YaspEntityPointer<codim,GridImp>
{
//! know your own dimension
enum { dim=GridImp::dimension };
//! know your own dimension of world
enum { dimworld=GridImp::dimensionworld };
typedef typename GridImp::ctype ctype;
public:
typedef typename GridImp::template Codim<codim>::Entity Entity;
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef YaspSpecialEntity<codim,dim,GridImp> SpecialEntity;
//! constructor
YaspLevelIterator (const GridImp * yg, const YGLI & g, const TSI & it) :
YaspEntityPointer<codim,GridImp>(yg,g,it) {}
//! copy constructor
YaspLevelIterator (const YaspLevelIterator& i) :
YaspEntityPointer<codim,GridImp>(i) {}
//! increment
void increment()
{
++(this->_it);
}
};
//========================================================================
/*!
\brief level-wise, non-persistent, consecutive index
*/
//========================================================================
template<class GridImp>
class YaspLevelIndexSet
: public IndexSet< GridImp, YaspLevelIndexSet< GridImp >, unsigned int >
{
typedef YaspLevelIndexSet< GridImp > This;
typedef IndexSet< GridImp, This, unsigned int > Base;
public:
typedef typename Base::IndexType IndexType;
using Base::subIndex;
//! constructor stores reference to a grid and level
YaspLevelIndexSet ( const GridImp &g, int l )
: grid( g ),
level( l )
{
// contains a single element type;
for (int codim=0; codim<=GridImp::dimension; codim++)
mytypes[codim].push_back(GeometryType(GeometryType::cube,GridImp::dimension-codim));
}
//! get index of an entity
template<int cc>
IndexType index (const typename GridImp::Traits::template Codim<cc>::Entity& e) const
{
assert( cc == 0 || cc == GridImp::dimension );
return grid.getRealImplementation(e).compressedIndex();
}
//! get index of subentity of an entity
template< int cc >
IndexType subIndex ( const typename remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e,
int i, unsigned int codim ) const
{
assert( cc == 0 || cc == GridImp::dimension );
if( cc == GridImp::dimension )
return grid.getRealImplementation(e).compressedIndex();
else
return grid.getRealImplementation(e).subCompressedIndex(i,codim);
}
//! get number of entities of given type and level (the level is known to the object)
int size (GeometryType type) const
{
return grid.size( level, type );
}
//! return size of set for a given codim
int size (int codim) const
{
return grid.size( level, codim );
}
//! return true if the given entity is contained in \f$E\f$.
template<class EntityType>
bool contains (const EntityType& e) const
{
return e.level() == level;
}
//! deliver all geometry types used in this grid
const std::vector<GeometryType>& geomTypes (int codim) const
{
return mytypes[codim];
}
private:
const GridImp& grid;
int level;
std::vector<GeometryType> mytypes[GridImp::dimension+1];
};
// Leaf Index Set
template<class GridImp>
class YaspLeafIndexSet
: public IndexSet< GridImp, YaspLeafIndexSet< GridImp >, unsigned int >
{
typedef YaspLeafIndexSet< GridImp > This;
typedef IndexSet< GridImp, This, unsigned int > Base;
public:
typedef typename Base::IndexType IndexType;
using Base::subIndex;
//! constructor stores reference to a grid
explicit YaspLeafIndexSet ( const GridImp &g )
: grid( g )
{
// contains a single element type;
for (int codim=0; codim<=GridImp::dimension; codim++)
mytypes[codim].push_back(GeometryType(GeometryType::cube,GridImp::dimension-codim));
}
//! get index of an entity
template<int cc>
IndexType index (const typename GridImp::Traits::template Codim<cc>::Entity& e) const
{
assert( cc == 0 || cc == GridImp::dimension );
return grid.getRealImplementation(e).compressedIndex();
}
//! get index of subentity of an entity
template< int cc >
IndexType subIndex ( const typename remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e,
int i, unsigned int codim ) const
{
assert( cc == 0 || cc == GridImp::dimension );
if( cc == GridImp::dimension )
return grid.getRealImplementation(e).compressedIndex();
else
return grid.getRealImplementation(e).subCompressedIndex(i,codim);
}
//! get number of entities of given type
int size (GeometryType type) const
{
return grid.size( grid.maxLevel(), type );
}
//! return size of set for a given codim
int size (int codim) const
{
return grid.size( grid.maxLevel(), codim );
}
//! return true if the given entity is contained in \f$E\f$.
template<class EntityType>
bool contains (const EntityType& e) const
{
//return e.isLeaf();
return (e.level() == grid.maxLevel());
}
//! deliver all geometry types used in this grid
const std::vector<GeometryType>& geomTypes (int codim) const
{
return mytypes[codim];
}
private:
const GridImp& grid;
enum { ncodim = remove_const<GridImp>::type::dimension+1 };
std::vector<GeometryType> mytypes[ncodim];
};
//========================================================================
/*!
\brief persistent, globally unique Ids
*/
//========================================================================
template<class GridImp>
class YaspGlobalIdSet : public IdSet<GridImp,YaspGlobalIdSet<GridImp>,
typename remove_const<GridImp>::type::PersistentIndexType >
/*
We used the remove_const to extract the Type from the mutable class,
because the const class is not instantiated yet.
*/
{
typedef YaspGlobalIdSet< GridImp > This;
public:
//! define the type used for persisitent indices
typedef typename remove_const<GridImp>::type::PersistentIndexType IdType;
using IdSet<GridImp, This, IdType>::subId;
//! constructor stores reference to a grid
explicit YaspGlobalIdSet ( const GridImp &g )
: grid( g )
{}
//! get id of an entity
/*
We use the remove_const to extract the Type from the mutable class,
because the const class is not instantiated yet.
*/
template<int cd>
IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
{
return grid.getRealImplementation(e).persistentIndex();
}
//! get id of subentity
/*
We use the remove_const to extract the Type from the mutable class,
because the const class is not instantiated yet.
*/
IdType subId (const typename remove_const<GridImp>::type::Traits::template Codim< 0 >::Entity &e,
int i, unsigned int codim ) const
{
return grid.getRealImplementation(e).subPersistentIndex(i,codim);
}
private:
const GridImp& grid;
};
template<int dim, int dimworld>
struct YaspGridFamily
{
#if HAVE_MPI
typedef CollectiveCommunication<MPI_Comm> CCType;
#else
typedef CollectiveCommunication<Dune::YaspGrid<dim> > CCType;
#endif
typedef GridTraits<dim,dimworld,Dune::YaspGrid<dim>,
YaspGeometry,YaspEntity,
YaspEntityPointer,YaspLevelIterator,
YaspIntersection, // leaf intersection
YaspIntersection, // level intersection
YaspIntersectionIterator, // leaf intersection iter
YaspIntersectionIterator, // level intersection iter
YaspHierarchicIterator,
YaspLevelIterator,
YaspLevelIndexSet< const YaspGrid< dim > >,
YaspLeafIndexSet< const YaspGrid< dim > >,
YaspGlobalIdSet<const YaspGrid<dim> >,
bigunsignedint<dim*yaspgrid_dim_bits+yaspgrid_level_bits+yaspgrid_codim_bits>,
YaspGlobalIdSet<const YaspGrid<dim> >,
bigunsignedint<dim*yaspgrid_dim_bits+yaspgrid_level_bits+yaspgrid_codim_bits>,
CCType,
DefaultLevelGridViewTraits, DefaultLeafGridViewTraits,
YaspEntitySeed>
Traits;
};
template<int dim, int codim>
struct YaspCommunicateMeta {
template<class G, class DataHandle>
static void comm (const G& g, DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level)
{
if (data.contains(dim,codim))
{
DUNE_THROW(GridError, "interface communication not implemented");
}
YaspCommunicateMeta<dim,codim-1>::comm(g,data,iftype,dir,level);
}
};
template<int dim>
struct YaspCommunicateMeta<dim,dim> {
template<class G, class DataHandle>
static void comm (const G& g, DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level)
{
if (data.contains(dim,dim))
g.template communicateCodim<DataHandle,dim>(data,iftype,dir,level);
YaspCommunicateMeta<dim,dim-1>::comm(g,data,iftype,dir,level);
}
};
template<int dim>
struct YaspCommunicateMeta<dim,0> {
template<class G, class DataHandle>
static void comm (const G& g, DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level)
{
if (data.contains(dim,0))
g.template communicateCodim<DataHandle,0>(data,iftype,dir,level);
}
};
//************************************************************************
/*!
\brief [<em> provides \ref Dune::Grid </em>]
\brief Provides a distributed structured cube mesh.
\ingroup GridImplementations
YaspGrid stands for yet another structured parallel grid.
It implements the dune grid interface for structured grids with codim 0
and dim, with arbitrary overlap (including zero),
periodic boundaries and fast implementation allowing on-the-fly computations.
\tparam dim The dimension of the grid and its surrounding world
\par History:
\li started on July 31, 2004 by PB based on abstractions developed in summer 2003
*/
template<int dim>
class YaspGrid :
public GridDefaultImplementation<dim,dim,yaspgrid_ctype,YaspGridFamily<dim,dim> >,
public MultiYGrid<dim,yaspgrid_ctype>
{
typedef const YaspGrid<dim> GridImp;
void init()
{
setsizes();
indexsets.push_back( new YaspLevelIndexSet<const YaspGrid<dim> >(*this,0) );
theleafindexset.push_back( new YaspLeafIndexSet<const YaspGrid<dim> >(*this) );
theglobalidset.push_back( new YaspGlobalIdSet<const YaspGrid<dim> >(*this) );
boundarysegmentssize();
}
void boundarysegmentssize()
{
// sizes of local macro grid
const FieldVector<int, dim> & size = MultiYGrid<dim,ctype>::begin().cell_overlap().size();
FieldVector<int, dim> sides;
{
for (int i=0; i<dim; i++)
{
sides[i] =
((MultiYGrid<dim,ctype>::begin().cell_overlap().origin(i)
== MultiYGrid<dim,ctype>::begin().cell_global().origin(i))+
(MultiYGrid<dim,ctype>::begin().cell_overlap().origin(i) +
MultiYGrid<dim,ctype>::begin().cell_overlap().size(i)
== MultiYGrid<dim,ctype>::begin().cell_global().origin(i) +
MultiYGrid<dim,ctype>::begin().cell_global().size(i)));
}
}
nBSegments = 0;
for (int k=0; k<dim; k++)
{
int offset = 1;
for (int l=0; l<dim; l++)
{
if (l==k) continue;
offset *= size[l];
}
nBSegments += sides[k]*offset;
}
}
public:
using MultiYGrid<dim,yaspgrid_ctype>::defaultLoadbalancer;
//! define type used for coordinates in grid module
typedef yaspgrid_ctype ctype;
// define the persistent index type
typedef bigunsignedint<dim*yaspgrid_dim_bits+yaspgrid_level_bits+yaspgrid_codim_bits> PersistentIndexType;
//! the GridFamily of this grid
typedef YaspGridFamily<dim,dim> GridFamily;
// the Traits
typedef typename YaspGridFamily<dim,dim>::Traits Traits;
// need for friend declarations in entity
typedef YaspLevelIndexSet<YaspGrid<dim> > LevelIndexSetType;
typedef YaspLeafIndexSet<YaspGrid<dim> > LeafIndexSetType;
typedef YaspGlobalIdSet<YaspGrid<dim> > GlobalIdSetType;
//! maximum number of levels allowed
enum { MAXL=64 };
//! shorthand for base class data types
typedef MultiYGrid<dim,ctype> YMG;
typedef typename MultiYGrid<dim,ctype>::YGridLevelIterator YGLI;
typedef typename SubYGrid<dim,ctype>::TransformingSubIterator TSI;
typedef typename MultiYGrid<dim,ctype>::Intersection IS;
typedef typename std::deque<IS>::const_iterator ISIT;
/*! Constructor for a YaspGrid, they are all forwarded to the base class
@param comm MPI communicator where this mesh is distributed to
@param L extension of the domain
@param s number of cells on coarse mesh in each direction
@param periodic tells if direction is periodic or not
@param overlap size of overlap on coarsest grid (same in all directions)
@param lb pointer to an overloaded YLoadBalance instance
*/
YaspGrid (Dune::MPIHelper::MPICommunicator comm,
Dune::FieldVector<ctype, dim> L,
Dune::FieldVector<int, dim> s,
Dune::FieldVector<bool, dim> periodic, int overlap,
const YLoadBalance<dim>* lb = defaultLoadbalancer())
#if HAVE_MPI
: YMG(comm,L,s,periodic,overlap,lb), ccobj(comm),
keep_ovlp(true), adaptRefCount(0), adaptActive(false)
#else
: YMG(L,s,periodic,overlap,lb),
keep_ovlp(true), adaptRefCount(0), adaptActive(false)
#endif
{
init();
}
/*! Constructor for a sequential YaspGrid, they are all forwarded to the base class.
Sequential here means that the whole grid is living on one process even if your program is running
in parallel.
@see YaspGrid(Dune::MPIHelper::MPICommunicator, Dune::FieldVector<ctype, dim>, Dune::FieldVector<int, dim>, Dune::FieldVector<bool, dim>, int)
for constructing one parallel grid decomposed between the processors.
@param L extension of the domain
@param s number of cells on coarse mesh in each direction
@param periodic tells if direction is periodic or not
@param overlap size of overlap on coarsest grid (same in all directions)
@param lb pointer to an overloaded YLoadBalance instance
*/
YaspGrid (Dune::FieldVector<ctype, dim> L,
Dune::FieldVector<int, dim> s,
Dune::FieldVector<bool, dim> periodic, int overlap,
const YLoadBalance<dim>* lb = YMG::defaultLoadbalancer())
#if HAVE_MPI
: YMG(MPI_COMM_SELF,L,s,periodic,overlap,lb), ccobj(MPI_COMM_SELF),
keep_ovlp(true), adaptRefCount(0), adaptActive(false)
#else
: YMG(L,s,periodic,overlap,lb),
keep_ovlp(true), adaptRefCount(0), adaptActive(false)
#endif
{
init();
}
~YaspGrid()
{
deallocatePointers(indexsets);
deallocatePointers(theleafindexset);
deallocatePointers(theglobalidset);
}
private:
// do not copy this class
YaspGrid(const YaspGrid&);
public:
/*! Return maximum level defined in this grid. Levels are numbered
0 ... maxlevel with 0 the coarsest level.
*/
int maxLevel() const {return MultiYGrid<dim,ctype>::maxlevel();} // delegate
//! refine the grid refCount times. What about overlap?
void globalRefine (int refCount)
{
if (refCount < -maxLevel())
DUNE_THROW(GridError, "Only " << maxLevel() << " levels left. " <<
"Coarsening " << -refCount << " levels requested!");
for (int k=refCount; k<0; k++)
{
MultiYGrid<dim,ctype>::coarsen();
setsizes();
indexsets.pop_back();
}
for (int k=0; k<refCount; k++)
{
MultiYGrid<dim,ctype>::refine(keep_ovlp);
setsizes();
indexsets.push_back( new YaspLevelIndexSet<const YaspGrid<dim> >(*this,maxLevel()) );
}
}
/**
\brief set options for refinement
@param keepPhysicalOverlap [true] keep the physical size of the overlap, [false] keep the number of cells in the overlap. Default is [true].
*/
void refineOptions (bool keepPhysicalOverlap)
{
keep_ovlp = keepPhysicalOverlap;
}
/** \brief Marks an entity to be refined/coarsened in a subsequent adapt.
\param[in] refCount Number of subdivisions that should be applied. Negative value means coarsening.
\param[in] e Entity to Entity that should be refined
\return true if Entity was marked, false otherwise.
\note
- On yaspgrid marking one element will mark all other elements of the level aswell
- If refCount is lower than refCount of a previous mark-call, nothing is changed
*/
bool mark( int refCount, const typename Traits::template Codim<0>::Entity & e )
{
assert(adaptActive == false);
if (e.level() != maxLevel()) return false;
adaptRefCount = std::max(adaptRefCount, refCount);
return true;
}
/** \brief returns adaptation mark for given entity
\param[in] e Entity for which adaptation mark should be determined
\return int adaptation mark, here the default value 0 is returned
*/
int getMark ( const typename Traits::template Codim<0>::Entity &e ) const
{
return ( e.level() == maxLevel() ) ? adaptRefCount : 0;
}
//! map adapt to global refine
bool adapt ()
{
globalRefine(adaptRefCount);
return (adaptRefCount > 0);
}
//! returns true, if the grid will be coarsened
bool preAdapt ()
{
adaptActive = true;
adaptRefCount = comm().max(adaptRefCount);
return (adaptRefCount < 0);
}
//! clean up some markers
void postAdapt()
{
adaptActive = false;
adaptRefCount = 0;
}
//! one past the end on this level
template<int cd, PartitionIteratorType pitype>
typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator lbegin (int level) const
{
return levelbegin<cd,pitype>(level);
}
//! Iterator to one past the last entity of given codim on level for partition type
template<int cd, PartitionIteratorType pitype>
typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator lend (int level) const
{
return levelend<cd,pitype>(level);
}
//! version without second template parameter for convenience
template<int cd>
typename Traits::template Codim<cd>::template Partition<All_Partition>::LevelIterator lbegin (int level) const
{
return levelbegin<cd,All_Partition>(level);
}
//! version without second template parameter for convenience
template<int cd>
typename Traits::template Codim<cd>::template Partition<All_Partition>::LevelIterator lend (int level) const
{
return levelend<cd,All_Partition>(level);
}
//! return LeafIterator which points to the first entity in maxLevel
template<int cd, PartitionIteratorType pitype>
typename Traits::template Codim<cd>::template Partition<pitype>::LeafIterator leafbegin () const
{
return levelbegin<cd,pitype>(maxLevel());
}
//! return LeafIterator which points behind the last entity in maxLevel
template<int cd, PartitionIteratorType pitype>
typename Traits::template Codim<cd>::template Partition<pitype>::LeafIterator leafend () const
{
return levelend<cd,pitype>(maxLevel());
}
//! return LeafIterator which points to the first entity in maxLevel
template<int cd>
typename Traits::template Codim<cd>::template Partition<All_Partition>::LeafIterator leafbegin () const
{
return levelbegin<cd,All_Partition>(maxLevel());
}
//! return LeafIterator which points behind the last entity in maxLevel
template<int cd>
typename Traits::template Codim<cd>::template Partition<All_Partition>::LeafIterator leafend () const
{
return levelend<cd,All_Partition>(maxLevel());
}
// \brief obtain EntityPointer from EntitySeed. */
template <typename Seed>
typename Traits::template Codim<Seed::codimension>::EntityPointer
entityPointer(const Seed& seed) const
{
const int codim = Seed::codimension;
YGLI g = MultiYGrid<dim,ctype>::begin(seed.level());
switch (codim)
{
case 0:
return YaspEntityPointer<codim,GridImp>(this,g,
TSI(g.cell_overlap(), seed.coord()));
case dim:
return YaspEntityPointer<codim,GridImp>(this,g,
TSI(g.vertex_overlap(), seed.coord()));
default:
DUNE_THROW(GridError, "YaspEntityPointer: codim not implemented");
}
}
//! return size (= distance in graph) of overlap region
int overlapSize (int level, int codim) const
{
YGLI g = MultiYGrid<dim,ctype>::begin(level);
return g.overlap();
}
//! return size (= distance in graph) of overlap region
int overlapSize (int codim) const
{
YGLI g = MultiYGrid<dim,ctype>::begin(maxLevel());
return g.overlap();
}
//! return size (= distance in graph) of ghost region
int ghostSize (int level, int codim) const
{
return 0;
}
//! return size (= distance in graph) of ghost region
int ghostSize (int codim) const
{
return 0;
}
//! number of entities per level and codim in this process
int size (int level, int codim) const
{
return sizes[level][codim];
}
//! number of leaf entities per codim in this process
int size (int codim) const
{
return sizes[maxLevel()][codim];
}
//! number of entities per level and geometry type in this process
int size (int level, GeometryType type) const
{
return (type.isCube()) ? sizes[level][dim-type.dim()] : 0;
}
//! number of leaf entities per geometry type in this process
int size (GeometryType type) const
{
return size(maxLevel(),type);
}
//! \brief returns the number of boundary segments within the macro grid
size_t numBoundarySegments () const
{
return nBSegments;
}
/*! The new communication interface
communicate objects for all codims on a given level
*/
template<class DataHandleImp, class DataType>
void communicate (CommDataHandleIF<DataHandleImp,DataType> & data, InterfaceType iftype, CommunicationDirection dir, int level) const
{
YaspCommunicateMeta<dim,dim>::comm(*this,data,iftype,dir,level);
}
/*! The new communication interface
communicate objects for all codims on the leaf grid
*/
template<class DataHandleImp, class DataType>
void communicate (CommDataHandleIF<DataHandleImp,DataType> & data, InterfaceType iftype, CommunicationDirection dir) const
{
YaspCommunicateMeta<dim,dim>::comm(*this,data,iftype,dir,this->maxLevel());
}
/*! The new communication interface
communicate objects for one codim
*/
template<class DataHandle, int codim>
void communicateCodim (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
{
// check input
if (!data.contains(dim,codim)) return; // should have been checked outside
// data types
typedef typename DataHandle::DataType DataType;
// access to grid level
YGLI g = MultiYGrid<dim,ctype>::begin(level);
// find send/recv lists or throw error
const std::deque<IS>* sendlist=0;
const std::deque<IS>* recvlist=0;
if (codim==0) // the elements
{
if (iftype==InteriorBorder_InteriorBorder_Interface)
return; // there is nothing to do in this case
if (iftype==InteriorBorder_All_Interface)
{
sendlist = &g.send_cell_interior_overlap();
recvlist = &g.recv_cell_overlap_interior();
}
if (iftype==Overlap_OverlapFront_Interface || iftype==Overlap_All_Interface || iftype==All_All_Interface)
{
sendlist = &g.send_cell_overlap_overlap();
recvlist = &g.recv_cell_overlap_overlap();
}
}
if (codim==dim) // the vertices
{
if (iftype==InteriorBorder_InteriorBorder_Interface)
{
sendlist = &g.send_vertex_interiorborder_interiorborder();
recvlist = &g.recv_vertex_interiorborder_interiorborder();
}
if (iftype==InteriorBorder_All_Interface)
{
sendlist = &g.send_vertex_interiorborder_overlapfront();
recvlist = &g.recv_vertex_overlapfront_interiorborder();
}
if (iftype==Overlap_OverlapFront_Interface || iftype==Overlap_All_Interface)
{
sendlist = &g.send_vertex_overlap_overlapfront();
recvlist = &g.recv_vertex_overlapfront_overlap();
}
if (iftype==All_All_Interface)
{
sendlist = &g.send_vertex_overlapfront_overlapfront();
recvlist = &g.recv_vertex_overlapfront_overlapfront();
}
}
// change communication direction?
if (dir==BackwardCommunication)
std::swap(sendlist,recvlist);
int cnt;
// Size computation (requires communication if variable size)
std::vector<int> send_size(sendlist->size(),-1); // map rank to total number of objects (of type DataType) to be sent
std::vector<int> recv_size(recvlist->size(),-1); // map rank to total number of objects (of type DataType) to be recvd
std::vector<size_t*> send_sizes(sendlist->size(),static_cast<size_t*>(0)); // map rank to array giving number of objects per entity to be sent
std::vector<size_t*> recv_sizes(recvlist->size(),static_cast<size_t*>(0)); // map rank to array giving number of objects per entity to be recvd
if (data.fixedsize(dim,codim))
{
// fixed size: just take a dummy entity, size can be computed without communication
cnt=0;
for (ISIT is=sendlist->begin(); is!=sendlist->end(); ++is)
{
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
it(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubbegin()));
send_size[cnt] = is->grid.totalsize() * data.size(*it);
cnt++;
}
cnt=0;
for (ISIT is=recvlist->begin(); is!=recvlist->end(); ++is)
{
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
it(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubbegin()));
recv_size[cnt] = is->grid.totalsize() * data.size(*it);
cnt++;
}
}
else
{
// variable size case: sender side determines the size
cnt=0;
for (ISIT is=sendlist->begin(); is!=sendlist->end(); ++is)
{
// allocate send buffer for sizes per entitiy
size_t *buf = new size_t[is->grid.totalsize()];
send_sizes[cnt] = buf;
// loop over entities and ask for size
int i=0; size_t n=0;
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
it(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubbegin()));
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
tsubend(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubend()));
for ( ; it!=tsubend; ++it)
{
buf[i] = data.size(*it);
n += buf[i];
i++;
}
// now we know the size for this rank
send_size[cnt] = n;
// hand over send request to torus class
MultiYGrid<dim,ctype>::torus().send(is->rank,buf,is->grid.totalsize()*sizeof(size_t));
cnt++;
}
// allocate recv buffers for sizes and store receive request
cnt=0;
for (ISIT is=recvlist->begin(); is!=recvlist->end(); ++is)
{
// allocate recv buffer
size_t *buf = new size_t[is->grid.totalsize()];
recv_sizes[cnt] = buf;
// hand over recv request to torus class
MultiYGrid<dim,ctype>::torus().recv(is->rank,buf,is->grid.totalsize()*sizeof(size_t));
cnt++;
}
// exchange all size buffers now
MultiYGrid<dim,ctype>::torus().exchange();
// release send size buffers
cnt=0;
for (ISIT is=sendlist->begin(); is!=sendlist->end(); ++is)
{
delete[] send_sizes[cnt];
send_sizes[cnt] = 0;
cnt++;
}
// process receive size buffers
cnt=0;
for (ISIT is=recvlist->begin(); is!=recvlist->end(); ++is)
{
// get recv buffer
size_t *buf = recv_sizes[cnt];
// compute total size
size_t n=0;
for (int i=0; i<is->grid.totalsize(); ++i)
n += buf[i];
// ... and store it
recv_size[cnt] = n;
++cnt;
}
}
// allocate & fill the send buffers & store send request
std::vector<DataType*> sends(sendlist->size(), static_cast<DataType*>(0)); // store pointers to send buffers
cnt=0;
for (ISIT is=sendlist->begin(); is!=sendlist->end(); ++is)
{
// std::cout << "[" << this->comm().rank() << "] "
// << " send " << " dest=" << is->rank
// << " size=" << send_size[cnt]
// << std::endl;
// allocate send buffer
DataType *buf = new DataType[send_size[cnt]];
// remember send buffer
sends[cnt] = buf;
// make a message buffer
MessageBuffer<DataType> mb(buf);
// fill send buffer; iterate over cells in intersection
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
it(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubbegin()));
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
tsubend(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubend()));
for ( ; it!=tsubend; ++it)
data.gather(mb,*it);
// hand over send request to torus class
MultiYGrid<dim,ctype>::torus().send(is->rank,buf,send_size[cnt]*sizeof(DataType));
cnt++;
}
// allocate recv buffers and store receive request
std::vector<DataType*> recvs(recvlist->size(),static_cast<DataType*>(0)); // store pointers to send buffers
cnt=0;
for (ISIT is=recvlist->begin(); is!=recvlist->end(); ++is)
{
// std::cout << "[" << this->comm().rank() << "] "
// << " recv " << " src=" << is->rank
// << " size=" << recv_size[cnt]
// << std::endl;
// allocate recv buffer
DataType *buf = new DataType[recv_size[cnt]];
// remember recv buffer
recvs[cnt] = buf;
// hand over recv request to torus class
MultiYGrid<dim,ctype>::torus().recv(is->rank,buf,recv_size[cnt]*sizeof(DataType));
cnt++;
}
// exchange all buffers now
MultiYGrid<dim,ctype>::torus().exchange();
// release send buffers
cnt=0;
for (ISIT is=sendlist->begin(); is!=sendlist->end(); ++is)
{
delete[] sends[cnt];
sends[cnt] = 0;
cnt++;
}
// process receive buffers and delete them
cnt=0;
for (ISIT is=recvlist->begin(); is!=recvlist->end(); ++is)
{
// get recv buffer
DataType *buf = recvs[cnt];
// make a message buffer
MessageBuffer<DataType> mb(buf);
// copy data from receive buffer; iterate over cells in intersection
if (data.fixedsize(dim,codim))
{
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
it(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubbegin()));
size_t n=data.size(*it);
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
tsubend(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubend()));
for ( ; it!=tsubend; ++it)
data.scatter(mb,*it,n);
}
else
{
int i=0;
size_t *sbuf = recv_sizes[cnt];
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
it(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubbegin()));
typename Traits::template Codim<codim>::template Partition<All_Partition>::LevelIterator
tsubend(YaspLevelIterator<codim,All_Partition,GridImp>(this,g,is->grid.tsubend()));
for ( ; it!=tsubend; ++it)
data.scatter(mb,*it,sbuf[i++]);
delete[] sbuf;
}
// delete buffer
delete[] buf; // hier krachts !
cnt++;
}
}
// The new index sets from DDM 11.07.2005
const typename Traits::GlobalIdSet& globalIdSet() const
{
return *(theglobalidset[0]);
}
const typename Traits::LocalIdSet& localIdSet() const
{
return *(theglobalidset[0]);
}
const typename Traits::LevelIndexSet& levelIndexSet(int level) const
{
if (level<0 || level>maxLevel()) DUNE_THROW(RangeError, "level out of range");
return *(indexsets[level]);
}
const typename Traits::LeafIndexSet& leafIndexSet() const
{
return *(theleafindexset[0]);
}
#if HAVE_MPI
/*! @brief return a collective communication object
*/
const CollectiveCommunication<MPI_Comm>& comm () const
{
return ccobj;
}
#else
/*! @brief return a collective communication object
*/
const CollectiveCommunication<YaspGrid>& comm () const
{
return ccobj;
}
#endif
YaspIntersectionIterator<const YaspGrid<dim> >&
getRealIntersectionIterator(typename Traits::LevelIntersectionIterator& it)
{
return this->getRealImplementation(it);
}
const YaspIntersectionIterator<const YaspGrid<dim> >&
getRealIntersectionIterator(const typename Traits::LevelIntersectionIterator& it) const
{
return this->getRealImplementation(it);
}
private:
#if HAVE_MPI
CollectiveCommunication<MPI_Comm> ccobj;
#else
CollectiveCommunication<YaspGrid> ccobj;
#endif
std::vector<YaspLevelIndexSet<const YaspGrid<dim> >*> indexsets;
std::vector<YaspLeafIndexSet<const YaspGrid<dim> >*> theleafindexset;
std::vector<YaspGlobalIdSet<const YaspGrid<dim> >*> theglobalidset;
int nBSegments;
// Index classes need access to the real entity
friend class Dune::YaspLevelIndexSet<const Dune::YaspGrid<dim> >;
friend class Dune::YaspLeafIndexSet<const Dune::YaspGrid<dim> >;
friend class Dune::YaspGlobalIdSet<const Dune::YaspGrid<dim> >;
friend class Dune::YaspIntersectionIterator<const Dune::YaspGrid<dim> >;
friend class Dune::YaspIntersection<const Dune::YaspGrid<dim> >;
friend class Dune::YaspEntity<0, dim, const Dune::YaspGrid<dim> >;
template<class T>
void deallocatePointers(T& container)
{
typedef typename T::iterator Iterator;
for(Iterator entry=container.begin(); entry != container.end(); ++entry)
delete (*entry);
}
template<int codim_, int dim_, class GridImp_, template<int,int,class> class EntityImp_>
friend class Entity;
template<class DT>
class MessageBuffer {
public:
// Constructor
MessageBuffer (DT *p)
{
a=p;
i=0;
j=0;
}
// write data to message buffer, acts like a stream !
template<class Y>
void write (const Y& data)
{
dune_static_assert(( is_same<DT,Y>::value ), "DataType missmatch");
a[i++] = data;
}
// read data from message buffer, acts like a stream !
template<class Y>
void read (Y& data) const
{
dune_static_assert(( is_same<DT,Y>::value ), "DataType missmatch");
data = a[j++];
}
private:
DT *a;
int i;
mutable int j;
};
void setsizes ()
{
for (YGLI g=MultiYGrid<dim,ctype>::begin(); g!=MultiYGrid<dim,ctype>::end(); ++g)
{
// codim 0 (elements)
sizes[g.level()][0] = 1;
for (int i=0; i<dim; ++i)
sizes[g.level()][0] *= g.cell_overlap().size(i);
// codim 1 (faces)
if (dim>1)
{
sizes[g.level()][1] = 0;
for (int i=0; i<dim; ++i)
{
int s=g.cell_overlap().size(i)+1;
for (int j=0; j<dim; ++j)
if (j!=i)
s *= g.cell_overlap().size(j);
sizes[g.level()][1] += s;
}
}
// codim dim-1 (edges)
if (dim>2)
{
sizes[g.level()][dim-1] = 0;
for (int i=0; i<dim; ++i)
{
int s=g.cell_overlap().size(i);
for (int j=0; j<dim; ++j)
if (j!=i)
s *= g.cell_overlap().size(j)+1;
sizes[g.level()][dim-1] += s;
}
}
// codim dim (vertices)
sizes[g.level()][dim] = 1;
for (int i=0; i<dim; ++i)
sizes[g.level()][dim] *= g.vertex_overlapfront().size(i);
}
}
//! one past the end on this level
template<int cd, PartitionIteratorType pitype>
YaspLevelIterator<cd,pitype,GridImp> levelbegin (int level) const
{
dune_static_assert( cd == dim || cd == 0 ,
"YaspGrid only supports Entities with codim=dim and codim=0");
YGLI g = MultiYGrid<dim,ctype>::begin(level);
if (level<0 || level>maxLevel()) DUNE_THROW(RangeError, "level out of range");
if (pitype==Ghost_Partition)
return levelend <cd, pitype> (level);
if (cd==0) // the elements
{
if (pitype<=InteriorBorder_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.cell_interior().tsubbegin());
if (pitype<=All_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.cell_overlap().tsubbegin());
}
if (cd==dim) // the vertices
{
if (pitype==Interior_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_interior().tsubbegin());
if (pitype==InteriorBorder_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_interiorborder().tsubbegin());
if (pitype==Overlap_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_overlap().tsubbegin());
if (pitype<=All_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_overlapfront().tsubbegin());
}
DUNE_THROW(GridError, "YaspLevelIterator with this codim or partition type not implemented");
}
//! Iterator to one past the last entity of given codim on level for partition type
template<int cd, PartitionIteratorType pitype>
YaspLevelIterator<cd,pitype,GridImp> levelend (int level) const
{
dune_static_assert( cd == dim || cd == 0 ,
"YaspGrid only supports Entities with codim=dim and codim=0");
YGLI g = MultiYGrid<dim,ctype>::begin(level);
if (level<0 || level>maxLevel()) DUNE_THROW(RangeError, "level out of range");
if (cd==0) // the elements
{
if (pitype<=InteriorBorder_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.cell_interior().tsubend());
if (pitype<=All_Partition || pitype == Ghost_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.cell_overlap().tsubend());
}
if (cd==dim) // the vertices
{
if (pitype==Interior_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_interior().tsubend());
if (pitype==InteriorBorder_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_interiorborder().tsubend());
if (pitype==Overlap_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_overlap().tsubend());
if (pitype<=All_Partition || pitype == Ghost_Partition)
return YaspLevelIterator<cd,pitype,GridImp>(this,g,g.vertex_overlapfront().tsubend());
}
DUNE_THROW(GridError, "YaspLevelIterator with this codim or partition type not implemented");
}
int sizes[MAXL][dim+1]; // total number of entities per level and codim
bool keep_ovlp;
int adaptRefCount;
bool adaptActive;
};
namespace Capabilities
{
/** \struct hasEntity
\ingroup YaspGrid
*/
/** \struct hasBackupRestoreFacilities
\ingroup YaspGrid
*/
/** \brief YaspGrid has only one geometry type for codim 0 entities
\ingroup YaspGrid
*/
template<int dim>
struct hasSingleGeometryType< YaspGrid<dim> >
{
static const bool v = true;
static const unsigned int topologyId = GenericGeometry :: CubeTopology< dim > :: type :: id ;
};
/** \brief YaspGrid is a Cartesian grid
\ingroup YaspGrid
*/
template<int dim>
struct isCartesian< YaspGrid<dim> >
{
static const bool v = true;
};
/** \brief YaspGrid has codim=0 entities (elements)
\ingroup YaspGrid
*/
template<int dim>
struct hasEntity< YaspGrid<dim>, 0 >
{
static const bool v = true;
};
/** \brief YaspGrid has codim=dim entities (vertices)
\ingroup YaspGrid
*/
template<int dim>
struct hasEntity< YaspGrid<dim>, dim >
{
static const bool v = true;
};
template< int dim >
struct canCommunicate< YaspGrid< dim >, 0 >
{
static const bool v = true;
};
template< int dim >
struct canCommunicate< YaspGrid< dim >, dim >
{
static const bool v = true;
};
/** \brief YaspGrid is parallel
\ingroup YaspGrid
*/
template<int dim>
struct isParallel< YaspGrid<dim> >
{
static const bool v = true;
};
/** \brief YaspGrid is levelwise conforming
\ingroup YaspGrid
*/
template<int dim>
struct isLevelwiseConforming< YaspGrid<dim> >
{
static const bool v = true;
};
/** \brief YaspGrid is leafwise conforming
\ingroup YaspGrid
*/
template<int dim>
struct isLeafwiseConforming< YaspGrid<dim> >
{
static const bool v = true;
};
}
} // end namespace
#endif
|