Changeset 7783
- Timestamp:
- Jun 5, 2010, 7:03:43 PM (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/pipeflow/sww_comp_flux_ext.c
r7780 r7783 168 168 //========================================================================= 169 169 PyObject *compute_fluxes_ext(PyObject *self, PyObject *args) { 170 171 PyArrayObject 172 *neighbours, 170 171 PyObject 172 *domain, 173 *stage, 174 *xmom, 175 *bed, 176 *height, 177 *velocity; 178 179 PyArrayObject 180 *neighbours, 173 181 *neighbour_vertices, 174 *normals, 182 *normals, 175 183 *areas, 176 184 *stage_vertex_values, … … 188 196 *max_speed_array; 189 197 190 191 double timestep, epsilon, g, h0, cfl; 192 int number_of_elements; 193 194 // Convert Python arguments to C 195 if (!PyArg_ParseTuple(args, "dddddOOOOOOOOOOOOOOOOiO", 196 &cfl, 197 ×tep, 198 &epsilon, 199 &g, 200 &h0, 201 &neighbours, 202 &neighbour_vertices, 203 &normals, 204 &areas, 205 &stage_vertex_values, 206 &xmom_vertex_values, 207 &bed_vertex_values, 208 &height_vertex_values, 209 &velocity_vertex_values, 210 &stage_boundary_values, 211 &xmom_boundary_values, 212 &bed_boundary_values, 213 &height_boundary_values, 214 &velocity_boundary_values, 215 &stage_explicit_update, 216 &xmom_explicit_update, 217 &number_of_elements, 218 &max_speed_array)) { 219 PyErr_SetString(PyExc_RuntimeError, "comp_flux_ext.c: compute_fluxes_ext could not parse input"); 220 return NULL; 221 } 222 223 224 // Call underlying flux computation routine and update 225 // the explicit update arrays 198 double timestep, epsilon, g, h0, cfl; 199 int number_of_elements; 200 201 202 // Convert Python arguments to C 203 if (!PyArg_ParseTuple(args, "dOOOOOO", 204 ×tep, 205 &domain, 206 &stage, 207 &xmom, 208 &bed, 209 &height, 210 &velocity)) { 211 PyErr_SetString(PyExc_RuntimeError, "comp_flux_ext.c: compute_fluxes_ext_short could not parse input"); 212 return NULL; 213 } 214 215 216 epsilon = get_python_double(domain,"epsilon"); 217 g = get_python_double(domain,"g"); 218 h0 = get_python_double(domain,"h0"); 219 cfl = get_python_double(domain,"cfl"); 220 221 222 neighbours = get_consecutive_array(domain, "neighbours"); 223 neighbour_vertices= get_consecutive_array(domain, "neighbour_vertices"); 224 normals = get_consecutive_array(domain, "normals"); 225 areas = get_consecutive_array(domain, "areas"); 226 max_speed_array = get_consecutive_array(domain, "max_speed_array"); 227 228 stage_vertex_values = get_consecutive_array(stage, "vertex_values"); 229 xmom_vertex_values = get_consecutive_array(xmom, "vertex_values"); 230 bed_vertex_values = get_consecutive_array(bed, "vertex_values"); 231 height_vertex_values = get_consecutive_array(height, "vertex_values"); 232 velocity_vertex_values = get_consecutive_array(velocity, "vertex_values"); 233 234 stage_boundary_values = get_consecutive_array(stage, "boundary_values"); 235 xmom_boundary_values = get_consecutive_array(xmom, "boundary_values"); 236 bed_boundary_values = get_consecutive_array(bed, "boundary_values"); 237 height_boundary_values = get_consecutive_array(height, "boundary_values"); 238 velocity_boundary_values = get_consecutive_array(velocity, "boundary_values"); 239 240 241 stage_explicit_update = get_consecutive_array(stage, "explicit_update"); 242 xmom_explicit_update = get_consecutive_array(xmom, "explicit_update"); 243 244 number_of_elements = stage_vertex_values -> dimensions[0]; 245 246 // Call underlying flux computation routine and update 247 // the explicit update arrays 226 248 timestep = _compute_fluxes_ext( 227 249 cfl, … … 250 272 251 273 252 // Return updated flux timestep253 return Py_BuildValue("d", timestep);254 }255 256 257 PyObject *compute_fluxes_ext_short(PyObject *self, PyObject *args) {258 259 PyObject260 *domain,261 *stage,262 *xmom,263 *bed,264 *height,265 *velocity;266 267 PyArrayObject268 *neighbours,269 *neighbour_vertices,270 *normals,271 *areas,272 *stage_vertex_values,273 *xmom_vertex_values,274 *bed_vertex_values,275 *height_vertex_values,276 *velocity_vertex_values,277 *stage_boundary_values,278 *xmom_boundary_values,279 *bed_boundary_values,280 *height_boundary_values,281 *velocity_boundary_values,282 *stage_explicit_update,283 *xmom_explicit_update,284 *max_speed_array;285 286 double timestep, epsilon, g, h0, cfl;287 int number_of_elements;288 289 290 // Convert Python arguments to C291 if (!PyArg_ParseTuple(args, "dOOOOOO",292 ×tep,293 &domain,294 &stage,295 &xmom,296 &bed,297 &height,298 &velocity)) {299 PyErr_SetString(PyExc_RuntimeError, "comp_flux_ext.c: compute_fluxes_ext_short could not parse input");300 return NULL;301 }302 303 304 epsilon = get_python_double(domain,"epsilon");305 g = get_python_double(domain,"g");306 h0 = get_python_double(domain,"h0");307 cfl = get_python_double(domain,"cfl");308 309 310 neighbours = get_consecutive_array(domain, "neighbours");311 neighbour_vertices= get_consecutive_array(domain, "neighbour_vertices");312 normals = get_consecutive_array(domain, "normals");313 areas = get_consecutive_array(domain, "areas");314 max_speed_array = get_consecutive_array(domain, "max_speed_array");315 316 stage_vertex_values = get_consecutive_array(stage, "vertex_values");317 xmom_vertex_values = get_consecutive_array(xmom, "vertex_values");318 bed_vertex_values = get_consecutive_array(bed, "vertex_values");319 height_vertex_values = get_consecutive_array(height, "vertex_values");320 velocity_vertex_values = get_consecutive_array(velocity, "vertex_values");321 322 stage_boundary_values = get_consecutive_array(stage, "boundary_values");323 xmom_boundary_values = get_consecutive_array(xmom, "boundary_values");324 bed_boundary_values = get_consecutive_array(bed, "boundary_values");325 height_boundary_values = get_consecutive_array(height, "boundary_values");326 velocity_boundary_values = get_consecutive_array(velocity, "boundary_values");327 328 329 stage_explicit_update = get_consecutive_array(stage, "explicit_update");330 xmom_explicit_update = get_consecutive_array(xmom, "explicit_update");331 332 number_of_elements = stage_vertex_values -> dimensions[0];333 334 // Call underlying flux computation routine and update335 // the explicit update arrays336 timestep = _compute_fluxes_ext(337 cfl,338 timestep,339 epsilon,340 g,341 h0,342 (long*) neighbours -> data,343 (long*) neighbour_vertices -> data,344 (double*) normals -> data,345 (double*) areas -> data,346 (double*) stage_vertex_values -> data,347 (double*) xmom_vertex_values -> data,348 (double*) bed_vertex_values -> data,349 (double*) height_vertex_values -> data,350 (double*) velocity_vertex_values -> data,351 (double*) stage_boundary_values -> data,352 (double*) xmom_boundary_values -> data,353 (double*) bed_boundary_values -> data,354 (double*) height_boundary_values -> data,355 (double*) velocity_boundary_values -> data,356 (double*) stage_explicit_update -> data,357 (double*) xmom_explicit_update -> data,358 number_of_elements,359 (double*) max_speed_array -> data);360 361 362 274 Py_DECREF(neighbours); 363 275 Py_DECREF(neighbour_vertices); … … 383 295 } 384 296 297 298 385 299 //------------------------------- 386 300 // Method table for python module … … 389 303 static struct PyMethodDef MethodTable[] = { 390 304 {"compute_fluxes_ext", compute_fluxes_ext, METH_VARARGS, "Print out"}, 391 {"compute_fluxes_ext_short", compute_fluxes_ext_short, METH_VARARGS, "Print out"},392 305 {NULL, NULL} 393 306 }; 394 307 395 308 // Module initialisation 396 void init comp_flux_ext(void){397 Py_InitModule(" comp_flux_ext", MethodTable);309 void initsww_comp_flux_ext(void){ 310 Py_InitModule("sww_comp_flux_ext", MethodTable); 398 311 import_array(); 399 312 }
Note: See TracChangeset
for help on using the changeset viewer.