Changeset 3730
- Timestamp:
- Oct 10, 2006, 3:02:21 PM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity_ext.c
r3719 r3730 230 230 231 231 // Convert Python arguments to C 232 if (!PyArg_ParseTuple(args, "Od", &quantity, ×tep)) 233 return NULL; 232 if (!PyArg_ParseTuple(args, "Od", &quantity, ×tep)) { 233 PyErr_SetString(PyExc_RuntimeError, 234 "quantity_ext.c: update could not parse input"); 235 return NULL; 236 } 234 237 235 238 centroid_values = get_consecutive_array(quantity, "centroid_values"); … … 240 243 241 244 err = _update(N, timestep, 242 243 244 245 (double*) centroid_values -> data, 246 (double*) explicit_update -> data, 247 (double*) semi_implicit_update -> data); 245 248 246 249 247 250 if (err != 0) { 248 249 "Zero division in semi implicit update - call Stephen :)");250 251 PyErr_SetString(PyExc_RuntimeError, 252 "Zero division in semi implicit update - call Stephen :)"); 253 return NULL; 251 254 } 252 255 … … 268 271 269 272 // Convert Python arguments to C 270 if (!PyArg_ParseTuple(args, "O", &quantity)) 271 return NULL; 272 273 if (!PyArg_ParseTuple(args, "O", &quantity)) { 274 PyErr_SetString(PyExc_RuntimeError, 275 "quantity_ext.c: interpolate_from_vertices_to_edges could not parse input"); 276 return NULL; 277 } 278 273 279 vertex_values = get_consecutive_array(quantity, "vertex_values"); 274 280 edge_values = get_consecutive_array(quantity, "edge_values"); … … 281 287 282 288 if (err != 0) { 283 PyErr_SetString(PyExc_RuntimeError, "Interpolate could not be computed"); 284 return NULL; 289 PyErr_SetString(PyExc_RuntimeError, 290 "Interpolate could not be computed"); 291 return NULL; 285 292 } 286 293 … … 306 313 307 314 // Convert Python arguments to C 308 if (!PyArg_ParseTuple(args, "O", &quantity)) 309 return NULL; 315 if (!PyArg_ParseTuple(args, "O", &quantity)) { 316 PyErr_SetString(PyExc_RuntimeError, 317 "quantity_ext.c: compute_gradients could not parse input"); 318 return NULL; 319 } 310 320 311 321 domain = PyObject_GetAttrString(quantity, "domain"); 312 if (!domain) 313 return NULL; 322 if (!domain) { 323 PyErr_SetString(PyExc_RuntimeError, 324 "compute_gradients could not obtain domain object from quantity"); 325 return NULL; 326 } 314 327 315 328 //Get pertinent variables … … 341 354 342 355 if (err != 0) { 343 344 356 PyErr_SetString(PyExc_RuntimeError, "Gradient could not be computed"); 357 return NULL; 345 358 } 346 359 … … 377 390 378 391 // Convert Python arguments to C 379 if (!PyArg_ParseTuple(args, "O", &quantity)) 380 return NULL; 392 if (!PyArg_ParseTuple(args, "O", &quantity)) { 393 PyErr_SetString(PyExc_RuntimeError, 394 "extrapolate_second_order could not parse input"); 395 return NULL; 396 } 381 397 382 398 domain = PyObject_GetAttrString(quantity, "domain"); 383 if (!domain) 384 return NULL; 399 if (!domain) { 400 PyErr_SetString(PyExc_RuntimeError, 401 "extrapolate_second_order could not obtain domain object from quantity"); 402 return NULL; 403 } 385 404 386 405 //Get pertinent variables … … 419 438 420 439 if (err != 0) { 421 422 440 PyErr_SetString(PyExc_RuntimeError, "Gradient could not be computed"); 441 return NULL; 423 442 } 424 443 … … 433 452 434 453 if (err != 0) { 435 436 "Internal function _extrapolate failed");437 454 PyErr_SetString(PyExc_RuntimeError, 455 "Internal function _extrapolate failed"); 456 return NULL; 438 457 } 439 458 … … 468 487 469 488 // Convert Python arguments to C 470 if (!PyArg_ParseTuple(args, "O", &quantity)) 471 return NULL; 489 if (!PyArg_ParseTuple(args, "O", &quantity)) { 490 PyErr_SetString(PyExc_RuntimeError, 491 "quantity_ext.c: limit could not parse input"); 492 return NULL; 493 } 472 494 473 495 domain = PyObject_GetAttrString(quantity, "domain"); 474 if (!domain) 475 return NULL; 496 if (!domain) { 497 PyErr_SetString(PyExc_RuntimeError, 498 "quantity_ext.c: limit could not obtain domain object from quantity"); 499 500 return NULL; 501 } 476 502 477 503 //neighbours = (PyArrayObject*) PyObject_GetAttrString(domain, "neighbours"); … … 480 506 //Get safety factor beta_w 481 507 Tmp = PyObject_GetAttrString(domain, "beta_w"); 482 if (!Tmp) 483 return NULL; 508 if (!Tmp) { 509 PyErr_SetString(PyExc_RuntimeError, 510 "quantity_ext.c: limit could not obtain beta_w object from domain"); 511 512 return NULL; 513 } 484 514 485 515 beta_w = PyFloat_AsDouble(Tmp); -
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r3719 r3730 616 616 if (!PyArg_ParseTuple(args, "dOOOOO", 617 617 &g, &h, &v, &x, 618 &xmom, &ymom)) 619 return NULL; 618 &xmom, &ymom)) { 619 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: gravity could not parse input arguments"); 620 return NULL; 621 } 620 622 621 623 N = h -> dimensions[0]; … … 667 669 if (!PyArg_ParseTuple(args, "ddOOOOOOO", 668 670 &g, &eps, &w, &z, &uh, &vh, &eta, 669 &xmom, &ymom)) 670 return NULL; 671 &xmom, &ymom)) { 672 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: manning_friction could not parse input arguments"); 673 return NULL; 674 } 675 671 676 672 677 N = w -> dimensions[0]; … … 788 793 //get the safety factor beta_w, set in the config.py file. This is used in the limiting process 789 794 Tmp = PyObject_GetAttrString(domain, "beta_w"); 790 if (!Tmp) 791 return NULL; 795 if (!Tmp) { 796 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object beta_w from domain"); 797 return NULL; 798 } 792 799 beta_w = PyFloat_AsDouble(Tmp); 793 800 Py_DECREF(Tmp); 794 801 795 802 Tmp = PyObject_GetAttrString(domain, "beta_w_dry"); 796 if (!Tmp) 797 return NULL; 803 if (!Tmp) { 804 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object beta_w_dry from domain"); 805 return NULL; 806 } 798 807 beta_w_dry = PyFloat_AsDouble(Tmp); 799 808 Py_DECREF(Tmp); 800 809 801 810 Tmp = PyObject_GetAttrString(domain, "beta_uh"); 802 if (!Tmp) 803 return NULL; 811 if (!Tmp) { 812 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object beta_uh from domain"); 813 return NULL; 814 } 804 815 beta_uh = PyFloat_AsDouble(Tmp); 805 816 Py_DECREF(Tmp); 806 817 807 818 Tmp = PyObject_GetAttrString(domain, "beta_uh_dry"); 808 if (!Tmp) 809 return NULL; 819 if (!Tmp) { 820 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object beta_uh_dry from domain"); 821 return NULL; 822 } 810 823 beta_uh_dry = PyFloat_AsDouble(Tmp); 811 824 Py_DECREF(Tmp); 812 825 813 826 Tmp = PyObject_GetAttrString(domain, "beta_vh"); 814 if (!Tmp) 815 return NULL; 827 if (!Tmp) { 828 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object beta_vh from domain"); 829 return NULL; 830 } 816 831 beta_vh = PyFloat_AsDouble(Tmp); 817 832 Py_DECREF(Tmp); 818 833 819 834 Tmp = PyObject_GetAttrString(domain, "beta_vh_dry"); 820 if (!Tmp) 821 return NULL; 835 if (!Tmp) { 836 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object beta_vh_dry from domain"); 837 return NULL; 838 } 822 839 beta_vh_dry = PyFloat_AsDouble(Tmp); 823 840 Py_DECREF(Tmp); 824 841 825 842 Tmp = PyObject_GetAttrString(domain, "minimum_allowed_height"); 826 if (!Tmp) 827 return NULL; 843 if (!Tmp) { 844 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: extrapolate_second_order_sw could not obtain object minimum_allowed_heigt"); 845 return NULL; 846 } 828 847 minimum_allowed_height = PyFloat_AsDouble(Tmp); 829 848 Py_DECREF(Tmp); … … 881 900 area2 = dy2*dx1 - dy1*dx2;//the triangle is guaranteed to be counter-clockwise 882 901 //If the mesh is 'weird' near the boundary, the trianlge might be flat or clockwise: 883 if (area2<=0) 884 return NULL; 885 886 //### Calculate heights of neighbouring cells 887 hc = ((double *)stage_centroid_values->data)[k] - ((double *)elevation_centroid_values->data)[k]; 888 h0 = ((double *)stage_centroid_values->data)[k0] - ((double *)elevation_centroid_values->data)[k0]; 889 h1 = ((double *)stage_centroid_values->data)[k1] - ((double *)elevation_centroid_values->data)[k1]; 890 h2 = ((double *)stage_centroid_values->data)[k2] - ((double *)elevation_centroid_values->data)[k2]; 891 hmin = min(hc,min(h0,min(h1,h2))); 902 if (area2<=0) { 903 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: negative triangle area encountered"); 904 return NULL; 905 } 906 907 908 //### Calculate heights of neighbouring cells 909 hc = ((double *)stage_centroid_values->data)[k] - ((double *)elevation_centroid_values->data)[k]; 910 h0 = ((double *)stage_centroid_values->data)[k0] - ((double *)elevation_centroid_values->data)[k0]; 911 h1 = ((double *)stage_centroid_values->data)[k1] - ((double *)elevation_centroid_values->data)[k1]; 912 h2 = ((double *)stage_centroid_values->data)[k2] - ((double *)elevation_centroid_values->data)[k2]; 913 hmin = min(hc,min(h0,min(h1,h2))); 914 892 915 //### stage ### 893 916 //calculate the difference between vertex 0 of the auxiliary triangle and the FV triangle centroid … … 908 931 //and compute jumps from the centroid to the min and max 909 932 find_qmin_and_qmax(dq0,dq1,dq2,&qmin,&qmax); 910 911 912 913 914 933 // Playing with dry wet interface 934 hmin = qmin; 935 beta_tmp = beta_w; 936 if (hmin<minimum_allowed_height) 937 beta_tmp = beta_w_dry; 915 938 limit_gradient(dqv,qmin,qmax,beta_tmp);//the gradient will be limited 916 939 for (i=0;i<3;i++) 917 940 ((double *)stage_vertex_values->data)[k3+i]=((double *)stage_centroid_values->data)[k]+dqv[i]; 918 941 919 942 //### xmom ### 920 943 //calculate the difference between vertex 0 of the auxiliary triangle and the FV triangle centroid … … 935 958 //and compute jumps from the centroid to the min and max 936 959 find_qmin_and_qmax(dq0,dq1,dq2,&qmin,&qmax); 937 938 939 960 beta_tmp = beta_uh; 961 if (hmin<minimum_allowed_height) 962 beta_tmp = beta_uh_dry; 940 963 limit_gradient(dqv,qmin,qmax,beta_tmp);//the gradient will be limited 941 964 for (i=0;i<3;i++) 942 965 ((double *)xmom_vertex_values->data)[k3+i]=((double *)xmom_centroid_values->data)[k]+dqv[i]; 943 966 944 967 //### ymom ### 945 968 //calculate the difference between vertex 0 of the auxiliary triangle and the FV triangle centroid … … 960 983 //and compute jumps from the centroid to the min and max 961 984 find_qmin_and_qmax(dq0,dq1,dq2,&qmin,&qmax); 962 963 964 985 beta_tmp = beta_vh; 986 if (hmin<minimum_allowed_height) 987 beta_tmp = beta_vh_dry; 965 988 limit_gradient(dqv,qmin,qmax,beta_tmp);//the gradient will be limited 966 989 for (i=0;i<3;i++) … … 974 997 break; 975 998 } 976 if ((k2==k3+3))//if we didn't find an internal neighbour 999 if ((k2==k3+3)) {//if we didn't find an internal neighbour 1000 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: Internal neighbour not found"); 977 1001 return NULL;//error 1002 } 1003 978 1004 k1=((long *)surrogate_neighbours->data)[k2]; 979 1005 //the coordinates of the triangle are already (x,y). Get centroid of the neighbour (x1,y1) … … 990 1016 dy2=dx2*dy1; 991 1017 dx2*=dx1; 992 1018 993 1019 //## stage ### 994 1020 //compute differentials … … 1010 1036 qmax=0.0; 1011 1037 } 1038 1039 1012 1040 limit_gradient(dqv,qmin,qmax,beta_w);//the gradient will be limited 1013 1041 for (i=0;i<3;i++) 1014 1042 ((double *)stage_vertex_values->data)[k3+i]=((double *)stage_centroid_values->data)[k]+dqv[i]; 1015 1043 1016 1044 //## xmom ### 1017 1045 //compute differentials … … 1036 1064 for (i=0;i<3;i++) 1037 1065 ((double *)xmom_vertex_values->data)[k3+i]=((double *)xmom_centroid_values->data)[k]+dqv[i]; 1038 1066 1039 1067 //## ymom ### 1040 1068 //compute differentials … … 1064 1092 }//extrapolate_second-order_sw 1065 1093 1094 1066 1095 PyObject *rotate(PyObject *self, PyObject *args, PyObject *kwargs) { 1067 1096 // … … 1081 1110 // Convert Python arguments to C 1082 1111 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i", argnames, 1083 &Q, &Normal, &direction)) 1084 return NULL; 1112 &Q, &Normal, &direction)) { 1113 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: rotate could not parse input arguments"); 1114 return NULL; 1115 } 1085 1116 1086 1117 //Input checks (convert sequences into numeric arrays) … … 1498 1529 &maximum_allowed_speed, 1499 1530 &epsilon, 1500 &wc, &zc, &xmomc, &ymomc)) 1501 return NULL; 1531 &wc, &zc, &xmomc, &ymomc)) { 1532 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: protect could not parse input arguments"); 1533 return NULL; 1534 } 1502 1535 1503 1536 N = wc -> dimensions[0]; … … 1542 1575 &wc, &zc, &hc, 1543 1576 &wv, &zv, &hv, &hvbar, 1544 &xmomc, &ymomc, &xmomv, &ymomv)) 1545 return NULL; 1577 &xmomc, &ymomc, &xmomv, &ymomv)) { 1578 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: balance_deep_and_shallow could not parse input arguments"); 1579 return NULL; 1580 } 1581 1546 1582 1547 1583 N = wc -> dimensions[0]; … … 1580 1616 1581 1617 // Convert Python arguments to C 1582 if (!PyArg_ParseTuple(args, "OOO", &domain, &hc, &hv)) 1583 return NULL; 1584 1618 if (!PyArg_ParseTuple(args, "OOO", &domain, &hc, &hv)) { 1619 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: h_limiter could not parse input arguments"); 1620 return NULL; 1621 } 1622 1585 1623 neighbours = get_consecutive_array(domain, "neighbours"); 1586 1624 1587 1625 //Get safety factor beta_h 1588 1626 Tmp = PyObject_GetAttrString(domain, "beta_h"); 1589 if (!Tmp) 1590 return NULL; 1591 1627 if (!Tmp) { 1628 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: h_limiter could not obtain object beta_h from domain"); 1629 return NULL; 1630 } 1592 1631 beta_h = PyFloat_AsDouble(Tmp); 1593 1632 … … 1650 1689 double beta_h; //Safety factor (see config.py) 1651 1690 double hmin, hmax, dh[3]; 1652 // Convert Python arguments to C 1653 if (!PyArg_ParseTuple(args, "OOO", &domain, &hc, &hv)) 1654 return NULL; 1691 // Convert Python arguments to C 1692 if (!PyArg_ParseTuple(args, "OOO", &domain, &hc, &hv)) { 1693 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: h_limiter_sw could not parse input arguments"); 1694 return NULL; 1695 } 1655 1696 neighbours = get_consecutive_array(domain, "neighbours"); 1656 1697 1657 1698 //Get safety factor beta_h 1658 1699 Tmp = PyObject_GetAttrString(domain, "beta_h"); 1659 if (!Tmp) 1660 return NULL; 1700 if (!Tmp) { 1701 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: h_limiter_sw could not obtain object beta_h from domain"); 1702 return NULL; 1703 } 1661 1704 beta_h = PyFloat_AsDouble(Tmp); 1662 1705 … … 1725 1768 &ymom_update, 1726 1769 &s_vec, &phi_vec, 1727 &cw)) 1728 return NULL; 1770 &cw)) { 1771 PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: assign_windfield_values could not parse input arguments"); 1772 return NULL; 1773 } 1774 1729 1775 1730 1776 N = xmom_update -> dimensions[0]; -
anuga_core/source/anuga/utilities/polygon_ext.c
r3633 r3730 159 159 160 160 // Convert Python arguments to C 161 if (!PyArg_ParseTuple(args, "dddddd", &x, &y, &x0, &y0, &x1, &y1)) 161 if (!PyArg_ParseTuple(args, "dddddd", &x, &y, &x0, &y0, &x1, &y1)) { 162 PyErr_SetString(PyExc_RuntimeError, 163 "point_on_line could not parse input"); 162 164 return NULL; 165 } 163 166 164 167 … … 227 230 &indices, 228 231 &closed, 229 &verbose)) 232 &verbose)) { 233 234 235 PyErr_SetString(PyExc_RuntimeError, 236 "separate_points_by_polygon could not parse input"); 230 237 return NULL; 238 } 231 239 232 240 M = points -> dimensions[0]; //Number of points -
anuga_core/source/anuga/utilities/sparse_ext.c
r2503 r3730 81 81 82 82 // Convert Python arguments to C 83 if (!PyArg_ParseTuple(args, "OO", &csr_sparse, &xin)) 84 return NULL; 83 if (!PyArg_ParseTuple(args, "OO", &csr_sparse, &xin)) { 84 PyErr_SetString(PyExc_RuntimeError, "Csr_mv could not parse input"); 85 return NULL; 86 } 85 87 86 88 x = (PyArrayObject*) PyArray_ContiguousFromObject(xin,PyArray_DOUBLE,1,2); 87 if (!x) 88 return NULL; 89 if (!x) { 90 PyErr_SetString(PyExc_RuntimeError, 91 "Input array could not be read in csr_mv"); 92 return NULL; 93 } 89 94 90 95 /* printf("x.nd = %i\n",x->nd); */ … … 101 106 102 107 103 data = (PyArrayObject*)108 data = (PyArrayObject*) 104 109 PyObject_GetAttrString(csr_sparse, "data"); 105 if (!data) 106 return NULL; 110 if (!data) { 111 PyErr_SetString(PyExc_RuntimeError, 112 "Data array could not be allocated in csr_mv"); 113 return NULL; 114 } 107 115 108 116 colind = (PyArrayObject*) 109 117 PyObject_GetAttrString(csr_sparse, "colind"); 110 if (!colind) return NULL; 118 if (!colind) { 119 PyErr_SetString(PyExc_RuntimeError, 120 "Column index array could not be allocated in csr_mv"); 121 return NULL; 122 } 111 123 112 124 row_ptr = (PyArrayObject*) 113 125 PyObject_GetAttrString(csr_sparse, "row_ptr"); 114 if (!row_ptr) return NULL; 126 if (!row_ptr) { 127 PyErr_SetString(PyExc_RuntimeError, 128 "Row pointer array could not be allocated in csr_mv"); 129 } 115 130 116 131 M = (row_ptr -> dimensions[0])-1; … … 132 147 133 148 if (err != 0) { 134 PyErr_SetString(PyExc_RuntimeError, " matrix vector mult could not be calculated");149 PyErr_SetString(PyExc_RuntimeError, "Matrix vector mult could not be calculated"); 135 150 return NULL; 136 151 } -
anuga_core/source/anuga/utilities/util_ext.c
r2738 r3730 35 35 // Convert Python arguments to C 36 36 if (!PyArg_ParseTuple(args, "ddddddddd", &x0, &y0, &x1, &y1, &x2, &y2, 37 &q0, &q1, &q2)) 37 &q0, &q1, &q2)) { 38 39 PyErr_SetString(PyExc_RuntimeError, 40 "gradient could not parse input"); 38 41 return NULL; 42 } 39 43 40 44 … … 57 61 58 62 // Convert Python arguments to C 59 if (!PyArg_ParseTuple(args, "dddddd", &x0, &y0, &x1, &y1, &q0, &q1)) 63 if (!PyArg_ParseTuple(args, "dddddd", &x0, &y0, &x1, &y1, &q0, &q1)) { 64 PyErr_SetString(PyExc_RuntimeError, 65 "gradient2 could not parse input"); 60 66 return NULL; 67 } 61 68 62 69
Note: See TracChangeset
for help on using the changeset viewer.