Changeset 1428 for inundation
- Timestamp:
- May 19, 2005, 12:47:39 PM (19 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/parallel/parallel_advection.py
r1426 r1428 96 96 97 97 pypar.send(Xout,send_proc) 98 print 'Processor %d Sending to Processor %d'%(self.processor,send_proc)98 #print 'Processor %d Sending to Processor %d'%(self.processor,send_proc) 99 99 else: 100 100 #Receive data from the iproc processor … … 104 104 105 105 X = pypar.receive(iproc,X) 106 print 'Processor %d receiving from Processor %d'%(self.processor,iproc)106 #print 'Processor %d receiving from Processor %d'%(self.processor,iproc) 107 107 for i, _ in enumerate(X): 108 108 stage_cv[Idg[i]] = X[i] … … 161 161 162 162 163 def parallel_rectangular(m, n, len1=1.0, len2=1.0, origin = (0.0, 0.0)):164 165 166 """Setup a rectangular grid of triangles167 with m+1 by n+1 grid points168 and side lengths len1, len2. If side lengths are omitted169 the mesh defaults to the unit square, divided between all the170 processors171 172 len1: x direction (left to right)173 len2: y direction (bottom to top)174 175 """176 177 from config import epsilon178 from Numeric import zeros, Float, Int179 180 processor = pypar.rank()181 numproc = pypar.size()182 183 184 185 delta1 = float(len1)/m186 delta2 = float(len2)/n187 188 #Calculate number of points189 Np = (m+1)*(n+1)190 191 class VIndex:192 193 def __init__(self, n,m):194 self.n = n195 self.m = m196 197 def __call__(self, i,j):198 return j+i*(self.n+1)199 200 class EIndex:201 202 def __init__(self, n,m):203 self.n = n204 self.m = m205 206 def __call__(self, i,j):207 return 2*(j+i*self.n)208 209 210 I = VIndex(n,m)211 E = EIndex(n,m)212 213 points = zeros( (Np,2), Float)214 215 for i in range(m+1):216 for j in range(n+1):217 218 points[I(i,j),:] = [i*delta1 + origin[0], j*delta2 + origin[1]]219 220 #Construct 2 triangles per rectangular element and assign tags to boundary221 #Calculate number of triangles222 Nt = 2*m*n223 224 225 elements = zeros( (Nt,3), Int)226 boundary = {}227 Idgl = []228 Xgl = []229 Idfl = []230 Xfl = []231 Idgr = []232 Xgr = []233 Idfr = []234 Xfr = []235 236 full_send_dict = {}237 ghost_recv_dict = {}238 nt = -1239 for i in range(m):240 for j in range(n):241 242 i1 = I(i,j+1)243 i2 = I(i,j)244 i3 = I(i+1,j+1)245 i4 = I(i+1,j)246 247 #Lower Element248 nt = E(i,j)249 if i == m-1:250 #print 'nt =',nt251 Idgr.append(nt)252 Idfr.append(E(1,j))253 if i == 0:254 Idgl.append(nt)255 Idfl.append(E(m-2,j))256 257 if i == m-1:258 boundary[nt, 2] = 'right'259 if j == 0:260 boundary[nt, 1] = 'bottom'261 elements[nt,:] = [i4,i3,i2]262 263 #Upper Element264 nt = E(i,j)+1265 if i == m-1:266 Idgr.append(nt)267 Idfr.append(E(1,j)+1)268 if i == 0:269 Idgl.append(nt)270 Idfl.append(E(m-2,j)+1)271 272 if i == 0:273 boundary[nt, 2] = 'left'274 if j == n-1:275 boundary[nt, 1] = 'top'276 elements[nt,:] = [i1,i2,i3]277 278 Idfl = array(Idfl,Int)279 Idgl = array(Idgl,Int)280 Xfl = zeros(Idfl.shape,Float)281 Xgl = zeros(Idgl.shape,Float)282 283 Idfr = array(Idfr,Int)284 Idgr = array(Idgr,Int)285 Xfr = zeros(Idfr.shape,Float)286 Xgr = zeros(Idgr.shape,Float)287 288 #print Idf289 #print Idg290 full_send_dict[(processor-1)%numproc] = [Idfl, Xfl]291 ghost_recv_dict[(processor-1)%numproc] = [Idgl, Xgl]292 full_send_dict[(processor+1)%numproc] = [Idfr, Xfr]293 ghost_recv_dict[(processor+1)%numproc] = [Idgr, Xgr]294 295 return points, elements, boundary, full_send_dict, ghost_recv_dict296 297 298 299 def rectangular_periodic(m, n, len1=1.0, len2=1.0, origin = (0.0, 0.0)):300 301 302 """Setup a rectangular grid of triangles303 with m+1 by n+1 grid points304 and side lengths len1, len2. If side lengths are omitted305 the mesh defaults to the unit square.306 307 len1: x direction (left to right)308 len2: y direction (bottom to top)309 310 Return to lists: points and elements suitable for creating a Mesh or311 FVMesh object, e.g. Mesh(points, elements)312 """313 314 from config import epsilon315 from Numeric import zeros, Float, Int316 317 delta1 = float(len1)/m318 delta2 = float(len2)/n319 320 #Calculate number of points321 Np = (m+1)*(n+1)322 323 class VIndex:324 325 def __init__(self, n,m):326 self.n = n327 self.m = m328 329 def __call__(self, i,j):330 return j+i*(self.n+1)331 332 class EIndex:333 334 def __init__(self, n,m):335 self.n = n336 self.m = m337 338 def __call__(self, i,j):339 return 2*(j+i*self.n)340 341 342 I = VIndex(n,m)343 E = EIndex(n,m)344 345 points = zeros( (Np,2), Float)346 347 for i in range(m+1):348 for j in range(n+1):349 350 points[I(i,j),:] = [i*delta1 + origin[0], j*delta2 + origin[1]]351 352 #Construct 2 triangles per rectangular element and assign tags to boundary353 #Calculate number of triangles354 Nt = 2*m*n355 356 357 elements = zeros( (Nt,3), Int)358 boundary = {}359 ghosts = {}360 nt = -1361 for i in range(m):362 for j in range(n):363 364 i1 = I(i,j+1)365 i2 = I(i,j)366 i3 = I(i+1,j+1)367 i4 = I(i+1,j)368 369 #Lower Element370 nt = E(i,j)371 if i == m-1:372 ghosts[nt] = E(1,j)373 if i == 0:374 ghosts[nt] = E(m-2,j)375 376 if j == n-1:377 ghosts[nt] = E(i,1)378 379 if j == 0:380 ghosts[nt] = E(i,n-2)381 382 if i == m-1:383 boundary[nt, 2] = 'right'384 if j == 0:385 boundary[nt, 1] = 'bottom'386 elements[nt,:] = [i4,i3,i2]387 388 #Upper Element389 nt = E(i,j)+1390 if i == m-1:391 ghosts[nt] = E(1,j)+1392 if i == 0:393 ghosts[nt] = E(m-2,j)+1394 395 if j == n-1:396 ghosts[nt] = E(i,1)+1397 398 if j == 0:399 ghosts[nt] = E(i,n-2)+1400 401 if i == 0:402 boundary[nt, 2] = 'left'403 if j == n-1:404 boundary[nt, 1] = 'top'405 elements[nt,:] = [i1,i2,i3]406 407 #bottom left408 nt = E(0,0)409 nf = E(m-2,n-2)410 ghosts[nt] = nf411 ghosts[nt+1] = nf+1412 413 #bottom right414 nt = E(m-1,0)415 nf = E(1,n-2)416 ghosts[nt] = nf417 ghosts[nt+1] = nf+1418 419 #top left420 nt = E(0,n-1)421 nf = E(m-2,1)422 ghosts[nt] = nf423 ghosts[nt+1] = nf+1424 425 #top right426 nt = E(m-1,n-1)427 nf = E(1,1)428 ghosts[nt] = nf429 ghosts[nt+1] = nf+1430 431 return points, elements, boundary, ghosts432 433 def rectangular_periodic_lr(m, n, len1=1.0, len2=1.0, origin = (0.0, 0.0)):434 435 436 """Setup a rectangular grid of triangles437 with m+1 by n+1 grid points438 and side lengths len1, len2. If side lengths are omitted439 the mesh defaults to the unit square.440 441 len1: x direction (left to right)442 len2: y direction (bottom to top)443 444 Return to lists: points and elements suitable for creating a Mesh or445 Domain object, e.g. Mesh(points, elements)446 """447 448 from config import epsilon449 from Numeric import zeros, Float, Int450 451 delta1 = float(len1)/m452 delta2 = float(len2)/n453 454 #Calculate number of points455 Np = (m+1)*(n+1)456 457 class VIndex:458 459 def __init__(self, n,m):460 self.n = n461 self.m = m462 463 def __call__(self, i,j):464 return j+i*(self.n+1)465 466 class EIndex:467 468 def __init__(self, n,m):469 self.n = n470 self.m = m471 472 def __call__(self, i,j):473 return 2*(j+i*self.n)474 475 476 I = VIndex(n,m)477 E = EIndex(n,m)478 479 points = zeros( (Np,2), Float)480 481 for i in range(m+1):482 for j in range(n+1):483 484 points[I(i,j),:] = [i*delta1 + origin[0], j*delta2 + origin[1]]485 486 #Construct 2 triangles per rectangular element and assign tags to boundary487 #Calculate number of triangles488 Nt = 2*m*n489 490 491 elements = zeros( (Nt,3), Int)492 boundary = {}493 ghosts = {}494 nt = -1495 for i in range(m):496 for j in range(n):497 498 i1 = I(i,j+1)499 i2 = I(i,j)500 i3 = I(i+1,j+1)501 i4 = I(i+1,j)502 503 #Lower Element504 nt = E(i,j)505 if i == m-1:506 ghosts[nt] = E(1,j)507 if i == 0:508 ghosts[nt] = E(m-2,j)509 510 if i == m-1:511 boundary[nt, 2] = 'right'512 if j == 0:513 boundary[nt, 1] = 'bottom'514 elements[nt,:] = [i4,i3,i2]515 516 #Upper Element517 nt = E(i,j)+1518 if i == m-1:519 ghosts[nt] = E(1,j)+1520 if i == 0:521 ghosts[nt] = E(m-2,j)+1522 523 if i == 0:524 boundary[nt, 2] = 'left'525 if j == n-1:526 boundary[nt, 1] = 'top'527 elements[nt,:] = [i1,i2,i3]528 529 530 return points, elements, boundary, ghosts -
inundation/ga/storm_surge/parallel/run_parallel_advection.py
r1426 r1428 8 8 from parallel_advection import * 9 9 from Numeric import array 10 from parallel_meshes import * 10 11 11 12 import pypar … … 17 18 18 19 19 N = 3020 M = 3020 N = 20 21 M = 20 21 22 22 23 points, vertices, boundary, full_send_dict, ghost_recv_dict = parallel_rectangular(N, M) … … 56 57 57 58 #Check that the boundary value gets propagated to all elements 58 for t in domain.evolve(yieldstep = 0.01, finaltime = 0.02): 59 domain.write_time() 59 for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0): 60 if myid == 0: 61 domain.write_time() 62 63 if myid == 0: 64 print 'Evolution ended' -
inundation/ga/storm_surge/zeus/parallel.zpi
r1398 r1428 78 78 <file>..\parallel\mg2ga.py</file> 79 79 <file>..\parallel\parallel_advection.py</file> 80 <file>..\parallel\parallel_meshes.py</file> 80 81 <file>..\parallel\run_advection.py</file> 81 82 <file>..\parallel\run_parallel_advection.py</file>
Note: See TracChangeset
for help on using the changeset viewer.