Changeset 2130 for inundation/parallel/build_local.py
- Timestamp:
- Dec 8, 2005, 8:29:24 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/parallel/build_local.py
r2091 r2130 18 18 ######################################################### 19 19 20 from mesh import * 21 from Numeric import * 20 from Numeric import zeros, Float, Int, concatenate, \ 21 take, arrayrange, put, sort, compress, equal 22 22 23 23 24 ######################################################### … … 44 45 Ntriangles = len(triangles) 45 46 46 # extract the nodes (using the local ID)47 # Extract the nodes (using the local ID) 47 48 48 49 GAnodes = take(nodes, (1, 2), 1) 49 50 50 # build a global ID to local ID mapping51 # Build a global ID to local ID mapping 51 52 52 53 NGlobal = 0 … … 55 56 NGlobal = nodes[i][0] 56 57 index = zeros(int(NGlobal)+1, Int) 57 put(index, take(nodes, (0,), 1).astype(Int), arrayrange(Nnodes)) 58 put(index, take(nodes, (0,), 1).astype(Int), \ 59 arrayrange(Nnodes)) 58 60 59 # change the global IDs in the triangles to the local IDs61 # Change the global IDs in the triangles to the local IDs 60 62 61 63 GAtriangles = zeros((Ntriangles, 3), Int) … … 94 96 def build_local_commun(index, ghostc, fullc, nproc): 95 97 96 # initialise98 # Initialise 97 99 98 100 full_send = {} 99 101 ghost_recv = {} 100 102 101 # build the ghost_recv dictionary (sort the103 # Build the ghost_recv dictionary (sort the 102 104 # information by the global numbering) 103 105 … … 112 114 ghost_recv[c][0] = take(index, d) 113 115 114 # build a temporary copy of the full_send dictionary116 # Build a temporary copy of the full_send dictionary 115 117 # (this version allows the information to be stored 116 118 # by the global numbering) … … 122 124 if not tmp_send.has_key(neigh): 123 125 tmp_send[neigh] = [] 124 tmp_send[neigh].append([global_id, index[global_id]]) 125 126 # extract the full send information and put it in the form 126 tmp_send[neigh].append([global_id, \ 127 index[global_id]]) 128 129 # Extract the full send information and put it in the form 127 130 # required for the full_send dictionary 128 131 … … 158 161 def build_local_mesh(submesh, lower_t, upper_t, nproc): 159 162 160 # combine the full nodes and ghost nodes 161 162 nodes = concatenate((submesh["full_nodes"], submesh["ghost_nodes"])) 163 164 # combine the full triangles and ghost triangles 163 # Combine the full nodes and ghost nodes 164 165 nodes = concatenate((submesh["full_nodes"], \ 166 submesh["ghost_nodes"])) 167 168 # Combine the full triangles and ghost triangles 165 169 166 170 gtri = take(submesh["ghost_triangles"],(1, 2, 3),1) 167 171 triangles = concatenate((submesh["full_triangles"], gtri)) 168 172 169 # renumber the boundary edges to correspond to the new173 # Renumber the boundary edges to correspond to the new 170 174 # triangle numbering 171 175 172 176 GAboundary = {} 173 177 for b in submesh["full_boundary"]: 174 GAboundary[b[0]-lower_t,b[1]] =submesh["full_boundary"][b]175 176 # make note of the new triangle numbers, including the ghost178 GAboundary[b[0]-lower_t,b[1]] = submesh["full_boundary"][b] 179 180 # Make note of the new triangle numbers, including the ghost 177 181 # triangles 178 182 … … 187 191 index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t 188 192 189 # change the node numbering (and update the numbering in the193 # Change the node numbering (and update the numbering in the 190 194 # triangles) 191 195 192 196 [GAnodes, GAtriangles] = build_local_GA(nodes, triangles) 193 197 194 # extract the local quantities198 # Extract the local quantities 195 199 196 200 quantities ={} … … 202 206 quantities[k][Nf:Nf+Ng] = submesh["ghost_quan"][k] 203 207 204 # change the communication pattern into a form needed by205 # the parallel_adv ection.py file208 # Change the communication pattern into a form needed by 209 # the parallel_adv 206 210 207 211 gcommun = submesh["ghost_commun"] 208 212 fcommun = submesh["full_commun"] 209 [ghost_rec, full_send] = build_local_commun(index, gcommun, fcommun, nproc) 210 211 # clean up before exiting 213 [ghost_rec, full_send] = \ 214 build_local_commun(index, gcommun, fcommun, nproc) 215 216 # Clean up before exiting 212 217 213 218 del(index) 214 219 215 return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, full_send 220 return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \ 221 full_send
Note: See TracChangeset
for help on using the changeset viewer.