Changeset 8865 for trunk/anuga_work/development
- Timestamp:
- May 12, 2013, 8:11:11 PM (12 years ago)
- Location:
- trunk/anuga_work/development/gareth
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain.py
r8772 r8865 59 59 number_of_full_triangles = number_of_full_triangles) 60 60 61 #self.forcing_terms.append(manning_friction_implicit) 61 62 #------------------------------------------------ 62 63 # set some defaults 63 64 # Most of these override the options in config.py 64 65 #------------------------------------------------ 65 self.set_CFL(1.0 0)66 self.set_CFL(1.0) 66 67 self.set_use_kinematic_viscosity(False) 67 self.timestepping_method='rk2' #'euler'#'rk2'#'euler'#'rk2'68 self.timestepping_method='rk2'#'rk2'#'euler'#'rk2' 68 69 # The following allows storage of the negative depths associated with this method 69 70 self.minimum_storable_height=-99999999999.0 … … 76 77 # extrapolate_second_order_and_limit_by_edge) uses a constant value for 77 78 # all the betas. 78 self.beta_w= 1.079 self.beta_w=0.0 79 80 self.beta_w_dry=0.0 80 self.beta_uh= 1.081 self.beta_uh=0.0 81 82 self.beta_uh_dry=0.0 82 self.beta_vh= 1.083 self.beta_vh=0.0 83 84 self.beta_vh_dry=0.0 84 85 … … 241 242 242 243 # Shortcuts 243 if(domain.timestepping_method!='rk2'): 244 err_mess='ERROR: Timestepping method is ' + domain.timestepping_method +'. '+\ 245 'You need to use rk2 timestepping with this solver, ' +\ 246 ' because there is presently a hack in compute fluxes central. \n'+\ 247 ' The HACK: The timestep will only ' +\ 248 'be recomputed on every 2nd call to compute_fluxes_central, to support'+\ 249 ' correct treatment of wetting and drying' 250 251 raise Exception, err_mess 244 #if(domain.timestepping_method!='rk2'): 245 # err_mess='ERROR: Timestepping method is ' + domain.timestepping_method +'. '+\ 246 # 'You need to use rk2 timestepping with this solver, ' +\ 247 # ' because there is presently a hack in compute fluxes central. \n'+\ 248 # ' The HACK: The timestep will only ' +\ 249 # 'be recomputed on every 2nd call to compute_fluxes_central, to support'+\ 250 # ' correct treatment of wetting and drying' 251 252 # raise Exception, err_mess 253 254 if(domain.timestepping_method=='rk2'): 255 timestep_order=2 256 elif(domain.timestepping_method=='euler'): 257 timestep_order=1 258 #elif(domain.timestepping_method=='rk3'): 259 # timestep_order=3 260 else: 261 err_mess='ERROR: domain.timestepping_method= ' + domain.timestepping_method +' not supported in this solver' 262 raise Exception, err_mess 263 264 #print 'timestep_order=', timestep_order 252 265 253 266 Stage = domain.quantities['stage'] … … 260 273 flux_timestep = compute_fluxes_ext(timestep, 261 274 domain.epsilon, 262 domain. H0,275 domain.minimum_allowed_height, 263 276 domain.g, 264 277 domain.boundary_flux_sum, … … 284 297 domain.max_speed, 285 298 int(domain.optimise_dry_cells), 299 timestep_order, 286 300 Stage.centroid_values, 287 301 Xmom.centroid_values, … … 293 307 #pdb.set_trace() 294 308 #print 'flux timestep: ', flux_timestep, domain.timestep 295 if(flux_timestep == float(sys.maxint)): 296 domain.boundary_flux_integral[0]= domain.boundary_flux_integral[0] +\ 297 domain.boundary_flux_sum[0]*domain.timestep*0.5 298 #print 'dbfi ', domain.boundary_flux_integral, domain.boundary_flux_sum 299 domain.boundary_flux_sum[0]=0. 309 if(domain.timestepping_method=='rk2'): 310 if(flux_timestep == float(sys.maxint)): 311 domain.boundary_flux_integral[0]= domain.boundary_flux_integral[0] +\ 312 domain.boundary_flux_sum[0]*domain.timestep*0.5 313 #print 'dbfi ', domain.boundary_flux_integral, domain.boundary_flux_sum 314 domain.boundary_flux_sum[0]=0. 300 315 301 316 domain.flux_timestep = flux_timestep … … 590 605 591 606 607 #def manning_friction_implicit(domain): 608 # """Apply (Manning) friction to water momentum 609 # Wrapper for c version 610 # """ 611 # 612 # from shallow_water_ext import manning_friction_flat 613 # from shallow_water_ext import manning_friction_sloped 614 # 615 # xmom = domain.quantities['xmomentum'] 616 # ymom = domain.quantities['ymomentum'] 617 # 618 # x = domain.get_vertex_coordinates() 619 # 620 # w = domain.quantities['stage'].centroid_values 621 # z = domain.quantities['elevation'].vertex_values 622 # 623 # uh = xmom.centroid_values 624 # vh = ymom.centroid_values 625 # eta = domain.quantities['friction'].centroid_values 626 # 627 # xmom_update = xmom.semi_implicit_update 628 # ymom_update = ymom.semi_implicit_update 629 # 630 # eps = domain.epsilon 631 # g = domain.g 632 # 633 # if domain.use_sloped_mannings: 634 # manning_friction_sloped(g, eps, x, w, uh, vh, z, eta, xmom_update, \ 635 # ymom_update) 636 # else: 637 # manning_friction_flat(g, eps, w, uh, vh, z, eta, xmom_update, \ 638 # #ymom_update) -
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c
r8775 r8865 94 94 double g, 95 95 double *edgeflux, double *max_speed, 96 double *pressure_flux) 96 double *pressure_flux, double hc, 97 double hc_n, 98 double speed_max_last) 97 99 { 98 100 … … 141 143 h_left = max(w_left - z,0.); 142 144 uh_left = q_left_rotated[1]; 143 //if(h_left>1.e-06){144 //u_left = uh_left/max(h_left, 1.0e-06);145 //}else{146 //u_left=0.;147 //}148 u_left = _compute_speed(&uh_left, &h_left,149 epsilon, h0, limiting_threshold);145 if(h_left>h0){ 146 u_left = uh_left/max(h_left, 1.0e-06); 147 }else{ 148 u_left=0.; 149 } 150 //u_left = _compute_speed(&uh_left, &h_left, 151 // epsilon, h0, limiting_threshold); 150 152 151 153 w_right = q_right_rotated[0]; 152 154 h_right = max(w_right - z, 0.); 153 155 uh_right = q_right_rotated[1]; 154 u_right = _compute_speed(&uh_right, &h_right,155 epsilon, h0, limiting_threshold);156 //if(h_right>1.0e-06){157 //u_right = uh_right/max(h_right, 1.0e-06);158 //}else{159 //u_right=0.;160 //}156 //u_right = _compute_speed(&uh_right, &h_right, 157 // epsilon, h0, limiting_threshold); 158 if(h_right>h0){ 159 u_right = uh_right/max(h_right, 1.0e-06); 160 }else{ 161 u_right=0.; 162 } 161 163 162 164 // Momentum in y-direction … … 198 200 } 199 201 202 if( hc < h0){ 203 s_max = 0.0; 204 } 205 206 200 207 s_min = min(u_left - soundspeed_left, u_right - soundspeed_right); 201 208 if (s_min > 0.0) … … 204 211 } 205 212 213 if( hc_n < h0){ 214 s_min = 0.0; 215 } 216 206 217 // Flux formulas 207 218 flux_left[0] = u_left*h_left; 208 flux_left[1] = u_left*uh_left ; //+ 0.5*g*h_left*h_left; 209 flux_left[2] = u_left*vh_left; 219 //if(hc>h0){ 220 flux_left[1] = u_left*uh_left; //+ 0.5*g*h_left*h_left; 221 flux_left[2] = u_left*vh_left; 222 //}else{ 223 // flux_left[1] = 0.;//u_left*uh_left; //+ 0.5*g*h_left*h_left; 224 // flux_left[2] = 0.;//u_left*vh_left; 225 //} 210 226 211 227 flux_right[0] = u_right*h_right; 212 flux_right[1] = u_right*uh_right ; //+ 0.5*g*h_right*h_right; 213 flux_right[2] = u_right*vh_right; 228 //if(hc_n>h0){ 229 flux_right[1] = u_right*uh_right ; //+ 0.5*g*h_right*h_right; 230 flux_right[2] = u_right*vh_right; 231 //}else{ 232 // flux_right[1] = 0.; //u_right*uh_right ; //+ 0.5*g*h_right*h_right; 233 // flux_right[2] = 0.; //u_right*vh_right; 234 //} 214 235 215 236 // Flux computation … … 222 243 *max_speed = 0.0; 223 244 *pressure_flux = 0.0; 245 //*pressure_flux = 0.5*g*0.5*(h_left*h_left+h_right*h_right); 224 246 } 225 247 else 226 248 { 249 // Maximal wavespeed 250 *max_speed = max(s_max, -s_min); 251 227 252 inverse_denominator = 1.0/denom; 228 253 for (i = 0; i < 3; i++) 229 254 { 230 255 edgeflux[i] = s_max*flux_left[i] - s_min*flux_right[i]; 231 edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]); 256 // Standard smoothing term 257 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]); 258 //GD HACK: Here, we supress the 'smoothing' part of the flux -- like scaling diffusion by local wave speed 259 edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i])* 260 (min(*max_speed/(max(speed_max_last,1e-06)),1.0));//(min(hc/h_left,min(hc_n/h_right,1.0))); 232 261 edgeflux[i] *= inverse_denominator; 233 262 } … … 235 264 *pressure_flux = 0.5*g*( s_max*h_left*h_left -s_min*h_right*h_right)*inverse_denominator; 236 265 237 // Maximal wavespeed238 *max_speed = max(fabs(s_max), fabs(s_min));239 266 240 267 // Rotate back … … 274 301 double* max_speed_array, 275 302 int optimise_dry_cells, 303 int timestep_order, 276 304 double* stage_centroid_values, 277 305 double* xmom_centroid_values, … … 281 309 // Local variables 282 310 double max_speed, length, inv_area, zl, zr; 283 double h0 = H0* H0; // This ensures a good balance when h approaches H0.284 285 double limiting_threshold = H0; //10 * H0; // Avoid applying limiter below this311 double h0 = H0*2.0;//H0*H0;//H0*H0; // This ensures a good balance when h approaches H0. 312 313 double limiting_threshold = 10 * H0 ;//H0; //10 * H0; // Avoid applying limiter below this 286 314 // threshold for performance reasons. 287 315 // See ANUGA manual under flux limiting … … 297 325 double stage_edge_lim, outgoing_mass_edges, bedtop, bedbot, pressure_flux, hc, hc_n, tmp, tmp2; 298 326 static long call = 1; // Static local variable flagging already computed flux 327 double speed_max_last, vol; 299 328 300 329 double *max_bed_edgevalue, *min_bed_edgevalue, *edgeflux_store, *pressuregrad_store; … … 314 343 local_timestep=timestep; 315 344 345 //printf("timestep_order %lf \n", timestep_order*1.0); 316 346 // Compute minimum bed edge value on each triangle 347 speed_max_last=0.0; 317 348 for (k = 0; k < number_of_elements; k++){ 318 349 max_bed_edgevalue[k] = max(bed_edge_values[3*k], 319 350 max(bed_edge_values[3*k+1], bed_edge_values[3*k+2])); 351 speed_max_last=max(speed_max_last, max_speed_array[k]); 352 353 //if(stage_centroid_values[k]<bed_centroid_values[k]){ 354 // printf("Stage < bed"); 355 //} 320 356 } 321 357 358 //printf("SML: %.12lf, %.12lf, %.12lf \n", speed_max_last, fabs(-speed_max_last), max(speed_max_last*2.0, 0.5*speed_max_last)/2.0); 359 360 //printf("SPM: %lf \n", speed_max_last); 322 361 323 362 // For all triangles … … 375 414 //If one centroid is dry, then extrapolate its edge values from the neighbouring centroid, 376 415 // unless the local centroid value is smaller 377 if(n>=0){378 if((hc<=H0)&&(hc_n>H0)){379 ql[0]=max(min(qr[0],stage_centroid_values[k]),zl);380 }381 if((hc_n<=H0)&&(hc>H0)){382 qr[0]=max(min(ql[0],stage_centroid_values[n]),zr);383 }384 385 }else{386 // Treat the boundary case387 // ??388 }416 //if(n>=0){ 417 // if((hc<=H0)&&(hc_n>H0)){ 418 // ql[0]=max(min(qr[0],stage_centroid_values[k]),zl); 419 // } 420 // if((hc_n<=H0)&&(hc>H0)){ 421 // qr[0]=max(min(ql[0],stage_centroid_values[n]),zr); 422 // } 423 424 //}else{ 425 // // Treat the boundary case 426 // // ?? 427 //} 389 428 390 429 // Edge flux computation (triangle k, edge i) … … 392 431 normals[ki2], normals[ki2 + 1], 393 432 epsilon, h0, limiting_threshold, g, 394 edgeflux, &max_speed, &pressure_flux); 433 edgeflux, &max_speed, &pressure_flux, hc, hc_n, 434 speed_max_last); 395 435 396 436 … … 409 449 // bedslope_work contains all gravity related terms -- weighting of 410 450 // conservative and non-conservative versions. 411 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 412 //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope 413 pressuregrad_store[ki] = bedslope_work; 414 451 if(hc> -h0){ 452 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 453 //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 454 //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope 455 pressuregrad_store[ki] = bedslope_work; 456 }else{ 457 bedslope_work = length*(g*(hc*ql[0]-0.0*max(ql[0]-zl,0.)*(ql[0]-zl)) + 0.0*pressure_flux); 458 //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.0*max(ql[0]-zl,0.)*(ql[0]-zl)) + 0.0*pressure_flux); 459 //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope 460 pressuregrad_store[ki] = bedslope_work; 461 } 415 462 416 463 already_computed_flux[ki] = call; // #k Done … … 424 471 edgeflux_store[nm3 + 2 ] = edgeflux[2]; 425 472 426 bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 427 //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; 428 pressuregrad_store[nm] = bedslope_work; 429 473 if(hc_n> -h0){ 474 bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 475 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 476 //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; 477 pressuregrad_store[nm] = bedslope_work; 478 }else{ 479 bedslope_work = length*(g*(hc_n*qr[0]-0.0*max(qr[0]-zr,0.)*(qr[0]-zr)) + 0.0*pressure_flux); 480 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.0*max(qr[0]-zr,0.)*(qr[0]-zr)) + 0.0*pressure_flux); 481 //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; 482 pressuregrad_store[nm] = bedslope_work; 483 } 430 484 431 485 already_computed_flux[nm] = call; // #n Done … … 439 493 if ((tri_full_flag[k] == 1) ) { 440 494 441 if(call% 2==1) max_speed = max_speed_array[k]; // HACK to Ensure that local timestep is the same as the last timestep495 if(call%timestep_order!=0) max_speed = max_speed_array[k]; // HACK to Ensure that local timestep is the same as the last timestep 442 496 443 497 if (max_speed > epsilon) { … … 465 519 // Limit edgefluxes, for mass conservation near wet/dry cells 466 520 for(k=0; k< number_of_elements; k++){ 521 //continue; 467 522 hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.); 468 523 // Loop over every edge … … 474 529 if(edgeflux_store[3*(3*k+useint)]< 0.){ 475 530 //outgoing_mass_edges+=1.0; 476 outgoing_mass_edges+=(edgeflux_store[3*(3*k+useint)] *local_timestep);531 outgoing_mass_edges+=(edgeflux_store[3*(3*k+useint)]); 477 532 } 478 533 } 534 outgoing_mass_edges*=local_timestep; 479 535 } 480 536 … … 486 542 // Idea: The cell will not go dry if: 487 543 // total_outgoing_flux <= cell volume = Area_triangle*hc 488 if((edgeflux_store[ki3]< 0.0) && (outgoing_mass_edges<0.)){ 544 vol=areas[k]*hc; 545 if((edgeflux_store[ki3]< 0.0) && (-outgoing_mass_edges> vol)){ 489 546 490 547 // This bound could be improved (e.g. we could actually sum … … 493 550 // about subsequent changes to the + edgeflux caused by 494 551 // constraints associated with neighbouring triangles. 495 tmp = (areas[k]*hc)/(fabs(outgoing_mass_edges)+1.0e-10) ;552 tmp = vol/(-(outgoing_mass_edges)) ; 496 553 if(tmp< 1.0){ 497 554 edgeflux_store[ki3+0]*=tmp; … … 528 585 // GD HACK 529 586 // Option to limit advective fluxes 530 if(hc > H0){587 if(hc > h0){ 531 588 stage_explicit_update[k] += edgeflux_store[ki3+0]; 532 589 // Cut these terms for shallow flows, and protect stationary states from round-off error … … 546 603 // GD HACK 547 604 // Compute bed slope term 548 if(hc >H0){605 if(hc > h0){ 549 606 xmom_explicit_update[k] -= normals[ki2]*pressuregrad_store[ki]; 550 607 ymom_explicit_update[k] -= normals[ki2+1]*pressuregrad_store[ki]; … … 564 621 } // end cell k 565 622 566 if(call% 2==0) timestep=local_timestep;623 if(call%timestep_order==0) timestep=local_timestep; 567 624 568 625 // Look for 'dry' edges, and set momentum (& component of momentum_update) … … 668 725 669 726 //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) { 670 if (hc < minimum_allowed_height ) {727 if (hc < minimum_allowed_height*2.0) { 671 728 // Set momentum to zero and ensure h is non negative 672 xmomc[k] = 0.0; 673 ymomc[k] = 0.0; 729 //xmomc[k] = 0.;//xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 730 //ymomc[k] = 0.;//ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 731 xmomc[k] = xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 732 ymomc[k] = ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 674 733 675 734 if (hc <= 0.0){ … … 678 737 //bmin =0.5*bmin + 0.5*min(zv[3*k],min(zv[3*k+1],zv[3*k+2])); 679 738 //bmin =min(zv[3*k],min(zv[3*k+1],zv[3*k+2])) -minimum_allowed_height; 680 bmin=zc[k] -minimum_allowed_height;739 bmin=zc[k];//-1.0e-03; 681 740 // Minimum allowed stage = bmin 682 741 … … 687 746 688 747 wc[k] = max(wc[k], bmin); 689 printf(" mass_add, %f, %f, %f,%f,%f,%d\n", xc[k], yc[k], wc[k],zc[k],wc[k]-zc[k], k) ;748 //printf(" mass_add, %f, %f, %f,%f,%f,%d\n", xc[k], yc[k], wc[k],zc[k],wc[k]-zc[k], k) ; 690 749 691 750 … … 801 860 double x, y, x0, y0, x1, y1, x2, y2, xv0, yv0, xv1, yv1, xv2, yv2; // Vertices of the auxiliary triangle 802 861 double dx1, dx2, dy1, dy2, dxv0, dxv1, dxv2, dyv0, dyv1, dyv2, dq0, dq1, dq2, area2, inv_area2; 803 double dqv[3], qmin, qmax, hmin, hmax, bedmax, stagemin;862 double dqv[3], qmin, qmax, hmin, hmax, bedmax,bedmin, stagemin; 804 863 double hc, h0, h1, h2, beta_tmp, hfactor, xtmp, ytmp, weight, tmp; 805 864 double dk, dv0, dv1, dv2, de[3], demin, dcmax, r0scale, vect_norm, l1, l2, a_bs, b_bs, area_e, inv_area_e; … … 848 907 cell_wetness_scale[k] = 0.; 849 908 // Check if cell k is wet 850 if(stage_centroid_values[k] > elevation_centroid_values[k]){851 //if(stage_centroid_values[k] > elevation_centroid_values[k] +minimum_allowed_height+epsilon){909 //if(stage_centroid_values[k] > elevation_centroid_values[k]){ 910 if(stage_centroid_values[k] > elevation_centroid_values[k] + 2*minimum_allowed_height+epsilon){ 852 911 //if(stage_centroid_values[k] > max_elevation_edgevalue[k] + minimum_allowed_height+epsilon){ 853 912 cell_wetness_scale[k] = 1.; … … 935 994 936 995 // Compute bed slope as a reference 937 area_e = (yv2-yv0)*(xv1-xv0) - (yv1-yv0)*(xv2-xv0);938 inv_area_e=1.0/area_e;939 a_bs = (yv2 - yv0)*(elevation_edge_values[k3+1]-elevation_edge_values[k3+0]) -940 (yv1 - yv0)*(elevation_edge_values[k3+2]-elevation_edge_values[k3+0]);941 a_bs *= inv_area_e;942 943 b_bs = -(xv2 - xv0)*(elevation_edge_values[k3+1]-elevation_edge_values[k3+0]) +944 (xv1 - xv0)*(elevation_edge_values[k3+2]-elevation_edge_values[k3+0]);945 b_bs *= inv_area_e;996 //area_e = (yv2-yv0)*(xv1-xv0) - (yv1-yv0)*(xv2-xv0); 997 //inv_area_e=1.0/area_e; 998 //a_bs = (yv2 - yv0)*(elevation_edge_values[k3+1]-elevation_edge_values[k3+0]) - 999 // (yv1 - yv0)*(elevation_edge_values[k3+2]-elevation_edge_values[k3+0]); 1000 //a_bs *= inv_area_e; 1001 1002 //b_bs = -(xv2 - xv0)*(elevation_edge_values[k3+1]-elevation_edge_values[k3+0]) + 1003 // (xv1 - xv0)*(elevation_edge_values[k3+2]-elevation_edge_values[k3+0]); 1004 //b_bs *= inv_area_e; 946 1005 947 1006 //printf("slopes: %f, %f \n", a_bs, b_bs); … … 989 1048 // Take note if the max neighbour bed elevation is greater than the min 990 1049 // neighbour stage -- suggests a 'steep' bed relative to the flow 991 //bedmax = max(elevation_centroid_values[k], 992 // max(elevation_centroid_values[k0], 993 // max(elevation_centroid_values[k1], 994 // elevation_centroid_values[k2]))); 1050 bedmax = max(elevation_centroid_values[k], 1051 max(elevation_centroid_values[k0], 1052 max(elevation_centroid_values[k1], 1053 elevation_centroid_values[k2]))); 1054 bedmin = min(elevation_centroid_values[k], 1055 min(elevation_centroid_values[k0], 1056 min(elevation_centroid_values[k1], 1057 elevation_centroid_values[k2]))); 995 1058 //stagemin = min(max(stage_centroid_values[k], elevation_centroid_values[k]), 996 1059 // min(max(stage_centroid_values[k0], elevation_centroid_values[k0]), … … 1028 1091 1029 1092 if(0==1){ 1030 // Friction slope type extrapolation -- emulating steady flow1031 // d(stage)/dx = - u*sqrt(u**2 + v**2)*n**2/depth**(4/3)1032 hc=max(stage_centroid_values[k] - elevation_centroid_values[k],0.0);1033 if(hc>1.0e-06){1034 tmp = sqrt(xmom_centroid_values[k]*xmom_centroid_values[k] +1035 ymom_centroid_values[k]*ymom_centroid_values[k])*0.03*0.03;1036 tmp /=pow(hc,10.0/3.0);1037 }else{1038 tmp=0.0;1039 }1040 a = -xmom_centroid_values[k]*tmp;1041 b = -ymom_centroid_values[k]*tmp;1093 //// Friction slope type extrapolation -- emulating steady flow 1094 //// d(stage)/dx = - u*sqrt(u**2 + v**2)*n**2/depth**(4/3) 1095 //hc=max(stage_centroid_values[k] - elevation_centroid_values[k],0.0); 1096 //if(hc>1.0e-06){ 1097 // tmp = sqrt(xmom_centroid_values[k]*xmom_centroid_values[k] + 1098 // ymom_centroid_values[k]*ymom_centroid_values[k])*0.03*0.03; 1099 // tmp /=pow(hc,10.0/3.0); 1100 //}else{ 1101 // tmp=0.0; 1102 //} 1103 //a = -xmom_centroid_values[k]*tmp; 1104 //b = -ymom_centroid_values[k]*tmp; 1042 1105 1043 // Limit gradient to be between the bed slope, and zero1044 if(a*a_bs<0.) a=0.;1045 if(fabs(a)>fabs(a_bs)) a=a_bs;1046 if(b*b_bs<0.) b=0.;1047 if(fabs(b)>fabs(b_bs)) b=b_bs;1048 1049 1050 dqv[0] = a*dxv0 + b*dyv0;1051 dqv[1] = a*dxv1 + b*dyv1;1052 dqv[2] = a*dxv2 + b*dyv2;1053 1054 stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0];1055 stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1];1056 stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2];1106 //// Limit gradient to be between the bed slope, and zero 1107 //if(a*a_bs<0.) a=0.; 1108 //if(fabs(a)>fabs(a_bs)) a=a_bs; 1109 //if(b*b_bs<0.) b=0.; 1110 //if(fabs(b)>fabs(b_bs)) b=b_bs; 1111 1112 1113 //dqv[0] = a*dxv0 + b*dyv0; 1114 //dqv[1] = a*dxv1 + b*dyv1; 1115 //dqv[2] = a*dxv2 + b*dyv2; 1116 1117 //stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1118 //stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1119 //stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1057 1120 }else{ 1058 1121 // Constant stage extrapolation … … 1185 1248 ////if (hc>0.0) 1186 1249 //{ 1187 hfactor = 1.0 ;//hmin/(hmin + 0.004);1250 // hfactor = 1.0 ;//hmin/(hmin + 0.004); 1188 1251 //hfactor=hmin/(hmin + 0.004); 1189 1252 //} 1190 hfactor= min(2.0*max(hmin,0)/max(hc,1.0e-06), 1.0); 1253 hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height*10.)), 1.0); 1254 //hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height)), 1.0); 1191 1255 1192 1256 //----------------------------------- … … 1252 1316 //if( (area2>0) ){ 1253 1317 //if(count_wet_neighbours[k]>0){ 1254 1318 limit_gradient(dqv, qmin, qmax, beta_tmp); 1255 1319 //} 1256 1320 //} 1257 1258 1259 1321 stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1322 stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1323 stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1260 1324 // IDEA: extrapolate assuming slope is that of steady flow?? 1261 1325 // GD HACK - FIXME … … 1746 1810 1747 1811 double timestep, epsilon, H0, g; 1748 int optimise_dry_cells ;1812 int optimise_dry_cells, timestep_order; 1749 1813 1750 1814 // Convert Python arguments to C 1751 if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOOi OOOOO",1815 if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOOiiOOOOO", 1752 1816 ×tep, 1753 1817 &epsilon, … … 1774 1838 &max_speed_array, 1775 1839 &optimise_dry_cells, 1840 ×tep_order, 1776 1841 &stage_centroid_values, 1777 1842 &xmom_centroid_values, … … 1841 1906 (double*) max_speed_array -> data, 1842 1907 optimise_dry_cells, 1908 timestep_order, 1843 1909 (double*) stage_centroid_values -> data, 1844 1910 (double*) xmom_centroid_values -> data, … … 1871 1937 1872 1938 1873 h0 = H0*H0; // This ensures a good balance when h approaches H0. 1874 // But evidence suggests that h0 can be as little as 1875 // epsilon! 1876 1939 h0 = H0; 1877 1940 limiting_threshold = 10*H0; // Avoid applying limiter below this 1878 1941 // threshold for performance reasons. … … 1890 1953 (double*) edgeflux -> data, 1891 1954 &max_speed, 1892 &pressure_flux); 1955 &pressure_flux, 1956 ((double*) normal -> data)[0], 1957 ((double*) normal -> data)[1], 1958 ((double*) normal -> data)[1] 1959 ); 1893 1960 1894 1961 return Py_BuildValue("d", max_speed); -
trunk/anuga_work/development/gareth/tests/dam_break/plotme.py
r8774 r8865 9 9 p2_st=util.get_centroids(p_st) 10 10 11 p_dev = util.get_output('dam_break_20130 320_001049/dam_break.sww', 0.001)11 p_dev = util.get_output('dam_break_20130504_145918/dam_break.sww', 0.001) 12 12 p2_dev=util.get_centroids(p_dev, velocity_extrapolation=True) 13 13 -
trunk/anuga_work/development/gareth/tests/runup/runup.py
r8772 r8865 34 34 #------------------ 35 35 36 scale_me=100.0 37 36 38 def topography(x,y): 37 return -x/2 #+0.05*numpy.sin((x+y)*50.0) #+0.1*(numpy.random.rand(len(x)) -0.5) # Linear bed slope + small random perturbation39 return -x/2*scale_me #+0.05*numpy.sin((x+y)*50.0) #+0.1*(numpy.random.rand(len(x)) -0.5) # Linear bed slope + small random perturbation 38 40 39 41 def stagefun(x,y): 40 stg=-0.2*(x<0.5) -0.1*(x>=0.5)41 #stg=-0.2# Stage42 #stg=(-0.2*(x<0.5) -0.1*(x>=0.5))*scale_me 43 stg=-0.2*scale_me # Stage 42 44 #topo=topography(x,y) #Bed 43 45 return stg #*(stg>topo) + topo*(stg<=topo) … … 55 57 Br=anuga.Reflective_boundary(domain) # Solid reflective wall 56 58 Bt=anuga.Transmissive_boundary(domain) # Continue all values of boundary -- not used in this example 57 Bd=anuga.Dirichlet_boundary([-0.2 ,0.,0.]) # Constant boundary values -- not used in this example59 Bd=anuga.Dirichlet_boundary([-0.2*scale_me,0.,0.]) # Constant boundary values -- not used in this example 58 60 #Bw=anuga.Time_boundary(domain=domain, 59 61 # f=lambda t: [(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1,0.0,0.0]) # Time varying boundary -- get rid of the 0.0 to do a runup. -
trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py
r8772 r8865 24 24 domain=Domain(points,vertices,boundary) # Create Domain 25 25 domain.set_name('runup_sinusoid_v2') # Output to file runup.sww 26 26 #domain.set_timestepping_method('euler') 27 27 #------------------ 28 28 # Define topography 29 29 #------------------ 30 30 scale_me=1.0 31 boundary_ws=-0.1 32 init_ws=-0.2 33 bumpiness=10. # Higher = shorter wavelength oscillations in topography 31 34 #domain.minimum_allowed_height=domain.minimum_allowed_height*scale_me # Seems needed to make the algorithms behave 32 35 33 36 def topography(x,y): 34 return (-x/2.0 +0.05*numpy.sin((x+y)* 50.0))*scale_me37 return (-x/2.0 +0.05*numpy.sin((x+y)*bumpiness))*scale_me 35 38 36 39 def stagefun(x,y): 37 stge= -0.2*scale_me #+0.1*(x>0.9)40 stge=init_ws*scale_me# +0.1*(x>0.9)*scale_me 38 41 #topo=topography(x,y) 39 42 return stge#*(stge>topo) + (topo)*(stge<=topo) … … 41 44 domain.set_quantity('elevation',topography) # Use function for elevation 42 45 domain.get_quantity('elevation').smooth_vertex_values() 43 domain.set_quantity('friction',0.0 3) # Constant friction46 domain.set_quantity('friction',0.00) # Constant friction 44 47 45 48 #def frict_change(x,y): … … 64 67 Bd=anuga.Dirichlet_boundary([-0.1*scale_me,0.,0.]) # Constant boundary values -- not used in this example 65 68 def waveform(t): 66 return -0.1 #(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1 69 return boundary_ws*scale_me 70 #return -0.2*scale_me #-0.1 #(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1 67 71 Bt2=anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain,waveform) 68 72 #Bw=anuga.Time_boundary(domain=domain, … … 78 82 #------------------------------ 79 83 80 for t in domain.evolve(yieldstep=0.2 00,finaltime=40.00):84 for t in domain.evolve(yieldstep=0.2,finaltime=120.00): 81 85 print domain.timestepping_statistics() 82 print domain.boundary_flux_integral86 #print domain.boundary_flux_integral 83 87 xx = domain.quantities['xmomentum'].centroid_values 84 88 yy = domain.quantities['ymomentum'].centroid_values … … 88 92 vv = ( (xx/dd)**2 + (yy/dd)**2)**0.5 89 93 vv = vv*(dd>1.0e-03) 90 print 'Peak velocity is: ', vv.max(), vv.argmax() 94 print 'Peak velocity is: ', vv.max(), vv.argmax(), dd[vv.argmax()] 91 95 print 'Volume is', sum(dd_raw*domain.areas) 92 print 'Volume less flux int', sum(dd_raw*domain.areas) - domain.boundary_flux_integral96 #print 'Volume less flux int', sum(dd_raw*domain.areas) - domain.boundary_flux_integral 93 97 94 98 -
trunk/anuga_work/development/gareth/tests/shallow_steep_slope/channel_SU_sparse.py
r8772 r8865 36 36 #------------------------------------------------------------------------------ 37 37 def topography(x, y): 38 return -x/10. #+ 1.*(numpy.sin(x/10.) +abs(y-50.)/10.) -0.*(x>80.) # linear bed slope38 return -x/10. + 1.*(numpy.sin(x/10.) +abs(y-50.)/10.) -0.*(x>80.) # linear bed slope 39 39 40 40 def stagetopo(x,y):
Note: See TracChangeset
for help on using the changeset viewer.