Changeset 8555


Ignore:
Timestamp:
Sep 4, 2012, 9:40:01 PM (13 years ago)
Author:
steve
Message:

speeding up ghost_bdy_layer

Location:
trunk/anuga_core/source/anuga_parallel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga_parallel/distribute_mesh.py

    r8554 r8555  
    744744
    745745
    746     print ghosttri
     746    #print ghosttri
    747747
    748748    # FIXME SR: For larger layers need to pass through the correct
    749749    # boundary tag!
    750750
    751     for t in ghosttri:
    752         ghost_list.append(t[0])
    753 
    754 
    755 
    756     for t in ghosttri:
    757 
    758         n = mesh.neighbours[t[0], 0]
    759         if not is_in_processor(ghost_list, tlower, tupper, n):
    760             if boundary.has_key( (t[0], 0) ):
    761                 subboundary[t[0], 0] = boundary[t[0],0]
    762             else:
    763                 subboundary[t[0], 0] = 'ghost'
    764 
    765 
    766         n = mesh.neighbours[t[0], 1]
    767         if not is_in_processor(ghost_list, tlower, tupper, n):
    768             if boundary.has_key( (t[0], 1) ):
    769                 subboundary[t[0], 1] = boundary[t[0],1]
    770             else:
    771                 subboundary[t[0], 1] = 'ghost'
    772 
    773 
    774         n = mesh.neighbours[t[0], 2]
    775         if not is_in_processor(ghost_list, tlower, tupper, n):
    776             if boundary.has_key( (t[0], 2) ):
    777                 subboundary[t[0], 2] = boundary[t[0],2]
    778             else:
    779                 subboundary[t[0], 2] = 'ghost'
    780 
     751#    for t in ghosttri:
     752#        ghost_list.append(t[0])
     753#
     754#
     755#
     756#    for t in ghosttri:
     757#
     758#        n = mesh.neighbours[t[0], 0]
     759#        if not is_in_processor(ghost_list, tlower, tupper, n):
     760#            if boundary.has_key( (t[0], 0) ):
     761#                subboundary[t[0], 0] = boundary[t[0],0]
     762#            else:
     763#                subboundary[t[0], 0] = 'ghost'
     764#
     765#
     766#        n = mesh.neighbours[t[0], 1]
     767#        if not is_in_processor(ghost_list, tlower, tupper, n):
     768#            if boundary.has_key( (t[0], 1) ):
     769#                subboundary[t[0], 1] = boundary[t[0],1]
     770#            else:
     771#                subboundary[t[0], 1] = 'ghost'
     772#
     773#
     774#        n = mesh.neighbours[t[0], 2]
     775#        if not is_in_processor(ghost_list, tlower, tupper, n):
     776#            if boundary.has_key( (t[0], 2) ):
     777#                subboundary[t[0], 2] = boundary[t[0],2]
     778#            else:
     779#                subboundary[t[0], 2] = 'ghost'
     780#
    781781
    782782
     
    784784    new_ghost_list = ghosttri[:,0]
    785785
    786     print new_ghost_list
    787 
    788     # 0 boundaries
    789     nghb = mesh.neighbours[new_ghost_list,0]
    790     gl0 = num.extract(num.logical_or(nghb < tlower, nghb >= tupper), new_ghost_list)
    791 
    792 
     786    #print new_ghost_list
     787
     788    # 0 edge boundaries
     789    nghb0 = mesh.neighbours[new_ghost_list,0]
     790    gl0 = num.extract(num.logical_or(nghb0 < tlower, nghb0 >= tupper), new_ghost_list)
    793791    nghb0 = mesh.neighbours[gl0,0]
    794792    flag = numset.in1d(nghb0,new_ghost_list)
    795793    gl0 = num.extract(num.logical_not(flag),gl0)
    796 
    797     print tlower, tupper
    798     print nghb
    799     print gl0
    800     print nghb0
    801     print flag
    802     print gl0
     794    edge0 = 0*num.ones_like(gl0)
     795    n0 = len(edge0)
     796    values0 = ['ghost']*n0
     797
     798    # 1 edge boundary
     799    nghb1 = mesh.neighbours[new_ghost_list,1]
     800    gl1 = num.extract(num.logical_or(nghb1 < tlower, nghb1 >= tupper), new_ghost_list)
     801    nghb1 = mesh.neighbours[gl1,1]
     802    flag = numset.in1d(nghb1,new_ghost_list)
     803    gl1 = num.extract(num.logical_not(flag),gl1)
     804    edge1 = 1*num.ones_like(gl1)
     805    n1 = len(edge1)
     806    values1 = ['ghost']*n1
     807
     808    # 1 edge boundary
     809    nghb2 = mesh.neighbours[new_ghost_list,2]
     810    gl2 = num.extract(num.logical_or(nghb2 < tlower, nghb2 >= tupper), new_ghost_list)
     811    nghb2 = mesh.neighbours[gl2,2]
     812    flag = numset.in1d(nghb2,new_ghost_list)
     813    gl2 = num.extract(num.logical_not(flag),gl2)
     814    edge2 = 2*num.ones_like(gl2)
     815    n2 = len(edge2)
     816    values2 = ['ghost']*n2
     817
     818
     819    gl = num.concatenate((gl0,gl1,gl2))
     820    edge = num.concatenate((edge0,edge1,edge2))
     821    values = values0 + values1 + values2
     822#    print gl
     823#    print edge
     824#    print values
     825
     826    subboundary = dict(zip(zip(gl,edge),values))
     827    #intersect with boundary
     828
     829    subboundary.update( (k,boundary[k]) for k in subboundary.viewkeys() & boundary.viewkeys() )
     830
     831    #print subboundary
    803832
    804833
     
    959988
    960989
    961         # Find the boundary layer formed by the ghost triangles
     990        # Find the new boundary formed by the ghost triangles
    962991       
    963992        subbnd = ghost_bnd_layer(subtri, tlower, tupper, mesh, p)
  • trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py

    r8554 r8555  
    4343    dx = dy = 0.005
    4444    dx = dy = 0.005
    45     dx = dy  = 0.5
     45    #dx = dy  = 0.5
    4646    domain = rectangular_cross_domain(int(length/dx), int(width/dy),
    4747                                              len1=length, len2=width)
Note: See TracChangeset for help on using the changeset viewer.