Changeset 1407


Ignore:
Timestamp:
May 17, 2005, 12:02:50 PM (19 years ago)
Author:
steve
Message:

Adding parallel update_timestep

Location:
inundation/ga/storm_surge
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/parallel/advection.py

    r1363 r1407  
    2424"""
    2525
     26from realtime_visualisation_new import Visualiser
    2627from domain import *
    2728Generic_domain = Domain #Rename
     
    4849        self.visualise_timer = True
    4950        self.visualise_range_z = None
     51
    5052        self.smooth = True
    5153
     54
     55
     56    def initialise_visualiser(self,scale_z=1.0):
     57        #Realtime visualisation
     58        self.visualiser = Visualiser(self,scale_z)
     59        self.visualise = True
    5260
    5361
     
    180188        if self.visualise is True and self.time == 0.0:
    181189            import realtime_visualisation_new as visualise
    182             visualise.create_surface(self)
     190            self.visualiser.update_quantity('stage')
     191            self.visualiser.update_timer()
    183192
    184193        #Call basic machinery from parent class
     
    186195            #Real time viz
    187196            if self.visualise is True:
    188                 visualise.update(self)
     197                self.visualiser.update_quantity('stage')
     198                self.visualiser.update_timer()
    189199
    190200            #Pass control on to outer loop for more specific actions
  • inundation/ga/storm_surge/parallel/parallel_advection.py

    r1402 r1407  
    1717Advection_Domain = Domain
    1818from Numeric import zeros, Float, Int, ones
     19import pypar
     20
    1921
    2022class Parallel_Domain(Advection_Domain):
    2123
    22     def __init__(self, coordinates, vertices, boundary = None, ghosts = None, velocity = None):
     24    def __init__(self, coordinates, vertices, boundary = None, ghosts = None, velocity = None, processor=0):
    2325
    2426        Advection_Domain.__init__(self, coordinates, vertices, boundary, velocity)
    2527
    2628        N = self.number_of_elements
     29
     30        self.processor = processor
    2731
    2832        if  ghosts == None:
     
    3640                self.full[key] = -1
    3741
     42
     43
     44
    3845    def check_integrity(self):
    3946        Advection_Domain.check_integrity(self)
     
    4148        msg = 'Will need to check global and local numbering'
    4249        assert self.conserved_quantities[0] == 'stage', msg
     50
     51
     52
     53    def update_timestep(self, yieldstep, finaltime):
     54        Advection_Domain.update_timestep(self, yieldstep, finaltime)
     55
     56        timestep = 0.0
     57        pypar.raw_reduce(self.timestep,timestep,pypar.MIN,0)
     58        print 'Processor %d, Timestep %.4f'%(self.processor,timestep)
     59
     60
    4361
    4462
     
    4967                stage_cv[triangle] = stage_cv[self.ghosts[triangle]]
    5068
     69
     70    def write_time(self):
     71        if self.min_timestep == self.max_timestep:
     72            print 'Processor %d, Time = %.4f, delta t = %.8f, steps=%d (%d)'\
     73                  %(self.processor, self.time, self.min_timestep, self.number_of_steps,
     74                    self.number_of_first_order_steps)
     75        elif self.min_timestep > self.max_timestep:
     76            print 'Processor %d, Time = %.4f, steps=%d (%d)'\
     77                  %(self.processor, self.time, self.number_of_steps,
     78                    self.number_of_first_order_steps)
     79        else:
     80            print 'Processor %d, Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)'\
     81                  %(self.processor, self.time, self.min_timestep,
     82                    self.max_timestep, self.number_of_steps,
     83                    self.number_of_first_order_steps)
     84
     85
     86
    5187    def evolve(self, yieldstep = None, finaltime = None):
    5288        """Specialisation of basic evolve method from parent class
     
    5490
    5591        #Initialise real time viz if requested
    56         if self.visualise is True and self.time == 0.0:
    57             import realtime_visualisation_new as visualise
    58             self.visualiser = visualise.Visualiser(self)
     92        if self.time == 0.0:
     93            pass
    5994
    6095        #Call basic machinery from parent class
    6196        for t in Advection_Domain.evolve(self, yieldstep, finaltime):
    62             #Real time viz
    63             if self.visualise is True:
    64                 self.visualiser.update_quantity('stage')
    6597
    6698            #Pass control on to outer loop for more specific actions
  • inundation/ga/storm_surge/parallel/run_parallel_advection.py

    r1404 r1407  
    99from Numeric import array
    1010
     11import pypar
     12
     13numprocs = pypar.size()
     14myid = pypar.rank()
     15processor_name = pypar.Get_processor_name()
     16
    1117N = 30
    1218M = 30
     
    1521
    1622#Create advection domain with direction (1,-1)
    17 domain = Parallel_Domain(points, vertices, boundary, ghosts, velocity=[1.0, 0.0])
     23domain = Parallel_Domain(points, vertices, boundary, ghosts, velocity=[1.0, 0.0],processor = myid)
    1824
    1925# Initial condition is zero by default
    2026
    21 domain.visualise = True
    22 #domain.visualise_range_z = 1.0
    23 
     27domain.initialise_visualiser()
    2428
    2529#Boundaries
  • inundation/ga/storm_surge/pyvolution/realtime_visualisation_new.py

    r1387 r1407  
    66
    77class Visualiser:
     8
    89    def __init__(self,domain,scale_z=1.0):
    910        """Create visualisation of domain
     
    2021        self.z_models = {}
    2122        keys = self.domain.quantities.keys()
    22         #print keys
     23        print keys
    2324        for key in keys:
    2425            self.z_models[key] = faces(frame= self.frame)
    2526
    26 
     27        print self.z_models
    2728
    2829        self.max_x = max(max(self.vertices[:,0]),max(self.vertices[:,2]),max(self.vertices[:,4]))
     
    5556        #print 'keys',self.domain.quantities.keys()
    5657        #print 'shape of stage',shape(self.stage)
     58
     59        setup_scene()
    5760
    5861        self.border_model = curve(frame = self.frame,
     
    486489                 type_converters = converters.blitz, compiler='gcc');
    487490
    488 scene.width = 1000
    489 scene.height = 800
    490 
    491 #Original
    492 scene.center = (0.5,0.5,0.0)
    493 scene.forward = vector(-0.0, 0.5, -0.8)
    494 
    495 #Temporary (for bedslope)
    496 #scene.forward = vector(0.0006, 0.7, -0.03)
    497 
    498 
    499 #Temporary for hackett - begin
    500 #scene.autoscale = 0
    501 #scene.scale = (0.002, 0.002, 0.01) #Scale z so that countours stand out more
    502 #scene.center = (300.0,500.0,-10)
    503 #Temporary for hackett - end
    504 
    505 
    506 scene.ambient = 0.4
    507 #scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4), (-0.1, 0.1, -0.4),
    508 #               (-0.2, 0.2, 0.1)]
    509 
    510 scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4)]
    511 
    512 
    513 
    514 def create_surface(domain,scale_z=0.5):
    515 
    516     visualiser = Visualiser(domain,scale_z=0.5)
     491
     492def setup_scene():
     493
     494    from visual import *
     495    #scene.width = 1000
     496    #scene.height = 800
     497
     498    #Original
     499    scene.center = (0.5,0.5,0.0)
     500    scene.forward = vector(-0.0, 0.5, -0.8)
     501
     502    #Temporary (for bedslope)
     503    #scene.forward = vector(0.0006, 0.7, -0.03)
     504
     505
     506    #Temporary for hackett - begin
     507    #scene.autoscale = 0
     508    #scene.scale = (0.002, 0.002, 0.01) #Scale z so that countours stand out more
     509    #scene.center = (300.0,500.0,-10)
     510    #Temporary for hackett - end
     511
     512
     513    scene.ambient = 0.4
     514    #scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4), (-0.1, 0.1, -0.4),
     515    #               (-0.2, 0.2, 0.1)]
     516
     517    scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4)]
     518
     519
     520
     521def create_surface(domain,scale_z=1.0):
     522
     523    visualiser = Visualiser(domain,scale_z)
    517524    domain.visualiser = visualiser
    518525
     
    529536        visualiser.update_quantity('stage')
    530537
    531     if domain.visualise_timer:
    532         visualiser.update_timer()
     538    visualiser.update_timer()
Note: See TracChangeset for help on using the changeset viewer.