1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2011 by The University of Queensland //
// Earth Systems Science Computational Centre (ESSCC) //
// http://www.uq.edu.au/esscc //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.opensource.org/licenses/osl-3.0.php //
// //
/////////////////////////////////////////////////////////////
#include <mpi.h>
#include <boost/version.hpp>
#include <boost/python.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/mpl/vector.hpp>
#include "Python/esys/lsm/ParticlePy.h"
#include "Python/esys/lsm/RotParticlePy.h"
#include "Python/esys/lsm/RotParticleViPy.h"
#include "Python/esys/lsm/RotThermalParticlePy.h"
#include "Python/esys/lsm/LsmMpiPy.h"
#include "Parallel/LatticeMaster.h"
#include "Foundation/StringUtil.h"
#include "Python/BoostPythonUtil/ListConverter.h"
#include "Python/BoostPythonUtil/PythonIterIterator.h"
#include "Python/esys/lsm/util/Vec3Py.h"
#include "Python/esys/lsm/util/BoundingBoxPy.h"
#include "Python/esys/lsm/RunnablePy.h"
#include "Python/esys/lsm/geometry/SimpleSpherePy.h"
#include "Python/esys/lsm/geometry/TaggedIdConnectionPy.h"
#include "Python/esys/lsm/CheckPointParamsPy.h"
#include "Python/esys/lsm/InteractionParamsPy.h"
#include "Python/esys/lsm/MeshBuildParamsPy.h"
#include "Python/esys/lsm/BondedTriMeshPrmsPy.h"
#include "Python/esys/lsm/ElasticMesh2DPrmsPy.h"
#include "Python/esys/lsm/ElasticTriMeshPrmsPy.h"
#include "Python/esys/lsm/BondedMesh2DPrmsPy.h"
#include "Python/esys/lsm/WallPrmsPy.h"
#include "Python/esys/lsm/ParticleFieldSaverPrmsPy.h"
#include "Python/esys/lsm/InteractionFieldSaverPrmsPy.h"
#include "Python/esys/lsm/WallFieldSaverPrmsPy.h"
#include "Python/esys/lsm/LmParticleAdder.h"
#include "Python/esys/lsm/TriggerPrmsPy.h"
#include "Foundation/console.h"
using namespace boost;
using namespace esys::lsm;
#include <vector>
#include <fstream>
#include <stdexcept>
#include <string>
namespace esys
{
namespace lsm
{
class LsmMpiPy::Impl
{
public:
Impl() : m_latticeMaster(), m_nameTypeMap()
{
}
CLatticeMaster m_latticeMaster;
LsmMpiPy::InteractionNameTypeMap m_nameTypeMap;
};
void throwValueError(const std::string &msg)
{
PyErr_SetString(PyExc_ValueError, msg.c_str());
boost::python::throw_error_already_set();
}
std::string joinIntVector(
const std::vector<int> &v,
const std::string &delim
)
{
return
StringUtil::join<
std::vector<int>,
StringUtil::StdOStreamOp<std::vector<int>::const_iterator>
>(v, delim);
}
void checkParticleTypePy(const std::string &particleType)
{
if (
(particleType != "NRotSphere")
&&
(particleType != "RotSphere")
&&
(particleType != "RotSphereVi")
&&
(particleType != "RotThermalSphere")
)
{
throwValueError(
std::string()
+
"Invalid particle type, needs to be one of"
+
" 'NRotSphere', 'RotSphere', 'RotSphereVi' or 'RotThermalSphere'"
+
", got particleType='"
+
particleType + "'"
);
}
}
void checkMpiDimensions(
int numProcesses,
const std::vector<int> &mpiDimVector
)
{
if (numProcesses > 0)
{
if (mpiDimVector.size() == 3)
{
int prod = 1;
for (unsigned int i = 0; i < mpiDimVector.size(); i++)
{
const int dim = mpiDimVector[i];
if (dim > 0)
{
prod *= dim;
}
else if (dim < 0)
{
throwValueError(
std::string()
+
"MPI dimension list contains negative element, values"
+
" must"
+
" be >= 0, got MPI dimension list=" + joinIntVector(mpiDimVector, ",")
);
}
}
if ((numProcesses % prod) != 0)
{
throwValueError(
std::string()
+
"Inconsistency beween numProcesses and MPI dimension list,"
+
" numProcesses must be a multiple of the product of"
+
" non-zero"
+
" MPI dimension list elements, got (numProcesses % product)=("
+
StringUtil::toString(numProcesses) + " % " + StringUtil::toString(prod)
+
") = " + StringUtil::toString(numProcesses % prod)
);
}
}
else
{
throwValueError(
"mpiDimList must have 3 elements, got mpiDimList="
+
joinIntVector(mpiDimVector, ",")
);
}
}
else
{
throwValueError(
std::string()
+
"Number of processes must be greater than 0, got numProcesses="
+
StringUtil::toString(numProcesses)
);
}
}
void checkMpiDimensionsPy(
int numWorkerProcesses,
const boost::python::list &mpiDimList
)
{
checkMpiDimensions(numWorkerProcesses, bpu::listToVector<int>(mpiDimList));
}
LsmMpiPy::LsmMpiPy(
int numWorkerProcesses,
const python::list &mpiDimList,
const std::string &spawnCmd,
const boost::python::list &spawnArgList
)
: m_implPtr(new Impl)
{
setWorkerSpawnCmd(spawnCmd, spawnArgList);
getLatticeMaster().spawnSlaves(numWorkerProcesses);
getLatticeMaster().setProcessDims(
bpu::listToVector<unsigned int>(mpiDimList)
);
}
LsmMpiPy::~LsmMpiPy()
{
}
LsmMpiPy::InteractionNameTypeMap &LsmMpiPy::getNameTypeMap()
{
return m_implPtr->m_nameTypeMap;
}
const LsmMpiPy::InteractionNameTypeMap &LsmMpiPy::getNameTypeMap() const
{
return m_implPtr->m_nameTypeMap;
}
int LsmMpiPy::getNumWorkerProcesses() const
{
return getLatticeMaster().getNumWorkerProcesses();
}
void LsmMpiPy::initVerletModel(
const std::string &particleType,
double gridSpacing,
double verletDist
)
{
checkParticleTypePy(particleType);
std::string lmParticleType;
if (particleType == "RotSphere")
{
lmParticleType = "Rot";
}
else if (particleType == "RotSphereVi")
{
lmParticleType = "RotVi";
}
else if (particleType == "RotThermalSphere")
{
lmParticleType = "RotTherm";
}
else
{
lmParticleType = "Basic";
}
getLatticeMaster().makeLattice(
lmParticleType.c_str(),
gridSpacing,
verletDist
);
}
void LsmMpiPy::setWorkerSpawnCmd(
const std::string &exe,
const boost::python::list &argList
)
{
// getLatticeMaster().setWorkerSpawnCmd(
// exe,
// bpu::listToVector<std::string>(argList)
// );
}
std::string LsmMpiPy::getWorkerSpawnCmd()
{
//return getLatticeMaster().getWorkerSpawnCmd().getCmdLine();
}
double LsmMpiPy::getTimeStepSize() const
{
return getLatticeMaster().getTimeStepSize();
}
void LsmMpiPy::setTimeStepSize(double dt)
{
getLatticeMaster().setTimeStepSize(dt);
}
std::string LsmMpiPy::getLsmVersion() const
{
return getLatticeMaster().getLsmVersion();
}
void LsmMpiPy::setTimingFileName(const std::string &fileName)
{
getLatticeMaster().setTimingFileName(fileName);
}
void LsmMpiPy::setSlaveTimingFileName(const std::string &fileName)
{
getLatticeMaster().saveTimingDataToFile(fileName);
}
void LsmMpiPy::createConnections(boost::python::object &iteratable)
{
bpu::PythonIterIterator<TaggedIdConnectionPy &> it(iteratable);
getLatticeMaster().addConnections(it);
}
void LsmMpiPy::createParticles(boost::python::object &iteratable)
{
if (getParticleType() == "NRotSphere")
{
LmParticleAdder<
boost::mpl::vector<RotParticlePy,ParticlePy,SimpleSpherePy>,
CParticle
> adder;
adder.addParticles(iteratable, getLatticeMaster());
}
else if (getParticleType() == "RotSphere")
{
LmParticleAdder<
boost::mpl::vector<RotParticlePy,ParticlePy,SimpleSpherePy>,
CRotParticle
> adder;
adder.addParticles(iteratable, getLatticeMaster());
}
else if (getParticleType() == "RotSphereVi")
{
LmParticleAdder<
boost::mpl::vector<RotParticleViPy,ParticlePy,SimpleSpherePy>,
CRotParticleVi
> adder;
adder.addParticles(iteratable, getLatticeMaster());
}
else if (getParticleType() == "RotThermalSphere")
{
LmParticleAdder<
boost::mpl::vector<RotThermalParticlePy,RotParticleViPy,ParticlePy,SimpleSpherePy>,
CRotThermParticle
> adder;
adder.addParticles(iteratable, getLatticeMaster());
}
else
{
throw
std::runtime_error(
std::string("Unknown particle type:")
+
getLatticeMaster().getParticleType()
);
}
}
void LsmMpiPy::createParticle(boost::python::object &particle)
{
boost::python::list l;
l.append(particle);
createParticles(l);
}
std::string LsmMpiPy::getParticleType() const
{
const std::string lmParticleType = getLatticeMaster().getParticleType();
if (lmParticleType == "Rot")
{
return "RotSphere";
}
else if (lmParticleType == "RotTherm")
{
return "RotThermalSphere";
}
else if (lmParticleType == "RotVi")
{
return "RotSphereVi";
}
else
{
return "NRotSphere";
}
}
void LsmMpiPy::readGeometry(const std::string &fileName)
{
getLatticeMaster().readGeometryFile(fileName);
}
int LsmMpiPy::getNumParticles()
{
return getLatticeMaster().getNumParticles();
}
int LsmMpiPy::getTimeStep() const
{
return getLatticeMaster().getTimeStep();
}
// --- interaction creation functions ---
void LsmMpiPy::createNRotElasticInteractGrp(
const NRotElasticPrmsPy &prms
)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createHertzianElasticIG(
const HertzianElasticPrmsPy &prms
)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createHertzianViscoElasticFrictionIG(
const HertzianViscoElasticFrictionPrmsPy &prms
)
{
HertzianViscoElasticFrictionPrmsPy p = prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addPairIG(p);
}
void LsmMpiPy::createHertzianViscoElasticIG(
const HertzianViscoElasticPrmsPy &prms
)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createLinearDashpotIG(
const LinearDashpotPrmsPy &prms
)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createNRotBondInteractGrp(
const NRotBondPrmsPy &bondPrms
)
{
getNameTypeMap()[bondPrms.getName()] = bondPrms.getTypeString();
getLatticeMaster().addBondedIG(bondPrms);
}
void LsmMpiPy::createCappedNRotBondInteractGrp(
const CappedNRotBondPrmsPy &bondPrms
)
{
getNameTypeMap()[bondPrms.getName()] = bondPrms.getTypeString();
getLatticeMaster().addCappedBondedIG(
bondPrms.tag,
bondPrms.getName(),
bondPrms.k,
bondPrms.rbreak,
bondPrms.m_force_limit
);
}
void LsmMpiPy::createNRotShortBondInteractGrp(
const NRotShortBondPrmsPy &bondPrms
)
{
getNameTypeMap()[bondPrms.getName()] = bondPrms.getTypeString();
getLatticeMaster().addShortBondedIG(
bondPrms.tag,
bondPrms.getName(),
bondPrms.k,
bondPrms.rbreak
);
}
void LsmMpiPy::createNRotFrictionInteractGrp(
const NRotFrictionPrmsPy &prms
)
{
NRotFrictionPrmsPy p = prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addPairIG(p);
}
void LsmMpiPy::createRotBondInteractGrp(const RotBondPrmsPy &bondPrms)
{
getNameTypeMap()[bondPrms.getName()] = bondPrms.getTypeString();
getLatticeMaster().addRotBondedIG(
bondPrms.tag,
bondPrms.getName(),
bondPrms.kr,
bondPrms.ks,
bondPrms.kt,
bondPrms.kb,
bondPrms.max_nForce,
bondPrms.max_shForce,
bondPrms.max_tMoment,
bondPrms.max_bMoment,
bondPrms.scaling
);
}
BondInteractionGroupPy LsmMpiPy::createRotThermBondInteractGrp(
const RotThermBondPrmsPy &bondPrms
)
{
getNameTypeMap()[bondPrms.getName()] = bondPrms.getTypeString();
getLatticeMaster().addRotThermBondedIG(bondPrms);
return BondInteractionGroupPy(*this, bondPrms.getName());
}
void LsmMpiPy::createBrittleBeamInteractGrp(const BrittleBeamPrmsPy &bondPrms)
{
getNameTypeMap()[bondPrms.getName()] = bondPrms.getTypeString();
getLatticeMaster().addRotBondedIG(
bondPrms.tag,
bondPrms.getName(),
bondPrms.kr,
bondPrms.ks,
bondPrms.kt,
bondPrms.kb,
bondPrms.max_nForce,
bondPrms.max_shForce,
bondPrms.max_tMoment,
bondPrms.max_bMoment,
bondPrms.scaling
);
}
void LsmMpiPy::createFrictionInteractGrp(const FrictionPrmsPy &prms)
{
FrictionPrmsPy p=prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addPairIG(p);
}
void LsmMpiPy::createRotFrictionInteractGrp(const RotFrictionPrmsPy &prms)
{
RotFrictionPrmsPy p=prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addPairIG(p);
}
void LsmMpiPy::createRotThermFrictionInteractGrp(
const RotThermFrictionPrmsPy &prms
)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createVWFrictionIG(const VWFrictionPrmsPy &prms)
{
VWFrictionPrmsPy p=prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createRotElasticInteractGrp(const RotElasticPrmsPy& prms)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createRotThermElasticInteractGrp(
const RotThermElasticPrmsPy &prms
)
{
getNameTypeMap()[prms.getName()] = prms.getTypeString();
getLatticeMaster().addPairIG(prms);
}
void LsmMpiPy::createDamping(const DampingPrmsPy &prms)
{
DampingPrmsPy p = prms;
p.setTimeStepSize(getTimeStepSize());
getLatticeMaster().addDamping(p);
}
void LsmMpiPy::createLocalDamping(const LocalDampingPrmsPy &prms)
{
LocalDampingPrmsPy p = prms;
p.setTimeStepSize(getTimeStepSize());
getLatticeMaster().addDamping(p);
}
void LsmMpiPy::createRotLocalDamping(const RotLocalDampingPrmsPy &prms)
{
RotLocalDampingPrmsPy p = prms;
p.setTimeStepSize(getTimeStepSize());
getLatticeMaster().addDamping(p);
}
void LsmMpiPy::createABCDamping(const ABCDampingPrmsPy &prms)
{
ABCDampingPrmsPy p = prms;
p.setTimeStepSize(getTimeStepSize());
getLatticeMaster().addDamping(p);
}
void LsmMpiPy::createGravity(const GravityPrmsPy& prms)
{
getLatticeMaster().addSingleIG(prms);
}
void LsmMpiPy::removeInteractionGrp(const std::string& name)
{
getLatticeMaster().removeIG(name);
}
// ----------------------------------------------
// tagged interaction creation functions
// ----------------------------------------------
void LsmMpiPy::createRotFrictionInteractGrpTag(const RotFrictionPrmsPy &prms,
int tag1, int mask1,
int tag2, int mask2)
{
RotFrictionPrmsPy p=prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addTaggedPairIG(p,tag1,mask1,tag2,mask2);
}
void LsmMpiPy::createNRotFrictionInteractGrpTag(const NRotFrictionPrmsPy &prms,
int tag1, int mask1,
int tag2, int mask2)
{
NRotFrictionPrmsPy p=prms;
p.setTimeStepSize(getTimeStepSize());
getNameTypeMap()[p.getName()] = p.getTypeString();
std::cerr << "createNRotFrictionInteractGrpTag " << tag1 << " , "<< mask1 << " , "<< tag2 << " , "<< mask2 << " , " << std::endl;
getLatticeMaster().addTaggedPairIG(p,tag1,mask1,tag2,mask2);
}
void LsmMpiPy::createLinearDashpotInteractGrpTag(const LinearDashpotPrmsPy &prms,
int tag1, int mask1,
int tag2, int mask2)
{
LinearDashpotPrmsPy p=prms;
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addTaggedPairIG(p,tag1,mask1,tag2,mask2);
}
void LsmMpiPy::createElasticInteractGrpTag(const NRotElasticPrmsPy &prms,
int tag1, int mask1,
int tag2, int mask2)
{
NRotElasticPrmsPy p=prms;
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addTaggedPairIG(p,tag1,mask1,tag2,mask2);
}
void LsmMpiPy::createRotElasticInteractGrpTag(
const RotElasticPrmsPy& prms,
int tag1,
int mask1,
int tag2,
int mask2
) {
RotElasticPrmsPy p=prms;
getNameTypeMap()[p.getName()] = p.getTypeString();
getLatticeMaster().addTaggedPairIG(p,tag1,mask1,tag2,mask2);
}
// ----------------------------------------------
// interaction group exclusion
// ----------------------------------------------
void LsmMpiPy::createExclusion(
const std::string &interactionName1,
const std::string &interactionName2
)
{
getLatticeMaster().addExIG(interactionName1, interactionName2);
}
// -- checkpoint & snapshot setup ---
void LsmMpiPy::createCheckPointer(const CheckPointPrmsPy &prms)
{
getLatticeMaster().performCheckPoints(
prms.getFileNamePrefix(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
void LsmMpiPy::createCheckPointerThroughMaster(const CheckPointPrmsPy &prms)
{
getLatticeMaster().performCheckPointsThroughMaster(
prms.getFileNamePrefix(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
void LsmMpiPy::createSnapShots(const CheckPointPrmsPy &prms)
{
getLatticeMaster().initSnapShotController(
prms.getFileNamePrefix(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
void LsmMpiPy::loadCheckPoint(const std::string& filename)
{
getLatticeMaster().loadCheckPointData(filename);
}
int LsmMpiPy::getNumTimeSteps() const
{
return getLatticeMaster().getNumSteps();
}
void LsmMpiPy::setNumTimeSteps(int numTimeSteps)
{
getLatticeMaster().setNumSteps(numTimeSteps);
}
//-------------------
// Mesh related functions
//-------------------
/*!
read triangle mesh from file
*/
void LsmMpiPy::readMeshWithTag(const std::string &fileName, const std::string &meshName,int tag)
{
getLatticeMaster().readAndDistributeTriMesh(meshName, fileName, tag);
}
/*!
read triangle mesh from file ignoring tag
*/
void LsmMpiPy::readMesh(const std::string &fileName, const std::string &meshName)
{
getLatticeMaster().readAndDistributeTriMesh(meshName, fileName);
}
/*
create triangle mesh from within the python script
*/
void LsmMpiPy::createTriMesh(
const std::string &meshName,
const boost::python::object &nodeSequence,
const boost::python::object &triSequence
)
{
const std::size_t numNodes = bpu::len(nodeSequence);
MeshNodeDataVector nodeVector;
for (std::size_t i = 0; i < numNodes; i++)
{
boost::python::object node = nodeSequence[i];
int tag = 0;
if (bpu::len(node) > 2)
{
tag = boost::python::extract<int>(node[2]);
}
nodeVector.push_back(
MeshNodeData(
boost::python::extract<int>(node[0]),
Vec3Py(node[1]),
tag
)
);
}
const std::size_t numTriangles = bpu::len(triSequence);
MeshTriDataVector triVector;
for (std::size_t i = 0; i < numTriangles; i++)
{
boost::python::object triangle = triSequence[i];
int tag = 0;
if (bpu::len(triangle) > 2)
{
tag = boost::python::extract<int>(triangle[2]);
}
triVector.push_back(
MeshTriData(
boost::python::extract<int>(triangle[0]),
boost::python::extract<int>(triangle[1][0]),
boost::python::extract<int>(triangle[1][1]),
boost::python::extract<int>(triangle[1][2]),
tag
)
);
}
getLatticeMaster().createTriMesh(meshName, nodeVector, triVector);
}
void LsmMpiPy::readMesh2D(
const std::string &fileName,
const std::string &meshName,
int tag
)
{
getLatticeMaster().addMesh2D(meshName, fileName,tag);
}
void LsmMpiPy::translateMesh(
const std::string &meshName,
const Vec3Py &translation
)
{
getLatticeMaster().translateMeshBy(meshName, translation);
}
void LsmMpiPy::createNRotElasticTriMeshInteractGrp(
const NRotElasticTriMeshPrmsPy &prms
)
{
getLatticeMaster().addTriMeshIG(prms);
}
void LsmMpiPy::createNRotBondedTriMeshInteractGrp(
const NRotBondedTriMeshPrmsPy &prms
)
{
if (prms.haveTagBuildPrms()) {
getLatticeMaster().addBondedTriMeshIG(prms, prms.getTagBuildPrms());
}
else if (prms.haveGapBuildPrms()) {
getLatticeMaster().addBondedTriMeshIG(prms, prms.getGapBuildPrms());
}
else {
throw std::runtime_error("Unknown bonded triangular mesh build prms.");
}
}
void LsmMpiPy::createNRotElasticMesh2DInteractGrp(
const NRotElasticMesh2DPrmsPy &prms
)
{
getLatticeMaster().addMesh2DIG(prms);
}
void LsmMpiPy::createNRotElasticLinMeshInteractGrp(
const NRotElasticLinMeshPrmsPy &prms
)
{
getLatticeMaster().addMesh2DIG(prms);
}
void LsmMpiPy::createNRotBondedLinMeshInteractGrp(
const NRotBondedLinMeshPrmsPy &prms
)
{
if (prms.haveTagBuildPrms()) {
getLatticeMaster().addBondedMesh2DIG(prms, prms.getTagBuildPrms());
}
else if (prms.haveGapBuildPrms()) {
getLatticeMaster().addBondedMesh2DIG(prms, prms.getGapBuildPrms());
}
else {
throw std::runtime_error("Unknown bonded triangular mesh build prms.");
}
}
void LsmMpiPy::moveSingleMeshNodeBy(
const string& meshname,
int id,
const Vec3Py& d
)
{
getLatticeMaster().moveSingleNodeBy(meshname,id,d);
}
void LsmMpiPy::addPreTimeStepRunnable(RunnablePy &runnable)
{
getLatticeMaster().addPreTimeStepRunnable(runnable);
}
void LsmMpiPy::addPostTimeStepRunnable(RunnablePy &runnable)
{
getLatticeMaster().addPostTimeStepRunnable(runnable);
}
void LsmMpiPy::runTimeStep()
{
getLatticeMaster().runOneStep();
}
void LsmMpiPy::run()
{
getLatticeMaster().run();
}
// Exit the simulation after running a series of single steps
// of the time-integration method.
void LsmMpiPy::exit()
{
getLatticeMaster().runEnd();
}
void LsmMpiPy::force2dComputations(bool do2d)
{
getLatticeMaster().do2dCalculations(do2d);
}
void LsmMpiPy::setBBoxSpatialDomain(const BoundingBoxPy &domain)
{
getLatticeMaster().setSpatialDomain(
domain.getMinPt(),
domain.getMaxPt()
);
}
void LsmMpiPy::setBBoxSpatialDomainWithCirc(
const BoundingBoxPy &domain,
const boost::python::list &circDimList
)
{
getLatticeMaster().setSpatialDomain(
domain.getMinPt(),
domain.getMaxPt(),
bpu::listToVector<int>(circDimList)
);
}
void LsmMpiPy::setSpatialDomain(const Vec3Py &minPt, const Vec3Py &maxPt)
{
getLatticeMaster().setSpatialDomain(minPt, maxPt);
}
int LsmMpiPy::findClosestParticle(const Vec3Py &pt)
{
return getLatticeMaster().findParticleNearestTo(pt);
}
Vec3Py LsmMpiPy::getParticlePosn(int particleId)
{
return Vec3Py(getLatticeMaster().getParticlePosn(particleId));
}
// -----------------------
// moving particles
// -----------------------
void LsmMpiPy::moveTaggedParticlesTo(int tag, const Vec3Py &pt)
{
getLatticeMaster().moveParticleTo(tag, pt);
}
void LsmMpiPy::moveTaggedParticlesBy(int tag, const Vec3Py &displacement)
{
getLatticeMaster().moveTaggedParticlesBy(tag, displacement);
}
void LsmMpiPy::moveSingleParticleTo(int particleId, const Vec3Py &pt)
{
getLatticeMaster().moveSingleParticleTo(particleId, pt);
}
// -----------------------
// Wall related functions
// -----------------------
void LsmMpiPy::createWall(
const string& name,
const Vec3Py& pos, const Vec3Py& norm
)
{
getLatticeMaster().addWall(name,pos,norm);
}
void LsmMpiPy::moveWallBy(const string& name, const Vec3Py &disp)
{
getLatticeMaster().moveWallBy(name,disp);
}
void LsmMpiPy::setWallNormal(const string& name, const Vec3Py &wn)
{
getLatticeMaster().setWallNormal(name,wn);
}
void LsmMpiPy::createNRotBondedWall(
const NRotBondedWallPrmsPy &prms
)
{
getLatticeMaster().addWallIG(prms);
}
void LsmMpiPy::createNRotElasticWall(
const NRotElasticWallPrmsPy &prms
)
{
getLatticeMaster().addWallIG(prms);
}
void LsmMpiPy::createNRotSoftBondedWall(const NRotSoftBondedWallPrmsPy &prms)
{
getLatticeMaster().addWallIG(prms);
}
void LsmMpiPy::applyForceToWall(const string& name, const Vec3Py &Frc)
{
getLatticeMaster().applyForceToWall(name,Frc);
}
Vec3Py LsmMpiPy::getWallPosition(const std::string& name)
{
return Vec3Py(getLatticeMaster().getWallPosn(name));
}
Vec3Py LsmMpiPy::getWallForce(const std::string& name)
{
return Vec3Py(getLatticeMaster().getWallForce(name));
}
// --- particle property setting functions ---
void LsmMpiPy::setParticleVel(int id,const Vec3Py &V)
{
getLatticeMaster().setParticleVel(id,V);
}
void LsmMpiPy::setParticleAngVel(int id,const Vec3Py &AV)
{
getLatticeMaster().setParticleAngVel(id,AV);
}
void LsmMpiPy::setParticleDensity(int tag,int mask, double rho)
{
getLatticeMaster().setParticleDensity(tag,mask,rho);
}
void LsmMpiPy::setTaggedParticleVel(int tag, const Vec3Py &V)
{
getLatticeMaster().setTaggedParticleVel(tag,V);
}
void LsmMpiPy::setVelocityOfWall(const std::string &name,const Vec3Py &V)
{
getLatticeMaster().setVelocityOfWall(name,V);
}
void LsmMpiPy::tagParticleNearestTo(int tag,int mask,const Vec3Py &Pos)
{
getLatticeMaster().tagParticleNearestTo(tag,mask,Pos);
}
void LsmMpiPy::setParticleNonDynamic(int tag)
{
getLatticeMaster().setParticleNonDynamic(tag);
}
void LsmMpiPy::setParticleNonRot(int tag)
{
getLatticeMaster().setParticleNonRot(tag);
}
void LsmMpiPy::setParticleNonTrans(int id)
{
getLatticeMaster().setParticleNonTrans(id);
}
// ------------------------------
// field saving functions
// ------------------------------
void LsmMpiPy::createParticleScalarFieldSaver(
const ParticleScalarFieldSaverPrmsPy &prms
)
{
getLatticeMaster().addScalarParticleSaveField(
prms.getFileName(),
prms.getFieldName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
void LsmMpiPy::createParticleVectorFieldSaver(const ParticleVectorFieldSaverPrmsPy &prms)
{
getLatticeMaster().addVectorParticleSaveField(
prms.getFileName(),
prms.getFieldName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
void LsmMpiPy::createInteractionScalarFieldSaver(
const InteractionScalarFieldSaverPrmsPy &prms
)
{
if (
getNameTypeMap().find(prms.getInteractionName())
!=
getNameTypeMap().end()
)
{
getLatticeMaster().addScalarInteractionSaveField(
prms.getFileName(),
prms.getFieldName(),
getNameTypeMap()[prms.getInteractionName()],
prms.getInteractionName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
else
{
std::stringstream msg;
msg
<< "No interaction named '" << prms.getInteractionName()
<< "' has been created in this model.";
throw std::runtime_error(msg.str().c_str());
}
}
void LsmMpiPy::createCheckedInteractionScalarFieldSaver(
const CheckedInteractionScalarFieldSaverPrmsPy &prms
)
{
if (
getNameTypeMap().find(prms.getInteractionName())
!=
getNameTypeMap().end()
)
{
getLatticeMaster().addScalarInteractionSaveField(
prms.getFileName(),
prms.getFieldName(),
getNameTypeMap()[prms.getInteractionName()],
prms.getInteractionName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
true
);
}
else
{
std::stringstream msg;
msg
<< "No interaction named '" << prms.getInteractionName()
<< "' has been created in this model.";
throw std::runtime_error(msg.str().c_str());
}
}
void LsmMpiPy::createTaggedInteractionScalarFieldSaver(
const TaggedInteractionScalarFieldSaverPrmsPy &prms
)
{
if (
getNameTypeMap().find(prms.getInteractionName())
!=
getNameTypeMap().end()
)
{
getLatticeMaster().addTaggedScalarInteractionSaveField(
prms.getFileName(),
prms.getFieldName(),
getNameTypeMap()[prms.getInteractionName()],
prms.getInteractionName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
prms.getTag(),
prms.getMask(),
false
);
}
else
{
std::stringstream msg;
msg
<< "No interaction named '" << prms.getInteractionName()
<< "' has been created in this model.";
throw std::runtime_error(msg.str().c_str());
}
}
void LsmMpiPy::createInteractionVectorFieldSaver(
const InteractionVectorFieldSaverPrmsPy &prms
)
{
if (
getNameTypeMap().find(prms.getInteractionName())
!=
getNameTypeMap().end()
)
{
getLatticeMaster().addVectorInteractionSaveField(
prms.getFileName(),
prms.getFieldName(),
getNameTypeMap()[prms.getInteractionName()],
prms.getInteractionName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
else
{
std::stringstream msg;
msg
<< "No interaction named '" << prms.getInteractionName()
<< "' has been created in this model.";
throw std::runtime_error(msg.str().c_str());
}
}
void LsmMpiPy::createCheckedInteractionVectorFieldSaver(
const CheckedInteractionVectorFieldSaverPrmsPy &prms
)
{
if (
getNameTypeMap().find(prms.getInteractionName())
!=
getNameTypeMap().end()
)
{
getLatticeMaster().addVectorInteractionSaveField(
prms.getFileName(),
prms.getFieldName(),
getNameTypeMap()[prms.getInteractionName()],
prms.getInteractionName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
true
);
}
else
{
std::stringstream msg;
msg
<< "No interaction named '" << prms.getInteractionName()
<< "' has been created in this model.";
throw std::runtime_error(msg.str().c_str());
}
}
void LsmMpiPy::createTaggedParticleScalarFieldSaver(const TaggedParticleScalarFieldSaverPrmsPy& prms)
{
getLatticeMaster().addTaggedScalarParticleSaveField(
prms.getFileName(),
prms.getFieldName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
prms.getTag(),
prms.getMask());
}
void LsmMpiPy::createTaggedParticleVectorFieldSaver(const TaggedParticleVectorFieldSaverPrmsPy& prms)
{
getLatticeMaster().addTaggedVectorParticleSaveField(
prms.getFileName(),
prms.getFieldName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
prms.getTag(),
prms.getMask());
}
void LsmMpiPy::addTaggedScalarParticleDistributionSaver(
const string &filename,
const string& fieldname,
const string& savetype,
int t_0,int t_end,int dt,int t_snap,
int tag,int mask,
double x_0,double x_max,int nx
)
{
getLatticeMaster().addTaggedScalarParticleDistributionSaver(
filename,fieldname,
savetype,t_0,t_end,dt,t_snap,tag,mask,x_0,x_max,nx
);
}
void LsmMpiPy::addVectorTriangleSaveField(
const string& filename,
const string& fieldname,
const string& meshname,
const string& savetype,
int t_0,int t_end,int dt
)
{
getLatticeMaster().addVectorTriangleSaveField(
filename,fieldname,meshname,
savetype,t_0,t_end,dt
);
}
void LsmMpiPy::addScalarTriangleSaveField(
const string& filename,
const string& fieldname,
const string& meshname,
const string& savetype,
int t_0,int t_end,int dt)
{
getLatticeMaster().addScalarTriangleSaveField(
filename,fieldname,meshname,
savetype,t_0,t_end,dt
);
}
/*!
wrap LatticeMaster::addVectorWallField
*/
void LsmMpiPy::addVectorWallField(
const WallVectorFieldSaverPrmsPy &prms
)
{
getLatticeMaster().addVectorWallField(
prms.getFileName(),
prms.getFieldName(),
prms.getWallNameVector(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr()
);
}
// --- with trigger ---
/*!
wrap
*/
void LsmMpiPy::createParticleVectorFieldSaverWithTrigger(
const MaxTriggerPrmsPy &tprms,
const ParticleVectorFieldSaverPrmsPy &prms)
{
const MaxTrigParams mtp=MaxTrigParams(tprms);
getLatticeMaster().addVectorParticleSaveFieldWT(
prms.getFileName(),
prms.getFieldName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
mtp
);
}
/*!
wrap
*/
void LsmMpiPy::createTaggedParticleVectorFieldSaverWithTrigger(
const MaxTriggerPrmsPy &tprms,
const TaggedParticleVectorFieldSaverPrmsPy& prms)
{
const MaxTrigParams mtp=MaxTrigParams(tprms);
getLatticeMaster().addTaggedVectorParticleSaveFieldWT(
prms.getFileName(),
prms.getFieldName(),
prms.getFileFormat(),
prms.getBeginTimeStep(),
prms.getEndTimeStep(),
prms.getTimeStepIncr(),
prms.getTag(),
prms.getMask(),
mtp
);
}
/*!
set verbosity via LatticeMaster - call gets communicated to Workers
*/
void LsmMpiPy::setVerbosityPy(bool verbose)
{
getLatticeMaster().setVerbosity(verbose);
}
// ------
const CLatticeMaster &LsmMpiPy::getLatticeMaster() const
{
return m_implPtr->m_latticeMaster;
}
CLatticeMaster &LsmMpiPy::getLatticeMaster()
{
return m_implPtr->m_latticeMaster;
}
/*!
Global setVerbosity call. Only influences the Master
*/
void setVerbosityPy(bool verbose)
{
if (verbose)
{
console.SetVerbose(Con::all);
}
else
{
console.SetVerbose(Con::silent);
}
}
class NodeRefVisitor
{
public:
NodeRefVisitor(boost::python::object pyObject) : m_pyObject(pyObject)
{
}
void visitNodeRef(int nodeRef)
{
m_pyObject.attr("visitNodeRef")(nodeRef);
}
private:
boost::python::object m_pyObject;
};
class RefStressVisitor
{
public:
RefStressVisitor(boost::python::object pyObject) : m_pyObject(pyObject)
{
}
void visitRefStressPair(int nodeRef, const Vec3 &force)
{
m_pyObject.attr("visitRefStressPair")(nodeRef, Vec3Py(force));
}
private:
boost::python::object m_pyObject;
};
void LsmMpiPy::visitNodeRefs2d(const std::string &meshName, boost::python::object pyObject)
{
NodeRefVisitor visitor(pyObject);
getLatticeMaster().visitMesh2dNodeReferences(meshName, visitor);
}
void LsmMpiPy::visitRefStressPairs2d(
const std::string &meshName,
boost::python::object pyObject
)
{
RefStressVisitor visitor(pyObject);
getLatticeMaster().visitMesh2dEdgeStress(meshName, visitor);
}
void LsmMpiPy::updateInteractions()
{
// getLatticeMaster().updateInteractions();
}
class ParticleVisitor
{
public:
ParticleVisitor(boost::python::object pyObject) : m_pyObject(pyObject)
{
}
void visitParticle(const CParticle &particle)
{
m_pyObject.attr("visitNRotSphere")(ParticlePy(particle));
}
void visitRotParticle(const CRotParticle &particle)
{
m_pyObject.attr("visitRotSphere")(RotParticlePy(particle));
}
void visitRotParticleVi(const CRotParticleVi &particle)
{
m_pyObject.attr("visitRotSphereVi")(RotParticleViPy(particle));
}
void visitRotThermParticle(const CRotThermParticle &particle)
{
m_pyObject.attr("visitRotThermalSphere")(RotThermalParticlePy(particle));
}
private:
boost::python::object m_pyObject;
};
class ListGatherVisitor
{
public:
ListGatherVisitor() : m_pyList()
{
}
void visitParticle(const CParticle &particle)
{
m_pyList.append(ParticlePy(particle));
}
void visitRotParticle(const CRotParticle &particle)
{
m_pyList.append(RotParticlePy(particle));
}
void visitRotParticleVi(const CRotParticleVi &particle)
{
m_pyList.append(RotParticleViPy(particle));
}
void visitRotThermParticle(const CRotThermParticle &particle)
{
m_pyList.append(RotThermalParticlePy(particle));
}
const boost::python::list &getList() const
{
return m_pyList;
}
private:
boost::python::list m_pyList;
};
void LsmMpiPy::visitParticlesWithId(
const boost::python::list &idList,
boost::python::object &pyObject
)
{
ParticleVisitor visitor(pyObject);
getLatticeMaster().visitParticles(
bpu::listToVector<int>(idList),
visitor
);
}
boost::python::list LsmMpiPy::getParticleList()
{
ListGatherVisitor visitor;
getLatticeMaster().visitParticles(
CLatticeMaster::IdVector(),
visitor
);
return visitor.getList();
}
boost::python::list LsmMpiPy::getParticleWithIdList(
const boost::python::list &idList
)
{
ListGatherVisitor visitor;
getLatticeMaster().visitParticles(
bpu::listToVector<int>(idList),
visitor
);
return visitor.getList();
}
void LsmMpiPy::createBonds(
const std::string &groupName,
const ParticleIdPairVector &idPairVector
)
{
//getLatticeMaster().createBonds(groupName, idPairVector);
}
LsmMpiPy::ParticleIdPairVector
LsmMpiPy::getBondGroupIdPairs(
const std::string &groupName
)
{
//return getLatticeMaster().getBondGroupIdPairs(groupName);
}
/*!
export the interfaces to Python via boost
*/
void exportLsm()
{
// Check that Boost 1.34.0 or higher is being used.
// If so, disable auto-generation of C++ signatures for Epydoc
// (which stumbles over indentation in the auto-generated strings).
#if ((BOOST_VERSION / 100000 >= 1) \
&& (BOOST_VERSION / 100 % 1000 >= 34)) \
|| (BOOST_VERSION / 100000 >= 2)
boost::python::docstring_options no_autogen(true,false);
#endif
setVerbosityPy(false);
exportRunnable();
exportCheckPointPrms();
exportInteractionPrms();
exportMeshBuildPrms();
exportBondedTriMeshPrms();
exportElasticTriMeshPrms();
exportElasticMesh2DPrms();
exportBondedMesh2dPrms();
exportWallPrms();
exportTriggerPrms();
using boost::python::arg;
boost::python::def(
"checkMpiDimensions",
&checkMpiDimensionsPy,
(
arg("numProcesses"),
arg("mpiDimList")
)
);
boost::python::def(
"checkParticleType",
&checkParticleTypePy,
(
arg("particleType")
)
);
boost::python::def(
"setVerbosity",
&setVerbosityPy
);
boost::python::class_<LsmMpiPy>(
"LsmMpi",
"Lattice Solid Model (parallelised using Message Passing Interface)"
" class for particle simulation.\n",
boost::python::init<
int,
const python::list &,
const std::string &,
const boost::python::list &
>(
(
arg("numWorkerProcesses"),
arg("mpiDimList"),
arg("spawnExe")="",
arg("spawnArgList")=boost::python::list()
),
"Spawns MPI worker processes for use in a cartesian grid decomposition"
" of the particle domain.\n"
"@type numWorkerProcesses: int\n"
"@kwarg numWorkerProcesses: The number of spawned MPI worker processes.\n"
"@type mpiDimList: list of 3 ints\n"
"@kwarg mpiDimList: List of 3 elements specifying the decomposition of"
" the simulation domain among worker processes. For example,"
" C{[3,2,4]} indicates a rectangular grid where the M{x}-axis of the"
" domain is divided into 3, the M{y}-axis is divided in 2 and the"
" M{z}-axis is divided into 4. A zero value in the list indicates"
" that dimension discretization is chosen according to the"
" numWorkerProcesses argument, for example,"
" C{(numWorkerProcesses=16, mpiDimList=[2,2,0])} implies that the"
" M{z}-axis of the will be divided into 4 parts (ie four two-by-two"
" cells). Particles in each domain cell are handled by a MPI worker process.\n"
"@type spawnExe: string\n"
"@kwarg spawnExe: Command used to spawn MPI worker processes.\n"
"@type spawnArgList: list of string\n"
"@kwarg spawnArgList: List of command-line argument strings.\n"
)
)
.def(
"getNumWorkerProcesses",
&LsmMpiPy::getNumWorkerProcesses,
"@rtype: int\n"
"@return: Number of spawned MPI worker processes."
)
.def(
"initVerletModel",
&LsmMpiPy::initVerletModel,
(
arg("particleType"),
arg("gridSpacing"),
arg("verletDist")
),
"Initialises simulation data structures.\n"
"@type particleType: string\n"
"@kwarg particleType: Specifies the type discrete-element"
" particles.\n"
"@type gridSpacing: float\n"
"@kwarg gridSpacing: The size of the grid-spacing used by the"
" contact detection algorithm. For spherical particles,"
" C{gridSpacing} must be greater than double the maximum particle radius.\n"
"@type verletDist: float\n"
"@kwarg verletDist: When the magnitude of a"
" particle-displacement exceeds this amount, the neighbour lists"
" (used in the contact detection) are updated.\n"
)
.def(
"initNeighbourSearch",
&LsmMpiPy::initVerletModel,
(
arg("particleType"),
arg("gridSpacing"),
arg("verletDist")
),
"Initialises simulation data structures.\n"
"@type particleType: string\n"
"@kwarg particleType: Specifies the type discrete-element"
" particles.\n"
"@type gridSpacing: float\n"
"@kwarg gridSpacing: The size of the grid-spacing used by the"
" contact detection algorithm. For spherical particles,"
" C{gridSpacing} must be greater than double the maximum particle radius.\n"
"@type verletDist: float\n"
"@kwarg verletDist: When the magnitude of a"
" particle-displacement exceeds this amount, the neighbour lists"
" (used in the contact detection) are updated.\n"
)
.def(
"setTimeStepSize",
&LsmMpiPy::setTimeStepSize,
(arg("dt")),
"Sets the size of the time step used in the integration method.\n"
"@type dt: float\n"
"@kwarg dt: time step size used in explicit "
" time-stepping scheme."
)
.def(
"getWorkerSpawnCmd",
&LsmMpiPy::getWorkerSpawnCmd,
"Returns the command line string which spawns MPI worker"
" processes.\n"
"@rtype: string\n"
"@return: Command line string."
)
.def(
"getParticleType",
&LsmMpiPy::getParticleType,
"@rtype: string\n"
"@return: A string indicating the type of discrete-element"
" particles in the model."
)
.def(
"getTimeStepSize",
&LsmMpiPy::getTimeStepSize,
"Returns the current time-step size.\n"
"@rtype: float\n"
"@return: time step size for the current time-step."
)
.def(
"getNumTimeSteps",
&LsmMpiPy::getNumTimeSteps,
"Returns the maximum number of time-steps which will"
" be executed by the L{run} method.\n"
"@rtype: int\n"
"@return: Returns the maximum number of time-steps to execute."
)
.def(
"setNumTimeSteps",
&LsmMpiPy::setNumTimeSteps,
(arg("numTimeSteps")),
"Sets the maximum number of time-steps for the L{run}"
" method to execute.\n"
"@type numTimeSteps: int\n"
"@kwarg numTimeSteps: The number of time-steps to execute in the"
" L{run} method."
)
.def(
"getTimeStep",
&LsmMpiPy::getTimeStep,
"Returns the current time-step number (number of time-steps"
" executed so far).\n"
"@rtype: int\n"
"@return: Number of time-steps executed."
)
.def(
"readGeometry",
&LsmMpiPy::readGeometry,
(arg("fileName")),
"Reads particle-model setup from file.\n"
"@type fileName: string\n"
"@kwarg fileName: A file containing domain, particle and"
" connection data."
)
.def(
"getNumParticles",
&LsmMpiPy::getNumParticles,
"Returns the current number of particles in the model.\n"
"@rtype: int\n"
"@return: Number of particles."
)
.def(
"createConnections",
&LsmMpiPy::createConnections,
(arg("iterable")),
"Method for establishing bonds between particles.\n"
"@type iterable: iterator\n"
"@kwarg iterable: An object supporting the I{iterator protocol}"
" (ie supports C{iter(iterable)} which forms a sequence of "
"L{esys.lsm.geometry.TaggedIdConnection"
"<esys.lsm.geometry.GeometryPy.TaggedIdConnection>} objects,"
" indicating an association between particles with the specified"
" id's."
)
.def("setTimingFileName",
&LsmMpiPy::setTimingFileName,
(arg("fileName")),
"Method to switch on the saving of timing information and set the filename.\n"
"@type fileName: string\n"
"@kwarg fileName: the name of the file to which the timing data is saved\n"
)
.def("setSlaveTimingFileName",
&LsmMpiPy::setSlaveTimingFileName,
(arg("fileName")),
"Method to switch on the saving of timing information and set the filename prefix for the slaves.\n"
"@type fileName: string\n"
"@kwarg fileName: the prefix of the file name to which the timing data is saved\n"
)
.def(
"createParticles",
&LsmMpiPy::createParticles,
(arg("iterable")),
"Creates discrete-element particles within the model.\n"
"@type iterable: iterator\n"
"@kwarg iterable: An object supporting the I{iterator protocol}"
" (ie supports C{iter(iterable)} which forms a sequence of "
"L{esys.lsm.geometry.SimpleSphere"
"<esys.lsm.geometry.GeometryPy.SimpleSphere>} objects."
" A model particle is created for each element "
" object in the sequence."
)
.def(
"createParticle",
&LsmMpiPy::createParticle,
(arg("particle")),
"Creates a discrete-element particle within the model.\n"
"@type particle: object\n"
"@kwarg particle: An object from which a particle can be constructed."
)
.def(
"createInteractionGroup",
&LsmMpiPy::createDamping,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createLocalDamping,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotLocalDamping,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createABCDamping,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createGravity,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotElasticTriMeshInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotBondedTriMeshInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotElasticMesh2DInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotElasticLinMeshInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotBondedLinMeshInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotBondInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotShortBondInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createCappedNRotBondInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotFrictionInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotElasticInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotBondInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotThermBondInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createBrittleBeamInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createFrictionInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotFrictionInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotThermFrictionInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createVWFrictionIG,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotElasticInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createRotThermElasticInteractGrp,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createHertzianElasticIG,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createHertzianViscoElasticFrictionIG,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createHertzianViscoElasticIG,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createLinearDashpotIG,
(arg("prms"))
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotElasticWall,
(
arg("prms")
)
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotBondedWall,
(
arg("prms")
)
)
.def(
"createInteractionGroup",
&LsmMpiPy::createNRotSoftBondedWall,
(arg("prms")),
"Creates a group of interactions with specified properties,"
" or a model-wall which is described by an infinite plane.\n"
"@type prms: L{esys.lsm.InteractionPrms"
"<esys.lsm.LsmPy.InteractionPrms>}\n"
"@kwarg prms: An object describing the type of interaction"
" and any parameters associated with that interaction,"
" or parameters describing the planar wall geometry"
" and the interactions to which particles are subjected when"
" they encounter the wall. For non-rotational soft bonded walls,"
" elastic coefficients are direction dependent.\n"
)
.def(
"removeInteractionGroup",
&LsmMpiPy::removeInteractionGrp,
(arg("name"))
)
.def(
"createDamping",
&LsmMpiPy::createDamping,
(arg("prms")),
"Creates viscosity within the model.\n"
"@type prms: L{DampingPrms}\n"
"@kwarg prms: Object describing the type of damping and"
" the parameters associated with the damping.\n"
"\n@status: Deprecated, use"
" C{createInteractionGroup(DampingPrms(...))}.\n"
)
.def(
"createGravity",
&LsmMpiPy::createGravity,
(arg("prms")),
"Creates a gravitational body force within the model.\n"
"@type prms: L{GravityPrms<esys.lsm.LsmPy.GravityPrms>}\n"
"@kwarg prms: Parameters specifying gravitational acceleration.\n"
)
.def(
"createInteractionGroupTagged",
&LsmMpiPy::createRotFrictionInteractGrpTag,
(
arg("prms"),
arg("tag1"),
arg("mask1"),
arg("tag2"),
arg("mask2")
)
)
.def(
"createInteractionGroupTagged",
&LsmMpiPy::createNRotFrictionInteractGrpTag,
(
arg("prms"),
arg("tag1"),
arg("mask1"),
arg("tag2"),
arg("mask2")
)
)
.def(
"createInteractionGroupTagged",
&LsmMpiPy::createLinearDashpotInteractGrpTag,
(
arg("prms"),
arg("tag1"),
arg("mask1"),
arg("tag2"),
arg("mask2")
)
)
.def(
"createInteractionGroupTagged",
&LsmMpiPy::createElasticInteractGrpTag,
(
arg("prms"),
arg("tag1"),
arg("mask1"),
arg("tag2"),
arg("mask2")
)
)
.def(
"createInteractionGroupTagged",
&LsmMpiPy::createRotElasticInteractGrpTag,
(
arg("prms"),
arg("tag1"),
arg("mask1"),
arg("tag2"),
arg("mask2")
)
)
.def(
"createExclusion",
&LsmMpiPy::createExclusion,
(
arg("interactionName1"),
arg("interactionName2")
),
"Creates an I{interaction exclusion}. When a pair of particles"
" come into contact, a decision is made as to the types of "
" interactions to which the pair are subjected."
" An exclusion precludes a pair of particles from being"
" subjected to the interaction C{interactionName2} if"
" they are already subjected to C{interactionName1}."
" This is necessary, for instance, in fracture models, where"
" particles are initially elastically bonded, but after fracture"
" occurs particles are subjected to a frictional type of"
" interaction.\n"
"@type interactionName1: string\n"
"@kwarg interactionName1: Name of an existing interaction.\n"
"@type interactionName2: string\n"
"@kwarg interactionName2: Name of an existing interaction.\n"
)
.def(
"createWall",
&LsmMpiPy::createWall,
(
arg("name"),
arg("posn"),
arg("normal")
),
"Creates a model wall, an infinite plane specified as point-on-plane"
" and normal-to-plane.\n"
"@type name: str\n"
"@kwarg name: Name assigned to the wall. This name can be used to"
"to reference this wall in other wall-related methods.\n"
"@type posn: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg posn: A point on the plane which describes the position of"
" the wall.\n"
"@type normal: L{esys.lsm.util.Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg normal: The normal to the plane describing the orientation of"
" the wall."
)
.def(
"getWallPosition",
&LsmMpiPy::getWallPosition,
(
arg("name")
),
"Get postion of named wall. Returns (0,0,0) for unknown walls."
"@type name: str\n"
"@kwarg name: Name of the wall."
)
.def(
"getWallForce",
&LsmMpiPy::getWallForce,
(
arg("name")
),
"Get force acting on named wall. Returns (0,0,0) for unknown walls."
"@type name: str\n"
"@kwarg name: Name of the wall."
)
.def(
"createRestartCheckPointer",
&LsmMpiPy::createCheckPointer,
(arg("prms")),
"Causes simulation to periodically save the entire model state"
" to file in a way neccessary to restart the simulation.\n"
"@type prms: L{CheckPointPrms<esys.lsm.LsmPy.CheckPointPrms>}\n"
"@kwarg prms: Object describing when and where to save model state."
)
.def(
"createCheckPointerWriteThroughMaster",
&LsmMpiPy::createCheckPointerThroughMaster,
(arg("prms")),
"Causes simulation to periodically save the entire model state"
" to file in a way neccessary to restart the simulation.\n"
"@type prms: L{CheckPointPrms<esys.lsm.LsmPy.CheckPointPrms>}\n"
"@kwarg prms: Object describing when and where to save model state."
)
.def(
"createCheckPointer",
&LsmMpiPy::createSnapShots,
(arg("prms")),
"Causes simulation to periodically save the entire model state"
" to file for post-processing / visualisation.\n"
"@type prms: L{CheckPointPrms<esys.lsm.LsmPy.CheckPointPrms>}\n"
"@kwarg prms: Object describing when and where to save model state."
)
.def(
"loadCheckPoint",
&LsmMpiPy::loadCheckPoint,
(arg("filename")),
"load stored model state from a checkpoint file"
"@type prms: string\n"
"@kwarg prms: name of the checkpoint file."
)
.def(
"readMesh",
&LsmMpiPy::readMesh,
(
arg("fileName"),
arg("meshName")
),
"Creates a 3D triangulated surface mesh within the model which"
" is loaded from file.\n"
"@type fileName: string\n"
"@kwarg fileName: Name of file from which surface-mesh is read.\n"
"@type meshName: string\n"
"@kwarg meshName: Name assigned to the created mesh.\n"
)
.def(
"readMesh",
&LsmMpiPy::readMeshWithTag,
(
arg("fileName"),
arg("meshName"),
arg("tag")
),
"@type tag: int\n"
"@kwarg tag: Only elements with tag C{tag} are created in the model"
" (optional).\n"
)
.def(
"createTriMesh",
&LsmMpiPy::createTriMesh,
(
arg("meshName"),
arg("nodeSequence"),
arg("faceSequence")
),
"Creates a 3D triangulated surface mesh within the model.\n"
"@type meshName: string\n"
"@kwarg meshName: Name assigned to the created mesh.\n"
"@type nodeSequence: indexable\n"
"@kwarg nodeSequence: Indexable sequence of node data, each element is"
" a tuple C{(nodeId,coordinate,optionalNodeTag)}.\n"
"@type faceSequence: indexable\n"
"@kwarg faceSequence: Indexable sequence of triangle data, each"
" element is a tuple"
" C{(faceId,(nodeId0,nodeId1,nodeId2),optionalFaceTag)}.\n"
)
.def(
"readMesh2D",
&LsmMpiPy::readMesh2D,
(
arg("fileName"),
arg("meshName"),
arg("tag")
),
"Creates a 2D I{linear} surface mesh within the model which"
" is loaded from file.\n"
"@type fileName: string\n"
"@kwarg fileName: Name of file from which surface-mesh is read.\n"
"@type meshName: string\n"
"@kwarg meshName: Name assigned to the created mesh.\n"
"@type tag: int\n"
"@kwarg tag: Only elements with tag C{tag} are created in the model."
)
.def(
"moveSingleMeshNodeBy",
&LsmMpiPy::moveSingleMeshNodeBy,
(
arg("meshName"),
arg("nodeId"),
arg("delta")
),
"Moves an individual mesh node/vertex.\n"
"@type meshName: string\n"
"@kwarg meshName: Name which identifies an existing mesh.\n"
"@type nodeId: int\n"
"@kwarg nodeId: The identifier of the node which is to be moved.\n"
"@type delta: L{Vec3<esys.lsm.util.FoundationPy>}\n"
"@kwarg delta: The node is moved by this amount.\n"
)
.def(
"translateMeshBy",
&LsmMpiPy::translateMesh,
(
arg("meshName"),
arg("translation")
),
"Rigidly translates a whole mesh \n"
"@type meshName: string\n"
"@kwarg meshName: Name which identifies an existing mesh.\n"
"@type translation: L{Vec3<esys.lsm.util.FoundationPy>}\n"
"@kwarg translation: The mesh is translated by this vector.\n"
).def(
"setWallNormal",
&LsmMpiPy::setWallNormal,
(
arg("wallName"),
arg("norm")
),
"Sets a wall Normal to the supplied vector.\n"
"@type wallName: str\n"
"@kwarg wallName: Name of the wall whose normal is to be changed.\n"
"@type d: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg d: The new normal vector of the wall."
)
.def(
"setSpatialDomain",
&LsmMpiPy::setSpatialDomain,
(
arg("minPt"),
arg("maxPt")
)
)
.def(
"setSpatialDomain",
&LsmMpiPy::setBBoxSpatialDomain,
(arg("bBox"))
)
.def(
"setSpatialDomain",
&LsmMpiPy::setBBoxSpatialDomainWithCirc,
(
arg("bBox"),
arg("circDimList")
),
"Defines the rectangular particle domain for this model.\n"
"@type bBox: L{BoundingBox<esys.lsm.util.FoundationPy.BoundingBox>}\n"
"@kwarg bBox: Defines rectangular domain.\n"
"@type circDimList: list of 3 bool\n"
"@kwarg circDimList: List of 3 boolean elements indicating in which"
" dimension the circular boundary occurs. For example,"
" C{[True,False,False]} indicates a circular boundary at the"
" M{x=}C{bBox.getMinPt()[0]} and M{x=}bBox.getMaxPt()[0]"
" planes of the rectangular domain specified by C{bBox}.\n"
)
.def(
"findClosestParticle",
&LsmMpiPy::findClosestParticle,
(arg("pt")),
"Returns the Id of the particle closest to a specified point.\n"
"@type posn: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg posn: Finds particle closest to this point.\n"
"@rtype: int\n"
"@return: Id of particle closest to C{posn}."
)
.def(
"getParticlePosn",
&LsmMpiPy::getParticlePosn,
(arg("id")),
"Returns the location of a particle with a specified Id.\n"
"@type id: int\n"
"@kwarg id: Particle Id.\n"
"@rtype: L{Vec3<esys.lsm.util.FoundationPy>}\n"
"@return: Position of particle."
)
.def(
"moveParticleTo",
&LsmMpiPy::moveSingleParticleTo,
(
arg("id"),
arg("posn")
),
"Sets the absolute position of a particle.\n"
"@type id: int\n"
"@kwarg id: Id of the particle to be moved.\n"
"@type posn: L{Vec3<esys.lsm.util.FoundationPy>}\n"
"@kwarg posn: New position of particle."
)
.def(
"moveTaggedParticlesBy",
&LsmMpiPy::moveTaggedParticlesBy,
(
arg("tag"),
arg("displacement")
),
"Translates the position of a particle by a specified displacment.\n"
"@type tag: int\n"
"@kwarg tag: Tag of all particles which are to be moved.\n"
"@type displacement: L{Vec3<esys.lsm.util.FoundationPy>}\n"
"@kwarg displacement: Amount by which particle positions are translated."
)
.def(
"moveWallBy",
&LsmMpiPy::moveWallBy,
(
arg("wallName"),
arg("d")
),
"Moves a model wall by a specified displacement.\n"
"@type wallName: str\n"
"@kwarg wallName: Name of the wall which is to be moved.\n"
"@type d: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg d: The displacement vector, the wall is displaced"
" by this amount.\n"
)
.def(
"applyForceToWall",
&LsmMpiPy::applyForceToWall,
(
arg("interactionName"),
arg("force")
),
"A wall is displaced in the normal direction so that the total"
" force applied to the wall attains a specified value.\n"
"@type interactionName: str\n"
"@kwarg interactionName: Name of the interaction group governing"
" interactions between the wall and particles.\n"
"@type force: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg force: Wall is displaced in the direction of the normal,"
" so that net wall force is C{force.n}."
)
.def(
"setParticleVelocity",
&LsmMpiPy::setParticleVel,
(
arg("id"),
arg("Velocity")
),
"Set the velocity of a particle \n"
"@type id: int\n"
"@kwarg id: the ID of the particle \n"
"@type Velocity: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg Velocity: The velocity of the particle.\n"
)
.def(
"setParticleAngularVelocity",
&LsmMpiPy::setParticleAngVel,
(
arg("id"),
arg("angularVelocity")
),
"Set the angular velocity of a rotational particle \n"
"@type id: int\n"
"@kwarg id: the ID of the particle \n"
"@type angularVelocity: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg angularVelocity: The angular velocity of the particle.\n"
)
.def(
"setParticleDensity",
&LsmMpiPy::setParticleDensity,
(
arg("tag"),
arg("mask"),
arg("Density")
),
"Set the density of a group of tagged particles \n"
"@type tag: int\n"
"@kwarg tag: the tag of the particles \n"
"@type mask: int\n"
"@kwarg mask: the tag mask \n"
"@type Density: float\n"
"@kwarg Density: The density of the particle.\n"
)
.def(
"setTaggedParticleVelocity",
&LsmMpiPy::setTaggedParticleVel,
(
arg("tag"),
arg("Velocity")
),
"Set the velocity of a group of tagged particles \n"
"@type tag: int\n"
"@kwarg tag: the tag of the particles \n"
"@type Velocity: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg Velocity: The velocity of the particle.\n"
)
.def(
"setVelocityOfWall",
&LsmMpiPy::setVelocityOfWall,
(arg("name"),arg("velocity")),
"Set the velocity of a wall with viscous drag. This does not"
" influence the position of the wall, only the viscous drag"
" applied to particles interacting with the wall. Therefore"
" it is meaningless for walls without viscous drag.\n"
"@type name: str\n"
"@kwarg name: the name of the wall\n"
"@type velocity: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
"@kwarg velocity: The velocity of the wall.\n"
)
.def(
"tagParticleNearestTo",
&LsmMpiPy::tagParticleNearestTo,
(arg("tag"),arg("mask"),arg("Position"))
)
.def(
"setParticleNonDynamic",
&LsmMpiPy::setParticleNonDynamic,
(arg("tag")),
"Make the particle non-dynamic, i.e. the particle still interacts \n"
"with other particles the usual way but doesn't move in response to \n"
"forces applied to it. Useful if the particle is moved in order to \n"
"create a deformation source.\n"
"@type tag: int\n"
"@kwarg tag: the tag of the particle.\n"
)
.def(
"setParticleNonRotational",
&LsmMpiPy::setParticleNonRot,
(arg("tag")),
"Set the particle with tag C{tag} to be non-rotational,"
" i.e. it still participates in \n"
"rotational (RotFriction, RotBonded, etc) interactions but doesn't"
" rotate in response to applied torque. Only applicable if the"
" particle type is rotational.\n"
"@type tag: int\n"
"@kwarg tag: the tag of the particle."
)
.def(
"addPreTimeStepRunnable",
&LsmMpiPy::addPreTimeStepRunnable,
(arg("runnable")),
"Adds a L{Runnable} object to the list of runnables. The L{Runnable.run}\n"
"method is called before the execution of a time-step. This method can be\n"
"used to introduce a loading mechanism (apply force to walls,"
" move walls, etc).\n"
"@type runnable: L{Runnable<esys.lsm.LsmPy.Runnable>}\n"
"@kwarg runnable: An object which has a C{run} method which takes"
" no arguments.\n"
)
.def(
"addPostTimeStepRunnable",
&LsmMpiPy::addPostTimeStepRunnable,
(arg("runnable")),
"Like the L{addPreTimeStepRunnable} method, except the C{run} method"
" of C{runnable} gets called at the end of a time-step.\n"
"@type runnable: L{Runnable<esys.lsm.LsmPy.Runnable>}\n"
"@kwarg runnable: An object which has a C{run} method which takes"
" no arguments.\n"
)
.def(
"createFieldSaver",
&LsmMpiPy::createParticleScalarFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createParticleVectorFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createInteractionScalarFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createCheckedInteractionScalarFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createInteractionVectorFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createCheckedInteractionVectorFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createTaggedParticleScalarFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createTaggedParticleVectorFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createTaggedInteractionScalarFieldSaver,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createParticleVectorFieldSaverWithTrigger,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::createTaggedParticleVectorFieldSaverWithTrigger,
(arg("prms"))
)
.def(
"createFieldSaver",
&LsmMpiPy::addVectorWallField,
(arg("prms")),
"Causes specified data to be saved periodically to file.\n"
"@type prms: L{FieldSaverPrms}\n"
"@kwarg prms: An object specifing where, when and what data are"
" to be saved.\n"
)
#if 0
.def(
"addTaggedScalarParticleDistributionSaver",
&LsmMpiPy::addTaggedScalarParticleDistributionSaver
)
.def("addVectorTriangleSaveField", &LsmMpiPy::addVectorTriangleSaveField)
.def("addScalarTriangleSaveField", &LsmMpiPy::addScalarTriangleSaveField)
#endif
.def(
"force2dComputations",
&LsmMpiPy::force2dComputations,
"Ensures particles only move in the M{x-y} plane and that"
" rotations only occur about the M{z}-axis.\n"
)
.def(
"runTimeStep",
&LsmMpiPy::runTimeStep,
"Runs a single step of the time-integration method."
)
.def(
"run",
&LsmMpiPy::run,
"Runs multiple steps of the time-integration method."
)
.def(
"exit",
&LsmMpiPy::exit,
"Exits the simulation after running a series of single"
"steps of the time-integration method."
)
.def(
"visitNodeRefs2d",
&LsmMpiPy::visitNodeRefs2d,
(
arg("meshName"),
arg("nodeRefVisitor")
),
"Method for visiting mesh node Id's.\n"
"@type meshName: string\n"
"@kwarg meshName: name of the mesh whose nodes will be visited.\n"
"@type nodeRefVisitor: L{object}\n"
"@kwarg nodeRefVisitor: object which has a method named"
"C{visitNodeRef} which takes a single integer argument.\n"
)
.def(
"visitRefStressPairs2d",
&LsmMpiPy::visitRefStressPairs2d,
(
arg("meshName"),
arg("refStressVisitor")
),
"Method for visiting mesh C{(element-Id, stress)} pairs.\n"
"@type meshName: string\n"
"@kwarg meshName: name of the mesh whose elements will be visited.\n"
"@type refStressVisitor: L{object}\n"
"@kwarg refStressVisitor: object which has a method named"
"C{visitRefStressPair} which two arguments, an integer element-id"
" argument and a L{Vec3<esys.lsm.util.FoundationPy>} stress"
" argument.\n"
)
.def(
"visitParticlesWithId",
&LsmMpiPy::visitParticlesWithId,
(
arg("idList"),
arg("particleVisitor")
),
"Method for visiting particle data.\n"
"@type idList: list\n"
"@kwarg idList: List of particle-id values specifying which particles"
" are to be visited.\n"
"@type particleVisitor: L{object}\n"
"@kwarg particleVisitor: object which has a method named"
"C{visitParticle} which accepts a single particle argument."
)
.def(
"getParticleList",
&LsmMpiPy::getParticleList
)
.def(
"getParticleList",
&LsmMpiPy::getParticleWithIdList,
(
arg("idList")
),
"Returns a I{copy} of particles with specified id's. If the C{idList}"
" argument is not specified (or is empty) then all particles are"
" returned in the list.\n"
"@type idList: list\n"
"@kwarg idList: Optional list of particle-id values specifying which"
" particles are to be returned.\n"
"@rtype: list\n"
"@return: Python C{list} containing particles with specified id."
" If C{idList} is empty, then all particles are returned in the list.\n"
)
.def(
"getLsmVersion",
&LsmMpiPy::getLsmVersion,
"Returns " PACKAGE_NAME " version string.\n"
"@rtype: string\n"
"@return: " PACKAGE_NAME " version."
)
.def(
"setVerbosity",
&LsmMpiPy::setVerbosityPy,
"set verbosity for Master & Workers"
)
;
}
}
}
|