Changeset 8884
- Timestamp:
- Jun 7, 2013, 3:49:59 PM (11 years ago)
- Location:
- trunk/anuga_work/development/gareth
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain.py
r8866 r8884 66 66 self.set_CFL(1.0) 67 67 self.set_use_kinematic_viscosity(False) 68 self.timestepping_method='rk2'#' rk2'#'rk2'#'euler'#'rk2'68 self.timestepping_method='rk2'#'euler'#'rk3'#'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 self.beta_w= 0.076 self.beta_w=1.0 77 77 self.beta_w_dry=0.0 78 self.beta_uh= 0.078 self.beta_uh=1.0 79 79 self.beta_uh_dry=0.0 80 self.beta_vh= 0.080 self.beta_vh=1.0 81 81 self.beta_vh_dry=0.0 82 82 -
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c
r8867 r8884 234 234 // Flux formulas 235 235 flux_left[0] = u_left*h_left; 236 //if(hc>h0){ 236 //if(hc>h0 & hc_n > h0){ 237 //if(w_left>z+h0 & w_right>z+h0){ 237 238 flux_left[1] = u_left*uh_left; //+ 0.5*g*h_left*h_left; 238 239 flux_left[2] = u_left*vh_left; … … 243 244 244 245 flux_right[0] = u_right*h_right; 245 //if( hc_n>h0){246 //if(w_left>z+h0 & w_right>z+h0){ 246 247 flux_right[1] = u_right*uh_right ; //+ 0.5*g*h_right*h_right; 247 248 flux_right[2] = u_right*vh_right; … … 253 254 // Flux computation 254 255 denom = s_max - s_min; 255 //if (denom < -epsilon)256 //if (denom < epsilon) 256 257 if (0==1) 257 258 { … … 275 276 276 277 // Standard smoothing term 277 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]);278 edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]); 278 279 279 280 // Standard smoothing term, scaled … … 282 283 // Adjustment to the scheme by Kurganov and Lin 2007 Communications in Computational 283 284 // Physics 2:141-163 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);285 //uint = (s_max*q_right_rotated[i] - s_min*q_left_rotated[i] - (flux_right[i] - flux_left[i]))*inverse_denominator; 286 //t1 = (q_right_rotated[i] - uint); 287 //t2 = (-q_left_rotated[i] + uint); 288 //t3 = _minmod(t1,t2); 289 //edgeflux[i] += (s_max*s_min)*(q_right_rotated[i] - q_left_rotated[i]-t3); 289 290 290 291 // test this … … 457 458 } 458 459 459 // GD HACK -- although I think this is a common technique460 //If one centroid is dry, then extrapolate its edge values from the neighbouring centroid,461 // unless the local centroid value is smaller462 //if(n>=0){463 // if((hc<=H0)&&(hc_n>H0)){464 // ql[0]=max(min(qr[0],stage_centroid_values[k]),zl);465 // }466 // if((hc_n<=H0)&&(hc>H0)){467 // qr[0]=max(min(ql[0],stage_centroid_values[n]),zr);468 // }469 470 //}else{471 // // Treat the boundary case472 // // ??473 //}474 460 475 461 smooth=1.0; … … 500 486 // bedslope_work contains all gravity related terms -- weighting of 501 487 // conservative and non-conservative versions. 488 489 if(ql[0]>zl){ 490 tmp=1.0; 491 }else{ 492 tmp=1.; 493 } 502 494 if(hc> h0){ 503 495 //if(stage_centroid_values[k] > count_wet_edges[k]){ 504 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux);496 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl))*tmp + pressure_flux); 505 497 //bedslope_work = length*(g*(hc*stage_centroid_values[k]*0.- 506 498 // 0.5*max(stage_centroid_values[k]-zl,0.)*(stage_centroid_values[k]-zl)) … … 509 501 pressuregrad_store[ki] = bedslope_work; 510 502 }else{ 511 // NOTE: When hc<h0, pressure_flux is entirely computed from the512 // other side of the edge. Hence, we can't necessarily satisfy513 // well-balancing by just assuming that the 2nd and 3rd terms in514 // bedslope_work cancel. So, we force it here -- equivalent to515 // using the water surface gravity term516 bedslope_work = length*(g*(hc*ql[0] -0.0*max(ql[0]-zl,0.)*(ql[0]-zl))+ 0.0*pressure_flux);503 // NOTE: When hc<h0, local contribution to the pressure_flux is 504 // entirely computed from the other side of the edge. Hence, we 505 // can't necessarily satisfy well-balancing by just assuming that 506 // the 2nd and 3rd terms in bedslope_work cancel. So, we force it 507 // here -- equivalent to using the water surface gravity term 508 bedslope_work = length*(g*(hc*ql[0]*tmp-0.0*max(ql[0]-zl,0.)*(ql[0]-zl))*tmp + 0.0*pressure_flux); 517 509 //bedslope_work = length*(g*(hc*stage_centroid_values[k]-0.0*max(ql[0]-zl,0.)*(ql[0]-zl)) + 0.0*pressure_flux); 518 510 //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope … … 532 524 edgeflux_store[nm3 + 2 ] = edgeflux[2]; 533 525 526 if(qr[0]>zr){ 527 tmp=1.0; 528 }else{ 529 tmp=1.; 530 } 534 531 if(hc_n> h0){ 535 532 //if(stage_centroid_values[n] > count_wet_edges[n]){ 536 bedslope_work = length*(g*(hc_n*qr[0] -0.5*max(qr[0]-zr,0.)*(qr[0]-zr))+ pressure_flux);533 bedslope_work = length*(g*(hc_n*qr[0]*tmp-0.5*max(qr[0]-zr,0.)*(qr[0]-zr))*tmp + pressure_flux); 537 534 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]*0.-0.5*max(stage_centroid_values[n]-zr,0.)* 538 535 // (stage_centroid_values[n]-zr)) + pressure_flux); … … 545 542 // bedslope_work cancel. So, we force it here -- equivalent to 546 543 // using the water surface gravity term 547 bedslope_work = length*(g*(hc_n*qr[0] -0.0*max(qr[0]-zr,0.)*(qr[0]-zr))+ 0.0*pressure_flux);544 bedslope_work = length*(g*(hc_n*qr[0]*tmp-0.0*max(qr[0]-zr,0.)*(qr[0]-zr))*tmp + 0.0*pressure_flux); 548 545 //bedslope_work = length*(g*(hc_n*stage_centroid_values[n]-0.0*max(qr[0]-zr,0.)*(qr[0]-zr)) + 0.0*pressure_flux); 549 546 //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; … … 778 775 // distance between the bed_centroid_value and the max bed_edge_value of 779 776 // every triangle. 780 double minimum_relative_height=0. 1;777 double minimum_relative_height=0.05; 781 778 int mass_added=0; 782 779 … … 786 783 hc = wc[k] - zc[k]; 787 784 // Definine the maximum bed edge value on triangle 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]))); 785 //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]))); 786 bmax = max(zv[3*k],max(zv[3*k+2],zv[3*k+1])); 789 787 790 788 //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) { … … 796 794 //if (hc < minimum_allowed_height*2.0 | hc < minimum_relative_height*(bmax-zc[k]) ){ 797 795 if (hc < minimum_allowed_height*2.0 ){ 796 //if (hc < minimum_allowed_height*2.0 ){ 798 797 // Set momentum to zero and ensure h is non negative 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;798 //xmomc[k] = 0.;//xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 799 //ymomc[k] = 0.;//ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 801 800 //xmomc[k] = xmomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; 802 801 //ymomc[k] = ymomc[k]*hc*max(hc-minimum_allowed_height,0.)/(2.0*minimum_allowed_height*minimum_allowed_height);// 0.0; … … 809 808 //bmin =0.5*bmin + 0.5*min(zv[3*k],min(zv[3*k+1],zv[3*k+2])); 810 809 //bmin =min(zv[3*k],min(zv[3*k+1],zv[3*k+2])) -minimum_allowed_height; 811 bmin=zc[k] ;//-1.0e-03;810 bmin=zc[k]-minimum_allowed_height;//-1.0e-03; 812 811 // Minimum allowed stage = bmin 813 812 … … 1006 1005 } 1007 1006 1007 1008 // Alternative 'PROTECT' step 1009 for(k=0; k<number_of_elements;k++){ 1010 if(count_wet_neighbours[k]<=3){ 1011 bedmax = max(elevation_centroid_values[k], 1012 max(elevation_vertex_values[3*k], 1013 max(elevation_vertex_values[3*k+1], 1014 elevation_vertex_values[3*k+2]))); 1015 if(cell_wetness_scale[k]==0. || 1016 stage_centroid_values[k] - elevation_centroid_values[k] < 0.05*(bedmax-elevation_centroid_values[k])){ 1017 xmom_centroid_store[k]=0.; 1018 xmom_centroid_values[k]=0.; 1019 ymom_centroid_store[k]=0.; 1020 ymom_centroid_values[k]=0.; 1021 } 1022 } 1023 } 1008 1024 1009 1025 // First treat all 'fully wet' cells, then treat 'partially dry' cells … … 1128 1144 max(elevation_centroid_values[k1], 1129 1145 elevation_centroid_values[k2]))); 1130 bedmin = min(elevation_centroid_values[k],1131 min(elevation_centroid_values[k0],1132 min(elevation_centroid_values[k1],1133 elevation_centroid_values[k2])));1134 //stagemin = min(max(stage_centroid_values[k], elevation_centroid_values[k]),1135 //min(max(stage_centroid_values[k0], elevation_centroid_values[k0]),1136 //min(max(stage_centroid_values[k1], elevation_centroid_values[k1]),1137 //max(stage_centroid_values[k2], elevation_centroid_values[k2]))));1146 //bedmin = min(elevation_centroid_values[k], 1147 // min(elevation_centroid_values[k0], 1148 // min(elevation_centroid_values[k1], 1149 // elevation_centroid_values[k2]))); 1150 stagemin = min(max(stage_centroid_values[k], elevation_centroid_values[k]), 1151 min(max(stage_centroid_values[k0], elevation_centroid_values[k0]), 1152 min(max(stage_centroid_values[k1], elevation_centroid_values[k1]), 1153 max(stage_centroid_values[k2], elevation_centroid_values[k2])))); 1138 1154 1139 1155 // Get the auxiliary triangle's vertex coordinates … … 1163 1179 1164 1180 //// Treat triangles with zero or 1 wet neighbours (area2 <=0.) 1165 if ((area2 <= 0.) )// || (cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0))1181 if ((area2 <= 0.) )// || (cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0)) 1166 1182 { 1167 1183 … … 1217 1233 1218 1234 //} 1219 //if( (k==k0) & (k==k1) & (k==k2)){1235 if( (k==k0) & (k==k1) & (k==k2)){ 1220 1236 // // Isolated wet cell -- use constant depth extrapolation for stage 1221 1237 // stage_edge_values[k3] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3]; … … 1228 1244 // //stage_edge_values[k3+2] = min(stage_centroid_values[k], stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+2]); 1229 1245 // // Isolated wet cell -- constant stage extrapolation 1230 //stage_edge_values[k3] = stage_centroid_values[k];1231 //stage_edge_values[k3+1] = stage_centroid_values[k];1232 //stage_edge_values[k3+2] = stage_centroid_values[k];1233 //}else{1246 stage_edge_values[k3] = stage_centroid_values[k]; 1247 stage_edge_values[k3+1] = stage_centroid_values[k]; 1248 stage_edge_values[k3+2] = stage_centroid_values[k]; 1249 }else{ 1234 1250 // // Cell with one wet neighbour. 1235 1251 // // Find which neighbour is wet [if k!=k0, then k0 is wet] 1236 //if(k!=k0){1237 //ktmp=k0;1238 //ii=0;1239 //xtmp = x0;1240 //ytmp = y0;1241 //}else if(k!=k1){1242 //ktmp=k1;1243 //ii=1;1244 //xtmp = x1;1245 //ytmp = y1;1246 //}else if(k!=k2){1247 //ktmp=k2;1248 //ii=2;1249 //xtmp = x2;1250 //ytmp = y2;1251 //}else{1252 //printf("ERROR in extrapolation routine: Should have had one ki == k \n");1253 //report_python_error(AT, "Negative triangle area");1254 //return -1;1255 //}1252 if(k!=k0){ 1253 ktmp=k0; 1254 ii=0; 1255 xtmp = x0; 1256 ytmp = y0; 1257 }else if(k!=k1){ 1258 ktmp=k1; 1259 ii=1; 1260 xtmp = x1; 1261 ytmp = y1; 1262 }else if(k!=k2){ 1263 ktmp=k2; 1264 ii=2; 1265 xtmp = x2; 1266 ytmp = y2; 1267 }else{ 1268 printf("ERROR in extrapolation routine: Should have had one ki == k \n"); 1269 report_python_error(AT, "Negative triangle area"); 1270 return -1; 1271 } 1256 1272 1257 1273 // //if(stage_centroid_values[k]>elevation_centroid_values[k]+minimum_allowed_height){ … … 1275 1291 // // stage_edge_values[k3+1] = stage_centroid_values[ktmp]; 1276 1292 // // stage_edge_values[k3+2] = stage_centroid_values[ktmp]; 1277 // // //stage_edge_values[k3]= max(stage_centroid_values[k]-elevation_centroid_values[k]+elevation_edge_values[k3], stage_centroid_values[ktmp]);1278 // // //stage_edge_values[k3+1]= max(stage_centroid_values[k] -elevation_centroid_values[k]+elevation_edge_values[k3+1],stage_centroid_values[ktmp]);1279 // // //stage_edge_values[k3+2]= max(stage_centroid_values[k] -elevation_centroid_values[k]+elevation_edge_values[k3+2], stage_centroid_values[ktmp]);1293 stage_edge_values[k3]= max(stage_centroid_values[k]-elevation_centroid_values[k]+elevation_edge_values[k3], stage_centroid_values[ktmp]); 1294 stage_edge_values[k3+1]= max(stage_centroid_values[k] -elevation_centroid_values[k]+elevation_edge_values[k3+1],stage_centroid_values[ktmp]); 1295 stage_edge_values[k3+2]= max(stage_centroid_values[k] -elevation_centroid_values[k]+elevation_edge_values[k3+2], stage_centroid_values[ktmp]); 1280 1296 // //} 1281 1297 … … 1297 1313 // } 1298 1314 // 1299 //}1315 } 1300 1316 // First order momentum / velocity extrapolation 1301 stage_edge_values[k3] = stage_centroid_values[k]; 1302 stage_edge_values[k3+1] = stage_centroid_values[k]; 1303 stage_edge_values[k3+2] = stage_centroid_values[k]; 1317 //if(stagemin>=bedmax){ 1318 // stage_edge_values[k3] = stage_centroid_values[k]; 1319 // stage_edge_values[k3+1] = stage_centroid_values[k]; 1320 // stage_edge_values[k3+2] = stage_centroid_values[k]; 1321 //}else{ 1322 // stage_edge_values[k3]= stage_centroid_values[k]-elevation_centroid_values[k]+elevation_edge_values[k3]; 1323 // stage_edge_values[k3+1]= stage_centroid_values[k] -elevation_centroid_values[k]+elevation_edge_values[k3+1]; 1324 // stage_edge_values[k3+2]= stage_centroid_values[k] -elevation_centroid_values[k]+elevation_edge_values[k3+2]; 1325 //} 1304 1326 xmom_edge_values[k3] = xmom_centroid_values[k]; 1305 1327 xmom_edge_values[k3+1] = xmom_centroid_values[k]; … … 1327 1349 //hfactor=hmin/(hmin + 0.004); 1328 1350 //} 1329 hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height*2.)), 1.0);1330 1351 //hfactor= min(2.0*max(hmin,0.0)/max(hc,max(0.5*(bedmax-bedmin),minimum_allowed_height)), 1.0); 1352 hfactor= min(2.0*max(hmin,0.0)/max(hc,minimum_allowed_height*0.1), 1.0); 1331 1353 1332 1354 //----------------------------------- … … 1392 1414 //if( (area2>0) ){ 1393 1415 //if(count_wet_neighbours[k]>0){ 1394 limit_gradient(dqv, qmin, qmax, beta_tmp); 1416 //if(bedmax<=stagemin){ 1417 limit_gradient(dqv, qmin, qmax, beta_tmp); 1418 //}else{ 1419 // dqv[0]=-elevation_centroid_values[k] + elevation_edge_values[k3+0]; 1420 // dqv[1]=-elevation_centroid_values[k] + elevation_edge_values[k3+1]; 1421 // dqv[2]=-elevation_centroid_values[k] + elevation_edge_values[k3+2]; 1422 //} 1395 1423 //printf("%lf \n ", beta_tmp); 1396 1424 //} … … 1488 1516 // (cell_wetness_scale[k]==1.0)){ 1489 1517 //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){ 1518 1490 1519 limit_gradient(dqv, qmin, qmax, beta_tmp); 1491 1520 //}else{ -
trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py
r8880 r8884 14 14 #from swb2_domain import * 15 15 #from balanced_basic import * 16 #from balanced_dev import *16 from balanced_dev import * 17 17 #from anuga_tsunami import * 18 18 … … 22 22 points, vertices, boundary = anuga.rectangular_cross(20,20, len1=1., len2=1.) 23 23 24 domain= anuga.Domain(points,vertices,boundary) # Create Domain24 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 domain.set_flow_algorithm('tsunami')27 #domain.set_flow_algorithm('tsunami') 28 28 #------------------ 29 29 # Define topography … … 32 32 #### Pathological 33 33 #scale_me=100.0 34 #boundary_ws=-0.2 34 #boundary_ws=-0.2#1999 35 35 #init_ws=-0.2 36 36 #bumpiness=50. # Higher = shorter wavelength oscillations in topography 37 #tstep=0. 00238 #lasttime= 1.137 #tstep=0.2 38 #lasttime=20.1 39 39 40 40 ### Sensible … … 60 60 domain.set_quantity('friction',0.00) # Constant friction 61 61 62 print '#-#', domain.minimum_allowed_height 62 63 #def frict_change(x,y): 63 64 # return 0.2*(x>0.5)+0.1*(x<=0.5) -
trunk/anuga_work/development/gareth/tests/shallow_steep_slope/channel_SU_sparse.py
r8865 r8884 43 43 return stg#*(stg>topo) + topo*(stg<=topo) 44 44 45 line1=[ [ 10.,0.], [10., 100.] ]46 Qin=2 0.45 line1=[ [9.,0.], [9., 100.] ] 46 Qin=2. 47 47 Inlet_operator(domain, line1,Qin) 48 48
Note: See TracChangeset
for help on using the changeset viewer.