 Timestamp:
 Sep 7, 2007, 10:43:46 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

anuga_core/source/anuga/abstract_2d_finite_volumes/quantity_ext.c
r4536 r4712 100 100 101 101 102 102 103 int _extrapolate(int N, 103 104 double* centroids, … … 162 163 return 0; 163 164 } 165 166 int _backup_centroid_values(int N, 167 double* centroid_values, 168 double* centroid_backup_values) { 169 //Backup centroid values 170 171 172 int k; 173 174 for (k=0; k<N; k++) { 175 centroid_backup_values[k] = centroid_values[k]; 176 } 177 178 179 return 0; 180 } 181 182 183 int _saxpy_centroid_values(int N, 184 double a, 185 double b, 186 double* centroid_values, 187 double* centroid_backup_values) { 188 //saxby centroid values 189 190 191 int k; 192 193 194 for (k=0; k<N; k++) { 195 centroid_values[k] = a*centroid_values[k] + b*centroid_backup_values[k]; 196 } 197 198 199 return 0; 200 } 201 164 202 165 203 int _update(int N, … … 305 343 306 344 345 PyObject *backup_centroid_values(PyObject *self, PyObject *args) { 346 347 PyObject *quantity; 348 PyArrayObject *centroid_values, *centroid_backup_values; 349 350 int N, err; 351 352 353 // Convert Python arguments to C 354 if (!PyArg_ParseTuple(args, "O", &quantity)) { 355 PyErr_SetString(PyExc_RuntimeError, 356 "quantity_ext.c: backup_centroid_values could not parse input"); 357 return NULL; 358 } 359 360 centroid_values = get_consecutive_array(quantity, "centroid_values"); 361 centroid_backup_values = get_consecutive_array(quantity, "centroid_backup_values"); 362 363 N = centroid_values > dimensions[0]; 364 365 err = _backup_centroid_values(N, 366 (double*) centroid_values > data, 367 (double*) centroid_backup_values > data); 368 369 370 //Release and return 371 Py_DECREF(centroid_values); 372 Py_DECREF(centroid_backup_values); 373 374 return Py_BuildValue(""); 375 } 376 377 PyObject *saxpy_centroid_values(PyObject *self, PyObject *args) { 378 379 PyObject *quantity; 380 PyArrayObject *centroid_values, *centroid_backup_values; 381 382 double a,b; 383 int N, err; 384 385 386 // Convert Python arguments to C 387 if (!PyArg_ParseTuple(args, "Odd", &quantity, &a, &b)) { 388 PyErr_SetString(PyExc_RuntimeError, 389 "quantity_ext.c: saxpy_centroid_values could not parse input"); 390 return NULL; 391 } 392 393 centroid_values = get_consecutive_array(quantity, "centroid_values"); 394 centroid_backup_values = get_consecutive_array(quantity, "centroid_backup_values"); 395 396 N = centroid_values > dimensions[0]; 397 398 err = _saxpy_centroid_values(N,a,b, 399 (double*) centroid_values > data, 400 (double*) centroid_backup_values > data); 401 402 403 //Release and return 404 Py_DECREF(centroid_values); 405 Py_DECREF(centroid_backup_values); 406 407 return Py_BuildValue(""); 408 } 409 410 307 411 PyObject *interpolate_from_vertices_to_edges(PyObject *self, PyObject *args) { 308 412 … … 645 749 {"limit", limit, METH_VARARGS, "Print out"}, 646 750 {"update", update, METH_VARARGS, "Print out"}, 751 {"backup_centroid_values", backup_centroid_values, METH_VARARGS, "Print out"}, 752 {"saxpy_centroid_values", saxpy_centroid_values, METH_VARARGS, "Print out"}, 647 753 {"compute_gradients", compute_gradients, METH_VARARGS, "Print out"}, 648 754 {"extrapolate_second_order", extrapolate_second_order,
Note: See TracChangeset
for help on using the changeset viewer.