Changeset 752
- Timestamp:
- Jan 20, 2005, 1:03:56 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/quantity_ext.c
r587 r752 23 23 double* centroids, 24 24 double* centroid_values, 25 int* number_of_boundaries,26 int* surrogate_neighbours,25 long* number_of_boundaries, 26 long* surrogate_neighbours, 27 27 double* a, 28 28 double* b) { … … 31 31 double x0, x1, x2, y0, y1, y2, q0, q1, q2, det; 32 32 33 33 34 34 for (k=0; k<N; k++) { 35 35 index3 = 3*k; … … 44 44 k1 = surrogate_neighbours[index3 + 1]; 45 45 k2 = surrogate_neighbours[index3 + 2]; 46 47 46 48 if (k0 == k1 || k1 == k2) return -1; 47 49 … … 217 219 return NULL; 218 220 219 centroid_values = (PyArrayObject*) 220 PyObject_GetAttrString(quantity, "centroid_values"); 221 if (!centroid_values) return NULL; 222 223 explicit_update = (PyArrayObject*) 224 PyObject_GetAttrString(quantity, "explicit_update"); 225 if (!explicit_update) return NULL; 226 227 semi_implicit_update = (PyArrayObject*) 228 PyObject_GetAttrString(quantity, "semi_implicit_update"); 229 if (!semi_implicit_update) return NULL; 221 centroid_values = get_consecutive_array(quantity, "centroid_values"); 222 explicit_update = get_consecutive_array(quantity, "explicit_update"); 223 semi_implicit_update = get_consecutive_array(quantity, "semi_implicit_update"); 224 225 226 //centroid_values = (PyArrayObject*) 227 // PyObject_GetAttrString(quantity, "centroid_values"); 228 //if (!centroid_values) return NULL; 229 230 //explicit_update = (PyArrayObject*) 231 // PyObject_GetAttrString(quantity, "explicit_update"); 232 //if (!explicit_update) return NULL; 233 234 //semi_implicit_update = (PyArrayObject*) 235 // PyObject_GetAttrString(quantity, "semi_implicit_update"); 236 //if (!semi_implicit_update) return NULL; 230 237 231 238 N = centroid_values -> dimensions[0]; … … 264 271 return NULL; 265 272 273 vertex_values = get_consecutive_array(quantity, "vertex_values"); 274 edge_values = get_consecutive_array(quantity, "edge_values"); 275 276 /* 266 277 vertex_values = (PyArrayObject*) 267 278 PyObject_GetAttrString(quantity, "vertex_values"); … … 271 282 PyObject_GetAttrString(quantity, "edge_values"); 272 283 if (!edge_values) return NULL; 284 */ 273 285 274 286 N = vertex_values -> dimensions[0]; … … 312 324 313 325 //Get pertinent variables 314 centroids = (PyArrayObject*) 315 PyObject_GetAttrString(domain, "centroid_coordinates"); 316 if (!centroids) return NULL; 317 326 327 centroids = get_consecutive_array(domain, "centroid_coordinates"); 328 centroid_values = get_consecutive_array(quantity, "centroid_values"); 329 surrogate_neighbours = get_consecutive_array(domain, "surrogate_neighbours"); 330 number_of_boundaries = get_consecutive_array(domain, "number_of_boundaries"); 331 332 //centroids = (PyArrayObject*) 333 // PyArray_ContiguousFromObject( 334 // PyObject_GetAttrString(domain, "centroid_coordinates"), 335 // PyArray_DOUBLE, 0, 0); 336 // if (!centroids) return NULL; 337 338 /* 318 339 centroid_values = (PyArrayObject*) 319 PyObject_GetAttrString(quantity, "centroid_values"); 320 if (!centroid_values) return NULL; 321 340 PyArray_ContiguousFromObject( 341 PyObject_GetAttrString(quantity, 342 "centroid_values"), 343 PyArray_DOUBLE, 0, 0); 344 if (!centroid_values) return NULL; 345 */ 346 347 /* 322 348 surrogate_neighbours = (PyArrayObject*) 323 PyObject_GetAttrString(domain, "surrogate_neighbours"); 349 PyArray_ContiguousFromObject( 350 PyObject_GetAttrString(domain, "surrogate_neighbours"), 351 PyArray_LONG, 0, 0); 324 352 if (!surrogate_neighbours) return NULL; 325 353 326 354 number_of_boundaries = (PyArrayObject*) 327 PyObject_GetAttrString(domain, "number_of_boundaries"); 355 PyArray_ContiguousFromObject( 356 PyObject_GetAttrString(domain, "number_of_boundaries"), 357 PyArray_LONG, 0, 0); 328 358 if (!number_of_boundaries) return NULL; 359 360 */ 329 361 330 362 N = centroid_values -> dimensions[0]; … … 343 375 (double*) centroids -> data, 344 376 (double*) centroid_values -> data, 345 ( int*) number_of_boundaries -> data,346 ( int*) surrogate_neighbours -> data,377 (long*) number_of_boundaries -> data, 378 (long*) surrogate_neighbours -> data, 347 379 (double*) a -> data, 348 380 (double*) b -> data); … … 393 425 394 426 //Get pertinent variables 427 centroids = get_consecutive_array(domain, "centroid_coordinates"); 428 centroid_values = get_consecutive_array(quantity, "centroid_values"); 429 surrogate_neighbours = get_consecutive_array(domain, "surrogate_neighbours"); 430 number_of_boundaries = get_consecutive_array(domain, "number_of_boundaries"); 431 vertex_coordinates = get_consecutive_array(domain, "vertex_coordinates"); 432 vertex_values = get_consecutive_array(quantity, "vertex_values"); 433 434 435 /* 395 436 centroids = (PyArrayObject*) 396 PyObject_GetAttrString(domain, "centroid_coordinates"); 437 PyArray_ContiguousFromObject( 438 PyObject_GetAttrString(domain, "centroid_coordinates"), 439 PyArray_DOUBLE, 0, 0); 397 440 if (!centroids) return NULL; 398 441 399 centroid_values = (PyArrayObject*) 400 PyObject_GetAttrString(quantity, "centroid_values"); 442 443 centroid_values = (PyArrayObject*) 444 PyArray_ContiguousFromObject( 445 PyObject_GetAttrString(quantity, "centroid_values"), 446 PyArray_DOUBLE, 0, 0); 401 447 if (!centroid_values) return NULL; 402 448 403 449 surrogate_neighbours = (PyArrayObject*) 404 PyObject_GetAttrString(domain, "surrogate_neighbours"); 450 PyArray_ContiguousFromObject( 451 PyObject_GetAttrString(domain, "surrogate_neighbours"), 452 PyArray_LONG, 0, 0); 405 453 if (!surrogate_neighbours) return NULL; 406 454 407 455 number_of_boundaries = (PyArrayObject*) 408 PyObject_GetAttrString(domain, "number_of_boundaries"); 456 PyArray_ContiguousFromObject( 457 PyObject_GetAttrString(domain, "number_of_boundaries"), 458 PyArray_LONG, 0, 0); 409 459 if (!number_of_boundaries) return NULL; 410 460 411 461 vertex_coordinates = (PyArrayObject*) 412 PyObject_GetAttrString(domain, "vertex_coordinates"); 462 PyArray_ContiguousFromObject( 463 PyObject_GetAttrString(domain, "vertex_coordinates"), 464 PyArray_DOUBLE, 0, 0); 413 465 if (!vertex_coordinates) return NULL; 414 466 415 vertex_values = (PyArrayObject*) 416 PyObject_GetAttrString(quantity, "vertex_values"); 467 vertex_values = (PyArrayObject*) 468 PyArray_ContiguousFromObject( 469 PyObject_GetAttrString(quantity, "vertex_values"), 470 PyArray_DOUBLE, 0, 0); 417 471 if (!vertex_values) return NULL; 418 419 420 /*421 printf("In extrapolate C routine\n");422 printf("d0=%d, d1=%d\n",423 vertex_values -> dimensions[0],424 vertex_values -> dimensions[1]);425 472 */ 426 473 427 vertex_values = (PyArrayObject*) 428 PyObject_GetAttrString(quantity, "vertex_values"); 429 if (!vertex_values) return NULL; 474 475 430 476 431 477 N = centroid_values -> dimensions[0]; … … 450 496 (double*) centroids -> data, 451 497 (double*) centroid_values -> data, 452 ( int*) number_of_boundaries -> data,453 ( int*) surrogate_neighbours -> data,498 (long*) number_of_boundaries -> data, 499 (long*) surrogate_neighbours -> data, 454 500 (double*) a -> data, 455 501 (double*) b -> data); … … 515 561 return NULL; 516 562 517 neighbours = (PyArrayObject*) PyObject_GetAttrString(domain, "neighbours"); 563 //neighbours = (PyArrayObject*) PyObject_GetAttrString(domain, "neighbours"); 564 neighbours = get_consecutive_array(domain, "neighbours"); 518 565 519 566 //Get safety factor beta … … 527 574 Py_DECREF(domain); 528 575 529 qc = (PyArrayObject*) PyObject_GetAttrString(quantity, "centroid_values"); 530 qv = (PyArrayObject*) PyObject_GetAttrString(quantity, "vertex_values"); 576 //qc = (PyArrayObject*) PyObject_GetAttrString(quantity, "centroid_values"); 577 //qv = (PyArrayObject*) PyObject_GetAttrString(quantity, "vertex_values"); 578 qc = get_consecutive_array(quantity, "centroid_values"); 579 qv = get_consecutive_array(quantity, "vertex_values"); 580 581 531 582 N = qc -> dimensions[0]; 532 583 -
inundation/ga/storm_surge/pyvolution/util_ext.h
r265 r752 69 69 printf("\n"); 70 70 } 71 72 PyArrayObject *get_consecutive_array(PyObject *O, char *name) { 73 PyArrayObject *A, *B; 74 75 76 //Get array object from attribute 77 78 /* 79 //FIXME: THE TEST DOESN't WORK 80 printf("Err = %d\n", PyObject_HasAttrString(O, name)); 81 if (PyObject_HasAttrString(O, name) == 1) { 82 B = (PyArrayObject*) PyObject_GetAttrString(O, name); 83 if (!B) return NULL; 84 } else { 85 return NULL; 86 } 87 */ 88 89 B = (PyArrayObject*) PyObject_GetAttrString(O, name); 90 if (!B) return NULL; 91 92 //Convert to consecutive array 93 A = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*) B, B -> descr -> type, 0, 0); 94 95 //Py_DECREF(B); //FIXME: Is this really needed?? 96 97 if (!A) return NULL; 98 return A; 99 } 100
Note: See TracChangeset
for help on using the changeset viewer.