Changeset 8281
- Timestamp:
- Dec 12, 2011, 5:11:47 PM (13 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8235 r8281 165 165 self.fractional_step_operators = [] 166 166 167 168 169 # by default domain is not parallel 170 self.parallel = False 171 172 self.number_of_global_triangles = self.number_of_triangles 173 self.number_of_global_nodes = self.number_of_nodes 174 167 175 # Setup the ghost cell communication 168 176 if full_send_dict is None: -
trunk/anuga_core/source/anuga/file/sww.py
r8278 r8281 183 183 points_georeference=\ 184 184 domain.geo_reference) 185 186 187 if domain.parallel: 188 self.writer.store_parallel_data(fid, 189 domain.number_of_global_triangles, 190 domain.number_of_global_nodes, 191 domain.tri_full_flag, 192 domain.tri_l2g, 193 domain.node_l2g) 185 194 186 195 … … 676 685 outfile.variables['y'][:] = y #- geo_ref.get_yllcorner() 677 686 outfile.variables['volumes'][:] = volumes.astype(num.int32) #On Opteron 64 687 688 689 def store_parallel_data(self, 690 outfile, 691 number_of_global_triangles, 692 number_of_global_nodes, 693 tri_full_flag = None, 694 tri_l2g = None, 695 node_l2g = None, 696 sww_precision=netcdf_float32, 697 verbose=False): 698 699 700 # dimension definitions 701 #outfile.createDimension('number_of_volumes', number_of_volumes) 702 #outfile.createDimension('number_of_vertices', 3) 703 #outfile.createDimension('numbers_in_range', 2) 704 705 print 'store parallel data' 706 outfile.number_of_global_triangles = number_of_global_triangles 707 outfile.number_of_global_nodes = number_of_global_nodes 708 709 # variable definitions 710 outfile.createVariable('tri_l2g', netcdf_int, ('number_of_volumes',)) 711 outfile.createVariable('node_l2g', netcdf_int, ('number_of_points',)) 712 outfile.createVariable('tri_full_flag', netcdf_int, ('number_of_volumes',)) 713 714 print tri_l2g.shape 715 print tri_l2g 716 print outfile.variables['tri_l2g'].shape 717 718 outfile.variables['tri_l2g'][:] = tri_l2g.astype(num.int32) 719 720 print node_l2g.shape 721 print node_l2g 722 print outfile.variables['node_l2g'].shape 723 724 outfile.variables['node_l2g'][:] = node_l2g.astype(num.int32) 725 726 print tri_full_flag.shape 727 print tri_full_flag 728 print outfile.variables['tri_full_flag'].shape 729 730 outfile.variables['tri_full_flag'][:] = tri_full_flag.astype(num.int32) 678 731 679 732 -
trunk/anuga_core/source/anuga/utilities/sww_merge.py
r8278 r8281 14 14 15 15 output = domain_global_name+".sww" 16 swwfiles = [ domain_global_name+"_P"+str( v)+"_"+str(np)+".sww" for v in range(np)]16 swwfiles = [ domain_global_name+"_P"+str(np)+"_"+str(v)+".sww" for v in range(np)] 17 17 18 18 _sww_merge(swwfiles, output, verbose) … … 132 132 133 133 134 135 from anuga.coordinate_transforms.geo_reference import Geo_reference 136 geo_reference = Geo_reference() 134 137 135 136 sww.store_triangulation(fido, points, out_tris) 138 sww.store_triangulation(fido, points, out_tris, points_georeference=geo_reference) 137 139 138 140 fido.order = order -
trunk/anuga_core/source/anuga/utilities/test_file_utils.py
r8124 r8281 7 7 from anuga.utilities.file_utils import copy_code_files, get_all_swwfiles 8 8 from anuga.utilities.file_utils import del_dir 9 from sww_merge import sww_merge 9 from sww_merge import sww_merge, _sww_merge 10 10 11 11 … … 139 139 140 140 outfile = 'test_out.sww' 141 sww_merge(['test1.sww', 'test2.sww'], outfile)141 _sww_merge(['test1.sww', 'test2.sww'], outfile) 142 142 self.failUnless(os.access(outfile, os.F_OK)) 143 143 -
trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
r8260 r8281 147 147 del npart 148 148 149 # Sometimes (usu. on x86_64), partMeshNodal return es an array of zero149 # Sometimes (usu. on x86_64), partMeshNodal returns an array of zero 150 150 # dimensional arrays. Correct this. 151 151 if type(epart[0]) == num.ndarray: … … 808 808 ######################################################### 809 809 810 def build_local_GA(nodes, triangles, boundaries, tri_ index):810 def build_local_GA(nodes, triangles, boundaries, tri_map): 811 811 812 812 Nnodes =len(nodes) … … 823 823 if nodes[i][0] > NGlobal: 824 824 NGlobal = nodes[i][0] 825 index = num.zeros(int(NGlobal)+1, num.int) 826 num.put(index, num.take(nodes, (0,), 1).astype(num.int), \ 825 826 node_map = -1*num.ones(int(NGlobal)+1, num.int) 827 828 num.put(node_map, num.take(nodes, (0,), 1).astype(num.int), \ 827 829 num.arange(Nnodes)) 828 830 … … 830 832 831 833 GAtriangles = num.zeros((Ntriangles, 3), num.int) 832 GAtriangles[:,0] = num.take( index, triangles[:,0])833 GAtriangles[:,1] = num.take( index, triangles[:,1])834 GAtriangles[:,2] = num.take( index, triangles[:,2])834 GAtriangles[:,0] = num.take(node_map, triangles[:,0]) 835 GAtriangles[:,1] = num.take(node_map, triangles[:,1]) 836 GAtriangles[:,2] = num.take(node_map, triangles[:,2]) 835 837 836 838 # Change the triangle numbering in the boundaries … … 838 840 GAboundaries = {} 839 841 for b in boundaries: 840 GAboundaries[tri_ index[b[0]], b[1]] = boundaries[b]842 GAboundaries[tri_map[b[0]], b[1]] = boundaries[b] 841 843 842 del (index) 843 844 return GAnodes, GAtriangles, GAboundaries 844 845 return GAnodes, GAtriangles, GAboundaries, node_map 845 846 846 847 … … 868 869 ######################################################### 869 870 870 def build_local_commun( index, ghostc, fullc, nproc):871 def build_local_commun(tri_map, ghostc, fullc, nproc): 871 872 872 873 # Initialise … … 886 887 ghost_recv[c] = [0, 0] 887 888 ghost_recv[c][1] = d 888 ghost_recv[c][0] = num.take( index, d)889 ghost_recv[c][0] = num.take(tri_map, d) 889 890 890 891 # Build a temporary copy of the full_send dictionary … … 899 900 tmp_send[neigh] = [] 900 901 tmp_send[neigh].append([global_id, \ 901 index[global_id]])902 tri_map[global_id]]) 902 903 903 904 # Extract the full send information and put it in the form … … 958 959 if id > NGlobal: 959 960 NGlobal = id 960 index = num.zeros(int(NGlobal)+1, num.int) 961 index[lower_t:upper_t]=num.arange(upper_t-lower_t) 961 #index = num.zeros(int(NGlobal)+1, num.int) 962 tri_map = -1*num.ones(int(NGlobal)+1, num.int) 963 tri_map[lower_t:upper_t]=num.arange(upper_t-lower_t) 962 964 for i in range(len(submesh["ghost_triangles"])): 963 index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t965 tri_map[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t 964 966 965 967 # Change the node numbering (and update the numbering in the 966 968 # triangles) 967 969 968 [GAnodes, GAtriangles, GAboundary] = build_local_GA(nodes, triangles, boundaries, index) 970 [GAnodes, GAtriangles, GAboundary, node_map] = \ 971 build_local_GA(nodes, triangles, boundaries, tri_map) 969 972 970 973 # Extract the local quantities … … 984 987 fcommun = submesh["full_commun"] 985 988 [ghost_rec, full_send] = \ 986 build_local_commun(index, gcommun, fcommun, nproc) 987 988 # Clean up before exiting 989 990 del(index) 989 build_local_commun(tri_map, gcommun, fcommun, nproc) 990 991 991 992 992 return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \ 993 full_send 993 full_send, tri_map, node_map 994 994 995 995 … … 1284 1284 # datastructure 1285 1285 1286 [GAnodes, GAtriangles, boundary, quantities, ghost_rec, full_send] = \ 1286 [GAnodes, GAtriangles, boundary, quantities, \ 1287 ghost_rec, full_send, tri_map, node_map] = \ 1287 1288 build_local_mesh(submesh_cell, lower_t, upper_t, \ 1288 1289 numproc) … … 1290 1291 return GAnodes, GAtriangles, boundary, quantities,\ 1291 1292 ghost_rec, full_send,\ 1292 number_of_full_nodes, number_of_full_triangles 1293 number_of_full_nodes, number_of_full_triangles, tri_map, node_map 1294 1293 1295 1294 1296 … … 1327 1329 1328 1330 numprocs = len(triangles_per_proc) 1329 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \ 1331 points, vertices, boundary, quantities, ghost_recv_dict, \ 1332 full_send_dict, tri_map, node_map = \ 1330 1333 build_local_mesh(submesh_cell, 0, triangles_per_proc[0], numprocs) 1331 1334 1332 1335 1333 1336 return points, vertices, boundary, quantities, ghost_recv_dict, \ 1334 full_send_dict 1335 1336 1337 1338 1337 full_send_dict, tri_map, node_map 1338 1339 1340 1341 1342 -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r8272 r8281 99 99 ghost_recv_dict, full_send_dict,\ 100 100 number_of_full_nodes, number_of_full_triangles,\ 101 s2p_map, p2s_map =\101 s2p_map, p2s_map, tri_map, node_map =\ 102 102 distribute_mesh(domain, verbose=verbose) 103 104 number_of_global_triangles = len(tri_map) 105 number_of_global_nodes = len(node_map) 106 107 # Extract l2g maps 108 tri_l2g = extract_l2g_map(tri_map) 109 node_l2g = extract_l2g_map(node_map) 103 110 104 111 # Send serial to parallel (s2p) and parallel to serial (p2s) triangle mapping to proc 1 .. numprocs … … 115 122 points, vertices, boundary, quantities,\ 116 123 ghost_recv_dict, full_send_dict,\ 117 number_of_full_nodes, number_of_full_triangles =\ 124 number_of_full_nodes, number_of_full_triangles, \ 125 tri_map, node_map =\ 118 126 rec_submesh(0, verbose) 119 127 128 number_of_global_triangles = len(tri_map) 129 number_of_global_nodes = len(node_map) 130 131 # Extract l2g maps 132 tri_l2g = extract_l2g_map(tri_map) 133 node_l2g = extract_l2g_map(node_map) 134 120 135 # Recieve serial to parallel (s2p) and parallel to serial (p2s) triangle mapping 121 136 s2p_map = receive(0) … … 136 151 number_of_full_triangles=number_of_full_triangles, 137 152 geo_reference=georef, 138 tri_map = s2p_map, 139 inv_tri_map = p2s_map) ## jj added this 153 number_of_global_triangles = number_of_global_triangles, 154 number_of_global_nodes = number_of_global_nodes, 155 s2p_map = s2p_map, 156 p2s_map = p2s_map, ## jj added this 157 tri_l2g = tri_l2g, ## SR added this 158 node_l2g = node_l2g) 140 159 141 160 #------------------------------------------------------------------------ … … 177 196 # Subdivide the mesh 178 197 if verbose: print 'Subdivide mesh' 179 nodes, triangles, boundary, triangles_per_proc, quantities, s2p_map, p2s_map = \ 198 nodes, triangles, boundary, triangles_per_proc, quantities, \ 199 s2p_map, p2s_map = \ 180 200 pmesh_divide_metis_with_map(domain, numprocs) 181 201 182 202 #PETE: s2p_map (maps serial domain triangles to parallel domain triangles) 183 # p2_map (maps parallel domain triangles to domain triangles)203 # sp2_map (maps parallel domain triangles to domain triangles) 184 204 185 205 … … 204 224 205 225 # Build the local mesh for processor 0 206 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict =\ 226 points, vertices, boundary, quantities, \ 227 ghost_recv_dict, full_send_dict, tri_map, node_map =\ 207 228 extract_hostmesh(submesh, triangles_per_proc) 208 229 … … 240 261 return points, vertices, boundary, quantities,\ 241 262 ghost_recv_dict, full_send_dict,\ 242 number_of_full_nodes, number_of_full_triangles, s2p_map, p2s_map 243 244 245 246 263 number_of_full_nodes, number_of_full_triangles, \ 264 s2p_map, p2s_map, tri_map, node_map 265 266 267 268 def extract_l2g_map(map): 269 # Extract l2g_map 270 271 import numpy as num 272 273 b = num.arange(len(map)) 274 275 l_ids = num.extract(map>-1,map) 276 g_ids = num.extract(map>-1,b) 277 278 # print len(g_ids) 279 # print len(l_ids) 280 # print l_ids 281 282 l2g = num.zeros_like(g_ids) 283 l2g[l_ids] = g_ids 284 285 return l2g 286 -
trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py
r8272 r8281 33 33 number_of_full_triangles=None, 34 34 geo_reference=None, 35 tri_map=None, 36 inv_tri_map=None): #jj added this 35 number_of_global_triangles=None, ## SR added this 36 number_of_global_nodes= None, ## SR added this 37 s2p_map=None, 38 p2s_map=None, #jj added this 39 tri_l2g = None, ## SR added this 40 node_l2g = None): ## SR added this 37 41 38 42 Domain.__init__(self, … … 48 52 geo_reference=geo_reference) #jj added this 49 53 54 55 56 self.parallel = True 57 50 58 # PETE: Find the number of full nodes and full triangles, this is a temporary fix 51 59 # until the bug with get_number_of_full_[nodes|triangles]() is fixed. … … 64 72 65 73 self.global_name = 'domain' 66 self.tri_map = tri_map 67 self.inv_tri_map = inv_tri_map 74 75 self.number_of_global_triangles=number_of_global_triangles 76 self.number_of_global_nodes = number_of_global_nodes 77 78 self.s2p_map = s2p_map 79 self.p2s_map = p2s_map 80 self.tri_l2g = tri_l2g 81 self.node_l2g = node_l2g 68 82 69 83 … … 78 92 79 93 # Call parents method with processor number attached. 80 Domain.set_name(self, name + '_P%d_%d' %(self. processor, self.numproc))94 Domain.set_name(self, name + '_P%d_%d' %(self.numproc, self.processor)) 81 95 82 96 -
trunk/anuga_core/source/anuga_parallel/run_parallel_sw_merimbula.py
r8277 r8281 35 35 36 36 37 from anuga_parallel import distribute, myid, numprocs, finalize 37 from anuga_parallel import distribute, myid, numprocs, finalize, barrier 38 38 39 39 … … 42 42 #-------------------------------------------------------------------------- 43 43 44 mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.044 #mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0 45 45 #mesh_filename = "merimbula_43200.tsh" ; x0 = 756000.0 ; x1 = 756500.0 46 #mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.546 mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5 47 47 yieldstep = 20 48 48 finaltime = 500 … … 70 70 domain = create_domain_from_file(mesh_filename) 71 71 domain.set_quantity('stage', Set_Stage(x0, x1, 2.0)) 72 73 print domain.statistics() 74 print domain.get_extent() 75 print domain.get_extent(absolute=True) 76 print domain.geo_reference 72 77 else: 73 78 domain = None … … 86 91 #domain.set_CFL(0.7) 87 92 #domain.set_beta(1.5) 88 domain.set_name('meribula') 93 domain.set_name('merimbula') 94 95 for p in range(numprocs): 96 if myid == p: 97 print 'P%d'%p 98 print domain.get_extent() 99 print domain.get_extent(absolute=True) 100 print domain.geo_reference 101 #print domain.tri_map 102 #print domain.inv_tri_map 103 print domain.tri_l2g 104 print domain.node_l2g 105 else: 106 pass 107 108 barrier() 109 89 110 90 111 #------------------------------------------------------------------------------ -
trunk/anuga_core/source/anuga_parallel/test_parallel_distribute_mesh.py
r8115 r8281 195 195 # Test extract_hostmesh 196 196 #---------------------------------------------------------------------------------- 197 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict =\ 197 points, vertices, boundary, quantities, \ 198 ghost_recv_dict, full_send_dict, tri_map, node_map =\ 198 199 extract_hostmesh(submesh, triangles_per_proc) 199 200 … … 222 223 # Test rec_submesh 223 224 #---------------------------------------------------------------------------------- 224 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict, no_full_nodes, no_full_trigs = rec_submesh(0, verbose=False) 225 points, vertices, boundary, quantities, \ 226 ghost_recv_dict, full_send_dict, \ 227 no_full_nodes, no_full_trigs, tri_map, node_map = \ 228 rec_submesh(0, verbose=False) 225 229 226 230 if myid == 1: … … 235 239 true_full_send = {0: [num.array([0, 1, 3, 4, 5]), num.array([ 5, 6, 8, 9, 10])], 2: [num.array([0, 1]), num.array([5, 6])]} 236 240 241 true_tri_map = num.array([ 6, 7, 8, -1, 9, 0, 1, 2, 3, 4, 5, 10, 11]) 242 243 true_node_map = num.array([ 0, 1, 2, 7, 3, 4, -1, 8, 9, 5, 6, 10, 11]) 244 245 assert_(num.allclose(tri_map, true_tri_map)) 246 assert_(num.allclose(node_map, true_node_map)) 237 247 assert_(num.allclose(points, true_points)) 238 248 assert_(num.allclose(vertices, true_vertices)) … … 249 259 true_vertices = [[1, 5, 0], [1, 6, 2], [3, 6, 1], [4, 6, 3], [2, 6, 4], [2, 5, 1], [2, 10, 8], [4, 10, 2], [9, 10, 4], [0, 5, 7], [7, 5, 2]] 250 260 251 252 261 true_ghost_recv = {0: [num.array([5, 6, 7, 8]), num.array([0, 1, 2, 3])], 1: [num.array([ 9, 10]), num.array([5, 6])]} 253 262 254 263 true_full_send = {0: [num.array([0, 1, 2, 3, 4]), num.array([11, 12, 13, 14, 15])], 1: [num.array([0, 1]), num.array([11, 12])]} 255 264 256 265 true_tri_map = num.array([5, 6, 7, 8, -1, 9, 10, -1, -1, -1, -1, 0, 1, 2, 3, 4, -1]) 266 267 true_node_map = num.array([ 0, 7, -1, 1, 2, 8 , 3, 4, 9, 5, -1, 6, 10]) 268 269 assert_(num.allclose(tri_map, true_tri_map)) 270 assert_(num.allclose(node_map, true_node_map)) 257 271 assert_(num.allclose(points, true_points)) 258 272 assert_(num.allclose(vertices, true_vertices))
Note: See TracChangeset
for help on using the changeset viewer.