Changeset 273
- Timestamp:
- Sep 6, 2004, 11:43:36 AM (21 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/config.py
r272 r273 59 59 60 60 use_psyco = True #Use psyco optimisations 61 use_psyco = False #Do not use psyco optimisations61 #use_psyco = False #Do not use psyco optimisations 62 62 63 63 -
inundation/ga/storm_surge/pyvolution/shallow_water.py
r272 r273 426 426 #Control momentum 427 427 xmomc[k] = ymomc[k] = 0.0 428 429 430 431 def protect_against_infintesimal_and_negative_heights_c(domain): 432 """Protect against infinitesimal heights and associated high velocities 433 """ 434 435 #Shortcuts 436 wc = domain.quantities['level'].centroid_values 437 zc = domain.quantities['elevation'].centroid_values 438 xmomc = domain.quantities['xmomentum'].centroid_values 439 ymomc = domain.quantities['ymomentum'].centroid_values 440 441 from shallow_water_ext import protect 442 443 protect(domain.minimum_allowed_height, wc, zc, xmomc, ymomc) 444 445 428 446 429 447 def extrapolate_first_order(domain): … … 954 972 gravity = gravity_c 955 973 manning_friction = manning_friction_c 956 balance_deep_and_shallow = balance_deep_and_shallow_c 974 balance_deep_and_shallow = balance_deep_and_shallow_c 975 protect_against_infintesimal_and_negative_heights = protect_against_infintesimal_and_negative_heights_c 957 976 958 977 #distribute_to_vertices_and_edges = distribute_to_vertices_and_edges_c -
inundation/ga/storm_surge/pyvolution/shallow_water_ext.c
r267 r273 253 253 return 0; 254 254 } 255 256 257 258 int _protect(int N, 259 double minimum_allowed_height, 260 double* wc, 261 double* zc, 262 double* xmomc, 263 double* ymomc) { 264 265 int k; 266 double hc; 267 268 //Compute linear combination between constant levels and and 269 //levels parallel to the bed elevation. 270 271 for (k=0; k<N; k++) { 272 hc = wc[k] - zc[k]; 273 if (hc < minimum_allowed_height) { 274 if (hc < 0.0) { 275 //Control level and height 276 wc[k] = zc[k]; 277 } 278 279 //Control momentum 280 xmomc[k] = 0.0; 281 ymomc[k] = 0.0; 282 } 283 } 284 return 0; 285 } 286 287 255 288 256 289 /////////////////////////////////////////////////////////////////// … … 559 592 560 593 594 PyObject *protect(PyObject *self, PyObject *args) { 595 // 596 // protect(minimum_allowed_height, wc, zc, xmomc, ymomc) 597 598 599 PyArrayObject 600 *wc, //Level at centroids 601 *zc, //Elevation at centroids 602 *xmomc, //Momentums at centroids 603 *ymomc; 604 605 606 int N; 607 double minimum_allowed_height; 608 609 // Convert Python arguments to C 610 if (!PyArg_ParseTuple(args, "dOOOO", 611 &minimum_allowed_height, 612 &wc, &zc, &xmomc, &ymomc)) 613 return NULL; 614 615 N = wc -> dimensions[0]; 616 617 _protect(N, 618 minimum_allowed_height, 619 (double*) wc -> data, 620 (double*) zc -> data, 621 (double*) xmomc -> data, 622 (double*) ymomc -> data); 623 624 return Py_BuildValue(""); 625 } 626 627 628 561 629 PyObject *balance_deep_and_shallow(PyObject *self, PyObject *args) { 562 630 // 563 // balance_deep_and_shallow(domain.number_of_elements, 564 // wc, zc, hc, wv, zv, hv, 631 // balance_deep_and_shallow(wc, zc, hc, wv, zv, hv, 565 632 // xmomc, ymomc, xmomv, ymomv) 566 633 … … 607 674 608 675 609 610 611 676 ////////////////////////////////////////// 612 677 // Method table for python module … … 623 688 {"balance_deep_and_shallow", balance_deep_and_shallow, 624 689 METH_VARARGS, "Print out"}, 690 {"protect", protect, METH_VARARGS | METH_KEYWORDS, "Print out"}, 625 691 //{"distribute_to_vertices_and_edges", 626 692 // distribute_to_vertices_and_edges, METH_VARARGS},
Note: See TracChangeset
for help on using the changeset viewer.