- Timestamp:
- May 13, 2013, 5:09:25 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 //}
Note: See TracChangeset
for help on using the changeset viewer.