Changeset 9257
- Timestamp:
- Jul 10, 2014, 5:42:24 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r9256 r9257 250 250 self.riverwallData=anuga.structures.riverwall.RiverWall(self) 251 251 252 # Keep track of the fluxes through the boundaries 253 # Only works for DE algorithms at present 254 max_time_substeps=3 # Maximum number of substeps supported by any timestepping method 255 # boundary_flux_sum holds boundary fluxes on each sub-step 256 self.boundary_flux_sum=num.array([0.]*max_time_substeps) 257 from anuga.operators.boundary_flux_integral_operator import boundary_flux_integral_operator 258 self.boundary_flux_integral=boundary_flux_integral_operator(self) 259 # Make an integer counting how many times we call compute_fluxes_central -- so we know which substep we are on 260 self.call=1 252 261 253 262 … … 480 489 self.maximum_allowed_speed=0.0 481 490 482 ## FIXME: Should implement tracking of boundary fluxes483 ## Keep track of the fluxes through the boundaries484 self.boundary_flux_integral=num.ndarray(1)485 self.boundary_flux_integral[0]=0.486 self.boundary_flux_sum=num.ndarray(1)487 self.boundary_flux_sum[0]=0.488 489 self.call=1 # Integer counting how many times we call compute_fluxes_central490 491 491 492 if self.processor == 0 and self.verbose: … … 547 548 self.maximum_allowed_speed=0.0 548 549 549 ## FIXME: Should implement tracking of boundary fluxes550 ## Keep track of the fluxes through the boundaries551 self.boundary_flux_integral=num.ndarray(1)552 self.boundary_flux_integral[0]=0.553 self.boundary_flux_sum=num.ndarray(1)554 self.boundary_flux_sum[0]=0.555 556 self.call=1 # Integer counting how many times we call compute_fluxes_central557 558 550 if self.processor == 0 and self.verbose: 559 551 print '##########################################################################' … … 615 607 self.maximum_allowed_speed=0.0 616 608 617 ## FIXME: Should implement tracking of boundary fluxes618 ## Keep track of the fluxes through the boundaries619 self.boundary_flux_integral=num.ndarray(1)620 self.boundary_flux_integral[0]=0.621 self.boundary_flux_sum=num.ndarray(1)622 self.boundary_flux_sum[0]=0.623 624 self.call=1 # Integer counting how many times we call compute_fluxes_central625 626 609 if self.processor == 0 and self.verbose: 627 610 print '##########################################################################' … … 682 665 683 666 self.maximum_allowed_speed=0.0 684 685 ## FIXME: Should implement tracking of boundary fluxes686 ## Keep track of the fluxes through the boundaries687 self.boundary_flux_integral=num.ndarray(1)688 self.boundary_flux_integral[0]=0.689 self.boundary_flux_sum=num.ndarray(1)690 self.boundary_flux_sum[0]=0.691 692 self.call=1 # Integer counting how many times we call compute_fluxes_central693 667 694 668 if self.processor == 0 and self.verbose: … … 1337 1311 return water_volume 1338 1312 1313 def get_boundary_flux_integral(self): 1314 """ 1315 Compute the boundary flux integral. 1316 Should work in parallel 1317 """ 1318 1319 from anuga import myid, numprocs, send, receive, barrier 1320 1321 if not self.compute_fluxes_method=='DE': 1322 msg='Boundary flux integral only supported for DE fluxes '+\ 1323 '(because computation of boundary_flux_sum is only implemented there)' 1324 raise Exception, msg 1325 1326 flux_integral = self.boundary_flux_integral.boundary_flux_integral 1327 1328 if myid == 0: 1329 for i in range(1,numprocs): 1330 remote_flux_integral = receive(i) 1331 flux_integral = flux_integral + remote_flux_integral 1332 else: 1333 send(flux_integral,0) 1334 1335 barrier() 1336 1337 if myid == 0: 1338 for i in range(1,numprocs): 1339 send(flux_integral,i) 1340 else: 1341 flux_integral = receive(0) 1342 1343 return flux_integral 1339 1344 1340 1345 def get_flow_through_cross_section(self, polyline, verbose=False): … … 1587 1592 self.riverwallData.hydraulic_properties) 1588 1593 1589 ## FIXME: This won't work in parallel since the timestep has not been updated to include other processors.1590 ## Update the boundary flux integral1591 ## FIXME GD: This should be moved to its own routine -- something like this1592 ## could be included in all solvers.1593 #if(self.timestepping_method=='rk2'):1594 # if(self.call%2==1):1595 # self.boundary_flux_integral[0]= self.boundary_flux_integral[0] +\1596 # self.boundary_flux_sum[0]*self.timestep*0.51597 # #print 'dbfi ', self.boundary_flux_integral, self.boundary_flux_sum1598 # self.boundary_flux_sum[0]=0.1599 #elif(self.timestepping_method=='euler'):1600 # # FIXME GD: Unsupported at present.1601 # self.boundary_flux_integral=0.1602 # # This presently doesn't work -- this section of code may need to go elsewhere1603 # #self.boundary_flux_integral[0]= self.boundary_flux_integral[0] +\1604 # # self.boundary_flux_sum[0]*self.timestep1605 # #self.boundary_flux_sum[0]=0.1606 #elif(self.timestepping_method=='rk3'):1607 # # FIXME GD: Unsupported at present.1608 # self.boundary_flux_integral=0.1609 # # FIXME GD: This needs to be implemented1610 #else:1611 # mess='ERROR: domain.timestepping_method', self.timestepping_method,' method not recognised'1612 # raise Exception, mess1613 1614 1594 self.flux_timestep = flux_timestep 1615 1595 … … 2338 2318 These calculations are only approximate since they don't use the 2339 2319 flux calculation used in evolve 2320 2321 See get_boundary_flux_integral for an exact computation 2340 2322 """ 2341 2323 -
trunk/anuga_core/source/anuga/shallow_water/swDE1_domain_ext.c
r9232 r9257 415 415 // Smoothing by stage alone can cause high velocities / slow draining for nearly dry cells 416 416 if(i==0) edgeflux[i] += (s_max*s_min)*(max(q_right_rotated[i],ze) - max(q_left_rotated[i],ze)); 417 //if(i==0) edgeflux[i] += (s_max*s_min)*(h_right - h_left); 417 418 if(i==1) edgeflux[i] += (s_max*s_min)*(uh_right - uh_left); 418 419 if(i==2) edgeflux[i] += (s_max*s_min)*(vh_right - vh_left); … … 584 585 double bedslope_work, local_timestep; 585 586 int neighbours_wet[3];//Work array 586 int RiverWall_count ;587 int RiverWall_count, substep_count; 587 588 double hle, hre, zc, zc_n, Qfactor, s1, s2, h1, h2; 588 589 double stage_edge_lim, outgoing_mass_edges, bedtop, bedbot, pressure_flux, hc, hc_n, tmp, tmp2; … … 606 607 local_timestep=timestep; 607 608 RiverWall_count=0; 609 substep_count=(call-2)%timestep_fluxcalls; 608 610 609 611 … … 790 792 edgeflux_store[ki3 + 2 ] = -edgeflux[2]; 791 793 792 // bedslope_work contains all gravity related terms -- weighting of794 // bedslope_work contains all gravity related terms 793 795 bedslope_work=length*(-g*0.5*(h_left*h_left - hle*hle -(hle+hc)*(zl-zc))+pressure_flux); 794 796 … … 836 838 } // End edge i (and neighbour n) 837 839 // Keep track of maximal speeds 838 if( (call-2)%timestep_fluxcalls==0) max_speed_array[k] = speed_max_last; //max_speed;840 if(substep_count==0) max_speed_array[k] = speed_max_last; //max_speed; 839 841 840 842 … … 843 845 //// GD HACK 844 846 //// Limit edgefluxes, for mass conservation near wet/dry cells 847 //// This doesn't seem to be needed anymore 845 848 //for(k=0; k< number_of_elements; k++){ 846 849 // //continue; … … 925 928 // boundary_flux_integral 926 929 if( (n<0 & tri_full_flag[k]==1) | ( n>=0 && (tri_full_flag[k]==1 & tri_full_flag[n]==0)) ){ 927 boundary_flux_sum[0] += edgeflux_store[ki3]; 930 // boundary_flux_sum is an array with length = timestep_fluxcalls 931 // For each sub-step, we put the boundary flux sum in. 932 boundary_flux_sum[substep_count] += edgeflux_store[ki3]; 928 933 } 929 930 934 // GD HACK 931 935 // Compute bed slope term … … 950 954 951 955 // Hack to ensure we only update the timestep on the first call within each rk2/rk3 step 952 if( (call-2)%timestep_fluxcalls==0) timestep=local_timestep;953 956 if(substep_count==0) timestep=local_timestep; 957 954 958 free(edgeflux_store); 955 959 free(pressuregrad_store); -
trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py
r9200 r9257 9 9 10 10 from math import sin, pi, exp 11 #from anuga.shallow_water.shallow_water_domain import Domain as Domain12 #from anuga.shallow_water_balanced2.swb2_domain import Domain as Domain13 #path.append('/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/development/gareth/balanced_basic')14 #from swb2_domain import *15 #from balanced_basic import *16 #from balanced_dev import *17 11 from anuga import Domain as Domain 18 #from bal_and import * 19 #from anuga_tsunami import * 12 from anuga.operators.boundary_flux_integral_operator import boundary_flux_integral_operator 20 13 21 14 #--------- … … 27 20 domain.set_name('runup_sinusoid_v2') # Output to file runup.sww 28 21 #domain.set_store_centroids(True) 29 #domain.set_timestepping_method('euler')30 #domain.set_flow_algorithm('DE1')31 #domain.set_flow_algorithm('tsunami')32 22 domain.set_flow_algorithm('DE0') 33 23 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 34 24 'ymomentum': 2, 'elevation': 2}) 35 #domain.minimum_storable_height=1.0e-0336 25 domain.set_store_vertices_uniquely() 37 26 #------------------ … … 70 59 71 60 print '#-#', domain.minimum_allowed_height 72 #domain.minimum_allowed_height=0.00173 #def frict_change(x,y):74 # return 0.2*(x>0.5)+0.1*(x<=0.5)75 #76 #domain.set_quantity('friction',frict_change)77 61 78 62 domain.set_quantity('stage', stagefun) # Constant negative initial stage … … 108 92 #Evolve the system through time 109 93 #------------------------------ 110 111 94 for t in domain.evolve(yieldstep=tstep,finaltime=lasttime): 112 95 #for t in domain.evolve(yieldstep=0.2,finaltime=60.): … … 121 104 vv = vv*(dd>1.0e-03) 122 105 print 'Peak velocity is: ', vv.max(), vv.argmax(), dd[vv.argmax()] 123 print 'Volume is', sum(dd_raw*domain.areas) 106 vol=sum(dd_raw*domain.areas) 107 print 'Volume is', vol 108 flux_integral=domain.get_boundary_flux_integral() 109 print 'Flux integral is: ', flux_integral 110 print 'Their difference is:', vol-flux_integral 124 111 #print 'Volume less flux int', sum(dd_raw*domain.areas) - domain.boundary_flux_integral 125 112 126 113 127 114 vel_final_inds=(vv>1.0e-01).nonzero()
Note: See TracChangeset
for help on using the changeset viewer.