Changeset 5563 for anuga_work/development/anuga_1d/comp_flux_ext.c
- Timestamp:
- Jul 23, 2008, 4:38:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anuga_1d/comp_flux_ext.c
r5562 r5563 5 5 const double pi = 3.14159265358979; 6 6 7 double max(double a, double b) { 8 double z; 9 z=(a>b)?a:b; 10 return z;} 11 12 double min(double a, double b) { 13 double z; 14 z=(a<b)?a:b; 15 return z;} 7 // Shared code snippets 8 #include "util_ext.h" 9 10 11 /* double max(double a, double b) { */ 12 /* double z; */ 13 /* z=(a>b)?a:b; */ 14 /* return z;} */ 15 16 /* double min(double a, double b) { */ 17 /* double z; */ 18 /* z=(a<b)?a:b; */ 19 /* return z;} */ 16 20 17 21 … … 154 158 155 159 normal = normals[ki]; 156 _flux_function(ql, qr, zl, zr, normal, g, epsilon, flux, &max_speed);160 _flux_function(ql, qr, zl, zr, normal, g, epsilon, edgeflux, &max_speed); 157 161 flux[0] -= edgeflux[0]; 158 162 flux[1] -= edgeflux[1]; … … 189 193 //========================================================================= 190 194 PyObject *compute_fluxes_ext(PyObject *self, PyObject *args) { 191 PyArrayObject *neighbours, 195 196 PyArrayObject 197 *neighbours, 192 198 *neighbour_vertices, 193 199 *normals, 194 200 *areas, 195 196 197 198 199 201 *stage_edge_values, 202 *xmom_edge_values, 203 *bed_edge_values, 204 *stage_boundary_values, 205 *xmom_boundary_values, 200 206 *stage_explicit_update, 201 207 *xmom_explicit_update, … … 231 237 // the explicit update arrays 232 238 timestep = _compute_fluxes_ext(timestep, 233 epsilon, 234 g, 235 (long*) neighbours -> data, 236 (long*) neighbour_vertices -> data, 237 (double*) normals -> data, 238 (double*) areas -> data, 239 (double*) stage_edge_values -> data, 240 (double*) xmom_edge_values -> data, 241 (double*) bed_edge_values -> data, 242 (double*) stage_boundary_values -> data, 243 (double*) xmom_boundary_values -> data, 244 (double*) stage_explicit_update -> data, 245 (double*) xmom_explicit_update -> data, 246 number_of_elements, 247 (double*) max_speed_array -> data); 239 epsilon, 240 g, 241 (long*) neighbours -> data, 242 (long*) neighbour_vertices -> data, 243 (double*) normals -> data, 244 (double*) areas -> data, 245 (double*) stage_edge_values -> data, 246 (double*) xmom_edge_values -> data, 247 (double*) bed_edge_values -> data, 248 (double*) stage_boundary_values -> data, 249 (double*) xmom_boundary_values -> data, 250 (double*) stage_explicit_update -> data, 251 (double*) xmom_explicit_update -> data, 252 number_of_elements, 253 (double*) max_speed_array -> data); 254 248 255 // Return updated flux timestep 249 256 return Py_BuildValue("d", timestep); 250 257 } 251 258 259 260 PyObject *compute_fluxes_ext_short(PyObject *self, PyObject *args) { 261 262 PyObject 263 *domain, 264 *stage, 265 *xmom, 266 *bed; 267 268 PyArrayObject 269 *neighbours, 270 *neighbour_vertices, 271 *normals, 272 *areas, 273 *stage_vertex_values, 274 *xmom_vertex_values, 275 *bed_vertex_values, 276 *stage_boundary_values, 277 *xmom_boundary_values, 278 *stage_explicit_update, 279 *xmom_explicit_update, 280 *max_speed_array; 281 282 double timestep, epsilon, g; 283 int number_of_elements; 284 285 286 // Convert Python arguments to C 287 if (!PyArg_ParseTuple(args, "dOOOO", 288 ×tep, 289 &domain, 290 &stage, 291 &xmom, 292 &bed)) { 293 PyErr_SetString(PyExc_RuntimeError, "comp_flux_ext.c: compute_fluxes_ext_short could not parse input"); 294 return NULL; 295 } 296 297 298 epsilon = get_python_double(domain,"epsilon"); 299 g = get_python_double(domain,"g"); 300 301 302 neighbours = get_consecutive_array(domain, "neighbours"); 303 neighbour_vertices= get_consecutive_array(domain, "neighbour_vertices"); 304 normals = get_consecutive_array(domain, "normals"); 305 areas = get_consecutive_array(domain, "areas"); 306 max_speed_array = get_consecutive_array(domain, "max_speed_array"); 307 308 stage_vertex_values = get_consecutive_array(stage, "vertex_values"); 309 xmom_vertex_values = get_consecutive_array(xmom, "vertex_values"); 310 bed_vertex_values = get_consecutive_array(bed, "vertex_values"); 311 312 stage_boundary_values = get_consecutive_array(stage, "boundary_values"); 313 xmom_boundary_values = get_consecutive_array(xmom, "boundary_values"); 314 315 316 stage_explicit_update = get_consecutive_array(stage, "explicit_update"); 317 xmom_explicit_update = get_consecutive_array(xmom, "explicit_update"); 318 319 320 321 number_of_elements = stage_vertex_values -> dimensions[0]; 322 323 324 325 // Call underlying flux computation routine and update 326 // the explicit update arrays 327 timestep = _compute_fluxes_ext(timestep, 328 epsilon, 329 g, 330 (long*) neighbours -> data, 331 (long*) neighbour_vertices -> data, 332 (double*) normals -> data, 333 (double*) areas -> data, 334 (double*) stage_vertex_values -> data, 335 (double*) xmom_vertex_values -> data, 336 (double*) bed_vertex_values -> data, 337 (double*) stage_boundary_values -> data, 338 (double*) xmom_boundary_values -> data, 339 (double*) stage_explicit_update -> data, 340 (double*) xmom_explicit_update -> data, 341 number_of_elements, 342 (double*) max_speed_array -> data); 343 344 345 Py_DECREF(neighbours); 346 Py_DECREF(neighbour_vertices); 347 Py_DECREF(normals); 348 Py_DECREF(areas); 349 Py_DECREF(stage_vertex_values); 350 Py_DECREF(xmom_vertex_values); 351 Py_DECREF(bed_vertex_values); 352 Py_DECREF(stage_boundary_values); 353 Py_DECREF(xmom_boundary_values); 354 Py_DECREF(stage_explicit_update); 355 Py_DECREF(xmom_explicit_update); 356 Py_DECREF(max_speed_array); 357 358 359 360 361 // Return updated flux timestep 362 return Py_BuildValue("d", timestep); 363 } 364 252 365 253 366 … … 259 372 static struct PyMethodDef MethodTable[] = { 260 373 {"compute_fluxes_ext", compute_fluxes_ext, METH_VARARGS, "Print out"}, 374 {"compute_fluxes_ext_short", compute_fluxes_ext_short, METH_VARARGS, "Print out"}, 261 375 {NULL, NULL} 262 376 };
Note: See TracChangeset
for help on using the changeset viewer.