Changeset 1520
- Timestamp:
- Jun 20, 2005, 4:53:05 PM (19 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/parallel/build_commun.py
r1500 r1520 1 1 ######################################################### 2 # 2 # 3 3 # Handle the communication between the host machine 4 4 # (processor 0) and the processors. The host machine is 5 # responsible for the doing the initial grid partitioning. 5 # responsible for the doing the initial grid partitioning. 6 6 # 7 7 # The routines given below should be moved to the … … 18 18 ######################################################### 19 19 20 import logging, logging.config 21 logger = logging.getLogger('parallel') 22 logger.setLevel(logging.WARNING) 23 24 try: 25 logging.config.fileConfig('log.ini') 26 except: 27 pass 28 20 29 21 30 import sys … … 38 47 39 48 def send_submesh(submesh, triangles_per_proc, tagmap, p): 40 49 41 50 # send the number of triangles per processor 42 43 print "pypar send triangles per proc",p 51 52 print "pypar send triangles per proc",p 44 53 pypar.send(triangles_per_proc, p, use_buffer=True) 45 54 … … 47 56 48 57 flat_full_commun = [] 58 49 59 50 60 for c in submesh["full_commun"][p]: 51 61 for i in range(len(submesh["full_commun"][p][c])): 52 flat_full_commun.append([c,submesh["full_commun"][p][c][i]]) 53 62 flat_full_commun.append([c,submesh["full_commun"][p][c][i]]) 63 54 64 # send the array sizes so memory can be allocated 55 65 56 66 setup_array = [0, 0, 0, 0, 0, 0, 0] 57 67 setup_array[0] = len(submesh["full_nodes"][p]) … … 64 74 print "pypar send setup_array", p 65 75 pypar.send(setup_array, p) 66 76 67 77 # send the nodes 68 78 69 79 print "pypar send full_nodes", p 70 80 pypar.send(submesh["full_nodes"][p], p, use_buffer=True) … … 72 82 print "pypar send ghost_nodes", p 73 83 pypar.send(submesh["ghost_nodes"][p], p, use_buffer=True) 74 84 75 85 # send the triangles 76 86 77 87 print "pypar send full_triangles", p 78 88 pypar.send(submesh["full_triangles"][p], p, use_buffer=True) … … 82 92 83 93 # send the boundary (is it quicker to send as an array?) 84 94 85 95 print "pypar send full_boundary", p 86 96 bc = [] … … 93 103 print "pypar send ghost_commun", p, len(submesh["ghost_commun"][p]) 94 104 pypar.send(submesh["ghost_commun"][p], p, use_buffer=True) 95 105 96 106 print "pypar send full_commun", p, len(flat_full_commun) 97 107 pypar.send(flat_full_commun, p, use_buffer=True) … … 117 127 118 128 def rec_submesh(tagmap, p): 119 129 120 130 from Numeric import zeros, Float, Int 121 131 … … 124 134 125 135 submesh_cell = {} 126 136 127 137 # receive the number of triangles per processor 128 138 129 139 triangles_per_proc = [] 130 140 for i in range(numproc): … … 133 143 print "pypar rec triangles_per_proc", p 134 144 triangles_per_proc = pypar.receive(p, triangles_per_proc) 135 145 136 146 # recieve information about the array sizes 137 147 138 148 setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 139 149 print "pypar rec setup_array", p … … 141 151 142 152 # receive the full nodes 143 153 144 154 no_full_nodes = setup_array[0] 145 155 full_nodes = [] … … 150 160 151 161 # receive the ghost nodes 152 162 153 163 no_ghost_nodes = setup_array[1] 154 164 ghost_nodes = [] … … 157 167 print "pypar rec ghost_nodes ", p 158 168 submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes) 159 169 160 170 # receive the full triangles 161 171 162 172 no_full_triangles = setup_array[2] 163 173 full_triangles = [] … … 168 178 169 179 # receive the ghost triangles 170 180 171 181 no_ghost_triangles = setup_array[3] 172 182 ghost_triangles = [] … … 175 185 print "pypar rec ghost_triangles", p 176 186 submesh_cell["ghost_triangles"] = pypar.receive(p, ghost_triangles) 177 187 178 188 # receive the full boundary 179 189 180 190 print "pypar rec full_boundary", p 181 191 no_full_boundary = setup_array[4] … … 188 198 for t in tagmap: 189 199 itagmap[tagmap[t]]=t 190 200 191 201 submesh_cell["full_boundary"] = {} 192 202 for b in bnd_c: … … 194 204 195 205 # receive the ghost communication pattern 196 206 197 207 no_ghost_commun = setup_array[5] 198 208 ghost_commun = [] … … 204 214 205 215 # receive the full communication pattern 206 216 207 217 no_full_commun = setup_array[6] 208 218 full_commun = [] … … 211 221 print "pypar rec full_commun", p 212 222 full_commun = pypar.receive(p, full_commun) 213 223 214 224 submesh_cell["full_commun"] = {} 215 225 for c in full_commun: … … 219 229 220 230 # find the full triangles assigned to this processor 221 231 222 232 lower_t = 0 223 233 for i in range(myid): … … 227 237 # convert the information into a form needed by the GA 228 238 # datastructure 229 239 230 240 [GAnodes, GAtriangles, boundary, ghost_rec, full_send] = build_local_mesh(submesh_cell, lower_t, upper_t, numproc) 231 241 232 242 return GAnodes, GAtriangles, boundary, ghost_rec, full_send 233 243 234 244 235 -
inundation/ga/storm_surge/parallel/parallel_meshes.py
r1510 r1520 17 17 18 18 19 def parallel_rectangular(m , n, len1=1.0, len2=1.0, origin= (0.0, 0.0)):19 def parallel_rectangular(m_g, n_g, len1_g=1.0, len2_g=1.0, origin_g = (0.0, 0.0)): 20 20 21 21 … … 37 37 numproc = pypar.size() 38 38 39 40 41 delta1 = float(len1)/m 42 delta2 = float(len2)/n 39 m_low, m_high = pypar.balance(m_g, numproc, processor) 40 41 n = n_g 42 m_low = m_low-1 43 m_high = m_high+1 44 m = m_high - m_low 45 46 delta1 = float(len1_g)/m_g 47 delta2 = float(len2_g)/n_g 48 49 len1 = len1_g*float(m)/float(m_g) 50 len2 = len2_g 51 origin = ( origin_g[0]+float(m_low)/float(m_g)*len1_g, origin_g[1] ) 52 43 53 44 54 #Calculate number of points … … 151 161 Xf = zeros(Idfl.shape,Float) 152 162 Xg = zeros(Idgr.shape,Float) 153 full_send_dict[processor] = [Idfl, Xf]154 ghost_recv_dict[processor] = [Idgr, Xg]163 full_send_dict[processor] = [Idfl, Idfl, Xf] 164 ghost_recv_dict[processor] = [Idgr, Idgr, Xg] 155 165 elif numproc == 2: 156 166 Idfl.extend(Idfr) … … 161 171 Xf = zeros(Idfl.shape,Float) 162 172 Xg = zeros(Idgr.shape,Float) 163 full_send_dict[(processor-1)%numproc] = [Idfl, Xf]164 ghost_recv_dict[(processor-1)%numproc] = [Idgr, Xg]173 full_send_dict[(processor-1)%numproc] = [Idfl, Idfl, Xf] 174 ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr, Xg] 165 175 else: 166 176 Idfl = array(Idfl,Int) -
inundation/ga/storm_surge/parallel/run_advection.py
r1472 r1520 1 import pdb 2 pdb.set_trace() 3 1 4 import sys 2 5 from os import sep … … 8 11 from advection import * 9 12 from Numeric import array 13 10 14 11 15 from mesh_factory import rectangular … … 27 31 D = Dirichlet_boundary(array([1.0])) 28 32 33 #turn on the visualisation 34 rect = [0.0, 0.0, 1.0, 1.0] 35 domain.initialise_visualiser(rect=rect) 36 37 29 38 domain.default_order = 2 30 39 … … 37 46 for t in domain.evolve(yieldstep = 0.1, finaltime = 1.5): 38 47 domain.write_time() 48 pdb.set_trace() 49 -
inundation/ga/storm_surge/parallel/run_parallel_advection.py
r1471 r1520 22 22 M = 50 23 23 24 points, vertices, boundary, full_send_dict, ghost_recv_dict = parallel_rectangular(N, M, len1=1.0) 24 points, vertices, boundary, full_send_dict, ghost_recv_dict = \ 25 parallel_rectangular(N, M, len1_g=1.0) 25 26 26 27 #Create advection domain with direction (1,-1) … … 31 32 32 33 #turn on the visualisation 33 domain.initialise_visualiser() 34 rect = [0.0, 0.0, 1.0, 1.0] 35 domain.initialise_visualiser(rect=rect) 34 36 35 37 #Boundaries … … 55 57 return self.h*((x>self.x0)&(x<self.x1)) 56 58 59 domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0)) 60 57 61 if myid == 0: 58 domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))59 62 import time 60 63 t0 = time.time() 61 64 62 65 #Check that the boundary value gets propagated to all elements 63 for t in domain.evolve(yieldstep = 0. 5, finaltime = 3.0):66 for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0): 64 67 if myid == 0: 65 68 domain.write_time() -
inundation/ga/storm_surge/parallel/run_parallel_mesh.py
r1510 r1520 65 65 from build_local import * 66 66 from build_commun import * 67 import pdb 67 68 68 69 # define the initial time step … … 96 97 # if this is the host processor 97 98 99 print 'trace' 100 pdb.set_trace() 101 print 'after trace' 102 98 103 if myid == 0: 99 104 … … 115 120 # processor (note that the information is in the 116 121 # correct form for the GA data structure 122 117 123 118 124 [points, vertices, boundary, ghost_recv_dict, full_send_dict] = rec_submesh(tagmap, 0) -
inundation/ga/storm_surge/pyvolution-parallel/run_advection.py
r1231 r1520 4 4 from Numeric import array 5 5 6 import pdb 6 7 from mesh_factory import rectangular 7 8 … … 26 27 #Check that the boundary value gets propagated to all elements 27 28 for t in domain.evolve(yieldstep = 0.01, finaltime = 1.5): 29 pdb.set_trace() 28 30 domain.write_time()
Note: See TracChangeset
for help on using the changeset viewer.