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
|
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/****************************************************************************/
/* */
/* File: assemble.c */
/* */
/* Purpose: assemble num procs */
/* */
/* */
/* Author: Christian Wieners */
/* Institut fuer Computeranwendungen III */
/* Universitaet Stuttgart */
/* Pfaffenwaldring 27 */
/* 70569 Stuttgart */
/* email: ug@ica3.uni-stuttgart.de */
/* */
/* History: November 29, 1996 */
/* */
/* Remarks: */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* include files */
/* system include files */
/* application include files */
/* */
/****************************************************************************/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "general.h"
#include "debug.h"
#include "ugdevices.h"
#include "gm.h"
#include "cw.h"
#include "disctools.h"
#include "np.h"
#include "ugdevices.h"
#include "assemble.h"
USING_UG_NAMESPACES
/****************************************************************************/
/* */
/* defines in the following order */
/* */
/* compile time constants defining static data size (i.e. arrays) */
/* other constants */
/* macros */
/* */
/****************************************************************************/
#define MAX_PA 2
#define PA_VT(pa) ((pa)->vt)
#define PA_VD_g(pa) ((pa)->gridvel)
#define PA_NASS(pa) ((pa)->nass)
#define PA_SUB(pa,i) ((pa)->sub[i])
#define PA_ASS(pa,i) ((pa)->ass[i])
#define PA_DT(pa) ((pa)->dt)
#define PA_DT_OLD(pa) ((pa)->dt_old)
#define PA_VD_o(pa) ((pa)->old)
/****************************************************************************/
/* */
/* data structures used in this source file (exported data structures are */
/* in the corresponding include file!) */
/* */
/****************************************************************************/
typedef struct
{
NP_NL_ASSEMBLE pa; /* class for nonlinear ass routines */
/* additional data */
VEC_TEMPLATE *vt; /* vector template for part decomp */
VECDATA_DESC *gridvel; /* velocity of moving grid (iff) */
INT nass; /* number of part assembling numprocs */
INT sub[MAX_PA]; /* sub vector of vt for part decomp */
NP_NL_PARTASS *ass[MAX_PA]; /* pointers to part assembling numprocs */
} NP_PA_NL;
typedef struct
{
NP_T_ASSEMBLE pa; /* class for nonlinear ass routines */
/* additional data */
VEC_TEMPLATE *vt; /* vector template for part decomp */
VECDATA_DESC *gridvel; /* velocity of moving grid (iff) */
VECDATA_DESC *old; /* old solution */
INT nass; /* number of part assembling numprocs */
INT sub[MAX_PA]; /* sub vector of vt for part decomp */
NP_T_PARTASS *ass[MAX_PA]; /* pointers to part assembling numprocs */
DOUBLE dt; /* time step */
DOUBLE dt_old; /* old time step */
} NP_PA_T;
/* TODO (HRR 971118): remove old part assemble structs (2 items) */
typedef struct
{
NP_NL_ASSEMBLE pa; /* class for nonlinear ass routines */
/* additional data */
INT nass; /* number of part assembling numprocs */
NP_NL_ASSEMBLE *ass[MAX_PA]; /* pointers to part assembling numprocs */
} OLD_NP_NL_PARTASS;
typedef struct
{
NP_T_ASSEMBLE pa; /* class for nonlinear ass routines */
/* additional data */
INT nass; /* number of part assembling numprocs */
NP_T_ASSEMBLE *ass[MAX_PA]; /* pointers to part assembling numprocs */
} OLD_NP_T_PARTASS;
/****************************************************************************/
/* */
/* definition of exported global variables */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* definition of variables global to this source file only (static!) */
/* */
/****************************************************************************/
static DOUBLE *mat,*sol,*def;
static INT *vecskip;
static char pp_action_str[64];
REP_ERR_FILE;
/* RCS string */
static char RCS_ID("$Header$",UG_RCS_STRING);
/****************************************************************************/
/* */
/* forward declarations of functions used before they are defined */
/* */
/****************************************************************************/
/****************************************************************************/
/*D
assemble - ug offers several classes of assmbling 'num_proc's
DESCRIPTION:
The classes defined in ug are:~
. NP_ASSEMBLE - type definition for assembling
. NP_NL_ASSEMBLE - type definition for nonlinear assembling
. NP_LOCAL_ASSEMBLE - type definition for local assembling
. NP_T_ASSEMBLE - type definition for time dependent assembling
For realizations of assembling num_procs (which are defined in the problem
classes) try typing
.n help assemble $k
SEE ALSO:
'num_proc', 'NP_ASSEMBLE', 'NP_NL_ASSEMBLE', 'NP_LOCAL_ASSEMBLE', 'NP_T_ASSEMBLE'
D*/
/****************************************************************************/
/****************************************************************************/
/*D
NP_ASSEMBLE - type definition for assembling
DESCRIPTION:
This numproc type is used for the description of assembling.
It can be called by the given interface from a nonlinear solver.
Initializing the data is optional; it can be done with
'INT NPAssembleInit (NP_ASSEMBLE *theNP, INT argc , char **argv);'
This routine returns 'EXECUTABLE' if the initizialization is complete
and 'ACTIVE' else.
The data can be displayed and the num proc can be executed by
'INT NPAssembleDisplay (NP_ASSEMBLE *theNP);'
'INT NPAssembleExecute (NP_BASE *theNP, INT argc , char **argv);'
.vb
struct np_assemble {
NP_BASE base; // inherits base class
// data (optinal, necessary for calling the generic execute routine)
VECDATA_DESC *x; // solution
VECDATA_DESC *b; // defect
MATDATA_DESC *A; // matrix
// functions
INT (*PreProcess)
(struct np_assemble *, // pointer to (derived) object
INT, // level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // rhs vector
MATDATA_DESC *, // matrix
INT *); // result
INT (*Assemble)
(struct np_assemble *, // pointer to (derived) object
INT, // level
VECDATA_DESC *, // current solution (initial)
VECDATA_DESC *, // right hand side
MATDATA_DESC *, // matrix
INT *); // result
INT (*PostProcess)
(struct np_assemble *, // pointer to (derived) object
INT, // level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // defect vector
MATDATA_DESC *, // matrix
INT *); // result
};
typedef struct np_assemble NP_ASSEMBLE;
.ve
SEE ALSO:
'num_proc', 'NP_NL_ASSEMBLE', 'NP_LOCAL_ASSEMBLE', 'NP_T_ASSEMBLE'
D*/
/****************************************************************************/
INT NS_DIM_PREFIX NPAssembleInit (NP_BASE *theNP, INT argc , char **argv)
{
NP_ASSEMBLE *np;
np = (NP_ASSEMBLE *) theNP;
np->A = ReadArgvMatDesc(np->base.mg,"A",argc,argv);
np->x = ReadArgvVecDesc(np->base.mg,"x",argc,argv);
np->b = ReadArgvVecDesc(np->base.mg,"b",argc,argv);
if ((np->A == NULL) || (np->b == NULL) || (np->x == NULL))
return(NP_ACTIVE);
return(NP_EXECUTABLE);
}
INT NS_DIM_PREFIX NPAssembleDisplay (NP_BASE *theNP)
{
NP_ASSEMBLE *np;
np = (NP_ASSEMBLE *) theNP;
if ((np->A == NULL) && (np->b == NULL) && (np->x == NULL))
return(0);
UserWrite("symbolic user data:\n");
if (np->A != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"A",ENVITEM_NAME(np->A));
if (np->b != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"b",ENVITEM_NAME(np->b));
if (np->x != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"x",ENVITEM_NAME(np->x));
UserWrite("\n");
return(0);
}
INT NS_DIM_PREFIX NPAssembleExecute (NP_BASE *theNP, INT argc , char **argv)
{
NP_ASSEMBLE *np;
INT result,level;
np = (NP_ASSEMBLE *) theNP;
level = CURRENTLEVEL(theNP->mg);
if (np->x == NULL) {
PrintErrorMessage('E',"NPAssembleExecute","no vector x");
return (1);
}
if (np->b == NULL) {
PrintErrorMessage('E',"NPAssembleExecute","no vector b");
return (1);
}
if (np->A == NULL) {
PrintErrorMessage('E',"NPAssembleExecute","no matrix A");
return (1);
}
if (ReadArgvOption("i",argc,argv)) {
if (np->PreProcess == NULL) {
PrintErrorMessage('E',"NPAssembleExecute","no PreProcess");
return (1);
}
if ((*np->PreProcess)(np,level,np->x,np->b,np->A,&result)) {
UserWriteF("NPAssembleExecute: PreProcess failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("a",argc,argv)) {
if (np->Assemble == NULL) {
PrintErrorMessage('E',"NPAssembleExecute","no Assemble");
return (1);
}
if ((*np->Assemble)(np,level,np->x,np->b,np->A,&result)) {
UserWriteF("NPAssembleExecute: Assemble failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("p",argc,argv)) {
if (np->PostProcess == NULL) {
PrintErrorMessage('E',"NPAssembleExecute","no PostProcess");
return (1);
}
if ((*np->PostProcess)(np,level,np->x,np->b,np->A,&result)) {
UserWriteF("NPAssembleExecute: PostProcess failed, error code %d\n",
result);
return (1);
}
}
return(0);
}
/****************************************************************************/
/*D
NP_NL_ASSEMBLE - type definition for nonlinear assembling
DESCRIPTION:
This numproc type is used for the description of assembling.
It can be called by the given interface from a nonlinear solver.
Initializing the data is optional; it can be done with
'INT NPNLAssembleInit (NP_BASE *theNP, INT argc , char **argv);'
This routine returns 'EXECUTABLE' if the initizialization is complete
and 'ACTIVE' else.
The data can be displayed and the num proc can be executed by
'INT NPNLAssembleDisplay (NP_BASE *theNP);'
'INT NPNLAssembleExecute (NP_BASE *theNP, INT argc , char **argv);'
.vb
struct np_nl_assemble {
NP_BASE base; // inherits base class
// data (optinal, necessary for calling the generic execute routine)
VECDATA_DESC *x; // solution
VECDATA_DESC *c; // correction
VECDATA_DESC *b; // defect
MATDATA_DESC *A; // matrix
// functions
INT (*PreProcess)
(struct np_nl_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
VECDATA_DESC *, // solution vector
INT *); // result
INT (*NLAssembleSolution)
(struct np_nl_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
VECDATA_DESC *, // solution vector
INT *); // result
INT (*NLAssembleDefect)
(struct np_nl_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // defect vector
MATDATA_DESC *, // matrix
INT *); // result
INT (*NLAssembleMatrix)
(struct np_nl_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
VECDATA_DESC *, // current solution (initial)
VECDATA_DESC *, // defect for current solution
VECDATA_DESC *, // correction to be computed
MATDATA_DESC *, // matrix
INT *); // result
INT (*PostProcess)
(struct np_nl_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // defect vector
MATDATA_DESC *, // matrix
INT *); // result
};
typedef struct np_nl_assemble NP_NL_ASSEMBLE;
.ve
SEE ALSO:
'num_proc', 'NP_ASSEMBLE', 'NP_LOCAL_ASSEMBLE', 'NP_T_ASSEMBLE'
D*/
/****************************************************************************/
INT NS_DIM_PREFIX NPNLAssembleInit (NP_BASE *theNP, INT argc , char **argv)
{
NP_NL_ASSEMBLE *np;
np = (NP_NL_ASSEMBLE *) theNP;
np->A = ReadArgvMatDesc(np->base.mg,"A",argc,argv);
np->x = ReadArgvVecDesc(np->base.mg,"x",argc,argv);
np->c = ReadArgvVecDesc(np->base.mg,"c",argc,argv);
np->b = ReadArgvVecDesc(np->base.mg,"b",argc,argv);
if ((np->A == NULL) || (np->b == NULL) || (np->x == NULL))
return(NP_ACTIVE);
return(NP_EXECUTABLE);
}
INT NS_DIM_PREFIX NPNLAssembleDisplay (NP_BASE *theNP)
{
NP_NL_ASSEMBLE *np;
np = (NP_NL_ASSEMBLE *) theNP;
if ((np->A == NULL) && (np->b == NULL) && (np->x == NULL))
return(0);
UserWrite("symbolic user data:\n");
if (np->A != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"A",ENVITEM_NAME(np->A));
if (np->b != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"b",ENVITEM_NAME(np->b));
if (np->x != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"x",ENVITEM_NAME(np->x));
if (np->c != NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"c",ENVITEM_NAME(np->x));
UserWrite("\n");
return(0);
}
INT NS_DIM_PREFIX NPNLAssembleExecute (NP_BASE *theNP, INT argc , char **argv)
{
NP_NL_ASSEMBLE *np;
INT result,level;
np = (NP_NL_ASSEMBLE *) theNP;
level = CURRENTLEVEL(theNP->mg);
if (np->x == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no vector x");
return (1);
}
if (np->b == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no vector b");
return (1);
}
if (np->A == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no matrix A");
return (1);
}
if (ReadArgvOption("i",argc,argv)) {
if (np->PreProcess == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no PreProcess");
return (1);
}
if ((*np->PreProcess)(np,0,level,np->x,&result)) {
UserWriteF("NPNLAssembleExecute: PreProcess failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("s",argc,argv)) {
if (np->NLAssembleSolution == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no NLAssembleSolution");
return (1);
}
if ((*np->NLAssembleSolution)(np,0,level,np->x,&result)) {
UserWriteF("NPNLAssembleExecute: NLAssembleSolution failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("d",argc,argv)) {
if (np->NLAssembleDefect == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no NLAssembleDefect");
return (1);
}
if ((*np->NLAssembleDefect)(np,0,level,np->x,np->b,np->A,&result)) {
UserWriteF("NPNLAssembleExecute: NLAssembleDefect failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("M",argc,argv)) {
if (np->NLAssembleMatrix == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no NLAssembleMatrix");
return (1);
}
if ((*np->NLAssembleMatrix)(np,0,level,np->x,np->b,np->c,np->A,&result)) {
UserWriteF("NPNLAssembleExecute: NLAssembleMatrix failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("p",argc,argv)) {
if (np->PostProcess == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no PostProcess");
return (1);
}
if ((*np->PostProcess)(np,0,level,np->x,np->b,np->A,&result)) {
UserWriteF("NPNLAssembleExecute: PostProcess failed, error code %d\n",
result);
return (1);
}
}
return(0);
}
/****************************************************************************/
/*D
NP_LOCAL_ASSEMBLE - type definition for local assembling
DESCRIPTION:
This numproc type is used for the description of local assembling.
It can be called by the given interface from a nonlinear multigrid
solver.
Initializing the data is optional; it can with
'INT NPLocalAssembleInit (NP_LOCAL_ASSEMBLE *theNP, INT argc , char **argv);'
This routine returns 'EXECUTABLE' if the initizialization is complete
and 'ACTIVE' else.
The data can be displayed and the num proc can be executed by
'INT NPLocalAssembleDisplay (NP_LOCAL_ASSEMBLE *theNP);'
'INT NPAssembleExecute (NP_BASE *theNP, INT argc , char **argv);'
The interface functions 'LocalAssemblePreProcess', 'LocalAssemble'
'AssembleDefect', 'AssembleMatrix' and 'LocalAssemblePostProcess'
of NP_ASSEMBLE can be constructed by the interface of NP_LOCAL_ASSEMBLE
by
'INT LocalAssembleConstruct (NP_ASSEMBLE *theNP);'
.vb
struct np_local_assemble {
NP_ASSEMBLE assemble; // inherits assemble class
// data
INT galerkin; // Galerkin assembling
// functions
INT (*PreProcess)
(struct np_local_assemble *, // pointer to (derived) object
INT, // level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // defect vector
MATDATA_DESC *, // matrix
DOUBLE **, // local solution
DOUBLE **, // local defect
DOUBLE **, // local matrix
INT **, // local vecskip
INT *); // result
INT (*AssembleLocal)
(ELEMENT *, // pointer to an element
INT *); // result
INT (*AssembleLocalDefect)
(ELEMENT *, // pointer to an element
INT *); // result
INT (*AssembleLocalMatrix)
(ELEMENT *, // pointer to an element
INT *); // result
INT (*PostMatrix)
(struct np_local_assemble *, // pointer to (derived) object
INT, // level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // defect vector
MATDATA_DESC *, // matrix
INT *); // result
INT (*PostProcess)
(struct np_local_assemble *, // pointer to (derived) object
INT, // level
VECDATA_DESC *, // solution vector
VECDATA_DESC *, // defect vector
MATDATA_DESC *, // matrix
INT *); // result
};
typedef struct np_local_assemble NP_LOCAL_ASSEMBLE;
.ve
SEE ALSO:
'num_proc', 'NP_ASSEMBLE', 'NP_NL_ASSEMBLE', 'NP_T_ASSEMBLE'
D*/
/****************************************************************************/
INT NPLocalAssembleInit (NP_LOCAL_ASSEMBLE *np, INT argc , char **argv)
{
if (ReadArgvINT("g",&np->galerkin,argc,argv))
np->galerkin = 0;
return(NPAssembleInit(&np->assemble.base,argc,argv));
}
INT NPLocalAssembleDisplay (NP_LOCAL_ASSEMBLE *np)
{
NPAssembleDisplay(&np->assemble.base);
UserWrite("configuration parameters:\n");
UserWriteF(DISPLAY_NP_FORMAT_SI,"g",(int)np->galerkin);
return(0);
}
INT NPLocalAssemblePostMatrix (NP_LOCAL_ASSEMBLE *theNP, INT level,
VECDATA_DESC *x,
VECDATA_DESC *b, MATDATA_DESC *A, INT *result)
{
INT lev;
#ifdef ModelP
if (a_vector_vecskip(theNP->assemble.base.mg,0,level,x) != NUM_OK)
return (1);
#endif
for (lev=0; lev<=level; lev++)
AssembleDirichletBoundary(GRID_ON_LEVEL(theNP->assemble.base.mg,lev),
A,x,b);
UserWrite(" [d]");
return(0);
}
static INT LocalAssemblePreProcess (NP_ASSEMBLE *theNP, INT level, VECDATA_DESC *x,
VECDATA_DESC *b, MATDATA_DESC *A, INT *result)
{
NP_LOCAL_ASSEMBLE *np;
np = (NP_LOCAL_ASSEMBLE *) theNP;
if ((*np->PreProcess)(np,level,x,b,A,&sol,&def,&mat,&vecskip,result)) {
UserWriteF("PreProcess failed, error code %d\n",result[0]);
return (1);
}
return(0);
}
static INT LocalAssemble (NP_ASSEMBLE *theNP, INT level, VECDATA_DESC *x,
VECDATA_DESC *b, MATDATA_DESC *A, INT *result)
{
NP_LOCAL_ASSEMBLE *np;
MULTIGRID *theMG;
GRID *theGrid;
ELEMENT *theElement;
DOUBLE *mptr[MAX_NODAL_VALUES*MAX_NODAL_VALUES];
DOUBLE *sptr[MAX_NODAL_VALUES];
DOUBLE *rptr[MAX_NODAL_VALUES];
INT i,l,m;
np = (NP_LOCAL_ASSEMBLE *) theNP;
theMG = NP_MG(theNP);
for (l=0; l<=level; l++) {
UserWriteF(" [%d:",l);
theGrid = GRID_ON_LEVEL(theMG,l);
if (dset(theMG,l,l,ALL_VECTORS,b,0.0)!=NUM_OK) NP_RETURN(1,result[0]);
if (dmatset(theMG,l,l,ALL_VECTORS,A,0.0)!=NUM_OK) NP_RETURN(1,result[0]);
CLEAR_VECSKIP_OF_GRID(theGrid);
for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL;
theElement=SUCCE(theElement)) {
if (np->galerkin)
if (NSONS(theElement) > 2) continue;
m = GetElementVVMPtrs(theElement,x,b,A,sptr,rptr,mptr,vecskip);
for (i=0; i<m; i++) sol[i] = *sptr[i];
for (i=0; i<m; i++) def[i] = 0.0;
for (i=0; i<m*m; i++) mat[i] = 0.0;
if ((*np->AssembleLocal)(theElement,result)) {
UserWriteF("AssembleLocal failed for element %d, error code %d\n",
ID(theElement),result[0]);
return (1);
}
for (i=0; i<m; i++) *rptr[i] += def[i];
for (i=0; i<m*m; i++) *mptr[i] += mat[i];
for (i=0; i<m; i++) *sptr[i] = sol[i];
if (OBJT(theElement) == BEOBJ)
SetElementDirichletFlags(theElement,x,vecskip);
}
UserWrite("a]");
}
if (np->PostMatrix != NULL)
if ((*np->PostMatrix)(np,level,x,b,A,result)) {
UserWriteF("(PostMatrix failed, error code %d\n",result[0]);
return (1);
}
UserWrite("\n");
return(0);
}
static INT LocalAssemblePostProcess (NP_ASSEMBLE *theNP, INT level, VECDATA_DESC *x,
VECDATA_DESC *b, MATDATA_DESC *A, INT *result)
{
NP_LOCAL_ASSEMBLE *np;
np = (NP_LOCAL_ASSEMBLE *) theNP;
if (np->PostProcess != NULL)
if ((*np->PostProcess)(np,level,x,b,A,result)) {
UserWriteF("PostProcess failed, error code %d\n",result[0]);
return (1);
}
UserWrite("\n");
return(0);
}
INT NPLocalAssembleConstruct (NP_ASSEMBLE *np)
{
np->PreProcess = LocalAssemblePreProcess;
np->Assemble = LocalAssemble;
np->PostProcess = LocalAssemblePostProcess;
return(0);
}
/****************************************************************************/
/*D
NP_T_ASSEMBLE - type definition for time dependent assembling
DESCRIPTION:
This is the interface for a time dependent problem as it is required
by the tsolver. An NP_T_ASSEMBLE object is never executable, only its
functional interface is used.
.vb
struct np_t_assemble {
NP_BASE base; // inherits base class
// functions
INT (*TAssemblePreProcess) // call at begin of timestep
(struct np_t_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
DOUBLE, // time t_k+1
DOUBLE, // time t_k
DOUBLE, // time t_k-1
VECDATA_DESC *, // (unknown) solution at t_k+1
VECDATA_DESC *, // solution vector at t_k
VECDATA_DESC *, // solution vector at t_k-1
INT *); // result
INT (*TAssembleInitial) // set initial values
(struct np_t_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
DOUBLE, // time value t
VECDATA_DESC *, // solution vector at time t
INT *); // result
INT (*TAssembleSolution) // set dirichlet conditions in sol.
(struct np_t_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
DOUBLE, // time value t
VECDATA_DESC *, // solution vector at time t
INT *); // result
INT (*TAssembleDefect) // accumulate to defect vector
(struct np_t_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
DOUBLE, // time value t
DOUBLE, // scaling for m-term: s_m
DOUBLE, // scaling for a-term: s_a
VECDATA_DESC *, // solution vector y
VECDATA_DESC *, // accumulate s_m*m(t,y)+s_a*a(t,y)
MATDATA_DESC *, // matrix may be handy for Picard
INT *); // result
INT (*TAssembleMatrix) // compute linearization (Jacobian)
(struct np_t_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
DOUBLE, // time value t
DOUBLE, // scaling for a-term: s_a (s_m=1!)
VECDATA_DESC *, // current sol (linearization pt)
VECDATA_DESC *, // defect for current solution
VECDATA_DESC *, // correction to be computed
MATDATA_DESC *, // matrix
INT *); // result
INT (*TAssemblePostProcess) // call after solution t_k+1 known
(struct np_t_assemble *, // pointer to (derived) object
INT, // from level
INT, // to level
DOUBLE, // time t_k+1
DOUBLE, // time t_k
DOUBLE, // time t_k-1
VECDATA_DESC *, // solution t_k+1 (just computed!)
VECDATA_DESC *, // solution vector at t_k
VECDATA_DESC *, // solution vector at t_k-1
INT *); // result
};
typedef struct np_t_assemble NP_T_ASSEMBLE;
.ve
SEE ALSO:
'num_proc', 'NP_ASSEMBLE', 'NP_NL_ASSEMBLE', 'NP_LOCAL_ASSEMBLE'
D*/
/****************************************************************************/
INT NS_DIM_PREFIX NPTAssembleInit (NP_BASE *theNP, INT argc , char **argv)
{
return(NP_ACTIVE);
}
INT NS_DIM_PREFIX NPTAssembleDisplay (NP_BASE *theNP)
{
return(0);
}
INT NS_DIM_PREFIX NPTAssembleExecute (NP_BASE *theNP, INT argc , char **argv)
{
REP_ERR_RETURN(1); /* never executable */
}
/****************************************************************************/
/*D
SetPartassParams - constructor for part assemble parameters
SYNOPSIS:
INT SetPartassParams (PARTASS_PARAMS *pp, DOUBLE s_a, DOUBLE s_m, DOUBLE t, DOUBLE dt, DOUBLE dt_old,
VECDATA_DESC *s, VECDATA_DESC *r, VECDATA_DESC *o,
VECDATA_DESC *c, VECDATA_DESC *g, MATDATA_DESC *A)
PAAMETERS:
. pp - part assemble parameters
. s_a - stiffness matrix scaling factor
. s_m - mass matrix scaling factor
. t - time
. dt - time step
. dt_old - old time step
. s - global solution descriptor
. r - global right hand side descriptor
. o - global old solution descriptor
. c - global correction descriptor
. g - grid velocity descriptor
. A - global stiffness matrix descriptor
DESCRIPTION:
Constructor for part assemble parameters fills components of struct.
LOCATION:
assemble.c
RETURN VALUE:
INT
.n
D*/
/****************************************************************************/
INT NS_DIM_PREFIX SetPartassParams (PARTASS_PARAMS *pp,
DOUBLE s_a, DOUBLE s_m, DOUBLE t, DOUBLE dt, DOUBLE dt_old,
VECDATA_DESC *s, VECDATA_DESC *r, VECDATA_DESC *o,
VECDATA_DESC *c, VECDATA_DESC *g, MATDATA_DESC *A)
{
int i;
memset(pp,0,sizeof(PARTASS_PARAMS));
PP_ACTION(pp) = PARTASS_UNKNOWN;
PP_SCALE_A(pp) = s_a;
PP_SCALE_M(pp) = s_m;
PP_TIME(pp) = t;
PP_DELTA_T(pp) = dt;
PP_OLD_DELTA_T(pp) = dt_old;
PP_ASS_PART(pp) = NO;
PP_MD_A(pp) = A;
PP_MD_A_glob(pp) = A;
PP_VD_s(pp) = s;
PP_VD_s_glob(pp) = s;
PP_VD_s_i(pp) = NULL;
PP_VD_s_co(pp) = NULL;
PP_VD_o(pp) = o;
PP_VD_o_glob(pp) = o;
PP_VD_c(pp) = c;
PP_VD_c_glob(pp) = c;
PP_VD_r(pp) = r;
PP_VD_r_glob(pp) = r;
PP_VD_gridvel(pp) = g;
for (i=0; i<NVECTYPES; i++)
PP_SKIP(pp)[i] =
PP_CO_SKIP(pp)[i] = 0;
return (0);
}
/****************************************************************************/
/*D
SetPartassParamsX - create part sub descriptors and set part assemble parameters
SYNOPSIS:
INT SetPartassParamsX (PARTASS_PARAMS *pp, const VEC_TEMPLATE *vt, INT sub,
DOUBLE s_a, DOUBLE s_m, DOUBLE t, DOUBLE dt, DOUBLE dt_old, VECDATA_DESC *s,
VECDATA_DESC *r, VECDATA_DESC *o, VECDATA_DESC *c, VECDATA_DESC *g, MATDATA_DESC *A)
PAAMETERS:
. pp - part assemble parameters
. vt - vector template
. sub - sub descriptor of vt
. s_a - stiffness matrix scaling factor
. s_m - mass matrix scaling factor
. t - time
. dt - time step
. dt_old - old time step
. s - global solution descriptor
. r - global right hand side descriptor
. o - global old solution descriptor
. c - global correction descriptor
. g - grid velocity descriptor
. A - global stiffness matrix descriptor
DESCRIPTION:
This function creates the part sub descriptors and sets the part assemble parameters.
LOCATION:
'assemble.c'
RETURN VALUE:
INT
.n 0: ok
.n else: error
D*/
/****************************************************************************/
INT NS_DIM_PREFIX SetPartassParamsX (PARTASS_PARAMS *pp, const VEC_TEMPLATE *vt, INT sub,
DOUBLE s_a, DOUBLE s_m, DOUBLE t, DOUBLE dt, DOUBLE dt_old,
VECDATA_DESC *s, VECDATA_DESC *r, VECDATA_DESC *o,
VECDATA_DESC *c, VECDATA_DESC *g, MATDATA_DESC *A)
{
/* checks */
if (s==NULL)
REP_ERR_RETURN (1);
if (vt==NULL)
REP_ERR_RETURN (1);
if (sub<0 || sub>=VT_NSUB(vt))
REP_ERR_RETURN (1);
/* clear */
memset(pp,0,sizeof(PARTASS_PARAMS));
/* general */
PP_ASS_PART(pp) = TRUE;
PP_ACTION(pp) = PARTASS_UNKNOWN;
PP_SCALE_A(pp) = s_a;
PP_SCALE_M(pp) = s_m;
PP_TIME(pp) = t;
PP_DELTA_T(pp) = dt;
PP_OLD_DELTA_T(pp) = dt_old;
PP_MD_A_glob(pp) = A;
PP_VD_s_glob(pp) = s;
PP_VD_o_glob(pp) = o;
PP_VD_c_glob(pp) = c;
PP_VD_r_glob(pp) = r;
PP_VD_gridvel(pp) = g;
/* decompose descriptors */
if (!VDmatchesVT(s,vt))
REP_ERR_RETURN(1);
if (VDsubDescFromVT(s,vt,sub,&PP_VD_s(pp)))
REP_ERR_RETURN(1)
if (VDinterfaceDesc(s,PP_VD_s(pp),&PP_VD_s_i(pp)))
REP_ERR_RETURN(1)
if (VDinterfaceCoDesc(s,PP_VD_s(pp),&PP_VD_s_ico(pp)))
REP_ERR_RETURN(1)
if (VDCoDesc(s,PP_VD_s(pp),&PP_VD_s_co(pp)))
REP_ERR_RETURN(1)
if (ComputePartVecskip(s,PP_VD_s(pp),PP_SKIP(pp),PP_CO_SKIP(pp)))
REP_ERR_RETURN(1)
if (o!=NULL)
{
if (!VDmatchesVT(o,vt))
REP_ERR_RETURN(1);
if (VDsubDescFromVT(o,vt,sub,&PP_VD_o(pp)))
REP_ERR_RETURN(1);
}
if (c!=NULL)
{
if (!VDmatchesVT(c,vt))
REP_ERR_RETURN(1);
if (VDsubDescFromVT(c,vt,sub,&PP_VD_c(pp)))
REP_ERR_RETURN(1);
}
if (r!=NULL)
{
if (!VDmatchesVT(r,vt))
REP_ERR_RETURN(1);
if (VDsubDescFromVT(r,vt,sub,&PP_VD_r(pp)))
REP_ERR_RETURN(1);
}
if (A!=NULL)
{
if (!MDmatchesVT(A,vt))
REP_ERR_RETURN(1);
if (MDsubDescFromVT(A,vt,sub,&PP_MD_A(pp)))
REP_ERR_RETURN(1);
}
return (0);
}
/****************************************************************************/
/*D
nlpass - numerical procedure for assembling in parts
DESCRIPTION:
This num proc can be used to assemble parts of the computational domain
with different assembling routines. The num proc can be used in conjunction
with a 'nl_solver' num proc. The part assembling routines are called in the
order they have appeared in npinit.
.vb
npcreate assemble $c nlpass
npinit
$m <vt>
{$ass <pnl-assemble> $sub <vt-sub>}+
[$g <grid-velocity>]
.ve
. $m~<vt> - vector template matching global descriptors
. $ass~<pnl-assemble> - part nonlinear assembling num proc
. $sub~<vt-sub> - sub descriptor of vt
. $g~<grid-velocity> - velocity of grid nodes if grid is moving
KEYWORDS:
assemble, discretization
D*/
/****************************************************************************/
static INT NLPartAssInit (NP_BASE *theNP, INT argc, char **argv)
{
NP_PA_NL *pa = (NP_PA_NL*) theNP;
VEC_TEMPLATE *mvt;
INT r,i,j,nass;
char name[NAMESIZE],buffer[VALUELEN];
r = NPNLAssembleInit(theNP,argc,argv);
/* get name of main vector template */
if (ReadArgvChar("m",buffer,argc,argv)!=0)
{
PrintErrorMessage('E',"NLPartAssInit","m option with main vector template not found");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
mvt = GetVectorTemplate(MGFORMAT(NP_MG(theNP)),buffer);
if (mvt == NULL)
{
PrintErrorMessageF('E',"NLPartAssInit",
"cannot find specified vector template '%s'",buffer);
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_VT(pa) = mvt;
PA_VD_g(pa) = ReadArgvVecDesc(NP_MG(theNP),"g",argc,argv);
PA_NASS(pa) = nass = 0;
for (i=1; i<argc; i++)
switch (argv[i][0])
{
case 'a' :
if (nass>=MAX_PA)
{
PrintErrorMessage('E',"NLPartAssInit","max number of part assembling numprocs exceeded");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
if (sscanf(argv[i],expandfmt(CONCAT3("ass %",NAMELENSTR,"[ -~]")),name)!=1)
{
PrintErrorMessage('E',"NLPartAssInit","specify a nonlinear part assembling numproc with $ass");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_ASS(pa,nass) = (NP_NL_PARTASS*) GetNumProcByName (NP_MG(theNP),name,NL_PARTASS_CLASS_NAME);
if (PA_ASS(pa,nass) == NULL)
{
PrintErrorMessage('E',"NLPartAssInit",
"cannot find specified numerical procedure");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
/* next arg has to specify a valid sub vector */
if (++i>=argc)
{
PrintErrorMessage('E',"NLPartAssInit",
"last ass option has no sub option");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
/* scan name of subvector of main vector template */
if (sscanf(argv[i],expandfmt(CONCAT3("sub %",NAMELENSTR,"[ -~]")),name)!=1)
{
PrintErrorMessage('E',"NLPartAssInit","s option expected after ass option");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
for (j=0; j<VT_NSUB(mvt); j++)
if (strcmp(SUBV_NAME(VT_SUB(mvt,j)),name)==0)
break;
if (j>=VT_NSUB(mvt))
{
PrintErrorMessageF('E',"NLPartAssInit","name '%s' of sub template not found",name);
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_SUB(pa,nass) = j;
NPPNL_t(PA_ASS(pa,nass)) = mvt;
NPPNL_s(PA_ASS(pa,nass)) = j;
nass++;
break;
}
if (nass==0)
{
PrintErrorMessage('E',"NLPartAssInit","specify at least one nonlinear assembling numproc with $ass");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_NASS(pa) = nass;
if ((r==NP_ACTIVE) || (r==NP_EXECUTABLE))
return (r);
else
REP_ERR_RETURN (r);
}
static INT NLPartAssDisplay (NP_BASE *theNP)
{
NP_PA_NL *pa = (NP_PA_NL*) theNP;
INT i;
char text[8];
NPNLAssembleDisplay(theNP);
if (PA_VD_g(pa)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"g",ENVITEM_NAME(PA_VD_g(pa)));
UserWriteF(DISPLAY_NP_FORMAT_SS,"vec tmplt",ENVITEM_NAME(PA_VT(pa)));
UserWrite("\npart assembling numprocs:\n");
for (i=0; i<PA_NASS(pa); i++)
{
sprintf(text,"ass%d",i);
UserWriteF(DISPLAY_NP_FORMAT_SSS,text,strrchr(ENVITEM_NAME(PA_ASS(pa,i)),'.')+1,SUBV_NAME(VT_SUB(PA_VT(pa),PA_SUB(pa,i))));
}
return (0);
}
static INT NLPartAssPreProcess (NP_NL_ASSEMBLE *ass, INT fl, INT tl, VECDATA_DESC *x, INT *res)
{
NP_PA_NL *pa = (NP_PA_NL*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* call prep routines */
for (i=0; i<PA_NASS(pa); i++)
if (NPPNL_PRE(PA_ASS(pa,i))!=NULL)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,0.,0.,0.,x,NULL,NULL,NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN (1);
if (NPPNL_PRE(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT NLPartAssPostProcess (NP_NL_ASSEMBLE *ass, INT fl, INT tl, VECDATA_DESC *x,
VECDATA_DESC *d, MATDATA_DESC *J, INT *res)
{
NP_PA_NL *pa = (NP_PA_NL*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* call post routines */
for (i=0; i<PA_NASS(pa); i++)
if (NPANL_POST(PA_ASS(pa,i))!=NULL)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,0.,0.,0.,x,d,NULL,NULL,PA_VD_g(pa),J))
REP_ERR_RETURN (1);
if (NPPNL_POST(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT NLPartAssSolution (NP_NL_ASSEMBLE *ass, INT fl, INT tl, VECDATA_DESC *u, INT *res)
{
NP_PA_NL *pa = (NP_PA_NL*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* call assemble solution routines */
for (i=0; i<PA_NASS(pa); i++)
if (NPPNL_ASSSOL(PA_ASS(pa,i))!=NULL)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,0.,0.,0.,u,NULL,NULL,NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN(1);
if (NPPNL_ASSSOL(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT NLPartAssDefect (NP_NL_ASSEMBLE *ass, INT fl, INT tl, VECDATA_DESC *s,
VECDATA_DESC *r, MATDATA_DESC *A, INT *res)
{
NP_PA_NL *pa = (NP_PA_NL*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i,l;
/* first clear skip flags of global problem */
for (l=fl; l<=tl; l++)
ClearVecskipFlags(GRID_ON_LEVEL(NP_MG(ass),l),s);
/* call assemble defect routines */
for (i=0; i<PA_NASS(pa); i++)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,0.,0.,0.,s,r,NULL,NULL,PA_VD_g(pa),A))
REP_ERR_RETURN(1);
PP_ACTION(pp) = PARTASS_DEFECT;
if (NPPNL_ASS(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT NLPartAssMatrix (NP_NL_ASSEMBLE *ass, INT fl, INT tl, VECDATA_DESC *s,
VECDATA_DESC *d, VECDATA_DESC *v, MATDATA_DESC *A, INT *res)
{
NP_PA_NL *pa = (NP_PA_NL*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* clear global matrix */
if (dmatset(NP_MG(ass),fl,tl,ALL_VECTORS,A,0.0)!=NUM_OK) REP_ERR_RETURN (__LINE__);
/* call assemble defect routines */
for (i=0; i<PA_NASS(pa); i++)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,0.,0.,0.,s,d,NULL,v,PA_VD_g(pa),A))
REP_ERR_RETURN(1);
PP_ACTION(pp) = PARTASS_MATRIX;
if (NPPNL_ASS(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT NLPartAssConstruct (NP_BASE *theNP)
{
NP_NL_ASSEMBLE *np = (NP_NL_ASSEMBLE *) theNP;
NP_INIT(np) = NLPartAssInit;
NP_EXECUTE(np) = NPNLAssembleExecute;
NP_DISPLAY(np) = NLPartAssDisplay;
NPANL_PRE(np) = NLPartAssPreProcess;
NPANL_POST(np) = NLPartAssPostProcess;
NPANL_ASSSOL(np) = NLPartAssSolution;
NPANL_ASSDEF(np) = NLPartAssDefect;
NPANL_ASSMAT(np) = NLPartAssMatrix;
return(0);
}
/****************************************************************************/
/*D
tpass - numerical procedure for assembling in parts
DESCRIPTION:
This num proc can be used to assemble parts of the computational domain
with different assembling routines. The num proc can be used in conjunction
with a 'ts' num proc. The part assembling routines are called in the
order they have appeared in npinit.
.vb
npcreate assemble $c tpass
npinit
$m <vt>
{$ass <pnl-assemble> $sub <vt-sub>}+
[$g <grid-velocity>]
.ve
. $m~<vt> - vector template matching global descriptors
. $ass~<pnl-assemble> - part nonlinear assembling num proc
. $sub~<vt-sub> - sub descriptor of vt
. $g~<grid-velocity> - velocity of grid nodes if grid is moving
KEYWORDS:
assemble, discretization
D*/
/****************************************************************************/
static INT TPartAssInit (NP_BASE *theNP, INT argc, char **argv)
{
NP_PA_T *pa = (NP_PA_T*) theNP;
VEC_TEMPLATE *mvt;
INT r,i,j,nass;
char name[NAMESIZE],buffer[VALUELEN];
r = NPTAssembleInit(theNP,argc,argv);
/* get name of main vector template */
if (ReadArgvChar("m",buffer,argc,argv)!=0)
{
PrintErrorMessage('E',"NLPartAssInit","m option with main vector template not found");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
mvt = GetVectorTemplate(MGFORMAT(NP_MG(theNP)),buffer);
if (mvt == NULL)
{
PrintErrorMessageF('E',"NLPartAssInit",
"cannot find specified vector template '%s'",buffer);
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_VT(pa) = mvt;
PA_VD_g(pa) = ReadArgvVecDesc(NP_MG(theNP),"g",argc,argv);
PA_NASS(pa) = nass = 0;
for (i=1; i<argc; i++)
switch (argv[i][0])
{
case 'a' :
if (nass>=MAX_PA)
{
PrintErrorMessage('E',"NLPartAssInit","max number of part assembling numprocs exceeded");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
if (sscanf(argv[i],expandfmt(CONCAT3("ass %",NAMELENSTR,"[ -~]")),name)!=1)
{
PrintErrorMessage('E',"NLPartAssInit","specify a nonlinear part assembling numproc with $ass");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_ASS(pa,nass) = (NP_T_PARTASS*) GetNumProcByName (NP_MG(theNP),name,T_PARTASS_CLASS_NAME);
if (PA_ASS(pa,nass) == NULL)
{
PrintErrorMessage('E',"NLPartAssInit",
"cannot find specified numerical procedure");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
/* next arg has to specify a valid sub vector */
if (++i>=argc)
{
PrintErrorMessage('E',"NLPartAssInit",
"last ass option has no sub option");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
/* scan name of subvector of main vector template */
if (sscanf(argv[i],expandfmt(CONCAT3("sub %",NAMELENSTR,"[ -~]")),name)!=1)
{
PrintErrorMessage('E',"NLPartAssInit","s option expected after ass option");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
for (j=0; j<VT_NSUB(mvt); j++)
if (strcmp(SUBV_NAME(VT_SUB(mvt,j)),name)==0)
break;
if (j>=VT_NSUB(mvt))
{
PrintErrorMessageF('E',"NLPartAssInit","name '%s' of sub template not found",name);
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_SUB(pa,nass) = j;
NPPT_t(PA_ASS(pa,nass)) = mvt;
NPPT_s(PA_ASS(pa,nass)) = j;
nass++;
break;
}
if (nass==0)
{
PrintErrorMessage('E',"NLPartAssInit","specify at least one nonlinear assembling numproc with $ass");
REP_ERR_RETURN (NP_NOT_ACTIVE);
}
PA_NASS(pa) = nass;
if ((r==NP_ACTIVE) || (r==NP_EXECUTABLE))
return (r);
else
REP_ERR_RETURN (r);
}
static INT TPartAssDisplay (NP_BASE *theNP)
{
NP_PA_T *pa = (NP_PA_T*) theNP;
INT i;
char text[8];
NPTAssembleDisplay(theNP);
if (PA_VD_g(pa)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"g",ENVITEM_NAME(PA_VD_g(pa)));
UserWriteF(DISPLAY_NP_FORMAT_SS,"vec tmplt",ENVITEM_NAME(PA_VT(pa)));
UserWrite("\npart assembling numprocs:\n");
for (i=0; i<PA_NASS(pa); i++)
{
sprintf(text,"ass%d",i);
UserWriteF(DISPLAY_NP_FORMAT_SSS,text,strrchr(ENVITEM_NAME(PA_ASS(pa,i)),'.')+1,SUBV_NAME(VT_SUB(PA_VT(pa),PA_SUB(pa,i))));
}
return (0);
}
static INT TPartAssPreProcess (NP_T_ASSEMBLE *ass, INT fl, INT tl, DOUBLE t_p1, DOUBLE t_0,
DOUBLE t_m1, VECDATA_DESC *u_p1, VECDATA_DESC *u_0,
VECDATA_DESC *u_m1, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
PA_DT(pa) = t_p1-t_0;
PA_DT_OLD(pa) = t_0-t_m1;
PA_VD_o(pa) = u_0;
/* call prep routines */
for (i=0; i<PA_NASS(pa); i++)
if (NPPT_PRE(PA_ASS(pa,i))!=NULL)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,t_p1,PA_DT(pa),PA_DT_OLD(pa),u_p1,NULL,u_0,NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN(1);
if (NPPT_PRE(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssPostProcess (NP_T_ASSEMBLE *ass, INT fl, INT tl, DOUBLE t_p1, DOUBLE t_0,
DOUBLE t_m1, VECDATA_DESC *u_p1, VECDATA_DESC *u_0,
VECDATA_DESC *u_m1, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* call post routines */
for (i=0; i<PA_NASS(pa); i++)
if (NPPT_POST(PA_ASS(pa,i))!=NULL)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,t_p1,t_p1-t_0,t_0-t_m1,u_p1,NULL,u_0,NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN(1);
if (NPPT_POST(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssInitial (NP_T_ASSEMBLE *ass, INT fl, INT tl, DOUBLE time, VECDATA_DESC *u, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
if (PA_VD_g(pa)!=NULL)
/* clear grid velocity */
if (dset(NP_MG(ass),fl,tl,ALL_VECTORS,PA_VD_g(pa),0.0))
REP_ERR_RETURN(1);
/* call assemble solution routines */
for (i=0; i<PA_NASS(pa); i++)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,time,PA_DT(pa),PA_DT_OLD(pa),u,NULL,NULL,NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN(1);
if (NPPT_INITIAL(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssSolution (NP_T_ASSEMBLE *ass, INT fl, INT tl, DOUBLE time, VECDATA_DESC *u, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* call assemble solution routines */
for (i=0; i<PA_NASS(pa); i++)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),0.,1.,time,PA_DT(pa),PA_DT_OLD(pa),u,NULL,PA_VD_o(pa),NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN(1);
if (NPPT_ASSSOL(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssDefect (NP_T_ASSEMBLE *ass, INT fl, INT tl,
DOUBLE time, DOUBLE s_m, DOUBLE s_a, VECDATA_DESC *s,
VECDATA_DESC *r, MATDATA_DESC *A, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i,l;
/* first clear skip flags of global problem */
for (l=fl; l<=tl; l++)
ClearVecskipFlags(GRID_ON_LEVEL(NP_MG(ass),l),s);
/* call assemble defect routines */
for (i=0; i<PA_NASS(pa); i++)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),s_a,s_m,time,PA_DT(pa),PA_DT_OLD(pa),s,r,PA_VD_o(pa),NULL,PA_VD_g(pa),A))
REP_ERR_RETURN(1);
PP_ACTION(pp) = PARTASS_DEFECT;
if (NPPT_ASS(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssMatrix (NP_T_ASSEMBLE *ass, INT fl, INT tl, DOUBLE time, DOUBLE s_a,
VECDATA_DESC *s, VECDATA_DESC *d, VECDATA_DESC *v, MATDATA_DESC *A, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* clear global matrix */
if (dmatset(NP_MG(ass),fl,tl,ALL_VECTORS,A,0.0)!=NUM_OK) REP_ERR_RETURN (__LINE__);
/* call assemble matrix routines */
for (i=0; i<PA_NASS(pa); i++)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),s_a,1.,time,PA_DT(pa),PA_DT_OLD(pa),s,d,PA_VD_o(pa),v,PA_VD_g(pa),A))
REP_ERR_RETURN(1);
PP_ACTION(pp) = PARTASS_MATRIX;
if (NPPT_ASS(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssFinal (NP_T_ASSEMBLE *ass, INT fl, INT tl, INT *res)
{
NP_PA_T *pa = (NP_PA_T*) ass;
PARTASS_PARAMS papa,*pp=&papa;
INT i;
/* call post routines */
for (i=0; i<PA_NASS(pa); i++)
if (NPPT_FINAL(PA_ASS(pa,i))!=NULL)
{
if (SetPartassParamsX(pp,PA_VT(pa),PA_SUB(pa,i),1.,0.,0.,PA_DT(pa),PA_DT_OLD(pa),NULL,NULL,PA_VD_o(pa),NULL,PA_VD_g(pa),NULL))
REP_ERR_RETURN(1);
if (NPPT_FINAL(PA_ASS(pa,i)) (PA_ASS(pa,i),fl,tl,pp,res))
REP_ERR_RETURN(1);
}
return(0);
}
static INT TPartAssConstruct (NP_BASE *theNP)
{
NP_T_ASSEMBLE *np = (NP_T_ASSEMBLE *) theNP;
NP_INIT(np) = TPartAssInit;
NP_DISPLAY(np) = TPartAssDisplay;
NP_EXECUTE(np) = NPTAssembleExecute;
NPAT_PRE(np) = TPartAssPreProcess;
NPAT_POST(np) = TPartAssPostProcess;
NPAT_INITIAL(np) = TPartAssInitial;
NPAT_ASSSOL(np) = TPartAssSolution;
NPAT_ASSDEF(np) = TPartAssDefect;
NPAT_ASSMAT(np) = TPartAssMatrix;
NPAT_FINAL(np) = TPartAssFinal;
return(0);
}
/****************************************************************************/
/*D
NPNLPartAssInit - non-linear part assemble num proc init routine
SYNOPSIS:
INT NPNLPartAssInit (NP_BASE *theNP, INT argc, char **argv)
PAAMETERS:
. theNP - num proc
. argc - argument count
. argv - array of argument strings
DESCRIPTION:
This is a non-linear part assemble num proc init routine. It should
be used by a derived num proc to init the inherited num proc.
OPTIONS:
.vb
npinit
[$A <mat>]
[$x <sol>]
[$c <cor>]
[$b <rhs>]
[$g <vel>]
[$part <vt> <vt-sub]
.ve
. A~<mat> - stiffness matrix descriptor
. x~<sol> - solution descriptor
. c~<sol> - correction descriptor
. b~<sol> - right hand side descriptor
. g~<sol> - grid velocity descriptor
. part~<vt>~<vt-sub> - vector template and sub descriptor
The num proc is executable if at least A, b, x and t are specified.
LOCATION:
'assemble.c'
RETURN VALUE:
INT
.n 0: ok
.n else: error
D*/
/****************************************************************************/
INT NS_DIM_PREFIX NPNLPartAssInit (NP_BASE *theNP, INT argc, char **argv)
{
NP_NL_PARTASS *np = (NP_NL_PARTASS *) theNP;
MULTIGRID *mg = NP_MG(theNP);
NPPNL_A(np) = ReadArgvMatDesc(mg,"A",argc,argv);
NPPNL_x(np) = ReadArgvVecDesc(mg,"x",argc,argv);
NPPNL_c(np) = ReadArgvVecDesc(mg,"c",argc,argv);
NPPNL_b(np) = ReadArgvVecDesc(mg,"b",argc,argv);
NPPNL_g(np) = ReadArgvVecDesc(mg,"g",argc,argv);
NPPNL_t(np) = ReadArgvVecTemplateSub(MGFORMAT(mg),"part",argc,argv,&NPPNL_s(np));
if ((NPPNL_A(np) == NULL) || (NPPNL_b(np) == NULL) || (NPPNL_x(np) == NULL) || (NPPNL_t(np) == NULL))
return(NP_ACTIVE);
return(NP_EXECUTABLE);
}
INT NS_DIM_PREFIX NPNLPartAssDisplay (NP_BASE *theNP)
{
NP_NL_PARTASS *np = (NP_NL_PARTASS *) theNP;
UserWrite("part description:\n");
UserWriteF(DISPLAY_NP_FORMAT_SSS,"vt+sub",ENVITEM_NAME(NPPNL_t(np)),SUBV_NAME(VT_SUB(NPPNL_t(np),NPPNL_s(np))));
UserWrite("\nsymbolic user data:\n");
if (NPPNL_A(np)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"A",ENVITEM_NAME(NPPNL_A(np)));
if (NPPNL_x(np)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"x",ENVITEM_NAME(NPPNL_x(np)));
if (NPPNL_c(np)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"c",ENVITEM_NAME(NPPNL_c(np)));
if (NPPNL_b(np)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"b",ENVITEM_NAME(NPPNL_b(np)));
if (NPPNL_g(np)!=NULL)
UserWriteF(DISPLAY_NP_FORMAT_SS,"g",ENVITEM_NAME(NPPNL_g(np)));
UserWrite("\n");
return (0);
}
INT NS_DIM_PREFIX NPNLPartAssExecute (NP_BASE *theNP, INT argc, char **argv)
{
NP_NL_PARTASS *np = (NP_NL_PARTASS *) theNP;
INT result = NUM_OK;
int level = CURRENTLEVEL(NP_MG(theNP));
PARTASS_PARAMS papa,*pp=&papa;
if (NPPNL_x(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no vector x");
REP_ERR_RETURN (1);
}
if (NPPNL_b(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no vector b");
REP_ERR_RETURN (1);
}
if (NPPNL_A(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no matrix A");
REP_ERR_RETURN (1);
}
if (NPPNL_t(np)!=NULL)
{
if (SetPartassParamsX(pp,NPPNL_t(np),NPPNL_s(np),1.,0.,0.,0.,0.,NPPNL_x(np),NPPNL_b(np),NULL,NULL,NPPNL_g(np),NPPNL_A(np)))
REP_ERR_RETURN (1);
}
else
{
SetPartassParams(pp,1.,0.,0.,0.,0.,NPPNL_x(np),NPPNL_b(np),NULL,NULL,NPPNL_g(np),NPPNL_A(np));
/*PP_MD_A(pp) = NPPNL_A(np);
PP_VD_s(pp) = NPPNL_x(np);
PP_VD_r(pp) = NPPNL_b(np);
PP_VD_gridvel(pp) = NPPNL_g(np);*/
}
if (ReadArgvOption("i",argc,argv)) {
if (NPPNL_PRE(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no PreProcess");
REP_ERR_RETURN (1);
}
if (NPPNL_PRE(np) (np,0,level,pp,&result)) {
PrintErrorMessageF('E',"NPNLAssembleExecute","PreProcess failed, error code %d\n",result);
REP_ERR_RETURN (1);
}
}
if (ReadArgvOption("s",argc,argv)) {
if (NPPNL_ASSSOL(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no NLAssembleSolution");
REP_ERR_RETURN (1);
}
if (NPPNL_ASSSOL(np) (np,0,level,pp,&result)) {
PrintErrorMessageF('E',"NPNLAssembleExecute","NLAssembleSolution failed, error code %d\n",result);
REP_ERR_RETURN (1);
}
}
if (ReadArgvOption("a",argc,argv)) {
if (NPPNL_ASS(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no NLAssembleDefect");
REP_ERR_RETURN (1);
}
if (NPPNL_ASS(np) (np,0,level,pp,&result)) {
PrintErrorMessageF('E',"NPNLAssembleExecute","NLPassemble failed, error code %d\n",result);
REP_ERR_RETURN (1);
}
}
if (ReadArgvOption("p",argc,argv)) {
if (NPPNL_POST(np) == NULL) {
PrintErrorMessage('E',"NPNLAssembleExecute","no PostProcess");
REP_ERR_RETURN (1);
}
if (NPPNL_POST(np) (np,0,level,pp,&result)) {
PrintErrorMessageF('E',"NPNLAssembleExecute","PostProcess failed, error code %d\n",result);
REP_ERR_RETURN (1);
}
}
return(0);
}
/****************************************************************************/
/*D
NPTPartAssInit - time part assemble num proc init routine
SYNOPSIS:
INT NPTPartAssInit (NP_BASE *theNP, INT argc, char **argv)
PAAMETERS:
. theNP - num proc
. argc - argument count
. argv - array of argument strings
DESCRIPTION:
This is a time part assemble num proc init routine. It should
be used by a derived num proc to init the inherited num proc.
OPTIONS:
.vb
npinit
.ve
The num proc is never executable.
LOCATION:
'assemble.c'
RETURN VALUE:
INT
.n 0: ok
.n else: error
D*/
/****************************************************************************/
INT NS_DIM_PREFIX NPTPartAssInit (NP_BASE *theNP, INT argc, char **argv)
{
return(NP_ACTIVE);
}
INT NS_DIM_PREFIX NPTPartAssDisplay (NP_BASE *theNP)
{
NP_NL_PARTASS *np = (NP_NL_PARTASS *) theNP;
UserWrite("part description:\n");
UserWriteF(DISPLAY_NP_FORMAT_SSS,"vt+sub",ENVITEM_NAME(NPPNL_t(np)),SUBV_NAME(VT_SUB(NPPNL_t(np),NPPNL_s(np))));
UserWrite("\n");
return(0);
}
INT NS_DIM_PREFIX NPTPartAssExecute (NP_BASE *theNP, INT argc, char **argv)
{
/* never executable */
REP_ERR_RETURN(1);
}
/****************************************************************************/
/*D
pp_action2str - convert action component of PARTASS_PARAMS into string
SYNOPSIS:
const char * pp_action2str (const PARTASS_PARAMS *pp)
PAAMETERS:
. pp - part assemble parameters
DESCRIPTION:
This function converts the action component of PARTASS_PARAMS into a string.
LOCATION:
'assemble.c'
RETURN VALUE:
const char *
.n string
D*/
/****************************************************************************/
const char *NS_DIM_PREFIX pp_action2str (const PARTASS_PARAMS *pp)
{
pp_action_str[0] = '\0';
if (PP_ACTION(pp)==0)
{
strcat(pp_action_str,"none");
return (pp_action_str);
}
if (READ_FLAG(PP_ACTION(pp),PARTASS_DEFECT))
strcat(pp_action_str,"def");
if (READ_FLAG(PP_ACTION(pp),PARTASS_MATRIX))
{
if (strlen(pp_action_str)>0)
strcat(pp_action_str,"+");
strcat(pp_action_str,"mat");
}
return (pp_action_str);
}
/****************************************************************************/
/*D
InitAssemble - init the file assemble.c
SYNOPSIS:
INT InitAssemble (void)
PARAMETERS:
. void -
DESCRIPTION:
Create a numerical procedure class 'partass' which can call several
assembling numprocs. 'partass' does not check any compatibility or
consistency!
RETURN VALUE:
INT
.n __LINE__: CreateClass failed
.n 0: ok
D*/
/****************************************************************************/
INT NS_DIM_PREFIX InitAssemble (void)
{
/* create partass class */
if (CreateClass(NL_ASSEMBLE_CLASS_NAME ".nlpass",
sizeof(NP_PA_NL), NLPartAssConstruct))
REP_ERR_RETURN (__LINE__);
/* create time partass class */
if (CreateClass(T_ASSEMBLE_CLASS_NAME ".tpass",
sizeof(NP_PA_T), TPartAssConstruct))
REP_ERR_RETURN (__LINE__);
return(0);
}
|