Changeset 5162
- Timestamp:
- Mar 11, 2008, 8:43:22 PM (17 years ago)
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r5080 r5162 10 10 from Numeric import allclose, argmax, zeros, Float 11 11 from anuga.config import epsilon 12 from anuga.config import beta_euler, beta_rk2 12 13 13 14 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh … … 301 302 self.default_order = n 302 303 self._order_ = self.default_order 304 305 if self.default_order == 1: 306 self.set_timestepping_method('euler') 307 #self.set_all_limiters(beta_euler) 308 309 if self.default_order == 2: 310 self.set_timestepping_method('rk2') 311 #self.set_all_limiters(beta_rk2) 303 312 304 313 … … 1550 1559 elif self._order_ == 2: 1551 1560 Q.extrapolate_second_order() 1552 Q.limit()1561 #Q.limit() 1553 1562 else: 1554 1563 raise 'Unknown order' 1555 Q.interpolate_from_vertices_to_edges()1564 #Q.interpolate_from_vertices_to_edges() 1556 1565 1557 1566 -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r4990 r5162 62 62 #Allocate space for Gradient 63 63 self.x_gradient = zeros(N, Float) 64 self.y_gradient = zeros(N, Float) 64 self.y_gradient = zeros(N, Float) 65 66 #Allocate space for Limiter Phi 67 self.phi = zeros(N, Float) 65 68 66 69 #Intialise centroid and edge_values … … 74 77 #flux calculations and forcing functions 75 78 76 N = len(domain) # number_of_triangles79 #Allocate space for update fields 77 80 self.explicit_update = zeros(N, Float ) 78 81 self.semi_implicit_update = zeros(N, Float ) 79 self.centroid_backup_values = zeros(N, Float) 82 self.centroid_backup_values = zeros(N, Float) 83 84 self.beta = 1.0 80 85 81 86 … … 1403 1408 compute_gradients(self) 1404 1409 extrapolate_from_gradient(self) 1405 1410 1406 1411 def extrapolate_second_order_and_limit(self): 1407 1412 #Call correct module function 1408 1413 #(either from this module or C-extension) 1409 extrapolate_second_order_and_limit(self) 1414 extrapolate_second_order_and_limit(self) 1415 1416 def bound_vertices_below_by_constant(self, bound): 1417 #Call correct module function 1418 #(either from this module or C-extension) 1419 bound_vertices_below_by_constant(self, bound) 1420 1421 def bound_vertices_below_by_quantity(self, quantity): 1422 #Call correct module function 1423 #(either from this module or C-extension) 1424 1425 #check consistency 1426 assert self.domain == quantity.domain 1427 bound_vertices_below_by_quantity(self, quantity) 1410 1428 1411 1429 def backup_centroid_values(self): … … 1450 1468 limit_gradient_by_neighbour,\ 1451 1469 extrapolate_from_gradient,\ 1470 extrapolate_second_order_and_limit,\ 1471 bound_vertices_below_by_constant,\ 1472 bound_vertices_below_by_quantity,\ 1452 1473 interpolate_from_vertices_to_edges,\ 1453 1474 interpolate_from_edges_to_vertices,\ -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity_ext.c
r4990 r5162 145 145 double* vertex_values, 146 146 double* edge_values, 147 double* phi, 147 148 double* x_gradient, 148 149 double* y_gradient) { … … 151 152 double x, y, x0, y0, x1, y1, x2, y2; 152 153 long n; 153 double qmin, qmax, q n, qc;154 double dq, dqa[3], phi, r;155 154 double qmin, qmax, qc; 155 double qn[3]; 156 double dq, dqa[3], r; 156 157 157 158 for (k=0; k<N; k++){ … … 161 162 162 163 // Centroid coordinates 163 x = centroids[k2]; y = centroids[k2+1]; 164 x = centroids[k2+0]; 165 y = centroids[k2+1]; 164 166 165 167 // vertex coordinates 166 168 // x0, y0, x1, y1, x2, y2 = X[k,:] 167 169 x0 = vertex_coordinates[k6 + 0]; 168 170 y0 = vertex_coordinates[k6 + 1]; 169 171 x1 = vertex_coordinates[k6 + 2]; … … 172 174 y2 = vertex_coordinates[k6 + 5]; 173 175 174 //Centroid Value175 qc = centroid_values[k];176 177 176 // Extrapolate to Vertices 178 177 vertex_values[k3+0] = centroid_values[k] + x_gradient[k]*(x0-x) + y_gradient[k]*(y0-y); … … 184 183 edge_values[k3+1] = 0.5*(vertex_values[k3 + 2]+vertex_values[k3 + 0]); 185 184 edge_values[k3+2] = 0.5*(vertex_values[k3 + 0]+vertex_values[k3 + 1]); 186 187 188 phi = 1.0; 185 } 186 187 188 189 for (k=0; k<N; k++){ 190 k6 = 6*k; 191 k3 = 3*k; 192 k2 = 2*k; 193 194 195 qc = centroid_values[k]; 196 197 qmin = qc; 198 qmax = qc; 199 200 for (i=0; i<3; i++) { 201 n = neighbours[k3+i]; 202 if (n < 0) { 203 qn[i] = qc; 204 } else { 205 qn[i] = centroid_values[n]; 206 } 207 208 qmin = min(qmin, qn[i]); 209 qmax = max(qmax, qn[i]); 210 } 211 212 //qtmin = min(min(min(qn[0],qn[1]),qn[2]),qc); 213 //qtmax = max(max(max(qn[0],qn[1]),qn[2]),qc); 214 215 /* for (i=0; i<3; i++) { */ 216 /* n = neighbours[k3+i]; */ 217 /* if (n < 0) { */ 218 /* qn[i] = qc; */ 219 /* qmin[i] = qtmin; */ 220 /* qmax[i] = qtmax; */ 221 /* } */ 222 /* } */ 223 224 phi[k] = 1.0; 189 225 190 226 for (i=0; i<3; i++) { … … 192 228 dqa[i] = dq; //Save dq for use in updating vertex values 193 229 194 n = neighbours[k3+i]; 195 if (n >= 0) { 196 qn = centroid_values[n]; //Neighbour's centroid value 197 198 qmin = min(qc, qn); 199 qmax = max(qc, qn); 200 201 202 r = 1.0; 230 r = 1.0; 203 231 204 205 if (dq < 0.0) r = (qmin - qc)/dq;232 if (dq > 0.0) r = (qmax - qc)/dq; 233 if (dq < 0.0) r = (qmin - qc)/dq; 206 234 207 phi = min( min(r*beta, 1.0), phi);208 }235 phi[k] = min( min(r*beta, 1.0), phi[k]); 236 209 237 } 210 238 211 239 240 212 241 //Update gradient, edge and vertex values using phi limiter 213 x_gradient[k] = x_gradient[k]*phi ;214 y_gradient[k] = y_gradient[k]*phi ;215 216 edge_values[k3+0] = qc + phi *dqa[0];217 edge_values[k3+1] = qc + phi *dqa[1];218 edge_values[k3+2] = qc + phi *dqa[2];242 x_gradient[k] = x_gradient[k]*phi[k]; 243 y_gradient[k] = y_gradient[k]*phi[k]; 244 245 edge_values[k3+0] = qc + phi[k]*dqa[0]; 246 edge_values[k3+1] = qc + phi[k]*dqa[1]; 247 edge_values[k3+2] = qc + phi[k]*dqa[2]; 219 248 220 249 … … 222 251 vertex_values[k3+1] = edge_values[k3+2] + edge_values[k3+0] - edge_values[k3+1]; 223 252 vertex_values[k3+2] = edge_values[k3+0] + edge_values[k3+1] - edge_values[k3+2]; 253 224 254 225 255 } … … 290 320 } 291 321 322 323 324 292 325 int _limit_edges_by_all_neighbours(int N, double beta, 293 double* centroid_values, 294 double* vertex_values, 295 double* edge_values, 296 long* neighbours) { 326 double* centroid_values, 327 double* vertex_values, 328 double* edge_values, 329 long* neighbours, 330 double* x_gradient, 331 double* y_gradient) { 297 332 298 333 int i, k, k2, k3, k6; … … 334 369 } 335 370 336 //Update vertex and edge values using phi limiter 371 //Update gradient, vertex and edge values using phi limiter 372 x_gradient[k] = x_gradient[k]*phi; 373 y_gradient[k] = y_gradient[k]*phi; 374 337 375 edge_values[k3+0] = qc + phi*dqa[0]; 338 376 edge_values[k3+1] = qc + phi*dqa[1]; … … 353 391 double* vertex_values, 354 392 double* edge_values, 393 long* neighbours) { 394 395 int i, k, k2, k3, k6; 396 long n; 397 double qmin, qmax, qn, qc; 398 double dq, dqa[3], phi, r; 399 400 for (k=0; k<N; k++){ 401 k6 = 6*k; 402 k3 = 3*k; 403 k2 = 2*k; 404 405 qc = centroid_values[k]; 406 phi = 1.0; 407 408 for (i=0; i<3; i++) { 409 dq = edge_values[k3+i] - qc; //Delta between edge and centroid values 410 dqa[i] = dq; //Save dqa for use in updating vertex values 411 412 n = neighbours[k3+i]; 413 qn = qc; 414 if (n >= 0) qn = centroid_values[n]; //Neighbour's centroid value 415 416 qmin = min(qc, qn); 417 qmax = max(qc, qn); 418 419 r = 1.0; 420 421 if (dq > 0.0) r = (qmax - qc)/dq; 422 if (dq < 0.0) r = (qmin - qc)/dq; 423 424 phi = min( min(r*beta, 1.0), phi); 425 426 } 427 428 429 //Update edge and vertex values using phi limiter 430 edge_values[k3+0] = qc + phi*dqa[0]; 431 edge_values[k3+1] = qc + phi*dqa[1]; 432 edge_values[k3+2] = qc + phi*dqa[2]; 433 434 vertex_values[k3+0] = edge_values[k3+1] + edge_values[k3+2] - edge_values[k3+0]; 435 vertex_values[k3+1] = edge_values[k3+2] + edge_values[k3+0] - edge_values[k3+1]; 436 vertex_values[k3+2] = edge_values[k3+0] + edge_values[k3+1] - edge_values[k3+2]; 437 438 } 439 440 return 0; 441 } 442 443 444 int _limit_gradient_by_neighbour(int N, double beta, 445 double* centroid_values, 446 double* vertex_values, 447 double* edge_values, 448 double* x_gradient, 449 double* y_gradient, 355 450 long* neighbours) { 356 451 … … 403 498 } 404 499 405 406 int _limit_gradient_by_neighbour(int N, double beta, 500 int _bound_vertices_below_by_constant(int N, double bound, 407 501 double* centroid_values, 408 502 double* vertex_values, 409 503 double* edge_values, 410 504 double* x_gradient, 411 double* y_gradient, 412 long* neighbours) { 505 double* y_gradient) { 413 506 414 507 int i, k, k2, k3, k6; 415 long n; 416 double qmin, qmax, qn, qc; 508 double qmin, qc; 417 509 double dq, dqa[3], phi, r; 418 510 … … 423 515 424 516 qc = centroid_values[k]; 517 qmin = bound; 518 519 425 520 phi = 1.0; 426 427 for (i=0; i<3; i++) { 428 dq = edge_values[k3+i] - qc; //Delta between edge and centroid values 521 for (i=0; i<3; i++) { 522 r = 1.0; 523 524 dq = vertex_values[k3+i] - qc; //Delta between vertex and centroid values 429 525 dqa[i] = dq; //Save dq for use in updating vertex values 430 431 n = neighbours[k3+i];432 if (n >= 0) {433 qn = centroid_values[n]; //Neighbour's centroid value434 435 qmin = min(qc, qn);436 qmax = max(qc, qn);437 438 r = 1.0;439 526 440 if (dq > 0.0) r = (qmax - qc)/dq;441 if (dq < 0.0) r = (qmin - qc)/dq;527 if (dq < 0.0) r = (qmin - qc)/dq; 528 442 529 443 phi = min( min(r*beta, 1.0), phi); 444 } 530 phi = min( min(r, 1.0), phi); 445 531 } 446 447 448 //Update edge and vertex values using phi limiter 449 edge_values[k3+0] = qc + phi*dqa[0]; 450 edge_values[k3+1] = qc + phi*dqa[1]; 451 edge_values[k3+2] = qc + phi*dqa[2]; 532 533 534 //Update gradient, vertex and edge values using phi limiter 535 x_gradient[k] = x_gradient[k]*phi; 536 y_gradient[k] = y_gradient[k]*phi; 537 538 vertex_values[k3+0] = qc + phi*dqa[0]; 539 vertex_values[k3+1] = qc + phi*dqa[1]; 540 vertex_values[k3+2] = qc + phi*dqa[2]; 452 541 453 vertex_values[k3+0] = edge_values[k3+1] + edge_values[k3+2] - edge_values[k3+0];454 vertex_values[k3+1] = edge_values[k3+2] + edge_values[k3+0] - edge_values[k3+1];455 vertex_values[k3+2] = edge_values[k3+0] + edge_values[k3+1] - edge_values[k3+2];542 edge_values[k3+0] = 0.5*(vertex_values[k3+1] + vertex_values[k3+2]); 543 edge_values[k3+1] = 0.5*(vertex_values[k3+2] + vertex_values[k3+0]); 544 edge_values[k3+2] = 0.5*(vertex_values[k3+0] + vertex_values[k3+1]); 456 545 457 546 } … … 460 549 } 461 550 462 551 int _bound_vertices_below_by_quantity(int N, 552 double* bound_vertex_values, 553 double* centroid_values, 554 double* vertex_values, 555 double* edge_values, 556 double* x_gradient, 557 double* y_gradient) { 558 559 int i, k, k2, k3, k6; 560 double qmin, qc; 561 double dq, dqa[3], phi, r; 562 563 for (k=0; k<N; k++){ 564 k6 = 6*k; 565 k3 = 3*k; 566 k2 = 2*k; 567 568 qc = centroid_values[k]; 569 570 phi = 1.0; 571 for (i=0; i<3; i++) { 572 r = 1.0; 573 574 dq = vertex_values[k3+i] - qc; //Delta between vertex and centroid values 575 dqa[i] = dq; //Save dq for use in updating vertex values 576 577 qmin = bound_vertex_values[k3+i]; 578 if (dq < 0.0) r = (qmin - qc)/dq; 579 580 581 phi = min( min(r, 1.0), phi); 582 } 583 584 585 //Update gradient, vertex and edge values using phi limiter 586 x_gradient[k] = x_gradient[k]*phi; 587 y_gradient[k] = y_gradient[k]*phi; 588 589 vertex_values[k3+0] = qc + phi*dqa[0]; 590 vertex_values[k3+1] = qc + phi*dqa[1]; 591 vertex_values[k3+2] = qc + phi*dqa[2]; 592 593 edge_values[k3+0] = 0.5*(vertex_values[k3+1] + vertex_values[k3+2]); 594 edge_values[k3+1] = 0.5*(vertex_values[k3+2] + vertex_values[k3+0]); 595 edge_values[k3+2] = 0.5*(vertex_values[k3+0] + vertex_values[k3+1]); 596 597 } 598 599 return 0; 600 } 463 601 464 602 int _interpolate_from_vertices_to_edges(int N, … … 906 1044 907 1045 908 /* PyObject *compute_gradients(PyObject *self, PyObject *args) { */909 /* //"""Compute gradients of triangle surfaces defined by centroids of */910 /* //neighbouring volumes. */911 /* //If one edge is on the boundary, use own centroid as neighbour centroid. */912 /* //If two or more are on the boundary, fall back to first order scheme. */913 /* //""" */914 915 916 /* PyObject *quantity, *domain, *R; */917 /* PyArrayObject */918 /* *centroids, //Coordinates at centroids */919 /* *centroid_values, //Values at centroids */920 /* *number_of_boundaries, //Number of boundaries for each triangle */921 /* *surrogate_neighbours, //True neighbours or - if one missing - self */922 /* *a, *b; //Return values */923 924 /* int dimensions[1], N, err; */925 926 /* // Convert Python arguments to C */927 /* if (!PyArg_ParseTuple(args, "O", &quantity)) { */928 /* PyErr_SetString(PyExc_RuntimeError, */929 /* "quantity_ext.c: compute_gradients could not parse input"); */930 /* return NULL; */931 /* } */932 933 /* domain = PyObject_GetAttrString(quantity, "domain"); */934 /* if (!domain) { */935 /* PyErr_SetString(PyExc_RuntimeError, */936 /* "compute_gradients could not obtain domain object from quantity"); */937 /* return NULL; */938 /* } */939 940 /* // Get pertinent variables */941 942 /* centroids = get_consecutive_array(domain, "centroid_coordinates"); */943 /* centroid_values = get_consecutive_array(quantity, "centroid_values"); */944 /* surrogate_neighbours = get_consecutive_array(domain, "surrogate_neighbours"); */945 /* number_of_boundaries = get_consecutive_array(domain, "number_of_boundaries"); */946 947 /* N = centroid_values -> dimensions[0]; */948 949 /* // Release */950 /* Py_DECREF(domain); */951 952 /* // Allocate space for return vectors a and b (don't DECREF) */953 /* dimensions[0] = N; */954 /* a = (PyArrayObject *) PyArray_FromDims(1, dimensions, PyArray_DOUBLE); */955 /* b = (PyArrayObject *) PyArray_FromDims(1, dimensions, PyArray_DOUBLE); */956 957 958 959 /* err = _compute_gradients(N, */960 /* (double*) centroids -> data, */961 /* (double*) centroid_values -> data, */962 /* (long*) number_of_boundaries -> data, */963 /* (long*) surrogate_neighbours -> data, */964 /* (double*) a -> data, */965 /* (double*) b -> data); */966 967 /* if (err != 0) { */968 /* PyErr_SetString(PyExc_RuntimeError, "Gradient could not be computed"); */969 /* return NULL; */970 /* } */971 972 /* // Release */973 /* Py_DECREF(centroids); */974 /* Py_DECREF(centroid_values); */975 /* Py_DECREF(number_of_boundaries); */976 /* Py_DECREF(surrogate_neighbours); */977 978 /* // Build result, release and return */979 /* R = Py_BuildValue("OO", PyArray_Return(a), PyArray_Return(b)); */980 /* Py_DECREF(a); */981 /* Py_DECREF(b); */982 /* return R; */983 /* } */984 985 986 987 1046 PyObject *extrapolate_from_gradient(PyObject *self, PyObject *args) { 988 1047 … … 1087 1146 *quantity_vertex_values, //Values at vertices 1088 1147 *quantity_edge_values, //Values at edges 1148 *quantity_phi, //limiter phi values 1089 1149 *quantity_x_gradient, //x gradient 1090 1150 *quantity_y_gradient; //y gradient … … 1097 1157 1098 1158 // Convert Python arguments to C 1099 if (!PyArg_ParseTuple(args, "OOd", 1100 &domain, 1101 &quantity, 1102 &beta)) { 1159 if (!PyArg_ParseTuple(args, "O",&quantity)) { 1103 1160 PyErr_SetString(PyExc_RuntimeError, 1104 1161 "quantity_ext.c: extrapolate_second_order_and_limit could not parse input"); 1162 return NULL; 1163 } 1164 1165 domain = PyObject_GetAttrString(quantity, "domain"); 1166 if (!domain) { 1167 PyErr_SetString(PyExc_RuntimeError, 1168 "quantity_ext.c: extrapolate_second_order_and_limit could not obtain domain object from quantity"); 1105 1169 return NULL; 1106 1170 } … … 1117 1181 quantity_vertex_values = get_consecutive_array(quantity, "vertex_values"); 1118 1182 quantity_edge_values = get_consecutive_array(quantity, "edge_values"); 1183 quantity_phi = get_consecutive_array(quantity, "phi"); 1119 1184 quantity_x_gradient = get_consecutive_array(quantity, "x_gradient"); 1120 1185 quantity_y_gradient = get_consecutive_array(quantity, "y_gradient"); 1121 1186 1187 beta = get_python_double(quantity,"beta"); 1188 1122 1189 ntri = quantity_centroid_values -> dimensions[0]; 1123 1124 1125 1190 1126 1191 err = _compute_gradients(ntri, … … 1139 1204 1140 1205 1141 err = _extrapolate_and_limit_from_gradient(ntri, beta, 1142 (double*) domain_centroids -> data, 1143 (long*) domain_neighbours -> data, 1144 (double*) quantity_centroid_values -> data, 1145 (double*) domain_vertex_coordinates -> data, 1146 (double*) quantity_vertex_values -> data, 1147 (double*) quantity_edge_values -> data, 1148 (double*) quantity_x_gradient -> data, 1149 (double*) quantity_y_gradient -> data); 1206 err = _extrapolate_from_gradient(ntri, 1207 (double*) domain_centroids -> data, 1208 (double*) quantity_centroid_values -> data, 1209 (double*) domain_vertex_coordinates -> data, 1210 (double*) quantity_vertex_values -> data, 1211 (double*) quantity_edge_values -> data, 1212 (double*) quantity_x_gradient -> data, 1213 (double*) quantity_y_gradient -> data); 1150 1214 1151 1215 if (err != 0) { 1152 1216 PyErr_SetString(PyExc_RuntimeError, 1153 "quantity_ext.c: Internal function _extrapolate_and_limit_from_gradient failed"); 1217 "quantity_ext.c: Internal function _extrapolate_from_gradient failed"); 1218 return NULL; 1219 } 1220 1221 1222 err = _limit_edges_by_all_neighbours(ntri, beta, 1223 (double*) quantity_centroid_values -> data, 1224 (double*) quantity_vertex_values -> data, 1225 (double*) quantity_edge_values -> data, 1226 (long*) domain_neighbours -> data, 1227 (double*) quantity_x_gradient -> data, 1228 (double*) quantity_y_gradient -> data); 1229 1230 if (err != 0) { 1231 PyErr_SetString(PyExc_RuntimeError, 1232 "quantity_ext.c: Internal function _limit_edges_by_all_neighbours failed"); 1154 1233 return NULL; 1155 1234 } … … 1165 1244 Py_DECREF(quantity_vertex_values); 1166 1245 Py_DECREF(quantity_edge_values); 1246 Py_DECREF(quantity_phi); 1167 1247 Py_DECREF(quantity_x_gradient); 1168 1248 Py_DECREF(quantity_y_gradient); … … 1445 1525 // 1446 1526 1447 PyObject *quantity, *domain , *Tmp;1527 PyObject *quantity, *domain; 1448 1528 PyArrayObject 1449 1529 *vertex_values, //Conserved quantities at vertices 1450 1530 *centroid_values, //Conserved quantities at centroids 1451 1531 *edge_values, //Conserved quantities at edges 1532 *x_gradient, 1533 *y_gradient, 1452 1534 *neighbours; 1453 1535 … … 1463 1545 } 1464 1546 1465 domain = PyObject_GetAttrString(quantity, "domain"); 1466 if (!domain) { 1467 PyErr_SetString(PyExc_RuntimeError, 1468 "quantity_ext.c: limit_edges_by_all_neighbours could not obtain domain object from quantity"); 1469 1470 return NULL; 1471 } 1472 1473 // Get safety factor beta_w 1474 Tmp = PyObject_GetAttrString(domain, "beta_w"); 1475 if (!Tmp) { 1476 PyErr_SetString(PyExc_RuntimeError, 1477 "quantity_ext.c: limit_edges_by_all_neighbours could not obtain beta_w object from domain"); 1478 1479 return NULL; 1480 } 1547 domain = get_python_object(quantity, "domain"); 1481 1548 1482 1549 … … 1486 1553 vertex_values = get_consecutive_array(quantity, "vertex_values"); 1487 1554 edge_values = get_consecutive_array(quantity, "edge_values"); 1488 beta_w = PyFloat_AsDouble(Tmp); 1489 1555 x_gradient = get_consecutive_array(quantity, "x_gradient"); 1556 y_gradient = get_consecutive_array(quantity, "y_gradient"); 1557 beta_w = get_python_double(domain,"beta_w"); 1558 1559 Py_DECREF(domain); 1490 1560 1491 1561 N = centroid_values -> dimensions[0]; … … 1495 1565 (double*) vertex_values -> data, 1496 1566 (double*) edge_values -> data, 1497 (long*) neighbours -> data); 1567 (long*) neighbours -> data, 1568 (double*) x_gradient -> data, 1569 (double*) y_gradient -> data); 1498 1570 1499 1571 if (err != 0) { 1500 1572 PyErr_SetString(PyExc_RuntimeError, 1501 " Internal function _limit_by_vertexfailed");1573 "quantity_ect.c: limit_edges_by_all_neighbours internal function _limit_edges_by_all_neighbours failed"); 1502 1574 return NULL; 1503 1575 } … … 1509 1581 Py_DECREF(vertex_values); 1510 1582 Py_DECREF(edge_values); 1511 Py_DECREF(Tmp); 1583 1584 1585 1586 return Py_BuildValue(""); 1587 } 1588 1589 PyObject *bound_vertices_below_by_constant(PyObject *self, PyObject *args) { 1590 //Bound a quantity below by a contant (useful for ensuring positivity 1591 //precondition: 1592 // vertex values are already calulated, gradient consistent 1593 //postcondition: 1594 // gradient, vertex and edge values are updated 1595 // 1596 1597 PyObject *quantity, *domain; 1598 PyArrayObject 1599 *vertex_values, //Conserved quantities at vertices 1600 *centroid_values, //Conserved quantities at centroids 1601 *edge_values, //Conserved quantities at edges 1602 *x_gradient, 1603 *y_gradient; 1604 1605 double bound; //Safety factor 1606 int N, err; 1607 1608 1609 // Convert Python arguments to C 1610 if (!PyArg_ParseTuple(args, "Od", &quantity, &bound)) { 1611 PyErr_SetString(PyExc_RuntimeError, 1612 "quantity_ext.c: bound_vertices_below_by_constant could not parse input"); 1613 return NULL; 1614 } 1615 1616 domain = get_python_object(quantity, "domain"); 1617 1618 // Get pertinent variables 1619 centroid_values = get_consecutive_array(quantity, "centroid_values"); 1620 vertex_values = get_consecutive_array(quantity, "vertex_values"); 1621 edge_values = get_consecutive_array(quantity, "edge_values"); 1622 x_gradient = get_consecutive_array(quantity, "x_gradient"); 1623 y_gradient = get_consecutive_array(quantity, "y_gradient"); 1624 1625 1626 1627 Py_DECREF(domain); 1628 1629 N = centroid_values -> dimensions[0]; 1630 1631 err = _bound_vertices_below_by_constant(N, bound, 1632 (double*) centroid_values -> data, 1633 (double*) vertex_values -> data, 1634 (double*) edge_values -> data, 1635 (double*) x_gradient -> data, 1636 (double*) y_gradient -> data); 1637 1638 if (err != 0) { 1639 PyErr_SetString(PyExc_RuntimeError, 1640 "quantity_ect.c: bound_vertices_below_by_constant internal function _bound_vertices_below_by_constant failed"); 1641 return NULL; 1642 } 1643 1644 1645 // Release 1646 Py_DECREF(centroid_values); 1647 Py_DECREF(vertex_values); 1648 Py_DECREF(edge_values); 1649 Py_DECREF(x_gradient); 1650 Py_DECREF(y_gradient); 1651 1652 1653 1654 return Py_BuildValue(""); 1655 } 1656 1657 1658 PyObject *bound_vertices_below_by_quantity(PyObject *self, PyObject *args) { 1659 //Bound a quantity below by a contant (useful for ensuring positivity 1660 //precondition: 1661 // vertex values are already calulated, gradient consistent 1662 //postcondition: 1663 // gradient, vertex and edge values are updated 1664 // 1665 1666 PyObject *quantity, *bounding_quantity, *domain; 1667 PyArrayObject 1668 *vertex_values, //Conserved quantities at vertices 1669 *centroid_values, //Conserved quantities at centroids 1670 *edge_values, //Conserved quantities at edges 1671 *x_gradient, 1672 *y_gradient, 1673 *bound_vertex_values; 1674 1675 int N, err; 1676 1677 1678 // Convert Python arguments to C 1679 if (!PyArg_ParseTuple(args, "OO", &quantity, &bounding_quantity)) { 1680 PyErr_SetString(PyExc_RuntimeError, 1681 "quantity_ext.c: bound_vertices_below_by_quantity could not parse input"); 1682 return NULL; 1683 } 1684 1685 domain = get_python_object(quantity, "domain"); 1686 1687 // Get pertinent variables 1688 centroid_values = get_consecutive_array(quantity, "centroid_values"); 1689 vertex_values = get_consecutive_array(quantity, "vertex_values"); 1690 edge_values = get_consecutive_array(quantity, "edge_values"); 1691 x_gradient = get_consecutive_array(quantity, "x_gradient"); 1692 y_gradient = get_consecutive_array(quantity, "y_gradient"); 1693 bound_vertex_values = get_consecutive_array(bounding_quantity, "vertex_values"); 1694 1695 1696 1697 Py_DECREF(domain); 1698 1699 N = centroid_values -> dimensions[0]; 1700 1701 err = _bound_vertices_below_by_quantity(N, 1702 (double*) bound_vertex_values -> data, 1703 (double*) centroid_values -> data, 1704 (double*) vertex_values -> data, 1705 (double*) edge_values -> data, 1706 (double*) x_gradient -> data, 1707 (double*) y_gradient -> data); 1708 1709 if (err != 0) { 1710 PyErr_SetString(PyExc_RuntimeError, 1711 "quantity_ect.c: bound_vertices_below_by_quantity internal function _bound_vertices_below_by_quantity failed"); 1712 return NULL; 1713 } 1714 1715 1716 // Release 1717 Py_DECREF(centroid_values); 1718 Py_DECREF(vertex_values); 1719 Py_DECREF(edge_values); 1720 Py_DECREF(x_gradient); 1721 Py_DECREF(y_gradient); 1722 Py_DECREF(bound_vertex_values); 1723 1512 1724 1513 1725 … … 1589 1801 1590 1802 // Release 1803 Py_DECREF(domain); 1591 1804 Py_DECREF(neighbours); 1592 1805 Py_DECREF(centroid_values); … … 1700 1913 {"limit_edges_by_neighbour", limit_edges_by_neighbour, METH_VARARGS, "Print out"}, 1701 1914 {"limit_gradient_by_neighbour", limit_gradient_by_neighbour, METH_VARARGS, "Print out"}, 1915 {"bound_vertices_below_by_constant", bound_vertices_below_by_constant, METH_VARARGS, "Print out"}, 1916 {"bound_vertices_below_by_quantity", bound_vertices_below_by_quantity, METH_VARARGS, "Print out"}, 1702 1917 {"update", update, METH_VARARGS, "Print out"}, 1703 1918 {"backup_centroid_values", backup_centroid_values, METH_VARARGS, "Print out"}, -
anuga_core/source/anuga/advection/advection_ext.c
r4978 r5162 2 2 // 3 3 // To compile (Python2.X): 4 // use python ../utilities/compile.py 5 // 6 // See the module advection.py 4 // use python ../utilities/compile.py to 5 // compile all C files within a directory 7 6 // 8 7 // … … 19 18 20 19 20 //------------------------------------------- 21 // Low level routines (called from wrappers) 22 //------------------------------------------ 21 23 22 24 double _compute_fluxes( … … 38 40 39 41 40 //Lo op42 //Local Variables 41 43 42 44 double qr,ql; … … 51 53 int k3; 52 54 55 //Loop through triangles 56 53 57 timestep = max_timestep; 54 58 … … 59 63 for (i=0; i<3; i++){ 60 64 k_i = k3+i; 61 //Quantities inside volume facing neighbour i65 //Quantities inside triangle facing neighbour i 62 66 ql = quantity_edge[k_i]; 63 67 … … 144 148 145 149 PyObject *domain, *quantity; 150 146 151 PyArrayObject 147 152 * quantity_update, -
anuga_core/source/anuga/config.py
r4837 r5162 100 100 #timestepping_method = 'rk2' # 2nd Order TVD scheme 101 101 102 # rk2 is a little more stable than euler, so rk2 timestepping 103 # can deal with a larger beta when slope limiting the reconstructed 104 # solution. The large beta is needed if solving problems sensitive 105 # to numerical diffusion, like a small forced wave in an ocean 106 beta_euler = 1.0 107 beta_rk2 = 1.6 108 109 110 102 111 # Option to search for signatures where isolated triangles are 103 112 # responsible for a small global timestep. -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r5089 r5162 103 103 from anuga.config import alpha_balance 104 104 from anuga.config import optimise_dry_cells 105 from anuga.config import optimised_gradient_limiter 105 106 106 107 #--------------------- … … 176 177 self.minimum_storable_height = minimum_storable_height 177 178 self.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] 178 179 180 # Limiters 181 self.use_old_limiter = True 182 183 self.optimised_gradient_limiter = optimised_gradient_limiter 179 184 180 185 … … 187 192 self.beta_w = beta 188 193 self.beta_w_dry = beta 194 self.quantities['stage'].beta = beta 195 189 196 self.beta_uh = beta 190 197 self.beta_uh_dry = beta 198 self.quantities['xmomentum'].beta = beta 199 191 200 self.beta_vh = beta 192 201 self.beta_vh_dry = beta 202 self.quantities['ymomentum'].beta = beta 203 193 204 self.beta_h = beta 194 205 … … 384 395 # Call correct module function 385 396 # (either from this module or C-extension) 386 distribute_to_vertices_and_edges(self) 397 if self.use_old_limiter: 398 distribute_to_vertices_and_edges(self) 399 else: 400 for name in self.conserved_quantities: 401 Q = self.quantities[name] 402 if self._order_ == 1: 403 Q.extrapolate_first_order() 404 elif self._order_ == 2: 405 Q.extrapolate_second_order_and_limit() 406 if name == 'stage': 407 Q.bound_vertices_below_by_quantity(self.quantities['elevation']) 408 else: 409 raise 'Unknown order' 410 387 411 388 412 … … 399 423 # self.check_integrity() 400 424 401 msg = 'Parameter beta_h must be in the interval [0, 1['402 assert 0 <= self.beta_h <= 1.0, msg403 msg = 'Parameter beta_w must be in the interval [0, 1['404 assert 0 <= self.beta_w <= 1.0, msg425 msg = 'Parameter beta_h must be in the interval [0, 2[' 426 assert 0 <= self.beta_h <= 2.0, msg 427 msg = 'Parameter beta_w must be in the interval [0, 2[' 428 assert 0 <= self.beta_w <= 2.0, msg 405 429 406 430 … … 737 761 """ 738 762 739 from anuga.config import optimised_gradient_limiter763 740 764 741 765 # Remove very thin layers of water … … 743 767 744 768 # Extrapolate all conserved quantities 745 if optimised_gradient_limiter:769 if domain.optimised_gradient_limiter: 746 770 # MH090605 if second order, 747 771 # perform the extrapolation and limiting on … … 764 788 Q.extrapolate_first_order() 765 789 elif domain._order_ == 2: 766 767 # Experiment768 #if name == 'stage':769 # #print name, 'second'770 # Q.extrapolate_second_order()771 # Q.limit()772 #else:773 # #print name, 'first'774 # Q.extrapolate_first_order()775 # #Q.extrapolate_second_order()776 # #Q.limit()777 778 790 Q.extrapolate_second_order() 779 791 Q.limit() -
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r4978 r5162 1088 1088 double dx1,dx2,dy1,dy2,dxv0,dxv1,dxv2,dyv0,dyv1,dyv2,dq0,dq1,dq2,area2; 1089 1089 double dqv[3], qmin, qmax, hmin, hmax; 1090 double hc, h0, h1, h2, beta_tmp ;1090 double hc, h0, h1, h2, beta_tmp, hfactor; 1091 1091 1092 1092 … … 1185 1185 h1 = stage_centroid_values[k1] - elevation_centroid_values[k1]; 1186 1186 h2 = stage_centroid_values[k2] - elevation_centroid_values[k2]; 1187 hmin = min(h0,min(h1,h2)); 1188 1187 hmin = min(min(h0,min(h1,h2)),hc); 1188 //hfactor = hc/(hc + 1.0); 1189 1190 hfactor = 0.0; 1191 if (hmin > 0.1 ) { 1192 hfactor = (hmin-0.1)/(hmin+0.4); 1193 } 1189 1194 1190 1195 if (optimise_dry_cells) { … … 1230 1235 1231 1236 // Playing with dry wet interface 1232 hmin = qmin;1233 beta_tmp = beta_w;1234 if (hmin<minimum_allowed_height)1235 beta_tmp = beta_w_dry;1237 //hmin = qmin; 1238 //beta_tmp = beta_w_dry; 1239 //if (hmin>minimum_allowed_height) 1240 beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor; 1236 1241 1242 //printf("min_alled_height = %f\n",minimum_allowed_height); 1243 //printf("hmin = %f\n",hmin); 1244 //printf("beta_w = %f\n",beta_w); 1245 //printf("beta_tmp = %f\n",beta_tmp); 1237 1246 // Limit the gradient 1238 1247 limit_gradient(dqv,qmin,qmax,beta_tmp); … … 1271 1280 // from the centroid to the min and max 1272 1281 find_qmin_and_qmax(dq0,dq1,dq2,&qmin,&qmax); 1273 beta_tmp = beta_uh; 1274 if (hmin<minimum_allowed_height) 1275 beta_tmp = beta_uh_dry; 1276 1282 //beta_tmp = beta_uh; 1283 //if (hmin<minimum_allowed_height) 1284 //beta_tmp = beta_uh_dry; 1285 beta_tmp = beta_uh_dry + (beta_uh - beta_uh_dry) * hfactor; 1286 1277 1287 // Limit the gradient 1278 1288 limit_gradient(dqv,qmin,qmax,beta_tmp); … … 1311 1321 // from the centroid to the min and max 1312 1322 find_qmin_and_qmax(dq0,dq1,dq2,&qmin,&qmax); 1313 beta_tmp = beta_vh; 1314 1315 if (hmin<minimum_allowed_height) 1316 beta_tmp = beta_vh_dry; 1317 1323 1324 //beta_tmp = beta_vh; 1325 // 1326 //if (hmin<minimum_allowed_height) 1327 //beta_tmp = beta_vh_dry; 1328 beta_tmp = beta_vh_dry + (beta_vh - beta_vh_dry) * hfactor; 1329 1318 1330 // Limit the gradient 1319 1331 limit_gradient(dqv,qmin,qmax,beta_tmp); … … 1563 1575 1564 1576 1565 beta_w = get_double(domain,"beta_w");1566 beta_w_dry = get_double(domain,"beta_w_dry");1567 beta_uh = get_double(domain,"beta_uh");1568 beta_uh_dry = get_double(domain,"beta_uh_dry");1569 beta_vh = get_double(domain,"beta_vh");1570 beta_vh_dry = get_double(domain,"beta_vh_dry");1571 1572 minimum_allowed_height = get_ double(domain,"minimum_allowed_height");1573 epsilon = get_double(domain,"epsilon");1577 beta_w = get_python_double(domain,"beta_w"); 1578 beta_w_dry = get_python_double(domain,"beta_w_dry"); 1579 beta_uh = get_python_double(domain,"beta_uh"); 1580 beta_uh_dry = get_python_double(domain,"beta_uh_dry"); 1581 beta_vh = get_python_double(domain,"beta_vh"); 1582 beta_vh_dry = get_python_double(domain,"beta_vh_dry"); 1583 1584 minimum_allowed_height = get_python_double(domain,"minimum_allowed_height"); 1585 epsilon = get_python_double(domain,"epsilon"); 1574 1586 1575 1587 number_of_elements = stage_centroid_values -> dimensions[0]; -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4924 r5162 248 248 249 249 range = fid.variables['xmomentum_range'][:] 250 assert allclose(range,[0,0.4695096]) or\ 251 allclose(range,[0,0.47790655]) # Old slope limiters 250 251 252 253 assert allclose(range,[0,0.4695096]) or \ 254 allclose(range,[0,0.47790655]) or\ 255 allclose(range,[0,0.46941957]) 252 256 253 257 range = fid.variables['ymomentum_range'][:] 254 258 #assert allclose(range,[0,0.02174380]) 259 255 260 assert allclose(range,[0,0.02174439]) or\ 256 allclose(range,[0,0.02283983]) # Old slope limiters 261 allclose(range,[0,0.02283983]) or\ 262 allclose(range,[0,0.0217342]) # Old slope limiters 257 263 258 264 fid.close() … … 324 330 325 331 extrema = fid.variables['xmomentum.extrema'][:] 326 assert allclose(extrema,[-0.06062178, 0.478 86313])332 assert allclose(extrema,[-0.06062178, 0.47873023]) 327 333 328 334 extrema = fid.variables['ymomentum.extrema'][:] 329 assert allclose(extrema,[0.00, 0.062 41221])335 assert allclose(extrema,[0.00, 0.0625786]) 330 336 331 337 time_interval = fid.variables['extrema.time_interval'][:] -
anuga_core/source/anuga/utilities/util_ext.h
r4978 r5162 261 261 262 262 B = (PyArrayObject*) PyObject_GetAttrString(O, name); 263 if (!B) return NULL; 263 if (!B) { 264 PyErr_SetString(PyExc_RuntimeError, "util_ext.h: get_consecutive_array could not obtain array"); 265 return NULL; 266 } 264 267 265 268 //Convert to consecutive array … … 269 272 Py_DECREF(B); //FIXME: Is this really needed?? 270 273 271 if (!A) return NULL; 274 if (!A) { 275 PyErr_SetString(PyExc_RuntimeError, "util_ext.h: get_consecutive_array could not obtain array"); 276 return NULL; 277 } 272 278 return A; 273 279 } 274 280 275 double get_ double(PyObject *O, char *name) {281 double get_python_double(PyObject *O, char *name) { 276 282 PyObject *TObject; 277 283 double tmp; … … 281 287 TObject = PyObject_GetAttrString(O, name); 282 288 if (!TObject) { 283 PyErr_SetString(PyExc_RuntimeError, "util_ext.h: get_ double could not obtain double from object");289 PyErr_SetString(PyExc_RuntimeError, "util_ext.h: get_python_double could not obtain double from object"); 284 290 return 0.0; 285 291 } … … 293 299 294 300 295 301 PyObject *get_python_object(PyObject *O, char *name) { 302 PyObject *Oout; 303 304 Oout = PyObject_GetAttrString(O, name); 305 if (!Oout) { 306 PyErr_SetString(PyExc_RuntimeError, "util_ext.h: get_python_object could not obtain object"); 307 return NULL; 308 } 309 310 return Oout; 311 312 } 313 314 315 -
anuga_core/source/anuga/utilities/xml_tools.py
r5022 r5162 239 239 fid = xml 240 240 241 try: 242 dom = parse(fid) 243 except Exception, e: 244 # Throw filename into dom exception 245 msg = 'XML file "%s" could not be parsed: ' %fid.name 246 msg += str(e) 247 raise Exception, msg 241 dom = parse(fid) 242 243 ## try: 244 ## dom = parse(fid) 245 ## except Exception, e: 246 ## # Throw filename into dom exception 247 ## msg = 'XML file "%s" could not be parsed: ' %fid.name 248 ## msg += str(e) 249 ## raise Exception, msg 248 250 249 251 return dom2object(dom) -
anuga_validation/convergence_study/animatesww2d_alt.py
r4838 r5162 1 def animatesww2d_alt(sww_filename, movie_filename, range):2 """Plot cross section of model output3 """1 ## def animatesww2d_alt(sww_filename, movie_filename, range): 2 ## """Plot cross section of model output 3 ## """ 4 4 5 # Read SWW file6 from Scientific.IO.NetCDF import NetCDFFile7 fid = NetCDFFile(sww_filename, 'r')5 ## # Read SWW file 6 ## from Scientific.IO.NetCDF import NetCDFFile 7 ## fid = NetCDFFile(sww_filename, 'r') 8 8 9 x = fid.variables['x']10 y = fid.variables['y']11 volumes = fid.variables['volumes']9 ## x = fid.variables['x'] 10 ## y = fid.variables['y'] 11 ## volumes = fid.variables['volumes'] 12 12 13 elevation = fid.variables['elevation']14 time = fid.variables['time']15 stage = fid.variables['stage']16 xmomentum = fid.variables['xmomentum']17 ymomentum = fid.variables['ymomentum']13 ## elevation = fid.variables['elevation'] 14 ## time = fid.variables['time'] 15 ## stage = fid.variables['stage'] 16 ## xmomentum = fid.variables['xmomentum'] 17 ## ymomentum = fid.variables['ymomentum'] 18 18 19 19 def animatesww2d(swwfile): … … 34 34 # interpolation points are for y = 0 35 35 # number of increments in x 36 m = 100 36 m = 1000 37 37 max_x = 100000. 38 38 x = 0 -
anuga_validation/convergence_study/convergence_structured.py
r4992 r5162 17 17 from anuga.shallow_water import Transmissive_boundary 18 18 from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary 19 from anuga.geospatial_data.geospatial_data import *19 #from anuga.geospatial_data.geospatial_data import * 20 20 from math import cos 21 from Numeric import zeros, Float 21 22 22 23 #------------------------------------------------------------------------------ 23 24 # Setup computational domain 24 25 #------------------------------------------------------------------------------ 25 dx = 1000.26 dx = 200. 26 27 dy = dx 27 28 L = 100000. … … 33 34 domain = Domain(points, vertices, boundary) 34 35 35 domain.set_timestepping_method(' euler')36 domain.set_timestepping_method('rk2') 36 37 domain.set_default_order(2) 37 38 domain.set_name('myexample9') 38 39 domain.set_datadir('.') # Use current directory for output 39 40 40 domain.beta_w = 1.0 41 domain.beta_w_dry = 0.2 42 domain.beta_uh = 1.0 43 domain.beta_uh_dry = 0.2 44 domain.beta_vh = 1.0 45 domain.beta_vh_dry = 0.2 46 domain.beta_h = 1.0 41 domain.set_all_limiters(0.9) 42 43 print domain.beta_w 44 domain.use_old_limiter = False 45 domain.CFL = 1.0 47 46 48 47 #------------------------------------------------------------------------------ … … 50 49 #------------------------------------------------------------------------------ 51 50 #domain.set_quantity('elevation', topography) # Use function for elevation 52 domain.set_quantity('elevation', -100)51 domain.set_quantity('elevation',0.0) 53 52 domain.set_quantity('friction', 0.00) 54 domain.set_quantity('stage', 0.0) 53 54 h0 = 10.0 55 h1 = 1.0 56 57 def height(x,y): 58 z = zeros(len(x),Float) 59 for i in range(len(x)): 60 if x[i]<=50000.0: 61 z[i] = h0 62 else: 63 z[i] = h1 64 return z 65 66 67 domain.set_quantity('stage', height) 68 #domain.set_quantity('stage', 0.0) 55 69 56 70 #----------------------------------------------------------------------------- … … 65 79 Bw = Time_boundary(domain=domain, # Time dependent boundary 66 80 ## Sine wave 67 f=lambda t: [(-amplitude*sin((1./300.)*t*2*pi)), 0.0, 0.0]) 81 # f=lambda t: [(-amplitude*sin((1./300.)*t*2*pi)), 0.0, 0.0]) 82 ## Single wave 83 f=lambda t: [h0, 0.0, 0.0]) 68 84 ## Sawtooth? 69 85 # f=lambda t: [(-8.0*(sin((1./180.)*t*2*pi))+(1./2.)*sin((2./180.)*t*2*pi)+(1./3.)*sin((3./180.)*t*2*pi)), 0.0, 0.0]) … … 92 108 #------------------------------------------------------------------------------ 93 109 94 for t in domain.evolve(yieldstep = 20.0, finaltime = 10*40*60.):110 for t in domain.evolve(yieldstep = 50.0, finaltime = 10*40*60.): 95 111 domain.write_time() 96 112 vis.update() -
anuga_work/development/analytical_solutions/oblique_shock.py
r5030 r5162 29 29 30 30 31 from shallow_water import Domain, Constant_height32 from shallow_water import Transmissive_boundary, Reflective_boundary,\31 from anuga.shallow_water import Domain 32 from anuga.shallow_water import Transmissive_boundary, Reflective_boundary,\ 33 33 Dirichlet_boundary 34 34 from anuga.visualiser import RealtimeVisualiser 35 35 from math import sqrt, cos, sin, pi 36 from mesh_factory import oblique 36 from mesh_factory import oblique_cross 37 37 38 38 … … 44 44 leny = 30. 45 45 lenx = 40. 46 n = 5047 m = 6046 n = 100 47 m = 120 48 48 49 points, elements, boundary = oblique (m, n, lenx, leny)49 points, elements, boundary = oblique_cross(m, n, lenx, leny) 50 50 domain = Domain(points, elements, boundary) 51 51 … … 54 54 55 55 # Store output 56 domain.store=True56 #domain.store=True 57 57 58 58 # Output format 59 domain.format="sww" #NET.CDF binary format59 #domain.format="sww" #NET.CDF binary format 60 60 # "dat" for ASCII 61 61 … … 87 87 #Initial condition 88 88 h = 0.5 89 domain.set_quantity('stage', Constant_height(x_slope, h))89 domain.set_quantity('stage', expression = 'elevation + %d'%h ) 90 90 91 #--------------------------------- 92 # Setup visualization 93 #--------------------------------- 94 vis = RealtimeVisualiser(domain) 95 vis.render_quantity_height("elevation", dynamic=False) 96 vis.render_quantity_height("stage", zScale=10, dynamic=True) 97 vis.colour_height_quantity('stage', (0.75, 0.5, 0.5)) 98 vis.start() 91 99 92 100 ###################### … … 96 104 for t in domain.evolve(yieldstep = 0.5, finaltime = 50): 97 105 domain.write_time() 106 vis.update() 98 107 99 108 print 'That took %.2f seconds' %(time.time()-t0) 109 110 111 vis.evolveFinished() 112 vis.join() 100 113 101 114 #FIXME: Compute average water depth on either side of shock and compare -
anuga_work/development/near_shore_PMD/run_beach.py
r5154 r5162 167 167 domain.set_boundary( {'wall': Br, 'wave': Bwp_velocity} ) 168 168 169 169 170 #------------------------------------------------------------------------- 170 171 # Evolve system through time … … 174 175 for t in domain.evolve(yieldstep, finaltime): 175 176 domain.write_time() 177 176 178 print 'That took %.2f seconds' %(time.time()-t0) 177 179 print 'finished'
Note: See TracChangeset
for help on using the changeset viewer.