Changeset 5864
- Timestamp:
- Oct 24, 2008, 5:03:31 PM (16 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r5863 r5864 16 16 17 17 from Numeric import array, zeros, Float, less, concatenate, NewAxis,\ 18 argmax, argmin, allclose, take, reshape 18 argmax, argmin, allclose, take, reshape, alltrue 19 19 20 20 from anuga.utilities.numerical_tools import ensure_numeric, is_scalar … … 1029 1029 1030 1030 1031 1032 def get_interpolated_values(self, interpolation_points, 1031 def obsolete_get_interpolated_values(self, interpolation_points, 1033 1032 verbose=False): 1034 1033 """ Get values at interpolation points … … 1075 1074 # Use caching to reuse interpolation information 1076 1075 from anuga.fit_interpolate.interpolate import interpolate 1076 1077 return interpolate(vertex_coordinates, 1078 triangles, 1079 vertex_values, 1080 interpolation_points, 1081 use_cache=True, 1082 verbose=verbose) 1083 1084 1085 1086 def get_interpolated_values(self, interpolation_points, 1087 verbose=False): 1088 """ Get values at interpolation points 1089 1090 If interpolation points have been given previously, the 1091 associated matrices will be reused to save time. 1092 1093 The argument interpolation points must be given as either a 1094 list of absolute UTM coordinates or a geospatial data object. 1095 """ 1096 1097 # FIXME (Ole): Could do with an input check (should be generalised 1098 # and used widely) 1099 # That will check that interpolation points is either a list of 1100 # points, Nx2 array, or geospatial 1101 1102 # Ensure points are converted to coordinates relative to mesh origin 1103 # FIXME (Ole): This could all be refactored using the 1104 # 'change_points_geo_ref' method of Class geo_reference. 1105 # The purpose is to make interpolation points relative 1106 # to the mesh origin. 1107 # 1108 # Speed is also a consideration here. 1109 1110 # FIXME (Ole): The reuse of I is a little rough, but it sure does speed up 1111 # frequent interpolations such as those found in culvert_class. 1112 1113 use_cache = True 1114 1115 # Get internal (discontinuous) triangles for use with the 1116 # interpolation object. 1117 x, y, vertex_values, triangles = self.get_vertex_values(xy=True, 1118 smooth=False) 1119 # FIXME (Ole): This concat should roll into get_vertex_values 1120 vertex_coordinates = concatenate((x[:, NewAxis], y[:, NewAxis]), 1121 axis=1) 1122 1123 1124 if isinstance(interpolation_points, Geospatial_data): 1125 # Ensure interpolation points are in absolute UTM coordinates 1126 interpolation_points = interpolation_points.get_data_points(absolute=True) 1127 1128 # Reconcile interpolation points with georeference of domain 1129 interpolation_points = self.domain.geo_reference.get_relative(interpolation_points) 1130 interpolation_points = ensure_numeric(interpolation_points) 1131 1132 # Check if same interpolation points have been used before 1133 if hasattr(self, 'stored_I') and\ 1134 alltrue(interpolation_points == self.stored_interpolation_points): 1135 I = self.stored_I 1136 else: 1137 1138 # Use caching to reuse interpolation information 1139 from anuga.fit_interpolate.interpolate import Interpolate 1140 from anuga.caching import cache 1141 1142 1143 # Create interpolation object with matrix 1144 args = (ensure_numeric(vertex_coordinates, Float), 1145 ensure_numeric(triangles)) 1146 1147 if use_cache is True: 1148 I = cache(Interpolate, args, 1149 verbose=verbose) 1150 else: 1151 I = apply(Interpolate, args) 1152 1153 self.stored_I = I 1154 self.stored_interpolation_points = interpolation_points 1155 1156 1157 1158 # Call interpolate method with interpolation points 1159 result = I.interpolate_block(vertex_values, interpolation_points, 1160 use_cache=use_cache, 1161 verbose=verbose) 1162 1163 return result 1164 1077 1165 1078 1166 return interpolate(vertex_coordinates, -
anuga_core/source/anuga/culvert_flows/Test_Culvert_Flat_Water_Lev.py
r5862 r5864 158 158 #------------------------------------------------------------------------------ 159 159 160 #for t in domain.evolve(yieldstep = 0.01, finaltime = 45):161 #if int(domain.time*100) % 100 == 0:162 #domain.write_time()160 for t in domain.evolve(yieldstep = 0.01, finaltime = 45): 161 if int(domain.time*100) % 100 == 0: 162 domain.write_time() 163 163 164 164 165 166 167 import sys; sys.exit() 165 168 # Profiling code 166 169 import time -
anuga_core/source/anuga/fit_interpolate/interpolate.py
r5863 r5864 373 373 See interpolate for doc info. 374 374 """ 375 if isinstance(point_coordinates, Geospatial_data):375 if isinstance(point_coordinates, Geospatial_data): 376 376 point_coordinates = point_coordinates.get_data_points(\ 377 377 absolute=True)
Note: See TracChangeset
for help on using the changeset viewer.