- Timestamp:
- Sep 14, 2006, 9:24:05 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/production/wollongong_2006/run_flagstaff_parallel_api.py
r3584 r3585 31 31 from anuga.pmesh.mesh import importUngenerateFile, Segment 32 32 33 from anuga.caching import cache 34 33 35 # Parallelism 34 import pypar # The Python-MPI interface 35 from anuga_parallel.pmesh_divide import pmesh_divide_metis 36 from anuga_parallel.build_submesh import build_submesh 37 from anuga_parallel.build_local import build_local_mesh 38 from anuga_parallel.build_commun import send_submesh, rec_submesh, extract_hostmesh 39 from anuga_parallel.parallel_shallow_water import Parallel_Domain 40 36 from parallel_api import * 41 37 42 38 # Application specific imports 43 39 import project 44 40 45 46 #------------------------------------------------------------------------------ 47 # Read in processor information 48 #------------------------------------------------------------------------------ 49 50 numprocs = pypar.size() 51 myid = pypar.rank() 52 processor_name = pypar.Get_processor_name() 53 print 'I am processor %d of %d on node %s' %(myid, numprocs, processor_name) 54 55 56 #------------------------------------------------------------------------------ 57 # Preparation of topographic data 58 # 59 # Convert ASC 2 DEM 2 PTS using source data and store result in source data 60 #------------------------------------------------------------------------------ 61 62 max_area = project.base_resolution 41 # Sequential part 63 42 if myid == 0: 64 43 … … 69 48 #-------------------------------------------------------------------------- 70 49 71 72 50 print 'Generate mesh' 73 51 # Generate basic mesh 74 mesh = create_mesh_from_regions(project.bounding_polygon, 75 boundary_tags=project.boundary_tags, 76 maximum_triangle_area=max_area, 77 interior_regions=project.interior_regions) 52 max_area = project.base_resolution 53 54 55 mesh = cache(create_mesh_from_regions, 56 project.bounding_polygon, 57 {'boundary_tags': project.boundary_tags, 58 'maximum_triangle_area':max_area, 59 'interior_regions': project.interior_regions}, 60 verbose=True) 78 61 79 62 # Add buildings that will bind to a Reflective boundary … … 94 77 print domain.statistics() 95 78 79 domain.set_name(project.basename) 80 domain.set_datadir(project.outputdir) 81 82 83 #------------------------------------------------------------------------------ 84 # Setup initial conditions 85 #------------------------------------------------------------------------------ 86 domain.set_quantity('stage', project.initial_sealevel) 87 domain.set_quantity('friction', 0.03) 96 88 domain.set_quantity('elevation', 97 89 filename=project.demname + '.pts', 98 90 use_cache=True, 99 verbose=True) 91 verbose=True) 100 92 101 93 102 # Subdivide the mesh103 print 'Subdivide mesh'104 nodes, triangles, boundary, triangles_per_proc, quantities = \105 pmesh_divide_metis(domain, numprocs)106 94 107 # Build the mesh that should be assigned to each processor,108 # this includes ghost nodes and the communicaiton pattern109 print 'Build submeshes'110 submesh = build_submesh(nodes, triangles, boundary,\111 quantities, triangles_per_proc)112 95 113 # Send the mesh partition to the appropriate processor 114 print 'Distribute submeshes' 115 for p in range(1, numprocs): 116 send_submesh(submesh, triangles_per_proc, p) 96 #--------------- 97 # Parallel stuff 98 #--------------- 117 99 118 # Build the local mesh for processor 0 119 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \ 120 extract_hostmesh(submesh, triangles_per_proc) 100 if myid == 0: 101 # Distribute the domain 102 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict,\ 103 = distribute_mesh(domain) 121 104 105 106 domain_name = domain.get_name() 107 domain_dir = domain.get_datadir() 108 109 for p in range(pypar.size()): 110 pypar.send((domain_name, domain_dir), p) 111 122 112 print 'Communication done' 123 113 … … 127 117 # correct form for the GA data structure) 128 118 129 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict \119 points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict, \ 130 120 = rec_submesh(0) 131 121 122 print 'P %d receiving names' %myid 123 X = pypar.receive(0) 124 print X 125 (domain_name, domain_dir) = X 132 126 133 127 … … 138 132 139 133 134 140 135 # Build the domain for this processor 141 136 domain = Parallel_Domain(points, vertices, boundary, … … 143 138 ghost_recv_dict = ghost_recv_dict) 144 139 145 # Name etc currently has to be set here as they are not transferred from the140 # Name and dir, etc currently has to be set here as they are not transferred from the 146 141 # original domain 147 domain.set_name( project.basename)148 domain.set_datadir( project.outputdir)142 domain.set_name(domain_name) 143 domain.set_datadir(domain_dir) 149 144 150 145 … … 152 147 # Setup initial conditions 153 148 #------------------------------------------------------------------------------ 149 for q in quantities: 150 domain.set_quantity(q, quantities[q]) # Distribute elevation 154 151 155 152 156 domain.set_quantity('elevation', quantities['elevation']) # Distribute elevation 157 domain.set_quantity('stage', project.initial_sealevel) 158 domain.set_quantity('friction', 0.03) 159 160 # 161 # FIXME (Ole): This one segfaults which is bad, because set_quantity is 162 # time consuming and should be done here rather than on processor 0 163 # It did not segfault today 2 Aug 2006 !!! 164 # But values are zero ??.... 165 # 166 #domain.set_quantity('elevation', 167 # filename=project.demname + '.pts', 168 # use_cache=False, 169 # verbose=True) 153 #domain.set_quantity('elevation', quantities['elevation']) # Distribute elevation 154 #domain.set_quantity('stage', project.initial_sealevel) 155 #domain.set_quantity('friction', 0.03) 170 156 171 157
Note: See TracChangeset
for help on using the changeset viewer.