Changeset 8260
- Timestamp:
- Nov 30, 2011, 7:57:30 PM (13 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
r7461 r8260 101 101 102 102 def pmesh_divide_metis(domain, n_procs): 103 # Wrapper for old pmesh_divide_metis which does not return tri_index or r_tri_index 104 nodes, ttriangles, boundary, triangles_per_proc, quantities, tri_index, r_tri_index = pmesh_divide_metis_helper(domain, n_procs) 105 return nodes, ttriangles, boundary, triangles_per_proc, quantities 106 107 def pmesh_divide_metis_with_map(domain, n_procs): 108 return pmesh_divide_metis_helper(domain, n_procs) 109 110 def pmesh_divide_metis_helper(domain, n_procs): 103 111 104 112 # Initialise the lists … … 110 118 111 119 tri_list = [] 120 121 # Serial to Parallel and Parallel to Serial Triangle index maps 122 tri_index = {} 123 r_tri_index = {} # reverse tri index, parallel to serial triangle index mapping 112 124 113 125 # List indexed by processor of cumulative total of triangles allocated. … … 148 160 # (local to the processor) 149 161 150 tri_index = {}151 162 triangles = [] 152 163 for i in range(n_tri): … … 154 165 tri_list[epart[i]].append(domain.triangles[i]) 155 166 tri_index[i] = ([epart[i], len(tri_list[epart[i]]) - 1]) 167 r_tri_index[epart[i], len(tri_list[epart[i]]) - 1] = i 156 168 157 169 # Order the triangle list so that all of the triangles belonging … … 202 214 for i in range(len(triangles)): 203 215 ttriangles[i] = triangles[i] 204 205 return nodes, ttriangles, boundary, triangles_per_proc, quantities 216 217 #return nodes, ttriangles, boundary, triangles_per_proc, quantities 218 219 return nodes, ttriangles, boundary, triangles_per_proc, quantities, tri_index, r_tri_index 206 220 207 221 -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r8114 r8260 20 20 # Mesh partitioning using Metis 21 21 from anuga_parallel.distribute_mesh import build_submesh 22 from anuga_parallel.distribute_mesh import pmesh_divide_metis 22 from anuga_parallel.distribute_mesh import pmesh_divide_metis_with_map 23 23 24 24 from anuga_parallel.parallel_shallow_water import Parallel_domain … … 97 97 points, vertices, boundary, quantities,\ 98 98 ghost_recv_dict, full_send_dict,\ 99 number_of_full_nodes, number_of_full_triangles =\ 99 number_of_full_nodes, number_of_full_triangles,\ 100 s2p_map, p2s_map =\ 100 101 distribute_mesh(domain, verbose=verbose) 101 102 103 # Send serial to parallel (s2p) and parallel to serial (p2s) triangle mapping to proc 1 .. numprocs 104 for p in range(1, numprocs): 105 send(s2p_map, p) 106 send(p2s_map, p) 102 107 103 108 if verbose: print 'Communication done' … … 112 117 rec_submesh(0, verbose) 113 118 119 # Recieve serial to parallel (s2p) and parallel to serial (p2s) triangle mapping 120 s2p_map = receive(0) 121 p2s_map = receive(0) 122 114 123 115 124 #------------------------------------------------------------------------ … … 125 134 number_of_full_nodes=number_of_full_nodes, 126 135 number_of_full_triangles=number_of_full_triangles, 127 geo_reference=georef) ## jj added this 136 geo_reference=georef, 137 tri_map = s2p_map, 138 inv_tri_map = p2s_map) ## jj added this 128 139 129 140 #------------------------------------------------------------------------ … … 165 176 # Subdivide the mesh 166 177 if verbose: print 'Subdivide mesh' 167 nodes, triangles, boundary, triangles_per_proc, quantities = \ 168 pmesh_divide_metis(domain, numprocs) 169 170 178 nodes, triangles, boundary, triangles_per_proc, quantities, s2p_map, p2s_map = \ 179 pmesh_divide_metis_with_map(domain, numprocs) 180 181 #PETE: s2p_map (maps serial domain triangles to parallel domain triangles) 182 #p2_map (maps parallel domain triangles to domain triangles) 171 183 172 184 … … 227 239 return points, vertices, boundary, quantities,\ 228 240 ghost_recv_dict, full_send_dict,\ 229 number_of_full_nodes, number_of_full_triangles 230 231 232 233 241 number_of_full_nodes, number_of_full_triangles, s2p_map, p2s_map 242 243 244 245 -
trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py
r8224 r8260 20 20 21 21 22 #Import matplotlib 23 24 import matplotlib 25 matplotlib.use('Agg') 26 import matplotlib.pyplot as plt 27 import matplotlib.tri as tri 22 28 23 29 class Parallel_domain(Domain): … … 29 35 number_of_full_nodes=None, 30 36 number_of_full_triangles=None, 31 geo_reference=None): #jj added this 37 geo_reference=None, 38 tri_map=None, 39 inv_tri_map=None): #jj added this 32 40 33 41 Domain.__init__(self, … … 57 65 58 66 setup_buffers(self) 67 68 self.tri_map = tri_map 69 self.inv_tri_map = inv_tri_map 59 70 60 71 … … 122 133 return N[:self.number_of_full_nodes_tmp,:] 123 134 135 def get_tri_map(self): 136 return self.tri_map 137 138 def get_inv_tri_map(self): 139 return self.inv_tri_map 140 141 ''' 142 Outputs domain triangulation, full triangles are shown in green while ghost triangles are shown in blue. 143 The default filename is "domain.png" 144 ''' 145 def dump_triangulation(self, filename="domain.png"): 146 # Get vertex coordinates, partition full and ghost triangles based on self.tri_full_flag 147 vertices = self.get_vertex_coordinates() 148 full_mask = num.repeat(self.tri_full_flag == 1, 3) 149 ghost_mask = num.repeat(self.tri_full_flag == 0, 3) 150 151 myid = pypar.rank() 152 numprocs = pypar.size() 153 154 if myid == 0: 155 fx = {} 156 fy = {} 157 gx = {} 158 gy = {} 159 160 # Proc 0 gathers full and ghost nodes from self and other processors 161 fx[0] = vertices[full_mask,0] 162 fy[0] = vertices[full_mask,1] 163 gx[0] = vertices[ghost_mask,0] 164 gy[0] = vertices[ghost_mask,1] 165 166 for i in range(1,numprocs): 167 fx[i] = pypar.receive(i) 168 fy[i] = pypar.receive(i) 169 gx[i] = pypar.receive(i) 170 gy[i] = pypar.receive(i) 171 172 # Plot full triangles 173 for i in range(0, numprocs): 174 n = int(len(fx[i])/3) 175 176 triang = num.array(range(0,3*n)) 177 triang.shape = (n, 3) 178 plt.triplot(fx[i], fy[i], triang, 'g-') 179 180 # Plot ghost triangles 181 for i in range(0, numprocs): 182 n = int(len(gx[i])/3) 183 184 triang = num.array(range(0,3*n)) 185 triang.shape = (n, 3) 186 plt.triplot(gx[i], gy[i], triang, 'b--') 187 188 # Save triangulation to location pointed by filename 189 plt.savefig(filename) 190 191 else: 192 # Proc 1..numprocs send full and ghost triangles to Proc 0 193 pypar.send(vertices[full_mask,0], 0) 194 pypar.send(vertices[full_mask,1], 0) 195 pypar.send(vertices[ghost_mask,0], 0) 196 pypar.send(vertices[ghost_mask,1], 0) 197 -
trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py
r8229 r8260 105 105 ##----------------------------------------------------------------------- 106 106 107 if parallel: domain = distribute(domain) 107 if parallel: 108 domain = distribute(domain) 109 domain.dump_triangulation("frac_op_domain.png") 108 110 109 111 … … 147 149 148 150 ################ Define Fractional Operators ########################## 151 152 inlet0 = None 153 inlet1 = None 154 boyd_box0 = None 149 155 150 156 inlet0 = Inlet_operator(domain, line0, Q0, debug = False) … … 152 158 153 159 # Enquiry point [ 19. 2.5] is contained in two domains in 4 proc case 160 154 161 boyd_box0 = Boyd_box_operator(domain, 155 162 end_points=[[9.0, 2.5],[19.0, 2.5]], … … 161 168 manning=0.013, 162 169 verbose=False, debug = False) 163 170 164 171 if inlet0 is not None: inlet0.print_statistics() 165 172 if inlet1 is not None: inlet1.print_statistics() … … 202 209 ##----------------------------------------------------------------------- 203 210 204 for t in domain.evolve(yieldstep = 1.0, finaltime = 38):211 for t in domain.evolve(yieldstep = 0.1, finaltime = 38): 205 212 domain.write_time() 206 213
Note: See TracChangeset
for help on using the changeset viewer.