Changeset 8610


Ignore:
Timestamp:
Nov 9, 2012, 4:46:46 PM (11 years ago)
Author:
steve
Message:

Added in some sequential distribute run scripts

Location:
trunk/anuga_core/source/anuga_parallel
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_tsunami.py

    r8585 r8610  
    5555#--------------------------------------------------------------------------
    5656if myid == 0:
    57     length = 1.0
    58     width = 1.0
     57    length = 2.0
     58    width = 2.0
    5959    dx = dy = 0.005
    6060    #dx = dy = 0.00125
  • trunk/anuga_core/source/anuga_parallel/run_sequential_dist_distribute_rectangular.py

    r8609 r8610  
    1616import time
    1717import sys
     18import numpy
    1819
    1920
     
    2728# Parallel interface
    2829#---------------------------
    29 from anuga_parallel.sequential_distribute import sequential_distribute
     30from anuga_parallel.sequential_distribute import sequential_distribute_dump
    3031
    3132
     
    3536
    3637#--------------------------------------------------------------------------
     38# Setup functions for topograpy etc
     39#--------------------------------------------------------------------------
     40scale_me=1.0
     41
     42def topography(x,y):
     43        return (-x/2.0 +0.05*numpy.sin((x+y)*200.0))*scale_me
     44
     45def stagefun(x,y):
     46    stge=-0.2*scale_me #+0.01*(x>0.9)
     47    #topo=topography(x,y)
     48    return stge#*(stge>topo) + (topo)*(stge<=topo)
     49
     50
     51#--------------------------------------------------------------------------
    3752# Setup Domain only on processor 0
    3853#--------------------------------------------------------------------------
    3954myid = 0
    40 numprocs = 100
    41 if myid == 0:
    42     length = 2.0
    43     width = 2.0
    44     dx = dy = 0.005  # 640,000
    45     dx = dy = 0.00125
    46     #dx = dy  = 0.5
    47     domain = rectangular_cross_domain(int(length/dx), int(width/dy),
    48                                               len1=length, len2=width, verbose=verbose)
     55numprocs = 4
    4956
    5057
    51     print domain.number_of_global_triangles
    52     domain.set_store(True)
    53     domain.set_quantity('elevation', lambda x,y : -1.0-x )
    54     domain.set_quantity('stage', 1.0)
    55     domain.set_flow_algorithm('tsunami')
    56     domain.set_name('sw_rectangle')
    57     #domain.print_statistics()
    5858
    59 else:
    60     domain = None
     59length = 2.0
     60width = 2.0
     61dx = dy = 0.005  # 640,000
     62dx = dy  = 0.05
     63domain = rectangular_cross_domain(int(length/dx), int(width/dy),
     64                                          len1=length, len2=width, verbose=verbose)
     65
     66
     67print domain.number_of_global_triangles
     68
     69domain.set_store(True)
     70domain.set_flow_algorithm('tsunami')
     71domain.set_minimum_allowed_height(0.01)
     72domain.set_quantity('elevation',topography)     # Use function for elevation
     73domain.get_quantity('elevation').smooth_vertex_values()
     74domain.set_quantity('friction',0.03)            # Constant friction
     75domain.set_quantity('stage', stagefun)          # Constant negative initial stage
     76domain.get_quantity('stage').smooth_vertex_values()
     77
     78domain.set_name('sw_rectangle')
     79#domain.print_statistics()
     80
    6181
    6282t1 = time.time()
     
    7696#domain = distribute(domain,verbose=verbose)
    7797
    78 sequential_distribute(domain,numprocs, verbose = True)
     98sequential_distribute_dump(domain, numprocs, verbose = True)
    7999
    80100
     
    84104    print 'Distribute domain ',t2-t1
    85105   
    86 if myid == 0 : print 'after parallel domain'
    87106
    88107
     108
  • trunk/anuga_core/source/anuga_parallel/sequential_distribute.py

    r8609 r8610  
    1818
    1919
    20 def sequential_distribute(domain, numprocs=1, verbose=False, debug=False, parameters = None):
     20def sequential_distribute_dump(domain, numprocs=1, verbose=False, debug=False, parameters = None):
    2121    """ Distribute the domain, create parallel domain and pickle result
    2222    """
     
    122122
    123123
    124         args = [points, vertices, boundary]
     124        #args = [points, vertices, boundary]
    125125
    126126        kwargs = {'full_send_dict': full_send_dict,
     
    139139                'ghost_layer_width':  ghost_layer_width}
    140140
    141         parallel_domain = Parallel_domain(*args, **kwargs)
     141#        parallel_domain = Parallel_domain(points, vertices, boundary, **kwargs)
    142142
    143143
     
    146146        # Transfer initial conditions to each subdomain
    147147        #------------------------------------------------------------------------
    148         for q in quantities:
    149             parallel_domain.set_quantity(q, quantities[q])
     148#        for q in quantities:
     149#            parallel_domain.set_quantity(q, quantities[q])
    150150
    151151
     
    153153        # Transfer boundary conditions to each subdomain
    154154        #------------------------------------------------------------------------
    155         boundary_map['ghost'] = None  # Add binding to ghost boundary
    156         parallel_domain.set_boundary(boundary_map)
     155#        boundary_map['ghost'] = None  # Add binding to ghost boundary
     156#        parallel_domain.set_boundary(boundary_map)
    157157
    158158
     
    160160        # Transfer other attributes to each subdomain
    161161        #------------------------------------------------------------------------
    162         parallel_domain.set_name(domain_name)
    163         parallel_domain.set_datadir(domain_dir)
    164         parallel_domain.set_store(domain_store)
    165         parallel_domain.set_minimum_storable_height(domain_minimum_storable_height)
    166         parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height)
    167         parallel_domain.set_flow_algorithm(domain_flow_algorithm)
    168         parallel_domain.geo_reference = georef
     162#        parallel_domain.set_name(domain_name)
     163#        parallel_domain.set_datadir(domain_dir)
     164#        parallel_domain.set_store(domain_store)
     165#        parallel_domain.set_minimum_storable_height(domain_minimum_storable_height)
     166#        parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height)
     167#        parallel_domain.set_flow_algorithm(domain_flow_algorithm)
     168#        parallel_domain.geo_reference = georef
    169169
    170170
     
    173173        # Now let's store the parallel_domain via cPickle
    174174        #-----------------------------------------------------------------------
     175#        import cPickle
     176#        pickle_name = domain_name + '_P%g_%g.pickle'% (numprocs,p)
     177#        f = file(pickle_name, 'wb')
     178#        cPickle.dump(parallel_domain, f, protocol=cPickle.HIGHEST_PROTOCOL)
     179#        f.close()
     180
     181
     182        #FIXME SR: Looks like we could reduce storage by a factor of 4 by just
     183        # storing the data to create the parallel_domain instead of pickling
     184        # a created domain
    175185        import cPickle
    176186        pickle_name = domain_name + '_P%g_%g.pickle'% (numprocs,p)
    177187        f = file(pickle_name, 'wb')
    178         cPickle.dump(parallel_domain, f, protocol=cPickle.HIGHEST_PROTOCOL)
    179         f.close()
    180 
    181         #FIXME SR: Looks like we could reduce storage by a factor of 4 by just
    182         # storing the data to create the parallel_domain instead of pickling
    183         # a created domain
    184         #pickle_name = 'test_P%g_%g.pickle'% (numprocs,p)
    185         #f = file(pickle_name, 'wb')
    186         #cPickle.dump( (args, kwargs, quantities), f, protocol=cPickle.HIGHEST_PROTOCOL)
    187         #f.close()
     188        tostore = (kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \
     189                   domain_minimum_allowed_height, domain_flow_algorithm, georef)
     190        cPickle.dump( tostore, f, protocol=cPickle.HIGHEST_PROTOCOL)
    188191
    189192    return
    190193
    191194
     195def sequential_distribute_load(filename = 'domain', verbose = False):
     196
     197
     198    from anuga_parallel import myid, numprocs
     199
     200
     201    #---------------------------------------------------------------------------
     202    # Open pickle files
     203    #---------------------------------------------------------------------------
     204    import cPickle
     205    pickle_name = filename+'_P%g_%g.pickle'% (numprocs,myid)
     206    f = file(pickle_name, 'rb')
     207    kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \
     208                   domain_minimum_allowed_height, domain_flow_algorithm, georef = cPickle.load(f)
     209    f.close()
     210
     211    #---------------------------------------------------------------------------
     212    # Create parallel domain
     213    #---------------------------------------------------------------------------
     214    parallel_domain = Parallel_domain(points, vertices, boundary, **kwargs)
     215
     216
     217    #------------------------------------------------------------------------
     218    # Copy in quantity data
     219    #------------------------------------------------------------------------
     220    for q in quantities:
     221        parallel_domain.set_quantity(q, quantities[q])
     222
     223
     224    #------------------------------------------------------------------------
     225    # Transfer boundary conditions to each subdomain
     226    #------------------------------------------------------------------------
     227    boundary_map['ghost'] = None  # Add binding to ghost boundary
     228    parallel_domain.set_boundary(boundary_map)
     229
     230
     231    #------------------------------------------------------------------------
     232    # Transfer other attributes to each subdomain
     233    #------------------------------------------------------------------------
     234    parallel_domain.set_name(domain_name)
     235    parallel_domain.set_datadir(domain_dir)
     236    parallel_domain.set_store(domain_store)
     237    parallel_domain.set_minimum_storable_height(domain_minimum_storable_height)
     238    parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height)
     239    parallel_domain.set_flow_algorithm(domain_flow_algorithm)
     240    parallel_domain.geo_reference = georef
     241
     242
     243    return parallel_domain
    192244
    193245def extract_l2g_map(map):
Note: See TracChangeset for help on using the changeset viewer.