/usr/share/elmerfront/tcl/ecif_tk_procsMenuExec.tcl is in elmer-common 6.1.0.svn.5396.dfsg2-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 | #/*****************************************************************************/
# *
# * Elmer, A Finite Element Software for Multiphysical Problems
# *
# * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
# *
# * This program is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License
# * as published by the Free Software Foundation; either version 2
# * of the License, or (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program (in file fem/GPL-2); if not, write to the
# * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# * Boston, MA 02110-1301, USA.
# *
# *****************************************************************************/
#***********************************************************************
#Program: ELMER Front
#Module: ecif_tk_procsMenuExec.tcl
#Language: Tcl
#Date: 16.11.98
#Version: 1.00
#Author(s): Martti Verho
#Revisions:
#
#Abstract: Menu handling procedures
#
#************************************************************************
#####################################################################
#
# Initialization procs
#
#####################################################################
# Apply user setting for directories and
# auto OPEN model file if model-name was given!!!
#
proc MenuExec::applySettings {} {
global Info Model ModelProperty UserSetting
# Copy possible command line values
foreach vn {MODEL_DIRECTORY MODEL_NAME PROBLEM_NAME} {
if { $Info($vn) != "" } {
set ModelProperty($vn) $Info($vn)
set Info($vn) ""
}
}
#--Set working directory
if { $Info(workingDirectory) == "" } {
set Info(workingDirectory) [MenuExec::getCurrentDirectory]
}
#--Set other default directoies
#
if { $Model(CAD_OPEN_DIR) == "" } {
set Model(CAD_OPEN_DIR) $Info(workingDirectory)
}
if { $Model(MESH_OPEN_DIR) == "" } {
set Model(MESH_OPEN_DIR) $Info(workingDirectory)
}
if { $Model(EMF_OPEN_DIR) == "" } {
set Model(EMF_OPEN_DIR) $Info(workingDirectory)
}
# Model directory
# ===============
set rc [ModelProperty::setDefaultDirectoryValue MODEL_DIRECTORY]
# If not ok
if { $rc != 1 } {
# If invalid value
if { $rc == -1 } {
set dir $UserSetting(DEFAULT_MODEL_DIRECTORY)
Message::showMessage "NOTE: Invalid model directory value: $dir"
}
# Put current directory as default
ModelProperty::setDefaultDirectoryValue MODEL_DIRECTORY $Info(workingDirectory)
}
ModelProperty::applyModelDirectoryValue
# Include path
# ============
set dir $UserSetting(DEFAULT_INCLUDE_PATH)
if { $dir != "" } {
set rc [ModelProperty::setDefaultDirectoryValue INCLUDE_PATH $dir]
}
# Log directory
# =============
set dir $Info(defaultLogDirectoryName)
if { $dir != "" } {
set rc [ModelProperty::setDefaultDirectoryValue LOG_DIRECTORY $dir]
}
# Results directory
# =================
set dir $UserSetting(DEFAULT_RESULTS_DIRECTORY)
if { $dir != "" } {
set rc [ModelProperty::setDefaultDirectoryValue RESULTS_DIRECTORY $dir]
}
# Cad files directory
# ===================
set dir $UserSetting(DEFAULT_CAD_FILES_DIRECTORY)
if { $Model(CAD_OPEN_DIR) == "" && $dir != "" && [file isdirectory $dir] } {
set Model(CAD_OPEN_DIR) $dir
}
# Mesh files directory
# ====================
set dir $UserSetting(DEFAULT_EXTERNAL_MESH_FILES_DIRECTORY)
if { $dir != "" && [file isdirectory $dir] } {
if { $Model(MESH_OPEN_DIR) == "" } {
set Model(MESH_OPEN_DIR) $dir
}
if { $Model(MESH_SAVE_DIR) == "" } {
set Model(MESH_SAVE_DIR) $dir
}
}
# Font sizes
# ==========
# Target widgets in order: Entry, Table Entry, and Message Area
#
if { $UserSetting(FONT_SIZES) != "" } {
foreach sz $UserSetting(FONT_SIZES) \
trg {fontSizeEntry fontSizeTable fontSizeMsg} {
if { $sz == "" || $trg == "" } {
break
}
set Info($trg) $sz
}
}
# Other data
# ==========
#--Set and check case directories
if { $Model(CASE_NAME) != "" } {
set force 0
set show_msg 1
MenuExec::applySettingsToCaseDirectories $force $show_msg
}
set model_dir $ModelProperty(MODEL_DIRECTORY,absolute)
#--Default model open and save dirs
set Model(EMF_OPEN_DIR) $model_dir
set Model(EMF_SAVE_DIR) $model_dir
#--Open model file, if name given !!!
#--------------------------------
#
if { $ModelProperty(MODEL_NAME) != "" } {
set emf_path [file join $model_dir $ModelProperty(MODEL_NAME).emf]
if { [file exists $emf_path] } {
Message::showMessage "Opening model file: $emf_path"
#MenuExec::presetModelData
MenuExec::loadNewModel $emf_path
} else {
Message::showMessage "NOTE: cannot open model file: $emf_path"
}
}
} ;# End applySettings
proc MenuExec::checkUserLevel {} {
global Info
set Info(userLevel,prev) $Info(userLevel)
if { $Info(userLevel,new) == 0 } {
set Info(userLevel) $Info(userLevel,prev)
} else {
set Info(userLevel) $Info(userLevel,new)
}
MenuBuild::applyUserLevel
UserSetting::applyUserLevel
}
# Reset model data before loading
# a new model
#
proc MenuExec::presetModelData {} {
global Common Coordinate Info Model ModelProperty ObjectTable
global Solver Equation
set Model(CASE_NAME) ""
set Model(GEOMETRY_DIMENSION) ""
set Model(SIMULATION_DIMENSION) ""
set Coordinate(COORDINATE_MAPPING) {1 2 3}
set Model(EMF_PATH_IN) ""
set Model(EMF_PATH) ""
set Model(EMF_FILE) ""
set Model(inModelFile) ""
set Model(cadPath) ""
set Model(sifModelIncludeFile) ""
set Model(sifSimulationIncludeFile) ""
set Model(hasMatcDefinitions) 0
set Model(meshNames) ""
set Model(nofActiveMeshes) 0
set Model(activeMeshIndices) ""
set Model(activeMeshNames) ""
set Model(meshBgMeshFiles) ""
set Model(meshBgMeshActives) ""
set Model(meshBgMeshControls) ""
set Model(currentMeshBgMeshFile) ""
set Model(currentMeshBgMeshControlFile) ""
MenuExec::resetObjectTable
# Reset panel arries
# NOTE: Skip UserSetting!
# =======================
# (Its values are kept during the whole session!)
foreach arr $Common(allPanelArries) {
if { $arr == "UserSetting" } {
continue
}
MenuExec::resetArrayData $arr
}
# These arries need a bit special handling, because
# they do not have id-parameters!
Panel::initFields ModelProperty "" 1
Panel::initFields Variables
#Panel::initFields EquationVariable
#EquationVariable::formActiveParameter
#EquationVariable::updateAllVariableNames
set force 1
set show_msg 0
ModelProperty::initCaseDirectoryVariables
#---General model level flags
set Model(meshNames) ""
set Model(meshHs) ""
set Model(meshFs) ""
set Model(meshBgMeshFiles) ""
set Model(meshBgMeshActives) ""
set Model(meshBgMeshControls) ""
set Model(currentMeshIndex) $Info(NO_INDEX)
set Model(currentMeshName) ""
set Model(currentBgMeshFile) ""
set Model(currentBgMeshControlFile) ""
set Model(hasDiffuseGrayRadiation) 0
set Model(nofMeshZeroVelocityElements) 0
set Model(nofBodiesWithEquation) 0
set Model(Database,needsUpdate) 0
set Model(Front,needsUpdate) 0
set Model(GebhardtFactors,needsUpdate,data) 0
set Model(GebhardtFactors,needsUpdate,mesh) 0
set Model(GebhardtFactors,verifyFilename) 0
set Model(Mesh,exists) 0
set Model(Mesh,generating) 0
set Model(Mesh,edited) 0
set Model(Mesh,hasParameter) 0
set Model(Mesh,needsUpdate) 0
set Model(Mesh,added) 0
set Model(MeshFromDB,needsUpdate) 0
set Model(Results,activated) 0
set Model(Solver,inputFileExists) 0
set Model(Solver,needsUpdate) 0
set Model(Solver,askZeroVelocityElements) 1
set Model(Solver,askNonExistingMesh) 1
set Model(Viewfactors,needsUpdate,data) 0
set Model(Viewfactors,needsUpdate,mesh) 0
set Model(Viewfactors,verifyFilename) 0
set Model(removedFieldsList) ""
set Equation(totalMask) ""
set Equation(problemMask) ""
set Equation(activeIndices) ""
set Equation(updateValuesArea) 0
Equation::initMasks
MenuExec::resetModelFlags
MenuExec::initStatusFields
#-Apply user setting values
MenuExec::applySettings
#-Read possible color tables (via cpp)
MenuExec::readColorFile "front"
MenuExec::readColorFile "elmer"
MenuExec::readColorFile "user"
MenuExec::readColorFile "model"
#-Read possible matc variable definitions (via cpp)
MenuExec::readMatcFile "elmer"
MenuExec::readMatcFile "user"
MenuExec::readMatcFile "model"
}
proc MenuExec::resetObjectTable {} {
global ObjectTable
set ObjectTable(count) 0
if { [info exist ObjectTable(ids)] } {
Util::unsetArrayIdVariables ObjectTable $ObjectTable(ids)
unset ObjectTable(ids)
}
set ObjectTable(ids) ""
}
proc MenuExec::resetObjectTableByType {type} {
global ObjectTable
if { ![info exist ObjectTable(ids)] } {
return
}
set ids_to_keep ""
set delete_count 0
set ids_to_delete ""
foreach id $ObjectTable(ids) {
if { $ObjectTable($id,tp) == $type } {
lappend ids_to_delete $id
incr delete_count
} else {
lappend ids_to_keep $id
}
}
if { $delete_count > 0 } {
Util::unsetArrayIdVariables ObjectTable $ids_to_delete
}
set ObjectTable(ids) $ids_to_keep
}
proc MenuExec::resetArrayData { arr } {
upvar #0 $arr theArr
set theArr(panelSizeKnown) 0
#Panel::unsetFields $arr
Panel::unsetAllFieldData $arr
if { [info exist theArr(ids)] } {
Util::unsetArrayIdVariables $arr $theArr(ids)
unset theArr(ids)
}
if { [info exist theArr(ids,old)] } {
unset theArr(ids,old)
}
Util::unsetArrayVariables $arr objectIndex
Util::unsetArrayVariables $arr boundaryIndex
Util::unsetArrayVariables $arr parameterIndex
}
#
proc MenuExec::resetUpdateFlags {} {
global Model
set Model(Front,needsUpdate) 0
set Model(Database,needsUpdate) 0
set Model(GebhardtFactors,needsUpdate,data) 0
set Model(GebhardtFactors,needsUpdate,mesh) 0
set Model(Viewfactors,needsUpdate,data) 0
set Model(Viewfactors,needsUpdate,mesh) 0
}
# Update model data after loading
# a new model
#
proc MenuExec::updateModelData {} {
global Model
#MenuExec::resetUpdateFlags
Solver::updateActiveMeshInfo
set check_factors 0
BoundaryCondition::updateModelStatus $check_factors
Interface::setStatusMeshes
}
# Set status fields to initial values
#
proc MenuExec::initStatusFields {} {
global Status
set Status(equations) "None"
set Status(timesteps) "None"
set Status(materials) "None"
set Status(initialConditions) "None"
set Status(bodyForces) "None"
set Status(innerBoundaryConditions) "None"
set Status(outerBoundaryConditions) "None"
set Status(meshes) "None"
}
# =========================
# EQUATION DEFINITONS STUFF
# =========================
# Load user defined equations definition file
proc MenuExec::loadDefinitionFile {} {
global Common Model
set types {
{ {All} {*} }
{ {Txt} {.txt} }
{ {Elmer def file} {.edf .Edf .EDF} }
}
set title "Load Definition File"
# Use the latest directory
set dir $Model(inDefinitionFileDir)
#--Display dialog and get path
set path [ MenuExec::openFile $title $types $dir ]
if {$path == ""} {
return
}
set Model(inDefinitionFile) $path
set Model(inDefinitionFileDir) [file dirname $path]
# NOTE: We do not read default def files or reset model data here!!!
set read_default_def_file 0
set read_in_def_file 1
set preset_model_data 0
FRONT_POST_INIT $read_default_def_file $read_in_def_file $preset_model_data
# Mark panel size unknown (possible new fields!)
#
foreach arr $Common(allPanelArries) {
upvar #0 $arr theArr
set theArr(panelSizeKnown) 0
}
}
# Load user defined equations definition file
proc MenuExec::saveDefinitionFileAs {} {
global Model
set types {
{ {Elmer def file} {.edf .Edf .EDF} }
{ {Txt} {.txt} }
{ {All} {*} }
}
set title "Save Definition File"
set default_path $Model(outDefinitionFile)
#--Display dialog and get saved path
set path [MenuExec::saveFile $title $types $default_path]
if {$path == ""} {
return
}
set append 0
MenuExec::saveDefinitionFile $path $append
}
# Saves current definitions in a file
#
proc MenuExec::saveDefinitionFile {path {append 0}} {
global Model
if { $path == "" } {
return 0
}
if { $Model(allDefinitions) == "" } {
return 0
}
set msg ""
if { $append } {
set mode "a+"
} else {
set mode "w"
}
if { [catch {set def_ch [open $path $mode]} msg] } {
set msg [string map {"\"" " "} $msg]
Message::showMessage "NOTE: cannot save definition file: $msg"
return 0
}
foreach line $Model(allDefinitions) {
puts $def_ch $line
}
close $def_ch
return 1
}
# Clear current definitions
#
proc MenuExec::clearCurrentDefinitions { {verify 1}} {
global Info Model
set msg [list \
"This command removes all definitions loaded by the user!\n\n" \
"\nPress OK to remove definitions, otherwise press Cancel" \
]
if { $verify &&
![Message::verifyAction $Info(powerUser) $msg]
} {
return
}
set Model(hasUserDefinitions) 0
set Model(inDefinitionFile) ""
set Model(allDefinitions) ""
FRONT_SET_INITIAL_GENERIC_FIELD_PROPERTIES
FRONT_SET_INITIAL_PANEL_FIELD_PROPERTIES
# NOTE: We do not reset model data or read any new def file here!!!
set read_default_def_file 0
set read_in_def_file 0
set preset_model_data 0
FRONT_POST_INIT $read_default_def_file $read_in_def_file $preset_model_data
}
#####################################################################
#
# CHECKING procs
#
#####################################################################
# Procedure checks what to do when
# model file is not saved
#
proc MenuExec::askModelOk {process_name {automatic_save 0} } {
global Info Model
if { $Model(Front,needsUpdate) == 0 } {
return "ok"
}
if {$automatic_save} {
set rc [saveModelFile]
return $rc
}
set msg [list "Model file is not saved!\n\n" \
$Info(anywayOk) ]
set Info(messageIcon) warning
set result [ Message::dispOkCancelMessage $msg ]
return $result
}
# Procedure checks what to do when mesh is missing when
# sif file is saved
#
proc MenuExec::askSolverOk { {path ""}} {
global Model Info
if { $Model(Mesh,exists) ||
$Model(Mesh,generating) ||
!$Model(Solver,askNonExistingMesh)
} {
return "ok"
}
# A warning of a non-existing mesh!
#
if { $path != "" } {
set msg [list "Saving solver input file as:\n\n" \
"$path \n\n" \
"NOTE: Elmer mesh for the model does not exist\n" \
"and the problem cannot be possibly solved!\n\n" ]
} else {
set msg [list "NOTE: Elmer mesh for the model does not exist\n" \
"and the problem cannot be possibly solved!\n\n" ]
}
set Info(messageIcon) warning
#--Solving
#
if { $Model(Solver,solving) } {
set result [ Message::dispOkCancelMessage $msg ]
# User cancelled sif-file saving
#
if { $result == "cancel" } {
set Model(Solver,solving) 0
return "cancel"
}
#--Just saving sif file
#
} else {
Message::dispOkMessage $msg
}
# If user proceeds, we will not notify about this any more
# for this model file!
#
set Model(Solver,askNonExistingMesh) 0
return "ok"
}
# Checks that Cad geometry data is ok
#
proc MenuExec::checkCadData {process_name} {
global Info Model ModelFlags
#-These processes are meaningless without
# Cad geometry
if { $process_name == $Info(Mesh2D,processName) ||
$process_name == $Info(Mesh3D,processName)
} {
if { !$ModelFlags(GEOMETRY_TYPE_CAD) } {
return "cancel"
}
}
return "ok"
}
# Check that model DB-directory is given
#
proc MenuExec::checkDBDirectory {} {
global Info ModelProperty
if { $ModelProperty(MODEL_DIRECTORY) == "" } {
set msg [list "Model directory not defined!\n" \
"Use command: Save model file as... in File menu!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
return "ok"
}
# Check that model DB-name is given
#
proc MenuExec::checkDBName { {name_needed 1} } {
global ModelProperty Info
if {$ModelProperty(MODEL_NAME) == ""} {
#-Model must have name
if { $name_needed } {
set msg [list "NOTE: Model name is not defined, model cannot be saved!\n\n" \
$Info(setModelNameMsg) ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
#-Model name optional
} else {
set msg [list "NOTE: Model name is not defined, model cannot be saved!\n\n" \
"$Info(setModelNameMsg) \n\n" \
$Info(anywayOk) ]
set Info(messageIcon) warning
return [ Message::dispOkCancelMessage $msg ]
}
}
return "ok"
}
# Checks if GebhardtFactors should be calculated (when running the Solver)
# and that the file exists (when running theSolver) and notifies if default file
# name is used (when running the GebhardtFactors)
#
proc MenuExec::checkGebhardtFactors {process_name} {
global Equation Info Datafile Model ModelProperty
#---If not an interesting process
if { $process_name != $Info(Solver,processName) && $process_name != $Info(GebhardtFactors,processName) } {
return "ok"
}
#---Proc Solver checking
if { $process_name == $Info(Solver,processName) &&
$Model(hasDiffuseGrayRadiation)
} {
# If the user has not turned of the checking for the session
# or for this case for viewfactors check status against mesh
#
if { $Model(Viewfactors,needsUpdate,mesh) == 0 &&
$Model(GebhardtFactors,needsUpdate,mesh) != -1
} {
# Check if mesh is more recent than the GebhardtFactors file
set eidx [DataField::getFieldProperty Equation HEAT_EQUATION EquationIndex]
set dc_mh [MenuExec::getSolverMeshHeaderFile $eidx 0]
set dc_mn [MenuExec::getSolverMeshName $eidx 0]
set gf_fn [MenuExec::getMeshRelatedFile $dc_mn GEBHARDT_FACTORS]
if { $gf_fn == "" ||
[ file mtime $dc_mh] > [file mtime $gf_fn]
} {
set Model(GebhardtFactors,needsUpdate,mesh) 1
set msg [list "Gebhard factors should be updated (MESH is more recent)!\n\n" \
$Info(noMoreNotifying) ]
set Info(messageIcon) warning
set result [Message::dispCancelYesNoMessage $msg]
if { $result == "cancel" } {
return "cancel"
} elseif { $result == "yes" } {
set Model(GebhardtFactors,needsUpdate,mesh) -1
return "ok"
}
}
}
# If emissivity has been changed (checked elswhere!)
# ==============================
if { $Model(GebhardtFactors,needsUpdate,data) == 1 } {
set msg [list "Gebhard factors should be updated (EMISSIVITY has been changed)!\n\n" \
$Info(noMoreNotifying) ]
set Info(messageIcon) warning
set Info(messageIcon) warning
set result [Message::dispCancelYesNoMessage $msg]
if { $result == "cancel" } {
return "cancel"
} elseif { $result == "yes" } {
set Model(GebhardtFactors,needsUpdate,data) -1
return "ok"
}
}
}
#---Proc GebhardtFactors checking
if { $Model(GebhardtFactors,verifyFilename) } {
set msg [list "Default filename $Datafile(GEBHARDT_FACTORS)\n" \
"will be used for Gebhardt factors!\n\n" \
$Info(anywayOk) ]
if { ![Message::verifyAction $Info(advancedUser) $msg] } {
return "cancel"
} else {
set Model(GebhardtFactors,verifyFilename) 0
}
}
#-Check that output file is writable
set reserved_files ""
set path [MenuExec::getMeshRelatedFile $Model(currentMeshName) GEBHARDT_FACTORS]
if { ![Util::isWritableFile $path] } {
append reserved_files "Gebhardt factors file"
}
if { $reserved_files != "" } {
set msg [list "Cannot open the Gebhardt factors output file for writing!\n" \
"Enter a new file name in the Problem/Data files panel or wait until\n" \
"the process which is using the file, has finished!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
return "ok"
}
# Checks that mesh parameter data is ok
# for mesh generator
#
proc MenuExec::checkMeshData {process_name} {
global Info Model ModelProperty Status
if { $process_name != $Info(Mesh2D,processName) &&
$process_name != $Info(Mesh3D,processName)
} {
return "ok"
}
#---Check that mesh directory exists
if {"ok" != [Util::checkAndCreateDirectory2B \
$ModelProperty(CURRENT_MESH_DIRECTORY,absolute) \
"Elmer mesh files"]
} {
return "cancel"
}
return "ok"
}
# Check that model outfile exist
#
proc MenuExec::checkModelFile {} {
global Info Model
if {$Model(EMF_FILE) == ""} {
set msg [list "Model file not saved!\n" \
"Save model file: (File/Save model file)" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
return "ok"
}
proc MenuExec::checkProcessEnvironment {process_name_var} {
global Info Model Datafile ModelProperty UserSetting
upvar $process_name_var process_name
#---Preprocess (meshing)
if { $process_name == $Info(Mesh2D,processName) ||
$process_name == $Info(Mesh3D,processName)
} {
set Model(Mesh,generating) 1
#---Solve
} elseif { $process_name == $Info(Solver,processName) } {
set Model(Solver,solving) 1
set rc [MenuExec::askSolverOk]
if { $rc != "ok" } {
return "cancel"
}
}
#---Postprocess
#
# NOTE: Postprocessor can be started although model
# file is not available or stored!
if { $process_name == $Info(Post,processName) } {
return "ok"
}
if { $process_name == $Info(Results,processName) } {
# If no model opened, start plain Postprocessor!
#
if { ![info exists Datafile(POST_FILE)] ||
$Datafile(POST_FILE) == ""
} {
set process_name $Info(Post,processName)
return "ok"
}
if { "ok" != [MenuExec::checkPostFile $process_name] } {
return "cancel"
}
return "ok"
}
#---Check that DB-dir is available and model file exists
#
if { "ok" != [MenuExec::checkDBDirectory] } {
return "cancel"
}
if { "ok" != [MenuExec::checkDBName 1] } {
return "cancel"
}
set automatic_save 0
#---Check that model file is saved
#
if { $process_name == $Info(GebhardtFactors,processName) ||
$process_name == $Info(Mesh2D,processName) ||
$process_name == $Info(Mesh3D,processName) ||
$process_name == $Info(Solver,processName) ||
$process_name == $Info(Viewfactors,processName) } {
set automatic_save $UserSetting(AUTO_SAVE_MODEL)
} elseif {
$process_name == $Info(Emf2Db,processName) } {
set automatic_save 1
} else {
set automatic_save 0
}
if { "ok" != [ MenuExec::askModelOk $process_name $automatic_save ] } {
return "cancel"
}
#---Check that mesh data is uptodate if process needs it
#
if { "ok" != [MenuExec::checkMeshData $process_name] } {
return "cancel"
}
#---Check that solver related data is ok
#
if { "ok" != [MenuExec::checkSolverData $process_name] } {
return "cancel"
}
if { "ok" != [MenuExec::checkViewfactors $process_name] } {
return "cancel"
}
if { "ok" != [MenuExec::checkGebhardtFactors $process_name] } {
return "cancel"
}
return "ok"
}
# Checks that ElmerPost file exists
#
proc MenuExec::checkPostFile {process_name} {
global Info Model
if { $process_name != $Info(Results,processName) } {
return "ok"
}
set path [MenuExec::getMeshRelatedFile $Model(currentMeshName) POST_FILE]
if { ![file exists $path] || ![file readable $path] } {
set msg [list "Postprocessor file: $path is not available\n\n" \
$Info(continueOk) ]
if { ![Message::verifyAction $Info(noviceUser) $msg cancel] } {
return "cancel"
}
}
return "ok"
}
# Checks that data is ok for solver
#
proc MenuExec::checkSolverData {process_name} {
global Info Model ModelProperty Solver
#--Proc Solver checking
if { $process_name != $Info(Solver,processName) } {
return "ok"
}
#---Check that Mesh data exists
set model_dir $ModelProperty(MODEL_DIRECTORY,absolute)
if { ![file isdirectory $model_dir] } {
set msg [list "Directory for the model data:\n" \
"$model_dir \n" \
"does not exist, cannot continue!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
#-Check that all equations have an existing mesh
set msg_info ""
if { ![MenuExec::checkEquationMeshes msg_info] } {
set msg [list "NOTE: The following equations do not have a mesh\n" \
"in the bodies they should be calculated:\n\n" \
"$msg_info \n\n" \
"Cannot continue!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
#---Check that Model data is ok
# No equations!
if { $Model(nofBodiesWithEquation) <= 0 } {
set msg [list "No equations defined!\n" \
"Nothing to solve!\n\n"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
# If error in model (status != 0)
Util::cpp_exec checkModelStatus
if { $Model(status) != 0 } {
set msg [list "Model is not completely defined!\n" \
"$Model(statusMessage)\n" \
"Cannot possibly solve the problem!\n\n" \
$Info(anywayOk) ]
if { ![Message::verifyAction $Info(noviceUser) $msg] } {
return "cancel"
}
}
#-Check that solver-output files are writable
set reserved_files ""
foreach sid $Solver(activeIds) {
set ename [DataField::getFieldValue Solver $sid EQUATION]
set path [MenuExec::getSolverResultFile $sid OUTPUT_FILE]
if { ![Util::isWritableFile $path] } {
append reserved_files "Result file for: $ename "
break
}
set path [MenuExec::getSolverResultFile $sid POST_FILE]
if { ![Util::isWritableFile $path] } {
append reserved_files "Postprocessor file for: $ename "
break
}
}
# If even one of the files is reserved, recommend stop!
#
if { $reserved_files != "" } {
set msg [list "The following Solver output file(s) could be unavailable for writing:\n\n" \
"$reserved_files\n\n" \
"Enter a new file name in the Problem/Data files panel or wait until\n" \
"the process which is using the files, has finished!" \
$Info(anywayOk) ]
if { ![Message::verifyAction $Info(powerUser) $msg] } {
return "cancel"
}
}
# Check zero-velocity elements
# ----------------------------
Util::cpp_exec checkMeshCornerElements
if { $Model(Solver,askZeroVelocityElements) &&
$Model(nofMeshZeroVelocityElements) > 0
} {
set msg [list "Mesh contains zero-velocity element(s).\nThis may create singularity problems in Solver!\n\n" \
"Press YES to correct the mesh by splitting the elements\n\n" \
"Press NO to continue without correcting the mesh"]
set Info(messageIcon) warning
set result [Message::dispCancelYesNoMessage $msg]
if { $result == "cancel" } {
return "cancel"
}
if { $result == "yes" } {
# Correct zero-velocity elements
# ----------------------------
Util::cpp_exec correctMeshZeroVelocityElements
# Save modified mesh
# ------------------
set Model(Mesh,edited) 1
MenuExec::saveModelFile
}
}
#Finally, all ok?!
return "ok"
}
# Check if a body is exlcuded from the given mesh
#
proc MenuExec::bodyExcludedFromMesh { id mesh_index } {
global ObjectTable
if { [info exists ObjectTable($id,tp)] ||
$ObjectTable($id,tp) != "B"
} {
return 0
}
# If some of the body layers are in the mesh, then the body itself
# is in the mesh!
#
foreach lr_id $ObjectTable($id,lrIds) {
if { -1 == [lsearch $ObjectTable($lr_id,excldMshIndcs) $mesh_index] } {
return 0
}
}
return 1
}
proc MenuExec::checkEquationMeshes { {msg_var ""} } {
global Equation Info ObjectTable
if { $msg_var != "" } {
upvar $msg_var msg
}
set msg ""
foreach id $ObjectTable(ids) {
# If not a body object, or the body does not have an equation
#
if { ![info exists ObjectTable($id,eq)] ||
$ObjectTable($id,eq) == $Info(NO_INDEX)
} {
continue
}
set eq_id $ObjectTable($id,eq)
set sids [Solver::findSolverIdsForEquation $eq_id]
if { $sids == "" } {
continue
}
foreach sid $sids {
set mesh_index [Solver::getMeshIndex $sid]
if { [MenuExec::bodyExcludedFromMesh $id $mesh_index] } {
append mrow "Equation: "
set eq_nm [DataField::getFieldValue Solver $sid EQUATION]
append mrow [string map {"_" " "} $eq_nm]
append mrow " "
set mrow "Body: "
append mrow $ObjectTable($id,nm)
append msg $mrow
append msg "\n"
}
} ;# Each solver for equation
} ; # Each object
if { $msg != "" } {
return 0
} else {
return 1
}
}
#-Check that Solver input files exists
# in the model directory
#
proc MenuExec::checkSolverInputFile {} {
global Datafile Model
set Model(Solver,inputFileExists) 0
if { [file exists $Datafile(SOLVER_INPUT_FILE)] } {
set Model(Solver,inputFileExists) 1
}
}
# Checks if Viewfactors should be calculated (when running the Solver)
# and that the file exists (when running theSolver) and notifies if default file
# name is used (when running the Viewfactors)
#
proc MenuExec::checkViewfactors {process_name} {
global Equation Info Model ModelProperty
#print "process=$process_name"
#---If not an interesting process
if { $process_name != $Info(Solver,processName) &&
$process_name != $Info(Viewfactors,processName) } {
return "ok"
}
#---Proc Solver checking
if { $process_name == $Info(Solver,processName) &&
$Model(hasDiffuseGrayRadiation)
} {
# Check if mesh is more recent than the Viewfactors file
# ======================================================
# Check only if the checking is not turned of by the user
if { $Model(Viewfactors,needsUpdate,mesh) != -1 } {
set eidx [DataField::getFieldProperty Equation HEAT_EQUATION EquationIndex]
set dc_mh [MenuExec::getSolverMeshHeaderFile $eidx 0]
set dc_mn [MenuExec::getSolverMeshName $eidx 0]
set vf_fn [MenuExec::getMeshRelatedFile $dc_mn VIEW_FACTORS]
if { $vf_fn == "" ||
[ file mtime $dc_mh] > [file mtime $vf_fn ]
} {
set Model(Viewfactors,needsUpdate,mesh) 1
set msg [list "Viewfactors should be updated (MESH is more recent)!\n\n" \
$Info(noMoreNotifying) ]
set Info(messageIcon) warning
set result [Message::dispCancelYesNoMessage $msg]
if { $result == "cancel" } {
return "cancel"
} elseif { $result == "yes" } {
set Model(Viewfactors,needsUpdate,mesh) -1
return "ok"
}
}
}
}
#---Proc Viewfactors checking
#-Check that output file is writable
set reserved_files ""
set path [MenuExec::getMeshRelatedFile $Model(currentMeshName) VIEW_FACTORS]
if { ![Util::isWritableFile $path] } {
append reserved_files "View factors file "
}
if { $reserved_files != "" } {
set msg [list "Cannot open the View factors output file for writing!\n" \
"Enter a new file name in the Problem/Data files panel or wait until\n" \
"the process which is using the file, has finished!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
return "ok"
}
# Proc check if radiation boundary condition is applied
# This is needed when allowing linearization button for
# HEAT-system solver
#
proc MenuExec::updateRadiationStatus {} {
global Info BoundaryCondition ObjectTable
if { ![info exists BoundaryCondition(ids)] } {
return
}
#-Extra fill characters around separators (normally spaces )
set disp_sep $Info(dispListSeparatorIn)
set extra1 $Info(dispListSeparatorExtra1)
set extra2 $Info(dispListSeparatorExtra2)
set appliedParamIds ""
foreach id $ObjectTable(ids) {
if { ![info exist ObjectTable($id,bc)] } {
continue
}
set pid $ObjectTable($id,bc)
if { $pid == $Info(NO_INDEX) } {
continue
}
if { -1 == [lsearch $appliedParamIds $pid ] } {
lappend appliedParamIds $pid
}
}
foreach pid $BoundaryCondition(ids) {
if { -1 == [lsearch $appliedParamIds $pid] } {
continue
}
set param $BoundaryCondition($pid,data)
# Form values list. Pick first var-type
# indicator (like (Sc)) from value and collect them into a list
# which is used for the current parameter.
set tmp [split $param $disp_sep]
set values_list ""
foreach val $tmp {
set size [DataField::extractFieldSize cleaned_result $val]
lappend values_list $cleaned_result
}
set variable_id "RADIATION"
#--Find radiation field value
set index [lsearch -regexp $values_list ^$extra1$variable_id]
#-Field not found
if {$index == -1} {
continue
}
set data [lindex $values_list $index]
#-Variable-id (like TEMP=) is trimmed away.
regsub $extra1$variable_id $data {} rest
#-Trim fill-character(s) extra1 before value-type indicator
set rest [string trimleft $rest $extra1]
#-Is value a procedure name?
set is_proc 0
if {$Info(procFlag) == [string range $rest 0 1]} {
set is_proc 1
}
set rest [string trimleft $rest $Info(valueFlag)$Info(procFlag)$extra2]
set rest [string trimright $rest $extra2]
set rest [string trimright $rest $Info(groupDataSeparator)]
set value $rest
if {$value != "none"} {
set Info(hasRadiation) 1
return
}
}
set Info(hasRadiation) 0
}
# Check possible open and modified panel before
# loading a new model
proc MenuExec::checkOpenPanels {} {
global Common Info
MenuExec::closeAllWindows
# Check if some arries are still modified
#
set mod_arries ""
foreach globArr $Common(allPanelArries) {
upvar #0 $globArr theArr
if { [info exist theArr(dataChanged)] && $theArr(dataChanged) ||
[info exist theArr(dataModified)] && $theArr(dataModified)
} {
lappend mod_arries $globArr
}
}
# Some still modified!
if { $mod_arries != "" } {
set msg [list "NOTE: Data for the following panels is modified\n:" \
"$mod_arries\n" \
$Info(anywayOk)]
if { ![Message::verifyAction $Info(powerUser) $msg] } {
return 0
}
}
# Ok
return 1
}
#####################################################################
#
# FILE MENU procs
#
#####################################################################
#------------#
# OPEN procs #
#------------#
# Open Cad input file.
proc MenuExec::openCadFile {} {
global Info Model ModelFlags ModelProperty
if { "ok" != [MenuExec::askModelOk "exit"] } {
return
}
if { ![MenuExec::checkOpenPanels] } {
return
}
# Supported Cad types and their default extensions
# -------------------------------------------------
set cad_types {"Elmer" "Iges" "Ideas"}
set rb_labels {"Elmer 2D" "Iges 2D" "Ideas 2D"}
set cad_extensions {
{ {Elmer} {.egf .Egf .EGF} }
{ {Iges} {.igs .Igs .IGS} }
{ {Ideas} {.unv .Unv .UNV} }
}
#--Build extensions list for the file browser
# Helper variable
set all_extension {{All} {*}}
#---Collect all cad extension into one list to be used for the
# Default-option
#
#-First add 'All'-option
set default_extensions [list $all_extension]
#-Then add each separate mesh-type as a separate option
foreach me $cad_extensions {
lappend default_extensions $me
}
#---Now build the final extensions-list to be used for the file browser
#
set extensions ""
#-We have to add 'All' option for each separate cad-type
foreach me $cad_extensions {
lappend extensions [list $me $all_extension]
}
#--Display FileOpen dialog and get the path
#
global cad_path_ cad_type_index_
set cad_path_ ""
set cad_type_index_ ""
incr Info(fileSelectPanelId)
set wname ".w$Info(fileSelectPanelId)"
set hdr "Select Cad file type"
set wtitle "Open Cad File"
set path $Model(cadPath)
set dir $Model(CAD_OPEN_DIR)
set idx $Model(cadFileType)
Widget::dispFileSelectPanel $wname $wtitle $hdr cad_path_ cad_type_index_ $rb_labels $extensions 0 $dir $path $idx
tkwait variable cad_path_
set cad_path $cad_path_
set cad_type [lindex $cad_types $cad_type_index_]
#--Nothing selected or cancelled
#
if {$cad_path == "" || $cad_path == "!cancel!" } {
return
}
MenuExec::presetModelData
set Model(cadPath) $cad_path
set Model(CAD_OPEN_DIR) [file dirname $cad_path]
set Model(cadFileType) $cad_type_index_
Util::cpp_exec openCadFile "\"$cad_path\" \"$cad_type\""
#-Example of a direct call when using a slave interpreter
#set Info(arguments) $cad_path
#cpp_openCadFile
if { $Model(GEOMETRY_DIMENSION) != "" } {
ModelProperty::openPanel
}
}
# Open mesh file.
proc MenuExec::openMeshFile {} {
global Info MeshDefine Model ModelFlags ModelProperty
if { "ok" != [MenuExec::askModelOk "exit"] } {
return
}
if { ![MenuExec::checkOpenPanels] } {
return
}
set Model(meshOpenMode) "new_model"
# If opening mesh to an existing model which is based on an
# external mesh (ie. mesh geometry)
#
if { !$ModelFlags(GEOMETRY_TYPE_CAD) &&
$ModelProperty(MODEL_NAME) != ""
} {
# Note: Model(meshOpenMode) is updated
set win .meshOpenWin
MenuExec::openMeshDialog $win Model meshOpenMode
tkwait window $win
if { $Model(meshOpenMode) == "cancel" } {
return
}
}
# Supported mesh types and their default extensions
# -------------------------------------------------
set mesh_types {
"Abaqus2D" "Abaqus3D"
"Elmer2D" "Elmer3D"
"Fidap2D" "Fidap3D"
"Ideas2D" "Ideas3D"
}
set rb_labels {
"Abaqus 2D" "Abaqus 3D"
"Elmer 2D" "Elmer 3D"
"Fidap neutral file 2D" "Fidap neutral file 3D"
"Ideas universal file 2D" "Ideas universal file 3D"
}
set mesh_extensions {
{ {Abaqus2D} {.inp .Inp .INP} }
{ {Abaqus3D} {.inp .Inp .INP} }
{ {Elmer2D} {mesh.header Mesh.header Mesh.Header MESH.HEADER} }
{ {Elmer3D} {mesh.header Mesh.header Mesh.Header MESH.HEADER} }
{ {Fidap2D} {.fdneut .Fdneut .FDNEUT} }
{ {Fidap3D} {.fdneut .Fdneut .FDNEUT} }
{ {Ideas2D} {.unv .Unv .UNV} }
{ {Ideas3D} {.unv .Unv .UNV} }
}
if { $Info(ELMER_FRONT_THETIS_SUPPORT) } {
lappend mesh_types "Thetis2D Thetis3D"
lappend rb_labels "Thetis 2D" "Thetis 3D"
lappend mesh_extensions {{Thetis2D} {.tmf .Tmf .TMF}}
lappend mesh_extensions {{Thetis3D} {.tmf .Tmf .TMF}}
}
#--Build extensions list for the file browser
# Helper variable
set all_extension {{All} {*}}
#---Collect all mesh extension into one list to be used for the
# Default-option
#
#-First add 'All'-option
set default_extensions [list $all_extension]
#-Then add each separate mesh-type as a separate option
foreach me $mesh_extensions {
lappend default_extensions $me
}
#---Now build the final extensions-list to be used for the file browser
#
set extensions ""
#-We have to add 'All' option for each separate mesh-type
foreach me $mesh_extensions {
lappend extensions [list $me $all_extension]
}
#--Reopen current mesh (eg. a remeshed external mesh!)
if { $Model(meshOpenMode) == "update_mesh" } {
set fn [lindex [file split $Model(meshPath)] end]
set wtitle "Reload Mesh File (current is: $fn)"
set dir [file dirname $Model(meshPath)]
set path $Model(meshPath)
set idx $Model(meshFileType)
#--Read new mesh
} else {
set wtitle "Open Mesh File"
set dir $Model(MESH_OPEN_DIR)
set path $Model(meshPath)
set idx $Model(meshFileType)
}
#--Display FileOpen dialog and get the path
#
global mesh_path_ mesh_type_index_
set mesh_path_ ""
set mesh_type_index_ ""
incr Info(fileSelectPanelId)
set wname ".w$Info(fileSelectPanelId)"
set hdr "Select mesh file type"
#--Display selection widget
#
Widget::dispFileSelectPanel $wname $wtitle $hdr mesh_path_ mesh_type_index_ $rb_labels $extensions 0 $dir $path $idx
tkwait variable mesh_path_
set mesh_path $mesh_path_
set mesh_type [lindex $mesh_types $mesh_type_index_]
#--Nothing selected or cancelled
#
if {$mesh_path == "" || $mesh_path == "!cancel!" } {
return
}
set Model(nofMeshZeroVelocityElements) 0
#--For a new model, reset all data
if { $Model(meshOpenMode) == "new_model" } {
MenuExec::presetModelData
}
set directory [file dirname $mesh_path]
set filename [file tail $mesh_path]
set extension [file extension $filename]
set Model(MESH_OPEN_DIR) $directory
set Model(meshPath) $mesh_path
set Model(meshFileType) $mesh_type_index_
Panel::initFields ModelProperty
#--New model
if { $Model(meshOpenMode) == "new_model" } {
Util::cpp_exec openMeshFile "1 \"$Model(meshPath)\" \"$mesh_type\""
if { $Model(GEOMETRY_DIMENSION) != "" } {
ModelProperty::openPanel
tkwait window $ModelProperty(winName)
}
#--New mesh added or updated
} else {
Util::cpp_exec openMeshFile "0 \"$Model(meshPath)\" \"$mesh_type\""
}
#--For these we need a new mesh name
#
if { ($ModelProperty(MODEL_NAME) != "" ) &&
($Model(meshOpenMode) == "new_model" ||
$Model(meshOpenMode) == "add_mesh")
} {
set add_new_mesh 1
set rc [MeshDefine::openPanel $add_new_mesh]
tkwait window $MeshDefine(winName)
if { $rc != "cancel" } {
set Model(Mesh,added) 1
#--Set mesh name and directory
set Model(currentMeshName) $MeshDefine(MESH_NAME)
ModelProperty::setCurrentMeshDirectory
}
}
}
# OLD VERSIONS: Cad/Mesh Open
# ===========================
# Open Cad input file.
proc MenuExec::openCadFile_old {} {
global Info Model ModelFlags ModelProperty
if { "ok" != [MenuExec::askModelOk "exit"] } {
return
}
if { ![MenuExec::checkOpenPanels] } {
return
}
set types {
{ {All} {*} }
{ {Elmer} {.egf .Egf .EGF} }
{ {Iges} {.igs .Igs .IGS} }
{ {Ideas} {.unv .Unv .UNV} }
}
set title "Open Cad File"
#--Display dialog and get path
set path [ MenuExec::openFile $title $types $Model(CAD_OPEN_DIR) ]
if {$path == ""} {
return
}
MenuExec::presetModelData
set Model(cadPath) $path
set Model(CAD_OPEN_DIR) [file dirname $path]
Util::cpp_exec openCadFile $Model(cadPath)
#-Example of a direct call when using a slave interpreter
#set Info(arguments) $path
#cpp_openCadFile
if { $Model(GEOMETRY_DIMENSION) != "" } {
ModelProperty::openPanel
}
}
# Open mesh file.
proc MenuExec::openMeshFile_old {} {
global Info MeshDefine Model ModelFlags ModelProperty
if { "ok" != [MenuExec::askModelOk "exit"] } {
return
}
if { ![MenuExec::checkOpenPanels] } {
return
}
set Model(meshOpenMode) "new_model"
# If opening mesh to an existing model which is based on an
# external mesh (ie. mesh geometry)
#
if { !$ModelFlags(GEOMETRY_TYPE_CAD) &&
$ModelProperty(MODEL_NAME) != ""
} {
# Note: Model(meshOpenMode) is updated
set win .meshOpenWin
MenuExec::openMeshDialog $win Model meshOpenMode
tkwait window $win
if { $Model(meshOpenMode) == "cancel" } {
return
}
}
set types {
{ {All} {*} }
{ {Abaqus} {.inp .Inp .INP} }
{ {Elmer} {mesh.header Mesh.header Mesh.Header} }
{ {Fidap} {.fdneut .Fdneut .FDNEUT} }
{ {Ideas} {.unv .Unv .UNV} }
}
if { $Info(ELMER_FRONT_THETIS_SUPPORT) } {
lappend types { {Thetis} {.tmf .Tmf .TMF} }
}
set path ""
#--Reopen current mesh (eg. a remeshed external mesh!)
if { $Model(meshOpenMode) == "update_mesh" } {
set fn [lindex [file split $Model(meshPath)] end]
set title "Reopen Mesh File (current is: $fn)"
set dir [file dirname $Model(meshPath)]
#--Read new mesh
} else {
set title "Open Mesh File"
set dir $Model(MESH_OPEN_DIR)
}
#--Display FileOpen dialog and get the path
set path [ MenuExec::openFile $title $types $dir ]
if {$path == ""} {
return
}
set Model(nofMeshZeroVelocityElements) 0
#--For a new model, reset all data
if { $Model(meshOpenMode) == "new_model" } {
MenuExec::presetModelData
}
set directory [file dirname $path]
set filename [file tail $path]
set extension [file extension $filename]
set Model(MESH_OPEN_DIR) $directory
set Model(meshPath) $path
Panel::initFields ModelProperty
# Mesh type is selected by the extension!
#
set mesh_type ""
#--New model
if { $Model(meshOpenMode) == "new_model" } {
Util::cpp_exec openMeshFile "1 \"$Model(meshPath)\" \"$mesh_type\" "
if { $Model(GEOMETRY_DIMENSION) != "" } {
ModelProperty::openPanel
tkwait window $ModelProperty(winName)
}
#--New mesh added or updated
} else {
Util::cpp_exec openMeshFile "0 \"$Model(meshPath)\" \"$mesh_type\" "
}
#--For these we need a new mesh name
#
if { ($ModelProperty(MODEL_NAME) != "" ) &&
($Model(meshOpenMode) == "new_model" ||
$Model(meshOpenMode) == "add_mesh")
} {
set add_new_mesh 1
set rc [MeshDefine::openPanel $add_new_mesh]
tkwait window $MeshDefine(winName)
if { $rc != "cancel" } {
set Model(Mesh,added) 1
#--Set mesh name and directory
set Model(currentMeshName) $MeshDefine(MESH_NAME)
ModelProperty::setCurrentMeshDirectory
}
}
}
proc MenuExec::setRotatePriority {axis} {
global Info Model
if { $Model(GEOMETRY_DIMENSION) == "2D" &&
($axis == "X" || $axis == "Y")
} {
return
}
# Toggle current value if needed
if { $Info(currentRotateAxis) == $axis } {
set Info(currentRotateAxis) ""
} else {
set Info(currentRotateAxis) $axis
}
MenuExec::rendererSetRotatePriorities
}
# Note: updates globArray(varname) variable
#
proc MenuExec::openMeshDialog { winname arrayname varname} {
global Info Model ModelFlags
set var $arrayname
append var "($varname)"
set w $winname
toplevel $w
focus $w
wm geometry $w +500+100
wm title $w "Open mesh file"
set fpx $Info(framePadX2)
set fpy $Info(framePadY2)
#--Widgets
frame $w.fl
frame $w.fb
#-Boundaries edited, not possible to update or add new meshes!
if { $ModelFlags(GEOMETRY_EDITED_BOUNDARIES) } {
set add_state disabled
set upd_state disabled
#-Ok, new meshes accepted
} else {
set add_state normal
set upd_state normal
}
label $w.fl.l1 -text "\n\nSelect mesh open mode\n\n"
pack $w.fl.l1 -expand 1 -side top
button $w.fb.b1 -text "New model" \
-command "set $var new_model; destroy $w; return"
button $w.fb.b2 -text "Update mesh" \
-command "set $var update_mesh; destroy $w; return" \
-state $upd_state
button $w.fb.b3 -text "Add mesh" \
-command "set $var add_mesh; destroy $w; return" \
-state $add_state
button $w.fb.b4 -text "Cancel" \
-command "set $var cancel; destroy $w; return"
pack $w.fb.b1 $w.fb.b2 $w.fb.b3 $w.fb.b4 -side left -padx $fpx
focus $w.fb.b1
#--Packing
pack $w.fb $w.fl -expand 1 -side bottom -fill both -padx $fpx -pady $fpy
}
# Read model file.
#
proc MenuExec::openModelFile {} {
global Info Model ModelProperty UserSetting
if { "ok" != [MenuExec::askModelOk "exit"] } {
return
}
if { ![MenuExec::checkOpenPanels] } {
return
}
set types {
{ {Emf} {.emf .Emf .EMF} }
{ {All} {*} }
}
set title "Open Model File"
#--Display dialog and get path
set path [ MenuExec::openFile $title $types $Model(EMF_OPEN_DIR) ]
if {$path == ""} {
return
}
#--Load model file
MenuExec::presetModelData
if { ![MenuExec::loadNewModel $path] } {
return
}
MenuExec::updateModelData
# Delete possible old log files
#
set msg ""
set log_files [Util::getFileList $ModelProperty(LOG_DIRECTORY,absolute) Elmer*.log.* ]
catch {
foreach lf $log_files {
set lf [file join $ModelProperty(LOG_DIRECTORY,absolute) $lf]
file delete $lf
}
} msg
if { "" != $log_files && $msg == "" } {
Message::showMessage "NOTE: Old logfiles deleted!"
}
#--Load possible updated SOLVER.KEYWORD files
UserDefined::loadSolverKeywordsFiles
}
# Load model file (emf-file)
#
# Return: 1 <--> ok, 0 <--> error
#
proc MenuExec::loadNewModel { model_file_path } {
global Info Model ModelProperty
#-Get model file directory and path
set Model(inModelFile) $model_file_path
set ModelProperty(MODEL_DIRECTORY) [file dirname $model_file_path]
set Model(EMF_OPEN_DIR) [file dirname $model_file_path]
set Model(EMF_SAVE_DIR) [file dirname $model_file_path]
#-Apply new model directory value
ModelProperty::applyModelDirectoryValue
#-NOTE: EMF_PATH_IN/OUT, EMF_FILE are set via cpp, by calling
# Gui after the model file name is checked in cpp
Util::cpp_exec openModelFile $model_file_path
if { $Model(GEOMETRY_DIMENSION) == "" } {
return 0
}
#-Apply new problem directory values
set force_init 0
set show_msg 0
MenuExec::applySettingsToCaseDirectories $force_init $show_msg
#-Set at least initial value
set force_initial 0
Panel::initField ModelProperty MESH_NAME $force_initial
#-Store checked values into cpp-model
Util::cpp_exec modelPropertyPanelOk
return 1
}
# Read mesh into model
proc MenuExec::loadMesh { {number ""} } {
global Model ProcessTable
if { $number == "" ||
![info exists ProcessTable($number,terminated)] ||
$ProcessTable($number,terminated)
} {
Util::setFlagValue DRAW_TARGET DRAW_TARGET_BODIES 1
set Model(nofMeshZeroVelocityElements) 0
Util::cpp_exec loadMesh
} else {
after 1000 "MenuExec::loadMesh $number"
}
}
# Delete mesh from model
proc MenuExec::unloadMesh { {msg ""} } {
Util::cpp_exec unloadMesh $msg
}
proc MenuExec::monitorMesh {number} {
global ProcessTable MeshDefine Model
if { [info exists ProcessTable($number,terminated)] &&
!$ProcessTable($number,terminated)
} {
after 500 "MenuExec::monitorMesh $number"
} else {
if { [info exist MeshDefine(solveButton)] &&
[winfo exists $MeshDefine(solveButton)]
} {
$MeshDefine(solveButton) configure -state normal
}
}
}
proc MenuExec::resetModelFlags {} {
global Model
set Model(Front,needsUpdate) 0
set Model(GebhardtFactors,needsUpdate,data) 0
set Model(GebhardtFactors,needsUpdate,mesh) 0
set Model(Solver,needsUpdate) 0
set Model(Viewfactors,needsUpdate,data) 0
set Model(Viewfactors,needsUpdate,mesh) 0
}
proc MenuExec::setModelFile {} {
global Info Model
set path ""
set title "Set default name for the model file"
set label "Model file name: "
if { "ok" != [Widget::dispDataEntry path $Model(EMF_FILE) $title $label] } {
return
}
set Model(EMF_PATH_IN) $path
set Model(EMF_PATH) $path
set Model(EMF_FILE) [file tail $path]
set Model(EMF_SAVE_DIR) [file dirname $path]
}
# Copy parameters from an emf-file
#
proc MenuExec::copyParameters {} {
global Info Model UserSetting
set types {
{ {Emf} {.emf .Emf .EMF} }
{ {All} {*} }
}
set title "Select Model File To Copy Parameters"
#--Display dialog and get path
set path [ MenuExec::openFile $title $types $Model(EMF_OPEN_DIR) ]
if {$path == ""} {
return
}
MenuBuild::configureMenuButtonOption File copy_parameters state disabled
Util::cpp_exec copyParameters $path
}
#------------#
# SAVE procs #
#------------#
# ==========
# MODEL FILE
# ==========
# Save model file with existing names
# Check names and directories
#
proc MenuExec::saveModelFile {} {
global Info Model ModelFlags ModelProperty
if {"ok" != [MenuExec::checkDBName 1] } {
return "cancel"
}
#--Check what to do with removed fields if the original model
# has definitions
if { $Model(removedFieldsList) != "" && $Model(hasUserDefinitions) } {
set msg [list "Note: Some fields have been removed from the model\n\n" \
"(possibly owing to a missing definition file)\n\n" \
"and they will removed permanently, if model file is saved!\n\n\n" \
$Info(anywayOk) ]
set Info(messageIcon) warning
set result [ Message::dispOkCancelMessage $msg ]
if { $result == "cancel" } {
return "cancel"
}
}
#--Check model directory
if { $ModelProperty(MODEL_DIRECTORY) == "" } {
set title "Set model directory"
set label "Enter directory name"
set dir [MenuExec::checkDirectory "" $title $label]
if { [file isdirectory $dir] } {
set ModelProperty(MODEL_DIRECTORY) $dir
set ModelProperty(MODEL_DIRECTORY,absolute) [Util::makePathAbsolute $dir]
# Store new values into Model
Util::cpp_exec modelPropertyPanelOk
} else {
return "cancel"
}
}
set needed 1
if { -1 == [ModelProperty::checkModelDirectory $needed] } {
return "cancel"
}
# If no mesh name defined for an external mesh
if { $ModelFlags(GEOMETRY_TYPE_MESH) &&
$Model(meshNames) == ""
} {
set msg "No mesh name defined!"
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
set rc "ok"
#--Default is given
set msg ""
if {[catch { set rc [MenuExec::saveCheckedModelFile $Model(EMF_PATH)] } msg]} {
set msg [list "Could not save data because:" $msg]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
return $rc
}
# Ask user for the name of the model file
# NOTE: Not in use!
#
proc MenuExec::saveModelFileAs {} {
global Info Model ModelProperty
#--Check model name
if {"ok" != [MenuExec::checkDBName 1] } {
return "cancel"
}
#--Check model directory
if { $ModelProperty(MODEL_DIRECTORY) == "" } {
set title "Set model directory"
set label "Enter directory name"
set dir [MenuExec::checkDirectory "" $title $label]
if { [file isdirectory $dir] } {
set ModelProperty(MODEL_DIRECTORY) $dir
} else {
return "cancel"
}
}
set needed 1
if { -1 == [ModelProperty::checkModelDirectory $needed] } {
return "cancel"
}
#--Model file extension
set types {
{ {Ecif Files} {.emf} }
{ {All Files} {*} }
}
set title "Save Model File"
#--Display dialog and get path
set path [MenuExec::saveFile $title $types $Model(EMF_PATH)]
if {$path == ""} {
return "cancel"
}
set Model(EMF_PATH) $path
set Model(EMF_FILE) [file tail $path]
set Model(EMF_SAVE_DIR) [file dirname $path]
set rc "ok"
set msg ""
if {[catch { set rc [MenuExec::saveCheckedModelFile $Model(EMF_PATH)] } msg]} {
set msg [list "Could not save data because:" $msg]
set Info(messageIcon) error
Message::dispOkMessage $msg
return "cancel"
}
return $rc
}
# Saves model file
# Names and directories are checked!
#
proc MenuExec::saveCheckedModelFile {path {model_file_only 0} {show_msg 1}} {
global Info Model UserSetting ModelProperty
global ModelFlags
# Set possible user definitions status
# ====================================
#
if { $Model(allDefinitions) != "" } {
set Model(hasUserDefinitions) 1
# NOTE: Currently no automatic save!
#
#set def_path [file root $path]
#append def_path ".edf"
#-We always overwrite any existing def file!
#set append 0
# Def-file not saved any more with the model! MVe 16.02.01
#if { [MenuExec::saveDefinitionFile $def_path $append] } {
# set Model(outDefinitionFile) $def_path
#}
}
# Load possible updated SOLVER.KEYWORD files
# ==========================================
#
UserDefined::loadSolverKeywordsFiles
# Update model file info into cpp-side
# ====================================
#
set save_time [Util::setCurrentTimestamp]
#-Model file history
set Model(modified) "$save_time User=$Info(USER) Host=$Info(HOST)"
Util::cpp_exec readModelFileModified $Model(modified)
if { $Model(created) == "" } {
set Model(created) $Model(modified)
Util::cpp_exec readModelFileCreated $Model(created)
}
Util::cpp_exec readModelHasUserDefinitions $Model(hasUserDefinitions)
#-Read model status indicator from C++
Util::cpp_exec checkModelStatus
#-ModelFile save time
Util::cpp_exec readModelFileTime $save_time
#-Set Front update timestamp!
if { $Model(Front,needsUpdate) } {
set Model(Front,timestamp) $save_time
Util::cpp_exec readTimestamp [list "Front" $save_time]
}
#-Set Database ts already here, if it will be anyway
# updated!
# NOTE: Database itself must be updated after model file
# is saved, because it will need the model file contents!
if {!$model_file_only} {
set Model(Database,timestamp) $save_time
Util::cpp_exec readTimestamp [list "Database" $save_time]
}
# Save model file
# ===============
# NOTE: This must be done last, because otherwise latest values for
# status, model-time etc are not saved into the file!
#
#-Make a backup before saving!
set path_tmp ""
if { [file exist $path] } {
set path_tmp $path.tmp
file copy -force $path $path_tmp
}
Util::cpp_exec saveModelFile $path
if {$show_msg} {
Message::showMessage "Model file saved as $path"
}
#-Remove the backup after saving!
catch {file delete -force $path_tmp}
set Model(Front,needsUpdate) 0
set Model(removedFieldsList) ""
# If updating only model file
if {$model_file_only} {
return "ok"
}
# Update problem directory state variables
# ========================================
#
ModelProperty::updateCaseDirectoryVariables
# Mesh saving is conditional
# ==========================
# Check if the Elmer format mesh should be stored:
# if we have an external mesh or
# user has renamed current mesh
#
if { !$Model(Mesh,generating) } {
if { ( $ModelFlags(GEOMETRY_TYPE_MESH) && !$Model(Mesh,exists) ) ||
( $Model(Mesh,exists) && ( $Model(Mesh,added) || $Model(Mesh,edited)) )
} {
# If no Elmer mesh
#
if {!$Model(Mesh,exists)} {
if {$UserSetting(DEFAULT_AUTO_SAVE_EXTERNAL_MESH)} {
# Ask user if we should save the mesh in Elmer format
set msg [list "NOTE: Elmer mesh does not exist\n\n" \
"The external mesh will be saved in Elmer format\n" \
"using the name: $Model(currentMeshName) \n\n" \
$Info(continueOk) ]
if { [Message::verifyAction $Info(powerUser) $msg] } {
MenuExec::saveElmerMeshFile
}
}
# Elmer mesh exists, but it has been
# edited (split/combined) or renamed
} elseif { $Model(Mesh,added) || $Model(Mesh,edited) } {
MenuExec::saveElmerMeshFile
}
}
} ;# End mesh saving related
# Solver sif-file update is conditional
# =====================================
#-Solver input file saving rc!
set rc "ok"
set solver_input_file [MenuExec::getSolverInputFile]
#-If auto-save flag is off, we save only if Solver
# input file does not exist
#
if { !$UserSetting(AUTO_SAVE_SOLVER_INPUT) } {
MenuExec::checkSolverInputFile
if { !$Model(Solver,inputFileExists) } {
set rc [MenuExec::saveSolverInputFile $solver_input_file]
}
#-Otherwise we always save
#
} else {
set rc [MenuExec::saveSolverInputFile $solver_input_file]
}
return $rc
}
# =================
# SOLVER INPUT FILE
# =================
proc MenuExec::saveSolverInputFile {path} {
global Model Info
set result [MenuExec::askSolverOk $path]
# User cancelled sif-file saving
#
if { $result == "cancel" } {
return "cancel"
}
set dir [file dirname $path]
set dir_msg "solver input file"
if { "cancel" == [Util::checkAndCreateDirectory2B $dir $dir_msg] } {
return "cancel"
}
# Make a backup before saving!
set path_tmp ""
if { [file exist $path] } {
set path_tmp $path.tmp
file copy -force $path $path_tmp
}
Util::cpp_exec saveSolverInputFile $path
# Remove the backup after saving!
catch {file delete -force $path_tmp}
set Model(Solver,needsUpdate) 0
set Model(Solver,inputFileExists) 1
return "ok"
}
# ===========================================
# ELMER MESH FILE (in model or as "external")
# ===========================================
# Save mesh result file.
proc MenuExec::saveElmerMeshFile { {as_external 0} } {
global Info Model ModelProperty ModelFlags
# As "External" mesh, ask the directory
# =================
if {$as_external} {
set title "Set mesh directory"
set label "Enter a directory name"
set dir [MenuExec::checkDirectory "" $title $label]
if { $dir == "!cancel!" } {
return "cancel"
}
# Check that mesh directory exists
set ask 1
if {"ok" != [Util::checkAndCreateDirectory2B $dir "Mesh files" $ask]} {
return "cancel"
}
# As Model mesh
# =============
} else {
ModelProperty::setCurrentMeshDirectory
#---Check that mesh directory exists
set ask 0
if {"ok" != [Util::checkAndCreateDirectory2B \
$ModelProperty(CURRENT_MESH_DIRECTORY,absolute) \
"Elmer mesh files" $ask]} {
return "cancel"
}
set dir $ModelProperty(CURRENT_MESH_DIRECTORY,absolute)
}
set Model(Mesh,exists) 1
set Model(Mesh,edited) 0
set Model(Mesh,added) 0
Util::cpp_exec saveElmerMeshFile $dir
}
# ==================================
# ELEMRPOST MESH (mesh in ep-format)
# ==================================
# Save mesh result file.
proc MenuExec::saveElmerPostMeshFile {} {
global Info Model
set types {
{ {Mesh Files} {.ep .EP .Ep .p .P} }
{ {All Files} {*} }
}
set title "Save mesh in ElmerPost format"
set default_path $Model(outElmerPostMeshFile)
#--Display dialog and get path
set path [MenuExec::saveFile $title $types $default_path]
if {$path == ""} {
return
}
set Model(outElmerPostMeshFile) $path
Util::cpp_exec saveElmerPostMeshFile $path
}
# ===================================
# THETIS MESH (mesh in thetis format)
# ===================================
# Save mesh result file.
proc MenuExec::saveThetisMeshFile {} {
global Info Model
set types {
{ {Thetis Mesh Files} {.tmf} }
{ {Text Files} {.txt } }
{ {All Files} {*} }
}
set title "Save mesh in Thetis format"
set default_path $Model(outThetisMeshFile)
#--Display dialog and get path
set path [MenuExec::saveFile $title $types $default_path]
if {$path == ""} {
return
}
set Model(outThetisMeshFile) $path
Util::cpp_exec saveThetisMeshFile $path
}
#-----------------------#
# OTHER File menu procs #
#-----------------------#
proc MenuExec::browseFile { {edit_mode 0} } {
global Info
set types {
{ {All} {*} }
}
if { $edit_mode } {
set title "Edit File"
} else {
set title "Browse File"
}
if { $edit_mode } {
set open_dir $Info(editorDir)
set open_fil $Info(editorPath)
} else {
set open_dir $Info(browserDir)
set open_fil $Info(browserPath)
}
#--Display dialog and get path
set path [MenuExec::openFile $title $types $open_dir $open_fil]
if { $path == "" } return
if { $edit_mode } {
set Info(editorDir) [file dirname $path]
set Info(editorPath) $path
} else {
set Info(browserDir) [file dirname $path]
set Info(browserPath) $path
}
if { $edit_mode } {
FileBrowser::browse .winFileEedit $path 1 1
} else {
FileBrowser::browse .winFileBrowse $path
}
}
proc MenuExec::browseEgfFile { {edit_mode 0} } {
global Info Model
if { $Model(cadPath) != "" } {
set path $Model(cadPath)
} else {
set types {
{ {Egf} {.egf .Egf .EGF} }
{ {All} {*} }
}
if { $edit_mode } {
set title "Edit Egf File"
} else {
set title "Browse Egf File"
}
#--Display dialog and get path
set path [MenuExec::openFile $title $types $Model(CAD_OPEN_DIR)]
}
if { $path == "" } return
if { $edit_mode } {
FileBrowser::browse .winEgfFilEedit $path 1 1
} else {
FileBrowser::browse .winEgfFileBrowse $path
}
}
# Browse current definitions
#
proc MenuExec::browseCurrentDefinitions { {edit_mode 0 } } {
if { $edit_mode } {
FileBrowser::browse .winDefBrowse {Model allDefinitions} 0 1 1
} else {
FileBrowser::browse .winDefEdit {Model allDefinitions} 0
}
}
# NOTE: No edit-mode for model files!
#
proc MenuExec::browseEmfFile {} {
global Info Model
# For event testing:
# global InitialCondition mainWindow
# event generate $InitialCondition(winName) <Configure> -above $mainWindow
# event generate $InitialCondition(winName) <Circulate> -place PlaceOnTop
if {$Model(EMF_PATH) != ""} {
FileBrowser::browse .winModelFileBrowse $Model(EMF_PATH)
} else {
set msg [list "No model file defined!\n" \
"Command not valid" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
}
}
proc MenuExec::browseSifFile { {edit_mode 0} } {
global Info Datafile
set solver_input_file [MenuExec::getSolverInputFile]
if { $solver_input_file != "" } {
if { ![file isfile $solver_input_file] } {
set msg [list "File not found:\n" \
"$solver_input_file\n" \
"Save first model (File/Save model file) !" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
return
}
if { $edit_mode } {
FileBrowser::browse .winSolverFileEdit $solver_input_file 1 1
} else {
FileBrowser::browse .winSolverFileBrowse $solver_input_file
}
} else {
set msg [list "No solver input file defined!\n" \
"Define solver input file (Problem/Datafiles)\n" \
"and save model!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
}
}
proc MenuExec::browseSolverReloadFile { {edit_mode 0} } {
global Info Datafile
set reload_file [MenuExec::getSolverReloadFile]
if { $reload_file != "" } {
if { ![file isfile $reload_file] } {
set msg [list "File not found:\n" \
"$reload_file !"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return
}
if { $edit_mode } {
FileBrowser::browse .winSolverReloadEdit $reload_file 1 1
} else {
FileBrowser::browse .winSolverReloadBrowse $reload_file
}
} else {
set msg [list "No solver reload file defined!\n" \
"Define solver input file (Solver/Solver control)\n" \
"and save model!" ]
set Info(messageIcon) error
Message::dispOkMessage $msg
}
}
proc MenuExec::browseLogFile {} {
global Info
FileBrowser::browse .winLogFile $Info(ElmerRun,logfile)
}
#-Program EXIT
#
proc MenuExec::cifExit {} {
global Info Model
global ProcessIds ProcessTable
set do_exit 1
catch {
###### Start of CATCH #####
set result [MenuExec::askModelOk "exit"]
if { $result != "ok" } {
set do_exit 0
return
}
#---Check unstopped processes and delete possible logfiles
#
set p_info ""
foreach nbr $ProcessIds {
# List unstopped process
if { !$ProcessTable($nbr,terminated) } {
append p_info "Process: $ProcessTable($nbr,name) "
append p_info "Nbr: $nbr "
append p_info "PID: $ProcessTable($nbr,pid) "
append p_info "Model: $ProcessTable($nbr,model) "
if { $ProcessTable($nbr,logfile) != "" } {
append p_info "Logfile: $ProcessTable($nbr,logfile) "
}
append p_info "\n"
# Delete possible logfile
} else {
set msg ""
catch { [file delete $ProcessTable($nbr,logfile)] msg }
}
}
# Confirm exit, if active processes
if { $p_info != "" } {
set msg [list "NOTE: The following processes are still active!\n\n" \
"$p_info\n\n" \
"$Info(anywayOk)" ]
if { ![Message::verifyAction $Info(advancedUser) $msg] } {
set do_exit 0
return
}
}
}
###### End of CATCH #####
# If exit was cancelled by the user
#
if { !$do_exit } {
return
}
#---Exit Elmer Front!!!
Util::cpp_exec cpp_exit
exit
}
#-Open file cover procedure
#
proc MenuExec::openFile {title types {default_dir ""} {default_file ""} } {
#---Tk Open file dialog
set path [tk_getOpenFile \
-title $title \
-filetypes $types \
-initialdir $default_dir \
-initialfile $default_file \
]
return $path
}
#-Save file cover procedure
#
proc MenuExec::saveFile {title types default_path} {
set file [file tail $default_path]
set dir [file dirname $default_path]
#---Tk Save file dialog
set path [tk_getSaveFile \
-title $title \
-filetypes $types \
-initialdir $dir \
-initialfile $file \
]
return $path
}
#####################################################################
#
# BUTTON AREA procs
#
#####################################################################
#---Renderer display button procs
#-Move (translate) model
#
proc MenuExec::rendererMove { direction {axis ""} } {
global Info
if { $axis == "" } {
set axis $Info(currentMoveAxis)
}
#-Map axis to integer
if {$axis == "X"} {
set axis 0
} elseif {$axis == "Y"} {
set axis 1
} else {
set axis 2
}
set data [list $axis $direction]
Util::cpp_exec rendererTranslateModel $data
}
#-Set rotation priorities
#
proc MenuExec::rendererSetRotatePriorities { } {
global Info
set data {0 0 0}
switch $Info(currentRotateAxis) {
"X" {
set data {1 0 0}
}
"Y" {
set data {0 1 0}
}
"Z" {
set data {0 0 1}
}
}
Util::cpp_exec rendererSetRotatePriorities $data
}
#-Rotate model
#
proc MenuExec::rendererRotate { direction {axis ""} } {
global Info
if { $axis == "" } {
set axis $Info(currentRotateAxis)
}
#-Map axis to integer
#-None checked
if {$axis == ""} {
return
#-X checked
} elseif {$axis == "X"} {
set axis 0
#-Y checked
} elseif {$axis == "Y"} {
set axis 1
#-Z checked
} else {
set axis 2
}
set data [list $axis $direction]
Util::cpp_exec rendererRotateModel $data
}
#-Scale model
#
proc MenuExec::rendererScale {direction} {
global Info
set data $direction
Util::cpp_exec rendererScaleModel $data
}
#-Reset graphics screen
#
proc MenuExec::rendererReset {} {
Util::cpp_exec rendererResetModel
}
#-Display (refresh) graphics screen
#
proc MenuExec::rendererDisplay {} {
global ModelFlags
# Set at least bodies to be drawn!
if { $ModelFlags(DRAW_TARGET_BODIES) == 0 &&
$ModelFlags(DRAW_TARGET_SURFACES) == 0 &&
$ModelFlags(DRAW_TARGET_EDGES) == 0
} {
Util::setFlagValue DRAW_TARGET DRAW_TARGET_BODIES 1
}
Util::cpp_exec rendererDisplayModel
}
proc MenuExec::show_results {} {
global Model
# If we have only one mesh
if { 1 == $Model(nofActiveMeshes) } {
set postFile [list [MenuExec::getSolverResultFile 0 POST_FILE]]
MenuExec::prepare_elmer_exec Results $postFile
} else {
PostFileSelect::openPanel
}
}
proc MenuExec::info_ {} {
ModelInfo::openPanel
}
#-Stop Front task (by Break button)
#
proc MenuExec::doBreak {} {
global Info
#Message::showMessage "Break not active, sorry!"
Util::cpp_exec doBreak
}
#####################################################################
#
# EDIT MENU procs
#
#####################################################################
proc MenuExec::removeCadGeometry {} {
global ModelFlags Model ModelProperty Info
if {$ModelFlags(GEOMETRY_TYPE_CAD) == 0} {
set msg "No Cad geometry available, nothing to remove!"
set Info(messageIcon) info
Message::dispOkMessage $msg
return
}
if {$ModelFlags(GEOMETRY_TYPE_MESH) == 0} {
set msg "No other (mesh) geometry available, cannot remove Cad geometry!"
set Info(messageIcon) info
Message::dispOkMessage $msg
return
}
set msg [list \
"This command removes Cad geometry from the model!\n\n" \
"If you do that NOTE the following:\n\n" \
"--You CANNOT create a new mesh, because geometry is lost!\n\n" \
"--You CAN edit boundaries which will be based on mesh elements only!\n\n" \
"Change model name before saving the changes (if you want to keep the original model)!\n\n" \
"\nPress OK to remove Cad geometry, otherwise press Cancel" \
]
if { ![Message::verifyAction $Info(powerUser) $msg] } {
return
}
Util::cpp_exec removeCadGeometry
set Model(Front,needsUpdate) 1
Message::showMessage "Cad geometry removed!"
# Update main windo title
Util::updateMainWindowTitle
}
# This proc removes all inactive parameer field from
# all mask dependent parameters
#
proc MenuExec::removeInactiveParameterData {} {
global Info Equation
# NOTE: If turned off
# ===================
#set msg "Sorry, not in use currently!"
#Message::dispOkMessage $msg
#return
# ===========================
set msg [list \
"This command removes all inactive parameter data from the model!\n\n" \
"NOTE: you have to save the model after this command!\n\n" \
"\nPress OK to remove inactive parameter data, otherwise press Cancel" \
]
if { ![Message::verifyAction $Info(powerUser) $msg] } {
return
}
#-Set flag value for skipping inactive data
set tmp $Info(keepInactiveFields)
set Info(keepInactiveFields) 0
#-Clean Equation parameters
set modified1 0
Panel::checkParameters Equation modified1
#-Clean all mask related arries
set modified2 0
Panel::checkMaskedParameters modified2
#-Clean solver data
set modified2 0
Solver::checkSolverData $Equation(activeIndices) modified2
#-Restore flag
set Info(keepInactiveFields) $tmp
}
# Set Matc input file name to be stored in emf-file
#
proc MenuExec::setMatcInputFile {type} {
global Info Model
# Matc-input file for model (emf) file
#
if { $type == "emf" } {
set title "Matc input for Model file"
set mcf $Model(matcInputFile_emf)
# Matc-input file for sif-file
#
} elseif { $type == "sif" } {
set title "Matc input for Sif-file"
set mcf $Model(matcInputFile_sif)
}
set label "Enter file name"
global mcf_res ;# Reference var must be global in dispFileEntry!
set mcf_res ""
incr Info(fileEntryId)
set wname ".w$Info(fileEntryId)"
Widget::dispFileEntry $wname mcf_res $mcf $title $label
tkwait variable mcf_res
if { $mcf_res != "!cancel!" } {
#-If ok value
if { [file isfile $mcf_res] } {
set mcf $mcf_res
#-Empty file name
} elseif { $mcf_res == "" } {
set msg [list "No Matc input file will be in use!\n\n" \
$Info(anywayOk) ]
set Info(messageIcon) warning
set result [ Message::dispOkCancelMessage $msg ]
# Set empty name
if { $result != "cancel" } {
set mcf ""
# Close entry
} else {
unset mcf_res
return
}
#-Invalid file name
} else {
set msg [list "A non existing file name!\n\n$mcf_res\n\n" \
$Info(anywayOk) ]
set Info(messageIcon) error
set result [ Message::dispOkCancelMessage $msg ]
# Use invalid name (user knows better!)
if { $result != "cancel" } {
set mcf $mcf_res
# Close entry
} else {
unset mcf_res
return
}
}
# Set matc input file in model
#
if { $type == "emf" } {
set Model(matcInputFile_emf) $mcf
Util::cpp_exec setMatcInputFileEmf $Model(matcInputFile_emf)
} elseif { $type == "sif" } {
set Model(matcInputFile_sif) $mcf
Util::cpp_exec setMatcInputFileSif $Model(matcInputFile_sif)
}
}
set Model(Front,needsUpdate) 1
Util::updateMainWindowTitle
unset mcf_res
}
# Update model geometry (by Matc-definitions)
#
proc MenuExec::verifyUpdateCadGeometry {} {
global Info Model
# Warning if mesh(es) exists
if { $Model(Mesh,exists) } {
set msg [list "Matc-dependent model geometry will be updated and" \
"\ncurrent meshes may not then match the geometry!\n\n" \
$Info(anywayOk) ]
} else {
set msg "Matc-dependent model geometry will be updated!"
}
set Info(messageIcon) warning
set result [ Message::dispOkCancelMessage $msg ]
# User cancelled
if { $result == "cancel" } {
return
}
# Update (Matc-dependent) geometry
Util::cpp_exec updateCadGeometry
}
proc MenuExec::verifyDropMatcDefs {} {
global Info Model
# Warning
if { $Info(dropModelMatcDefinitions) && $Model(hasMatcDefinitions) } {
set msg [list "Model has Matc dependent geometry and these definitions will NOT be stored!\n\n" \
$Info(anywayOk) ]
set Info(messageIcon) warning
set result [ Message::dispOkCancelMessage $msg ]
# User cancelled
if { $result == "cancel" } {
set Info(dropModelMatcDefinitions) 0
}
}
# Set menu text
MenuBuild::setCheckMenuLabel Edit "Drop Matc definitions from model" Info(dropModelMatcDefinitions)
}
proc MenuExec::setMeshInputUnit {} {
global Model
global unit
set unit ""
set title "Set mesh unit for external mesh input"
set label "Enter input unit:"
Widget::dispDataEntry unit $Model(meshInputUnit) $title $label
tkwait variable unit
set result $unit
unset unit
if { $result == "!cancel!" } {
return
}
if { $result == "" || $result <= 0 || [catch {expr $result}] } {
Message::dispOkMessage "ERROR: Invalid value: $result (must be a positive number)"
return
}
Util::cpp_exec setMeshInputUnit $result
}
#####################################################################
#
# ELMER PROCESS EXEC procs
#
#####################################################################
proc MenuExec::send_WIN32 {target command} {
return [dde eval $target $command]
}
##########################
### PREPARE ELMER EXEC ###
##########################
# This procedure constructs proper arguments for the calls
# to the external Elmer procedures
#
proc MenuExec::prepare_elmer_exec {process_name { process_args ""} } {
global Info Model ModelProperty Datafile Timestep
global Processor UserSetting
global ProcessTable
#--General environment checking
if { "ok" != [MenuExec::checkProcessEnvironment process_name] } {
return -1
}
#--System specific call name specifier
if { $Info(platform) == "windows" } {
set sys WIN32
} else {
set sys UNIX
}
# Set program name and arguments
# ==============================
set exec_name $Info($process_name,proc,$sys)
set arg ""
set use_eval 1
set priority_level $Info(bgPriorityLevel)
set browser_delay 0
set process_info ""
set add_to_process_table 1
set show_in_process_list 1
set browse_parser "none"
set browse_parser_needs_runnumber 1
# GebhardtFactors
# ---------------
if { $process_name == $Info(GebhardtFactors,processName) } {
set arg [MenuExec::getSolverInputFile]
set browse_mode $UserSetting(BROWSE_MODE_GEBHARDT_FACTORS)
set browser_delay $Info(browser,largeDelay)
# Mesh
# ----
} elseif { $process_name == $Info(Mesh2D,processName) ||
$process_name == $Info(Mesh3D,processName)
} {
# Create mif-file
set mif_name [MenuExec::getMeshInputFileName]
set fname [file join $ModelProperty(CURRENT_MESH_DIRECTORY,absolute) $mif_name]
Util::cpp_exec saveMeshInputFile $fname
set arg1 "\"$fname\" \"$ModelProperty(CURRENT_MESH_DIRECTORY,absolute)\""
#-Control background mesh file in use
#
if { $Model(currentMeshBgMeshControlFile) != "" } {
set arg2 "--bgcontrol=\"$Model(currentMeshBgMeshControlFile)\""
#-Normal background mesh file in use
#
} elseif { $Model(currentMeshBgMeshFile) != "" } {
set arg2 "--bgmesh=\"$Model(currentMeshBgMeshFile)\""
#-No background mesh stuff
} else {
set arg2 ""
}
set arg [string trim "$arg1 $arg2"]
set browse_mode $UserSetting(BROWSE_MODE_MESH)
set browser_delay $Info(browser,largeDelay)
set process_info [ProcessTable::formMeshInfo]
set Model($process_name,ElmerMeshProcessing) 1
# Results
# -------
# NOTE:
# --Windows: we start first the server by a command line
# call and then send the initializing commands via DDE in
# proc MenuExec::reset_elmer_exec. This is because of the
# limited size of the command line buffer.
# --Unix: we send init level commands by the command line call
# and use DDE only for refresh commands
#
} elseif { $process_name == $Info(Results,processName) } {
set postFile [lindex $process_args 0]
set server $Info(Results,tclServer)
# These variables are used to control ElmerPost
# call mode
if { ![info exists Info(Results,$server,mode)] } {
set Info(Results,$server,mode) ""
set Info(Results,$server,created) 0
}
#--Check server state and form proper ElmerPost command
set rc [MenuExec::prepare_ElmerPost_exec $postFile \
$server \
Info(Results,tclCommand)]
#--If server exist, use send to deliver update commands
if { $rc == 1 } {
set Info(Results,$server,created) 0
# Try to send update command
if { ![MenuExec::sendTclCommands $server $Info(Results,tclCommand) 10 msg] } {
Message::showMessage "$server not updated because: $msg"
} elseif { $Info(displayExecMessages) } {
Message::showMessage "$server updated: $Info(Results,tclCommand)"
}
return 0
#--If server doesn't exist, create it using a command line call!
} elseif { $rc == 0 && $Info(Results,$server,mode) != "" } {
set Info(Results,$server,created) 1
set arg "-id"
lappend arg $Info(Results,tclServer)
lappend arg "-file"
lappend arg $postFile
lappend arg $Info(Results,tclCommand)
#--Not found or exists, but not accessible!
} else {
set Info(Results,$server,created) 0
return 0
}
#-Create a new post session
set use_eval 0
set priority_level "NORMAL_PRIORITY"
set add_to_process_table 0
set browse_mode "None"
# Post
# ----
# NOTE: This is used when no model file is opened, then
# "Results" is changed to "Post" command in checkProcessEnvironment!
} elseif { $process_name == $Info(Post,processName) } {
set arg ""
set use_eval 0
set priority_level "NORMAL_PRIORITY"
set add_to_process_table 0
set browse_mode "None"
# Solver
# ------
# NOTE: We do not add model-directory to the solver-input-file
# name, when we write solver startinfo data! MVe 29.09.99
#
} elseif { $process_name == $Info(Solver,processName) } {
# For exe-version
set startinfo_file [file join $ModelProperty(MODEL_DIRECTORY,absolute) "ELMERSOLVER_STARTINFO"]
set ch [open $startinfo_file "w+"]
puts $ch $Datafile(SOLVER_INPUT_FILE)
puts $ch $Processor(NOF_PROCESSORS)
close $ch
set reload_file [DataField::getFieldValue SolverControl 1 RELOAD_INPUT_FILE active]
if { $active && $reload_file != "" } {
set rereadinfo_file [file join $ModelProperty(MODEL_DIRECTORY,absolute) "ELMERSOLVER_REREADINFO"]
set ch [open $rereadinfo_file "w+"]
puts $ch $reload_file
puts $ch $Processor(NOF_PROCESSORS)
close $ch
}
# For batch-version
set arg "$Datafile(SOLVER_INPUT_FILE)"
append arg " $Processor(NOF_PROCESSORS)"
set browse_mode $UserSetting(BROWSE_MODE_SOLVER)
set browser_delay $Info(browser,largeDelay)
set process_info [ProcessTable::formSolverInfo]
set browse_parser "Process::solverBrowseParser"
set browse_parser_needs_runnumber 1
# Viewfactors
# -----------
} elseif { $process_name == $Info(Viewfactors,processName) } {
set arg [MenuExec::getSolverInputFile]
set browse_mode $UserSetting(BROWSE_MODE_VIEW_FACTORS)
set browser_delay $Info(browser,largeDelay)
# Error
# -----
} else {
set msg "Unknown program name: $process_name \n"
set Info(messageIcon) error
Message::dispOkMessage $msg
return -1
}
#--Complete name for the executable
set home $Info(ELMER_HOME)
set exec_dir [file join $home "bin"]
set exec_cmd [file join $exec_dir $exec_name]
#--Check that executable exists
if { ![file executable $exec_cmd] } {
set msg [list "Can't find executable program:\n" \
"$exec_cmd" \
"\nProgram not run!"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return -1
}
#--Other run arguments
set browse_mode [string tolower $browse_mode]
set process_tag $Info($process_name,processTag)
set logfile_base [file join $ModelProperty(LOG_DIRECTORY,absolute) \
$Info($process_name,logfile) ]
#--Check that logfile can be created!
if { $browse_mode == "logfile" } {
if { ![file isdirectory $ModelProperty(LOG_DIRECTORY,absolute)] } {
set dir_msg "for the log file"
set cre_msg "Press Yes to create the directory and continue\n"
append cre_msg "Press No to continue and use system shell window as log!"
set rc [Util::checkAndCreateDirectory3B $ModelProperty(LOG_DIRECTORY,absolute) $dir_msg 1 $cre_msg]
# Do not continue
if { $rc == "cancel" } {
return -1
}
# Continue without logfile
if { $rc == "no" } {
set logfile_base ""
set browse_mode "shell"
}
}
}
#--Changedir to model's directory (store current)
set Info(currentDirectory) [pwd]
Util::cpp_exec setCurrentDirectory $ModelProperty(MODEL_DIRECTORY,absolute)
# Exec the program
# ================
set runnumber [MenuExec::do_elmer_exec \
$process_name \
$use_eval $exec_cmd $arg \
$priority_level \
$add_to_process_table \
$show_in_process_list \
$browse_mode \
$exec_name \
$process_tag \
$logfile_base \
$process_info]
#--Restore current directoy
Util::cpp_exec setCurrentDirectory $Info(currentDirectory)
# Succes, reset flags etc.
# ========================
if { $runnumber != -1 } {
if { $add_to_process_table } {
set ProcessTable($runnumber,browserDelay) $browser_delay
}
# If possible logfile browser needs to know the runnumber
# (ex. to be able to update process table etc.)
if { $browse_parser != "none" && $browse_parser_needs_runnumber } {
append browse_parser " $runnumber"
}
MenuExec::reset_elmer_exec $process_name $process_args $runnumber $browse_mode $browse_parser
return $runnumber
# No success
# ==========
} else {
return -1
}
}
# ElmerPost specific
# ==================
#
proc MenuExec::prepare_ElmerPost_exec {post_file server script_argument} {
global Info
upvar $script_argument script
set rc 1
set script ""
# Check server state if something to send
# =======================================
if { $Info(Results,$server,mode) != "" } {
set try_count 10
set src [MenuExec::existsTclServer $server $try_count]
#---Server is not responding!
if { $src == 0 || $src == -1 } {
set Info(Results,$server,mode) ""
#--Server just created, but not found!
if { $src == 0 && $Info(Results,$server,created) } {
set msg [list "NOTE: Elmer Post server not found!\n\n" \
"We cannot send any update commands to Elmer Post!\n\n" \
"Use menus in Elmer Post for updating the results!"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return 0
#--Server just created, but not accessible!
} elseif { $src == -1 && $Info(Results,$server,created) } {
set msg [list "NOTE: Elmer Post server is not accessible!\n\n" \
"We cannot send any update commands to Elmer Post!\n\n"\
"Use menus in Elmer Post for updating the results!"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return 0
#---Server must be created (again)
} else {
set Info(Results,$server,mode) ""
}
}
}
# No server exists yet, we will use command line call
# ===================================================
if { $Info(Results,$server,mode) == "" } {
set Info(Results,$server,mode) "start"
set rc 0
}
# Form proper ep command
# ======================
set script [MenuExec::formElmerPostCommand $post_file $Info(Results,$server,mode)]
#--Set next command mode
if { $Info(Results,$server,mode) == "start" } {
#-Windows
if { $Info(platform) == "windows" } {
set Info(Results,$server,mode) "init"
#-Unix (directly from start to refresh!)
} else {
set Info(Results,$server,mode) "refresh"
}
} elseif { $Info(Results,$server,mode) == "init" } {
set Info(Results,$server,mode) "refresh"
}
return $rc
}
#####################
### DO ELMER EXEC ###
#####################
# Do the actual Elmer exec call
# =============================
# Arguments (when not self explaining :-):
# process_name: proc key to Info arries, like "Solver"
# exec_cmd: actual call (path, exec-name etc.)
# arg : arguments for the exec_cmd
# exec_name: name for executable file like "mesh.exe"
# process_tag: a short name for the process table like "Mesh2D", "GebFact" etc.
# process_info: process specific ino like db-name, Mesh-H etc.
#
proc MenuExec::do_elmer_exec {
process_name
use_eval
exec_cmd arg
{priority "NORMAL_PRIORITY"}
{add_to_process_table 0}
{show_in_process_list 0}
{browse_mode "none"}
{exec_name "Unknown"}
{process_tag "Unknown"}
{logfile_base ""}
{process_info ""}
} {
global Info Model ProcessTable errorCode
#--If nothing to do!
if {$exec_cmd == "" } {
return
}
# To be sure!
if { !$add_to_process_table } {
set show_in_process_list 0
}
incr Info(ElmerRun,runnumber)
set browse_mode [string tolower $browse_mode]
# Output directed to a logfile
# ============================
if { $browse_mode == "logfile" && $logfile_base != "" } {
# Try to find a free logfile,runnumber combi
# Increment runnumber, if necessary
#
set success 0
set counter 0
while { !$success &&
$counter < 100
} {
incr counter
# Full name for the logfile!!!
set testfile $logfile_base.log.$Info(ElmerRun,runnumber)
# Delete possible old version of the log file
set msg ""
set catch_rc [ catch [file delete -force $testfile] msg]
if {!$catch_rc} {
set success 1
set logfile $testfile
} else {
incr Info(ElmerRun,runnumber)
}
}
if {!$success} {
set msg [list "Program $exec_cmd was not run properly, because:\n" \
"could not open a logfile for it!"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return -1
}
# No logfile
# ==========
} else {
set logfile ""
}
set pid 0
set runnumber $Info(ElmerRun,runnumber)
set starttime [clock seconds]
set use_log 0
###############################
#--Run the program using catch!
###############################
set msg ""
set code [ catch {
#-ElmerPost is run always using exec
###########
#
if { $process_name == $Info(Results,processName) } {
set arg1 [lindex $arg 0] ;# -id
set arg2 [lindex $arg 1] ;# server name
set arg3 [lindex $arg 2] ;# -file
set arg4 [lindex $arg 3] ;# filename
set arg5 [lindex $arg 4] ;# commands
# Make easier to print (for messages)
set arg [join $arg]
set pid [exec $exec_cmd $arg1 $arg2 $arg3 $arg4 $arg5 & ]
#-WIN32 (other than ElmerPost)
#######
} elseif { $Info(platform) == "windows" } {
#-Send process output to shell console
if { $browse_mode == "shell" } {
set use_log 0
#-Send process output to Elmer log file
} elseif { $browse_mode == "logfile" } {
set use_log 1
#-Nothing special with the ouput
} else {
set use_log 0
}
# Set final logfile mode
if { $use_log } {
set logf $logfile
} else {
set logf $browse_mode
}
set data ""
lappend data $exec_cmd ;# exe-path
lappend data $arg ;# arguments
lappend data $runnumber ;# id nbr
lappend data $exec_name ;# name
lappend data $priority ;# priority level
lappend data $logf ;# logfile or none/shell
Util::cpp_exec processStart $data
#-UNIX (other than ElmerPost)
######
} else {
#-Send process output to shell console
if { $browse_mode == "shell" } {
if { $use_eval } {
set pid [eval exec $exec_cmd $arg & ]
} else {
set pid [exec $exec_cmd $arg & ]
}
#-Send process output to Elmer log file
} elseif { $browse_mode == "logfile" } {
if { $use_eval } {
set pid [eval exec $exec_cmd $arg >>& $logfile & ]
} else {
set pid [exec $exec_cmd $arg >>& $logfile & ]
}
#-"None", no visible ouput
} else {
if { $use_eval } {
set pid [eval exec $exec_cmd $arg > /dev/null & ]
} else {
set pid [exec $exec_cmd $arg > /dev/null & ]
}
}
}
} msg ]
############## End catch Run
# Display process run message in the message area
# ===============================================
if { $Info(displayExecMessages) } {
Message::showMessage "Process $runnumber: $exec_name $arg"
}
# If something went wrong
# =======================
if { $code != 0 } {
set msg [list "Program $exec_cmd was not run properly, because:\n" \
"$msg"]
set Info(messageIcon) error
Message::dispOkMessage $msg
return -1
}
# If process is added to process table
# ====================================
if { $add_to_process_table } {
set check_all_done $Info($process_name,checkAllDone)
ProcessTable::addEntry $pid $runnumber $priority \
$show_in_process_list $check_all_done \
$process_tag $logfile $starttime $process_info
if { $show_in_process_list } {
Process::monitor $runnumber
}
}
return $runnumber
}
########################
### RESET ELMER EXEC ###
########################
# This procedure resets Elemer exec related flags if the call
# to the executable was succeful
#
proc MenuExec::reset_elmer_exec {process_name process_args runnumber {browse_mode ""} {browse_parser "none"} } {
global Equation Info Model ModelProperty ProcessTable UserSetting
#---Possibly browse the log file
#
if { $browse_mode == "logfile" } {
MenuExec::browseProcessLog $runnumber $browse_parser
}
set set_timestamp 0
set save_model_file 0
#---Update flags and timestamps
# Emf2Db
# ======
if { $process_name == $Info(Emf2Db,processName) } {
set Model(Database,needsUpdate) 0
# GebhardtFactors
# ===============
} elseif { $process_name == $Info(GebhardtFactors,processName) } {
set set_timestamp 1
set save_model_file 1
set Model(GebhardtFactors,needsUpdate,data) 0
set Model(GebhardtFactors,needsUpdate,mesh) 0
# Mesh
# ====
} elseif { $process_name == $Info(Mesh2D,processName) ||
$process_name == $Info(Mesh3D,processName)
} {
#-Wait until mesh generator at end
MenuExec::monitorMesh $runnumber
if { !$ProcessTable($runnumber,terminated) } {
tkwait variable ProcessTable($runnumber,terminated)
}
set Model(Mesh,generating) 0
#-If success
if { $ProcessTable($runnumber,state) == "all done" } {
set set_timestamp 1
set save_model_file 1
set Model(MeshFromDB,needsUpdate) 1
MenuBuild::configureButtonOption loadMesh state disabled
MenuExec::unloadMesh "--Removing old mesh data from the memory"
#-Load mesh from DB
if { $UserSetting(AUTO_LOAD_MESH) } {
MenuExec::loadMesh $runnumber
} else {
MenuBuild::configureFileLoadMeshMenus 1
MenuBuild::configureButtonOption loadMesh state normal
}
#-Set Viewfactors and GebhardtFactors update flags if heat equation
# mesh was updated
set eidx [DataField::getFieldProperty Equation HEAT_EQUATION EquationIndex]
if { $Model(hasDiffuseGrayRadiation) &&
$Model(currentMeshName) == [MenuExec::getSolverMeshName $eidx 0]
} {
# If checking is not turend of by the user
if { $Model(Viewfactors,needsUpdate,mesh) != -1 } {
set Model(Viewfactors,needsUpdate,mesh) 1
}
# If checking is not turend of by the user
if { $Model(GebhardtFactors,needsUpdate,mesh) != -1 } {
set Model(GebhardtFactors,needsUpdate,mesh) 1
}
}
#-Update mesh names
#set Model(meshNames) [ModelProperty::findModelMeshNames]
} ;# If mesh generating succesful
# Results
# =======
} elseif { $process_name == $Info(Results,processName) } {
set server $Info(Results,tclServer)
#--If ElmerPost should be initialized (in "init"-mode)
if { $Info(Results,$server,mode) == "init" } {
MenuExec::prepare_elmer_exec $process_name $process_args
}
# Solver
# ======
} elseif { $process_name == $Info(Solver,processName) } {
# Warning for zero velocity condition corner bulk elements
if { $Model(nofMeshZeroVelocityElements) > 0 } {
set warning "***WARNING: Mesh contains zero-velocity element(s)!"
Process::addWarning $runnumber $warning
}
# NOTE: Order is important here!
set ProcessTable($runnumber,solver,postFiles) [MenuExec::getSolverResultFiles POST_FILE]
set ProcessTable($runnumber,solver,outputFiles) [MenuExec::getSolverResultFiles OUTPUT_FILE]
PostFileSelect::updateFileList $runnumber
MenuBuild::configureButtons results 1
set set_timestamp 1
set save_model_file 1
set Model(Solver,solving) 0
# Viewfactors
# ===========
} elseif { $process_name == $Info(Viewfactors,processName) } {
set set_timestamp 1
set save_model_file 1
set Model(Viewfactors,needsUpdate,data) 0
set Model(Viewfactors,needsUpdate,mesh) 0
}
# We have polled enough the process, we do not need
# it any more!
Process::markRemoveable $runnumber
# Save timestamp data in the model
#
if { $set_timestamp } {
set ts [Util::setCurrentTimestamp]
set Model($process_name,timestamp) $ts
Util::cpp_exec readTimestamp [list $process_name $ts]
}
# Save model file
#
if { $UserSetting(AUTO_SAVE_MODEL) && $save_model_file } {
set model_file_only 1
set show_msg 0
MenuExec::saveCheckedModelFile $Model(EMF_PATH) $model_file_only $show_msg
}
}
proc MenuExec::browseProcessLog {runnumber { browse_parser "none" } } {
global Info ProcessTable
set logfile $ProcessTable($runnumber,logfile)
set logchannel $ProcessTable($runnumber,channel)
set must_exist 0
set can_edit 0
set can_delete_cancelled 0
# Open browser
FileBrowser::browse .winLogFile $logfile $must_exist $can_edit $can_delete_cancelled \
$browse_parser $logchannel $runnumber
}
proc MenuExec::getElmerPostHeader {post_datafile} {
if { ![file exist $post_datafile] ||
![file readable $post_datafile]
} {
return ""
}
set msg ""
set channel_id -1
if { [catch {set channel_id [open $post_datafile] } msg] } {
return ""
}
set ep_header [gets $channel_id]
close $channel_id
return $ep_header
}
# Send command(s) to a remote tcl server
# Give 10 * wait-time test time for the server
# before given up
#
proc MenuExec::sendTclCommands {server cmd {max_try_count 10} {message ""} } {
if { $message != "" } {
upvar $message msg
}
set try_count 0
set msg ""
# Try to send commands
# ====================
while {$try_count < $max_try_count} {
incr try_count
#--If send was ok
if { ![catch {send $server [join $cmd] } msg] } {
return 1
#--Otherewise try again
} else {
Util::doWait 500
}
}
# No success!
# ===========
return 0
}
# Test if a remote tcl server is alive
#
proc MenuExec::existsTclServer {server {max_try_count 10} } {
global Info
set server_state ""
set try_count 0
while { $try_count <= $max_try_count } {
set msg ""
incr try_count
# Win32
# =====
if { $Info(platform) == "windows" } {
#--Problems
if { [catch {send $server ""} msg] } {
set server_state 0
#--Ok, we can stop
} else {
return 1
}
# Unix
# ====
} else {
#--Problems
if { [catch {send $server ""} msg] } {
#-"no application named"
if { [regexp (no) $msg] &&
[regexp (application) $msg] &&
[regexp (named) $msg]
} {
set server_state 0
#-"server insecure"
} elseif { [regexp (server) $msg] &&
[regexp (insecure) $msg]
} {
set server_state -1
}
#--Ok, we can stop
} else {
return 1
}
}
# Wait a while before the next try
# ================================
Util::doWait 100
}
return $server_state
}
proc MenuExec::formElmerPostCommand { post_file command_mode} {
global Info Model Timestep
set ep_cmd ""
set ep_header [MenuExec::getElmerPostHeader $post_file]
# Read nof timesteps
# ==================
# 4. item is the nof timesteps
set nof_ts [lindex $ep_header 3]
# Read first variable type and name
# =================================
set tmp [split $ep_header ":"]
set tmp_len [llength $tmp]
#-Last item is the 1. block is the type of the first variable
set ep_var1_type [lindex [lindex $tmp 0] end]
#-If we have a single variable
if { $tmp_len == 2 } {
set ep_var1_name [join [lindex $tmp 1] ]
#-All but the last items in the 2. block define the name of the first variable
} else {
set end_pos [llength [lindex $tmp 1]]
incr end_pos -2
set ep_var1_name [join [lrange [lindex $tmp 1] 0 $end_pos]]
}
#-For a vector type, abs-value is always defined, we
# start with it
if { "vector" == [string tolower $ep_var1_type] } {
append ep_var1_name "_abs"
}
# Timestep info
# =============
#---Transient problem: start with the first timestep
if { $Timestep(SIMULATION_TYPE) == "transient" } {
set step_info "1 1 1"
#---Steady state problem: start with the last timestep
} elseif { $nof_ts != "" } {
set step_info "$nof_ts $nof_ts 1"
} else {
set step_info ""
}
# File info
# =========
set file_info "readfile "
append file_info \\\"$post_file\\\"
append file_info " "
# Write ep-command
# ================
#---Start
if { $command_mode == "start" } {
#-Windows start
if { $Info(platform) == "windows" } {
set ep_cmd " $step_info;"
#-Unix start
} else {
set ep_cmd " $step_info;"
append ep_cmd "set DisplayStyle(ColorMesh) 1;"
append ep_cmd "set MeshStyle 1;"
append ep_cmd "set MeshColor $ep_var1_name;"
append ep_cmd "set DisplayStyle(ColorScale) 1;"
append ep_cmd "set ColorScaleStyle 1;"
append ep_cmd "set ColorScaleColor $ep_var1_name;"
append ep_cmd "set ColorScaleX -0.8;"
append ep_cmd "set ColorScaleY -0.95;"
append ep_cmd "set ColorScaleDecimals 4;"
append ep_cmd "UpdateObject;"
append ep_cmd "mesh_edit;" ;# Open ColorMeshEdit-panel
#append ep_cmd "colscale_edit;" ;# Open ColorScaleEdit-panel
append ep_cmd "time_set_loop;" ;# Update time value in TimeStep-loop panel (if possibly open)
append ep_cmd "display;"
}
#---Init
} elseif { $command_mode == "init" } {
#-Windows init
if { $Info(platform) == "windows" } {
append ep_cmd "set DisplayStyle(ColorMesh) 1;"
append ep_cmd "set MeshStyle 1;"
append ep_cmd "set MeshColor $ep_var1_name;"
append ep_cmd "set DisplayStyle(ColorScale) 1;"
append ep_cmd "set ColorScaleStyle 1;"
append ep_cmd "set ColorScaleColor $ep_var1_name;"
append ep_cmd "set ColorScaleX -0.8;"
append ep_cmd "set ColorScaleY -0.95;"
append ep_cmd "set ColorScaleDecimals 4;"
append ep_cmd "UpdateObject;"
append ep_cmd "mesh_edit;" ;# Open ColorMeshEdit-panel
#append ep_cmd "colscale_edit;" ;# Open ColorScaleEdit-panel
append ep_cmd "time_set_loop;" ;# Update time value in TimeStep-loop panel (if possibly open)
append ep_cmd "display;"
#-Unix init (do nothing!)
} else {
set ep_cmd ""
}
#---Refresh
} elseif { $command_mode == "refresh" } {
set ep_cmd $file_info
append ep_cmd "$step_info;"
append ep_cmd "time_set_loop;" ;# Update time value in TimeStep-loop panel (if possibly open)
append ep_cmd "display;"
}
# Return command
# ==============
return $ep_cmd
}
# Elmerpost commands delivered using a file
# (Not in use)
#
proc MenuExec::formElmerPostCommandFile {post_file} {
global Model Timestep
set msg ""
set channel_id -1
set cmd_file [file join $ModelProperty(LOG_DIRECTORY,absolute) "ELMERPOST_COMMAND_FILE"]
if { [catch { set channel_id [open $cmd_file "w"] } msg] } {
return ""
}
set ep_header [MenuExec::getElmerPostHeader $post_file]
#---Read nof timesteps
# 4. item is the nof timesteps
set nof_ts [lindex $ep_header 3]
#---Read first variable type and name
set tmp [split $ep_header ":"]
set tmp_len [llength $tmp]
# last item is the 1. block is the type of the first variable
set ep_var1_type [lindex [lindex $tmp 0] end]
# If we have a single variable
if { $tmp_len == 2 } {
set ep_var1_name [join [lindex $tmp 1] ]
# All but the last items in the 2. block define the name of the first variable
} else {
set end_pos [llength [lindex $tmp 1]]
incr end_pos -2
set ep_var1_name [join [lrange [lindex $tmp 1] 0 $end_pos]]
}
# For a vector type, abs-value is always defined, we
# start with it
if { "vector" == [string tolower $ep_var1_type] } {
append ep_var1_name "_abs"
}
#---Tansient problem: start with the first timestep
if { $Timestep(SIMULATION_TYPE) == "transient" } {
set step_info "1 1 1"
#---Steady state problem: start with the last timestep
} elseif { $nof_ts != "" } {
set step_info "$nof_ts $nof_ts 1"
} else {
set step_info ""
}
#---Write ep-command file
puts $channel_id "readfile \"$post_file\" $step_info;"
puts $channel_id "set DisplayStyle(ColorMesh) 1;"
puts $channel_id "set MeshStyle 1;"
puts $channel_id "set MeshColor $ep_var1_name;"
puts $channel_id "set DisplayStyle(ColorScale) 1;"
puts $channel_id "set ColorScaleStyle 1;"
puts $channel_id "set ColorScaleColor $ep_var1_name;"
puts $channel_id "set ColorScaleX -0.8;"
puts $channel_id "set ColorScaleY -0.95;"
puts $channel_id "set ColorScaleDecimals 4;"
puts $channel_id "UpdateObject;"
puts $channel_id "mesh_edit;"
puts $channel_id "time-set_loop;"
#puts $channel_id "colscale_edit;"
close $channel_id
return $cmd_file
}
#####################################################################
#
# MODEL DIRECTORY AND FILE utilities
#
#####################################################################
# Read color table file (via cpp)
#
proc MenuExec::readColorFile { {type "front"} } {
global Info Model ModelProperty
set path ""
set fn "rgb.txt"
set places {ELMER_FRONT_BUILD_LIB ELMER_FRONT_INSTALL_LIB}
#-Search in Front-lib
#
if { $type == "front" } {
if { [info exists Info(ELMER_FRONT_HOME)] &&
$Info(ELMER_FRONT_HOME) != ""
} {
set path [file join $Info(ELMER_FRONT_HOME) lib]
}
} elseif {$type == "elmer"} {
foreach place $places {
if { [info exists Info($place)] && $Info($place) != "" } {
set path [file join $Info($place) $fn]
if { [file exist $path] } {
set path $Info($place)
}
}
}
#-Search in elmer-user's home directory
#
} elseif { $type == "user" } {
set path $Info(ELMER_USER_HOME)
#-Search in model file directory
#
} elseif { $type == "model" } {
if { $ModelProperty(MODEL_DIRECTORY) != "" } {
set path $ModelProperty(MODEL_DIRECTORY,absolute)
}
}
# Read color table file if file found
#
if { $path != "" } {
set path [file join $path $fn]
if { [file exist $path] } {
Util::cpp_exec readColorFile $path
}
}
}
# Check if a Matc-file is found in a predefined directory and read the file
# via cpp call
#
# NOTE: File name must match exactly to "matc.txt" !!!
#
proc MenuExec::readMatcFile { {type "front"} } {
global Info Model ModelProperty
set path ""
set fn "matc.txt"
#-Search in elmer home directory
#
if { $type == "elmer" } {
set path $Info(ELMER_FRONT_HOME)
#-Search in elmer-user's home directory
#
} elseif { $type == "user" } {
set path $Info(ELMER_USER_HOME)
#-Search in model file directory
#
} elseif { $type == "model" } {
if { $ModelProperty(MODEL_DIRECTORY) != "" } {
set path $ModelProperty(MODEL_DIRECTORY,absolute)
}
}
# Read Matc file if file found
#
if { $path != "" } {
set path [file join $path $fn]
if { [file exist $path] } {
Util::cpp_exec readMatcFile $path
}
}
}
# Get Mesh2D input file name (mif-file) for the model
#
proc MenuExec::getMeshInputFileName {} {
global ModelProperty
set mif_name $ModelProperty(MODEL_NAME)
append mif_name ".mif"
return $mif_name
}
# Get filename for a mesh related file (like elmerpost file) for the model
#
proc MenuExec::getMeshRelatedFiles { mesh_names file_var {absolute 1} } {
global Solver
set files ""
foreach mesh_name $mesh_names {
set fname [MenuExec::getMeshRelatedFile $mesh_name $file_var]
# Absolute path
if { $absolute } {
lappend files $fname
# Meshname + filename (like Mesh1/CircleInBox.ep)
} else {
set fn [file tail $fname]
set mn [lindex [file split [file dirname $fname] ] end]
lappend files [file join $mn $fn]
}
}
return $files
}
# Absolute path for mesh related files like
# GebhardtFactors and ViewFactors
# NOTE: Datafile is suppoused to have all relevant data
# in variable field, no paramter line i schecked
# (perhaps this should be changed to work via parameter
# ids?)
#
proc MenuExec::getMeshRelatedFile { mesh_name file_var} {
global Datafile Info ModelProperty
if { $mesh_name == "" ||
![info exists Datafile($file_var)]
} {
return ""
}
set fname $Datafile($file_var)
# If fname is not relative, we use it as it is
if { "relative" != [file pathtype $fname] } {
return $fname
}
# If results' directory given,use it as thebase, add the meshname
if { $ModelProperty(RESULTS_DIRECTORY) != "" } {
return [file join $ModelProperty(RESULTS_DIRECTORY,absolute) \
$mesh_name \
$fname]
}
# Default solver output directory, add the meshname
return [file join $ModelProperty(MODEL_DIRECTORY,absolute) \
$Info(meshDirectoryName) \
$mesh_name \
$fname ]
}
# Get absolute path name for the solver's mesh file' header
# Solver defined by the system and subsystem indices
#
proc MenuExec::getSolverMeshHeaderFile {system_index subsystem_index} {
global Info ModelProperty
set mname [MenuExec::getSolverMeshName $system_index $subsystem_index]
if { $mname == "" } {
return ""
}
# Add paths
return [file join $ModelProperty(MODEL_DIRECTORY,absolute) \
$Info(meshDirectoryName) \
$mname \
"mesh.header"]
}
# Get mesh file name for the solver
# Solver define by the system and subsystem indices
# NOTE: This is in fact a directory name under MESHDIR, but
# no path information is return!
#
proc MenuExec::getSolverMeshName {system_index subsystem_index} {
global Info Solver SolverSystem
set sid [lindex $SolverSystem($system_index,ids) $subsystem_index]
if { $sid == $Info(NO_INDEX) || $sid == "" } {
return ""
}
return [DataField::getFieldValue Solver $sid MESH]
}
# Absolute path name for a solver's mesh directory
# Solver identified by solver id
#
proc MenuExec::getSolverMeshDirectory { sid } {
global Info ModelProperty Solver
if { $sid == $Info(NO_INDEX) || $solver_id == "" } {
return ""
}
# Get solver mesh name
set mesh_name [DataField::getFieldValue Solver $sid MESH]
# Add paths
return [file join $ModelProperty(MODEL_DIRECTORY,absolute) \
$Info(meshDirectoryName) \
$mesh_name ]
}
proc MenuExec::getSolverMeshDirectories {} {
global Solver
set dirs ""
foreach sid $Solver(activeIds) {
lappend dirs [MenuExec::getSolverMeshDirectory $id]
}
return $dirs
}
proc MenuExec::getSolverResultFileEquations {result_file} {
global Equation Solver
set equations ""
set mesh [lindex [file split [file dirname $result_file] ] end]
foreach id $Solver(activeIds) {
set smname [DataField::getFieldValue Solver $id MESH]
if { $smname == "" || $smname == $mesh } {
set eq_var [DataField::fieldNameSifToGui [DataField::getFieldValue Solver $id EQUATION]]
if { ![info exists Equation($eq_var)] } {
continue
}
set dsp_name [DataField::getFieldProperty Equation $eq_var StatusLineName]
append equations $dsp_name]
append equations " "
}
}
set equations [string trim $equations]
return [list $equations]
}
proc MenuExec::getSolverResultFiles { file_var {absolute 1} } {
global Solver
set files ""
foreach id $Solver(activeIds) {
set fname [MenuExec::getSolverResultFile $id $file_var]
# Absolute path
if { $absolute } {
lappend files $fname
# Meshname + filename (like Mesh1/CircleInBox.ep)
} else {
set fn [file tail $fname]
set mn [lindex [file split [file dirname $fname] ] end]
lappend files [file join $mn $fn]
}
}
return $files
}
# Absolute path name for solver result files for the solver with "id"
# Use solver-id to get the propeer mesh-name
# Used fex. for Output and Post result files
#
proc MenuExec::getSolverResultFile { solver_id file_var } {
global Info Datafile ModelProperty Solver
if { ![info exists Datafile($file_var)] } {
return ""
}
set fname $Datafile($file_var)
#--If "generic" query, return just filename
#
if { $solver_id == $Info(NO_INDEX) || $solver_id == "" } {
return $fname
}
#--If "generic single solver" query, return value for the first
# active Solver
if { $solver_id == 0 } {
set solver_id [lindex $Solver(activeIds) 0]
return [MenuExec::getSolverResultFile $solver_id $file_var]
}
#--If fname is not relative, we use it as it is
if { "relative" != [file pathtype $fname] } {
return $fname
}
#--Get current base directory for the solver and mesh
set dir_name [MenuExec::getSolverResultDirectory $solver_id]
#--Check that directory exists
set rc [Util::checkAndCreateDirectory2B $dir_name "Solver result files directory"]
if { $rc != "ok" } {
return ""
}
return [file join $dir_name $fname]
}
# Absolute dirdctory path for solver result files for the solver with "id"
# Use solver-id to get the propeer mesh-name
# Used fex. for Output and Post result files
#
proc MenuExec::getSolverResultDirectory { solver_id } {
global Info ModelProperty Solver
#--If "generic single solver" query, return value for the first
# active Solver
if { $solver_id == 0 || $solver_id == $Info(NO_INDEX) || $solver_id == "" } {
set solver_id [lindex $Solver(activeIds) 0]
return [MenuExec::getSolverResultDirectory $solver_id]
}
# Get solver mesh file name (directory in fact!)
set mesh_name [DataField::getFieldValue Solver $solver_id MESH]
if { $mesh_name == "" } {
set mesh_name [Solver::getDefaultMesh]
}
#--If result's directory given, use it as the base, add the meshname
if { $ModelProperty(RESULTS_DIRECTORY) != "" } {
return [file join $ModelProperty(RESULTS_DIRECTORY,absolute) \
$mesh_name]
}
# Default solver output directory, add the meshname
return [file join $ModelProperty(MODEL_DIRECTORY,absolute) \
$Info(meshDirectoryName) \
$mesh_name]
}
# Full name for the solver input file
# NOTE: simple filename, model-directory is added
#
proc MenuExec::getSolverInputFile {} {
global Datafile ModelProperty
return [file join $ModelProperty(MODEL_DIRECTORY,absolute) \
$Datafile(SOLVER_INPUT_FILE)]
}
# Full name for the solver reload file
#
proc MenuExec::getSolverReloadFile {} {
global SolverControl ModelProperty
set reload_file [DataField::getFieldValue SolverControl 1 RELOAD_INPUT_FILE]
if { $reload_file == "" } {
return ""
}
return [file join $ModelProperty(MODEL_DIRECTORY,absolute) $reload_file]
}
# Check that directory exists, if not, open
# a display for entry
#
proc MenuExec::checkDirectory {dir title label} {
global Info
if { [file isdirectory $dir] } {
return $dir
}
global tmp_dir
set tmp_dir ""
if { $dir != "" } {
set try_dir [file dirname $dir]
} else {
set try_dir $dir
}
incr Info(directoryEntryId)
set wname ".w$Info(directoryEntryId)"
Widget::dispDirectoryEntry $wname tmp_dir $try_dir $title $label
tkwait variable tmp_dir
set res_dir $tmp_dir
unset tmp_dir
return $res_dir
}
proc MenuExec::getCurrentDirectory {} {
return [pwd]
}
proc MenuExec::setWorkingDirectory { {initial_value ""} } {
global Info Model
if { $initial_value == "" } {
set initial_value $Info(workingDirectory)
}
set title "Set working directory"
set label "Enter directory name"
global wkd ;# Reference var must be global in dispDirectoryEntry!
set wkd ""
incr Info(directoryEntryId)
set wname ".w$Info(directoryEntryId)"
Widget::dispDirectoryEntry $wname wkd $Info(workingDirectory) $title $label
tkwait variable wkd
if { $wkd != "!cancel!" } {
#-If ok value
if { [file isdirectory $wkd] } {
set Info(workingDirectory) $wkd
Message::showMessage "Working directory: $Info(workingDirectory)"
#-Invalid directory name
} else {
set msg [list "A non existing directory name!\n\n$wkd\n\n" \
$Info(anywayOk) ]
set Info(messageIcon) error
set result [ Message::dispOkCancelMessage $msg ]
# Try again
if { $result != "cancel" } {
MenuExec::setWorkingDirectory $wkd
# Close entry
} else {
unset wkd
return
}
}
# Put current working directory as default model directory (if not defined)
ModelProperty::setDefaultDirectoryValue MODEL_DIRECTORY $Info(workingDirectory)
set Model(CAD_OPEN_DIR) $Info(workingDirectory)
set Model(MESH_OPEN_DIR) $Info(workingDirectory)
set Model(EMF_OPEN_DIR) $Info(workingDirectory)
# Set pwd
Util::cpp_exec setCurrentDirectory $Info(workingDirectory)
}
unset wkd
}
# Apply user settings values to problem directories
#
proc MenuExec::applySettingsToCaseDirectories { {force_to_settings 0 } {show_usage_message 1} } {
global Info Model ModelProperty UserSetting
# Model directory
# ===============
if { $force_to_settings ||
$ModelProperty(MODEL_NAME) == "" ||
$ModelProperty(MODEL_DIRECTORY) == ""
} {
set ModelProperty(MODEL_DIRECTORY) $UserSetting(DEFAULT_MODEL_DIRECTORY)
}
set ModelProperty(MODEL_DIRECTORY,absolute) [Util::makePathAbsolute $ModelProperty(MODEL_DIRECTORY)]
# Default for log directory (is always needed!)
# =========================
set def_val $Info(defaultLogDirectoryName)
ModelProperty::setDefaultDirectoryValue LOG_DIRECTORY $def_val
# Other problem directories
# =========================
set dir_names { INCLUDE_PATH RESULTS_DIRECTORY LOG_DIRECTORY }
foreach vn $dir_names {
# Store settings values to settings-variable
set ModelProperty($vn,settings) $UserSetting(DEFAULT_$vn)
# If value is missing or should force anyway
#
if { $force_to_settings ||
( $ModelProperty($vn) == "" &&
$UserSetting(DEFAULT_$vn) != ""
)
} {
set ModelProperty($vn) $UserSetting(DEFAULT_$vn)
set ModelProperty($vn,valueType) [ModelProperty::valueTypeMenuVar2Key settings]
}
}
# =================
#-Check new values
ModelProperty::checkCaseDirectoryValues
# Show info
# =========
if { $show_usage_message } {
MenuExec::showCaseDirectoriesMessage
}
}
# Show current values for problem directories
# NOTE: If model name is not yet defined, we show
# only models-directory value
#
proc MenuExec::showCaseDirectoriesMessage {} {
global Info ModelProperty Model
set clr $Info(remMsgColor)
Message::showMessage "Model dir = $ModelProperty(MODEL_DIRECTORY,absolute)" $clr
if { $Model(CASE_NAME) != "" } {
Message::showMessage "Inc path = $ModelProperty(INCLUDE_PATH,absolute)" $clr
Message::showMessage "Res dir = $ModelProperty(RESULTS_DIRECTORY,absolute)" $clr
Message::showMessage "Log dir = $ModelProperty(LOG_DIRECTORY,absolute)" $clr
Message::showMessage ""
}
}
#####################################################################
#
# WINDOW MENU procs
#
#####################################################################
proc MenuExec::closeAllWindows {} {
global Info
foreach row $Info(windowList) {
set arr [lindex $row 0]
set win [winfo atomname [lindex $row 1]]
set modified 0
upvar #0 $arr theArray
if { ( [info exists theArray(dataChanged)] && $theArray(dataChanged) ) ||
( [info exists theArray(dataModified)] && $theArray(dataModified) )
} {
set modified 1
}
catch {MenuExec::closePanel $arr $win $modified}
}
}
proc MenuExec::closeUnmodifiedWindows {} {
global Info
foreach row $Info(windowList) {
set arr [lindex $row 0]
set win [winfo atomname [lindex $row 1]]
upvar #0 $arr theArray
set modified 0
if { ( [info exist theArray(dataChanged)] && $theArray(dataChanged) ) ||
( [info exist theArray(dataModified)] && $theArray(dataModified) )
} {
set modified 1
}
if { !$modified} {
catch {MenuExec::closePanel $arr $win $modified}
}
}
}
proc MenuExec::closePanel {globArray win is_modified} {
global Common
set is_standard_panel 0
#-Check if panel is one of the standard panels, they
# need special handling for the cancel
foreach arr $Common(standardPanelArries) {
if { $arr == $globArray } {
set is_standard_panel 1
break
}
}
#-Standard panel cancel
if {$is_standard_panel} {
set tmp $Common(currentStandardPanel)
set Common(currentStandardPanel) $globArray
if {$is_modified} {
StdPanelExec::panelCancel $win $globArray
} else {
StdPanelExec::panelOk $globArray
}
set Common(currentStandardPanel) $tmp
#-Other cancel
} else {
if {$is_modified} {
execNsProc $globArray panelCancel $win
} else {
execNsProc $globArray panelOk $win
}
}
}
#####################################################################
#
# HELP MENU procs
#
#####################################################################
proc MenuExec::helpIndex {} {
Message::dispOkMessage "Sorry, not yet implemented!"
}
proc MenuExec::helpContents {} {
Message::dispOkMessage "Sorry, not yet implemented!"
}
# ecif_tk_procsMenu.tcl
# ********************
|