Changeset 7930
- Timestamp:
- Aug 6, 2010, 3:17:50 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/benchmarks/create_test_sww.py
r7877 r7930 10 10 #------------------------------------------------------------------------------ 11 11 points, vertices, boundary = anuga.rectangular_cross(5, 5, 12 12 len1=50.0, len2=50.0) # Mesh 13 13 14 14 domain = anuga.Domain(points, vertices, boundary) # Create domain -
trunk/anuga_work/development/2010-projects/anuga_1d/base/limiters_python.py
r7884 r7930 46 46 from numpy import abs, where 47 47 48 return where((a*a + b*b >= 1.0e- 16), (a*a*b+a*b*b)/(a*a+b*b), 0.0)48 return where((a*a + b*b >= 1.0e-32), (a*a*b+a*b*b)/(a*a+b*b), 0.0) 49 49 50 50 -
trunk/anuga_work/development/2010-projects/anuga_1d/base/quantity_ext.c
r7884 r7930 142 142 // Convert Python arguments to C 143 143 if (!PyArg_ParseTuple(args, "O", &quantity)) { 144 PyErr_SetString(PyExc_RuntimeError, "quantity_ext.c: limit_ 144 PyErr_SetString(PyExc_RuntimeError, "quantity_ext.c: limit_minmod_kurganov_ext could not parse input"); 145 145 return NULL; 146 146 } … … 320 320 321 321 322 //==================================================================== 323 PyObject *limit_vanalbada_ext(PyObject *self, PyObject *args) { 324 325 PyObject 326 *domain, 327 *quantity; 328 329 PyArrayObject 330 *qco, 331 *qvo, 332 *xco, 333 *xvo; 334 335 double *qc, 336 *qv, 337 *xc, 338 *xv; 339 340 double a, b; 341 //double c; 342 double phi, dx0, dx1; 343 double theta; 344 int N, k, k2; 345 346 347 // Convert Python arguments to C 348 if (!PyArg_ParseTuple(args, "O", &quantity)) { 349 PyErr_SetString(PyExc_RuntimeError, "quantity_ext.c: limit_vanalbada_ext could not parse input"); 350 return NULL; 351 } 352 353 354 domain = PyObject_GetAttrString(quantity, "domain"); 355 356 //printf("B = %p\n",(void*)domain); 357 if (!domain) { 358 printf("quantity_ext.c: Could not obtain python object"); 359 fflush(stdout); 360 PyErr_SetString(PyExc_RuntimeError, "quantity_ext.c: Could not obtain python object domain"); 361 return NULL; 362 } 363 364 365 366 N = get_python_integer(quantity,"N"); 367 theta = get_python_double(quantity,"beta"); 368 369 370 //printf("beta = %f",theta); 371 //fflush(stdout); 372 373 qco = get_consecutive_array(quantity, "centroid_values"); 374 qvo = get_consecutive_array(quantity, "vertex_values"); 375 xco = get_consecutive_array(domain, "centroids"); 376 xvo = get_consecutive_array(domain, "vertices"); 377 378 qc = (double *) qco -> data; 379 qv = (double *) qvo -> data; 380 xc = (double *) xco -> data; 381 xv = (double *) xvo -> data; 382 383 384 for (k=0; k<N; k++) { 385 k2 = 2*k; 386 if (k == 0) { 387 phi = (qc[1]-qc[0])/(xc[1] - xc[0]); 388 } 389 else if (k==N-1) { 390 phi = (qc[N-1] - qc[N-2])/(xc[N-1] - xc[N-2]); 391 } 392 else { 393 a = (qc[k]-qc[k-1])/(xc[k]-xc[k-1]); 394 b = (qc[k+1]-qc[k])/(xc[k+1]-xc[k]); 395 //c = (qc[k+1]-qc[k-1])/(xc[k+1]-xc[k-1]); 396 397 398 phi = 0.0; 399 if (a*a + b*b >= 1.0e-32) { 400 phi = (a*a*b+a*b*b)/(a*a+b*b); 401 } 402 403 404 } 405 406 dx0 = xv[k2] - xc[k]; 407 dx1 = xv[k2+1] - xc[k]; 408 409 410 qv[k2] = qc[k] + phi*dx0; 411 qv[k2+1] = qc[k] + phi*dx1; 412 } 413 414 415 Py_DECREF(qco); 416 Py_DECREF(qvo); 417 Py_DECREF(xco); 418 Py_DECREF(xvo); 419 420 // Return updated flux timestep 421 return Py_BuildValue(""); 422 } 423 322 424 323 425 … … 330 432 {"limit_minmod_kurganov_ext", limit_minmod_kurganov_ext, METH_VARARGS, "Print out"}, 331 433 {"limit_vanleer_ext", limit_vanleer_ext, METH_VARARGS, "Print out"}, 434 {"limit_vanalbada_ext", limit_vanalbada_ext, METH_VARARGS, "Print out"}, 332 435 {NULL, NULL} 333 436 }; -
trunk/anuga_work/development/2010-projects/anuga_1d/base/test_quantity_1d.py
r7884 r7930 595 595 [ 10.39393939, 11.60606061], 596 596 [ 11.4, 14.6 ]] ) 597 # 597 598 def test_limit_vanalbada(self): 599 quantity = Quantity(self.domain4) 600 601 #Create a deliberate overshoot (e.g. from gradient computation) 602 quantity.set_values([[0,0], [2,10], [9,13], [12,14]]) 603 604 #Limit 605 quantity.limiter = 'vanalbada' 606 quantity.limit_range() 607 608 609 print quantity.vertex_values 610 611 assert allclose(quantity.vertex_values, [[ -2.4, 2.4 ], 612 [ 2.32805995, 9.67194005], 613 [ 10.52104499, 11.47895501], 614 [ 11.4, 14.6 ]]) 615 616 from anuga_1d.base.quantity_ext import limit_vanalbada_ext 617 618 quantity.set_values([[0,0], [2,10], [9,13], [12,14]]) 619 620 limit_vanalbada_ext(quantity) 621 622 print quantity.vertex_values 623 624 625 626 627 assert allclose(quantity.vertex_values, [[ -2.4, 2.4 ], 628 [ 2.32805995, 9.67194005], 629 [ 10.52104499, 11.47895501], 630 [ 11.4, 14.6 ]] ) 631 632 633 598 634 599 635 def test_find_qmax_qmin(self):
Note: See TracChangeset
for help on using the changeset viewer.