Changeset 5776


Ignore:
Timestamp:
Sep 20, 2008, 12:18:08 AM (14 years ago)
Author:
ole
Message:

Optimised get_energy_through_cross_section

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
2 edited

Legend:

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

    r5736 r5776  
    10061006
    10071007
    1008     def get_interpolated_values(self, interpolation_points):
     1008    def get_interpolated_values(self, interpolation_points,
     1009                                verbose=False):
    10091010        """ Get values at interpolation points
    10101011       
     
    10471048                                         axis=1)
    10481049
    1049         can_reuse = False
    1050         if hasattr(self, 'interpolation_object'):
    1051             # Reuse to save time
    1052             I = self.interpolation_object
    1053 
    1054             if allclose(interpolation_points.shape,
    1055                         I._point_coordinates.shape):
    1056                 if allclose(interpolation_points, I._point_coordinates):
    1057                     can_reuse = True
    1058                
    1059 
    1060         if can_reuse is True:
    1061             # Use absence of points to indicate reuse in I.interpolate
    1062             result = I.interpolate(vertex_values)
    1063         else:   
    1064             from anuga.fit_interpolate.interpolate import Interpolate
    1065 
    1066             # Create interpolation object with matrix
    1067             I = Interpolate(vertex_coordinates, triangles)
    1068             self.interpolation_object = I
    1069 
    1070             # Call interpolate with points the first time
    1071             interpolation_points = ensure_numeric(interpolation_points, Float)
    1072             result = I.interpolate(vertex_values, interpolation_points)     
    1073 
    1074         return result
    1075 
    1076 
    1077     def get_values(self, interpolation_points=None,
     1050        # Use caching to reuse interpolation information
     1051        from anuga.fit_interpolate.interpolate import interpolate
     1052        return interpolate(vertex_coordinates, triangles, vertex_values, interpolation_points,
     1053                           use_cache=True,
     1054                           verbose=verbose)
     1055
     1056
     1057    def get_values(self,
     1058                   interpolation_points=None,
    10781059                   location='vertices',
    1079                    indices = None):
     1060                   indices=None,
     1061                   verbose=False):
    10801062        """get values for quantity
    10811063
     
    11191101        #              polygon into get_values. The question becomes how
    11201102        #              resulting values should be ordered.
     1103       
     1104        if verbose is True:
     1105            print 'Getting values from %s' %location
    11211106
    11221107        if interpolation_points is not None:
    1123             return self.get_interpolated_values(interpolation_points)
     1108            return self.get_interpolated_values(interpolation_points,
     1109                                                verbose=verbose)
    11241110       
    11251111       
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r5729 r5776  
    23102310        answer = quantity.get_values(location='centroids')
    23112311        #print answer
    2312         #print quantity.get_values(points=interpolation_points)
    2313         assert allclose(answer, quantity.get_values(interpolation_points=interpolation_points))       
     2312        #print quantity.get_values(interpolation_points=interpolation_points)
     2313        assert allclose(answer, quantity.get_values(interpolation_points=interpolation_points,
     2314                                                    verbose=False))       
    23142315                       
    23152316
Note: See TracChangeset for help on using the changeset viewer.