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
|
\section{Routines for barycentric coordinates}%
\label{S:bary_routines}
Operations on single elements are performed using barycentric
coordinates. In many applications, the world coordinates $x$ of the
local barycentric coordinates $\lambda$ have to be calculated (see
\secref{S:ass_tools}, e.g.). Some other applications will need
the calculation of barycentric coordinates for given world coordinates
(see \secref{S:traverse}, e.g.). Finally, derivatives of finite
element functions on elements involve the Jacobian of the barycentric
coordinates (see \secref{S:eval}, e.g.).
In case of a grid with parametric elements, these operations strongly
depend on the element parameterization and no general routines can be
supplied. For non-parametric simplices, \ALBERTA supplies
functions to perform these basic tasks:
%
\fdx{coord_to_world()@{\code{coord\_to\_world()}}}%
\idx{barycentric coordinates!coord_to_world()@{\code{coord\_to\_world()}}}%
\fdx{world_to_coord()@{\code{world\_to\_coord()}}}%
\idx{barycentric coordinates!world_to_coord()@{\code{world\_to\_coord()}}}%
\fdx{el_grd_lambda()@{\code{el\_grd\_lambda()}}}%
\idx{barycentric coordinates!el_grd_lambda()@{\code{el\_grd\_lambda()}}}%
\fdx{el_det()@{\code{el\_det()}}}%
\fdx{el_volume()@{\code{el\_volume()}}}%
\fdx{get_wall_normal()@{\code{get\_wall\_normal()}}}%
\bv\begin{lstlisting}
const REAL *coord_to_world(const EL_INFO *, const REAL *, REAL_D);
int world_to_coord(const EL_INFO *, const REAL *, REAL_B);
REAL el_grd_lambda(const EL_INFO *, REAL [N_LAMBDA][DIM_OF_WORLD]);
REAL el_det(const EL_INFO *);
REAL el_volume(const EL_INFO *);
REAL get_wall_normal(const EL_INFO *el_info, int i0, REAL *normal);
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{coord\_to\_world(el\_info, lambda, world)} returns a pointer
to a vector, which contains the world coordinates of a point in
barycentric coordinates \code{lambda} with respect to the element
\code{el\_info->el};
if \code{world} is not \nil the world coordinates are stored in this
vector; otherwise the function itself provides memory for this
vector; in this case the vector is overwritten during the next call
of \code{coord\_to\_world()};
\code{coord\_to\_world()} needs vertex coordinates information; the
flag \code{FILL\_COORDS} has to be set during mesh traversal when
calling this routine on elements.
\kitem{world\_to\_coord(el\_info, world, lambda)} calculates the
barycentric coordinates with respect to the element
\code{el\_info->el} of a point with world coordinates \code{world}
and stores them in the vector given by \code{lambda}. The return
value is \code{-1} when the point is inside the simplex (or on its
boundary), otherwise the index of the barycentric coordinate with
largest negative value (between 0 and $d$);
\code{world\_to\_coord()} needs vertex coordinates information; the
flag \code{FILL\_COORDS} has to be set during mesh traversal when
calling this routine on elements.
Note that -- with the exception of the 1d code -- this function is
only implemented for the co-dimension $0$ case, i.e.
\code{mesh->dim} and \DOW have to be equal, otherwise a call to this
function will terminate the application with a corresponding
error-message.
\kitem{el\_grd\_lambda(el\_info, Lambda)} calculates the Jacobian of
the barycentric coordinates on \code{el\_info->el} and stores the
matrix in \code{Lambda}; the return value of the function is the
absolute value of the determinant of the affine linear
parameterization's Jacobian. For $d<n$ the tangential gradient and
the value of Gram's determinant are calculated.
\code{el\_grd\_lambda()} needs vertex coordinates information; the
flag \code{FILL\_COORDS} has to be set during mesh traversal when
calling this routine on elements.
\kitem{el\_det(el\_info)} returns the the absolute value of the
determinant of the affine linear parameterization's Jacobian, or
Gram's determinant for $d<n$.
\code{el\_det()} needs vertex coordinates information; the flag
\code{FILL\_COORDS} has to be set during mesh traversal when calling
this routine on elements.
\kitem{el\_volume(el\_info)} returns the the volume of the simplex;
\code{el\_volume()} needs vertex coordinates information; the flag
\code{FILL\_COORDS} has to be set during mesh traversal when calling
this routine on elements.
\kitem{get\_wall\_normal(el\_info, wall, normal)} compute the outer
unit normal of the face opposite to vertex \code{wall}. The result
is stored in \code{normal}. The return value is the ``surface
element'' of the given face, i.e. Gram's determinant of the
transformation to the respective face of the reference element.
\code{normal} may be \nil. In the case of non-zero co-dimension
\code{normal} is contained in the sub-space spanned by the edges of
the given simplex.
\end{descr}
\medskip
All functions described above also come with a \code{\dots\_Xd}
variant, e.g. \code{coord\_to\_world\_2d()}. For the case of $0$
co-dimension there are also wrapper functions \code{\dots\_0cd} which
call the appropriate \code{\dots\_Xd} variant with \code{X ==
DIM\_OF\_WORLD}. The \code{\dots\_Xd} and \code{\dots\_0cd} variants
are very slightly faster because otherwise the dimension of the
underlying mesh has to be read out of the mesh structure -- e.g. via
\code{el\_info->mesh\_dim} -- and only then the functions branch to
the appropriate \code{\dots\_Xd} variant.
\section{Data structures for numerical quadrature}%
\label{S:quad_data}
For the numerical calculation of general integrals
\[
\int_S f(x)\, dx
\]
we use quadrature formulas described in \ref{book:S:quadrature}.
\ALBERTA supports numerical integration in zero, one, two, and three dimensions
on the standard simplex $\Shat$ in barycentric coordinates.
\subsection{The \code{QUAD} data structure}%
\label{S:QUAD}
A quadrature formula is described by the following structure, which
is defined both as type \code{QUAD} and \code{QUADRATURE}:
\ddx{QUAD@{\code{QUAD}}}
\idx{numerical quadrature!QUAD@{\code{QUAD}}}
\ddx{QUADRATURE@{\code{QUADRATURE}}}
\idx{numerical quadrature!QUADRATURE@{\code{QUADRATURE}}}
\bv\begin{lstlisting}[name=QUAD,label=T:QUAD]
extern n_quad_points_max[DIM_MAX+1];
typedef struct quadrature QUAD;
typedef struct quadrature QUADRATURE;
struct quadrature
{
char *name;
int degree;
int dim;
int codim;
int subsplx;
int n_points;
int n_points_max;
const REAL_B *lambda;
const REAL *w;
void *metadata;
INIT_ELEMENT_DECL;
};
\end{lstlisting}\ev
\label{T:QUADRATURE}
Description:
\begin{descr}
\kitem{name} Textual description of the quadrature.
%%
\kitem{degree} Quadrature is exact of degree \code{degree}.
%%
\kitem{dim} Quadrature for dimension \code{dim}. The barycentric
co-cordinates of the quadrature points always have \code{dim+1} valid
components.
%%
\kitem{codim} Co-dimension; \code{codim} is always \code{0} for
quadratures returned by \code{get\_quadrature()}, and \code{1} for
quadratures returned by \code{get\_wall\_quad()} and
\code{get\_bndry\_quad()}.
%%
\kitem{subsplx} For \code{codim == 1} the number of the wall-simplex
this quadrature can be used for; this implies that
\code{lambda[iq][subsplx]} zero.
%%
\kitem{n\_points} The number of quadrature points.
%%
\kitem{n\_points\_max} The maximal number of quadrature points. The
number of quadrature points can vary from simplex to simplex if
\code{INIT\_ELEMENT\_METHOD(quad)} is not \nil.
%%
\kitem{lambda} Vector
$\mbox{\code{lambda[0]}},\dots,\mbox{\code{lambda[n\_points-1]}}$
of quadrature points given in bary\-centric coordinates
(thus having \code{N\_LAMBDA\_MAX} components).
%%
\kitem{w} vector
$\mbox{\code{w[0]}},\dots,\mbox{\code{w[n\_points-1]}}$ of
quadrature weights.
%%
\kitem{metadata} Pointer to an internal data structure for
per-element quadrature caches and the like, see e.g.
\secref{S:fill_quad_el_cache}
%%
\kitem{INIT\_ELEMENT\_DECL} Function pointer to a per-element
initializer. This pointer is always \nil for quadratures returned by
\code{get\_quadrature()}, \code{get\_wall\_quad()} and
\code{get\_bndry\_quad()}. External extension modules make use of it.
See \secref{S:init_element}.
\end{descr}
Currently, numerical quadrature formulas exact up to degree 19 in one
(Gauss formulas), up to degree 17 in two, up to degree 7 in three
dimensions are implemented. We only use stable formulas; this results
in more quadrature points for some formulas (for example in 3d the
formula which is exact of degree 3). A compilation of quadrature
formulas on triangles and tetrahedra is given in
\cite{CoolsRabinowitz:93}. The implemented quadrature formulas are
taken from \cite{Dunavant:85,Gatermann:88,Kardestuncer:87,Stroud:71}.
Using a conical product rule it is possible to construct new
(non-symmetric) quadrature formulas from the existing ones, if that is
really needed.
Functions for numerical quadrature are
\fdx{get_quadrature()@{\code{get\_quadrature()}}}
\idx{numerical quadrature!get_quadrature()@{\code{get\_quadrature()}}}
\fdx{integrate_std_simp()@{\code{integrate\_std\_simp()}}}
\idx{numerical quadrature!integrate_std_simp()@{\code{integrate\_std\_simp()}}}
\fdx{get_product_quad()@{\code{get\_product\_quad()}}}
\idx{numerical quadrature!get_product_quad()@{\code{get\_product\_quad()}}}
\fdx{get_lumping_quadrature()@{\code{get\_lumping\_quadrature()}}}
\idx{numerical quadrature!get_lumping_quadrature()@{\code{get\_lumping\_quadrature()}}}
\fdx{register_quadrature()@{\code{register\_quadrature()}}}
\idx{numerical quadrature!register_quadrature()@{\code{register\_quadrature()}}}
\fdx{new_quadrature()@{\code{new\_quadrature()}}}
\idx{numerical quadrature!new_quadrature()@{\code{new\_quadrature()}}}
\bv\begin{lstlisting}
const QUAD *get_quadrature(int dim, int degree);
REAL integrate_std_simp(const QUAD *quad, REAL (*f)(const REAL *));
const QUAD *get_product_quad(const QUAD *oq);
const QUAD *get_lumping_quadrature(int dim);
void register_quadrature(QUAD *quad);
bool new_quadrature(const QUAD *quad);
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{get\_quadrature(dim, degree)} returns a pointer to a
\code{QUAD} structure for numerical integration in \code{dim}
dimensions which is exact of degree
$\min(19,\code{degree})$ for \code{dim==1},
$\min(17,\code{degree})$ for \code{dim==2},
and $\min(7,\code{degree})$ for \code{dim==3}.
It is possible to extend the maximal degrees by installing an
application-defined quadrature rule via \code{new\_quadrature()}.
%%
\kitem{register\_quadrature(quad)} Equip an application-defined
quadrature with internal used meta-data for quadrature caches; this
function also updates \code{n\_quad\_points\_max[quad->dim]}. To
install \code{quad} as a default quadrature which will returned on
request by \code{get\_quadrature()} the functions
\code{new\_quadrature()} has to be called additionally.
\kitem{new\_quadrature(quad)} Install the given quadrature as new
default quadrature for its dimension and polynomial degree; this
means that \code{get\_quadrature()} will return a pointer to
\code{quad} when called with \code{quad->dim} and \code{quad->degree}.
%%
\kitem{get\_product\_quad(quad)} Return a conical product quadrature
rule. The returned quadrature formula is non-symmetric and works for
one dimension higher than \code{quad} and is exact of the same
degree as \code{quad}. The 3D formula for degree $7$ found in
\cite{Stroud:71} is of this type, for example.
Note that \code{get\_product\_quad()} installs the new formula
calling \code{new\_quadrature()}, so the formula will be available
through \code{get\_quadrature()}.
%%
\kitem{get\_lumping\_quadrature(dim)} Returns a lumping quadrature
with quadrature nodes at the vertices of the reference simplex.
%%
\kitem{integrate\_std\_simp(quad, f)} approximates an integral
by the numerical quadrature described by \code{quad};
\code{f} is a pointer to a function to be integrated, evaluated
in barycentric coordinates; the return value is
\[
\sum_{\code{k = 0}}^{\mbox{\tiny\code{quad->n\_points-1}}}
\mbox{\code{quad->w[k] * (*f)(quad->lambda[k])}};
\]
for the approximation of $\int_S f$ we have to multiply this value
with $d! |S|$ for a simplex $S$; for a parametric simplex,
\code{f} should be a pointer to a function which calculates
$f(\lambda) |\det DF_S(\hat x(\lambda))|$.
\end{descr}
The following functions initialize values and gradients of functions
at the quadrature nodes:
\fdx{f_at_qp()@{\code{f\_at\_qp()}}}%
\fdx{f_d_at_qp()@{\code{f\_d\_at\_qp()}}}%
\fdx{grd_f_at_qp()@{\code{grd\_f\_at\_qp()}}}%
\fdx{grd_f_d_at_qp()@{\code{grd\_f\_d\_at\_qp()}}}%
\fdx{f_loc_at_qp()@{\code{f\_loc\_at\_qp()}}}%
\fdx{f_loc_d_at_qp()@{\code{f\_loc\_d\_at\_qp()}}}%
\fdx{grd_f_loc_at_qp()@{\code{grd\_f\_loc\_at\_qp()}}}%
\fdx{param_grd_f_loc_at_qp()@{\code{param\_grd\_f\_loc\_at\_qp()}}}%
\fdx{grd_f_loc_d_at_qp()@{\code{grd\_f\_loc\_d\_at\_qp()}}}%
\fdx{param_grd_f_loc_d_at_qp()@{\code{param\_grd\_f\_loc\_d\_at\_qp()}}}%
\fdx{fx_at_qp()@{\code{fx\_at\_qp()}}}%
\fdx{fx_d_at_qp()@{\code{fx\_d\_at\_qp()}}}%
\fdx{grd_fx_at_qp()@{\code{grd\_fx\_at\_qp()}}}%
\fdx{grd_fx_d_at_qp()@{\code{grd\_fx\_d\_at\_qp()}}}%
\bv\begin{lstlisting}
REAL *f_at_qp(REAL vec[], const QUAD *quad, REAL (*f)(const REAL_B lambda));
REAL_D *grd_f_at_qp(REAL_D vec[], const QUAD *quad,
const REAL *(*f)(const REAL_B));
REAL_D *f_d_at_qp(REAL_D vec[], const QUAD *quad,
const REAL *(*f)(const REAL_B lambda));
REAL_DD *grd_f_d_at_qp(REAL_DD vec[], const QUAD *quad,
const REAL_D *(*f)(const REAL_B lambda));
REAL *f_loc_at_qp(REAL vec[], const EL_INFO *el_info, const QUAD *quad,
REAL (*f)(const EL_INFO *el_info,
const QUAD *quad, int iq, void *ud),
void *ud);
REAL_D *grd_f_loc_at_qp(REAL_D vec[], const EL_INFO *el_info,
const QUAD *quad, const REAL_BD Lambda,
GRD_LOC_FCT_AT_QP grd_f, void *ud);
REAL_D *param_grd_f_loc_at_qp(REAL_D vec[], const EL_INFO *el_info,
const QUAD *quad, const REAL_BD Lambda[],
GRD_LOC_FCT_AT_QP grd_f, void *ud);
REAL_D *f_loc_d_at_qp(REAL_D vec[], const EL_INFO *el_info, const QUAD *quad,
const REAL *(*f)(REAL_D result, const EL_INFO *el_info,
const QUAD *quad, int iq, void *ud),
void *ud);
REAL_DD *grd_f_loc_d_at_qp(REAL_DD vec[], const EL_INFO *el_info,
const QUAD *quad, const REAL_BD Lambda,
GRD_LOC_FCT_D_AT_QP grd_f, void *ud);
REAL_DD *param_grd_f_loc_d_at_qp(REAL_DD vec[], const EL_INFO *el_info,
const QUAD *quad, const REAL_BD Lambda[],
GRD_LOC_FCT_D_AT_QP grd_f, void *ud);
REAL *fx_at_qp(REAL vec[], const EL_INFO *el_info, const QUAD *quad,
FCT_AT_X f);
REAL_D *grd_fx_at_qp(REAL_D vec[], const EL_INFO *el_info, const QUAD *quad,
GRD_FCT_AT_X grd_f);
REAL_D *fx_d_at_qp(REAL_D vec[], const EL_INFO *el_info, const QUAD *quad,
FCT_D_AT_X f);
REAL_DD *grd_fx_d_at_qp(REAL_DD vec[], const EL_INFO *el_info,
const QUAD *quad, GRD_FCT_D_AT_X grd_f);
\end{lstlisting}\ev
Description:
\def\DOW{\code{DIM\_OF\_WORLD}\xspace}
\def\div{\mathrm{div\,}}
\begin{descr}
\kitem{f\_at\_qp(vec, quad, f)} returns a pointer \code{ptr} to a
vector \code{quad->n\_points} storing the values of a \code{REAL}
valued function at all quadrature points of \code{quad};
\code{f} is a pointer to that function, evaluated in
barycentric coordinates; if \code{vec} is not \nil, the values
are stored in this vector, otherwise the values are stored in
some static local vector, which is overwritten on the next call;
\code{ptr[i]}$ = $\code{(*f)(quad->lambda[i])} for
$0\leq\code{i}<\mbox{\code{quad->n\_points}}$.
\kitem{grd\_f\_at\_qp(vec, quad, grd\_f)} returns a pointer \code{ptr} to a
vector \code{quad->n\_points} storing the gradient (with
respect to world coordinates) of a \code{REAL} valued function
at all quadrature points of \code{quad};
\code{grd\_f} is a pointer to a function, evaluated in
barycentric coordinates and returning a pointer to a vector of
length \DOW storing the gradient;
if \code{vec} is not \nil, the values are stored in this
vector, otherwise the values are stored in some local static
vector, which is overwritten on the next call;
\code{ptr[i][j]}$ = $\code{(*grd\_f)(quad->lambda[i])[j]}, for
$0\leq\code{j}<\mbox{\DOW}$ and
$0\leq\code{i}<\mbox{\code{quad->n\_points}}$,
\kitem{f\_d\_at\_qp(vec, quad, fd)} returns a pointer \code{ptr} to a
vector \code{quad->n\_points} storing the values of a
\code{REAL\_D} valued function at all quadrature points of
\code{quad};
\code{fd} is a pointer to that function, evaluated
in barycentric coordinates and returning a pointer to a vector
of length \DOW storing all components; if the second argument
\code{val} of \code{(*fd)(lambda, val)} is not \nil, the values
have to be stored at \code{val}, otherwise \code{fd} has to
provide memory for the vector which may be overwritten on the
next call;
if \code{vec} is not \nil, the values are stored in
this vector, otherwise the values are stored in some static
local vector, which is overwritten on the next call;
\code{ptr[i][j]}$ = $\code{(*fd)(quad->lambda[i],val)[j]}, for
$0\leq\code{j}<\mbox{\DOW}$ and
$0\leq\code{i}<\mbox{\code{quad->n\_points}}$.
\kitem{grd\_f\_d\_at\_qp(vec, quad, grd\_fd)} returns a pointer
\code{ptr} to a vector \code{quad->n\_points} storing the
Jacobian (with respect to world coordinates) of a
\code{REAL\_D} valued function at all quadrature points of
\code{quad};
\code{grd\_fd} is a pointer to a function, evaluated in
barycentric coordinates and returning a pointer to a matrix of
size \DOW$\times$\DOW storing the Jacobian; if the second
argument \code{val} of \code{(*grd\_fd)(x, val)} is not \nil, the
Jacobian has to be stored at \code{val}, otherwise \code{grd\_fd} has
to provide memory for the matrix which may be overwritten on
the next call;
if \code{vec} is not \nil, the values are stored in this
vector, otherwise the values are stored in some static local
vector, which is overwritten on the next call;
\code{ptr[i][j][k]}$ = $\code{(*grd\_fd)(quad->lambda[i],val)[j][k]},
for $0\leq\code{j},\code{k}<\mbox{\DOW}$ and
$0\leq\code{i}<\mbox{\code{quad->n\_points}}$,
\kitem{f\_loc\_at\_qp(vec, el\_info, quad, f, ud)}
\kitem{grd\_f\_loc\_at\_qp(vec, el\_info, quad, Lambda, grd\_f, ud)}
\kitem{param\_grd\_f\_loc\_at\_qp(vec, el\_info, quad, Lambda, grd\_f, ud)}
\kitem{f\_loc\_d\_at\_qp(vec, el\_info, quad, fd, ud)}
\kitem{grd\_f\_loc\_d\_at\_qp(vec, el\_info, quad, Lambda, grd\_fd, ud)}
\kitem{param\_grd\_f\_loc\_d\_at\_qp(vec, el\_info, quad, Lambda, grd\_fd, ud)}
\kitem{fx\_at\_qp(vec, el\_info, quad, f)}
\kitem{grd\_fx\_at\_qp(vec, el\_info, quad, grd\_f)}
\kitem{fx\_d\_at\_qp(vec, el\_info, quad, fd)}
\kitem{grd\_fx\_d\_at\_qp(vec, el\_info, quad, grd\_fd)}
\end{descr}
\subsection{The \code{QUAD\_FAST} data structure}
\label{S:QUAD_FAST}
Often numerical integration involves basis functions, such as the
assembling of the system matrix and right hand side, or the
integration of finite element functions. Since numerical quadrature
involves only the values at the quadrature points and the values of
basis functions and its derivatives (with respect to barycentric
coordinates) are the same at these points for
all elements of the grid, such routines can be much more efficient, if
they can use pre--computed values of the basis functions at the
quadrature points. In this case the basis functions do not have to be
evaluated for each quadrature point newly on every element.
Information that should be pre--computed can be specified by the
following symbolic constants:
\cdx{INIT_PHI@{\code{INIT\_PHI}}}%
\idx{numerical quadrature!INIT_PHI@{\code{INIT\_PHI}}}%
\cdx{INIT_GRD_PHI@{\code{INIT\_GRD\_PHI}}}%
\idx{numerical quadrature!INIT_GRD_PHI@{\code{INIT\_GRD\_PHI}}}%
\cdx{INIT_D2_PHI@{\code{INIT\_D2\_PHI}}}%
\idx{numerical quadrature!INIT_D2_PHI@{\code{INIT\_D2\_PHI}}}%
\bv\begin{lstlisting}[label=M:QFAST_FLAGS]
#define INIT_PHI 0x01
#define INIT_GRD_PHI 0x02
#define INIT_D2_PHI 0x04
#define INIT_D3_PHI 0x08
#define INIT_D4_PHI 0x10
#define INIT_TANGENTIAL 0x80
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{INIT\_PHI} pre--compute the values of all basis functions at
all quadrature nodes;
\kitem{INIT\_GRD\_PHI} pre--compute the gradients (with respect to
the barycentric coordinates) of all basis functions at
all quadrature nodes;
\kitem{INIT\_D2\_PHI}pre--compute all 2nd derivatives (with respect to
the barycentric coordinates) of all basis functions at
all quadrature nodes.
\end{descr}
In order to store such information for one set of basis functions
we define the data structure
\ddx{QUAD_FAST@{\code{QUAD\_FAST}}}%
\idx{numerical quadrature!QUAD_FAST@{\code{QUAD\_FAST}}}%
\bv\begin{lstlisting}[name=QUAD_FAST,label=T:QUAD_FAST]
typedef struct quad_fast QUAD_FAST;
struct quad_fast
{
const QUAD *quad;
const BAS_FCTS *bas_fcts;
FLAGS init_flag;
int dim;
int n_points;
int n_bas_fcts;
int n_points_max;
int n_bas_fcts_max;
const REAL *w; /* shallow copy of quad->w */
const REAL (*const*phi); /* [qp][bf] */
const REAL_B (*const*grd_phi);
const REAL_BB (*const*D2_phi);
const REAL_BBB (*const*D3_phi);
const REAL_BBBB (*const*D4_phi);
/* For vector valued basis functions with a p.w. constant
* directional derivative we cache that direction and make it
* available for applications. The component is initialized by the
* INIT_ELEMENT() method.
*
* So: phi_d[i] gives the value of the directional factor for the
* i-th basis function. If (!bas_fcts->dir_pw_const), then phi_d is
* NULL.
*/
const REAL_D *phi_d;
/* chain to next structure, if bas_fcts->chain is non-empty */
DBL_LIST_NODE chain;
/* a clone of this structure, but as single item. */
const QUAD_FAST *unchained;
INIT_ELEMENT_DECL;
void *internal;
};
\end{lstlisting}\ev
The entries yield following information:
\begin{descr}
\kitem{quad} Values stored for numerical quadrature \code{quad}.
%%
\kitem{bas\_fcts} Values stored for basis functions \code{bas\_fcts}.
%%
\kitem{dim} Clone of \code{quad->dim}.
%%
\kitem{init\_flag} Indicates which information is initialized; may be
one of, or a bitwise \textsf{OR} of several of \code{INIT\_PHI},
\code{INIT\_GRD\_PHI}, \code{INIT\_D2\_PHI}, \code{INIT\_D3\_PHI} or
\code{INIT\_D4\_PHI}. Not all basis functions have support for higher
derivatives. There is one additional fill-flag,
\code{INIT\_TANGENTIAL} with the meaning that only the tangential
derivatives of the basis functions will be computed if \code{quad} is
a co-dimension $1$ quadrature rule.
%%
\kitem{n\_points} The number of quadrature points; equals
\code{quad->n\_points}.
%%
\kitem{n\_bas\_fcts} number of basis functions; equals
\code{bas\_fcts->n\_bas\_fcts}.
%%
\kitem{n\_points\_max} The maximum number of quadrature points. If
\code{quad->init\_element()} is non-\nil, then the number of basis
functions can vary on a per-element basis.
%%
\kitem{n\_bas\_fcts\_max} The maximum
number of basis functions. If \code{bas\_fcts->init\_element} is
non-\nil, then the number of basis functions can vary on a per-element
basis.
%%
\kitem{w} Vector of quadrature weights; \code{w = quad->w}.
%%
\kitem{phi} Matrix storing function values if the flag
\code{INIT\_PHI} is set.
\code{phi[i][j]} stores the value
\code{bas\_fcts->phi[j](quad->lambda[i])},
$0\leq\code{j}<\mbox{\code{n\_bas\_fcts}}$ and
$0\leq\code{i}<\mbox{\code{n\_points}}$;
%%
\kitem{grd\_phi} Matrix storing all gradients (with respect to the
barycentric coordinates) if the flag
\code{INIT\_GRD\_PHI} is set;
\code{grd\_phi[i][j][k]} Stores the value
\code{bas\_fcts->grd\_phi[j](quad->lambda[i])[k]} for
$0\leq\code{j}<\mbox{\code{n\_bas\_fcts}}$,
$0\leq\code{i}<\mbox{\code{n\_points}}$, and
$0\leq\code{k}\leq d$;
%%
\kitem{D2\_phi} Matrix storing all second derivatives (with respect to the
barycentric coordinates) if the flag
\code{INIT\_D2\_PHI} is set;
\code{D2\_phi[i][j][k][l]} Stores the value
\code{bas\_fcts->D2\_phi[j](quad->lambda[i])[k][l]} for
$0\leq\code{j}<\mbox{\code{n\_bas\_fcts}}$,
$0\leq\code{i}<\mbox{\code{n\_points}}$, and
$0\leq\code{k,l}\leq d$.
%%
\kitem{D3\_phi} Matrix storing all third derivatives (with respect
to the barycentric coordinates) if the flag \code{INIT\_D3\_PHI} is
set;
\code{D3\_phi[i][j][k][l]} Stores the value
\code{bas\_fcts->D3\_phi[j](quad->lambda[i])[k][l][m]} for
$0\leq\code{j}<\mbox{\code{n\_bas\_fcts}}$,
$0\leq\code{i}<\mbox{\code{n\_points}}$, and
$0\leq\code{k,l,m}\leq d$.
%%
%%
\kitem{D4\_phi} Matrix storing all fourth derivatives (with respect
to the barycentric coordinates) if the flag \code{INIT\_D4\_PHI} is
set;
\code{D4\_phi[i][j][k][l]} Stores the value
\code{bas\_fcts->D4\_phi[j](quad->lambda[i])[k][l][m][n]} for
$0\leq\code{j}<\mbox{\code{n\_bas\_fcts}}$,
$0\leq\code{i}<\mbox{\code{n\_points}}$, and
$0\leq\code{k,l,m,n}\leq d$.
%%
\kitem{phi\_d} The directional part of vector-valued basis
functions, if that is constant on each element. This means, if
\code{bas\_fcts->rdim == \DOW} and \code{bas\_fcts->dir\_pw\_const},
then \code{phi\_d} contains valid data, probably after calling
\code{QUAD\_FAST.init\_element()} with the current element and the
instance of the \code{QUAD\_FAST} structure in question. See also
\secref{S:vector_bfcts}.
%%
\kitem{chain} If \code{bas\_fcts} forms part of a chain of basis
functions because the corresponding finite element space is a direct
sum, then this code{get\_quad\_fast()} will also generate a chain of
\code{QUAD\_FAST}-structures, one for each component. The chain
forms a doubly linked list, and the \code{chain}-component is the
list node. See also \secref{S:bfcts_chains} and
\secref{S:chain_impl}.
%%
\kitem{unchained} A clone of the current structure, but as single
element. Points back to the structure itself if the underlying basis
functions do not form part of chain of basis function sets. See
\secref{S:bfcts_chains} and \secref{S:chain_impl}.
%%
\kitem{INIT\_ELEMENT\_DECL} Per element initializer, see
\secref{S:init_element}.
%%
\kitem{internal} Pointer to internal meta-data stuff.
\end{descr}
%
A filled structure can be accessed by a call of
\fdx{get_quad_fast()@{\code{get\_quad\_fast()}}}%
\idx{numerical quadrature!get_quad_fast()@{\code{get\_quad\_fast()}}}%
\bv\begin{lstlisting}
const QUAD_FAST *get_quad_fast(const BAS_FCTS *, const QUAD *, U_CHAR);
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{get\_quad\_fast(bas\_fcts, quad, init\_flag)} \code{bas\_fcts}
is a pointer to a filled \code{BAS\_FCTS} structure,
\code{quad} a pointer to some quadrature (accessed by
\code{get\_quadrature()}, e.g.) and \code{init\_flag}
indicates which information should be filled into the
\code{QUAD\_FAST} structure; it may be one of, or a bitwise
\textsf{OR} of several of \code{INIT\_PHI}, \code{INIT\_GRD\_PHI},
\code{INIT\_D2\_PHI}; the function returns a pointer to a
filled \code{QUAD\_FAST} structure where all demanded information
is computed and stored.
All used \code{QUAD\_FAST} structures are stored in a linked
list and are identified uniquely by the members \code{quad} and
\code{bas\_fcts}; first, \code{get\_quad\_fast()} looks for a
matching structure in the linked list; if no structure is
found, a new structure is generated and linked to the list;
thus for one combination \code{bas\_fcts} and \code{quad} only
one \code{QUAD\_FAST} structure is created.
Then \code{get\_quad\_fast()} allocates memory for all
information demanded by \code{init\_flag} and which is not yet
initialized for this structure; only such information
is then computed and stored; on the first call for
\code{bas\_fcts} and \code{quad}, all information demanded
\code{init\_flag} is generated, on a subsequent call only
missing information is generated.
\code{get\_quad\_fast()} will return a \nil pointer, if
\code{INIT\_PHI} flag is set and \code{bas\_fcts->phi} is \nil,
\code{INIT\_GRD\_PHI} flag is set and
\code{bas\_fcts->grd\_phi} is \nil, and \code{INIT\_D2\_PHI}
flag is set and \code{bas\_fcts->D2\_phi} is \nil.
There may be several \code{QUAD\_FAST} structures in the list for
the same set of basis functions for different quadratures,
and there may be several \code{QUAD\_FAST} structures for one
quadrature for different sets of basis functions.
The function \code{get\_quad\_fast()} should not be called on
each element during mesh traversal, because it has to look in a
list for an existing entry for a set of basis functions and a
quadrature; a pointer to the \code{QUAD\_FAST} structure should
be accessed before mesh traversal and passed to the
element routine.
\end{descr}
Many functions using the \code{QUAD\_FAST} structure need vectors
for storing values at all quadrature points; for these functions
it can be of interest to get the count of the maximal number of
quadrature nodes used by the all initialized \code{quad\_fast}
structures in order to avoid several memory reallocations. This
count can be accessed by the function
\fdx{max_quad_points()@{\code{max\_quad\_points()}}}%
\idx{numerical quadrature!max_quad_points()@{\code{max\_quad\_points()}}}%
\bv\begin{lstlisting}
int max_quad_points(void);
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{max\_quad\_points()} returns the maximal number of quadrature
points for all yet initialized \code{quad\_fast} structures;
this value may change after a new initialization of a
\code{quad\_fast} structures;
this count is \emph{not} the maximal number of quadrature
points of all used \code{QUAD} structures, since new quadratures
can be used at any time without an initialization.
\end{descr}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Integration over subsimplices (walls)}%
\label{S:subsimplices}
The weak formulation of non-homogeneous Neumann or Robin boundary
values needs integration over $d-1$ dimensional boundary
simplices of $d$ dimensional mesh elements (compare \secref{book:S:Submeshes}),
and the evaluation of jump residuals for error estimators (compare Sections
\ref{book:S:adaptive_methods}, \ref{S:estimator}) needs integration over
all interior $d-1$ dimensional sub--simplices. The quadrature
formulas and data structures described above are available for any $d$
dimensional simplex, $d=0,1,2,3$. The above task can therefore be
accomplished by using a $d-1$ dimensional quadrature formula
and augmenting the corresponding $d$ dimensional barycentric
coordinates of quadrature points on edges/faces to $d+1$
dimensional coordinates on adjacent mesh elements.
When an integral over an edge/face involves values from both adjacent
elements (in the computation of jump residuals e.\,g.) it is
necessary to have a common orientation of the edge/face from both
elements. Only a common orientation of the edges/faces ensures that
augmenting $d$ dimensional barycentric coordinates of
quadrature points on the edge/face to $d+1$ dimensional
barycentric coordinates on the adjacent mesh elements results in the
same points from both sides.
This augmentation process, taking the relative orientation of
neighboring simplices into account, is taken care of by dedicated
co-dimension $1$ quadrature rules, see \secref{S:WALL_QUAD} and
\ref{S:WALL_QUAD_FAST}. Additionally, the calculation of Gram's
determinant for the $d-1$ dimensional transformation as well as
vertex/edge/face normals is needed. See \secref{S:bary_routines}
above.
Low-level access to the relative orientation of neighboring simplices
is provided through the routines and look-up tables
%%
\fdx{wall_orientation()@{\code{wall\_orientation()}}}%
\fdx{wall_rel_orientation()@{\code{wall\_rel\_orientation()}}}%
\ddx{sorted_wall_vertices_1d@{\code{sorted\_wall\_vertices\_1d}}}
\ddx{sorted_wall_vertices_2d@{\code{sorted\_wall\_vertices\_2d}}}
\ddx{sorted_wall_vertices_3d@{\code{sorted\_wall\_vertices\_3d}}}
\bv\begin{lstlisting}
int wall_orientation(int dim, const EL *el, int wall, int **vec);
int wall_rel_orientation(
int dim, const EL *el, const EL *neigh, int wall, int oppv);
const int sorted_wall_vertices_1d[N_WALLS_1D][DIM_FAC_1D][2*N_VERTICES_0D-1];
const int sorted_wall_vertices_2d[N_WALLS_2D][DIM_FAC_2D][2*N_VERTICES_1D-1];
const int sorted_wall_vertices_3d[N_WALLS_3D][DIM_FAC_3D][2*N_VERTICES_2D-1];
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{wall\_orientation(dim, el, wall, vec)} can be used to match
the local enumeration of the vertices of faces separating
neighbouring simplexes. The return value is a unique number between
\code{1} and \code{dim!}. On return \code{vec} -- if non-\nil --
contains a permutation of the local numbering of the vertices of
face number \code{wall} on \code{el}. If \code{neigh\_vec} is the
corresponding permutation for the neighbour element, then
\code{(*vec)[i]} and \code{(*neigh\_vec)[i]} refer to the same
vertex, e.g. \code{el\_info->coord[(*vec)[i]]} is the same as
\code{neigh\_info->coord[(*neigh\_vec)[i]]}.
Actually, the return value of \code{wall\_orientation()} is just the
index into the look-up tables
\code{sorted\_wall\_vertices\_Xd[][][]}, such that \code{vec}, if
non-\nil point upon return to
\code{sorted\_wall\_vertices\_Xd[wall][retval]}.
The principal purpose of this function is to match quadrature points
during the numerical integration of jumps of derivatives of finite
element function across the faces of the triangulation, see
\secref{S:subsimplices}.
\kitem{wall\_rel\_orientation(dim, el, neigh, wall, oppv)} can be
used to compute a relative orientation of a given wall separating
two elements with respect to both elements. The return value
\bv\begin{lstlisting}
perm = wall_rel_orientation(dim, el, neigh, wall, oppv);
\end{lstlisting}\ev
can be used as an offset into \code{sorted\_wall\_vertices\_Xd} in
the sense that
%%
\bv\begin{lstlisting}
nv = sorted_wall_vertices_Xd[oppv][perm][i];
\end{lstlisting}\ev
%%
matches
%%
\bv\begin{lstlisting}
v = vertex_of_wall_Xd[wall][i];
\end{lstlisting}\ev
%%
So it holds \code{el->dof[v][0] == neigh->dof[nv][0]}.
%%
\end{descr}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{The \code{WALL\_QUAD} data structure}%
\label{S:WALL_QUAD}
A collection of quadrature rules for the integration over walls (3d:
faces, 2d: edges) of a simplex. The quadrature points of these rules
are given in barycentric coordinates with \code{dim+1} valid
components; the component corresponding to the respective wall will be
set to zero.
Each of the quadrature rules \code{WALL\_QUAD\:\:quad[wall]} may have
its own \code{INIT\_ELEMENT} method. \code{INIT\_ELEMENT(el\_info,
WALL\_QUAD)} may or may not be called: it is legal to only call
\code{INIT\_ELEMENT(el\_info, WALL\_QUAD\:\:quad[wall])} individually.
If \code{INIT\_ELEMENT(el\_info, WALL\_QUAD)} is called, then it has
to initialize all quadrature rules for all walls, so the sub-ordinate
initializers need not be called in this case.
%%%
\ddx{WALL_QUAD@{\code{WALL\_QUAD}}}%
\idx{numerical quadrature!WALL_QUAD@{\code{WALL\_QUAD}}}
\bv\begin{lstlisting}[name=WALL_QUAD,label=T:WALL_QUAD]
typedef struct wall_quadrature WALL_QUAD;
struct wall_quadrature
{
const char *name;
int degree;
int dim;
int n_points_max;
QUAD quad[N_WALLS_MAX];
INIT_ELEMENT_DECL;
void *metadata;
};
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{name} Textual description of the quadrature.
%%
\kitem{degree} Quadrature is exact of degree \code{degree}.
%%
\kitem{dim} Quadrature for dimension \code{dim}; the barycentric
coordinates of the quadrature points have \code{dim+1} valid
components.
%%
\kitem{n\_points\_max} The maximal number of quadrature points.
%%
\kitem{quad} Quadrature rules for each wall. These are co-dimension
$1$ rules.
%%
\kitem{INIT\_ELEMENT\_DECL} Function pointer to a per-element
initializer. This pointer is always \nil for quadratures returned by
\code{get\_wall\_quad()}. External extension modules may make use of
it. See \secref{S:init_element}.
%%
\kitem{metadata} Pointer to an internal data structure for
per-element quadrature caches and the like.
\end{descr}
Functions for numerical quadrature are:
\fdx{get_wall_quad()@{\code{get\_wall\_quad()}}}%
\idx{numerical quadrature!get_wall_quad()@{\code{get\_wall\_quad()}}}%
\fdx{register_wall_quadrature()@{\code{register\_wall\_quadrature()}}}%
\idx{numerical quadrature!register_wall_quadrature()@{\code{register\_wall\_quadrature()}}}%
\bv\begin{lstlisting}
const WALL_QUAD *get_wall_quad(int dim, int degree);
void register_wall_quadrature(WALL_QUAD *wall_quad);
const QUAD *get_neigh_quad(const EL_INFO *el_info, const WALL_QUAD *wall_quad, int neigh);
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{get\_wall\_quad(dim, degree)} returns a pointer to a
\code{WALL\_QUAD} structure for numerical integration in \code{dim}
dimensions.
%%
\kitem{register\_wall\_quadrature(wall\_quad)} initializes the meta-data
for the given \code{WALL\_QUAD}, no need to call this if the
\code{WALL\_QUAD} has been acquired by \code{get\_wall\_quad()},
only needed for externally defined extension quadrature rules.
\end{descr}
\subsection{The \code{WALL\_QUAD\_FAST} data structure}
\label{S:WALL_QUAD_FAST}
Convenience structure for \code{WALL\_QUAD}: its is legal to call
\code{get\_quad\_fast(bas\_fcts, WALL\_QUAD::quad[wall], ...)}
(see \secref{S:QUAD_FAST} ``The \code{QUAD\_FAST} data structure'')
individually, however \code{get\_wall\_quad\_fast()} does this
in a single run. If \code{INIT\_ELEMENT(el\_info, WALL\_QUAD\_FAST)}
is called, then the sub-ordinate initializers
\code{INIT\_ELEMENT(el\_info,WALL\_QUAD\_FAST::quad\_fast[wall])}
need not be called.
\ddx{WALL_QUAD_FAST@{\code{WALL\_QUAD\_FAST}}}
\idx{numerical quadrature!WALL_QUAD_FAST@{\code{WALL\_QUAD\_FAST}}}
%%
\bv\begin{lstlisting}[label=T:WALL_QUAD_FAST]
typedef struct wall_quad_fast WALL_QUAD_FAST;
struct wall_quad_fast
{
const WALL_QUAD *wall_quad;
const BAS_FCTS *bas_fcts;
FLAGS init_flag;
const QUAD_FAST *quad_fast[N_WALLS_MAX];
INIT_ELEMENT_DECL;
};
\end{lstlisting}\ev
The entries yield following information:
\begin{descr}
\kitem{wall\_quad} values stored for numerical quadrature \code{quad};
\kitem{bas\_fcts} values stored for basis functions \code{bas\_fcts};
\kitem{init\_flag} indicates which information is initialized; may be
one of, or a bitwise \textsf{OR} of several of \code{INIT\_PHI},
\code{INIT\_GRD\_PHI}, \code{INIT\_D2\_PHI};
\kitem{\*quad\_fast[N\_WALLS\_MAX]} Pointer to \code{N\_WALLS\_MAX}
\code{quad\_fast} structures.
\kitem{INIT\_ELEMENT\_DECL} Function pointer to for a per-element
initialiser. This pointer is always \nil for quadratures returned by
\code{get\_quadrature()}, \code{get\_wall\_quad()} and
\code{get\_bndry\_quad()}. External extension modules make use of it.
See \secref{S:init_element}.
\end{descr}
\fdx{get_wall_quad_fast()@{\code{get\_wall\_quad\_fast()}}}%
\idx{numerical quadrature!get_wall_quad_fast()@{\code{get\_wall\_quad\_fast()}}}%
\fdx{get_neigh_quad()@{\code{get\_neigh\_quad()}}}%
\idx{numerical quadrature!get_neigh_quad()@{\code{get\_neigh\_quad()}}}%
\fdx{get_neigh_quad_fast()@{\code{get\_neigh\_quad\_fast()}}}%
\idx{numerical quadrature!get_neigh_quad_fast()@{\code{get\_neigh\_quad\_fast()}}}%
\bv\begin{lstlisting}
const WALL_QUAD *get_wall_quad_fast(const BAS_FCTS *, const WALL_QUAD *, FLAGS init_flag);
QUAD_FAST *get_neigh_quad_fast(const EL_INFO *el_info,
const WALL_QUAD_FAST *wqfast,
int neigh);
\end{lstlisting}\ev
Description:
\begin{descr}
\kitem{get\_wall\_quad\_fast(bas\_fcts, wall\_quad, init\_flag)}
\code{bas\_fcts}
is a pointer to a filled \code{BAS\_FCTS} structure,
\code{wall\_quad} a pointer to some quadrature (accessed by
\code{get\_wall\_quad()}, e.g.) and \code{init\_flag}
indicates which information should be filled into the
\code{QUAD\_FAST} structure. The function returns a pointer to a
filled \code{QUAD\_FAST} structure where all demanded information
is computed and stored.
%%
\kitem{get\_neigh\_quad(el\_info, wall\_quad, neigh)} returns a
suitable quadrature for integrating over the given wall (neigh number),
but the barycentric co-ordinates of \code{QUAD->lambda} are relative
to the neighbour element.
\kitem{get\_neigh\_quad\_fast(el\_info, wall\_quad, neigh)} returns a
suitable \code{QUAD\_FAST} structure for integrating over the given
wall, but relative to the neighbour element. If the returned
\code{QUAD\_FAST} object has a per-element initializer, then it must be
called with an \code{EL\_INFO} structure for the neighbour element.
It is also legal to just call
\code{get\_quad\_fast(bas\_fcts, get\_neigh\_quad(el\_info, wall\_quad, neigh), ...)} but \code{get\_neigh\_quad\_fast()} is slightly more efficient.
\end{descr}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Caching of geometric quantities on quadrature
nodes}
\label{S:fill_quad_el_cache}
Like for geometric quantities which are constant on a given
mesh-element it is useful to share geometric data attached to
quadrature nodes between different places of program code, see also
\secref{S:fill_el_geom_cache}. For this purpose there is a
per-quadrature-per-element cache, called \code{QUAD\_EL\_CACHE}, which
can be filled and accessed through calls to the function
\code{fill\_quad\_el\_cache()}. This is in particular useful for
higher-order parametric meshes, where for example the transformation
to the reference element is no longer piece-wise constant on each
element. Internally, the \code{QUAD\_EL\_CACHE} is maintained as part
of the ``metadata'' attached to each quadrature rule, see
\ref{T:QUAD}. The per-quadrature node cache and the related
definitions and proto-types are as follows:
%%
\bv\begin{lstlisting}[name=QUAD_EL_CACHE,label=T:QUAD_EL_CACHE]
typedef struct quad_el_cache QUAD_EL_CACHE;
struct quad_el_cache
{
EL *current_el;
FLAGS fill_flag;
REAL_D *world;
struct {
REAL *det;
REAL_BD *Lambda;
REAL_BDD *DLambda;
REAL_BD *grd_world;
REAL_BDB *D2_world;
REAL_BDBB *D3_world;
REAL *wall_det; /* for co-dim 1 */
REAL_D *wall_normal; /* for co-dim 1 */
REAL_DB *grd_normal; /* for co-dim 1 */
REAL_DBB *D2_normal; /* for co-dim 1 */
} param;
};
#define FILL_EL_QUAD_WORLD 0x0001
#define FILL_EL_QUAD_DET 0x0002
#define FILL_EL_QUAD_LAMBDA 0x0004
#define FILL_EL_QUAD_DLAMBDA 0x0008
#define FILL_EL_QUAD_GRD_WORLD 0x0010
#define FILL_EL_QUAD_D2_WORLD 0x0020
#define FILL_EL_QUAD_D3_WORLD 0x0040
#define FILL_EL_QUAD_WALL_DET 0x0100
#define FILL_EL_QUAD_WALL_NORMAL 0x0200
#define FILL_EL_QUAD_GRD_NORMAL 0x0400
#define FILL_EL_QUAD_D2_NORMAL 0x0800
static inline const QUAD_EL_CACHE *fill_quad_el_cache(const EL_INFO *el_info,
const QUAD *quad,
FLAGS fill);
\end{lstlisting}\ev
The quadrature cache can be obtained and filled by calls to
\code{fill\_quad\_el\_cache()}, see also below
\exampleref{E:fill_quad_el_cache}. The members of
\code{QUAD\_EL\_CACHE} have the following meaning:
\begin{descr}
\kitem{current\_el} For internal use only.
%%
\kitem{fill\_flag} A bit-mask, bit-wise or of the fill flags
listed above (\ref{T:QUAD_EL_CACHE}).
%%
\kitem{world} The world co-ordinates of the quadrature points,
filled by \code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_WORLD)}.
%%
\kitem{param} A cache for geometric quantities which are constant on
each element for affine-linear meshes, but vary between quadrature
points for higher-order parametric meshes.
\begin{descr}
\kitem{det} The determinant of the transformation to the reference
element, filled by
filled by \code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_DET)}.
%%
\kitem{Lambda} The derivative of the barycentric coordinates
w.r.t. the Cartesian coordinates, filled by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_LAMBDA)}.
%%
\kitem{DLambda} The second derivatives of the barycentric
coordinates w.r.t. the Cartesian coordinates, filled by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_DLAMBDA)}.
%%
\kitem{grd\_world} The first derivatives of the Cartesian
coordinates w.r.t. the barycentric coordinates, filled by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_GRD\_WORLD)}.
%%
\kitem{D2\_world} The second derivatives of the Cartesian
coordinates w.r.t. the barycentric coordinates, filled by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_D2\_WORLD)}.
%%
\kitem{D3\_world} The third derivatives of the Cartesian
coordinates w.r.t. the barycentric coordinates, filled by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_D3\_WORLD)}.
%%
\kitem{wall\_det} The determinant of the transformation of the
walls to the reference element's walls. This can be filled only
for co-dimension $1$ quadratures by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_WALL\_DET)}.
%%
\kitem{wall\_normal} The outer wall-normal. This can be filled
only for co-dimension $1$ quadratures by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_WALL\_NORMAL)}.
%%
\kitem{grd\_normal} The first derivative of the outer normal-field
with respect to the barycentric coordinates. This can be filled
only for co-dimension $1$ quadratures by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_GRD\_NORMAL)}.
%%
\kitem{D2\_normal} The second derivative of the outer normal-field
with respect to the barycentric coordinates. This can be filled
only for co-dimension $1$ quadratures by
\code{fill\_quad\_el\_cache(..., FILL\_EL\_QUAD\_D2\_NORMAL)}.
\end{descr}
\end{descr}
\begin{example}
\label{E:fill_quad_el_cache}
A simple example which computes the measure of the region occupied
by the mesh (of course, this can be achieved more efficiently by
computing a boundary integral \dots). This example is, of course,
quite artificial -- and in this context it would be more efficient
\emph{not} to read through the per-element caches.
%%
\bv\begin{lstlisting}[name=fill_quad_el_cache,label=C:quad_el_cache]
const PARAMERIC *param = mesh->parametric;
const QUAD *quad = get_quadrature(mesh->dim, 3 /* degree */);
REAL meas = 0.0;
TRAVERSE_FIRST(mesh, -1, CALL_LEAF_EL|FILL_COORDS) {
int iq;
if (param->init_element(el_info, param)) {
const QUAD_EL_CACHE *qelc = fill_quad_el_cache(el_info, quad, FILL_EL_QUAD_DET);
for (iq = 0; iq < quad->n_points; iq++) {
meas += quad->w[iq] * qelc->param.det[iq];
}
} else {
const EL_GEOM_CACHE *elgc = fill_el_geom_cache(el_info, FILL_EL_DET);
meas += elgc->det / (REAL)DIM_FAC(mesh->dim);
}
} TRAVERSE_NEXT()
\end{lstlisting}\ev
\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Functions for the evaluation of finite elements}
\label{S:eval}
Finite element functions are evaluated locally on single elements
using barycentric coordinates (compare \secref{book:S:eval_fe}). \ALBERTA
supplies several functions for calculating values and first and second
derivatives of finite element functions on single elements. Functions
for the calculation of derivatives are currently only implemented
for (non--parametric) simplices.
Recalling \mathref{book:E:uh_on_S} on page \pageref{book:E:uh_on_S} we obtain
for the value of a finite element function $\uh$ on an element $S$
\[
\uh(x(\lambda)) = \sum\limits_{i = 1}^m u^i_S\, \pbar^i(\lambda)
\qquad \mbox{for all } \lambda \in \Sbar,
\]
where $\left(\pbar^1,\dots,\pbar^m\right)$ is a basis of $\Pbar$ and
$\left(u_S^1,\dots,u_S^m\right)$ the local coefficient vector
of $\uh$ on $S$. Derivatives are evaluated on $S$ by
\[
\nabla u_h(x(\lambda)) = \Lambda^t
\sum_{i = 1}^m u_S^i \, \nablal \pbar^i(\lambda), \qquad \lambda \in \Sbar
\]
and
\[
D^2 u_h(x(\lambda)) = \Lambda^t \sum_{i = 1}^m u_S^i \,
D^2_\lambda \pbar^i(\lambda)\Lambda, \qquad \lambda \in \Sbar,
\]
where $\Lambda$ is the Jacobian of the barycentric coordinates,
compare \secref{book:S:eval_Dfe}.
These formulas are used for all evaluation routines. Information
about values of basis functions and their derivatives can be
calculated via function pointers in the \code{BAS\_FCTS} structure.
Additionally, the local coefficient vector and the Jacobian
of the barycentric coordinates are needed (for the calculation of
derivatives).
The following routines calculate values of a finite element function
at a single point, given in barycentric coordinates:
\fdx{eval_uh()@{\code{eval\_uh()}}}%
\idx{evaluation of finite element functions!eval_uh()@{\code{eval\_uh()}}}
\fdx{eval_grd_uh()@{\code{eval\_grd\_uh()}}}%
\idx{evaluation of finite element functions!eval_grd_uh()@{\code{eval\_grd\_uh()}}}%
\fdx{eval_D2_uh()@{\code{eval\_D2\_uh()}}}%
\idx{evaluation of finite element functions!eval_D2_uh()@{\code{eval\_D2\_uh()}}}%
\fdx{eval_uh_d()@{\code{eval\_uh\_d()}}}%
\idx{evaluation of finite element functions!eval_uh_d()@{\code{eval\_uh\_d()}}}
\fdx{eval_grd_uh_d()@{\code{eval\_grd\_uh\_d()}}}%
\idx{evaluation of finite element functions!eval_grd_uh_d()@{\code{eval\_grd\_uh\_d()}}}%
\fdx{eval_div_uh_d()@{\code{eval\_div\_uh\_d()}}}%
\idx{evaluation of finite element functions!eval_div_uh_d()@{\code{eval\_div\_uh\_d()}}}%
\fdx{eval_D2_uh_d()@{\code{eval\_D2\_uh\_d()}}}%
\idx{evaluation of finite element functions!eval_D2_uh_d()@{\code{eval\_D2\_uh\_d()}}}%
\fdx{eval_uh_dow()@{\code{eval\_uh\_dow()}}}%
\idx{evaluation of finite element functions!eval_uh_dow()@{\code{eval\_uh\_dow()}}}
\fdx{eval_grd_uh_dow()@{\code{eval\_grd\_uh\_dow()}}}%
\idx{evaluation of finite element functions!eval_grd_uh_dow()@{\code{eval\_grd\_uh\_dow()}}}%
\fdx{eval_div_uh_dow()@{\code{eval\_div\_uh\_dow()}}}%
\idx{evaluation of finite element functions!eval_div_uh_dow()@{\code{eval\_div\_uh\_dow()}}}%
\fdx{eval_D2_uh_dow()@{\code{eval\_D2\_uh\_dow()}}}%
\idx{evaluation of finite element functions!eval_D2_uh_dow()@{\code{eval\_D2\_uh\_dow()}}}%
\bv\begin{lstlisting}
REAL eval_uh(const REAL_B lambda, const EL_REAL_VEC *uh_loc,
const BAS_FCTS *bfcts);
REAL *eval_grd_uh(REAL_D result, const REAL_B lambda, const REAL_BD Lambda,
const EL_REAL_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_D *eval_D2_uh(REAL_DD result, const REAL_B lambda, const REAL_BD Lambda,
const EL_REAL_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL *eval_uh_d(REAL_D result, const REAL_B lambda,
const EL_REAL_D_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_D *eval_grd_uh_d(REAL_DD result, const REAL_B lambda,
const REAL_BD Lambda, const EL_REAL_D_VEC *uh_loc,
const BAS_FCTS *bfcts);
REAL eval_div_uh_d(const REAL_B lambda, const REAL_BD Lambda,
const EL_REAL_D_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_DD *eval_D2_uh_d(REAL_DDD result, const REAL_B lambda,
const REAL_BD Lambda, const EL_REAL_D_VEC *uh_loc,
const BAS_FCTS *bfcts);
REAL *eval_uh_dow(REAL_D result, const REAL_B lambda,
const EL_REAL_VEC_D *uh_loc, const BAS_FCTS *bfcts);
REAL_D *eval_grd_uh_dow(REAL_DD result, const REAL_B lambda,
const REAL_BD Lambda, const EL_REAL_VEC_D *uh_loc,
const BAS_FCTS *bfcts);
REAL eval_div_uh_dow(const REAL_B lambda, const REAL_BD Lambda,
const EL_REAL_VEC_D *uh_loc, const BAS_FCTS *bfcts);
REAL_DD *eval_D2_uh_dow(REAL_DDD result, const REAL_B lambda,
const REAL_BD Lambda, const EL_REAL_VEC_D *uh_loc,
const BAS_FCTS *bfcts);
\end{lstlisting}\ev
Description:
In the following $\code{lambda} = \lambda$ are the barycentric
coordinates at which the function is evaluated, $\code{Lambda} =
\Lambda$ is the Jacobian of the barycentric coordinates, \code{uh} the
local coefficient vector $\left(u_S^0,\dots,u_S^{\code{m}-1}\right)$
(where $u_S^i$ is a \code{REAL} or a \code{REAL\_D}), and
\code{bas\_fcts} is a pointer to a \code{BAS\_FCTS} structure, storing
information about the set of local basis functions
$\left(\pbar^0,\dots,\pbar^{\code{m}-1}\right)$.
All functions returning a pointer to a vector or matrix provide memory
for the vector or matrix in a statically allocated memory area. This
area is overwritten during the next call. If the first argument of such
a function is not \nil, then it is a pointer to a storage area where
the results are stored. This memory area must be of correct size, no
check is performed.
\begin{compatibility}
\label{compat:resultspace}
Former versions of \ALBERTA expected the argument providing optional
storage for the result at the last place in the parameter list. In
the current version of the library, storage for the result is still
optional, but generally passed as first argument to the respective
function.
\end{compatibility}
The functions for \DOW-valued discrete functions come in two variants,
one for discrete functions based on scalar-valued local basis function
sets, where the coefficients are \DOW-valued, and one for discrete
functions which may be based on either scalar-valued or \DOW-valued
local basis functions, modeled by \code{DOF\_REAL\_VEC\_D} -- and
locally by \code{EL\_REAL\_VEC\_D} -- objects. The names for the
latter functions have a \code{\dots\_dow} suffix, the others a
\code{\dots\_d} suffix. Besides the slightly differing argument types
the calling conventions for both variants are the same, so they are
documented together in the descriptions following below.
\begin{descr}
\kitem{eval\_uh(lambda, uh\_loc, bas\_fcts)} the function returns
$\uh(\lambda)$.
%%
\kitem{eval\_grd\_uh(result, lambda, Lambda, uh\_loc, bas\_fcts)} the function
returns a pointer \code{ptr} to a vector of length \DOW storing
$\nabla \uh(\lambda)$, i.e.
\[
\mbox{\code{ptr[i]}} = {\uh}_{,x_\code{i}}(\lambda),
\qquad \code{i}=0,\dots,\mbox{\DOW}-1;
\]
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{eval\_D2\_uh(result, lambda, Lambda, uh\_loc, bas\_fcts)} the function
returns a pointer \code{ptr} to a matrix of size
$(\DOW\times\DOW)$ storing $D^2 \uh(\lambda)$, i.e.
\[
\mbox{\code{ptr[i][j]}} = {\uh}_{,x_\code{i}x_\code{j}}(\lambda),
\qquad \code{i},\code{j}=0,\dots,\mbox{\DOW}-1;
\]
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{eval\_uh\_[d|dow](result, lambda, uh\_loc, bas\_fcts)}
the function
returns a pointer \code{ptr} to a vector of length \DOW storing
$\uh(\lambda)$, i.e.
\[
\mbox{\code{ptr[k]}} = {\uh}_\code{k}(\lambda),
\qquad \code{k}=0,\dots,\mbox{\DOW}-1;
\]
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{eval\_grd\_uh\_[d|dow](result, lambda, Lambda, uh\_loc, bas\_fcts)}
the function returns a pointer \code{ptr} to a vector of \DOW
vectors of length \DOW storing $\nabla {\uh}(\lambda)$, i.e.
\[
\mbox{\code{ptr[k][i]}} = {\uh}_{\code{k},x_\code{i}}(\lambda),
\qquad \code{k},\code{i}=0,\dots,\mbox{\DOW}-1;
\]
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{eval\_div\_uh\_[d|dow](lambda, Lambda, uh\_loc, bas\_fcts)} the function
returns \, $\div \uh(\lambda)$.
%%
\kitem{eval\_D2\_uh\_[d|dow](result, lambda, Lambda, uh\_loc, bas\_fcts)} the function
returns a pointer \code{ptr} to a vector of $(\DOW\times\DOW)$
matrices of length \DOW storing $D^2 {\uh}(\lambda)$, i.e.
\[
\mbox{\code{ptr[k][i][j]}} = {\uh}_{\code{k},x_\code{i}x_\code{j}}(\lambda),
\qquad \code{k},\code{i},\code{j}=0,\dots,\mbox{\DOW}-1;
\]
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\end{descr}
Using pre--computed values of basis functions at the evaluation point,
these routines can be implemented more efficiently.
\fdx{eval_uh_fast()@{\code{eval\_uh\_fast()}}}
\idx{evaluation of finite element functions!eval_uh_fast()@{\code{eval\_uh\_fast()}}}
\fdx{eval_grd_uh_fast()@{\code{eval\_grd\_uh\_fast()}}}
\idx{evaluation of finite element functions!eval_grd_uh_fast()@{\code{eval\_grd\_uh\_fast()}}}
\fdx{eval_D2_uh_fast()@{\code{eval\_D2\_uh\_fast()}}}
\idx{evaluation of finite element functions!eval_D2_uh_fast()@{\code{eval\_D2\_uh\_fast()}}}
\fdx{eval_uh_d_fast()@{\code{eval\_uh\_d\_fast()}}}
\idx{evaluation of finite element functions!eval_uh_d_fast()@{\code{eval\_uh\_d\_fast()}}}
\fdx{eval_grd_uh_d_fast()@{\code{eval\_grd\_uh\_d\_fast()}}}
\idx{evaluation of finite element functions!eval_grd_uh_d_fast()@{\code{eval\_grd\_uh\_d\_fast()}}}
\fdx{eval_div_uh_d_fast()@{\code{eval\_div\_uh\_d\_fast()}}}
\idx{evaluation of finite element functions!eval_div_uh_d_fast()@{\code{eval\_div\_uh\_d\_fast()}}}
\fdx{eval_D2_uh_d_fast()@{\code{eval\_D2\_uh\_d\_fast()}}}
\idx{evaluation of finite element functions!eval_D2_uh_d_fast()@{\code{eval\_D2\_uh\_d\_fast()}}}
\fdx{eval_uh_dow_fast()@{\code{eval\_uh\_dow\_fast()}}}
\idx{evaluation of finite element functions!eval_uh_dow_fast()@{\code{eval\_uh\_dow\_fast()}}}
\fdx{eval_grd_uh_dow_fast()@{\code{eval\_grd\_uh\_dow\_fast()}}}
\idx{evaluation of finite element functions!eval_grd_uh_dow_fast()@{\code{eval\_grd\_uh\_dow\_fast()}}}
\fdx{eval_div_uh_dow_fast()@{\code{eval\_div\_uh\_dow\_fast()}}}
\idx{evaluation of finite element functions!eval_div_uh_dow_fast()@{\code{eval\_div\_uh\_dow\_fast()}}}
\fdx{eval_D2_uh_dow_fast()@{\code{eval\_D2\_uh\_dow\_fast()}}}
\idx{evaluation of finite element functions!eval_D2_uh_dow_fast()@{\code{eval\_D2\_uh\_dow\_fast()}}}
\bv\begin{lstlisting}
REAL eval_uh_fast(const EL_REAL_VEC *uh_loc, const QUAD_FAST *qfast, int iq);
const REAL *eval_grd_uh_fast(REAL_D grd_uh, const REAL_BD Lambda,
const EL_REAL_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL_D *eval_D2_uh_fast(REAL_DD result, const REAL_BD Lambda,
const EL_REAL_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL *eval_uh_d_fast(REAL_D result, const EL_REAL_D_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL_D *eval_grd_uh_d_fast(REAL_DD result, const REAL_BD Lambda,
const EL_REAL_D_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL eval_div_uh_d_fast(const REAL_BD Lambda, const EL_REAL_D_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL_DD *eval_D2_uh_d_fast(REAL_DDD result, const REAL_BD Lambda,
const EL_REAL_D_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL *eval_uh_dow_fast(REAL_D result, const EL_REAL_VEC_D *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL_D *eval_grd_uh_dow_fast(REAL_DD result, const REAL_BD Lambda,
const EL_REAL_VEC_D *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL eval_div_uh_dow_fast(const REAL_BD Lambda, const EL_REAL_VEC_D *uh_loc,
const QUAD_FAST *qfast, int iq);
const REAL_DD *eval_D2_uh_dow_fast(REAL_DDD result, const REAL_BD Lambda,
const EL_REAL_VEC_D *uh_loc,
const QUAD_FAST *qfast, int iq);
\end{lstlisting}\ev
\begin{compatibility}
\label{compat:evalcallconv}
Former versions of \ALBERTA didn't expect the arguments
\begin{lstlisting}
..., const QUAD_FAST *qfast, int iq, ...
\end{lstlisting}
-- meaning the \hyperref[S:QUAD_FAST]{quadrature cache} and the
index of the quadrature point -- but instead expected the actual
cached-values to be passed, i.e. for the computation of the gradient
\begin{lstlisting}
..., qfast->grd_phi[iq], qfast->n_bas_fcts, ...
\end{lstlisting}
There is some potential for confusion, in particular because the
proto-types listed in the old documentation often omit the parameter
name and only give the parameter type. In the new version,
\lstinline!.., int iq, ...! denotes the index of the quadrature
point. The number of basis functions on the reference element is not
needed, because the evaluation functions fetch this quantity
themselves from the \hyperref[S:QUAD_FAST]{\code{QUAD\_FAST}} data
structure.
\end{compatibility}
Description:
In the following $\code{Lambda} = \Lambda$ denotes the Jacobian of the
barycentric coordinates, \code{uh\_loc} the local coefficient vector (of
type \hyperref[T:EL_REAL_VEC]{\code{EL\_REAL\_VEC}},
\hyperref[T:EL_REAL_D_VEC]{\code{EL\_REAL\_D\_VEC}} etc.) on an element.
\begin{descr}
\kitem{eval\_uh\_fast(uh\_loc, qfast, iq)} the function returns $\uh(\lambda)$;
\code{qfast} is a quadrature cache storing the values
$\pbar^0(\lambda),\dots,\pbar^{\code{m}-1}(\lambda)$.
%%
\kitem{eval\_grd\_uh\_fast(grd, Lambda, uh\_loc, qfast, iq)}
the function returns a pointer \code{ptr} to a vector of length
\DOW storing $\nabla \uh(\lambda)$, i.e.
\[
\mbox{\code{ptr[i]}} = {\uh}_{,x_\code{i}}(\lambda),
\qquad \code{i}=0,\dots,\mbox{\DOW}-1;
\]
\code{grd} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
\code{qfast} is a quadrature cache storing
$\nablal \pbar^0(\lambda),\dots,\nablal \pbar^{\code{m}-1}(\lambda)$;
%%
\kitem{eval\_D2\_uh\_fast(D2, Lambda, uh\_loc, qfast, iq)} the function
returns a pointer \code{ptr} to a matrix of size
$(\DOW\times\DOW)$ storing $D^2 \uh(\lambda)$, i.e.
\[
\mbox{\code{ptr[i][j]}} = {\uh}_{,x_\code{i}x_\code{j}}(\lambda),
\qquad \code{i},\code{j}=0,\dots,\mbox{\DOW}-1;
\]
\code{D2} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
\code{qfast} is a quadrature cache storing
$D^2_\lambda \pbar^0(\lambda),\dots,D2_\lambda\pbar^{\code{m}-1}
(\lambda)$.
%%
\kitem{eval\_uh\_[d|dow]\_fast(result, uh\_loc, qfast, iq)} the function
returns a pointer \code{ptr} to a vector of \DOW vectors of
length \DOW storing $\nabla {\uh}(\lambda)$, i.e.
\[
\mbox{\code{ptr[k][i]}} = {\uh}_{\code{k},x_\code{i}}(\lambda),
\qquad \code{k},\code{i}=0,\dots,\mbox{\DOW}-1;
\]
\code{qfast} is a quadrature cache storing the values
$\pbar^0(\lambda),\dots,\pbar^{\code{m}-1}(\lambda)$;
\code{result} is optional and provides storage for the resulty if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{eval\_grd\_uh\_[d|dow]\_fast(grd, Lambda, uh\_loc, qfast, iq)}
the function returns a pointer \code{ptr} to a vector of \DOW
vectors of length \DOW storing $\nabla {\uh}(\lambda)$, i.e.
\[
\mbox{\code{ptr[k][i]}} = {\uh}_{\code{k},x_\code{i}}(\lambda),
\qquad \code{k},\code{i}=0,\dots,\mbox{\DOW}-1;
\]
\code{qfast} is a quadrature cache storing
$\nablal \pbar^0(\lambda),\dots,\nablal
\pbar^{\code{m}-1}(\lambda)$;
\code{grd} is optional storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{eval\_div\_uh\_[d|dow]\_fast(Lambda, uh\_loc, qfast, iq)} the function
returns $\div \uh(\lambda)$;
\code{qfast} is a quadrature cache storing
$\nablal \pbar^0(\lambda),\dots,\nablal \pbar^{\code{m}-1}(\lambda)$.
Unused entries must be set to \code{0.0}.
%%
\kitem{eval\_D2\_uh\_[d|dow]\_fast(D2, Lambda, uh\_loc, qfast, iq)}
the function returns a pointer \code{ptr} to a vector of
$(\DOW\times\DOW)$ matrices of length \DOW storing
$D^2 {\uh}(\lambda)$, i.e.
\[
\mbox{\code{ptr[k][i][j]}} = {\uh}_{\code{k},x_\code{i}x_\code{j}}(\lambda),
\qquad \code{k},\code{i},\code{j}=0,\dots,\mbox{\DOW}-1;
\]
\code{qfast} is a quadrature cache storing
$D^2_\lambda \pbar^0(\lambda),\dots,D2_\lambda\pbar^{\code{m}-1}
(\lambda)$;
\code{D2} is optional storage for the result if non-\nil.
See \compatref{compat:resultspace}.
\end{descr}
One important task is the evaluation of finite element functions at
all quadrature nodes for a given quadrature formula. Using the
\code{QUAD\_FAST} data structures, the values of the basis functions
are known at the quadrature nodes which results in an efficient
calculation of values and derivatives of finite element functions
at these quadrature points.
\fdx{uh_at_qp()@{\code{uh\_at\_qp()}}}%
\idx{evaluation of finite element functions!uh_at_qp()@{\code{uh\_at\_qp()}}}%
\idx{numerical quadrature!uh_at_qp()@{\code{uh\_at\_qp()}}}%
\fdx{grd_uh_at_qp()@{\code{[param\_]grd\_uh\_at\_qp()}}}%
\idx{evaluation of finite element functions!grd_uh_at_qp()@{\code{[param\_]grd\_uh\_at\_qp()}}}%
\idx{numerical quadrature!grd_uh_at_qp()@{\code{[param\_]grd\_uh\_at\_qp()}}}%
\fdx{D2_uh_at_qp()@{\code{[param\_]D2\_uh\_at\_qp()}}}
\idx{evaluation of finite element functions!D2_uh_at_qp()@{\code{[param\_]D2\_uh\_at\_qp()}}}
\idx{numerical quadrature!D2_uh_at_qp()@{\code{[param\_]D2\_uh\_at\_qp()}}}
\fdx{uh_d_at_qp()@{\code{uh\_d\_at\_qp()}}}%
\idx{evaluation of finite element functions!uh_d_at_qp()@{\code{uh\_d\_at\_qp()}}}%
\idx{numerical quadrature!uh_d_at_qp()@{\code{uh\_d\_at\_qp()}}}%
\fdx{grd_uh_d_at_qp()@{\code{[param\_]grd\_uh\_d\_at\_qp()}}}%
\idx{evaluation of finite element functions!grd_uh_d_at_qp()@{\code{[param\_]grd\_uh\_d\_at\_qp()}}}%
\idx{numerical quadrature!grd_uh_d_at_qp()@{\code{[param\_]grd\_uh\_d\_at\_qp()}}}%
\fdx{div_uh_d_at_qp()@{\code{[param\_]div\_uh\_d\_at\_qp()}}}%
\idx{evaluation of finite element functions!div_uh_d_at_qp()@{\code{[param\_]div\_uh\_d\_at\_qp()}}}%
\idx{numerical quadrature!div_uh_d_at_qp()@{\code{[param\_]div\_uh\_d\_at\_qp()}}}%
\fdx{D2_uh_d_at_qp()@{\code{[param\_]D2\_uh\_d\_at\_qp()}}}%
\idx{evaluation of finite element functions!D2_uh_d_at_qp()@{\code{[param\_]D2\_uh\_d\_at\_qp()}}}%
\idx{numerical quadrature!D2_uh_d_at_qp()@{\code{[param\_]D2\_uh\_d\_at\_qp()}}}%
\fdx{uh_dow_at_qp()@{\code{uh\_dow\_at\_qp()}}}%
\idx{evaluation of finite element functions!uh_dow_at_qp()@{\code{uh\_dow\_at\_qp()}}}%
\idx{numerical quadrature!uh_dow_at_qp()@{\code{uh\_dow\_at\_qp()}}}%
\fdx{grd_uh_dow_at_qp()@{\code{[param\_]grd\_uh\_dow\_at\_qp()}}}%
\idx{evaluation of finite element functions!grd_uh_dow_at_qp()@{\code{[param\_]grd\_uh\_dow\_at\_qp()}}}%
\idx{numerical quadrature!grd_uh_dow_at_qp()@{\code{[param\_]grd\_uh\_dow\_at\_qp()}}}%
\fdx{div_uh_dow_at_qp()@{\code{[param\_]div\_uh\_dow\_at\_qp()}}}%
\idx{evaluation of finite element functions!div_uh_dow_at_qp()@{\code{[param\_]div\_uh\_dow\_at\_qp()}}}%
\idx{numerical quadrature!div_uh_dow_at_qp()@{\code{[param\_]div\_uh\_dow\_at\_qp()}}}%
\fdx{D2_uh_dow_at_qp()@{\code{[param\_]D2\_uh\_dow\_at\_qp()}}}%
\idx{evaluation of finite element functions!D2_uh_dow_at_qp()@{\code{[param\_]D2\_uh\_dow\_at\_qp()}}}%
\idx{numerical quadrature!D2_uh_dow_at_qp()@{\code{[param\_]D2\_uh\_dow\_at\_qp()}}}%
\bv\begin{lstlisting}
REAL *uh_at_qp(REAL *result, const QUAD_FAST *qfast,
const EL_REAL_VEC *uh_loc);
REAL_D *grd_uh_at_qp(REAL_D *result, const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_VEC *uh_loc);
REAL_DD *D2_uh_at_qp(REAL_DD *result, const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_VEC *uh_loc);
REAL_D *param_grd_uh_at_qp(REAL_D vec[], const QUAD_FAST *qfast,
const REAL_BD Lambda[], const EL_REAL_VEC *uh_loc);
REAL_DD *param_D2_uh_at_qp(REAL_DD *result, const QUAD_FAST *qfast,
const REAL_BD Lambda[], const REAL_BDD DLambda[],
const EL_REAL_VEC *uh_loc);
REAL_D *uh_d_at_qp(REAL_D *result, const QUAD_FAST *qfast,
const EL_REAL_D_VEC *uh_loc);
REAL_DD *grd_uh_d_at_qp(REAL_DD *result, const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_D_VEC *uh_loc);
REAL *div_uh_d_at_qp(REAL *result, const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_D_VEC *uh_loc);
REAL_DDD *D2_uh_d_at_qp(REAL_DDD vec[], const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_D_VEC *uh_loc);
REAL_DD *param_grd_uh_d_at_qp(REAL_DD vec[], const QUAD_FAST *qfast,
const REAL_BD Lambda[],
const EL_REAL_D_VEC *uh_loc);
REAL *param_div_uh_d_at_qp(REAL vec[], const QUAD_FAST *qfast,
const REAL_BD Lambda[],
const EL_REAL_D_VEC *uh_loc);
REAL_DDD *param_D2_uh_d_at_qp(REAL_DDD vec[], const QUAD_FAST *qfast,
const REAL_BD grd_lam[],
const REAL_BDD DLambda[],
const EL_REAL_D_VEC *uh_loc);
REAL_D *uh_dow_at_qp(REAL_D *result, const QUAD_FAST *qfast,
const EL_REAL_VEC_D *uh_loc);
REAL_DD *grd_uh_dow_at_qp(REAL_DD *result, const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_VEC_D *uh_loc);
REAL *div_uh_dow_at_qp(REAL *result, const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_VEC_D *uh_loc);
REAL_DDD *D2_uh_dow_at_qp(REAL_DDD vec[], const QUAD_FAST *qfast,
const REAL_BD Lambda, const EL_REAL_VEC_D *uh_loc);
REAL_DD *param_grd_uh_dow_at_qp(REAL_DD vec[], const QUAD_FAST *qfast,
const REAL_BD *Lambda,
const EL_REAL_VEC_D *uh_loc);
REAL *param_div_uh_dow_at_qp(REAL vec[], const QUAD_FAST *qfast,
const REAL_BD *Lambda,
const EL_REAL_VEC_D *uh_loc);
REAL_DDD *param_D2_uh_dow_at_qp(REAL_DDD *result, const QUAD_FAST *qfast,
const REAL_BD *Lambda, const REAL_BDD *DLambda,
const EL_REAL_VEC_D *uh_loc);
\end{lstlisting}\ev
Description:
In the following \code{uh\_loc} denotes the local coefficient vector (of
type \hyperref[T:EL_REAL_VEC]{\code{EL\_REAL\_VEC}},
\hyperref[T:EL_REAL_D_VEC]{\code{EL\_REAL\_D\_VEC}} etc.) on an element.
\begin{descr}
\kitem{uh\_at\_qp(result, qfast, uh\_loc)} the function returns a pointer
\code{ptr} to a vector of length \code{qfast->n\_points} storing the
values of $\uh$ at all quadrature points of \code{qfast->quad}, i.e.
\[
\mbox{\code{ptr[l]}} = \uh(\mbox{\code{qfast->quad->lambda[l]}})
\]
where $\code{l}=0,\dots,\mbox{\code{qfast->quad->n\_points}}-1$;
the \code{INIT\_PHI} flag must be set in \code{qfast->init\_flag};
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{grd\_uh\_at\_qp(result, qfast, Lambda, uh\_loc)} the function returns
a pointer \code{ptr} to a vector of length \code{qfast->n\_points}
of \DOW vectors storing $\nabla \uh$ at all quadrature points of
\code{qfast->quad}, i.e.
\[
\mbox{\code{ptr[l][i]}} =
{\uh}_{,x_\code{i}}(\mbox{\code{qfast->quad->lambda[l]}})
\]
where $\code{l}=0,\dots,\mbox{\code{qfast->quad->n\_points}}-1$, and
$\code{i}=0,\dots,\mbox{\DOW}-1$;
the \code{INIT\_GRD\_PHI} flag must be set in
\code{qfast->init\_flag};
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{D2\_uh\_at\_qp(result, qfast, Lambda, uh\_loc)}
%%
\kitem{param\_grd\_uh\_at\_qp(result, qfast, Lambdas, uh\_loc)} version for
parametric meshes; must be passed a vector storing the gradients of
the barycentric coordinates at each quadrature point. The same holds
for the other \code{param\_}-prefixed routines.
%%
\kitem{[param\_]D2\_uh\_at\_qp(result, qfast, Lambda[s], uh\_loc, D2)} The
function returns a pointer \code{ptr} to a vector of length
\code{qfast->n\_points} of $(\DOW\times\DOW)$ matrices storing $D^2
\uh$ at all quadrature points of \code{qfast->quad}, i.e.
\[
\mbox{\code{ptr[l][i][j]}} =
{\uh}_{,x_\code{i}x_\code{j}}(\mbox{\code{qfast->quad->lambda[l]}})
\]
where $\code{l}=0,\dots,\mbox{\code{qfast->quad->n\_points}}-1$, and
$\code{i},\code{j}=0,\dots,\mbox{\DOW}-1$;
the \code{INIT\_D2\_PHI} flag must be set in
\code{qfast->init\_flag};
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{uh\_[d|dow]\_at\_qp(result, qfast, uh\_loc)} The function returns a pointer
\code{ptr} to a vector of length \code{qfast->n\_points} of \DOW
vectors storing the values of $\uh$ at all quadrature points of
\code{qfast->quad}, i.e.
\[
\mbox{\code{ptr[l][k]}} =
{\uh}_\code{k}(\mbox{\code{qfast->quad->lambda[l]}})
\]
where $\code{l}=0,\dots,\mbox{\code{qfast->quad->n\_points}}-1$, and
$\code{k}=0,\dots,\mbox{\DOW}-1$;
the \code{INIT\_PHI} flag must be set in \code{qfast->init\_flag};
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{grd\_uh\_[d|dow]\_at\_qp(result, qfast, Lambda, uh\_loc)}
%%
\kitem{div\_uh\_[d|dow]\_at\_qp(result, qfast, Lambda, uh\_loc)}
%%
\kitem{D2\_uh\_[d|dow]\_at\_qp(result, qfast, Lambda[], uh\_loc)} The function
returns a pointer \code{ptr} to a vector of length
\code{qfast->n\_points} of $(\DOW\times\DOW\times\DOW)$ tensors
storing $D^2 \uh$ at all quadrature points \code{qfast->quad}, i.e.
\[
\mbox{\code{ptr[l][k][i][j]}} =
{\uh}_{\code{k},x_\code{i}x_\code{j}}(\mbox{\code{qfast->quad->lambda[l]}})
\]
where $\code{l}=0,\dots,\mbox{\code{qfast->quad->n\_points}}-1$, and
$\code{k},\code{i},\code{j}=0,\dots,\mbox{\DOW}-1$;
the \code{INIT\_D2\_PHI} flag must be set in
\code{qfast->init\_flag};
\code{result} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{param\_grd\_uh\_[d|dow]\_at\_qp(vec[], qfast, Lambda[], uh\_loc)} The
function returns a pointer \code{ptr} to a vector of length
\code{qfast->n\_points} of $(\DOW\times\DOW)$ matrices storing
$\nabla \uh$ at all quadrature points of \code{qfast->quad}, i.e.
\[
\mbox{\code{ptr[l][k][i]}} =
{\uh}_{\code{k},x_\code{i}}(\mbox{\code{qfast->quad->lambda[l]}})
\]
where $\code{l}=0,\dots,\mbox{\code{qfast->quad->n\_points}}-1$, and
$\code{k},\code{i}=0,\dots,\mbox{\DOW}-1$;
the \code{INIT\_GRD\_PHI} flag must be set in
\code{qfast->init\_flag};
\code{vec} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
%%
\kitem{param\_div\_uh\_[d|dow]\_at\_qp(result[], qfast, Lambda[], uh\_loc)}
%%
\kitem{param\_D2\_uh\_[d|dow]\_at\_qp(result, qfast, Lambda, DLambda, uh\_loc)}
Second derivatives for parametric meshes. Note that one needs the
second derivatives \code{DLambda} of the barycentric co-ordinates
with respect to the cartesian co-ordiantes for this function. Also
note that -- in the case of non-zero co-dimension -- the matrix
$(\ul\nabla(\ul\nabla u)_i)_j$ built from the components of the
second tangential derivatives is \emph{not} symmetric in general.
\code{vec} is optional and provides storage for the result if non-\nil.
See \compatref{compat:resultspace}.
\end{descr}
\fdx{eval_bar_grd_uh()@{\code{eval\_bar\_grd\_uh()}}}
\fdx{eval_bar_grd_uh_d()@{\code{eval\_bar\_grd\_uh\_d()}}}
\fdx{eval_bar_grd_uh_dow()@{\code{eval\_bar\_grd\_uh\_dow()}}}
\fdx{eval_bar_grd_uh_fast()@{\code{eval\_bar\_grd\_uh\_fast()}}}
\fdx{eval_bar_grd_uh_d_fast()@{\code{eval\_bar\_grd\_uh\_d\_fast()}}}
\fdx{eval_bar_grd_uh_dow_fast()@{\code{eval\_bar\_grd\_uh\_dow\_fast()}}}
\fdx{bar_grd_uh_at_qp()@{\code{bar\_grd\_uh\_at\_qp()}}}
\fdx{bar_grd_uh_d_at_qp()@{\code{bar\_grd\_uh\_d\_at\_qp()}}}
\fdx{bar_grd_uh_dow_at_qp()@{\code{bar\_grd\_uh\_dow\_at\_qp()}}}
\fdx{eval_bar_D2_uh()@{\code{eval\_bar\_D2\_uh()}}}
\fdx{eval_bar_D2_uh_d()@{\code{eval\_bar\_D2\_uh\_d()}}}
\fdx{eval_bar_D2_uh_dow()@{\code{eval\_bar\_D2\_uh\_dow()}}}
\fdx{eval_bar_D2_uh_fast()@{\code{eval\_bar\_D2\_uh\_fast()}}}
\fdx{eval_bar_D2_uh_d_fast()@{\code{eval\_bar\_D2\_uh\_d\_fast()}}}
\fdx{eval_bar_D2_uh_dow_fast()@{\code{eval\_bar\_D2\_uh\_dow\_fast()}}}
\fdx{bar_D2_uh_at_qp()@{\code{bar\_D2\_uh\_at\_qp()}}}
\fdx{bar_D2_uh_d_at_qp()@{\code{bar\_D2\_uh\_d\_at\_qp()}}}
\fdx{bar_D2_uh_dow_at_qp()@{\code{bar\_D2\_uh\_dow\_at\_qp()}}}
\bv\begin{lstlisting}
REAL *eval_bar_grd_uh(REAL_B result, const REAL_B lambda,
const EL_REAL_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_B *eval_bar_grd_uh_d(REAL_DB result, const REAL_B lambda,
const EL_REAL_D_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_B *eval_bar_grd_uh_dow(REAL_DB result, const REAL_B lambda,
const EL_REAL_VEC_D *uh_loc,
const BAS_FCTS *bfcts);
REAL *eval_bar_grd_uh_fast(REAL_B result, const EL_REAL_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL_B *eval_bar_grd_uh_d_fast(REAL_DB result, const EL_REAL_D_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL_B *eval_bar_grd_uh_dow_fast(REAL_DB result, const EL_REAL_VEC_D *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL_B *bar_grd_uh_at_qp(REAL_B *result, const QUAD_FAST *qfast,
const EL_REAL_VEC *uh_loc);
REAL_DB *bar_grd_uh_d_at_qp(REAL_DB *result, const QUAD_FAST *qfast,
const EL_REAL_D_VEC *uh_loc);
REAL_DB *bar_grd_uh_dow_at_qp(REAL_DB *result, const QUAD_FAST *fast,
const EL_REAL_VEC_D *uh_loc);
REAL_B *eval_bar_D2_uh(REAL_BB result, const REAL_B lambda,
const EL_REAL_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_BB *eval_bar_D2_uh_d(REAL_DBB result, const REAL_B lambda,
const EL_REAL_D_VEC *uh_loc, const BAS_FCTS *bfcts);
REAL_BB *eval_bar_D2_uh_dow(REAL_DBB result, const REAL_B lambda,
const EL_REAL_VEC_D *uh_loc,
const BAS_FCTS *bfcts);
REAL_B *eval_bar_D2_uh_fast(REAL_BB result, const EL_REAL_VEC *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL_BB *eval_bar_D2_uh_d_fast(REAL_DBB result, const EL_REAL_D_VEC *uh_loc,
const QUAD_FAST *qfast, int iq, bool update)
REAL_BB *eval_bar_D2_uh_dow_fast(REAL_DBB result, const EL_REAL_VEC_D *uh_loc,
const QUAD_FAST *qfast, int iq);
REAL_BB *bar_D2_uh_at_qp(REAL_BB *result, const QUAD_FAST *qfast,
const EL_REAL_VEC *uh_loc);
REAL_DBB *bar_D2_uh_d_at_qp(REAL_DBB vec[], const QUAD_FAST *qfast,
const EL_REAL_D_VEC *uh_loc);
REAL_DBB *bar_D2_uh_dow_at_qp(REAL_DBB vec[], const QUAD_FAST *qfast,
const EL_REAL_VEC_D *uh_loc);
\end{lstlisting}\ev
Description: These functions compute the respective derivatives with
respect to barycentric co-ordinates. Otherwise they are functionally
equivalent to the functions without the \code{bar\_}-prefix.
%\begin{descr}
%\kitem{eval\_bar\_grd\_uh(result, lambda, uh\_loc, bfcts)}
%\kitem{eval\_bar\_grd\_uh\_d(result, lambda, uh\_loc, bfcts)}
%\kitem{eval\_bar\_grd\_uh\_dow(result, lambda, uh\_loc, bfcts)}
%\kitem{eval\_bar\_grd\_uh\_fast(result, uh\_loc, qfast, iq)}
%\kitem{eval\_bar\_grd\_uh\_d\_fast(result, uh\_loc, qfast, iq)}
%\kitem{eval\_bar\_grd\_uh\_dow\_fast(result, uh\_loc, qfast, iq)}
%\kitem{bar\_grd\_uh\_at\_qp(result, qfast, uh\_loc)}
%\kitem{bar\_grd\_uh\_d\_at\_qp(result, qfast, uh\_loc)}
%\kitem{bar\_grd\_uh\_dow\_at\_qp(result, qfast, uh\_loc)}
%\kitem{eval\_bar\_D2\_uh(result, lambda, uh\_loc, bfcts)}
%\kitem{eval\_bar\_D2\_uh\_d(result, lambda, uh\_loc, bfcts)}
%\kitem{eval\_bar\_D2\_uh\_dow(result, lambda, uh\_loc, bfcts)}
%\kitem{eval\_bar\_D2\_uh\_fast(result, uh\_loc, qfast, iq)}
%\kitem{eval\_bar\_D2\_uh\_d\_fast(result, uh\_loc, qfast, iq)}
%\kitem{eval\_bar\_D2\_uh\_dow\_fast(result, uh\_loc, qfast, iq)}
%\kitem{bar\_D2\_uh\_at\_qp(result, qfast, uh\_loc)}
%\kitem{bar\_D2\_uh\_d\_at\_qp(result, qfast, uh\_loc)}
%\kitem{bar\_D2\_uh\_dow\_at\_qp(result, qfast, uh\_loc)}
%\end{descr}
\section{Calculation of norms for finite element functions}\label{S:eval_norm}
\ALBERTA supplies functions for the calculation of the $L^2$ norm and
$H^1$ semi--norm of a given scalar or vector valued finite element
function.
%%
\fdx{H1_norm_uh()@{\code{H1\_norm\_uh()}}}
\idx{evaluation tools!H1_norm_uh()@{\code{H1\_norm\_uh()}}}
\fdx{L2_norm_uh()@{\code{L2\_norm\_uh()}}}
\idx{evaluation tools!L2_norm_uh()@{\code{L2\_norm\_uh()}}}
\fdx{H1_norm_uh_d()@{\code{H1\_norm\_uh\_d()}}}
\idx{evaluation tools!H1_norm_uh_d()@{\code{H1\_norm\_uh\_d()}}}
\fdx{L2_norm_uh_d()@{\code{L2\_norm\_uh\_d()}}}
\idx{evaluation tools!L2_norm_uh_d()@{\code{L2\_norm\_uh\_d()}}}
\fdx{H1_norm_uh_dow()@{\code{H1\_norm\_uh\_dow()}}}
\idx{evaluation tools!H1_norm_uh_dow()@{\code{H1\_norm\_uh\_dow()}}}
\fdx{L2_norm_uh_dow()@{\code{L2\_norm\_uh\_dow()}}}
\idx{evaluation tools!L2_norm_uh_dow()@{\code{L2\_norm\_uh\_dow()}}}
\bv\begin{lstlisting}[label=P:DISC_FCT_NORMS]
REAL H1_norm_uh(const QUAD *, const DOF_REAL_VEC *);
REAL L2_norm_uh(const QUAD *, const DOF_REAL_VEC *);
REAL H1_norm_uh_d(const QUAD *, const DOF_REAL_D_VEC *);
REAL L2_norm_uh_d(const QUAD *, const DOF_REAL_D_VEC *);
REAL H1_norm_uh_dow(const QUAD *, const DOF_REAL_VEC_D *);
REAL L2_norm_uh_dow(const QUAD *, const DOF_REAL_VEC_D *);
\end{lstlisting}\ev
\paragraph{Descriptions}
\begin{descr}
\kitem{H1\_norm\_uh(quad, uh)}
%%
\fdx{H1_norm_uh()@{\code{H1\_norm\_uh()}}}
\idx{evaluation tools!H1_norm_uh()@{\code{H1\_norm\_uh()}}}
%%
returns an approximation to the $H^1$ semi norm $(\int_\Omega |\nabla
u_h|^2)^{1/2}$ of a finite element function; the coefficient vector of
the vector is stored in \code{uh}; the domain is given by
\code{uh->fe\_space->mesh}; the element integrals are approximated by
the numerical quadrature \code{quad}, if \code{quad} is not \nil;
otherwise a quadrature which is exact of degree
\code{2*uh->fe\_space->bas\_fcts->degree-2} is used.
%%
\kitem{L2\_norm\_uh(quad, uh)}
%%
\fdx{L2_norm_uh()@{\code{L2\_norm\_uh()}}}
\idx{evaluation tools!L2_norm_uh()@{\code{L2\_norm\_uh()}}}
%%
returns an approximation to the $L^2$ norm $(\int_\Omega
|u_h|^2)^{1/2}$ of a finite element function; the coefficient vector
of the vector is stored in \code{uh}; the domain is given by
\code{uh->fe\_space->mesh}; the element integrals are approximated by
the numerical quadrature \code{quad}, if \code{quad} is not \nil;
otherwise a quadrature which is exact of degree
\code{2*uh->fe\_space->bas\_fcts->degree} is used.
%%
\kitem{H1\_norm\_uh\_[d|dow](quad, uh\_d)}
%%
\fdx{H1_norm_uh_d()@{\code{H1\_norm\_uh\_d()}}}
\idx{evaluation tools!H1_norm_uh_d()@{\code{H1\_norm\_uh\_d()}}}
\fdx{H1_norm_uh_dow()@{\code{H1\_norm\_uh\_dow()}}}
\idx{evaluation tools!H1_norm_uh_dow()@{\code{H1\_norm\_uh\_dow()}}}
%%
returns an approximation to the $H^1$ semi norm of a vector valued
finite element function; the coefficient vector of the vector is
stored in \code{uh\_d}; the domain is given by
\code{uh\_d->fe\_space->mesh}; the element integrals are approximated
by the numerical quadrature \code{quad}, if \code{quad} is not \nil;
otherwise a quadrature which is exact of degree
\code{2*uh\_d->fe\_space->bas\_fcts->degree-2} is used.
%%
\kitem{L2\_norm\_uh\_[d|dow](quad, uh\_d)}
%%
\fdx{L2_norm_uh_d()@{\code{L2\_norm\_uh\_d()}}}
\idx{evaluation tools!L2_norm_uh_d()@{\code{L2\_norm\_uh\_d()}}}
\fdx{L2_norm_uh_dow()@{\code{L2\_norm\_uh\_dow()}}}
\idx{evaluation tools!L2_norm_uh_dow()@{\code{L2\_norm\_uh\_dow()}}}
%%
returns an approximation to the $L^2$ norm of a vector valued finite
element function; the coefficient vector of the vector is stored in
\code{uh\_d}; the domain is given by \code{uh\_d->fe\_space->mesh};
the element integrals are approximated by the numerical quadrature
\code{quad}, if \code{quad} is not \nil; otherwise a quadrature which
is exact of degree \code{2*uh\_d->fe\_space->bas\_fcts->degree} is
used.
\end{descr}
\section{Interface for application provided functions}
\label{S:user_fcts} %% oh, what a user ...
Often the library function in the \ALBERTA package require certain
application provided functions, e.g. for assembling the ``right hand
side'', for computations of the ``true'' error, for inhomogeneous
boundary conditions or for interpolation of (non-discrete) functions
onto finite element spaces. This section defines some basis calling
conventions concerning these application provided functions.
Most of these function must conform to one of the following proto-types:
%%
\ddx{FCT_AT_X@{\code{FCT\_AT\_X}}}
\idx{application function types!FCT_AT_X@{\code{FCT\_AT\_X}}}
\ddx{GRD_FCT_AT_X@{\code{GRD\_FCT\_AT\_X}}}
\idx{application function types!GRD\_FCT_AT_X@{\code{GRD\_FCT\_AT\_X}}}
\ddx{D2_FCT_AT_X@{\code{D2\_FCT\_AT\_X}}}
\idx{application function types!D2\_FCT_AT_X@{\code{D2\_FCT\_AT\_X}}}
\ddx{FCT_D_AT_X@{\code{FCT\_D\_AT\_X}}}
\idx{application function types!FCT_D_AT_X@{\code{FCT\_D\_AT\_X}}}
\ddx{GRD_FCT_D_AT_X@{\code{GRD\_FCT\_D\_AT\_X}}}
\idx{application function types!GRD\_FCT_D_AT_X@{\code{GRD\_FCT\_D\_AT\_X}}}
\ddx{D2_FCT_D_AT_X@{\code{D2\_FCT\_D\_AT\_X}}}
\idx{application function types!D2\_FCT_D_AT_X@{\code{D2\_FCT\_D\_AT\_X}}}
\ddx{LOC_FCT_AT_QP@{\code{LOC\_FCT\_AT\_QP}}}
\idx{application function types!LOC_FCT_AT_QP@{\code{LOC\_FCT\_AT\_QP}}}
\ddx{GRD_LOC_FCT_AT_QP@{\code{GRD\_LOC\_FCT\_AT\_QP}}}
\idx{application function types!GRD_LOC_FCT_AT_QP@{\code{GRD\_LOC\_FCT\_AT\_QP}}}
\ddx{LOC_FCT_D_AT_QP@{\code{LOC\_FCT\_D\_AT\_QP}}}
\idx{application function types!LOC_FCT_D_AT_QP@{\code{LOC\_FCT\_D\_AT\_QP}}}
\ddx{GRD_LOC_FCT_D_AT_QP@{\code{GRD\_LOC\_FCT\_D\_AT\_QP}}}
\idx{application function types!GRD_LOC_FCT_D_AT_QP@{\code{GRD\_LOC\_FCT\_D\_AT\_QP}}}
%%
\bv\begin{lstlisting}
typedef REAL (*FCT_AT_X)(const REAL_D x);
typedef const REAL *(*GRD_FCT_AT_X)(const REAL_D x, REAL_D result);
typedef const REAL_D *(*D2_FCT_AT_X)(const REAL_D x, REAL_DD result);
typedef const REAL *(*FCT_D_AT_X)(const REAL_D x, REAL_D result);
typedef const REAL_D *(*GRD_FCT_D_AT_X)(const REAL_D x, REAL_DD result);
typedef const REAL_DD *(*D2_FCT_D_AT_X)(const REAL_D x, REAL_DDD result);
typedef REAL (*LOC_FCT_AT_QP)(const EL_INFO *el_info,
const QUAD *quad, int iq,
void *ud);
typedef const REAL *(*LOC_FCT_D_AT_QP)(REAL_D result,
const EL_INFO *el_info,
const QUAD *quad, int iq,
void *ud);
typedef const REAL *(*GRD_LOC_FCT_AT_QP)(REAL_D res,
const EL_INFO *el_info,
const REAL_BD Lambda,
const QUAD *quad, int iq,
void *ud);
typedef const REAL_D *(*GRD_LOC_FCT_D_AT_QP)(REAL_DD res,
const EL_INFO *el_info,
const REAL_BD Lambda,
const QUAD *quad, int iq,
void *ud);
\end{lstlisting}\ev
\begin{datatype}{FCT\_AT\_X}
\label{S:FCT_AT_X_fptr}
\ddx{FCT_AT_X@{\code{FCT\_AT\_X}}}
\idx{application function types!FCT_AT_X@{\code{FCT\_AT\_X}}}
\item[Prototype]~\hfill
\begin{lstlisting}
typedef REAL (*FCT_AT_X)(const REAL_D x);
\end{lstlisting}
\item[Synopsis]~\hfill
\begin{lstlisting}
FCT_AT_X fptr;
result = fptr(x);
\end{lstlisting}
\item[Description]~\hfill
Evaluate at the point \code{x} and return a
scalar value. This is the simplest function-type.
%%
\item[Parameters]~\hfill
\begin{descr}
\kitem{x} The point of evaluation.
\end{descr}
\item[Return Value]~\hfill
The function value.
\end{datatype}
\begin{datatype}{GRD\_FCT\_AT\_X}
\label{S:GRD_FCT_AT_X_fptr}
\ddx{GRD_FCT_AT_X@{\code{GRD\_FCT\_AT\_X}}}
\idx{application function types!GRD\_FCT_AT_X@{\code{GRD\_FCT\_AT\_X}}}
\item[Prototype]~\hfill
\begin{lstlisting}
const REAL *GRD_FCT_AT_X(const REAL_D x, REAL\_D result);
\end{lstlisting}
\item[Synopsis]~\hfill
\begin{lstlisting}
GRD_FCT_AT_X fptr;
result = fptr(x, result);
result = fptr(x, NULL);
\end{lstlisting}
\item[Description]~\hfill
Evaluate the first derivative at the point \code{x}.
\item[Parameters]~\hfill
\begin{descr}
\kitem{x} The point of evaluation, in Cartesian coordinates.
\kitem{result} Storage for the result, or \nil.
\end{descr}
\item[Return Value] The address of \code{result}, if \code{result !=
\nil}, otherwise a pointer to a statically allocated storage
area, see \exampleref{E:grd_user_fct} below.
%%
\end{datatype}
\begin{example}
\label{E:grd_user_fct}
\bv\begin{lstlisting}[name=GRD_FCT_AT_X_ABI,label=C:GRD_FCT_AT_X_ABI]
const REAL *grd_g_implementation(const REAL_D x, REAL_D result) {
static REAL_D storage; /* mind the "static" key-word!!! */
if (result == NULL) {
result = storage;
}
... /* mighty complicated computations for "result" */
return result;
}
\end{lstlisting}\ev
\end{example}
\hrulefill
\begin{descr}
\kitem{const REAL\_D *D2\_FCT\_AT\_X(const REAL\_D x, REAL\_DD result)}
Evaluate the second derivative at the point \code{x}.
\begin{description}
\item[Parameters]~\hfill
\begin{descr}
\kitem{x} The point of evaluation, in Cartesian coordinates.
\kitem{result} Storage for the result, or \nil.
\end{descr}
\item[Return Value] The address of \code{result}, if \code{result !=
\nil}, otherwise a pointer to a statically allocated storage
area, see \exampleref{E:D2_user_fct} below.
\end{description}
\begin{example}
\label{E:D2_user_fct}
\bv\begin{lstlisting}[name=D2_FCT_AT_X_ABI,label=C:D2_FCT_AT_X_ABI]
const REAL_D *D2_g_implementation(const REAL_D x, REAL_DD result) {
static REAL_DD storage; /* mind the "static" key-word!!! */
if (result == NULL) {
result = storage;
}
... /* mighty complicated computations for "result" */
return (const REAL_D *)result;
}
\end{lstlisting}\ev
\end{example}
%%
\hrulefill
\kitem{const REAL *FCT\_D\_AT\_X(const REAL\_D x, REAL\_D result)}
\kitem{const REAL\_D *GRD\_FCT\_D\_AT\_X(const REAL\_D x, REAL\_DD result)}
\kitem{const REAL\_DD *D2\_FCT\_D\_AT\_X(const REAL\_D x, REAL\_DDD result)}
%%
~\hfill
Evaluate a vector valued function at the point \code{x}. There is, of
course, no difference between the \code{GRD\_FCT\_AT\_X} and the
\code{FCT\_D\_AT\_X} function pointers.
\begin{description}
\item[Parameters]~\hfill
\begin{descr}
\kitem{x} The point of evaluation, in Cartesian coordinates.
\kitem{result} Storage for the result, or \nil.
\end{descr}
\item[Return Value] The address of \code{result}, if \code{result !=
\nil}, otherwise a pointer to a statically allocated storage
area, see \exampleref{E:user_fct_d} below.
\end{description}
\begin{example}
\label{E:user_fct_d}
\bv\begin{lstlisting}[name=FCT_D_AT_X_ABI,label=C:FCT_D_AT_X_ABI]
const REAL *g_implementation(const REAL_D x, REAL_D result) {
static REAL_D storage; /* mind the "static" key-word!!! */
if (result == NULL) {
result = storage;
}
... /* mighty complicated computations for "result" */
return result;
}
\end{lstlisting}\ev
\end{example}
\pagebreak[2]
\kitem{REAL LOC\_FCT\_AT\_QP(}
\kitem{ const EL\_INFO *el\_info, const QUAD *quad, int iq, void *ud)}
~\hfill
%%
Evaluate the function at \code{quad->lambda[iq]}. This looks
slightly more complicated than the simple \code{FCT\_AT\_X} types,
but passing the \code{EL\_INFO} descriptor along with quadrature
rule opens the door to implement even complicated functions in an
efficient and simpler way than is possible with the simple
\code{FCT\_AT\_X} types. See also \exampleref{E:loc_fct_at_qp}.
\begin{description}
\item[Parameters]~\hfill
\begin{descr}
\kitem{el\_info} The current \code{EL\_INFO} descriptor.
\kitem{quad} The quadrature rule storing the evaluation points.
\kitem{iq} The number of the evaluation point.
\kitem{ud} Application data pointer.
\end{descr}
\item[Return Value] The function value.
\end{description}
\hrulefill
\kitem{const REAL *GRD\_LOC\_FCT\_AT\_QP(}
\kitem{ REAL\_D res, const EL\_INFO *el\_info, const QUAD *quad, int iq, void *ud)}
\kitem{const REAL *LOC\_FCT\_D\_AT\_QP(}
\kitem{ REAL\_D res, const EL\_INFO *el\_info, const QUAD *quad, int iq, void *ud)}
\kitem{const REAL\_D *GRD\_LOC\_FCT\_D\_AT\_QP(}
\kitem{ REAL\_DD res, const EL\_INFO *el\_info, const QUAD *quad, int iq, void *ud)}
%%
More or less self-explanatory, the convention for the \code{res}
argument are the same as for the \code{FCT\_AT\_X} types: a \nil
pointer must be accepted, and then a pointer to a statically
allocated storage area has to be returned, otherwise the result has
to be stored in \code{res}, and the return value must be \code{res},
too.
\end{descr}
\section{Calculation of errors of finite element approximations}
\label{S:error_cal}
For test purposes it is convenient to calculate the ``exact error''
between a finite element approximation and the exact solution.
\ALBERTA supplies functions to calculate the error in several norms.
For test purposes, the integral error routines may be used as ``error
estimators'' in an adaptive method. The local element error $\int_S
|\nabla (u-u_h)|^2$ or $\int_S |u-u_h|^2$ can be used as an error
indicator and can be stored on the element leaf data, for example.
\ALBERTA provides also functions for the computation of the mean value
of a given function, respectively the mean value difference of a given
non-discrete function and a discrete function.
Not all variants of the functions listed below will be explained in
detail further below. For the calling conventions for the application
supplied function pointer we refer the reader to \secref{S:user_fcts}
on page \pageref{S:user_fcts}.
%%
\fdx{max_err_at_qp()@{\code{max\_err\_at\_qp()}}}
\idx{evaluation tools!max_err_at_qp()@{\code{max\_err\_at\_qp()}}}
\fdx{max_err_at_qp_loc()@{\code{max\_err\_at\_qp\_loc()}}}
\idx{evaluation tools!max_err_at_qp_loc()@{\code{max\_err\_at\_qp\_loc()}}}
\fdx{max_err_dow_at_qp()@{\code{max\_err\_dow\_at\_qp()}}}
\idx{evaluation tools!max_err_dow_at_qp()@{\code{max\_err\_dow\_at\_qp()}}}
\fdx{max_err_dow_at_qp_loc()@{\code{max\_err\_dow\_at\_qp\_loc()}}}
\idx{evaluation tools!max_err_dow_at_qp_loc()@{\code{max\_err\_dow\_at\_qp\_loc()}}}
%%
\fdx{max_err_at_vert()@{\code{max\_err\_at\_vert()}}}
\idx{evaluation tools!max_err_at_vert()@{\code{max\_err\_at\_vert()}}}
\fdx{max_err_at_vert_loc()@{\code{max\_err\_at\_vert\_loc()}}}
\idx{evaluation tools!max_err_at_vert_loc()@{\code{max\_err\_at\_vert\_loc()}}}
\fdx{max_err_dow_at_vert()@{\code{max\_err\_dow\_at\_vert()}}}
\idx{evaluation tools!max_err_dow_at_vert()@{\code{max\_err\_dow\_at\_vert()}}}
\fdx{max_err_dow_at_vert_loc()@{\code{max\_err\_dow\_at\_vert\_loc()}}}
\idx{evaluation tools!max_err_dow_at_vert_loc()@{\code{max\_err\_dow\_at\_vert\_loc()}}}
%%
\fdx{L2_err()@{\code{L2\_err()}}}
\idx{evaluation tools!L2_err()@{\code{L2\_err()}}}
\fdx{L2_err_loc()@{\code{L2\_err\_loc()}}}
\idx{evaluation tools!L2_err_loc()@{\code{L2\_err\_loc()}}}
\fdx{L2_err_weighted()@{\code{L2\_err\_weighted()}}}
\idx{evaluation tools!L2_err_weighted()@{\code{L2\_err\_weighted()}}}
\fdx{L2_err_dow()@{\code{L2\_err\_dow()}}}
\idx{evaluation tools!L2_err_dow()@{\code{L2\_err\_dow()}}}
\fdx{L2_err_loc_dow()@{\code{L2\_err\_loc\_dow()}}}
\idx{evaluation tools!L2_err_loc_dow()@{\code{L2\_err\_loc\_dow()}}}
\fdx{L2_err_dow_weighted()@{\code{L2\_err\_dow\_weighted()}}}
\idx{evaluation tools!L2_err_dow_weighted()@{\code{L2\_err\_dow\_weighted()}}}
%%
\fdx{H1_err()@{\code{H1\_err()}}}
\idx{evaluation tools!H1_err()@{\code{H1\_err()}}}
\fdx{H1_err_loc()@{\code{H1\_err\_loc()}}}
\idx{evaluation tools!H1_err_loc()@{\code{H1\_err\_loc()}}}
\fdx{H1_err_weighted()@{\code{H1\_err\_weighted()}}}
\idx{evaluation tools!H1_err_weighted()@{\code{H1\_err\_weighted()}}}
\fdx{H1_err_dow()@{\code{H1\_err\_dow()}}}
\idx{evaluation tools!H1_err_dow()@{\code{H1\_err\_dow()}}}
\fdx{H1_err_loc_dow()@{\code{H1\_err\_loc\_dow()}}}
\idx{evaluation tools!H1_err_loc_dow()@{\code{H1\_err\_loc\_dow()}}}
\fdx{H1_err_dow_weighted()@{\code{H1\_err\_dow\_weighted()}}}
\idx{evaluation tools!H1_err_dow_weighted()@{\code{H1\_err\_dow\_weighted()}}}
%%
\fdx{mean_value()@{\code{mean\_value()}}}
\idx{evaluation tools!mean_value()@{\code{mean\_value()}}}
\fdx{mean_value_dow()@{\code{mean\_value\_dow()}}}
\idx{evaluation tools!mean_value_dow()@{\code{mean\_value\_dow()}}}
\fdx{mean_value_loc()@{\code{mean\_value\_loc()}}}
\idx{evaluation tools!mean_value_loc()@{\code{mean\_value\_loc()}}}
\fdx{mean_value_loc_dow()@{\code{mean\_value\_loc\_dow()}}}
\idx{evaluation tools!mean_value_loc_dow()@{\code{mean\_value\_loc\_dow()}}}
\bv\begin{lstlisting}
REAL max_err_at_qp(FCT_AT_X u, const DOF_REAL_VEC *uh, const QUAD *quad);
REAL max_err_at_qp_loc(LOC_FCT_AT_QP u_loc, void *ud, FLAGS fill_flag,
const DOF_REAL_VEC *uh,
const QUAD *quad);
REAL max_err_dow_at_qp(FCT_D_AT_X u,
const DOF_REAL_VEC_D *uh,
const QUAD *quad);
REAL max_err_dow_at_qp_loc(LOC_FCT_D_AT_QP u_loc,
void *ud, FLAGS fill_flag,
const DOF_REAL_VEC_D *uh,
const QUAD *quad);
REAL max_err_at_vert(FCT_AT_X u, const DOF_REAL_VEC *uh);
REAL max_err_at_vert_loc(LOC_FCT_AT_QP u_at_qp,
void *ud, FLAGS fill_flag,
const DOF_REAL_VEC *uh);
REAL max_err_dow_at_vert(FCT_D_AT_X u, const DOF_REAL_VEC_D *uh);
REAL max_err_dow_at_vert_loc(LOC_FCT_D_AT_QP u_at_qp,
void *ud, FLAGS fill_flag,
const DOF_REAL_VEC_D *uh);
REAL L2_err(FCT_AT_X u, const DOF_REAL_VEC *uh,
const QUAD *quad,
bool rel_err, bool mean_value_adjust,
REAL *(*rw_err_el)(EL *el), REAL *max_l2_err2);
REAL L2_err_loc(LOC_FCT_AT_QP u_loc, void *ud, FLAGS fill_flag,
const DOF_REAL_VEC *uh,
const QUAD *quad,
bool rel_err, bool mean_value_adjust,
REAL *(*rw_err_el)(EL *el), REAL *max_l2_err2);
REAL L2_err_weighted(FCT_AT_X weight, FCT_AT_X u, const DOF_REAL_VEC *uh,
const QUAD *quad,
bool rel_err, bool mean_value_adjust,
REAL *(*rw_err_el)(EL *el), REAL *max_l2_err2);
REAL L2_err_dow(FCT_D_AT_X u,
const DOF_REAL_VEC_D *uh,
const QUAD *quad,
bool rel_err, bool mean_value_adjust,
REAL *(*rw_err_el)(EL *el), REAL *max_l2_err2);
REAL L2_err_loc_dow(LOC_FCT_D_AT_QP u_loc,
void *ud, FLAGS fill_flag,
const DOF_REAL_VEC_D *uh,
const QUAD *quad,
bool rel_err, bool mean_value_adjust,
REAL *(*rw_err_el)(EL *el), REAL *max_l2_err2);
REAL L2_err_dow_weighted(FCT_AT_X weight, FCT_D_AT_X u,
const DOF_REAL_VEC_D *uh,
const QUAD *quad,
bool rel_err, bool mean_value_adjust,
REAL *(*rw_err_el)(EL *el), REAL *max_l2_err2);
REAL H1_err(GRD_FCT_AT_X grd_u, const DOF_REAL_VEC *uh,
const QUAD *quad, bool rel_err, REAL *(*rw_err_el)(EL *),
REAL *max_el_err2);
REAL H1_err_loc(GRD_LOC_FCT_AT_QP grd_u_loc,
void *ud, FLAGS fill_flag,
const DOF_REAL_VEC *uh,
const QUAD *quad, bool rel_err, REAL *(*rw_err_el)(EL *),
REAL *max_el_err2);
REAL H1_err_weighted(FCT_AT_X weight, GRD_FCT_AT_X grd_u,
const DOF_REAL_VEC *uh, const QUAD *quad,
bool rel_err, REAL *(*rw_err_el)(EL *),
REAL *max_el_err2);
REAL H1_err_dow(GRD_FCT_D_AT_X grd_u, const DOF_REAL_VEC_D *uh,
const QUAD *quad,
bool rel_err, REAL *(*rw_err_el)(EL *), REAL *max_el_err2);
REAL H1_err_loc_dow(GRD_LOC_FCT_D_AT_QP grd_u_loc, void *ud, FLAGS fill_flag,
const DOF_REAL_VEC_D *uh, const QUAD *quad,
bool rel_err,
REAL *(*rw_err_el)(EL *), REAL *max_el_err2);
REAL H1_err_dow_weighted(FCT_AT_X weight, GRD_FCT_D_AT_X grd_u,
const DOF_REAL_VEC_D *uh,
const QUAD *quad,
bool rel_err, REAL *(*rw_err_el)(EL *),
REAL *max_el_err2);
REAL mean_value(MESH *mesh, REAL (*f)(const REAL_D), const DOF_REAL_VEC *fh,
const QUAD *quad);
REAL mean_value_loc(MESH *mesh, LOC_FCT_AT_QP f_at_qp,
void *ud, FLAGS fill_flags,
const DOF_REAL_VEC *fh, const QUAD *quad);
const REAL *mean_value_dow(MESH *mesh, FCT_D_AT_X f, const DOF_REAL_VEC_D *fh,
const QUAD *quad, REAL_D mean);
const REAL *mean_value_loc_dow(REAL_D mean, MESH *mesh,
LOC_FCT_D_AT_QP f_at_qp,
void *ud, FLAGS fill_flag,
const DOF_REAL_VEC_D *fh,
const QUAD *quad);
\end{lstlisting}\ev
\paragraph{Descriptions}
\begin{descr}
\kitem{max\_err\_at\_qp(u, uh, quad)}
%%
the function returns the maximal error, $\max |u-u_h|$, between the
true solution and the approximation at all quadrature nodes on all
elements of a mesh; \code{u} is a pointer to a function for the
evaluation of the true solution, \code{uh} stores the coefficients of
the approximation, \code{uh->fe\_space->mesh} is the underlying mesh,
and \code{quad} is the quadrature which gives the quadrature nodes; if
\code{quad} is \nil, a quadrature which is exact of degree
\code{2*uh->fe\_space->bas\_fcts->degree-2} is used.
%%
\kitem{H1\_err(grd\_u, uh, quad, rel\_err, rw\_el\_err, max)}
%%
the function returns an approximation to the absolute error
$(\int_\Omega |\nabla (u-u_h)|^2)^{1/2}$ (\code{rel\_err == 0}) or
relative error $(\int_\Omega|\nabla(u-u_h)|^2/\int_\Omega|\nabla
u|^2)^{1/2}$ (\code{rel\_err == 1}) between the true solution and the
approximation in the $H^1$ semi norm;
\code{grd\_u} is a pointer to a function for the evaluation of the
gradient of the true solution returning a \DOW vector storing this
gradient, \code{uh} stores the coefficients of the approximation,
\code{uh->fe\_space->mesh} is the underlying mesh, and \code{quad} is
the quadrature for the approximation of the element integrals; if
\code{quad} is \nil, a quadrature which is exact of degree
\code{2*uh->fe\_space->bas\_fcts->degree-2} is used;
if \code{rw\_el\_err} is not \nil, the return value of
\code{(*rw\_el\_err)(el)} provides for each mesh element \code{el} an
address where the local error is stored; if \code{max} is not \nil,
\code{*max} is the maximal local error on an element on output.
%%
\kitem{L2\_err(u, uh, quad, rel\_err, rw\_el\_err, max)}
%%
the function returns an approximation to the absolute error
$(\int_\Omega |u-u_h|^2)^{1/2}$ (\code{rel\_err == 0}) or the relative
error $(\int_\Omega|u-u_h|^2/\int_\Omega|u|^2)^{1/2}$ (\code{rel\_err
== 1}) between the true solution and the approximation in the $L^2$
norm,
\code{u} is a pointer to a function for the evaluation of the true
solution, \code{uh} stores the coefficients of the approximation,
\code{uh->fe\_space->mesh} is the underlying mesh, and \code{quad} is
the quadrature for the approximation of the element integrals; if
\code{quad} is \nil, a quadrature which is exact of degree
\code{2*uh->fe\_space->bas\_fcts->degree-2} is used;
if \code{rw\_el\_err} is not \nil, the return value of
\code{(*rw\_el\_err)(el)} provides for each mesh element \code{el} an
address where the local error is stored; if \code{max} is not \nil,
\code{*max} is the maximal local error on an element on output.
%%
\kitem{max\_err\_at\_qp\_[d|dow](u\_d, uh\_d, quad)}
%%
the function returns the maximal error between the true solution and
the approximation at all quadrature nodes on all elements of a mesh;
\code{u\_d} is a pointer to a function for the evaluation of the true
solution returning a \DOW vector storing the value of the function,
\code{uh\_d} stores the coefficients of the approximation,
\code{uh\_d->fe\_space->mesh} is the underlying mesh, and \code{quad}
is the quadrature which gives the quadrature nodes; if \code{quad} is
\nil, a quadrature which is exact of degree
\code{2*uh\_d->fe\_space->bas\_fcts->degree-2} is used.
%%
\kitem{H1\_err2\_[d|dow](grd\_u\_d, uh\_d, quad, rel\_err, rw\_el\_err, max)}
%%
the function returns an approximation to the absolute error
(\code{rel\_err == 0}) or relative error (\code{rel\_err == 1})
between the true solution and the approximation in the $H^1$ semi
norm;
\code{grd\_u\_d} is a pointer to a function for the evaluation of the
Jacobian of the true solution returning a $\DOW\times\DOW$ matrix
storing this Jacobian, \code{uh\_d} stores the coefficients of the
approximation, \code{uh\_d->fe\_space->mesh} is the underlying mesh,
and \code{quad} is the quadrature for the approximation of the element
integrals; if \code{quad} is \nil, a quadrature which is exact of
degree \code{2*uh\_d->fe\_space->bas\_fcts->degree-2} is used;
if \code{rw\_el\_err} is not \nil, the return value of
\code{(*rw\_el\_err)(el)} provides for each mesh element \code{el} an
address where the local error is stored; if \code{max} is not \nil,
\code{*max} is the maximal local error on an element on output.
\kitem{L2\_err2\_[d|dow](u\_d, uh\_d, quad, rel\_err, rw\_el\_err, max)}
%%
the function returns an approximation to the absolute error
(\code{rel\_err == 0}) or relative error (\code{rel\_err == 1})
between the true solution and the approximation in the $L^2$ norm;
\code{u\_d} is a pointer to a function for the evaluation of the true
solution returning a \DOW vector storing the value of the function,
\code{uh\_d} stores the coefficients of the approximation,
\code{uh\_d->fe\_space->mesh} is the underlying mesh, and \code{quad}
is the quadrature for the approximation of the element integrals; if
\code{quad} is \nil, a quadrature which is exact of degree
\code{2*uh\_d->fe\_space->bas\_fcts->degree-2} is used;
if \code{rw\_el\_err} is not \nil, the return value of
\code{(*rw\_el\_err)(el)} provides for each mesh element \code{el} an
address where the local error is stored; if \code{max} is not \nil,
\code{*max} is the maximal local error on an element on output.
%%
\kitem{mean\_value(mesh, f, fh, quad)}
%%
\fdx{mean_value()@{\code{mean\_value()}}}
\idx{evaluation tools!mean_value()@{\code{mean\_value()}}}
%%
\kitem{mean\_value\_[d|dow](mesh, f, fh, quad, mean)}
%%
\fdx{mean_value_dow()@{\code{mean\_value\_dow()}}}
\idx{evaluation tools!mean_value_dow()@{\code{mean\_value\_dow()}}}
%%
\kitem{mean\_value\_loc(mesh, f\_at\_qp, ud, fill\_flags, fh, quad)}
%%
\fdx{mean_value_loc()@{\code{mean\_value\_loc()}}}
\idx{evaluation tools!mean_value_loc()@{\code{mean\_value\_loc()}}}
%%
\kitem{mean\_value\_loc\_[d|dow](mean, mesh, f\_at\_qp, ud, fill\_flags, fh, quad)}
%%
\fdx{mean_value_loc_dow()@{\code{mean\_value\_loc\_dow()}}}
\idx{evaluation tools!mean_value_loc_dow()@{\code{mean\_value\_loc\_dow()}}}
%%
compute the mean value of either a finite element function or a
non-discrete function. If both are given return the difference of
their mean values \code{(f-fh)}.
\end{descr}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "alberta-man"
%%% End:
|