Changeset 5776
 Timestamp:
 Sep 20, 2008, 12:18:08 AM (15 years ago)
 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 1006 1006 1007 1007 1008 def get_interpolated_values(self, interpolation_points): 1008 def get_interpolated_values(self, interpolation_points, 1009 verbose=False): 1009 1010 """ Get values at interpolation points 1010 1011 … … 1047 1048 axis=1) 1048 1049 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, 1078 1059 location='vertices', 1079 indices = None): 1060 indices=None, 1061 verbose=False): 1080 1062 """get values for quantity 1081 1063 … … 1119 1101 # polygon into get_values. The question becomes how 1120 1102 # resulting values should be ordered. 1103 1104 if verbose is True: 1105 print 'Getting values from %s' %location 1121 1106 1122 1107 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) 1124 1110 1125 1111 
anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r5729 r5776 2310 2310 answer = quantity.get_values(location='centroids') 2311 2311 #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)) 2314 2315 2315 2316
Note: See TracChangeset
for help on using the changeset viewer.