source: anuga_core/source/anuga_parallel/parallel_api.py @ 3588

Last change on this file since 3588 was 3588, checked in by ole, 18 years ago

Work on simple parallel test

File size: 1.8 KB
Line 
1"""Trying to lump parallel stuff into simpler interface
2
3
4"""
5
6# Parallelism
7import pypar   # The Python-MPI interface
8from anuga_parallel.pmesh_divide  import pmesh_divide_metis
9from anuga_parallel.build_submesh import build_submesh
10from anuga_parallel.build_local   import build_local_mesh
11from anuga_parallel.build_commun  import send_submesh, rec_submesh, extract_hostmesh
12from anuga_parallel.parallel_shallow_water import Parallel_Domain
13
14
15#------------------------------------------------------------------------------
16# Read in processor information
17#------------------------------------------------------------------------------
18
19numprocs = pypar.size()
20myid = pypar.rank()
21processor_name = pypar.Get_processor_name()
22print 'I am processor %d of %d on node %s' %(myid, numprocs, processor_name)
23
24
25
26
27def distribute_mesh(domain):
28
29    numprocs = pypar.size()
30
31   
32    # Subdivide the mesh
33    print 'Subdivide mesh'
34    nodes, triangles, boundary, triangles_per_proc, quantities = \
35           pmesh_divide_metis(domain, numprocs)
36
37    # Build the mesh that should be assigned to each processor,
38    # this includes ghost nodes and the communicaiton pattern
39    print 'Build submeshes'   
40    submesh = build_submesh(nodes, triangles, boundary,\
41                            quantities, triangles_per_proc)
42
43    # Send the mesh partition to the appropriate processor
44    print 'Distribute submeshes'       
45    for p in range(1, numprocs):
46      send_submesh(submesh, triangles_per_proc, p)
47
48    # Build the local mesh for processor 0
49    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \
50              extract_hostmesh(submesh, triangles_per_proc)
51
52    # Return structures necessary for building the parallel domain
53    return points, vertices, boundary, quantities, \
54           ghost_recv_dict, full_send_dict
55   
56
57
58
Note: See TracBrowser for help on using the repository browser.