Changeset 3928
- Timestamp:
- Nov 7, 2006, 1:13:03 PM (18 years ago)
- Location:
- anuga_core/source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r3926 r3928 47 47 processor=0, 48 48 numproc=1, 49 number_of_full_nodes= 0,50 number_of_full_triangles= 0):49 number_of_full_nodes=None, 50 number_of_full_triangles=None): 51 51 52 52 … … 87 87 88 88 # Initialise underlying mesh structure 89 Mesh.__init__(self, coordinates, triangles, boundary, 90 tagged_elements, geo_reference, use_inscribed_circle, 89 Mesh.__init__(self, coordinates, triangles, 90 boundary=boundary, 91 tagged_elements=tagged_elements, 92 geo_reference=geo_reference, 93 use_inscribed_circle=use_inscribed_circle, 94 number_of_full_nodes=number_of_full_nodes, 95 number_of_full_triangles=number_of_full_triangles, 91 96 verbose=verbose) 92 97 … … 136 141 self.numproc = numproc 137 142 138 self.number_of_full_nodes=number_of_full_nodes139 self.number_of_full_triangles=number_of_full_triangles140 141 143 142 144 # Setup Communication Buffers … … 156 158 # =1 for full 157 159 # =0 for ghost 158 N =self.number_of_elements160 N = len(self) #number_of_elements 159 161 self.tri_full_flag = ones(N, Int) 160 162 for i in self.ghost_recv_dict.keys(): … … 206 208 #MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array, 207 209 #to be used during the flux calculation 208 N =self.number_of_elements210 N = len(self) #number_of_triangles 209 211 self.already_computed_flux = zeros((N, 3), Int) 210 212 … … 923 925 from Numeric import ones, sum, equal, Float 924 926 925 N = self.number_of_elements927 N = len(self) #number_of_triangles 926 928 d = len(self.conserved_quantities) 927 929 -
anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py
r3689 r3928 56 56 #input 57 57 def __init__(self, coordinates, triangles, 58 number_of_full_nodes=None, 59 number_of_full_triangles=None, 58 60 geo_reference=None, 59 61 verbose=False): … … 65 67 origin is a 3-tuple consisting of UTM zone, easting and northing. 66 68 If specified coordinates are assumed to be relative to this origin. 69 70 71 number_of_full_nodes and number_of_full_triangles relate to 72 parallelism when each mesh has an extra layer of ghost points and 73 ghost triangles attached to the end of the two arrays. 74 In this case it is usefull to specify the number of real (called full) 75 nodes and triangles. If omitted they will default to all. 67 76 """ 68 77 … … 71 80 self.triangles = array(triangles,Int) 72 81 self.coordinates = array(coordinates,Float) 73 82 83 # Register number of elements and nodes 84 self.number_of_triangles = N = self.triangles.shape[0] 85 self.number_of_nodes = self.coordinates.shape[0] 86 87 88 89 if number_of_full_nodes is None: 90 self.number_of_full_nodes=self.number_of_nodes 91 else: 92 assert int(number_of_full_nodes) 93 self.number_of_full_nodes=number_of_full_nodes 94 95 96 if number_of_full_triangles is None: 97 self.number_of_full_triangles=self.number_of_triangles 98 else: 99 assert int(number_of_full_triangles) 100 self.number_of_full_triangles=number_of_full_triangles 101 102 103 #print self.number_of_full_nodes, self.number_of_nodes 104 #print self.number_of_full_triangles, self.number_of_triangles 105 106 74 107 75 108 # FIXME: this stores a geo_reference, but when coords are returned … … 94 127 assert max(max(self.triangles)) <= self.coordinates.shape[0], msg 95 128 96 97 # Register number of elements (N)98 self.number_of_elements = N = self.triangles.shape[0]99 129 100 130 # FIXME: Maybe move to statistics? … … 175 205 176 206 def __len__(self): 177 return self.number_of_elements 207 return self.number_of_triangles 208 178 209 179 210 def __repr__(self): … … 213 244 """ 214 245 246 N = self.number_of_full_nodes 247 215 248 if unique is True: 216 V = self.coordinates 249 V = self.coordinates[:N,:] 217 250 if absolute is True: 218 251 if not self.geo_reference.is_absolute(): … … 227 260 if not self.geo_reference.is_absolute(): 228 261 229 V0 = self.geo_reference.get_absolute(V[: ,0:2])230 V1 = self.geo_reference.get_absolute(V[: ,2:4])231 V2 = self.geo_reference.get_absolute(V[: ,4:6])262 V0 = self.geo_reference.get_absolute(V[:N,0:2]) 263 V1 = self.geo_reference.get_absolute(V[:N,2:4]) 264 V2 = self.geo_reference.get_absolute(V[:N,4:6]) 232 265 233 266 # This does double the memory need … … 262 295 #FIXME (Ole) - oh yes they should 263 296 264 N = self.number_of_ elements297 N = self.number_of_triangles 265 298 vertex_coordinates = zeros((N, 6), Float) 266 299 … … 279 312 """ 280 313 281 if (indices == None): 282 indices = range(len(self)) #len(self)=number of elements 314 N = self.number_of_full_triangles 315 316 if indices is None: 317 #indices = range(len(self)) #len(self)=number of elements 318 indices = range(N) 283 319 284 320 return take(self.triangles, indices) 321 285 322 286 323 #FIXME - merge these two (get_vertices and get_triangles) … … 314 351 return unique_verts.keys() 315 352 353 316 354 def build_vertexlist(self): 317 355 """Build vertexlist index by vertex ids and for each entry (point id) … … 327 365 328 366 vertexlist = [None]*len(self.coordinates) 329 for i in range(self.number_of_ elements):367 for i in range(self.number_of_triangles): 330 368 331 369 a = self.triangles[i, 0] -
anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r3689 r3928 67 67 tagged_elements=None, 68 68 geo_reference=None, 69 number_of_full_nodes=None, 70 number_of_full_triangles=None, 69 71 use_inscribed_circle=False, 70 72 verbose=False): … … 80 82 81 83 General_mesh.__init__(self, coordinates, triangles, 82 geo_reference, verbose=verbose) 84 number_of_full_nodes=\ 85 number_of_full_nodes, 86 number_of_full_triangles=\ 87 number_of_full_triangles, 88 geo_reference=geo_reference, 89 verbose=verbose) 83 90 84 91 if verbose: print 'Initialising mesh' 85 92 86 N = self.number_of_elements93 N = len(self) #Number_of_triangles 87 94 88 95 self.use_inscribed_circle = use_inscribed_circle … … 181 188 def set_to_inscribed_circle(self,safety_factor = 1): 182 189 #FIXME phase out eventually 183 N = self.number_of_ elements190 N = self.number_of_triangles 184 191 V = self.vertex_coordinates 185 192 … … 225 232 #to left hand side edge (facing neighbouring triangle) 226 233 227 N = self.number_of_elements234 N = len(self) #Number_of_triangles 228 235 neighbourdict = {} 229 236 for i in range(N): … … 289 296 """ 290 297 291 N = self.number_of_elements298 N = len(self) #Number of triangles 292 299 for i in range(N): 293 300 #Find all neighbouring volumes that are not boundaries … … 314 321 if boundary is None: 315 322 boundary = {} 316 for vol_id in range( self.number_of_elements):323 for vol_id in range(len(self)): 317 324 for edge_id in range(0, 3): 318 325 if self.neighbours[vol_id, edge_id] < 0: … … 330 337 331 338 #Check that all boundary segments are assigned a tag 332 for vol_id in range( self.number_of_elements):339 for vol_id in range(len(self)): 333 340 for edge_id in range(0, 3): 334 341 if self.neighbours[vol_id, edge_id] < 0: … … 374 381 375 382 msg = 'Not all elements exist. ' 376 assert max(tagged_elements[tag]) < self.number_of_elements, msg383 assert max(tagged_elements[tag]) < len(self), msg 377 384 #print "tagged_elements", tagged_elements 378 385 self.tagged_elements = tagged_elements … … 584 591 from anuga.utilities.numerical_tools import anglediff 585 592 586 N = self.number_of_elements593 N = len(self) 587 594 #Get x,y coordinates for all vertices for all triangles 588 595 V = self.get_vertex_coordinates() … … 732 739 str = '------------------------------------------------\n' 733 740 str += 'Mesh statistics:\n' 734 str += ' Number of triangles = %d\n' % self.number_of_elements741 str += ' Number of triangles = %d\n' %len(self) 735 742 str += ' Extent [m]:\n' 736 743 str += ' x in [%f, %f]\n' %(min(x), max(x)) -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r3918 r3928 29 29 30 30 if vertex_values is None: 31 N = domain.number_of_elements31 N = len(domain) # number_of_elements 32 32 self.vertex_values = zeros((N, 3), Float) 33 33 else: … … 42 42 %N 43 43 msg += 'number of elements in specified domain (%d).'\ 44 % domain.number_of_elements45 46 assert N == domain.number_of_elements, msg44 %len(domain) 45 46 assert N == len(domain), msg 47 47 48 48 self.domain = domain … … 1135 1135 """ 1136 1136 integral = 0 1137 for k in range( self.domain.number_of_elements):1137 for k in range(len(self.domain)): 1138 1138 area = self.domain.areas[k] 1139 1139 qc = self.centroid_values[k] … … 1165 1165 #flux calculations and forcing functions 1166 1166 1167 N = domain.number_of_elements1167 N = len(domain) # number_of_triangles 1168 1168 self.explicit_update = zeros(N, Float ) 1169 1169 self.semi_implicit_update = zeros(N, Float ) … … 1293 1293 1294 1294 #Check each triangle 1295 for k in range( quantity.domain.number_of_elements):1295 for k in range(len(quantity.domain)): 1296 1296 #Centroid coordinates 1297 1297 x, y = quantity.domain.centroid_coordinates[k] … … 1389 1389 from Numeric import zeros, Float 1390 1390 1391 N = quantity.domain.number_of_elements1391 N = len(quantity.domain) 1392 1392 1393 1393 beta_w = quantity.domain.beta_w -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py
r3927 r3928 28 28 domain = General_mesh(points, vertices) 29 29 30 print domain.__class__31 30 32 31 assert allclose(domain.get_vertex_coordinates(unique=True), domain.coordinates) -
anuga_core/source/anuga/advection/advection.py
r3567 r3928 169 169 from anuga.config import max_timestep 170 170 171 N = self.number_of_elements171 N = len(self) 172 172 173 173 neighbours = self.neighbours … … 260 260 from weave import converters 261 261 262 N = self.number_of_elements262 N = len(self) 263 263 264 264 -
anuga_core/source/anuga/shallow_water/data_manager.py
r3926 r3928 213 213 #Create filename 214 214 self.filename = create_filename(domain.get_datadir(), 215 domain.get_name(), extension)215 domain.get_name(), extension) 216 216 217 217 #print 'F', self.filename 218 218 self.timestep = 0 219 self.number_of_volumes = len(domain)220 219 self.domain = domain 220 221 222 223 # Exclude ghosts in case this is a parallel domain 224 self.number_of_nodes = domain.number_of_full_nodes 225 self.number_of_volumes = domain.number_of_full_triangles 226 #self.number_of_volumes = len(domain) 227 228 221 229 222 230 … … 277 285 if hasattr(domain, 'texture'): 278 286 fid.texture = domain.texture 279 #else:287 #else: 280 288 # fid.texture = 'None' 281 289 … … 291 299 if domain.smooth is True: 292 300 fid.createDimension('number_of_points', len(domain.vertexlist)) 301 #fid.createDimension('number_of_points', self.number_of_nodes) 302 303 # FIXME(Ole): This will cause sww files for paralle domains to 304 # have ghost nodes stored (but not used by triangles). 305 # To clean this up, we have to change get_vertex_values and friends in 306 # quantity.py (but I can't be bothered right now) 293 307 else: 294 308 fid.createDimension('number_of_points', 3*self.number_of_volumes) -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r3926 r3928 112 112 processor=0, 113 113 numproc=1, 114 number_of_full_nodes= 0,115 number_of_full_triangles= 0):114 number_of_full_nodes=None, 115 number_of_full_triangles=None): 116 116 117 117 … … 746 746 import sys 747 747 748 N = domain.number_of_elements748 N = len(domain) # number_of_triangles 749 749 750 750 #Shortcuts … … 820 820 import sys 821 821 822 N = domain.number_of_elements822 N = len(domain) # number_of_triangles 823 823 824 824 #Shortcuts … … 848 848 import sys 849 849 850 N = domain.number_of_elements850 N = len(domain) # number_of_triangles 851 851 852 852 #Shortcuts … … 960 960 961 961 #Update 962 #FIXME: Modify acc roditg to c-version - or discard altogether.963 for k in range( domain.number_of_elements):962 #FIXME: Modify according to c-version - or discard altogether. 963 for k in range(len(domain)): 964 964 965 965 if hc[k] < domain.minimum_allowed_height: … … 999 999 """ 1000 1000 1001 N = domain.number_of_elements1001 N = len(domain) 1002 1002 beta_h = domain.beta_h 1003 1003 … … 1069 1069 """ 1070 1070 1071 N = domain.number_of_elements1071 N = len(domain) # number_of_triangles 1072 1072 beta_h = domain.beta_h 1073 1073 … … 1114 1114 hvbar = h_limiter(domain) 1115 1115 1116 for k in range( domain.number_of_elements):1116 for k in range(len(domain)): 1117 1117 #Compute maximal variation in bed elevation 1118 1118 # This quantitiy is … … 1402 1402 g = domain.g 1403 1403 1404 for k in range( domain.number_of_elements):1404 for k in range(len(domain)): 1405 1405 avg_h = sum( h[k,:] )/3 1406 1406 … … 1454 1454 ymom_update = domain.quantities['ymomentum'].semi_implicit_update 1455 1455 1456 N = domain.number_of_elements1456 N = len(domain) 1457 1457 eps = domain.minimum_allowed_height 1458 1458 g = domain.g … … 1489 1489 ymom_update = ymom.semi_implicit_update 1490 1490 1491 N = domain.number_of_elements1491 N = len(domain) 1492 1492 eps = domain.minimum_allowed_height 1493 1493 g = domain.g … … 1516 1516 ymom_update = ymom.explicit_update 1517 1517 1518 N = domain.number_of_elements1518 N = len(domain) 1519 1519 eps = domain.minimum_allowed_height 1520 1520 g = domain.g … … 1543 1543 ymom_update = domain.quantities['ymomentum'].semi_implicit_update 1544 1544 1545 N = domain.number_of_elements1545 N = len(domain) # number_of_triangles 1546 1546 eps = domain.minimum_allowed_height 1547 1547 g = domain.g #Not necessary? Why was this added? … … 1681 1681 ymom_update = domain.quantities['ymomentum'].explicit_update 1682 1682 1683 N = domain.number_of_elements1683 N = len(domain) # number_of_triangles 1684 1684 t = domain.time 1685 1685 … … 1767 1767 #Computed linear combination between constant stages and and 1768 1768 #stages parallel to the bed elevation. 1769 for k in range( domain.number_of_elements):1769 for k in range(len(domain)): 1770 1770 #Compute maximal variation in bed elevation 1771 1771 # This quantitiy is … … 2034 2034 from Numeric import zeros, Float 2035 2035 2036 N = domain.number_of_elements2036 N = len(domain) # number_of_triangles 2037 2037 2038 2038 #Shortcuts -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r3847 r3928 1311 1311 const = eta_w*rho_a/rho_w 1312 1312 1313 N = domain.number_of_elements1313 N = len(domain) # number_of_triangles 1314 1314 1315 1315 xc = domain.get_centroid_coordinates() … … 1427 1427 const = eta_w*rho_a/rho_w 1428 1428 1429 N = domain.number_of_elements1429 N = len(domain) # number_of_triangles 1430 1430 1431 1431 t = domain.time … … 1922 1922 #Assert that quantities are conserved 1923 1923 from Numeric import sum 1924 for k in range( mesh.number_of_elements):1924 for k in range(len(mesh)): 1925 1925 assert allclose (ref_centroid_values[k], 1926 1926 sum(stage.vertex_values[k,:])/3) … … 1944 1944 1945 1945 #Assert that all vertex quantities have changed 1946 for k in range( mesh.number_of_elements):1946 for k in range(len(mesh)): 1947 1947 #print ref_vertex_values[k,:], stage.vertex_values[k,:] 1948 1948 assert not allclose (ref_vertex_values[k,:], stage.vertex_values[k,:]) 1949 1949 #and assert that quantities are still conserved 1950 1950 from Numeric import sum 1951 for k in range( mesh.number_of_elements):1951 for k in range(len(mesh)): 1952 1952 assert allclose (ref_centroid_values[k], 1953 1953 sum(stage.vertex_values[k,:])/3) … … 2212 2212 2213 2213 #print t, volume, initial_volume 2214 2215 2216 #if not allclose (volume, initial_volume):2217 # print 't==4.05'2218 # for k in range(domain.number_of_elements):2219 # pass2220 # print domain.quantities['stage'].centroid_values[k] -\2221 # ref_centroid_values[k]2222 2214 2223 2215 assert allclose (volume, initial_volume) -
anuga_core/source/anuga_parallel/parallel_api.py
r3926 r3928 171 171 172 172 for p in range(numprocs): 173 N = len(submesh['ghost_nodes'][p]) 173 174 M = len(submesh['ghost_triangles'][p]) 174 print 'There are %d ghost triangles on proc %d' %(M, p) 175 N = len(submesh['ghost_nodes'][p]) 176 print 'There are %d ghost nodes on proc %d' %(N, p) 175 print 'There are %d ghost nodes and %d ghost triangles on proc %d'\ 176 %(N, M, p) 177 177 178 178 -
anuga_core/source/anuga_parallel/parallel_shallow_water.py
r3926 r3928 34 34 full_send_dict=None, 35 35 ghost_recv_dict=None, 36 number_of_full_nodes= 0,37 number_of_full_triangles= 0):36 number_of_full_nodes=None, 37 number_of_full_triangles=None): 38 38 39 39 Domain.__init__(self, … … 48 48 number_of_full_triangles=number_of_full_triangles) 49 49 50 N = self.number_of_elements50 N = len(self) # number_of_triangles 51 51 52 52 # self.processor = pypar.rank() -
anuga_core/source/anuga_parallel/test_parallel_sw_runup.py
r3926 r3928 96 96 local_interpolation_points.append(i) 97 97 98 # Hack 98 # Hack before we excluded ghosts. 99 99 if numprocs == 2: 100 100 if myid == 0: 101 101 del local_interpolation_points[0] 102 102 #local_interpolation_points = [1,2,3] 103 104 103 if numprocs == 3: 105 104 if myid == 1: 106 105 del local_interpolation_points[0] 107 108 109 106 if numprocs == 4: 110 107 if myid == 0: … … 122 119 123 120 for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0): 124 #domain.write_time() 125 121 domain.write_time() 126 122 127 123 # Record time series at known points
Note: See TracChangeset
for help on using the changeset viewer.