Ignore:
Timestamp:
Sep 19, 2006, 4:23:39 PM (18 years ago)
Author:
ole
Message:

Got flagstaff to work with parallel API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/wollongong_2006/run_flagstaff_parallel_api.py

    r3585 r3624  
    3131from anuga.pmesh.mesh import importUngenerateFile, Segment
    3232
    33 from anuga.caching import cache
     33# Parallelism
     34import pypar   # The Python-MPI interface
     35from anuga_parallel.pmesh_divide  import pmesh_divide_metis
     36from anuga_parallel.build_submesh import build_submesh
     37from anuga_parallel.build_local   import build_local_mesh
     38from anuga_parallel.build_commun  import send_submesh, rec_submesh, extract_hostmesh
     39from anuga_parallel.parallel_shallow_water import Parallel_Domain
    3440
    35 # Parallelism
    36 from parallel_api import *
     41from anuga_parallel.parallel_api import *
    3742
    3843# Application specific imports
    3944import project
    4045
    41 # Sequential part
     46
    4247if myid == 0:
    4348   
     
    4853    #--------------------------------------------------------------------------
    4954
     55
    5056    print 'Generate mesh'
    5157    # Generate basic mesh
    5258    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)
     59    mesh = create_mesh_from_regions(project.bounding_polygon,
     60                                    boundary_tags=project.boundary_tags,
     61                                    maximum_triangle_area=max_area,
     62                                    interior_regions=project.interior_regions)
    6163   
    6264    # Add buildings that will bind to a Reflective boundary
     
    8082    domain.set_datadir(project.outputdir)   
    8183
    82 
    83     #------------------------------------------------------------------------------
    84     # Setup initial conditions
    85     #------------------------------------------------------------------------------
    8684    domain.set_quantity('stage', project.initial_sealevel)
    87     domain.set_quantity('friction', 0.03)   
     85    domain.set_quantity('friction', 0.03)
    8886    domain.set_quantity('elevation',
    8987                        filename=project.demname + '.pts',
     
    9189                        verbose=True)
    9290
     91    #------------------------------------------------------------------------------
     92    # Setup boundary conditions
     93    #------------------------------------------------------------------------------
     94
     95   
     96    D = Dirichlet_boundary([project.initial_sealevel, 0, 0])
     97    R = Reflective_boundary(domain)
     98    domain.set_boundary({'exterior': D,
     99                         'side': D,
     100                         'wall': R,
     101                         'ocean': None}) # This one to be bound later
     102else:
     103    domain = None
     104
     105   
     106
     107domain = distribute(domain)
    93108
    94109
    95110
    96 #---------------
    97 # Parallel stuff
    98 #---------------
    99 
    100 if myid == 0:
    101     # Distribute the domain
    102     points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict,\
    103             = distribute_mesh(domain)
    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    
    112     print 'Communication done'       
    113    
    114 else:
    115     # Read in the mesh partition that belongs to this
    116     # processor (note that the information is in the
    117     # correct form for the GA data structure)
    118 
    119     points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict, \
    120             = rec_submesh(0)
    121 
    122     print 'P %d receiving names' %myid
    123     X = pypar.receive(0)
    124     print X
    125     (domain_name, domain_dir) = X
    126 
    127 
    128 
    129 #------------------------------------------------------------------------------
    130 # Start the computations on each subpartion
    131 #------------------------------------------------------------------------------
    132 
    133 
    134 
    135 # Build the domain for this processor
    136 domain = Parallel_Domain(points, vertices, boundary,
    137                          full_send_dict  = full_send_dict,
    138                          ghost_recv_dict = ghost_recv_dict)
    139 
    140 # Name and dir, etc currently has to be set here as they are not transferred from the
    141 # original domain
    142 domain.set_name(domain_name)
    143 domain.set_datadir(domain_dir)
    144 
    145 
    146 #------------------------------------------------------------------------------
    147 # Setup initial conditions
    148 #------------------------------------------------------------------------------
    149 for q in quantities:
    150     domain.set_quantity(q, quantities[q]) # Distribute elevation   
    151 
    152 
    153 #domain.set_quantity('elevation', quantities['elevation']) # Distribute elevation
    154 #domain.set_quantity('stage', project.initial_sealevel)
    155 #domain.set_quantity('friction', 0.03)
    156 
    157 
    158 #------------------------------------------------------------------------------
    159 # Setup boundary conditions
    160 #------------------------------------------------------------------------------
    161 
    162 D = Dirichlet_boundary([project.initial_sealevel, 0, 0])
    163 R = Reflective_boundary(domain)
     111# Set those boundaries that can't be pickled here using boundary_map.
    164112W = Time_boundary(domain = domain,
    165113                  f=lambda t: [project.initial_sealevel + (60<t<480)*6, 0, 0])
    166114
    167 domain.set_boundary({'exterior': D,
    168                      'side': D,
    169                      'wall': R,
    170                      'ocean': W,
    171                      'ghost': None})
     115boundary_map = domain.boundary_map
     116boundary_map['ocean'] = W
     117domain.set_boundary(boundary_map)
    172118
    173119
Note: See TracChangeset for help on using the changeset viewer.