Changeset 6174
- Timestamp:
- Jan 15, 2009, 11:03:42 AM (16 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py
r6166 r6174 185 185 # - Stored as six floats n0x,n0y,n1x,n1y,n2x,n2y per triangle 186 186 187 n0 = num.array([x2 - x1, y2 - y1] )187 n0 = num.array([x2 - x1, y2 - y1], num.Float) 188 188 l0 = num.sqrt(num.sum(n0**2)) 189 189 190 n1 = num.array([x0 - x2, y0 - y2] )190 n1 = num.array([x0 - x2, y0 - y2], num.Float) 191 191 l1 = num.sqrt(num.sum(n1**2)) 192 192 193 n2 = num.array([x1 - x0, y1 - y0] )193 n2 = num.array([x1 - x0, y1 - y0], num.Float) 194 194 l2 = num.sqrt(num.sum(n2**2)) 195 195 … … 273 273 if not self.geo_reference.is_absolute(): 274 274 return V + num.array([self.geo_reference.get_xllcorner(), 275 self.geo_reference.get_yllcorner()] )275 self.geo_reference.get_yllcorner()], num.Float) 276 276 else: 277 277 return V … … 315 315 if absolute is True and not self.geo_reference.is_absolute(): 316 316 offset=num.array([self.geo_reference.get_xllcorner(), 317 self.geo_reference.get_yllcorner()] )317 self.geo_reference.get_yllcorner()], num.Float) 318 318 return num.array([V[i3,:]+offset, 319 319 V[i3+1,:]+offset, 320 V[i3+2,:]+offset] )320 V[i3+2,:]+offset], num.Float) 321 321 else: 322 return num.array([V[i3,:], V[i3+1,:], V[i3+2,:]] )322 return num.array([V[i3,:], V[i3+1,:], V[i3+2,:]], num.Float) 323 323 324 324 -
anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r6173 r6174 200 200 201 201 # Compute midpoints 202 if edge_id == 0: m = num.array([(x1 + x2)/2, (y1 + y2)/2] )203 if edge_id == 1: m = num.array([(x0 + x2)/2, (y0 + y2)/2] )204 if edge_id == 2: m = num.array([(x1 + x0)/2, (y1 + y0)/2] )202 if edge_id == 0: m = num.array([(x1 + x2)/2, (y1 + y2)/2], num.Float) 203 if edge_id == 1: m = num.array([(x0 + x2)/2, (y0 + y2)/2], num.Float) 204 if edge_id == 2: m = num.array([(x1 + x0)/2, (y1 + y0)/2], num.Float) 205 205 206 206 # Convert to absolute UTM coordinates -
anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r6166 r6174 124 124 125 125 #Compute centroid 126 centroid = num.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3] )126 centroid = num.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3], num.Float) 127 127 self.centroid_coordinates[i] = centroid 128 128 … … 133 133 134 134 #Midpoints 135 m0 = num.array([(x1 + x2)/2, (y1 + y2)/2] )136 m1 = num.array([(x0 + x2)/2, (y0 + y2)/2] )137 m2 = num.array([(x1 + x0)/2, (y1 + y0)/2] )135 m0 = num.array([(x1 + x2)/2, (y1 + y2)/2], num.Float) 136 m1 = num.array([(x0 + x2)/2, (y0 + y2)/2], num.Float) 137 m2 = num.array([(x1 + x0)/2, (y1 + y0)/2], num.Float) 138 138 139 139 #The radius is the distance from the centroid of … … 1136 1136 1137 1137 # Distances from line origin to the two intersections 1138 z0 = num.array([x0 - xi0, y0 - eta0] )1139 z1 = num.array([x1 - xi0, y1 - eta0] )1138 z0 = num.array([x0 - xi0, y0 - eta0], num.Float) 1139 z1 = num.array([x1 - xi0, y1 - eta0], num.Float) 1140 1140 d0 = num.sqrt(num.sum(z0**2)) 1141 1141 d1 = num.sqrt(num.sum(z1**2)) … … 1152 1152 # Normal direction: 1153 1153 # Right hand side relative to line direction 1154 vector = num.array([x1 - x0, y1 - y0] ) # Segment vector1154 vector = num.array([x1 - x0, y1 - y0], num.Float) # Segment vector 1155 1155 length = num.sqrt(num.sum(vector**2)) # Segment length 1156 normal = num.array([vector[1], -vector[0]] )/length1156 normal = num.array([vector[1], -vector[0]], num.Float)/length 1157 1157 1158 1158 … … 1234 1234 assert isinstance(segment, Triangle_intersection), msg 1235 1235 1236 midpoint = num.sum(num.array(segment.segment ))/21236 midpoint = num.sum(num.array(segment.segment, num.Float))/2 1237 1237 midpoints.append(midpoint) 1238 1238 -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r6166 r6174 1175 1175 sum += self.vertex_values[triangle_id, vertex_id] 1176 1176 vert_values.append(sum/len(triangles)) 1177 return num.array(vert_values )1177 return num.array(vert_values, num.Float) 1178 1178 else: 1179 1179 if (indices is None): -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py
r6145 r6174 345 345 346 346 347 A = num.array([[1,2,3], [5,5,-5], [0,0,9], [-6,3,3]], 'f')348 B = num.array([[2,4,4], [3,2,1], [6,-3,4], [4,5,-1]], 'f')347 A = num.array([[1,2,3], [5,5,-5], [0,0,9], [-6,3,3]], num.Float) 348 B = num.array([[2,4,4], [3,2,1], [6,-3,4], [4,5,-1]], num.Float) 349 349 350 350 #print A -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py
r6145 r6174 59 59 60 60 #bac, bce, ecf, dbe, daf, dae 61 triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]] )61 triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.Int) 62 62 63 63 domain = General_mesh(nodes, triangles, -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_neighbour_mesh.py
r6145 r6174 22 22 23 23 def distance(x, y): 24 return sqrt( sum( (num.array(x)-num.array(y))**2))24 return sqrt(num.sum((num.array(x)-num.array(y))**2)) 25 25 26 26 class Test_Mesh(unittest.TestCase): -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r6145 r6174 1766 1766 quantity = Quantity(self.mesh4) 1767 1767 1768 quantity.vertex_values = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.Float)1768 quantity.vertex_values = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.Float) 1769 1769 1770 1770 quantity.interpolate_from_vertices_to_edges() … … 1782 1782 [3., 2.5, 1.5], 1783 1783 [3.5, 4.5, 3.], 1784 [2.5, 3.5, 2]], num.Float)1784 [2.5, 3.5, 2]], num.Float) 1785 1785 1786 1786 quantity.interpolate_from_edges_to_vertices() -
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r6173 r6174 2097 2097 #add tide to stage if provided 2098 2098 if quantity == 'stage': 2099 quantity_value[quantity] = num.array(quantity_value[quantity] ) \2099 quantity_value[quantity] = num.array(quantity_value[quantity], num.Float) \ 2100 2100 + directory_add_tide 2101 2101 -
anuga_core/source/anuga/alpha_shape/alpha_shape.py
r6166 r6174 242 242 ind3 = [self.deltri[j][2] for j in range(len(self.deltri))] 243 243 244 x1 = num.array([ x[j] for j in ind1])245 y1 = num.array([ y[j] for j in ind1])246 x2 = num.array([ x[j] for j in ind2])247 y2 = num.array([ y[j] for j in ind2])248 x3 = num.array([ x[j] for j in ind3])249 y3 = num.array([ y[j] for j in ind3])244 x1 = num.array([x[j] for j in ind1]) 245 y1 = num.array([y[j] for j in ind1]) 246 x2 = num.array([x[j] for j in ind2]) 247 y2 = num.array([y[j] for j in ind2]) 248 x3 = num.array([x[j] for j in ind3]) 249 y3 = num.array([y[j] for j in ind3]) 250 250 251 251 x21 = x2-x1 -
anuga_core/source/anuga/fit_interpolate/search_functions.py
r6152 r6174 22 22 num.array([max_float,max_float]), 23 23 num.array([max_float,max_float])), 24 (num.array([1,1]),num.array([0,0]),num.array([-1.1,-1.1]))]]] 24 (num.array([1,1], num.Int), #array default# 25 num.array([0,0], num.Int), #array default# 26 num.array([-1.1,-1.1]))]]] 25 27 26 28 def search_tree_of_vertices(root, mesh, x): -
anuga_core/source/anuga/fit_interpolate/test_fit.py
r6152 r6174 25 25 26 26 def distance(x, y): 27 return sqrt( sum( (num.array(x)-num.array(y))**2))27 return sqrt(num.sum((num.array(x)-num.array(y))**2)) 28 28 29 29 def linear_function(point): … … 582 582 583 583 #Define f(x,y) = x 584 f = num.array([0,0,2] ) #Value at global vertex 2584 f = num.array([0,0,2], num.Int) #Value at global vertex 2 #array default# 585 585 586 586 #Check that int (df/dx)**2 + (df/dy)**2 dx dy = … … 589 589 590 590 #Define f(x,y) = y 591 f = num.array([0,2,0] ) #Value at global vertex 1591 f = num.array([0,2,0], num.Int) #Value at global vertex 1 #array default# 592 592 593 593 #Check that int (df/dx)**2 + (df/dy)**2 dx dy = … … 596 596 597 597 #Define f(x,y) = x+y 598 f = num.array([0,2,2] ) #Values at global vertex 1 and 2598 f = num.array([0,2,2], num.Int) #Values at global vertex 1 and 2 #array default# 599 599 600 600 #Check that int (df/dx)**2 + (df/dy)**2 dx dy = … … 623 623 624 624 #Define f(x,y) = x 625 f = num.array([0,0,2,0,2,4] ) #f evaluated at points a-f625 f = num.array([0,0,2,0,2,4], num.Int) #f evaluated at points a-f #array default# 626 626 627 627 #Check that int (df/dx)**2 + (df/dy)**2 dx dy = … … 630 630 631 631 #Define f(x,y) = y 632 f = num.array([0,2,0,4,2,0] ) #f evaluated at points a-f632 f = num.array([0,2,0,4,2,0], num.Int) #f evaluated at points a-f #array default# 633 633 634 634 #Check that int (df/dx)**2 + (df/dy)**2 dx dy = … … 637 637 638 638 #Define f(x,y) = x+y 639 f = num.array([0,2,2,4,4,4] ) #f evaluated at points a-f639 f = num.array([0,2,2,4,4,4], num.Int) #f evaluated at points a-f #array default# 640 640 641 641 #Check that int (df/dx)**2 + (df/dy)**2 dx dy = -
anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r6170 r6174 29 29 30 30 def distance(x, y): 31 return sqrt( num.sum( (num.array(x)-num.array(y))**2))31 return sqrt(num.sum((num.array(x)-num.array(y))**2)) 32 32 33 33 def linear_function(point): … … 760 760 761 761 interp = Interpolate(vertices, triangles) 762 f = num.array([linear_function(vertices),2*linear_function(vertices) 762 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 763 763 f = num.transpose(f) 764 764 #print "f",f … … 803 803 804 804 interp = Interpolate(vertices, triangles) 805 f = num.array([linear_function(vertices),2*linear_function(vertices) 805 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 806 806 f = num.transpose(f) 807 807 #print "f",f … … 819 819 820 820 f = num.array([linear_function(vertices),2*linear_function(vertices), 821 2*linear_function(vertices) - 100 821 2*linear_function(vertices) - 100]) 822 822 f = num.transpose(f) 823 823 #print "f",f … … 829 829 answer = num.array([linear_function(point_coords), 830 830 2*linear_function(point_coords) , 831 2*linear_function(point_coords)-100 831 2*linear_function(point_coords)-100]) 832 832 z = num.transpose(z) 833 833 #print "z",z … … 865 865 866 866 interp = Interpolate(vertices, triangles) 867 f = num.array([linear_function(vertices),2*linear_function(vertices) 867 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 868 868 f = num.transpose(f) 869 869 #print "f",f … … 883 883 884 884 f = num.array([linear_function(vertices),2*linear_function(vertices), 885 2*linear_function(vertices) - 100 885 2*linear_function(vertices) - 100]) 886 886 f = num.transpose(f) 887 887 #print "f",f … … 896 896 absolute = True)) , 897 897 2*linear_function(point_coords.get_data_points( \ 898 absolute = True))-100 898 absolute = True))-100]) 899 899 z = num.transpose(z) 900 900 #print "z",z … … 938 938 939 939 interp = Interpolate(vertices, triangles) 940 f = num.array([linear_function(vertices),2*linear_function(vertices) 940 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 941 941 f = num.transpose(f) 942 942 #print "f",f … … 984 984 985 985 interp = Interpolate(vertices, triangles) 986 f = num.array([linear_function(vertices),2*linear_function(vertices) 986 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 987 987 f = num.transpose(f) 988 988 z = interp.interpolate(f, point_coords, … … 1047 1047 1048 1048 interp = Interpolate(vertices, triangles) 1049 f = num.array([linear_function(vertices), 2*linear_function(vertices)])1049 f = num.array([linear_function(vertices), 2*linear_function(vertices)]) 1050 1050 f = num.transpose(f) 1051 1051 z = interp.interpolate(f, point_coords) … … 1363 1363 1364 1364 interp = Interpolate(points, triangles) 1365 f = num.array([linear_function(points),2*linear_function(points) 1365 f = num.array([linear_function(points),2*linear_function(points)]) 1366 1366 f = num.transpose(f) 1367 1367 #print "f",f … … 1653 1653 1654 1654 interp = Interpolate(vertices, triangles) 1655 f = num.array([linear_function(vertices),2*linear_function(vertices) 1655 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 1656 1656 f = num.transpose(f) 1657 1657 #print "f",f -
anuga_core/source/anuga/mesh_engine/test_generate_mesh.py
r6155 r6174 43 43 pointattlist,segattlist, mode, points) 44 44 45 correct = num.array([(1, 0, 2), (2, 3, 1)] )45 correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int) #array default# 46 46 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 47 47 correct.flat), 48 48 'trianglelist is wrong!') 49 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] )49 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int) #array default# 50 50 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 51 51 correct.flat), … … 74 74 data = generate_mesh(points,seglist,holelist,regionlist, 75 75 pointattlist,segattlist, mode, points) 76 correct = num.array([(1, 0, 2), (2, 3, 1)] )76 correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int) #array default# 77 77 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 78 78 correct.flat), 79 79 'trianglelist is wrong!') 80 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] )80 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int) #array default# 81 81 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 82 82 correct.flat), … … 154 154 pointattlist,segattlist, mode, points) 155 155 156 correct = num.array([(1, 0, 2), (2, 3, 1)] )156 correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int) #array default# 157 157 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 158 158 correct.flat), 159 159 'trianglelist is wrong!') 160 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] )160 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int) #array default# 161 161 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 162 162 correct.flat), … … 170 170 171 171 self.failUnless(num.alltrue(data['generatedsegmentmarkerlist'] == \ 172 num.array([1,2,3,4] )),172 num.array([1,2,3,4], num.Int)), #array default# 173 173 'Failed!') 174 174 … … 388 388 389 389 390 correct = num.array([(1, 0, 2), (2, 3, 1)] )390 correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int) #array default# 391 391 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 392 392 correct.flat), 393 393 'trianglelist is wrong!') 394 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] )394 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int) #array default# 395 395 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 396 396 correct.flat), … … 407 407 correct.flat), 408 408 'Failed') 409 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] )409 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int) #array default# 410 410 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 411 411 correct.flat), 412 412 'Failed!') 413 413 414 correct = num.array(segattlist )414 correct = num.array(segattlist, num.Int) #array default# 415 415 self.failUnless(num.allclose(data['generatedsegmentmarkerlist'].flat, 416 416 correct.flat), … … 418 418 419 419 # I copied these answers from the output, so bad test.. 420 correct = num.array([(-1, 1, -1), (-1, 0, -1)] )420 correct = num.array([(-1, 1, -1), (-1, 0, -1)], num.Int) #array default# 421 421 self.failUnless(num.alltrue(data['generatedtriangleneighborlist'].flat == \ 422 422 correct.flat), -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r6173 r6174 4950 4950 4951 4951 ## 7th test 4952 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]] )4952 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]], num.Int) #array default# 4953 4953 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( 4954 4954 latitudes,longitudes, … … 5010 5010 longitudes = [148,149,150,151] 5011 5011 5012 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]] )5012 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]], num.Int) #array default# 5013 5013 5014 5014 # k - lat … … 10626 10626 10627 10627 # Check runup restricted to a polygon 10628 p = num.array([[50,1], [99,1], [99,49], [50,49]] ) + num.array([E, N])10628 p = num.array([[50,1], [99,1], [99,49], [50,49]], num.Int) + num.array([E, N], num.Int) #array default# 10629 10629 10630 10630 runup = get_maximum_inundation_elevation(swwfile, polygon=p) -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r6157 r6174 2 2 3 3 import unittest, os 4 from math import pi 4 from math import pi, sqrt 5 5 import tempfile 6 6 … … 254 254 #Check error check 255 255 try: 256 rotate(r, num.array([1,1,1] ) )256 rotate(r, num.array([1,1,1], num.Int)) #array default# 257 257 except: 258 258 pass … … 338 338 def test_flux3(self): 339 339 #Use data from previous version of abstract_2d_finite_volumes 340 normal = num.array([- num.sqrt(2)/2, num.sqrt(2)/2])340 normal = num.array([-sqrt(2)/2, sqrt(2)/2]) 341 341 ql = num.array([-0.075, 2, 3]) 342 342 qr = num.array([-0.075, 2, 3]) … … 347 347 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) 348 348 349 assert num.allclose(edgeflux, [ num.sqrt(2)/2, 4.40221112, 7.3829019])349 assert num.allclose(edgeflux, [sqrt(2)/2, 4.40221112, 7.3829019]) 350 350 assert num.allclose(max_speed, 4.0716654239) 351 351 352 352 def test_flux4(self): 353 353 #Use data from previous version of abstract_2d_finite_volumes 354 normal = num.array([- num.sqrt(2)/2, num.sqrt(2)/2])354 normal = num.array([-sqrt(2)/2, sqrt(2)/2]) 355 355 ql = num.array([-0.34319278, 0.10254161, 0.07273855]) 356 356 qr = num.array([-0.30683287, 0.1071986, 0.05930515]) -
anuga_core/source/anuga/utilities/numerical_tools.py
r6158 r6174 254 254 if type(A) == num.ArrayType: 255 255 if A.typecode == typecode: 256 return num.array(A) #FIXME: Shouldn't this just return A? 256 # return num.array(A) #FIXME: Shouldn't this just return A? 257 return A 257 258 else: 258 259 return num.array(A,typecode) -
anuga_core/source/anuga/utilities/test_numerical_tools.py
r6158 r6174 90 90 assert B[0] == 1.0 and B[1] == 2.0 and B[2] == 3.0 and B[3] == 4.0 91 91 92 A = num.array([1,2,3,4] )92 A = num.array([1,2,3,4], num.Int) #array default# 93 93 B = ensure_numeric(A) 94 94 assert type(B) == num.ArrayType … … 97 97 assert A is B #Same object 98 98 99 A = num.array([1,2,3,4] )99 A = num.array([1,2,3,4], num.Int) #array default# 100 100 B = ensure_numeric(A, num.Float) 101 101 assert type(B) == num.ArrayType -
anuga_core/source/anuga/utilities/test_sparse.py
r6158 r6174 86 86 87 87 #Right hand side column 88 v = num.array([[2,4],[3,4],[4,4]] )88 v = num.array([[2,4],[3,4],[4,4]], num.Int) #array default# 89 89 90 90 u = A*v[:,0] … … 104 104 105 105 #Right hand side matrix 106 v = num.array([[2,4],[3,4],[4,4]] )106 v = num.array([[2,4],[3,4],[4,4]], num.Int) #array default# 107 107 108 108 u = A*v
Note: See TracChangeset
for help on using the changeset viewer.