Changeset 8751
- Timestamp:
- Mar 11, 2013, 8:17:49 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_validation_tests/utilities/fabricate.py
- Property svn:executable deleted
-
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain.py
r8547 r8751 63 63 # Most of these override the options in config.py 64 64 #------------------------------------------------ 65 self.set_CFL(1.0 )65 self.set_CFL(1.00) 66 66 self.set_use_kinematic_viscosity(False) 67 self.timestepping_method='rk2' 67 self.timestepping_method='rk2' #'euler'#'rk2'#'euler'#'rk2' 68 68 # The following allows storage of the negative depths associated with this method 69 69 self.minimum_storable_height=-99999999999.0 … … 235 235 236 236 # Shortcuts 237 if(domain.timestepping_method!='rk2'): 238 err_mess='ERROR: Timestepping method is ' + domain.timestepping_method +'. '+\ 239 'You need to use rk2 timestepping with this solver, ' +\ 240 ' because there is presently a hack in compute fluxes central. \n'+\ 241 ' The HACK: The timestep will only ' +\ 242 'be recomputed on every 2nd call to compute_fluxes_central, to support'+\ 243 ' correct treatment of wetting and drying' 244 245 raise Exception, err_mess 246 237 247 Stage = domain.quantities['stage'] 238 248 Xmom = domain.quantities['xmomentum'] … … 268 278 int(domain.optimise_dry_cells), 269 279 Stage.centroid_values, 280 Xmom.centroid_values, 281 Ymom.centroid_values, 270 282 Bed.centroid_values, 271 283 Bed.vertex_values) -
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c
r8549 r8751 206 206 denom = s_max - s_min; 207 207 if (denom < epsilon) 208 { // FIXME (Ole): Try using h0 here 208 { 209 // Both wave speeds are very small 209 210 memset(edgeflux, 0, 3*sizeof(double)); 210 211 … … 263 264 int optimise_dry_cells, 264 265 double* stage_centroid_values, 266 double* xmom_centroid_values, 267 double* ymom_centroid_values, 265 268 double* bed_centroid_values, 266 269 double* bed_vertex_values) { … … 273 276 // See ANUGA manual under flux limiting 274 277 int k, i, m, n,j; 275 int ki, nm = 0, ki2 ; // Index shorthands278 int ki, nm = 0, ki2,ki3, nm3; // Index shorthands 276 279 277 280 // Workspace (making them static actually made function slightly slower (Ole)) … … 281 284 int neighbours_wet[3];//Work array 282 285 int useint; 283 double stage_edge_lim, scale_factor_shallow, bedtop, bedbot, pressure_flux, hc, hc_n, tmp; 284 //double max_bed_edgevalue[number_of_elements]; // FIXME: Set memory explicitly 286 double stage_edge_lim, outgoing_flux_edges, bedtop, bedbot, pressure_flux, hc, hc_n, tmp, tmp2; 285 287 static long call = 1; // Static local variable flagging already computed flux 286 288 287 double *max_bed_edgevalue, *min_bed_edgevalue ;289 double *max_bed_edgevalue, *min_bed_edgevalue, *edgeflux_store, *pressuregrad_store; 288 290 289 291 max_bed_edgevalue = malloc(number_of_elements*sizeof(double)); 290 //min_bed_edgevalue = malloc(number_of_elements*sizeof(double)); 291 // Start computation 292 edgeflux_store = malloc(number_of_elements*9*sizeof(double)); 293 pressuregrad_store = malloc(number_of_elements*3*sizeof(double)); 294 292 295 call++; // Flag 'id' of flux calculation for this timestep 293 296 … … 298 301 memset((char*) ymom_explicit_update, 0, number_of_elements * sizeof (double)); 299 302 300 301 303 // Compute minimum bed edge value on each triangle 302 304 for (k = 0; k < number_of_elements; k++){ 303 305 max_bed_edgevalue[k] = max(bed_edge_values[3*k], 304 306 max(bed_edge_values[3*k+1], bed_edge_values[3*k+2])); 305 //max_bed_edgevalue[k]= 0.5*(max_bed_edgevalue[j]+bed_centroid_values[k]);306 //min_bed_edgevalue[k] = min(bed_edge_values[3*k],307 // min(bed_edge_values[3*k+1], bed_edge_values[3*k+2]));308 309 307 } 310 308 … … 315 313 for (i = 0; i < 3; i++) { 316 314 ki = k * 3 + i; // Linear index to edge i of triangle k 315 ki2 = 2 * ki; //k*6 + i*2 316 ki3 = 3*ki; 317 317 318 318 if (already_computed_flux[ki] == call) { … … 328 328 hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.0); 329 329 330 //if(ql[0]<=zl){331 // ql[1]=0.;332 // ql[2]=0.;333 //}334 330 // Get right hand side values either from neighbouring triangle 335 331 // or from boundary array (Quantities at neighbour on nearest face). … … 350 346 m = neighbour_edges[ki]; 351 347 nm = n * 3 + m; // Linear index (triangle n, edge m) 348 nm3 = nm*3; 352 349 353 350 qr[0] = stage_edge_values[nm]; … … 357 354 } 358 355 359 360 356 if (fabs(zl-zr)>1.0e-10) { 361 357 report_python_error(AT,"Discontinuous Elevation"); 362 358 return 0.0; 363 359 } 364 360 361 // GD HACK -- although I think this is a common technique 365 362 //If one centroid is dry, then extrapolate its edge values from the neighbouring centroid, 366 363 // unless the local centroid value is smaller 367 364 if(n>=0){ 368 //if(hc==0.0){369 365 if((hc<=H0)&&(hc_n>H0)){ 370 366 ql[0]=max(min(qr[0],stage_centroid_values[k]),zl); 371 //ql[0]=max(min(qr[0],0.5*(stage_centroid_values[k]+stage_centroid_values[n])),zl);372 //ql[0]=max(min(qr[0],stage_centroid_values[k]),zl);373 367 } 374 //if(hc_n==0.0){375 368 if((hc_n<=H0)&&(hc>H0)){ 376 369 qr[0]=max(min(ql[0],stage_centroid_values[n]),zr); 377 //qr[0]=max(min(ql[0],0.5*(stage_centroid_values[n]+stage_centroid_values[k])),zr);378 //qr[0]=ql[0];379 370 } 380 381 //if((hc_n<=H0)&&(hc<=H0)){382 // ql[0] = zl;383 // qr[0] = zr;384 //}385 371 386 372 }else{ 387 373 // Treat the boundary case 388 //if((hc==0.0)){ 389 // ql[0]=max(min(qr[0],stage_centroid_values[k]),zl); 390 // //ql[0]=max(min(qr[0],ql[0]),zl); 391 //} 374 // ?? 392 375 } 393 //if(k==229 | n==229){394 // printf(" ---------------\n ");395 // printf("k, ql, qr, zl, zr==%d, %20.20e, %20.20e, %20.20e, %20.20e \n", k, ql[0], qr[0], zl, zr);396 397 //}398 399 // Outward pointing normal vector (domain.normals[k, 2*i:2*i+2])400 ki2 = 2 * ki; //k*6 + i*2401 376 402 377 // Edge flux computation (triangle k, edge i) … … 406 381 edgeflux, &max_speed, &pressure_flux); 407 382 408 // Prevent outflow from 'seriously' dry cells409 // Idea: The cell will not go dry if:410 // mass_flux = edgeflux[0]*(dt*edgelength) <= (1/3)Area_triangle*hc411 if((stage_centroid_values[k]<=max_bed_edgevalue[k])|412 (ql[0]<=zl)){413 if(edgeflux[0]>0.0){414 tmp=min((1.0/3.0)*areas[k]*hc/(edgelengths[ki]*max(timestep,epsilon)), 1.0); // 28/7 -- Right answer for channel flow problem.415 tmp = min(min(edgeflux[0], tmp)/edgeflux[0], 1.0);416 if((tmp<0.)|tmp>1.0){417 printf("Invalid tmp value\n");418 }419 edgeflux[0]*=tmp;420 edgeflux[1]*=tmp;421 edgeflux[2]*=tmp;422 }423 }424 if(n>=0){425 if((stage_centroid_values[n]<=max_bed_edgevalue[n])|426 (qr[0]<=zr)){427 if(edgeflux[0]<0.0){428 tmp=min((1.0/3.0)*areas[n]*hc_n/(edgelengths[ki]*max(timestep,epsilon)), 1.0); // 28/7 -- Right answer for channel flow problem.429 tmp = min( max(edgeflux[0], -tmp)/edgeflux[0], 1.0);430 if((tmp<0.)|tmp>1.0){431 printf("Invalid tmp value\n");432 }433 edgeflux[0]*=tmp;434 edgeflux[1]*=tmp;435 edgeflux[2]*=tmp;436 }437 }438 }439 383 440 //if(k==229|n==229){441 // printf("++edgeflux=, %20.20e, %20.20e, %20.20e \n", edgeflux[0],edgeflux[1], edgeflux[2]);442 //}443 444 384 // Multiply edgeflux by edgelength 445 385 length = edgelengths[ki]; … … 448 388 edgeflux[2] *= length; 449 389 390 edgeflux_store[ki3 + 0 ] = -edgeflux[0]; 391 edgeflux_store[ki3 + 1 ] = -edgeflux[1]; 392 edgeflux_store[ki3 + 2 ] = -edgeflux[2]; 450 393 451 394 // Update triangle k with flux from edge i 452 stage_explicit_update[k] -= edgeflux[0]; 453 xmom_explicit_update[k] -= edgeflux[1]; 454 ymom_explicit_update[k] -= edgeflux[2]; 455 456 // Compute bed slope term 457 //if(hc>-9999.0){ 458 //Bedslope approx 1: 459 if(hc>H0){ 460 // Add the pressure gradient flux term back in 461 // Do this to avoid the above mass-conservative limiting 462 // Because limiting the pressure term would destroy balancing with the bedslope term 463 //edgeflux[1]+=normals[ki2]*pressure_flux; 464 //edgeflux[2]+=normals[ki2+1]*pressure_flux; 465 466 //bedslope_work = -0.5*g*max(stage_centroid_values[k]-zl,0.)*(stage_centroid_values[k]-zl)*length; 467 bedslope_work = length*g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux*length; 468 xmom_explicit_update[k] -= normals[ki2]*bedslope_work; 469 ymom_explicit_update[k] -= normals[ki2+1]*bedslope_work; 470 }else{ 471 //bedslope_work = 0.;//-pressure_flux*length ;//g*length*( 0.*(ql[0])-0.5*max(ql[0]-zl,0.)*(ql[0]-zl) ); 472 xmom_explicit_update[k] *= 0.; 473 ymom_explicit_update[k] *= 0.; 474 } 395 396 // bedslope_work contains all gravity related terms -- weighting of 397 // conservative and non-conservative versions. 398 bedslope_work = length*(g*(hc*ql[0]-0.5*max(ql[0]-zl,0.)*(ql[0]-zl)) + pressure_flux); 399 //bedslope_work+= (1.0-tmp)*length*g*hc*ql[0]; // Non-conservative water surface slope 400 pressuregrad_store[ki] = bedslope_work; 401 475 402 476 //if(k==229|n==229){477 // printf("--k-pres, xmom, bedwrk, %20.20e, %20.20e, %20.20e \n", pressure_flux*length, xmom_explicit_update[k], bedslope_work);478 //// printf(" Edgesum: %20.20e\n", edgelengths[3*k]*normals[6*k]*g*hc*stage_edge_values[3*k]479 //// + edgelengths[3*k+1]*normals[6*k+2]*g*hc*stage_edge_values[3*k+1]480 //// + edgelengths[3*k+2]*normals[6*k+4]*g*hc*stage_edge_values[3*k+2]);481 //}482 //483 // Bedslope approx 2484 //stage_edge_lim = ql[0]; // Limit this to be between a constant stage and constant depth extrapolation485 //if(stage_edge_lim > max(stage_centroid_values[k], zl +hc)){486 // stage_edge_lim = max(stage_centroid_values[k], zl+hc);487 //}488 //if(stage_edge_lim < min(stage_centroid_values[k], zl +hc)){489 // stage_edge_lim = min(stage_centroid_values[k], zl+hc);490 //}491 //bedslope_work = g*hc*(stage_edge_lim)*length-0.5*g*max(stage_edge_lim-zl,0.)*(stage_edge_lim-zl)*length;492 493 // Bedslope approx 3494 //bedslope_work = -0.5*g*max(stage_centroid_values[k]-zl,0.)*(stage_centroid_values[k]-zl)*length;495 //496 //}else{497 // // Treat nearly dry cells498 // bedslope_work =-0.5*g*max(ql[0]-zl,0.)*(ql[0]-zl)*length; //499 // //500 // //bedslope_work = -pressure_flux*length;501 // xmom_explicit_update[k] -= normals[ki2]*bedslope_work;502 // ymom_explicit_update[k] -= normals[ki2+1]*bedslope_work;503 // //xmom_explicit_update[k] = 0.0;504 // //ymom_explicit_update[k] = 0.0;505 506 ////}507 508 403 already_computed_flux[ki] = call; // #k Done 509 404 … … 511 406 // Update neighbour n with same flux but reversed sign 512 407 if (n >= 0) { 513 stage_explicit_update[n] += edgeflux[0]; 514 xmom_explicit_update[n] += edgeflux[1]; 515 ymom_explicit_update[n] += edgeflux[2]; 516 //Add bed slope term here 517 //if(hc_n>-9999.0){ 518 //if(stage_centroid_values[n] > max_bed_edgevalue[n]){ 519 // Bedslope approx 1: 520 if(hc_n>H0){ 521 //bedslope_work = -0.5*g*max(stage_centroid_values[n]-zr,0.)*(stage_centroid_values[n]-zr)*length; 522 bedslope_work = length*g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux*length; 523 xmom_explicit_update[n] += normals[ki2]*bedslope_work; 524 ymom_explicit_update[n] += normals[ki2+1]*bedslope_work; 525 }else{ 526 //bedslope_work = 0.;//-pressure_flux*length;//g*length*(0.*(qr[0])-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)); 527 xmom_explicit_update[n] *= 0.; 528 ymom_explicit_update[n] *= 0.; 529 } 530 //if(k==229| n==229){ 531 // printf("-n-pres,xmom,bedwrk, %20.20e, %20.20e, %20.20e \n", pressure_flux*length, xmom_explicit_update[n], bedslope_work); 532 //} 533 534 // 535 // Bedslope approx 2: 536 //stage_edge_lim = qr[0]; 537 //if(stage_edge_lim > max(stage_centroid_values[n], zr +hc_n)){ 538 // stage_edge_lim = max(stage_centroid_values[n], zr+hc_n); 539 //} 540 //if(stage_edge_lim < min(stage_centroid_values[n], zr +hc_n)){ 541 // stage_edge_lim = min(stage_centroid_values[n], zr+hc_n); 542 //} 543 //bedslope_work = g*hc_n*(stage_edge_lim)*length-0.5*g*max(stage_edge_lim-zr,0.)*(stage_edge_lim-zr)*length; 544 // 545 // Bedslope approx 3 546 //bedslope_work = -0.5*g*max(stage_centroid_values[n]-zr,0.)*(stage_centroid_values[n]-zr)*length; 547 // 548 //}else{ 549 // // Treat nearly dry cells 550 // bedslope_work = -0.5*g*max(qr[0]-zr,0.)*(qr[0]-zr)*length; //-pressure_flux*length; //-0.5*g*max(qr[0]-zr,0.)*(qr[0]-zr)*length; 551 // //bedslope_work = -pressure_flux*length; 552 // xmom_explicit_update[n] += normals[ki2]*bedslope_work; 553 // ymom_explicit_update[n] += normals[ki2+1]*bedslope_work; 554 555 // //xmom_explicit_update[n] = 0.0; 556 // //ymom_explicit_update[n] = 0.0; 557 //} 408 409 edgeflux_store[nm3 + 0 ] = edgeflux[0]; 410 edgeflux_store[nm3 + 1 ] = edgeflux[1]; 411 edgeflux_store[nm3 + 2 ] = edgeflux[2]; 412 413 bedslope_work = length*(g*(hc_n*qr[0]-0.5*max(qr[0]-zr,0.)*(qr[0]-zr)) + pressure_flux); 414 //bedslope_work+= (1.-tmp)*length*g*hc_n*qr[0]; 415 pressuregrad_store[nm] = bedslope_work; 416 558 417 559 418 already_computed_flux[nm] = call; // #n Done … … 561 420 562 421 // Update timestep based on edge i and possibly neighbour n 563 if (tri_full_flag[k] == 1) { 422 // GD HACK: 423 // FIXME: Presently this 'hacked' to only update the timestep on 424 // every 2nd call. This works for rk2 timestepping only, and is 425 // needed for correct wetting and drying treatment 426 if ((tri_full_flag[k] == 1) && (call%2==0)) { 564 427 if (max_speed > epsilon) { 565 428 // Apply CFL condition for triangles joining this edge (triangle k and triangle n) … … 573 436 } 574 437 575 // Ted Rigby's suggested less conservative version576 //if(n>=0){577 // timestep = min(timestep, (radii[k]+radii[n])/max_speed);578 //}else{579 // timestep = min(timestep, radii[k]/max_speed);580 //}581 438 } 582 439 } … … 584 441 } // End edge i (and neighbour n) 585 442 586 //if(k==2082){ 587 // printf("xmom_explicit: %20.20e \n", xmom_explicit_update[k]); 588 //} 443 // Keep track of maximal speeds 444 max_speed_array[k] = max_speed; 445 446 } // End triangle k 447 448 // GD HACK 449 // Limit edgefluxes, for mass conservation near wet/dry cells 450 for(k=0; k< number_of_elements; k++){ 451 // Only check cells that are **near dry** 452 // Found I could get problems by checking all cells 453 if(stage_centroid_values[k] <= max_bed_edgevalue[k] + H0){ 454 hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.); 455 // Loop over every edge 456 for(i = 0; i<3; i++){ 457 if(i==0){ 458 // Add up the outgoing flux through the cell 459 outgoing_flux_edges=0.0; 460 for(useint=0; useint<3; useint++){ 461 if(edgeflux_store[3*(3*k+useint)]< 0.){ 462 //outgoing_flux_edges+=1.0; 463 outgoing_flux_edges+=(edgeflux_store[3*(3*k+useint)]*timestep); 464 } 465 } 466 } 467 468 ki=3*k+i; 469 ki2=ki*2; 470 ki3 = ki*3; 471 472 // Prevent outflow from 'seriously' dry cells 473 // Idea: The cell will not go dry if: 474 // total_outgoing_flux <= cell volume = Area_triangle*hc 475 if((edgeflux_store[ki3]< 0.0) && (outgoing_flux_edges<0.)){ 476 477 // This bound could be improved (e.g. we could actually sum 478 // the + and - fluxes and check if they are too large). 479 // However, the advantage is that we don't have to worry 480 // about subsequent changes to the + edgeflux caused by 481 // constraints associated with neighbouring triangles. 482 tmp = (areas[k]*hc)/(fabs(outgoing_flux_edges)+1.0e-10) ; 483 if(tmp< 1.0){ 484 // Idea: we should be close to conserving mass if this holds, 485 // --- consider CFL condition. 486 tmp2 = min(hc/((stage_edge_values[ki]-bed_edge_values[ki])+1.0e-10), 1.0); 487 //tmp2=(xmom_centroid_values[k]*xmom_centroid_values[k]+ymom_centroid_values[k]*ymom_centroid_values[k]); 488 //tmp2/=(xmom_edge_values[ki]*xmom_edge_values[ki]+ ymom_edge_values[ki]*ymom_edge_values[ki]+1.0e-10); 489 //tmp2 = sqrt(tmp2); 490 //tmp2 = min(tmp2, 1.0); 491 edgeflux_store[ki3+0]*=tmp2; 492 edgeflux_store[ki3+1]*=tmp2; 493 edgeflux_store[ki3+2]*=tmp2; 494 495 // Compute neighbour edge index 496 n = neighbours[ki]; 497 if(n>=0){ 498 nm = 3*n + neighbour_edges[ki]; 499 nm3 = nm*3; 500 edgeflux_store[nm3+0]*=tmp2; 501 edgeflux_store[nm3+1]*=tmp2; 502 edgeflux_store[nm3+2]*=tmp2; 503 } 504 } 505 } 506 } 507 } 508 } 509 510 511 // Now add up stage, xmom, ymom explicit updates 512 for(k=0; k<number_of_elements; k++){ 513 hc = max(stage_centroid_values[k] - bed_centroid_values[k],0.); 514 stage_explicit_update[k]=0.; 515 xmom_explicit_update[k]=0.; 516 ymom_explicit_update[k]=0.; 517 518 for(i=0;i<3;i++){ 519 ki=3*k+i; 520 ki2=ki*2; 521 ki3 = ki*3; 522 523 // GD HACK 524 // Option to limit advective fluxes 525 if(hc > H0){ 526 stage_explicit_update[k] += edgeflux_store[ki3+0]; 527 // Cut these terms for shallow flows, and protect stationary states from round-off error 528 xmom_explicit_update[k] += edgeflux_store[ki3+1]; 529 ymom_explicit_update[k] += edgeflux_store[ki3+2]; 530 }else{ 531 stage_explicit_update[k] += edgeflux_store[ki3+0]; 532 } 533 534 535 // GD HACK 536 // Compute bed slope term 537 if(hc>H0){ 538 xmom_explicit_update[k] -= normals[ki2]*pressuregrad_store[ki]; 539 ymom_explicit_update[k] -= normals[ki2+1]*pressuregrad_store[ki]; 540 }else{ 541 xmom_explicit_update[k] *= 0.; 542 ymom_explicit_update[k] *= 0.; 543 } 544 545 } // end edge i 589 546 590 547 // Normalise triangle k by area and store for when all conserved … … 594 551 xmom_explicit_update[k] *= inv_area; 595 552 ymom_explicit_update[k] *= inv_area; 596 597 //if(k==2082){ 598 // printf(" inv_area: %20.20e \n", inv_area); 599 // printf("xmom_explicit: %20.20e \n", xmom_explicit_update[k]); 600 //} 601 // Keep track of maximal speeds 602 max_speed_array[k] = max_speed; 603 604 } // End triangle k 605 606 607 //bedtop=0.; 553 } // end cell k 554 555 // Look for 'dry' edges, and set momentum (& component of momentum_update) 556 // in that direction to zero. If we don't do this, then it is possible for 557 // the bedslope term normal to that edge to be nonzero, and for momentum to 558 // keep 'building' up in the cell without being able to flow out. 559 // 608 560 //for(k=0; k<number_of_elements; k++){ 609 // bedtop = bedtop + stage_explicit_update[k]*areas[k]; 561 // // Ignore "Dry" centroid cells, which will automatically have their 562 // // momentum set to zero (in _protect) 563 // if(stage_centroid_values[k] - bed_centroid_values[k] > H0){ 564 // for(i=0;i<3;i++){ 565 // ki=3*k+i; 566 // if(stage_edge_values[ki] - bed_edge_values[ki] <=0.){ 567 // // Compute magnitude of momentum_update in direction normal to edge 568 // tmp = xmom_explicit_update[k]*normals[2*ki] + ymom_explicit_update[k]*normals[2*ki+1]; 569 // if(tmp > 0.){ 570 // // Set component of momentum_update normal to edge to zero 571 // // [equivalently, subtract component of momentum_update normal to edge] 572 // xmom_explicit_update[k] -= tmp*normals[2*ki]; 573 // ymom_explicit_update[k] -= tmp*normals[2*ki+1]; 574 // 575 // } 576 // 577 // // Compute magnitude of momentum in direction normal to edge 578 // //tmp = xmom_centroid_values[k]*normals[2*ki] + ymom_centroid_values[k]*normals[2*ki+1]; 579 // //if(tmp > 0.){ 580 // // // Set component of momentum normal to edge to zero 581 // // // [equivalently, subtract component of momentum normal to edge] 582 // // xmom_centroid_values[k] -= tmp*normals[2*ki]; 583 // // ymom_centroid_values[k] -= tmp*normals[2*ki+1]; 584 // // 585 // //} 586 // } 587 // } 588 // } 610 589 //} 611 //printf("Bedtop = %20.20e \n ", bedtop); 612 // for(i=0;i<number_of_elements;i++){ 613 // bedtop=max(bedtop, fabs(ymom_edge_values[3*k+i])); 614 // } 590 615 591 // 616 592 // … … 634 610 free(max_bed_edgevalue); 635 611 //free(min_bed_edgevalue); 612 free(edgeflux_store); 613 free(pressuregrad_store); 636 614 637 615 return timestep; … … 668 646 hc = wc[k] - zc[k]; 669 647 // Definine the maximum bed edge value on triangle k. 670 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]))); 671 672 if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) { 673 // Set momentum to zero and ensure h is non negative 648 //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]))); 649 650 //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) { 651 // xmomc[k]*=0.1; 652 // ymomc[k]*=0.1; 653 //} 654 655 656 //if (hc < max(minimum_relative_height*(bmax-zc[k]), minimum_allowed_height)) { 657 if (hc < minimum_allowed_height) { 658 // Set momentum to zero and ensure h is non negative 674 659 xmomc[k] = 0.0; 675 660 ymomc[k] = 0.0; … … 689 674 690 675 wc[k] = max(wc[k], bmin); 691 printf(" mass_add, %f, %f, %f,% d\n", xc[k], yc[k], wc[k], k) ;676 printf(" mass_add, %f, %f, %f,%f,%f,%d\n", xc[k], yc[k], wc[k],zc[k],wc[k]-zc[k], k) ; 692 677 693 678 … … 804 789 double dx1, dx2, dy1, dy2, dxv0, dxv1, dxv2, dyv0, dyv1, dyv2, dq0, dq1, dq2, area2, inv_area2; 805 790 double dqv[3], qmin, qmax, hmin, hmax, bedmax, stagemin; 806 double hc, h0, h1, h2, beta_tmp, hfactor, xtmp, ytmp, weight ;791 double hc, h0, h1, h2, beta_tmp, hfactor, xtmp, ytmp, weight, tmp; 807 792 double dk, dv0, dv1, dv2, de[3], demin, dcmax, r0scale, vect_norm, l1, l2; 808 793 … … 844 829 } 845 830 831 // 846 832 // Compute some useful statistics on wetness/dryness 833 // 847 834 for(k=0; k<number_of_elements;k++){ 848 count_wet_neighbours[k]=0;849 835 cell_wetness_scale[k] = 0.; 850 836 // Check if cell k is wet 851 837 if(stage_centroid_values[k] > elevation_centroid_values[k] + minimum_allowed_height+epsilon){ 838 //if(stage_centroid_values[k] > max_elevation_edgevalue[k] + minimum_allowed_height+epsilon){ 852 839 cell_wetness_scale[k] = 1.; 853 840 } 841 } 842 // 843 for(k=0; k<number_of_elements;k++){ 854 844 // Count the wet neighbours 845 count_wet_neighbours[k]=0; 855 846 for (i=0; i<3; i++){ 856 847 ktmp = surrogate_neighbours[3*k+i]; 857 if(stage_centroid_values[ktmp] > max_elevation_edgevalue[ktmp]){ 848 if( (ktmp >= 0) && cell_wetness_scale[ktmp]>0.){ 849 count_wet_neighbours[k]+=1; 850 }else if(ktmp<=0){ 851 // Boundary condition -- FIXME: assume wet 858 852 count_wet_neighbours[k]+=1; 859 853 } 854 860 855 861 856 } … … 865 860 // First treat all 'fully wet' cells, then treat 'partially dry' cells 866 861 for(k_wetdry=0; k_wetdry<2; k_wetdry++){ 867 //if(((stage_centroid_values[k] > max_elevation_edgevalue[k]))==k_wetdry){868 //if(((stage_centroid_values[k] < elevation_centroid_values[k]+minimum_allowed_height))==k_wetdry){869 // For partially wet cells, we now know that the edges of neighbouring870 // fully wet cells have been defined871 862 872 863 // Begin extrapolation routine … … 935 926 //============================================== 936 927 // Number of boundaries <= 1 928 // 'Typical case' 937 929 //============================================== 938 930 … … 953 945 //if(stage_centroid_values[k2]<=max_elevation_edgevalue[k2]+epsilon){ 954 946 //if(stage_centroid_values[k2]<=elevation_centroid_values[k2]+minimum_allowed_height+epsilon){ 955 if( cell_wetness_scale[k2]==0.0){947 if(k2<0 || cell_wetness_scale[k2]==0.0){ 956 948 k2 = k ; 957 949 } 958 950 //if(stage_centroid_values[k0]<=max_elevation_edgevalue[k0]+epsilon){ 959 951 //if(stage_centroid_values[k0]<=elevation_centroid_values[k0]+minimum_allowed_height+epsilon){ 960 if( cell_wetness_scale[k0]==0.0){952 if(k0 < 0 || cell_wetness_scale[k0]==0.0){ 961 953 k0 = k ; 962 954 } 963 955 //if(stage_centroid_values[k1]<=max_elevation_edgevalue[k1]+epsilon){ 964 956 //if(stage_centroid_values[k1]<=elevation_centroid_values[k1]+minimum_allowed_height+epsilon){ 965 if( cell_wetness_scale[k1]==0.0){957 if(k1 < 0 || cell_wetness_scale[k1]==0.0){ 966 958 k1 = k ; 967 959 } … … 1003 995 area2 = dy2*dx1 - dy1*dx2; 1004 996 1005 // Treat triangles with zero or 1 wet neighbours .1006 if ((area2 <= 0 )|(cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0))997 // Treat triangles with zero or 1 wet neighbours (area2 <=0.) 998 if ((area2 <= 0.))// || (cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0)) 1007 999 { 1008 1000 //if((cell_wetness_scale[k]==1.0) | (k==k0)&&(k==k1)&&(k==k2)){ 1009 stage_edge_values[k3] = stage_centroid_values[k]; 1010 stage_edge_values[k3+1] = stage_centroid_values[k]; 1011 stage_edge_values[k3+2] = stage_centroid_values[k]; 1001 //if(count_wet_neighbours[k] > 5.){ 1002 stage_edge_values[k3] = stage_centroid_values[k]; 1003 stage_edge_values[k3+1] = stage_centroid_values[k]; 1004 stage_edge_values[k3+2] = stage_centroid_values[k]; 1005 //}else{ 1012 1006 //}else{ 1013 1007 // Dry cell with a single 'wet' neighbour … … 1028 1022 //if( (k==k0) & (k==k1) & (k==k2)){ 1029 1023 // // Isolated wet cell -- use constant depth extrapolation for stage 1030 // //stage_edge_values[k3] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3];1031 // //stage_edge_values[k3+1] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+1];1032 // //stage_edge_values[k3+2] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+2];1033 1024 // stage_edge_values[k3] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3]; 1025 // stage_edge_values[k3+1] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+1]; 1026 // stage_edge_values[k3+2] = stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3+2]; 1027 //} 1034 1028 // // Isolated wet cell -- constant depth extrapolation, but don't let water flow uphill 1035 1029 // //stage_edge_values[k3] = min(stage_centroid_values[k], stage_centroid_values[k]- elevation_centroid_values[k] + elevation_edge_values[k3]); … … 1122 1116 1123 1117 // Calculate heights of neighbouring cells 1124 hc = stage_centroid_values[k] - elevation_centroid_values[k];1125 h0 = stage_centroid_values[k0] - elevation_centroid_values[k0];1126 h1 = stage_centroid_values[k1] - elevation_centroid_values[k1];1127 h2 = stage_centroid_values[k2] - elevation_centroid_values[k2];1128 hmin = min(min(h0, min(h1, h2)), hc);1129 1130 hfactor = 0.0;1131 // if (hmin > 0.001)1132 if (hmin > 0.)1133 // if (hc>0.0)1134 {1118 //hc = stage_centroid_values[k] - elevation_centroid_values[k]; 1119 //h0 = stage_centroid_values[k0] - elevation_centroid_values[k0]; 1120 //h1 = stage_centroid_values[k1] - elevation_centroid_values[k1]; 1121 //h2 = stage_centroid_values[k2] - elevation_centroid_values[k2]; 1122 //hmin = min(min(h0, min(h1, h2)), hc); 1123 //// GD FIXME: No longer needed? 1124 //hfactor = 0.0; 1125 ////if (hmin > 0.001) 1126 //if (hmin > 0.) 1127 ////if (hc>0.0) 1128 //{ 1135 1129 hfactor = 1.0 ;//hmin/(hmin + 0.004); 1136 1130 //hfactor=hmin/(hmin + 0.004); 1137 }1131 //} 1138 1132 1139 1133 //----------------------------------- … … 1156 1150 b = dx1*dq2 - dx2*dq1; 1157 1151 b *= inv_area2; 1158 1152 // d(stage)/dx = - u*sqrt(u**2 + v**2)*n**2/depth 1153 //hc=max(stage_centroid_values[k] - elevation_centroid_values[k],0.0); 1154 //tmp = sqrt(xmom_centroid_values[k]*xmom_centroid_values[k] + 1155 // ymom_centroid_values[k]*ymom_centroid_values[k])*0.03*0.03; 1156 //tmp /=max(hc*hc*hc, 1.0e-09); 1157 //a = -xmom_centroid_values[k]*tmp; 1158 //b = -ymom_centroid_values[k]*tmp; 1159 1159 // Calculate provisional jumps in stage from the centroid 1160 1160 // of triangle k to its vertices, to be limited … … 1167 1167 // from the centroid to the min and max 1168 1168 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1169 1169 1170 1170 beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor; 1171 1171 … … 1173 1173 // Limit the gradient 1174 1174 // This is more complex for stage than other quantities 1175 if((count_wet_neighbours[k]>0)){//&&(k_wetdry==0)){ 1175 //if((count_wet_neighbours[k]>0)&&(cell_wetness_scale[k]=1.0)){//&&(k_wetdry==0)){ 1176 //if(stage_centroid_values[k] > max_elevation_edgevalue[k]){ 1176 1177 limit_gradient(dqv, qmin, qmax, beta_tmp); 1177 1178 stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1178 1179 stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1179 1180 stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1180 }else{ 1181 ////if(count_wet_neighbours[k]==0){ 1182 // //weight=max(cell_wetness_scale[k] - (stage_centroid_values[k]-elevation_centroid_values[k]), 0.); 1183 // //weight/=(max_elevation_edgevalue[k] - elevation_centroid_values[k]); 1184 // //weight=min(weight, 1.0); 1185 // //weight==0; 1186 // //weight=0.; 1187 // // 'Shallow flow on steep slope' 1188 // //limit_gradient(dqv, qmin, qmax, beta_tmp); 1189 stage_edge_values[k3+0] =stage_centroid_values[k] + dqv[0]; 1190 stage_edge_values[k3+1] =stage_centroid_values[k] + dqv[1]; 1191 stage_edge_values[k3+2] =stage_centroid_values[k] + dqv[2]; 1192 1193 // // There exists a neighbouring bed cell with elevation > minimum 1194 // // neighbouring stage value 1195 1196 // // We have to be careful in this situation. Limiting the stage gradient can 1197 // // cause problems for shallow flows down steep slopes (rainfall-runoff type problems) 1198 // // Previously 'balance_deep_and_shallow' was used to deal with this issue 1199 // //for(i=0; i<3; i++){ 1200 // // stage_edge_values[k3+i] = weight*stage_edge_values[k3+i] + 1201 // // (1.0-weight)*(stage_centroid_values[k] -elevation_centroid_values[k] 1202 // // +elevation_edge_values[k3+i]); 1203 // //} 1204 } 1181 // IDEA: extrapolate assuming slope is that of steady flow?? 1182 // GD HACK - FIXME 1183 // Note that 'near-dry' cells which don't exchange mass with 1184 // neighbouring cells have to revert to having a constant stage 1185 // extrapolation, or else they will have a residual bed slope term. 1186 // This helps! -- But probably makes rainfall-runoff problems worse. 1187 //ii = (stage_edge_values[k3+0] > elevation_edge_values[k3+0])+ 1188 // (stage_edge_values[k3+1] > elevation_edge_values[k3+1])+ 1189 // (stage_edge_values[k3+2] > elevation_edge_values[k3+2]); 1190 //if(ii<2){ 1191 // stage_edge_values[k3+0] = stage_centroid_values[k] ; 1192 // stage_edge_values[k3+1] = stage_centroid_values[k] ; 1193 // stage_edge_values[k3+2] = stage_centroid_values[k] ; 1194 //} 1195 //}else{ 1196 // d(stage)/dx = - u*sqrt(u**2 + v**2)*n**2/depth 1197 // hc=max(stage_centroid_values[k] - elevation_centroid_values[k],0.0); 1198 // tmp = sqrt(xmom_centroid_values[k]*xmom_centroid_values[k] + 1199 // ymom_centroid_values[k]*ymom_centroid_values[k])*0.03*0.03; 1200 // tmp /=max(hc*hc*hc, 1.0e-09); 1201 // a = -xmom_centroid_values[k]*tmp; 1202 // b = -ymom_centroid_values[k]*tmp; 1203 // dqv[0] = a*dxv0 + b*dyv0; 1204 // dqv[1] = a*dxv1 + b*dyv1; 1205 // dqv[2] = a*dxv2 + b*dyv2; 1206 //////if(count_wet_neighbours[k]==0){ 1207 //// //weight=max(cell_wetness_scale[k] - (stage_centroid_values[k]-elevation_centroid_values[k]), 0.); 1208 //// //weight/=(max_elevation_edgevalue[k] - elevation_centroid_values[k]); 1209 //// //weight=min(weight, 1.0); 1210 //// //weight==0; 1211 // weight=0.; 1212 //// // 'Shallow flow on steep slope' 1213 //limit_gradient(dqv, qmin, qmax, beta_tmp); 1214 //stage_edge_values[k3+0] =stage_centroid_values[k] + dqv[0]; 1215 //stage_edge_values[k3+1] =stage_centroid_values[k] + dqv[1]; 1216 //stage_edge_values[k3+2] =stage_centroid_values[k] + dqv[2]; 1217 // 1218 //// // There exists a neighbouring bed cell with elevation > minimum 1219 //// // neighbouring stage value 1220 1221 //// // We have to be careful in this situation. Limiting the stage gradient can 1222 //// // cause problems for shallow flows down steep slopes (rainfall-runoff type problems) 1223 //// // Previously 'balance_deep_and_shallow' was used to deal with this issue 1224 // for(i=0; i<3; i++){ 1225 // stage_edge_values[k3+i] = weight*stage_edge_values[k3+i] + 1226 // (1.0-weight)*(stage_centroid_values[k] -elevation_centroid_values[k] 1227 // +elevation_edge_values[k3+i]); 1228 // } 1229 //} 1205 1230 1206 1231 //----------------------------------- … … 1240 1265 //if((k!=k0)&(k!=k1)&(k!=k2)) 1241 1266 //if(stagemin>=bedmax){ 1242 if((count_wet_neighbours[k]>0) &&1243 (cell_wetness_scale[k]==1.0)){1244 //(stage_centroid_values[k]>(minimum_allowed_height+elevation_centroid_values[k]))){1267 if((count_wet_neighbours[k]>0)){ // && 1268 // (cell_wetness_scale[k]==1.0)){ 1269 //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){ 1245 1270 limit_gradient(dqv, qmin, qmax, beta_tmp); 1246 1271 }else{ … … 1293 1318 // Limit the gradient 1294 1319 //if(stagemin>=bedmax){ 1295 if((count_wet_neighbours[k]>0) &&1296 (cell_wetness_scale[k]==1.0)){1320 if((count_wet_neighbours[k]>0)){//&& 1321 //(cell_wetness_scale[k]==1.0)){ 1297 1322 //(stage_centroid_values[k]>(minimum_allowed_height+elevation_centroid_values[k]))){ 1323 //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){ 1298 1324 limit_gradient(dqv, qmin, qmax, beta_tmp); 1299 1325 }else{ … … 1635 1661 *max_speed_array, //Keeps track of max speeds for each triangle 1636 1662 *stage_centroid_values, 1663 *xmom_centroid_values, 1664 *ymom_centroid_values, 1637 1665 *bed_centroid_values, 1638 1666 *bed_vertex_values; … … 1642 1670 1643 1671 // Convert Python arguments to C 1644 if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOiOOO ",1672 if (!PyArg_ParseTuple(args, "ddddOOOOOOOOOOOOOOOOOOOOiOOOOO", 1645 1673 ×tep, 1646 1674 &epsilon, … … 1667 1695 &optimise_dry_cells, 1668 1696 &stage_centroid_values, 1697 &xmom_centroid_values, 1698 &ymom_centroid_values, 1669 1699 &bed_centroid_values, 1670 1700 &bed_vertex_values)) { … … 1695 1725 CHECK_C_CONTIG(max_speed_array); 1696 1726 CHECK_C_CONTIG(stage_centroid_values); 1727 CHECK_C_CONTIG(xmom_centroid_values); 1728 CHECK_C_CONTIG(ymom_centroid_values); 1697 1729 CHECK_C_CONTIG(bed_centroid_values); 1698 1730 CHECK_C_CONTIG(bed_vertex_values); … … 1729 1761 optimise_dry_cells, 1730 1762 (double*) stage_centroid_values -> data, 1763 (double*) xmom_centroid_values -> data, 1764 (double*) ymom_centroid_values -> data, 1731 1765 (double*) bed_centroid_values -> data, 1732 1766 (double*) bed_vertex_values -> data); -
trunk/anuga_work/development/gareth/tests/channel_floodplain/channel_floodplain1.py
r8547 r8751 14 14 #from anuga import * 15 15 #from balanced_basic import * 16 #from balanced_dev import *17 from anuga_tsunami import *16 from balanced_dev import * 17 #from anuga_tsunami import * 18 18 #from balanced_basic.swb2_domain import * 19 19 #from balanced_basic.swb2_domain import Domain -
trunk/anuga_work/development/gareth/tests/dam_break/dam_break.py
r8547 r8751 51 51 # Setup Algorithm 52 52 #------------------------------------------------------------------------------ 53 domain.set_timestepping_method('rk2')54 domain.set_default_order(2)53 #domain.set_timestepping_method('rk2') 54 #domain.set_default_order(2) 55 55 56 56 print domain.get_timestepping_method() 57 57 58 domain.use_edge_limiter = True58 #domain.use_edge_limiter = True 59 59 #domain.use_edge_limiter = False 60 domain.tight_slope_limiters = True61 domain.use_centroid_velocities = False60 #domain.tight_slope_limiters = True 61 #domain.use_centroid_velocities = False 62 62 63 domain.CFL = 1.063 #domain.CFL = 1.0 64 64 65 65 #domain.beta_w = 0.6 -
trunk/anuga_work/development/gareth/tests/dam_break/plotme.py
r8547 r8751 9 9 p2_st=util.get_centroids(p_st) 10 10 11 p_dev = util.get_output('dam_break_201 20831_172309/dam_break.sww', 0.001)11 p_dev = util.get_output('dam_break_20130219_202649/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/okushiri/run_okushiri.py
r8547 r8751 24 24 import anuga 25 25 import project 26 #from balanced_dev import *27 from anuga_tsunami import *26 from balanced_dev import * 27 #from anuga_tsunami import * 28 28 29 29 def main(elevation_in_mesh=False): -
trunk/anuga_work/development/gareth/tests/parabolic/parabolaplot.py
r8396 r8751 11 11 import util 12 12 13 p=util.get_output('parabola_v2.sww', 0.0 1)13 p=util.get_output('parabola_v2.sww', 0.001) 14 14 p2=util.get_centroids(p, velocity_extrapolation=True) 15 15 -
trunk/anuga_work/development/gareth/tests/runup/runup.py
r8547 r8751 56 56 Bt=anuga.Transmissive_boundary(domain) # Continue all values of boundary -- not used in this example 57 57 Bd=anuga.Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values -- not used in this example 58 Bw=anuga.Time_boundary(domain=domain,59 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.58 #Bw=anuga.Time_boundary(domain=domain, 59 # 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. 60 60 61 61 #---------------------------------------------- -
trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py
r8607 r8751 14 14 #from swb2_domain import * 15 15 #from balanced_basic import * 16 #from balanced_dev import * 17 from anuga_tsunami import * 16 from balanced_dev import * 17 #from anuga_tsunami import * 18 18 19 #--------- 19 20 #Setup computational domain … … 23 24 domain=Domain(points,vertices,boundary) # Create Domain 24 25 domain.set_name('runup_sinusoid_v2') # Output to file runup.sww 25 domain.set_datadir('.') # Use current folder 26 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1}) 27 #domain.set_store_vertices_uniquely(True) 26 28 27 #------------------ 29 28 # Define topography 30 29 #------------------ 31 30 scale_me=1.0 32 33 31 #domain.minimum_allowed_height=domain.minimum_allowed_height*scale_me # Seems needed to make the algorithms behave 34 32 … … 37 35 38 36 def stagefun(x,y): 39 stge=-0.2*scale_me #+0. 01*(x>0.9)37 stge=-0.2*scale_me #+0.1*(x>0.9) 40 38 #topo=topography(x,y) 41 39 return stge#*(stge>topo) + (topo)*(stge<=topo) … … 53 51 domain.get_quantity('stage').smooth_vertex_values() 54 52 53 #print domain.forcing_terms 54 #assert 0==1 55 55 # Experiment with rain. 56 56 # rainin = anuga.shallow_water.forcing.Rainfall(domain, rate=0.001) #, center=(0.,0.), radius=1000. ) … … 64 64 Bd=anuga.Dirichlet_boundary([-0.1*scale_me,0.,0.]) # Constant boundary values -- not used in this example 65 65 def waveform(t): 66 return (0.0*sin(t*2*pi)-0.1)*exp(-t)-0.166 return -0.1 #(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1 67 67 Bt2=anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain,waveform) 68 68 #Bw=anuga.Time_boundary(domain=domain, … … 72 72 # Associate boundary tags with boundary objects 73 73 #---------------------------------------------- 74 domain.set_boundary({'left': Br, 'right': B d, 'top': Br, 'bottom':Br})74 domain.set_boundary({'left': Br, 'right': Bt2, 'top': Br, 'bottom':Br}) 75 75 76 76 #------------------------------ … … 78 78 #------------------------------ 79 79 80 for t in domain.evolve(yieldstep=0.2 ,finaltime=40.0):80 for t in domain.evolve(yieldstep=0.200,finaltime=40.00): 81 81 print domain.timestepping_statistics() 82 82 xx = domain.quantities['xmomentum'].centroid_values … … 84 84 dd = domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values 85 85 dd_raw=1.0*dd 86 dd = (dd)*(dd>1.0e-03)+1.0e-0386 dd = dd*(dd>1.0e-03)+1.0e-03*(dd<=1.0e-03) 87 87 vv = ( (xx/dd)**2 + (yy/dd)**2)**0.5 88 88 vv = vv*(dd>1.0e-03) -
trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoidplot.py
r8353 r8751 15 15 #------------------ 16 16 #v=(p.y==0.5) 17 v=(p2.y==p2.y[80]) 17 myind=(abs(p2.y-0.5)).argmin() 18 v=(p2.y==p2.y[myind]) 18 19 19 20 #-------------------- -
trunk/anuga_work/development/gareth/tests/shallow_steep_slope/channel_SU_sparse.py
r8549 r8751 29 29 # Setup computational domain 30 30 #------------------------------------------------------------------------------ 31 points, vertices, boundary = rectangular_cross(1 0, 10,32 len1=1 00.0, len2=100.0) # Mesh31 points, vertices, boundary = rectangular_cross(14, 10, 32 len1=140.0, len2=100.0) # Mesh 33 33 domain = Domain(points, vertices, boundary) # Create domain 34 34 domain.set_name('channel_SU_2_v2') # Output name 35 #domain.set_store_vertices_uniquely(True)36 #domain.CFL=1.037 35 #------------------------------------------------------------------------------ 38 36 # Setup initial conditions 39 37 #------------------------------------------------------------------------------ 40 38 def topography(x, y): 41 return -x/10. #+ numpy.sin(x/10.) +abs(y-50.)/100.# linear bed slope39 return -x/10. + 1.*(numpy.sin(x/10.) +abs(y-50.)/10.) -0.*(x>80.) # linear bed slope 42 40 43 41 def stagetopo(x,y): 44 stg= -x/10. +0.06309625# Constant depth42 stg= topography(x,y) + 0.163 #-x/10. +0.06309625 -50.*(x>80.)# Constant depth 45 43 #topo=topography(x,y) 46 44 return stg#*(stg>topo) + topo*(stg<=topo) … … 68 66 #Bo = anuga.Transmissive_boundary(domain) 69 67 #Bd = anuga.Dirichlet_boundary([-20., 0., 0.]) 70 domain.set_boundary({'left': Br, 'right': B o, 'top': Br, 'bottom': Br})68 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 71 69 72 70
Note: See TracChangeset
for help on using the changeset viewer.