Changeset 4701
- Timestamp:
- Sep 4, 2007, 5:36:01 PM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r4679 r4701 170 170 171 171 172 # Defaults172 # Defaults 173 173 from anuga.config import max_smallsteps, beta_w, beta_h, epsilon 174 174 from anuga.config import CFL … … 180 180 181 181 182 # FIXME: Maybe have separate orders for h-limiter and w-limiter?183 # Or maybe get rid of order altogether and use beta_w and beta_h182 # FIXME: Maybe have separate orders for h-limiter and w-limiter? 183 # Or maybe get rid of order altogether and use beta_w and beta_h 184 184 self.set_default_order(1) 185 185 #self.default_order = 1 … … 195 195 196 196 197 # Model time197 # Model time 198 198 self.time = 0.0 199 199 self.finaltime = None … … 201 201 self.starttime = 0 #Physical starttime if any (0 is 1 Jan 1970 00:00:00) 202 202 203 ######OBSOLETE 204 #Origin in UTM coordinates 205 #FIXME: This should be set if read by a msh file 206 #self.zone = zone 207 #self.xllcorner = xllcorner 208 #self.yllcorner = yllcorner 209 210 211 #Checkpointing and storage 203 # Monitoring 204 self.quantities_to_be_monitored = None 205 self.monitor_polygon = None 206 self.monitor_time_interval = None 207 208 209 # Checkpointing and storage 212 210 from anuga.config import default_datadir 213 211 self.datadir = default_datadir … … 215 213 self.checkpoint = False 216 214 217 # MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array,218 # to be used during the flux calculation215 # MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array, 216 # to be used during the flux calculation 219 217 N = len(self) #number_of_triangles 220 218 self.already_computed_flux = zeros((N, 3), Int) … … 301 299 302 300 """ 301 302 # FIXME: Could we name this a bit more intuitively 303 # E.g. set_quantities_from_dictionary 303 304 for key in quantity_dict.keys(): 304 305 self.set_quantity(key, quantity_dict[key], location='vertices') … … 544 545 545 546 547 548 549 def set_quantities_to_be_monitored(self, q, 550 polygon=None, 551 time_interval=None): 552 """Specify which quantities will be monitored for extrema. 553 554 q must be either: 555 - the name of a quantity 556 - a list of quantity names 557 - None 558 559 In the two first cases, the named quantities will be monitored at 560 each internal timestep 561 562 If q is None, monitoring will be switched off altogether. 563 564 polygon (if specified) will restrict monitoring to triangles inside polygon. 565 If omitted all triangles will be included. 566 567 time_interval (if specified) will restrict monitoring to time steps in 568 that interval. If omitted all timesteps will be included. 569 570 FIXME: Derived quantities such as 'stage-elevation' will appear later 571 """ 572 573 # FIXME (Ole): This is under construction. See ticket:192 574 575 if q is None: 576 self.quantities_to_be_monitored = None 577 self.monitor_polygon = None 578 self.monitor_time_interval = None 579 return 580 581 if isinstance(q, basestring): 582 q = [q] # Turn argument into a list 583 584 # Check correcness 585 for quantity_name in q: 586 msg = 'Quantity %s is not a valid conserved quantity'\ 587 %quantity_name 588 589 assert quantity_name in self.conserved_quantities, msg 590 591 if polygon is not None: 592 # FIXME Check input 593 pass 594 595 if time_interval is not None: 596 # FIXME Check input 597 pass 598 599 600 self.quantities_to_be_monitored = q 601 self.monitor_polygon = polygon 602 self.monitor_time_interval = time_interval 603 604 605 546 606 #MISC 547 607 def check_integrity(self): … … 742 802 743 803 return msg 804 805 806 807 def quantity_statistics(self): 808 """Return string with statistics about quantities for printing or logging 809 810 Quantities reported are specified through method 811 812 set_quantities_to_be_monitored 813 814 """ 815 816 pass 817 818 744 819 745 820 -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r4687 r4701 173 173 self.forcing_terms.append(gravity) 174 174 175 # Stored output175 # Stored output 176 176 self.store = True 177 177 self.format = 'sww' … … 179 179 self.minimum_storable_height = minimum_storable_height 180 180 self.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] 181 181 182 182 183 … … 234 235 235 236 #FIXME (Ole): rename H0 to minimum_allowed_height_in_flux_computation 236 #rename tight_slope_limiters to tight_slope_limiters. 237 #Maybe use histogram to identify isolated extreme speeds and deal with them adaptively 238 #similarly to how we used to use 1 order steps to recover. 237 238 #FIXME (Ole): Maybe use histogram to identify isolated extreme speeds 239 #and deal with them adaptively similarly to how we used to use 1 order 240 #steps to recover. 239 241 self.minimum_allowed_height = minimum_allowed_height 240 242 self.H0 = minimum_allowed_height … … 262 264 self.points_file_block_line_size = points_file_block_line_size 263 265 266 264 267 def set_quantities_to_be_stored(self, q): 265 268 """Specify which quantities will be stored in the sww file. … … 286 289 q = [q] # Turn argument into a list 287 290 288 # Check correcness291 # Check correcness 289 292 for quantity_name in q: 290 293 msg = 'Quantity %s is not a valid conserved quantity'\ … … 930 933 #MH090605 if second order, 931 934 #perform the extrapolation and limiting on 932 #all of the conserved quantitie 935 #all of the conserved quantities 933 936 934 937 if (domain._order_ == 1): … … 944 947 for name in domain.conserved_quantities: 945 948 Q = domain.quantities[name] 949 946 950 if domain._order_ == 1: 947 951 Q.extrapolate_first_order() 948 952 elif domain._order_ == 2: 953 954 # Experiment 955 #if name == 'stage': 956 # #print name, 'second' 957 # Q.extrapolate_second_order() 958 # Q.limit() 959 #else: 960 # #print name, 'first' 961 # Q.extrapolate_first_order() 962 # #Q.extrapolate_second_order() 963 # #Q.limit() 964 949 965 Q.extrapolate_second_order() 950 966 Q.limit() -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4699 r4701 59 59 ###################### 60 60 #Initial condition - with jumps 61 62 63 61 bed = domain.quantities['elevation'].vertex_values 64 62 stage = zeros(bed.shape, Float) … … 233 231 self.domain.format = 'sww' 234 232 self.domain.smooth = True 235 236 sww = get_dataobject(self.domain) 237 sww.store_connectivity() 233 sww = get_dataobject(self.domain) 234 238 235 for t in self.domain.evolve(yieldstep = 1, finaltime = 1): 239 236 pass 240 237 241 #Get NetCDF 242 fid = NetCDFFile(sww.filename, 'r') #Open existing file for append 243 244 from anuga.shallow_water.shallow_water_domain import Domain 245 sww_quantities = Domain.conserved_quantities 238 # Get NetCDF 239 fid = NetCDFFile(sww.filename, 'r') # Open existing file for append 240 246 241 # Get the variables 247 242 range = fid.variables['stage_range'][:] 248 243 assert allclose(range,[-0.93519, 0.15]) or\ 249 244 allclose(range,[-0.9352743, 0.15]) # Old slope limiters 245 250 246 range = fid.variables['xmomentum_range'][:] 251 252 #assert allclose(range,[0,0.46950444])253 247 assert allclose(range,[0,0.4695096]) or\ 254 allclose(range,[0,0.47790655]) # Old slope limiters 248 allclose(range,[0,0.47790655]) # Old slope limiters 249 255 250 range = fid.variables['ymomentum_range'][:] 256 257 251 #assert allclose(range,[0,0.02174380]) 258 252 assert allclose(range,[0,0.02174439]) or\ 259 allclose(range,[0,0.02283983]) # Old slope limiters 253 allclose(range,[0,0.02283983]) # Old slope limiters 254 255 fid.close() 256 os.remove(sww.filename) 257 258 def NOtest_sww_extrema(self): 259 """Test that extrema of quantities can be retrieved at every vertex 260 Extrema are updated at every *internal* timestep 261 """ 262 263 domain = self.domain 264 265 domain.set_name('datatest' + str(id(self))) 266 domain.format = 'sww' 267 domain.smooth = True 268 269 assert domain.quantities_to_be_monitored is None 270 assert domain.monitor_polygon is None 271 assert domain.monitor_time_interval is None 272 273 domain.set_quantities_to_be_monitored(['stage', 'ymomentum']) 274 275 assert len(domain.quantities_to_be_monitored) == 2 276 assert domain.quantities_to_be_monitored[0] == 'stage' 277 assert domain.quantities_to_be_monitored[1] == 'ymomentum' 278 assert domain.monitor_polygon is None 279 assert domain.monitor_time_interval is None 280 281 sww = get_dataobject(domain) 282 283 for t in domain.evolve(yieldstep = 1, finaltime = 1): 284 print domain.timestepping_statistics() 285 print domain.quantity_statistics() 286 287 288 # Get NetCDF 289 fid = NetCDFFile(sww.filename, 'r') # Open existing file for append 290 291 # Get the variables 292 extrema = fid.variables['stage_extrema'][:] 293 assert allclose(range, []) 294 295 extrema = fid.variables['xmomentum_extrema'][:] 296 assert allclose(range,[]) 297 298 extrema = fid.variables['ymomentum_extrema'][:] 299 assert allclose(range,[]) 300 260 301 261 302 fid.close()
Note: See TracChangeset
for help on using the changeset viewer.