Changeset 3589


Ignore:
Timestamp:
Sep 14, 2006, 10:00:44 AM (18 years ago)
Author:
ole
Message:

New parallel test example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga_parallel/test_parallel_sw_runup.py

    r3588 r3589  
    2121from parallel_api import *
    2222
     23#------------------------------------------------------------------------------
     24# Read in processor information
     25#------------------------------------------------------------------------------
     26
     27numprocs = pypar.size()
     28myid = pypar.rank()
     29processor_name = pypar.Get_processor_name()
     30print 'I am processor %d of %d on node %s' %(myid, numprocs, processor_name)
     31
    2332
    2433#------------------------------------------------------------------------------
     
    3140    #--------------------------------------------------------------------------
    3241
    33     points, vertices, boundary = rectangular_cross(20, 20) # Basic mesh
     42    points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
    3443
    3544    domain = Domain(points, vertices, boundary) # Create domain
     
    4958
    5059
     60    #------------ -------------------------------------------------------------
     61    # Distribute the domain
    5162    #--------------------------------------------------------------------------
    52     # Setup boundary conditions
    53     #--------------------------------------------------------------------------
     63   
     64    # Subdivide the mesh
     65    print 'Subdivide mesh'
     66    nodes, triangles, boundary, triangles_per_proc, quantities = \
     67           pmesh_divide_metis(domain, numprocs)
    5468
    55     Br = Reflective_boundary(domain)      # Solid reflective wall
    56     Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
     69    # Build the mesh that should be assigned to each processor,
     70    # this includes ghost nodes and the communicaiton pattern
     71    print 'Build submeshes'   
     72    submesh = build_submesh(nodes, triangles, boundary,\
     73                            quantities, triangles_per_proc)
    5774
    58     # Associate boundary tags with boundary objects
    59     domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br})
     75    # Send the mesh partition to the appropriate processor
     76    print 'Distribute submeshes'       
     77    for p in range(1, numprocs):
     78      send_submesh(submesh, triangles_per_proc, p)
    6079
     80    # Build the local mesh for processor 0
     81    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \
     82              extract_hostmesh(submesh, triangles_per_proc)
    6183
    62 #------------------------------------------------------------------------------
    63 # Parallel stuff
    64 #------------------------------------------------------------------------------
    65 
    66 if myid == 0:
    67     # Distribute the domain
    68     points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict,\
    69             = distribute_mesh(domain)
    7084    print 'Communication done'       
    7185   
     
    102116
    103117
     118
    104119#------------------------------------------------------------------------------
    105120# Setup parallel boundary conditions
Note: See TracChangeset for help on using the changeset viewer.