Changeset 4701


Ignore:
Timestamp:
Sep 4, 2007, 5:36:01 PM (17 years ago)
Author:
ole
Message:

Work towards ticket:192

Location:
anuga_core/source/anuga
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r4679 r4701  
    170170                       
    171171
    172         #Defaults
     172        # Defaults
    173173        from anuga.config import max_smallsteps, beta_w, beta_h, epsilon
    174174        from anuga.config import CFL
     
    180180       
    181181
    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_h
     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_h
    184184        self.set_default_order(1)
    185185        #self.default_order = 1
     
    195195       
    196196
    197         #Model time
     197        # Model time
    198198        self.time = 0.0
    199199        self.finaltime = None
     
    201201        self.starttime = 0 #Physical starttime if any (0 is 1 Jan 1970 00:00:00)
    202202
    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
    212210        from anuga.config import default_datadir
    213211        self.datadir = default_datadir
     
    215213        self.checkpoint = False
    216214
    217         #MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array,
    218         #to be used during the flux calculation
     215        # MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array,
     216        # to be used during the flux calculation
    219217        N = len(self) #number_of_triangles
    220218        self.already_computed_flux = zeros((N, 3), Int)
     
    301299
    302300        """
     301       
     302        # FIXME: Could we name this a bit more intuitively
     303        # E.g. set_quantities_from_dictionary
    303304        for key in quantity_dict.keys():
    304305            self.set_quantity(key, quantity_dict[key], location='vertices')
     
    544545
    545546
     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
    546606    #MISC
    547607    def check_integrity(self):
     
    742802
    743803        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
    744819
    745820
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r4687 r4701  
    173173        self.forcing_terms.append(gravity)
    174174
    175         #Stored output
     175        # Stored output
    176176        self.store = True
    177177        self.format = 'sww'
     
    179179        self.minimum_storable_height = minimum_storable_height
    180180        self.quantities_to_be_stored = ['stage','xmomentum','ymomentum']
     181       
    181182               
    182183
     
    234235
    235236        #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.
    239241        self.minimum_allowed_height = minimum_allowed_height
    240242        self.H0 = minimum_allowed_height   
     
    262264        self.points_file_block_line_size = points_file_block_line_size
    263265       
     266       
    264267    def set_quantities_to_be_stored(self, q):
    265268        """Specify which quantities will be stored in the sww file.
     
    286289            q = [q] # Turn argument into a list
    287290
    288         #Check correcness
     291        # Check correcness
    289292        for quantity_name in q:
    290293            msg = 'Quantity %s is not a valid conserved quantity'\
     
    930933        #MH090605 if second order,
    931934        #perform the extrapolation and limiting on
    932         #all of the conserved quantitie
     935        #all of the conserved quantities
    933936
    934937        if (domain._order_ == 1):
     
    944947        for name in domain.conserved_quantities:
    945948            Q = domain.quantities[name]
     949
    946950            if domain._order_ == 1:
    947951                Q.extrapolate_first_order()
    948952            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               
    949965                Q.extrapolate_second_order()
    950966                Q.limit()
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4699 r4701  
    5959        ######################
    6060        #Initial condition - with jumps
    61 
    62 
    6361        bed = domain.quantities['elevation'].vertex_values
    6462        stage = zeros(bed.shape, Float)
     
    233231        self.domain.format = 'sww'
    234232        self.domain.smooth = True
    235 
    236         sww = get_dataobject(self.domain)
    237         sww.store_connectivity()
     233        sww = get_dataobject(self.domain)       
     234
    238235        for t in self.domain.evolve(yieldstep = 1, finaltime = 1):
    239236            pass
    240237           
    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
    246241        # Get the variables
    247242        range = fid.variables['stage_range'][:]
    248243        assert allclose(range,[-0.93519, 0.15]) or\
    249244               allclose(range,[-0.9352743, 0.15]) # Old slope limiters
     245       
    250246        range = fid.variables['xmomentum_range'][:]
    251        
    252         #assert allclose(range,[0,0.46950444])
    253247        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       
    255250        range = fid.variables['ymomentum_range'][:]
    256        
    257251        #assert allclose(range,[0,0.02174380])
    258252        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
    260301       
    261302        fid.close()
Note: See TracChangeset for help on using the changeset viewer.