Changeset 2380


Ignore:
Timestamp:
Feb 13, 2006, 12:35:15 PM (18 years ago)
Author:
ole
Message:

Revisited profiling, cleaned up and added setter for spatial order

Location:
inundation/pyvolution
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/domain.py

    r2319 r2380  
    6060        #FIXME: Maybe have separate orders for h-limiter and w-limiter?
    6161        #Or maybe get rid of order altogether and use beta_w and beta_h
    62         self.default_order = 1
    63         self.order = self.default_order
     62        self.set_default_order(1)       
     63        #self.default_order = 1
     64        #self.order = self.default_order
     65
    6466        self.smallsteps = 0
    6567        self.max_smallsteps = max_smallsteps
     
    9294        N=self.number_of_elements
    9395        self.already_computed_flux = zeros((N, 3), Int)
     96
     97
     98    def set_default_order(self, n):
     99        """Set default (spatial) order to either 1 or 2
     100        """
     101
     102        msg = 'Default order must be either 1 or 2. I got %s' %n
     103        assert n in [1,2], msg
     104       
     105        self.default_order = n
     106        self.order = self.default_order
     107
    94108
    95109    #Public interface to Domain
     
    197211
    198212        return self.quantities[name].get_values( location, indices = indices)
     213
     214    def get_quantity_object(self, name):
     215        """Get object for named quantity
     216
     217        name: Name of quantity
     218        """
     219
     220        return self.quantities[name]
    199221
    200222
  • inundation/pyvolution/run_profile.py

    r1629 r2380  
    11"""Example of shallow water wave equation.
    22
    3 This version is for profiling
    4 (The original)
     3This version is for profiling of timestepping
    54"""
    65
    76######################
    87# Module imports
    9 #
    10 from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
    11      Transmissive_boundary, Time_boundary,\
    12      Weir_simple as Weir, Constant_height
    13 
     8from shallow_water import Domain, Reflective_boundary
    149from mesh_factory import rectangular
    1510from Numeric import array
     
    1813######################
    1914# Domain
    20 #
    2115
    22 N = 128
     16#N = 16   #Should take less than 0.1 s
     17#N = 64  #Should take less than 3s
     18N = 128  #Should take less than 20s
     19
    2320
    2421print 'Creating domain'
     
    2825#Create shallow water domain
    2926domain = Domain(points, vertices, boundary)
    30 domain.default_order = 2
    31 #domain.visualise = True
     27domain.set_default_order(2)       
     28domain.set_quantities_to_be_stored(None)
    3229
    3330
    34 print 'Field values'
     31print 'Setting initial conditions'
     32
    3533def slope(x, y):
    3634    return -x
    3735
    3836domain.set_quantity('elevation', slope)
    39 domain.set_quantity('friction', 0.3)
     37domain.set_quantity('friction', 0.03)
     38domain.set_quantity('stage', expression = 'elevation + 0.5')
    4039
    4140
    42 # Boundary conditions
    43 #
     41
     42print 'Setting boundary conditions'
    4443Br = Reflective_boundary(domain)
    4544domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
    4645
    4746
    48 ######################
    49 #Initial condition
    50 domain.set_quantity('stage', Constant_height(slope, 0.3))
    51 
     47print 'Checking integrity'
    5248domain.check_integrity()
    5349
     
    6056
    6157s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
    62 
    6358
    6459
  • inundation/pyvolution/run_profile2.py

    r1592 r2380  
    33This version is for profiling
    44(The original)
     5
     6
     7FIXME: This should really measure something else, such as profiling the set up of domains.
    58"""
    69
     
    2932domain = Domain(points, vertices, boundary)
    3033domain.default_order = 2
     34domain.set_quantities_to_be_stored(None)
    3135#domain.visualise = True
    3236
Note: See TracChangeset for help on using the changeset viewer.