Changeset 8867
- Timestamp:
- May 16, 2013, 8:57:00 PM (11 years ago)
- Location:
- trunk/anuga_work/development/gareth
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c
r8866 r8867 108 108 double *edgeflux, double *max_speed, 109 109 double *pressure_flux, double hc, 110 double hc_n, 111 double s peed_max_last)110 double hc_n, double speed_max_last, 111 double smooth) 112 112 { 113 113 … … 129 129 double s_min, s_max, soundspeed_left, soundspeed_right; 130 130 double denom, inverse_denominator, z; 131 double uint, t1, t2, t3, min_speed ;131 double uint, t1, t2, t3, min_speed, tmp; 132 132 // Workspace (allocate once, use many) 133 133 static double q_left_rotated[3], q_right_rotated[3], flux_right[3], flux_left[3]; … … 277 277 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]); 278 278 279 // Standard smoothing term, scaled 280 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i])*smooth; 281 279 282 // Adjustment to the scheme by Kurganov and Lin 2007 Communications in Computational 280 283 // Physics 2:141-163 281 //uint = (s_max*q_right_rotated[i] - s_min*q_left_rotated[i] - (flux_right[i] - flux_left[i]))*inverse_denominator; 282 //t1 = (q_right_rotated[i] - uint); 283 //t2 = (-q_left_rotated[i] + uint); 284 //t3 = _minmod(t1,t2); 285 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]-t3); 284 uint = (s_max*q_right_rotated[i] - s_min*q_left_rotated[i] - (flux_right[i] - flux_left[i]))*inverse_denominator; 285 t1 = (q_right_rotated[i] - uint); 286 t2 = (-q_left_rotated[i] + uint); 287 t3 = _minmod(t1,t2); 288 edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]-t3); 289 290 // test this 291 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i])*pow(min(hc/(hc_n+epsilon), hc_n/(hc+epsilon)),1.0); 292 293 // test this 294 //tmp=min(fabs(q_right_rotated[i])/(fabs(q_left_rotated[i])+epsilon) , fabs(q_left_rotated[i])/(fabs(q_right_rotated[i])+epsilon)); 295 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]-t3)*pow(tmp,1.0); 286 296 287 297 //GD HACK: Here, we supress the 'smoothing' part of the flux -- like scaling diffusion by local wave speed 298 // This is a bad idea! E.g. oscillations in landslide wave runup case 299 // However, it does supress the growth of some wet-dry instabilities (e.g. PNG). 288 300 //if(i!=2){ 289 edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i])*290 (min(*max_speed/(max(speed_max_last,1.0e-100)),1.0));//(min(hc/h_left,min(hc_n/h_right,1.0)));301 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i])* 302 // (min(*max_speed/(max(speed_max_last,1.0e-100)),1.0));//(min(hc/h_left,min(hc_n/h_right,1.0))); 291 303 //} 292 304 … … 357 369 double stage_edge_lim, outgoing_mass_edges, bedtop, bedbot, pressure_flux, hc, hc_n, tmp, tmp2; 358 370 static long call = 1; // Static local variable flagging already computed flux 359 double speed_max_last, vol; 360 361 double *max_bed_edgevalue, *min_bed_edgevalue, *edgeflux_store, *pressuregrad_store; 362 363 max_bed_edgevalue = malloc(number_of_elements*sizeof(double)); 371 double speed_max_last, vol, smooth; 372 373 double *count_wet_edges, *count_wet_neighbours, *edgeflux_store, *pressuregrad_store; 374 375 count_wet_neighbours = malloc(number_of_elements*sizeof(double)); 376 count_wet_edges = malloc(number_of_elements*sizeof(double)); 364 377 edgeflux_store = malloc(number_of_elements*9*sizeof(double)); 365 378 pressuregrad_store = malloc(number_of_elements*3*sizeof(double)); … … 379 392 speed_max_last=0.0; 380 393 for (k = 0; k < number_of_elements; k++){ 381 max_bed_edgevalue[k] = max(bed_edge_values[3*k], 382 max(bed_edge_values[3*k+1], bed_edge_values[3*k+2])); 394 395 count_wet_edges[k] = 0.; 396 count_wet_neighbours[k] = 0.; 397 for (i =0; i<3; i++){ 398 ki=3*k+i; 399 if(stage_edge_values[ki] > bed_edge_values[ki]+epsilon) count_wet_edges[k]+=1.0; 400 401 n=neighbours[ki]; 402 if(n<0 || stage_centroid_values[n] > bed_centroid_values[n]+h0+epsilon) count_wet_neighbours[k]+=1.0; 403 } 404 383 405 speed_max_last=max(speed_max_last, max_speed_array[k]); 384 385 //if(stage_centroid_values[k]<bed_centroid_values[k]){386 // printf("Stage < bed");387 //}388 406 } 389 390 //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);391 392 //printf("SPM: %lf \n", speed_max_last);393 407 394 408 // For all triangles … … 459 473 //} 460 474 475 smooth=1.0; 476 //if((count_wet_edges[k]<=1.0 | count_wet_neighbours[k]<=1.0) & 477 // (n>=0 && (count_wet_edges[n]<=1.0 | count_wet_neighbours[n]<=1.0))){ 478 // smooth=0.0; 479 //} 480 461 481 // Edge flux computation (triangle k, edge i) 462 482 _flux_function_central(ql, qr, zl, zr, … … 464 484 epsilon, h0, limiting_threshold, g, 465 485 edgeflux, &max_speed, &pressure_flux, hc, hc_n, 466 speed_max_last );486 speed_max_last, smooth); 467 487 468 488 … … 478 498 479 499 // Update triangle k with flux from edge i 480 481 500 // bedslope_work contains all gravity related terms -- weighting of 482 501 // conservative and non-conservative versions. 483 502 if(hc> h0){ 503 //if(stage_centroid_values[k] > count_wet_edges[k]){ 484 504 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 485 //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 505 //bedslope_work = length*(g*(hc*stage_centroid_values[k]*0.- 506 // 0.5*max(stage_centroid_values[k]-zl,0.)*(stage_centroid_values[k]-zl)) 507 // + pressure_flux); 486 508 //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope 487 509 pressuregrad_store[ki] = bedslope_work; 488 510 }else{ 511 // NOTE: When hc<h0, pressure_flux is entirely computed from the 512 // other side of the edge. Hence, we can't necessarily satisfy 513 // well-balancing by just assuming that the 2nd and 3rd terms in 514 // bedslope_work cancel. So, we force it here -- equivalent to 515 // using the water surface gravity term 489 516 bedslope_work = length*(g*(hc*ql[0]-0.0*max(ql[0]-zl,0.)*(ql[0]-zl)) + 0.0*pressure_flux); 490 517 //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.0*max(ql[0]-zl,0.)*(ql[0]-zl)) + 0.0*pressure_flux); … … 492 519 pressuregrad_store[ki] = bedslope_work; 493 520 } 494 521 522 //if(count_wet_edges[k]<=1.0) pressuregrad_store[ki]=0.0; 523 495 524 already_computed_flux[ki] = call; // #k Done 496 525 … … 504 533 505 534 if(hc_n> h0){ 535 //if(stage_centroid_values[n] > count_wet_edges[n]){ 506 536 bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 507 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 537 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]*0.-0.5*max(stage_centroid_values[n]-zr,0.)* 538 // (stage_centroid_values[n]-zr)) + pressure_flux); 508 539 //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; 509 540 pressuregrad_store[nm] = bedslope_work; 510 541 }else{ 542 // NOTE: When hc<h0, pressure_flux is entirely computed from the 543 // other side of the edge. Hence, we can't necessarily satisfy 544 // well-balancing by just assuming that the 2nd and 3rd terms in 545 // bedslope_work cancel. So, we force it here -- equivalent to 546 // using the water surface gravity term 511 547 bedslope_work = length*(g*(hc_n*qr[0]-0.0*max(qr[0]-zr,0.)*(qr[0]-zr)) + 0.0*pressure_flux); 512 548 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.0*max(qr[0]-zr,0.)*(qr[0]-zr)) + 0.0*pressure_flux); … … 514 550 pressuregrad_store[nm] = bedslope_work; 515 551 } 552 553 //if(count_wet_edges[n]<=1.0) pressuregrad_store[nm]=0.0; 516 554 517 555 already_computed_flux[nm] = call; // #n Done 518 556 } 519 557 558 //if(n==576 | n==579) pressuregrad_store[nm]=0.; 520 559 // Update timestep based on edge i and possibly neighbour n 521 560 // GD HACK: … … 709 748 //return -1; 710 749 // 711 free( max_bed_edgevalue);712 //free(min_bed_edgevalue);750 free(count_wet_edges); 751 free(count_wet_neighbours); 713 752 free(edgeflux_store); 714 753 free(pressuregrad_store); … … 739 778 // distance between the bed_centroid_value and the max bed_edge_value of 740 779 // every triangle. 741 double minimum_relative_height=0. 0;780 double minimum_relative_height=0.1; 742 781 int mass_added=0; 743 782 … … 747 786 hc = wc[k] - zc[k]; 748 787 // Definine the maximum bed edge value on triangle k. 749 //bmax = 0.5*max((zv[3*k]+zv[3*k+1]),max((zv[3*k+1]+zv[3*k+2]),(zv[3*k+2]+zv[3*k])));788 bmax = 0.5*max((zv[3*k]+zv[3*k+1]),max((zv[3*k+1]+zv[3*k+2]),(zv[3*k+2]+zv[3*k]))); 750 789 751 790 //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) { … … 755 794 756 795 757 //if (hc < m ax(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)){758 if (hc < minimum_allowed_height*2.0 ){796 //if (hc < minimum_allowed_height*2.0 | hc < minimum_relative_height*(bmax-zc[k]) ){ 797 if (hc < minimum_allowed_height*2.0 ){ 759 798 // Set momentum to zero and ensure h is non negative 760 //xmomc[k] = 0.;//xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;761 //ymomc[k] = 0.;//ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0;799 xmomc[k] = 0.;//xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 800 ymomc[k] = 0.;//ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 762 801 //xmomc[k] = xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 763 802 //ymomc[k] = ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 764 xmomc[k] = xmomc[k]*max(hc-minimum_allowed_height,0.)/(minimum_allowed_height);// 0.0;765 ymomc[k] = ymomc[k]*max(hc-minimum_allowed_height,0.)/(minimum_allowed_height);// 0.0;803 //xmomc[k] = xmomc[k]*max(hc-minimum_allowed_height,0.)/(minimum_allowed_height);// 0.0; 804 //ymomc[k] = ymomc[k]*max(hc-minimum_allowed_height,0.)/(minimum_allowed_height);// 0.0; 766 805 767 806 if (hc <= 0.0){ … … 1965 2004 PyArrayObject *normal, *ql, *qr, *edgeflux; 1966 2005 double g, epsilon, max_speed, H0, zl, zr; 1967 double h0, limiting_threshold, pressure_flux ;2006 double h0, limiting_threshold, pressure_flux, smooth; 1968 2007 1969 2008 if (!PyArg_ParseTuple(args, "OOOddOddd", … … 1981 2020 1982 2021 pressure_flux = 0.0; // Store the water pressure related component of the flux 2022 smooth = 1.0 ; // term to scale diffusion in riemann solver 2023 1983 2024 _flux_function_central((double*) ql -> data, 1984 2025 (double*) qr -> data, … … 1994 2035 ((double*) normal -> data)[0], 1995 2036 ((double*) normal -> data)[1], 1996 ((double*) normal -> data)[1] 2037 ((double*) normal -> data)[1], 2038 smooth 1997 2039 ); 1998 2040 -
trunk/anuga_work/development/gareth/tests/channel_floodplain/plotme.py
r8774 r8867 4 4 5 5 # Time-index to plot outputs from 6 index= 6006 index=900 7 7 8 8 #p2 = util.get_output('channel_floodplain1_bal_dev.sww', minimum_allowed_height=0.01) -
trunk/anuga_work/development/gareth/tests/dam_break/plotme.py
r8865 r8867 9 9 p2_st=util.get_centroids(p_st) 10 10 11 p_dev = util.get_output('dam_break_201305 04_145918/dam_break.sww', 0.001)11 p_dev = util.get_output('dam_break_20130514_201704/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_sinusoid/runup_sinusoid.py
r8866 r8867 28 28 # Define topography 29 29 #------------------ 30 scale_me=1.0 31 boundary_ws=-0.1 30 31 ### Pathological 32 scale_me=100.0 33 boundary_ws=-0.1999 32 34 init_ws=-0.2 33 bumpiness=10. # Higher = shorter wavelength oscillations in topography 35 bumpiness=50. # Higher = shorter wavelength oscillations in topography 36 tstep=0.002 37 lasttime=1.1 38 39 ### Sensible 40 #scale_me=1.0 41 #boundary_ws=-0.1 42 #init_ws=-0.2 43 #bumpiness=50. # Higher = shorter wavelength oscillations in topography 44 #tstep=0.2 45 #lasttime=40. 46 34 47 #domain.minimum_allowed_height=domain.minimum_allowed_height*scale_me # Seems needed to make the algorithms behave 35 48 … … 82 95 #------------------------------ 83 96 84 for t in domain.evolve(yieldstep=0.2,finaltime=120.00): 97 for t in domain.evolve(yieldstep=tstep,finaltime=lasttime): 98 #for t in domain.evolve(yieldstep=0.2,finaltime=60.): 85 99 print domain.timestepping_statistics() 86 100 #print domain.boundary_flux_integral -
trunk/anuga_work/development/gareth/tests/wave_runup/plotme.py
r8751 r8867 2 2 import util 3 3 from matplotlib import pyplot as pyplot 4 import numpy4 import scipy, numpy 5 5 6 6 p= util.get_output('runup_v2.sww') … … 39 39 40 40 pyplot.plot(p2.x[v], p2.elev[v], '--', color='green') 41 pyplot.title(' Time ' + str(round(t,2)))41 pyplot.title('Stage (red is analytical): Time ' + str(round(t,2))) 42 42 pyplot.ylim((-25,20)) 43 43 pyplot.savefig('figure_stage_'+str(i)+'.png') … … 52 52 pyplot.plot(t220[:,0], t220[:,2],'-',color='red') 53 53 pyplot.ylim((-25,20)) 54 pyplot.title(' Time ' + str(round(t,2)))54 pyplot.title('Velocity (red is analytical): Time ' + str(round(t,2))) 55 55 pyplot.savefig('figure_vel_'+str(i)+'.png') 56 56 pyplot.clf() … … 59 59 model_shore_x=p2.time*0. 60 60 model_shore_u=p2.time*0. 61 62 # Hacks to identify the location of the shoreline 63 shoreline_depth_thresh1=0.01 64 shoreline_depth_thresh2=0.4 65 61 66 for i in range(len(model_shore_x)): 62 67 # Compute index of shoreline 63 vtmp = p2.stage[i,:]>p2.elev+ 0.00264 # FIXME -- introduced a bug here68 vtmp = p2.stage[i,:]>p2.elev+shoreline_depth_thresh1 69 65 70 model_shore_x[i]=p2.x[vtmp].min() 66 #v_ind= p2.x[vtmp].argmin()71 #v_ind=(p2.stage[i,vtmp]-p2.elev[vtmp]).argmin() 67 72 # Store x and xvel 68 73 #model_shore_x[i]=p2.x[vtmp[v_ind]] 69 74 #model_shore_u[i]=p2.xvel[i,vtmp[v_ind]] 70 75 76 # Extract shoreline velocity. It is tricky, to avoid getting 77 # zero velocity points -- might be a better way to do it? 78 vtmp2= (p2.stage[i,:]>p2.elev+shoreline_depth_thresh1)*\ 79 (p2.stage[i,:]<p2.elev+shoreline_depth_thresh2) 80 mloc=abs(p2.xvel[i,vtmp2]).argmax() 81 #print abs(p2.xvel[i,vtmp2]).max(), mloc 82 model_shore_u[i]=p2.xvel[i,vtmp2][mloc] 83 #vtmp2 = (p2.stage[i,:]>p2.elev+0.01) 84 #mloc= (vtmp2*(p2.stage[i,:]-p2.elev)).argmin() 85 #model_shore_u[i] = p2.xvel[i,mloc] 86 71 87 pyplot.plot(p2.time, model_shore_x-200.,'-o') 72 88 pyplot.plot(shoreline[:,0], shoreline[:,1],'-', color='red') 89 pyplot.title('Shoreline position (where depth >'+str(shoreline_depth_thresh1)+')') 73 90 pyplot.savefig('Shoreline_position.png') 74 91 75 92 # Can plot velocity as well -- but notice that velocity at the shoreline 76 93 # keeps being set to zero, so the model result is constant zeros 77 # pyplot.plot(p2.time, model_shore_u,'-o') 78 # pyplot.plot(shoreline[:,0], shoreline[:,2],'-',color='red') 94 pyplot.clf() 95 pyplot.plot(p2.time, model_shore_u,'-o') 96 pyplot.plot(shoreline[:,0], shoreline[:,2],'-',color='red') 97 pyplot.title('Shoreline velocity: Peak speed where depth >'\ 98 + str(shoreline_depth_thresh1) + ' and depth < '\ 99 + str(shoreline_depth_thresh2)) 100 pyplot.savefig('Shoreline_velocity.png')
Note: See TracChangeset
for help on using the changeset viewer.