Changeset 2491


Ignore:
Timestamp:
Mar 8, 2006, 1:39:11 PM (18 years ago)
Author:
ole
Message:

Changed domain.get_quantity() to return a quantity object rather than the values.
Updated tests accordingly

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • development/analytical solutions/Analytical_solution_Yoon_import_mesh.py

    r2229 r2491  
    128128    interp = Interpolation(tri_array,t_array,[points])
    129129
    130     stage = domain.get_quantity('stage')[n_point]
    131     xmomentum = domain.get_quantity('xmomentum')[n_point]
    132     ymomentum = domain.get_quantity('ymomentum')[n_point]
     130    stage = domain.get_quantity('stage').get_values()[n_point]
     131    xmomentum = domain.get_quantity('xmomentum').get_values()[n_point]
     132    ymomentum = domain.get_quantity('ymomentum').get_values()[n_point]
    133133
    134134    interp_stage = interp.interpolate([[stage[0]],[stage[1]],[stage[2]]])
  • documentation/user_manual/anuga_user_manual.tex

    r2486 r2491  
    2929
    3030%Draft date
    31 \date{\today}                   % update before release!
     31\date{\today}   % update before release!
    3232                % Use an explicit date so that reformatting
    3333                % doesn't cause a new date to be used.  Setting
     
    3535                % stages to make it easier to handle versions.
    3636
    37 \release{1.0}           % release version; this is used to define the
     37\release{1.0}   % release version; this is used to define the
    3838                % \version macro
    3939
  • inundation/pyvolution/domain.py

    r2380 r2491  
    196196
    197197    def get_quantity(self, name, location='vertices', indices = None):
    198         """Get values for named quantity
     198        """Get quantity object.
    199199
    200200        name: Name of quantity
    201201
    202         In case of location == 'centroids' the dimension values must
    203         be a list of a Numerical array of length N, N being the number
    204         of elements. Otherwise it must be of dimension Nx3.
    205 
    206         Indices is the set of element ids that the operation applies to.
    207 
    208         The values will be stored in elements following their
    209         internal ordering.
    210         """
    211 
    212         return self.quantities[name].get_values( location, indices = indices)
     202        See methods inside the quantity object for more options
     203        """
     204
     205        return self.quantities[name] #.get_values( location, indices = indices)
     206
    213207
    214208    def get_quantity_object(self, name):
     
    216210
    217211        name: Name of quantity
    218         """
    219 
     212
     213        FIXME: Obsolete
     214        """
     215
     216        print 'get_quantity_object has been deprecated. Please use get_quantity'
    220217        return self.quantities[name]
    221218
  • inundation/pyvolution/quantity.py

    r2472 r2491  
    761761        Indices is the set of element ids that the operation applies to.
    762762
     763        The values will be stored in elements following their
     764        internal ordering.       
     765
    763766        """
    764767        from Numeric import take
  • inundation/pyvolution/region.py

    r1751 r2491  
    8484        """   
    8585        if tag == self.tag:
    86             new_values = domain.get_quantity(self.quantity_initial_value,
    87                           indices=self.build_indices(elements, domain),
    88                           location=self.location) + self.X
     86            #new_values = domain.get_quantity(self.quantity_initial_value,
     87            #              indices=self.build_indices(elements, domain),
     88            #              location=self.location) + self.X
     89
     90            Q = domain.get_quantity(self.quantity_initial_value)
     91            new_values = Q.get_values(indices=self.build_indices(elements, domain),
     92                                      location=self.location) + self.X           
    8993            domain.set_quantity(self.quantity_answer, new_values,
    9094                                indices=self.build_indices(elements, domain),
     
    111115        """   
    112116        if tag == self.tag:
     117
     118            #new_values = domain.get_quantity(self.quantity_answer,
     119            #              indices=self.build_indices(elements, domain),
     120            #              location=self.location) \
     121            #              + domain.get_quantity(self.adding_quantity,
     122            #              indices=self.build_indices(elements, domain),
     123            #              location=self.location)
     124
     125
     126
     127            indices = self.build_indices(elements, domain)
     128            location = self.location
     129            Q1 = domain.get_quantity(self.quantity_answer)
     130            Q2 = domain.get_quantity(self.adding_quantity)           
     131            new_values = Q1.get_values(indices=indices, location=location) +\
     132                         Q2.get_values(indices=indices, location=location)
     133
    113134           
    114             new_values = domain.get_quantity(self.quantity_answer,
    115                           indices=self.build_indices(elements, domain),
    116                           location=self.location) \
    117                           + domain.get_quantity(self.adding_quantity,
    118                           indices=self.build_indices(elements, domain),
    119                           location=self.location)
    120135            domain.set_quantity(self.quantity_answer, new_values,
    121136                                indices=self.build_indices(elements, domain),
  • inundation/pyvolution/test_data_manager.py

    r2305 r2491  
    22772277        elevation = domain.quantities['elevation'].vertex_values
    22782278        domain.set_quantity('stage', elevation + h)
    2279         #elevation = domain.get_quantity('elevation')
    2280         #domain.set_quantity('stage', elevation + h)
    22812279
    22822280        domain.check_integrity()
     
    23072305        bits = ['vertex_coordinates']
    23082306        for quantity in ['elevation']+domain.quantities_to_be_stored:
    2309             bits.append('quantities["%s"].get_integral()'%quantity)
    2310             bits.append('get_quantity("%s")'%quantity)
     2307            bits.append('get_quantity("%s").get_integral()' %quantity)
     2308            bits.append('get_quantity("%s").get_values()' %quantity)
    23112309
    23122310        for bit in bits:
     
    23682366
    23692367        for quantity in ['elevation','xmomentum','ymomentum']:#+domain.quantities_to_be_stored:
    2370             bits.append('quantities["%s"].get_integral()'%quantity)
    2371             bits.append('get_quantity("%s")'%quantity)
     2368            bits.append('get_quantity("%s").get_integral()' %quantity)
     2369            bits.append('get_quantity("%s").get_values()' %quantity)
    23722370
    23732371        for bit in bits:
     
    24502448
    24512449        for quantity in ['elevation']+domain.quantities_to_be_stored:
    2452             bits.append('quantities["%s"].get_integral()'%quantity)
    2453             bits.append('get_quantity("%s")'%quantity)
     2450            bits.append('get_quantity("%s").get_integral()' %quantity)
     2451            bits.append('get_quantity("%s").get_values()' %quantity)
    24542452
    24552453        for bit in bits:
     
    24572455            assert allclose(eval('domain.'+bit),eval('domain2.'+bit))
    24582456
    2459         assert max(max(domain2.get_quantity('xmomentum')))==filler
    2460         assert min(min(domain2.get_quantity('xmomentum')))==filler
    2461         assert max(max(domain2.get_quantity('ymomentum')))==filler
    2462         assert min(min(domain2.get_quantity('ymomentum')))==filler
     2457        assert max(max(domain2.get_quantity('xmomentum').get_values()))==filler
     2458        assert min(min(domain2.get_quantity('xmomentum').get_values()))==filler
     2459        assert max(max(domain2.get_quantity('ymomentum').get_values()))==filler
     2460        assert min(min(domain2.get_quantity('ymomentum').get_values()))==filler
    24632461
    24642462
     
    25262524        elevation = domain.quantities['elevation'].vertex_values
    25272525        domain.set_quantity('stage', elevation + h)
    2528         #elevation = domain.get_quantity('elevation')
    2529         #domain.set_quantity('stage', elevation + h)
     2526
    25302527
    25312528        domain.check_integrity()
     
    25592556        for quantity in ['elevation']+domain.quantities_to_be_stored:
    25602557            bits.append('quantities["%s"].get_integral()'%quantity)
    2561             #bits.append('get_quantity("%s")'%quantity)
     2558
    25622559
    25632560        for bit in bits:
     
    26162613        ##################
    26172614
     2615        print '><><><><>>'
    26182616        bits = [ 'vertex_coordinates']
    26192617
    26202618        for quantity in ['elevation','xmomentum','ymomentum']:#+domain.quantities_to_be_stored:
    26212619            #bits.append('quantities["%s"].get_integral()'%quantity)
    2622             bits.append('get_quantity("%s")'%quantity)
     2620            bits.append('get_quantity("%s").get_values()' %quantity)
    26232621
    26242622        for bit in bits:
  • inundation/pyvolution/test_domain.py

    r1928 r2491  
    2626
    2727def set_all_friction(tag, elements, domain):
    28     if tag == "all":
    29         new_values = domain.get_quantity('friction', indices = elements) + 10.0
     28    if tag == 'all':
     29        new_values = domain.get_quantity('friction').get_values(indices = elements) + 10.0
    3030
    3131        domain.set_quantity('friction', new_values, indices = elements)
Note: See TracChangeset for help on using the changeset viewer.