Changeset 5847


Ignore:
Timestamp:
Oct 18, 2008, 9:13:18 PM (15 years ago)
Author:
steve
Message:

Changed parallel_api so that global mesh only needs to
be constructed on processor 0

Files:
13 edited

Legend:

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

    r5729 r5847  
    199199        self.CFL = CFL
    200200        self.set_timestepping_method(timestepping_method)
    201        
     201        self.set_beta(beta_w)
    202202        self.boundary_map = None  # Will be populated by set_boundary       
    203203       
     
    297297
    298298        return self.time + self.starttime
     299
     300    def set_beta(self,beta):
     301        """Set default beta for limiting
     302        """
     303
     304        self.beta = beta
     305        for name in self.quantities:
     306            #print 'setting beta for quantity ',name
     307            Q = self.quantities[name]
     308            Q.set_beta(beta)
     309
     310    def get_beta(self):
     311        """Get default beta for limiting
     312        """
     313
     314        return self.beta
    299315
    300316    def set_default_order(self, n):
     
    12061222        self.update_ghosts()
    12071223
     1224
     1225        # Update time
     1226        self.time += self.timestep
     1227
    12081228        # Update vertex and edge values
    12091229        self.distribute_to_vertices_and_edges()
     
    12121232        self.update_boundary()
    12131233
    1214         # Update time
    1215         self.time += self.timestep
    12161234
    12171235       
     
    12431261        self.update_ghosts()
    12441262
     1263        # Update time
     1264        self.time += self.timestep
     1265
    12451266        # Update vertex and edge values
    12461267        self.distribute_to_vertices_and_edges()
     
    12481269        # Update boundary values
    12491270        self.update_boundary()
    1250 
    1251         # Update time
    1252         self.time += self.timestep
    12531271
    12541272        #------------------------------------
     
    13091327        self.update_ghosts()
    13101328
     1329        # Update time
     1330        self.time += self.timestep
     1331
    13111332        # Update vertex and edge values
    13121333        self.distribute_to_vertices_and_edges()
     
    13151336        self.update_boundary()
    13161337
    1317         # Update time
    1318         self.time += self.timestep
    13191338
    13201339        #------------------------------------
     
    13391358        self.update_ghosts()
    13401359
     1360
     1361        # Set substep time
     1362        self.time = initial_time + self.timestep*0.5
     1363
    13411364        # Update vertex and edge values
    13421365        self.distribute_to_vertices_and_edges()
     
    13451368        self.update_boundary()
    13461369
    1347         # Set substep time
    1348         self.time = initial_time + self.timestep*0.5
    13491370
    13501371        #------------------------------------
     
    13691390        self.update_ghosts()
    13701391
     1392        # Set new time
     1393        self.time = initial_time + self.timestep       
     1394
    13711395        # Update vertex and edge values
    13721396        self.distribute_to_vertices_and_edges()
     
    13751399        self.update_boundary()
    13761400
    1377         # Set new time
    1378         self.time = initial_time + self.timestep       
    1379        
    1380 
     1401       
    13811402    def evolve_to_end(self, finaltime = 1.0):
    1382         """Iterate evolve all the way to the end
    1383         """
     1403        """Iterate evolve all the way to the end      """
    13841404
    13851405        for _ in self.evolve(yieldstep=None, finaltime=finaltime):
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r5776 r5847  
    8282        self.centroid_backup_values = zeros(N, Float)
    8383
    84         self.beta = 1.0
     84        self.set_beta(1.0)
    8585
    8686
     
    223223    #    """
    224224    #    pass
    225        
     225
     226    def set_beta(self,beta):
     227        """Set default beta value for limiting
     228        """
     229
     230        if beta < 0.0:
     231            print 'WARNING: setting beta < 0.0'
     232        if beta > 2.0:
     233            print 'WARNING: setting beta > 2.0'
     234           
     235        self.beta = beta
     236
     237    def get_beta(self):
     238        """Get default beta value for limiting
     239        """
     240
     241        return self.beta
    226242
    227243    def interpolate(self):
  • anuga_core/source/anuga/advection/advection.py

    r5242 r5847  
    7373
    7474        #Only first is implemented for advection
    75         self.default_order = self.order = 1
    76 
     75        self.set_default_order(1)
     76        self.set_beta(1.0)
     77       
    7778        self.smooth = True
    7879
     
    8283        msg = 'Conserved quantity must be "stage"'
    8384        assert self.conserved_quantities[0] == 'stage', msg
     85
     86
     87    def distribute_to_vertices_and_edges(self):
     88        """Extrapolate conserved quantities from centroid to
     89        vertices and edge-midpoints for each volume
     90
     91        Default implementation is straight first order,
     92        i.e. constant values throughout each element and
     93        no reference to non-conserved quantities.
     94        """
     95
     96        for name in self.conserved_quantities:
     97            Q = self.quantities[name]
     98            if self._order_ == 1:
     99                Q.extrapolate_first_order()
     100            elif self._order_ == 2:
     101                Q.extrapolate_second_order_and_limit_by_edge()
     102                #Q.limit()
     103            else:
     104                raise 'Unknown order'
     105            #Q.interpolate_from_vertices_to_edges()
     106
     107
    84108
    85109
     
    161185
    162186
    163     def evolve(self,
    164                yieldstep = None,
    165                finaltime = None,
    166                duration = None,
    167                skip_initial_step = False):
    168 
    169         """Specialisation of basic evolve method from parent class
    170         """
    171 
    172         #Call basic machinery from parent class
    173         for t in Generic_domain.evolve(self,
    174                                        yieldstep=yieldstep,
    175                                        finaltime=finaltime,
    176                                        duration=duration,
    177                                        skip_initial_step=skip_initial_step):
    178 
    179             #Pass control on to outer loop for more specific actions
    180             yield(t)
     187##     def evolve(self,
     188##                yieldstep = None,
     189##                finaltime = None,
     190##                duration = None,
     191##                skip_initial_step = False):
     192
     193##         """Specialisation of basic evolve method from parent class
     194##         """
     195
     196##         #Call basic machinery from parent class
     197##         for t in Generic_domain.evolve(self,
     198##                                        yieldstep=yieldstep,
     199##                                        finaltime=finaltime,
     200##                                        duration=duration,
     201##                                        skip_initial_step=skip_initial_step):
     202
     203##             #Pass control on to outer loop for more specific actions
     204##             yield(t)
    181205
    182206
  • anuga_core/source/anuga/shallow_water/shallow_water_ext.c

    r5618 r5847  
    18771877    radii             = get_consecutive_array(domain, "radii");   
    18781878    areas             = get_consecutive_array(domain, "areas");   
    1879     tri_full_flag     = get_consecutive_array(domain, "normals");
     1879    tri_full_flag     = get_consecutive_array(domain, "tri_full_flag");
    18801880    already_computed_flux  = get_consecutive_array(domain, "already_computed_flux");
    18811881    max_speed_array   = get_consecutive_array(domain, "max_speed");
  • anuga_core/source/anuga/shallow_water/test_system.py

    r4712 r5847  
    150150        for t in domain.evolve(yieldstep = 5, finaltime = 9.0):
    151151            pass
    152             #print domain.write_time()
     152            #domain.write_time()
    153153            #print "domain.time", domain.time
    154154
     
    157157        times = fid.variables['time'][:]
    158158        stage = fid.variables['stage'][:]
     159        #print stage
    159160        #print "times", times
    160161        #print "fid.starttime", fid.starttime
  • anuga_core/source/anuga_parallel/parallel_api.py

    r3928 r5847  
    4343    # FIXME: Dummy assignment (until boundaries are refactored to
    4444    # be independent of domains until they are applied)
    45     bdmap = {}
    46     for tag in domain.get_boundary_tags():
    47         bdmap[tag] = None
    48    
    49    
    50     domain.set_boundary(bdmap)
     45    if myid == 0:
     46        bdmap = {}
     47        for tag in domain.get_boundary_tags():
     48            bdmap[tag] = None
     49   
     50   
     51        domain.set_boundary(bdmap)
    5152
    5253
  • anuga_core/source/anuga_parallel/test_parallel_sw_runup.py

    r5822 r5847  
    3232
    3333#--------------------------------------------------------------------------
    34 # Setup computational domain
     34# Setup computational domain on processor 0
    3535#--------------------------------------------------------------------------
    36 points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
     36if myid == 0 :
     37    points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
    3738
    38 #if myid == 0:
    39 #    print 'points', points
    40 #    print 'vertices', vertices
     39    #print 'points', points
     40    #print 'vertices', vertices
    4141   
    42 domain = Domain(points, vertices, boundary) # Create domain
     42    domain = Domain(points, vertices, boundary) # Create domain
     43else:
     44    domain = None
    4345
    4446#--------------------------------------------------------------------------
     
    4951    return -x/2                              # linear bed slope
    5052
    51 domain.set_quantity('elevation', topography) # Use function for elevation
    52 domain.set_quantity('friction', 0.0)         # Constant friction
    53 domain.set_quantity('stage', expression='elevation') # Dry initial stage
     53
     54if myid == 0:
     55    domain.set_quantity('elevation', topography) # Use function for elevation
     56    domain.set_quantity('friction', 0.0)         # Constant friction
     57    domain.set_quantity('stage', expression='elevation') # Dry initial stage
    5458
    5559
     
    129133    stage = domain.get_quantity('stage')
    130134    w = stage.get_values(interpolation_points=interpolation_points)
     135
     136    print 'P%d:w(%f) = '%(myid,domain.get_time()),w
    131137   
    132138    for i, _ in enumerate(interpolation_points):
    133139        gauge_values[i].append(w[i])
    134140
    135 if myid == 0:
    136     for i, (x,y) in enumerate(interpolation_points):
     141## if myid == 0:
     142##     for i, (x,y) in enumerate(interpolation_points):
    137143
    138         try:
    139             from pylab import *
    140         except:
    141             pass
    142         else:
    143             ion()
    144             hold(False)
    145             plot(time, gauge_values[i], 'r.-')
    146             #time, predicted_gauge_values[i], 'k-')
     144##         try:
     145##             from pylab import *
     146##         except:
     147##             pass
     148##         else:
     149##             ion()
     150##             hold(False)
     151##             plot(time, gauge_values[i], 'r.-')
     152##             #time, predicted_gauge_values[i], 'k-')
    147153
    148             title('Gauge %d (%f,%f)' %(i,x,y))
    149             xlabel('time(s)')
    150             ylabel('stage (m)')   
    151             #legend(('Observed', 'Modelled'), shadow=True, loc='upper left')
    152             #savefig('Gauge_%d.png' %i, dpi = 300)
     154##             title('Gauge %d (%f,%f)' %(i,x,y))
     155##             xlabel('time(s)')
     156##             ylabel('stage (m)')   
     157##             #legend(('Observed', 'Modelled'), shadow=True, loc='upper left')
     158##             #savefig('Gauge_%d.png' %i, dpi = 300)
    153159
    154         raw_input('Next')
     160##         raw_input('Next')
    155161       
    156162
  • anuga_core/source/obsolete_code/netherlands-chris.py

    r3565 r5847  
    9797N = 60
    9898
    99 N = 4
     99N = 40
    100100#N = 140
    101101#N = 15
     
    165165domain.set_quantity('stage', Constant_height(Z, 0.))
    166166
     167
     168visualize = True
     169if visualize:
     170    from anuga.visualiser import RealtimeVisualiser
     171    vis = RealtimeVisualiser(domain)
     172    vis.render_quantity_height("elevation", zScale=100, offset = 5.0, dynamic=False)
     173    vis.render_quantity_height("stage", zScale =100, dynamic=True, opacity = 0.3)
     174    vis.colour_height_quantity('stage', (lambda q:q['stage'], -0.5, 0.5))
     175    vis.start()
     176
     177time.sleep(2.0)
     178
     179
     180
    167181#Evolve
    168182import time
     
    172186    domain.write_time()
    173187
    174 
     188    if visualize: vis.update()
     189   
     190if visualize: vis.evolveFinished()
    175191
    176192   
  • anuga_core/source/pypar-numeric/mandelbrot_example/compile.py

    r5779 r5847  
    149149    if os.name == 'posix' and os.uname()[4] == 'x86_64':
    150150      #Extra flags for 64 bit architectures
    151       #s += ' -fPIC -m64' #gcc
    152       s += ' -fPIC -tp amd64' #pgcc
     151      s += ' -fPIC -m64' #gcc
     152      #s += ' -fPIC -tp amd64' #pgcc
    153153     
    154154   
  • anuga_core/source/pypar-numeric/mandelbrot_example/mandel_sequential.py

    r5779 r5847  
    1212# User definable parameters
    1313kmax = 2**15  # Maximal number of iterations (=number of colors)
    14 M = N = 700   # width = height = N (200, 400, 600, 700 are good)
     14M = N = 200   # width = height = N (200, 400, 600, 700 are good)
    1515
    1616# Region in complex plane
  • anuga_core/source/pypar-numeric/mandelbrot_example/mandelplot.py

    r5779 r5847  
    1818    """
    1919   
    20     from Tkinter import Frame, Canvas, TOP, NW, PhotoImage
     20    #from Tkinter import Frame, Canvas, TOP, NW, PhotoImage
     21    from pylab import imshow, show
    2122    from Numeric import transpose, Float
    22     from Image import new             # PIL   
     23    #from Image import new             # PIL   
    2324    import time
    2425
     
    2728    # User definable parameters
    2829
    29     imtype = 'ppm'      # Image format (e.g 'ppm', 'bmp', 'tiff')
    30     filename ='mandel'  # Base filename
     30    #imtype = 'ppm'      # Image format (e.g 'ppm', 'bmp', 'tiff')
     31    #filename ='mandel'  # Base filename
    3132   
    3233    exponent = 0.998    # Exponent for morphing colors, good with kmax = 2**15
     
    4748    A = transpose(A).astype(Float)         
    4849
    49     im = new("RGB", A.shape)
     50    #im = new("RGB", A.shape)
    5051
    5152   
     
    7879   
    7980    # Save image to file       
    80     im.putdata(L)
    81     im.save(filename + '.' + imtype, imtype)
     81    imshow(A)
     82    show()
     83   
     84    #im.save(filename + '.' + imtype, imtype)
    8285    print 'Computed plot in %.2f seconds: ' %(time.time()-t0)
    8386
     
    8891    #   sys.exit()
    8992       
    90     import os
    91     os.system('xv %s' %(filename + '.' + imtype))
     93    #import os
     94    #os.system('xv %s' %(filename + '.' + imtype))
    9295
    9396
  • anuga_validation/okushiri_2005/run_okushiri_parallel.py

    r4299 r5847  
    3939#-------------------------
    4040# Create Domain from mesh
     41# on processor 0
    4142#-------------------------
    42 domain = Domain(project.mesh_filename, use_cache=use_cache, verbose=True)
    43 print domain.statistics()
     43if myid == 0 :
     44    domain = Domain(project.mesh_filename, use_cache=use_cache, verbose=True)
     45    print domain.statistics()
    4446
    45 
    46 #-------------------------
    47 # Initial Conditions
    48 #-------------------------
    49 domain.set_quantity('friction', 0.0)
    50 domain.set_quantity('stage', 0.0)
    51 domain.set_quantity('elevation',
    52                     filename=project.bathymetry_filename,
    53                     alpha=0.02,                   
    54                     verbose=True,
    55                     use_cache=use_cache)
    56 
     47    #-------------------------
     48    # Initial Conditions
     49    # At present need to do the
     50    # fitting of the bathymetry
     51    # on a global domain, ie before
     52    # distributing the domain
     53    #-------------------------
     54    domain.set_quantity('friction', 0.0)
     55    domain.set_quantity('stage', 0.0)
     56    domain.set_quantity('elevation',
     57                        filename=project.bathymetry_filename,
     58                        alpha=0.02,                   
     59                        verbose=True,
     60                        use_cache=use_cache)
     61else:
     62    domain = None
    5763
    5864#-------------------------
     
    8692domain.set_boundary({'wave': Bts, 'wall': Br})
    8793
     94# Select triangle containing ch5 for diagnostic output
     95# around known gauge
     96# This should get triangle id 32833 with centroid (4.5244, 1.1972) on one processor
     97try:
     98    triangle_id = domain.get_triangle_containing_point([4.521, 1.196])
     99except:
     100    triangle_id = None
     101
    88102
    89103#-------------------------
     
    94108
    95109for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5):
    96     domain.write_time()
     110    if myid == 0 :
     111        domain.write_time()
     112
     113    if triangle_id is not None :
     114        print domain.timestepping_statistics(track_speeds=False,
     115                                             triangle_id=triangle_id)
    97116
    98117print 'That took %.2f seconds' %(time.time()-t0)
  • anuga_validation/performance_tests/run_profile.py

    r5320 r5847  
    5757s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
    5858
     59#for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()
     60
    5961
    6062import profile, pstats
Note: See TracChangeset for help on using the changeset viewer.