Changeset 9105
- Timestamp:
- May 5, 2014, 5:21:42 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/pmesh/mesh_interface.py
r8699 r9105 33 33 breaklines=None, 34 34 use_cache=False, 35 verbose=True): 35 verbose=True, 36 regionPtArea=None): 36 37 """Create mesh from bounding polygons, and resolutions. 37 38 … … 107 108 'fail_if_polygons_outside': fail_if_polygons_outside, 108 109 'breaklines': breaklines, 109 'verbose': verbose} # FIXME (Ole): Should be bypassed one day. See ticket:14 110 'verbose': verbose, 111 'regionPtArea': regionPtArea} # FIXME (Ole): Should be bypassed one day. See ticket:14 110 112 111 113 # Call underlying engine with or without caching … … 145 147 fail_if_polygons_outside=True, 146 148 breaklines=None, 147 verbose=True): 149 verbose=True, 150 regionPtArea=None): 148 151 """_create_mesh_from_regions - internal function. 149 152 … … 151 154 """ 152 155 153 154 156 # check the segment indexes - throw an error if they are out of bounds 155 157 if boundary_tags is not None: … … 301 303 else: 302 304 bounding_polygon_absolute = bounding_polygon 303 305 304 306 inner_point = point_in_polygon(bounding_polygon_absolute) 305 307 inner = m.add_region(inner_point[0], inner_point[1]) … … 339 341 segment_tags=tags, 340 342 geo_reference=poly_geo_reference) 341 343 344 345 # 22/04/2014 346 # Add user-specified point-based regions with max area 347 if(regionPtArea is not None): 348 for i in range(len(regionPtArea)): 349 inner = m.add_region(regionPtArea[i][0], regionPtArea[i][1]) 350 inner.setMaxArea(regionPtArea[i][2]) 351 352 342 353 343 354 -
trunk/anuga_core/source/anuga/shallow_water/okada_tsunami.py
r8943 r9105 136 136 width = the width of the sub-fault (km) DOWN THE DIP (i.e. width=surface_width/cos(dip)) 137 137 138 dis1, dis2, dis3 are the fault displacement components in the138 dis1, dis2, dis3 are the fault displacement components (m) in the 139 139 directions 'along strike', 'up-dip', and 'perpendicular to the slip plain'. 140 140 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r9104 r9105 225 225 self.quantities['y'].set_values(self.vertex_coordinates[:,1].reshape(n,3)) 226 226 self.quantities['y'].set_boundary_values_from_edges() 227 228 # For riverwalls, we need to know the 'edge_flux_type' for each edge 229 # Edge-flux-type of 0 == Normal edge, with shallow water flux 230 # 1 == riverwall 231 # 2 == ? 232 # etc 233 self.edge_flux_type=num.zeros(len(self.edge_coordinates[:,0])).astype(int) 234 235 # Riverwalls -- initialise with dummy values 236 # Presently only works with DE1, will fail otherwise 237 import anuga.structures.riverwall 238 self.riverwallData=anuga.structures.riverwall.RiverWall(self) 227 239 228 240 … … 445 457 self.edge_coordinates=self.get_edge_midpoint_coordinates() 446 458 447 # Hold elevation of riverwalls along cell edges448 from anuga.config import max_float449 self.riverwall_elevation=self.edge_coordinates[:,0]*0.0 - max_float450 451 459 # By default vertex values are NOT stored uniquely 452 460 # for storage efficiency. We may override this (but not so important since … … 1294 1302 Bed.centroid_values, 1295 1303 height.centroid_values, 1296 Bed.vertex_values, 1297 self.riverwall_elevation) 1304 #Bed.vertex_values, 1305 self.edge_flux_type, 1306 self.riverwallData.riverwall_elevation, 1307 self.riverwallData.hydraulic_properties_rowIndex, 1308 int(self.riverwallData.ncol_hydraulic_properties), 1309 self.riverwallData.hydraulic_properties) 1298 1310 1299 1311 ## FIXME: This won't work in parallel since the timestep has not been updated to include other processors. -
trunk/anuga_core/source/anuga/shallow_water/swDE1_domain_ext.c
r9104 r9105 148 148 149 149 // Compute speeds in x-direction 150 w_left = q_left_rotated[0];150 //w_left = q_left_rotated[0]; 151 151 uh_left=q_left_rotated[1]; 152 152 vh_left=q_left_rotated[2]; … … 164 164 // epsilon, h0, limiting_threshold); 165 165 166 w_right = q_right_rotated[0];166 //w_right = q_right_rotated[0]; 167 167 uh_right = q_right_rotated[1]; 168 168 vh_right = q_right_rotated[2]; … … 257 257 } 258 258 259 double adjust_edgeflux_with_weir(double* edgeflux, 260 double h_left, double h_right, 261 double g, double weir_height, 262 double weirScale, 263 double s1, double s2, 264 double h1, double h2 265 ){ 266 // Adjust the edgeflux to agree with a weir relation [including 267 // subergence], but smoothly vary to shallow water solution when 268 // the flow over the weir is much deeper than the weir, or the 269 // upstream/downstream water elevations are too similar 270 double rw, rw2; // 'Raw' weir fluxes 271 double rwRat, hdRat,hdWrRat, scaleFlux, scaleFluxS, minhd, maxhd; 272 double w1,w2; // Weights for averaging 273 double newFlux; 274 // Following constants control the 'blending' with the shallow water solution 275 // They are now user-defined 276 //double s1=0.9; // At this submergence ratio, begin blending with shallow water solution 277 //double s2=0.95; // At this submergence ratio, completely use shallow water solution 278 //double h1=1.0; // At this (tailwater height above weir) / (weir height) ratio, begin blending with shallow water solution 279 //double h2=1.5; // At this (tailwater height above weir) / (weir height) ratio, completely use the shallow water solution 280 281 minhd=min(h_left, h_right); 282 maxhd=max(h_left,h_right); 283 // 'Raw' weir discharge = weirScale*2/3*H*(2/3*g*H)**0.5 284 rw=weirScale*2./3.*maxhd*sqrt(2./3.*g*maxhd); 285 // Factor for villemonte correction 286 rw2=weirScale*2./3.*minhd*sqrt(2./3.*g*minhd); 287 // Useful ratios 288 rwRat=rw2/max(rw, 1.0e-100); 289 hdRat=minhd/max(maxhd,1.0e-100); 290 // (tailwater height above weir)/weir_height ratio 291 hdWrRat=minhd/max(weir_height,1.0e-100); 292 293 // Villemonte (1947) corrected weir flow with submergence 294 // Q = Q1*(1-Q2/Q1)**0.385 295 rw = rw*pow(1.0-rwRat,0.385); 296 297 if(h_right>h_left){ 298 rw*=-1.0; 299 } 300 301 if( (hdRat<s2) & (hdWrRat< h2) ){ 302 // Rescale the edge fluxes so that the mass flux = desired flux 303 // Linearly shift to shallow water solution between hdRat = s1 and s2 304 // and between hdWrRat = h1 and h2 305 306 // 307 // WEIGHT WITH RAW SHALLOW WATER FLUX BELOW 308 // This ensures that as the weir gets very submerged, the 309 // standard shallow water equations smoothly take over 310 // 311 312 // Weighted average constants to transition to shallow water eqn flow 313 w1=min( max(hdRat-s1,0.)/(s2-s1), 1.0); 314 //w2=1.0-w1; 315 // 316 // Adjust again when the head is too deep relative to the weir height 317 w2=min( max(hdWrRat-h1,0.)/(h2-h1), 1.0); 318 //w2=1.0-w1; 319 320 newFlux=(rw*(1.0-w1)+w1*edgeflux[0])*(1.0-w2) + w2*edgeflux[0]; 321 322 if(fabs(edgeflux[0])>1.0e-100){ 323 scaleFlux=newFlux/edgeflux[0]; 324 325 // FINAL ADJUSTED FLUX 326 edgeflux[0]*=scaleFlux; 327 edgeflux[1]*=scaleFlux; 328 edgeflux[2]*=scaleFlux; 329 }else{ 330 // Can't divide by edgeflux 331 edgeflux[0] = newFlux; 332 edgeflux[1]*=0.; 333 edgeflux[2]*=0.; 334 } 335 } 336 337 //printf("%e, %e, %e, %e , %e, %e \n", weir_height, h_left, h_right, edgeflux[0], w1, w2); 338 339 return 0; 340 } 259 341 260 342 // Computational function for flux computation … … 293 375 double* bed_centroid_values, 294 376 double* height_centroid_values, 295 double* bed_vertex_values, 296 double* riverwall_elevation) { 377 //double* bed_vertex_values, 378 long* edge_flux_type, 379 double* riverwall_elevation, 380 long* riverwall_rowIndex, 381 int ncol_riverwall_hydraulic_properties, 382 double* riverwall_hydraulic_properties) { 297 383 // Local variables 298 384 double max_speed, length, inv_area, zl, zr; 299 385 //double h0 = H0*H0;//H0*H0;//H0*0.1;//H0*H0;//H0*H0; // This ensures a good balance when h approaches H0. 300 386 double h_left, h_right, z_half ; // For andusse scheme 301 387 // FIXME: limiting_threshold is not used for DE1 302 388 double limiting_threshold = 10*H0;//10 * H0 ;//H0; //10 * H0; // Avoid applying limiter below this 303 389 // threshold for performance reasons. … … 305 391 int k, i, m, n,j, ii; 306 392 int ki, nm = 0, ki2,ki3, nm3; // Index shorthands 307 393 //int num_hydraulic_properties=1; // FIXME: Move to function call 308 394 // Workspace (making them static actually made function slightly slower (Ole)) 309 395 double ql[3], qr[3], edgeflux[3]; // Work array for summing up fluxes … … 311 397 double bedslope_work, local_timestep; 312 398 int neighbours_wet[3];//Work array 313 int useint;314 double hle, hre, zc, zc_n ;399 int RiverWall_count; 400 double hle, hre, zc, zc_n, Qfactor, s1, s2, h1, h2; 315 401 double stage_edge_lim, outgoing_mass_edges, bedtop, bedbot, pressure_flux, hc, hc_n, tmp, tmp2; 316 402 static long call = 1; // Static local variable flagging already computed flux 317 double speed_max_last, vol, smooth, local_speed ;403 double speed_max_last, vol, smooth, local_speed, weir_height; 318 404 319 405 double *edgeflux_store, *pressuregrad_store; … … 331 417 332 418 local_timestep=timestep; 419 RiverWall_count=0; 333 420 334 421 … … 390 477 z_half=max(z_half,riverwall_elevation[ki]); 391 478 479 // Account for riverwalls 480 if(edge_flux_type[ki]==1){ 481 // Update counter of riverwall edges == index of 482 // riverwall_elevation + riverwall_rowIndex 483 RiverWall_count+=1; 484 // Set central bed to riverwall elevation 485 z_half=riverwall_elevation[RiverWall_count-1]; 486 // Since there is a wall, use first order extrapolation for this edge 487 // This also makes more sense from the viewpoint of weir relations 488 ql[0]=stage_centroid_values[k]; 489 ql[1]=xmom_centroid_values[k]; 490 ql[2]=ymom_centroid_values[k]; 491 hle=hc; 492 zl=zc; 493 if(n>=0){ 494 qr[0]=stage_centroid_values[n]; 495 qr[1]=xmom_centroid_values[n]; 496 qr[2]=ymom_centroid_values[n]; 497 hre=hc_n; 498 zr = zc_n; 499 } 500 501 } 502 503 // Define h left/right for Audusse flux method 392 504 h_left= max(hle+zl-z_half,0.); 393 505 h_right= max(hre+zr-z_half,0.); … … 402 514 speed_max_last); 403 515 516 // Force weir discharge to match weir theory 517 if(edge_flux_type[ki]==1){ 518 //printf("%e \n", z_half); 519 weir_height=riverwall_elevation[RiverWall_count-1]-min(zl,zr); // Reference weir height 520 521 // Get Qfactor index - multiply the idealised weir discharge by this constant factor 522 ii=riverwall_rowIndex[RiverWall_count-1]*ncol_riverwall_hydraulic_properties; 523 Qfactor=riverwall_hydraulic_properties[ii]; 524 //printf("%e \n", Qfactor); 525 // Get s1, submergence ratio at which we start blending with the shallow water solution 526 ii+=1; 527 s1=riverwall_hydraulic_properties[ii]; 528 // Get s2, submergence ratio at which we entirely use the shallow water solution 529 ii+=1; 530 s2=riverwall_hydraulic_properties[ii]; 531 // Get h1, tailwater head / weir height at which we start blending with the shallow water solution 532 ii+=1; 533 h1=riverwall_hydraulic_properties[ii]; 534 // Get h2, tailwater head / weir height at which we entirely use the shallow water solution 535 ii+=1; 536 h2=riverwall_hydraulic_properties[ii]; 537 538 //printf("%e, %e, %e, %e, %e \n", Qfactor, s1, s2, h1, h2); 539 540 adjust_edgeflux_with_weir(edgeflux, h_left, h_right, g, 541 weir_height, Qfactor, 542 s1, s2, h1, h2); 543 // NOTE: Should perhaps also adjust the wave-speed here?? Small chance of instability?? 544 //printf("%e \n", edgeflux[0]); 545 } 546 404 547 // Multiply edgeflux by edgelength 405 548 length = edgelengths[ki]; … … 407 550 edgeflux[1] *= length; 408 551 edgeflux[2] *= length; 552 409 553 410 554 //// Don't allow an outward advective flux if the cell centroid stage … … 1554 1698 domain.timestep = compute_fluxes(timestep, 1555 1699 domain.epsilon, 1556 domain.H0,1700 domain.H0, 1557 1701 domain.g, 1558 1702 domain.neighbours, … … 1611 1755 *height_centroid_values, 1612 1756 *bed_vertex_values, 1613 *riverwall_elevation; 1757 *edge_flux_type, 1758 *riverwall_elevation, 1759 *riverwall_rowIndex, 1760 *riverwall_hydraulic_properties; 1614 1761 1615 1762 double timestep, epsilon, H0, g; 1616 int optimise_dry_cells, timestep_fluxcalls ;1763 int optimise_dry_cells, timestep_fluxcalls, ncol_riverwall_hydraulic_properties; 1617 1764 1618 1765 // Convert Python arguments to C 1619 if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOOOiiOOOOOOO ",1766 if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOOOiiOOOOOOOOiO", 1620 1767 ×tep, 1621 1768 &epsilon, … … 1649 1796 &bed_centroid_values, 1650 1797 &height_centroid_values, 1651 &bed_vertex_values, 1652 &riverwall_elevation)) { 1798 //&bed_vertex_values, 1799 &edge_flux_type, 1800 &riverwall_elevation, 1801 &riverwall_rowIndex, 1802 &ncol_riverwall_hydraulic_properties, 1803 &riverwall_hydraulic_properties 1804 )) { 1653 1805 report_python_error(AT, "could not parse input arguments"); 1654 1806 return NULL; … … 1682 1834 CHECK_C_CONTIG(bed_centroid_values); 1683 1835 CHECK_C_CONTIG(height_centroid_values); 1684 CHECK_C_CONTIG(bed_vertex_values); 1836 //CHECK_C_CONTIG(bed_vertex_values); 1837 CHECK_C_CONTIG(edge_flux_type); 1685 1838 CHECK_C_CONTIG(riverwall_elevation); 1839 CHECK_C_CONTIG(riverwall_rowIndex); 1840 CHECK_C_CONTIG(riverwall_hydraulic_properties); 1686 1841 1687 1842 int number_of_elements = stage_edge_values -> dimensions[0]; … … 1723 1878 (double*) bed_centroid_values -> data, 1724 1879 (double*) height_centroid_values -> data, 1725 (double*) bed_vertex_values -> data, 1726 (double*) riverwall_elevation -> data); 1727 1880 //(double*) bed_vertex_values -> data, 1881 (long*) edge_flux_type-> data, 1882 (double*) riverwall_elevation-> data, 1883 (long*) riverwall_rowIndex-> data, 1884 ncol_riverwall_hydraulic_properties, 1885 (double*) riverwall_hydraulic_properties ->data); 1728 1886 // Return updated flux timestep 1729 1887 return Py_BuildValue("d", timestep);
Note: See TracChangeset
for help on using the changeset viewer.