Changeset 3612


Ignore:
Timestamp:
Sep 15, 2006, 4:17:49 PM (18 years ago)
Author:
ole
Message:

Parallel API now transfers all quantities, boundary conditions and some domain attributes in addition to the meshes.

Parallelisation virtually down to one line of code!

Location:
anuga_core/source
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r3563 r3612  
    174174        self.CFL = CFL
    175175
     176        self.boundary_map = None  # Will be populated by set_boundary       
     177       
     178
    176179        #Model time
    177180        self.time = 0.0
  • anuga_core/source/anuga_parallel/parallel_api.py

    r3595 r3612  
    3333    if myid == 0:
    3434        domain_name = domain.get_name()
     35        domain_dir = domain.get_datadir()
     36        # FIXME - what other attributes need to be transferred?
     37
    3538        for p in range(1, numprocs):
    36             print 'p', p           
    37             pypar.send(domain_name, p)
     39            pypar.send((domain_name, domain_dir), p)
    3840    else:
    39         if verbose: print 'Receiving'
     41        if verbose: print 'P%d: Receiving domain attributes' %(myid)
    4042
    41         domain_name = pypar.receive(0)
     43        domain_name, domain_dir = pypar.receive(0)
     44
     45
     46
     47    # Distribute boundary conditions   
     48    if myid == 0:
     49        boundary_map = domain.boundary_map
     50        for p in range(1, numprocs):
     51            pypar.send(boundary_map, p)
     52    else:
     53        if verbose: print 'P%d: Receiving boundary map' %(myid)       
     54
     55        boundary_map = pypar.receive(0)
     56       
     57
    4258
    4359
     
    5773        # Read in the mesh partition that belongs to this
    5874        # processor
     75        if verbose: print 'P%d: Receiving submeshes' %(myid)               
    5976        points, vertices, boundary, quantities,\
    6077                ghost_recv_dict, full_send_dict,\
    6178                = rec_submesh(0)
    62 
    6379
    6480
     
    7894
    7995    #------------------------------------------------------------------------
     96    # Transfer boundary conditions to each subdomain
     97    #------------------------------------------------------------------------
     98    boundary_map['ghost'] = None  # Add binding to ghost boundary
     99    domain.set_boundary(boundary_map)
     100
     101
     102    #------------------------------------------------------------------------
    80103    # Transfer other attributes to each subdomain
    81104    #------------------------------------------------------------------------
    82 
    83     # FIXME Do them all
    84     domain.set_name(domain_name)   
     105    domain.set_name(domain_name)
     106    domain.set_datadir(domain_dir)       
    85107
    86108    #------------------------------------------------------------------------
  • anuga_core/source/anuga_parallel/test_parallel_sw_runup.py

    r3595 r3612  
    77similar to a beach environment
    88
    9 This is a very simple test of the parallel algorithm
     9This is a very simple test of the parallel algorithm using the simplified parallel API
    1010"""
    1111
     
    2323from anuga.shallow_water import Transmissive_boundary
    2424
    25 from parallel_api import *
     25from parallel_api import distribute, myid
    2626
    2727
     
    3232domain = Domain(points, vertices, boundary) # Create domain
    3333domain.set_name('runup')                    # Set sww filename
     34domain.set_datadir('.')                     # Set output dir
    3435
    3536
     
    4647
    4748
    48 #--------------------------------------------------------------------------
    49 # Create the parallel domain
    50 #--------------------------------------------------------------------------
    51 domain = distribute(domain, verbose=True)
    52 
    53 print 'P%d: name = %s' %(myid, domain.get_name())
    54 
    55 
    56 # TODO: Communicate all attributes of domain including boundary conditions
    57 
    58 # Name and dir, etc currently has to be set here as they are not
    59 # transferred from the original domain
    60 #domain.set_name('runup')                    # Set sww filename
    61 
    62 
    63 
    64 
    6549#------------------------------------------------------------------------------
    66 # Setup parallel boundary conditions
     50# Setup boundary conditions
    6751#------------------------------------------------------------------------------
    6852
     
    7155
    7256# Associate boundary tags with boundary objects
    73 domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br,
    74                      'ghost': None})
     57domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br})
     58
     59
     60#--------------------------------------------------------------------------
     61# Create the parallel domain
     62#--------------------------------------------------------------------------
     63domain = distribute(domain, verbose=True)
    7564
    7665
     
    8069
    8170for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0):
    82     pass
    83     #domain.write_time()
     71    domain.write_time()
    8472   
    8573
Note: See TracChangeset for help on using the changeset viewer.