Changeset 8866
- Timestamp:
- May 13, 2013, 5:09:25 PM (12 years ago)
- Location:
- trunk/anuga_work/development/gareth
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain.py
r8865 r8866 66 66 self.set_CFL(1.0) 67 67 self.set_use_kinematic_viscosity(False) 68 self.timestepping_method='rk2'#'rk2'#' euler'#'rk2'68 self.timestepping_method='rk2'#'rk2'#'rk2'#'euler'#'rk2' 69 69 # The following allows storage of the negative depths associated with this method 70 70 self.minimum_storable_height=-99999999999.0 … … 74 74 self.extrapolate_velocity_second_order=True 75 75 76 # Note that the extrapolation method used in quantity_ext.c (e.g.77 # extrapolate_second_order_and_limit_by_edge) uses a constant value for78 # all the betas.79 76 self.beta_w=0.0 80 77 self.beta_w_dry=0.0 … … 83 80 self.beta_vh=0.0 84 81 self.beta_vh_dry=0.0 82 83 #self.epsilon=1.0e-100 85 84 86 85 #self.optimise_dry_cells=True … … 111 110 self.boundary_flux_sum=numpy.ndarray(1) 112 111 self.boundary_flux_sum[0]=0. 112 113 self.call=1 # Integer counting how many times we call compute_fluxes_central 114 115 # Integer recording the order of the time-stepping scheme 116 if(self.timestepping_method=='rk2'): 117 self.timestep_order=2 118 elif(self.timestepping_method=='euler'): 119 self.timestep_order=1 120 elif(self.timestepping_method=='rk3'): 121 self.timestep_order=3 122 else: 123 err_mess='ERROR: timestepping_method= ' + self.timestepping_method +' not supported in this solver' 124 raise Exception, err_mess 113 125 114 126 print '##########################################################################' … … 252 264 # raise Exception, err_mess 253 265 254 if(domain.timestepping_method=='rk2'):255 timestep_order=2256 elif(domain.timestepping_method=='euler'):257 timestep_order=1266 #if(domain.timestepping_method=='rk2'): 267 # timestep_order=2 268 #elif(domain.timestepping_method=='euler'): 269 # timestep_order=1 258 270 #elif(domain.timestepping_method=='rk3'): 259 271 # timestep_order=3 260 else:261 err_mess='ERROR: domain.timestepping_method= ' + domain.timestepping_method +' not supported in this solver'262 raise Exception, err_mess263 264 # print 'timestep_order=', timestep_order272 #else: 273 # err_mess='ERROR: domain.timestepping_method= ' + domain.timestepping_method +' not supported in this solver' 274 # raise Exception, err_mess 275 276 ##print 'timestep_order=', timestep_order 265 277 266 278 Stage = domain.quantities['stage'] … … 271 283 timestep = float(sys.maxint) 272 284 285 domain.call+=1 273 286 flux_timestep = compute_fluxes_ext(timestep, 274 287 domain.epsilon, … … 297 310 domain.max_speed, 298 311 int(domain.optimise_dry_cells), 299 timestep_order,312 domain.timestep_order, 300 313 Stage.centroid_values, 301 314 Xmom.centroid_values, … … 304 317 Bed.vertex_values) 305 318 306 #import pdb 307 #pdb.set_trace() 308 #print 'flux timestep: ', flux_timestep, domain.timestep 319 320 # Update the boundary flux integral 309 321 if(domain.timestepping_method=='rk2'): 310 if(flux_timestep == float(sys.maxint)):322 if(domain.call%2==1): 311 323 domain.boundary_flux_integral[0]= domain.boundary_flux_integral[0] +\ 312 324 domain.boundary_flux_sum[0]*domain.timestep*0.5 313 325 #print 'dbfi ', domain.boundary_flux_integral, domain.boundary_flux_sum 314 326 domain.boundary_flux_sum[0]=0. 327 328 elif(domain.timestepping_method=='euler'): 329 domain.boundary_flux_integral=0. 330 # This presently doesn't work -- this section of code may need to go elsewhere 331 #domain.boundary_flux_integral[0]= domain.boundary_flux_integral[0] +\ 332 # domain.boundary_flux_sum[0]*domain.timestep 333 #domain.boundary_flux_sum[0]=0. 334 335 elif(domain.timestepping_method=='rk3'): 336 domain.boundary_flux_integral=0. 337 # This needs to be designed 338 else: 339 mess='ERROR: domain.timestepping_method', domain.timestepping_method,' method not recognised' 340 raise Exception, mess 315 341 316 342 domain.flux_timestep = flux_timestep -
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c
r8865 r8866 85 85 } 86 86 87 // minmod limiter 88 int _minmod(double a, double b){ 89 // Compute minmod 90 91 if(sign(a)!=sign(b)){ 92 return 0.0; 93 }else{ 94 return min(fabs(a), fabs(b))*sign(a); 95 } 96 97 98 } 99 87 100 // Innermost flux function (using stage w=z+h) 88 101 int _flux_function_central(double *q_left, double *q_right, … … 116 129 double s_min, s_max, soundspeed_left, soundspeed_right; 117 130 double denom, inverse_denominator, z; 118 double uint, t1, t2, t3 ;131 double uint, t1, t2, t3, min_speed; 119 132 // Workspace (allocate once, use many) 120 133 static double q_left_rotated[3], q_right_rotated[3], flux_right[3], flux_left[3]; … … 145 158 if(h_left>h0){ 146 159 u_left = uh_left/max(h_left, 1.0e-06); 160 uh_left=h_left*u_left; 147 161 }else{ 148 162 u_left=0.; 163 uh_left=h_left*u_left; 149 164 } 150 165 //u_left = _compute_speed(&uh_left, &h_left, … … 158 173 if(h_right>h0){ 159 174 u_right = uh_right/max(h_right, 1.0e-06); 175 uh_right=h_right*u_right; 160 176 }else{ 161 177 u_right=0.; 178 uh_right=h_right*u_right; 162 179 } 163 180 … … 236 253 // Flux computation 237 254 denom = s_max - s_min; 238 if (denom < epsilon) 255 //if (denom < -epsilon) 256 if (0==1) 239 257 { 240 258 // Both wave speeds are very small … … 242 260 243 261 *max_speed = 0.0; 244 *pressure_flux = 0.0;245 //*pressure_flux = 0.5*g*0.5*(h_left*h_left+h_right*h_right);262 //*pressure_flux = 0.0; 263 *pressure_flux = 0.5*g*0.5*(h_left*h_left+h_right*h_right); 246 264 } 247 265 else … … 249 267 // Maximal wavespeed 250 268 *max_speed = max(s_max, -s_min); 251 252 inverse_denominator = 1.0/denom; 269 //min_speed=min(s_max, -s_min); 270 271 inverse_denominator = 1.0/max(denom,1.0e-100); 253 272 for (i = 0; i < 3; i++) 254 273 { 255 274 edgeflux[i] = s_max*flux_left[i] - s_min*flux_right[i]; 275 256 276 // Standard smoothing term 257 277 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]); 278 279 // Adjustment to the scheme by Kurganov and Lin 2007 Communications in Computational 280 // 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); 286 258 287 //GD HACK: Here, we supress the 'smoothing' part of the flux -- like scaling diffusion by local wave speed 288 //if(i!=2){ 259 289 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))); 290 (min(*max_speed/(max(speed_max_last,1.0e-100)),1.0));//(min(hc/h_left,min(hc_n/h_right,1.0))); 291 //} 292 261 293 edgeflux[i] *= inverse_denominator; 262 294 } … … 449 481 // bedslope_work contains all gravity related terms -- weighting of 450 482 // conservative and non-conservative versions. 451 if(hc> -h0){483 if(hc> h0){ 452 484 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 453 485 //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); … … 471 503 edgeflux_store[nm3 + 2 ] = edgeflux[2]; 472 504 473 if(hc_n> -h0){505 if(hc_n> h0){ 474 506 bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 475 507 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); … … 493 525 if ((tri_full_flag[k] == 1) ) { 494 526 495 if( call%timestep_order!=0) max_speed = max_speed_array[k]; // HACK to Ensure that local timestep is the same as the last timestep527 if((call-2)%timestep_order!=0) max_speed = max_speed_array[k]; // HACK to Ensure that local timestep is the same as the last timestep 496 528 497 529 if (max_speed > epsilon) { … … 585 617 // GD HACK 586 618 // Option to limit advective fluxes 587 if(hc > h0){619 if(hc > -h0){ 588 620 stage_explicit_update[k] += edgeflux_store[ki3+0]; 589 621 // Cut these terms for shallow flows, and protect stationary states from round-off error … … 598 630 if(n<0){ 599 631 boundary_flux_sum[0] += edgeflux_store[ki3]; 600 //printf("%f, %f, %d \n", boundary_flux_sum[0], timestep, ki3);601 632 } 602 633 603 634 // GD HACK 604 635 // Compute bed slope term 605 if(hc > h0){636 if(hc > -h0){ 606 637 xmom_explicit_update[k] -= normals[ki2]*pressuregrad_store[ki]; 607 638 ymom_explicit_update[k] -= normals[ki2+1]*pressuregrad_store[ki]; … … 621 652 } // end cell k 622 653 623 if( call%timestep_order==0) timestep=local_timestep;654 if((call-2)%timestep_order==0) timestep=local_timestep; // Hack to ensure we only update the timestep on the first call within each rk2/rk3 step 624 655 625 656 // Look for 'dry' edges, and set momentum (& component of momentum_update) … … 729 760 //xmomc[k] = 0.;//xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 730 761 //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; 762 //xmomc[k] = xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 763 //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; 733 766 734 767 if (hc <= 0.0){ … … 805 838 // Any provisional jump with magnitude < TINY does not contribute to 806 839 // the limiting process. 840 //return 0; 807 841 808 842 for (i=0;i<3;i++){ … … 821 855 dqv[1]=dqv[1]*phi; 822 856 dqv[2]=dqv[2]*phi; 857 858 859 //printf("%lf \n ", beta_w); 823 860 824 861 return 0; … … 1120 1157 }else{ 1121 1158 // Constant stage extrapolation 1122 stage_edge_values[k3] = stage_centroid_values[k];1123 stage_edge_values[k3+1] = stage_centroid_values[k];1124 stage_edge_values[k3+2] = stage_centroid_values[k];1159 //stage_edge_values[k3] = stage_centroid_values[k]; 1160 //stage_edge_values[k3+1] = stage_centroid_values[k]; 1161 //stage_edge_values[k3+2] = stage_centroid_values[k]; 1125 1162 } 1126 1163 //}else{ … … 1223 1260 //} 1224 1261 // First order momentum / velocity extrapolation 1225 //stage_edge_values[k3] = stage_centroid_values[k];1226 //stage_edge_values[k3+1] = stage_centroid_values[k];1227 //stage_edge_values[k3+2] = stage_centroid_values[k];1262 stage_edge_values[k3] = stage_centroid_values[k]; 1263 stage_edge_values[k3+1] = stage_centroid_values[k]; 1264 stage_edge_values[k3+2] = stage_centroid_values[k]; 1228 1265 xmom_edge_values[k3] = xmom_centroid_values[k]; 1229 1266 xmom_edge_values[k3+1] = xmom_centroid_values[k]; … … 1251 1288 //hfactor=hmin/(hmin + 0.004); 1252 1289 //} 1253 hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height* 10.)), 1.0);1290 hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height*2.)), 1.0); 1254 1291 //hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height)), 1.0); 1255 1292 … … 1317 1354 //if(count_wet_neighbours[k]>0){ 1318 1355 limit_gradient(dqv, qmin, qmax, beta_tmp); 1356 //printf("%lf \n ", beta_tmp); 1319 1357 //} 1320 1358 //} -
trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py
r8865 r8866 94 94 print 'Peak velocity is: ', vv.max(), vv.argmax(), dd[vv.argmax()] 95 95 print 'Volume is', sum(dd_raw*domain.areas) 96 #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 97 97 98 98
Note: See TracChangeset
for help on using the changeset viewer.