- Timestamp:
- Nov 8, 2006, 5:35:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r3928 r3945 16 16 17 17 from Numeric import array, zeros, Float, less, concatenate, NewAxis, argmax, allclose 18 from anuga.utilities.numerical_tools import ensure_numeric 18 from anuga.utilities.numerical_tools import ensure_numeric, is_scalar 19 19 20 20 class Quantity: … … 558 558 is_subset = True 559 559 560 561 # FIXME (Ole): Now we can compute the arrays once and for all 562 # for both centroids and vertices and the use set_values_from_array 563 560 564 if location == 'centroids': 561 P= take(self.domain.centroid_coordinates, indices)565 V = take(self.domain.centroid_coordinates, indices) 562 566 if is_subset: 563 self.set_values(f( P[:,0], P[:,1]),567 self.set_values(f(V[:,0], V[:,1]), 564 568 location = location, 565 569 indices = indices) 566 570 else: 567 self.set_values(f( P[:,0], P[:,1]), location = location)571 self.set_values(f(V[:,0], V[:,1]), location = location) 568 572 elif location == 'vertices': 569 P = self.domain.vertex_coordinates 573 V = self.domain.get_vertex_coordinates() 574 575 x = V[:,0]; y = V[:,1]; 576 values = f(x, y) 577 578 if is_scalar(values): 579 # Function returned a constant value 580 self.set_values_from_constant(values, 581 location, indices, verbose) 582 return 583 584 570 585 if is_subset: 571 586 #Brute force 572 for ein indices:573 for iin range(3):574 self.vertex_values[ e,i] = f(P[e,2*i], P[e,2*i+1])587 for i in indices: 588 for j in range(3): 589 self.vertex_values[i,j] = values[3*i+j] 575 590 else: 576 for iin range(3):577 self.vertex_values[:, i] = f(P[:,2*i], P[:,2*i+1])591 for j in range(3): 592 self.vertex_values[:,j] = values[j::3] 578 593 else: 579 594 raise 'Not implemented: %s' %location … … 625 640 raise ms 626 641 627 coordinates = self.domain. coordinates628 triangles = self.domain.triangles 642 coordinates = self.domain.get_nodes() 643 triangles = self.domain.triangles #FIXME 629 644 630 645 … … 910 925 elif location == 'unique vertices': 911 926 if (indices == None): 912 indices=range(self.domain. coordinates.shape[0])927 indices=range(self.domain.number_of_nodes) 913 928 vert_values = [] 914 929 #Go through list of unique vertices … … 958 973 959 974 if indices == None: 960 assert A.shape[0] == self.domain. coordinates.shape[0]975 assert A.shape[0] == self.domain.get_nodes().shape[0] 961 976 vertex_list = range(A.shape[0]) 962 977 else: … … 1085 1100 1086 1101 if xy is True: 1087 X = self.domain. coordinates[:,0].astype(precision)1088 Y = self.domain. coordinates[:,1].astype(precision)1102 X = self.domain.get_nodes()[:,0].astype(precision) 1103 Y = self.domain.get_nodes()[:,1].astype(precision) 1089 1104 1090 1105 return X, Y, A, V … … 1389 1404 from Numeric import zeros, Float 1390 1405 1391 N = len(quantity.domain)1406 N = quantity.domain.number_of_nodes 1392 1407 1393 1408 beta_w = quantity.domain.beta_w
Note: See TracChangeset
for help on using the changeset viewer.