Changeset 1363


Ignore:
Timestamp:
May 10, 2005, 4:40:06 PM (19 years ago)
Author:
steve
Message:

Changes to visualisation. Can use visualise_color_stage to color stage, but it uses python update (slow).

Location:
inundation/ga/storm_surge
Files:
13 added
11 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/Merimbula/run_merimbula_lake.py

    r1358 r1363  
    9090# Evolution
    9191t0 = time.time()
    92 domain.visualise = False
    93 yieldstep = 900
     92domain.visualise = True
     93yieldstep = 10
    9494finaltime = 588000*3
    9595for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
  • inundation/ga/storm_surge/parallel/advection.py

    r1280 r1363  
    4545        #Realtime visualisation
    4646        self.visualise = False
     47        self.visualise_color_stage = False
     48        self.visualise_timer = True
     49        self.visualise_range_z = None
    4750        self.smooth = True
    48         self.range_z = None
     51
    4952
    5053
     
    177180        if self.visualise is True and self.time == 0.0:
    178181            import realtime_visualisation_new as visualise
    179             visualise.create_surface(self,range_z =  self.range_z)
     182            visualise.create_surface(self)
    180183
    181184        #Call basic machinery from parent class
  • inundation/ga/storm_surge/parallel/run_advection.py

    r1280 r1363  
    1919
    2020domain.visualise = True
    21 domain.range_z = 1.0
     21#domain.visualise_range_z = 1.0
     22domain.visualise_color_stage = True
     23
    2224
    2325#Boundaries
    2426T = Transmissive_boundary(domain)
    25 D = Dirichlet_boundary(array([0.5]))
     27D = Dirichlet_boundary(array([1.0]))
    2628
    2729domain.default_order = 2
  • inundation/ga/storm_surge/pyvolution/advection.py

    r773 r1363  
     1import sys
     2from os import sep
     3sys.path.append('..'+sep+'pyvolution')
     4
    15"""Class Domain -
    262D triangular domains for finite-volume computations of
     
    1721
    1822Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
    19 Geoscience Australia, 2004   
     23Geoscience Australia, 2004
    2024"""
    2125
     
    2731    def __init__(self, coordinates, vertices, boundary = None, velocity = None):
    2832
    29        
     33
    3034        Generic_domain.__init__(self, coordinates, vertices, boundary,
    3135                                ['stage'])
     
    3640            self.velocity = velocity
    3741
    38         #Only first is implemented for advection   
    39         self.default_order = self.order = 1 
     42        #Only first is implemented for advection
     43        self.default_order = self.order = 1
    4044
    4145        #Realtime visualisation
    4246        self.visualise = False
     47        self.visualise_color_stage = False
     48        self.visualise_timer = True
     49        self.visualise_range_z = None
    4350        self.smooth = True
     51
    4452
    4553
     
    4957        msg = 'Conserved quantity must be "stage"'
    5058        assert self.conserved_quantities[0] == 'stage', msg
    51        
     59
    5260
    5361    def flux_function(self, normal, ql, qr, zl=None, zr=None):
    5462        """Compute outward flux as inner product between velocity
    5563        vector v=(v_1, v_2) and normal vector n.
    56            
     64
    5765        if <n,v> > 0 flux direction is outward bound and its magnitude is
    5866        determined by the quantity inside volume: ql.
     
    6068        quantity outside the volume: qr.
    6169        """
    62    
     70
    6371        v1 = self.velocity[0]
    6472        v2 = self.velocity[1]
     
    7179        else:
    7280            flux = ql * normal_velocity
    73        
     81
    7482        max_speed = abs(normal_velocity)
    75         return flux, max_speed       
     83        return flux, max_speed
    7684
    77        
     85
    7886    def compute_fluxes(self):
    7987        """Compute all fluxes and the timestep suitable for all volumes
    8088        in domain.
    81        
     89
    8290        Compute total flux for each conserved quantity using "flux_function"
    83        
     91
    8492        Fluxes across each edge are scaled by edgelengths and summed up
    8593        Resulting flux is then scaled by area and stored in
     
    93101        Post conditions:
    94102        domain.explicit_update is reset to computed flux values
    95         domain.timestep is set to the largest step satisfying all volumes. 
     103        domain.timestep is set to the largest step satisfying all volumes.
    96104        """
    97105
     
    101109
    102110        N = self.number_of_elements
    103    
     111
    104112        neighbours = self.neighbours
    105113        neighbour_edges = self.neighbour_edges
     
    109117        radii = self.radii
    110118        edgelengths = self.edgelengths
    111            
     119
    112120        timestep = max_timestep #FIXME: Get rid of this
    113121
     
    119127
    120128        stage_bdry = Stage.boundary_values
    121    
     129
    122130        flux = zeros(1, Float) #Work array for summing up fluxes
    123131
     
    132140
    133141                #Quantities at neighbour on nearest face
    134                 n = neighbours[k,i] 
     142                n = neighbours[k,i]
    135143                if n < 0:
    136144                    m = -n-1 #Convert neg flag to index
    137145                    qr = stage_bdry[m]
    138                 else:   
     146                else:
    139147                    m = neighbour_edges[k,i]
    140148                    qr = stage[n, m]
    141149
    142                    
    143                 #Outward pointing normal vector   
     150
     151                #Outward pointing normal vector
    144152                normal = normals[k, 2*i:2*i+2]
    145153
     
    147155                edgeflux, max_speed = self.flux_function(normal, ql, qr)
    148156                flux -= edgeflux * edgelengths[k,i]
    149                
     157
    150158                #Update optimal_timestep
    151159                try:
     
    158166            flux /= areas[k]
    159167            Stage.explicit_update[k] = flux[0]
    160            
     168
    161169            timestep = min(timestep, optimal_timestep)
    162170
    163         self.timestep = timestep   
    164        
     171        self.timestep = timestep
     172
    165173
    166174
     
    168176        """Specialisation of basic evolve method from parent class
    169177        """
    170        
     178
    171179        #Initialise real time viz if requested
    172180        if self.visualise is True and self.time == 0.0:
    173             import realtime_visualisation as visualise
     181            import realtime_visualisation_new as visualise
    174182            visualise.create_surface(self)
    175183
     
    180188                visualise.update(self)
    181189
    182             #Pass control on to outer loop for more specific actions   
     190            #Pass control on to outer loop for more specific actions
    183191            yield(t)
    184        
  • inundation/ga/storm_surge/pyvolution/data_manager.py

    r1360 r1363  
    2929Manually created files:
    3030ASC, PRJ:     Digital elevation models (gridded)
    31 TSH:          Triangular meshes (e.g. dreated from pmesh)
     31TSH:          Triangular meshes (e.g. created from pmesh)
    3232NC            Model outputs for use as boundary conditions (e.g from MOST)
    3333
     
    267267            if domain.geo_reference is not None:
    268268                domain.geo_reference.write_NetCDF(fid)
    269             #FIXME: Backwards compatibility
    270             fid.createVariable('z', self.precision, ('number_of_points',))
    271             #################################
     269            #FIXME: Backwards compatibility
     270            fid.createVariable('z', self.precision, ('number_of_points',))
     271            #################################
    272272
    273273            fid.createVariable('volumes', Int, ('number_of_volumes',
     
    317317
    318318        # Get X, Y and bed elevation Z
    319         Q = domain.quantities['elevation']
     319        Q = domain.quantities['elevation']
    320320        X,Y,Z,V = Q.get_vertex_values(xy=True,
    321321                                      precision = self.precision)
     
    327327        z[:] = Z.astype(self.precision)
    328328
    329         #FIXME: Backwards compatibility
     329        #FIXME: Backwards compatibility
    330330        z = fid.variables['z']
    331331        z[:] = Z.astype(self.precision)
    332         ################################
     332        ################################
    333333
    334334        volumes[:] = V.astype(volumes.typecode())
  • inundation/ga/storm_surge/pyvolution/realtime_visualisation_new.py

    r1295 r1363  
    44stage_color = (0.1,0.4,0.99)
    55
    6 class Surface:
    7     def __init__(self,domain,scale_z=1.0,range_z=None):
     6class Visualiser:
     7    def __init__(self,domain,scale_z=1.0):
    88        """Create visualisation of domain
    99        """
     
    1414        self.scale_z  = scale_z
    1515        self.vertices = domain.vertex_coordinates
     16
    1617
    1718        # models for each quantity
     
    3940#        print 'range_y',self.range_y
    4041
    41         self.range_z = 1.0
    42         self.max_z = self.range_z/2.0
    43         self.min_z = -self.range_z/2.0
    44         self.range_z = max(self.max_z - self.min_z, 1.0e-10)
     42
    4543
    4644
     
    5957        self.border_model = curve(frame = self.frame,
    6058                                  pos=[(0,0),(0,1),(1,1),(1,0),(0,0)])
    61         self.timer=label(pos=(0.75,0.75,0.5),text='Time=%10.5e'%self.domain.time)
    62 
    63         #scene.autoscale=0
     59        self.timer=label(pos=(0.75,0.75,0.5),text='Time=%10.5e'%self.domain.time,
     60                         visible=False)
     61
     62
     63        scene.autoscale=1
    6464        #self.update_all()
    6565        #scene.uniform=0
    66         self.setup_range_z()
     66        self.range_z  = 1.0
     67        if domain.visualise_range_z == None:
     68            self.setup_range_z()
     69        else:
     70            self.range_z = domain.visualise_range_z
     71
     72        self.max_z = self.range_z/2.0
     73        self.min_z = -self.range_z/2.0
     74        self.range_z = max(self.max_z - self.min_z, 1.0e-10)
     75
     76        print self.range_z
     77        print self.max_z
     78        print self.min_z
    6779
    6880    def setup_range_z(self,qname1='elevation',qname2='stage'):
     
    7082        #print qname1
    7183        #print qname2
    72         self.range_z = 1.0e-10
     84        range_z = 1.0e-10
    7385        try:
    7486            q1 = self.domain.quantities[qname1].vertex_values
     
    7688            min_z = min(min(q1))
    7789            print max_z, min_z
    78             self.range_z = max(self.range_z, max_z - min_z)
     90            range_z = max(range_z, max_z - min_z)
    7991        except:
    80             print 'could not find range of '+qname1
     92            print 'Visualisation: could not find range of '+qname1
    8193            pass
    8294
     
    8698            min_z = min(min(q2))
    8799            print max_z, min_z
    88             self.range_z = max(self.range_z, max_z - min_z)
     100            range_z = max(range_z, max_z - min_z)
    89101        except:
    90102            print 'Visualisation: could not find range of '+qname2
    91103            pass
    92104
     105        self.range_z = max(range_z,self.range_z)
     106
    93107    def update_all(self):
    94108
     
    97111
    98112    def update_timer(self):
    99         self.timer.text='Time=%10.5e'%self.domain.time
     113
     114        if self.domain.visualise_timer == True:
     115            self.timer.visible = True
     116            self.timer.text='Time=%10.5e'%self.domain.time
    100117
    101118
     
    489506
    490507
    491 def create_surface(domain,scale_z=0.5,range_z=None):
    492 
    493     surface = Surface(domain,scale_z=0.5,range_z=range_z)
    494     domain.surface = surface
    495 
    496     surface.update_quantity('elevation')
    497     surface.update_quantity('stage')
    498     surface.update_timer()
     508def create_surface(domain,scale_z=0.5):
     509
     510    visualiser = Visualiser(domain,scale_z=0.5)
     511    domain.visualiser = visualiser
     512
     513    visualiser.update_quantity('elevation')
     514    visualiser.update_quantity('stage')
     515    visualiser.update_timer()
    499516
    500517def update(domain):
    501518
    502     surface = domain.surface
     519    visualiser = domain.visualiser
    503520    if domain.visualise_color_stage:
    504         surface.update_quantity_color('stage')
     521        visualiser.update_quantity_color('stage')
    505522    else:
    506         surface.update_quantity('stage')
     523        visualiser.update_quantity('stage')
    507524
    508525    if domain.visualise_timer:
    509         surface.update_timer()
     526        visualiser.update_timer()
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r1360 r1363  
    8383        self.visualise_color_stage = False
    8484        self.visualise_stage_range = 1.0
    85         self.visualise_timer = False
     85        self.visualise_timer = True
     86        self.visualise_range_z = None
    8687
    8788        #Stored output
  • inundation/ga/storm_surge/pyvolution/view_tsh.py

    r1358 r1363  
    4343    print "Number of triangles = ", len(domain)
    4444
    45     surface =  Surface(domain, scale_z = scale_z)
    46     surface.update_quantity('stage')
    47 
     45    visualiser =  Visualiser(domain, scale_z = scale_z)
     46    visualiser.update_quantity('stage')
  • inundation/ga/storm_surge/zeus/anuga-workspace.zwi

    r1358 r1363  
    22<workspace name="anuga-workspace">
    33    <mode>Debug</mode>
    4     <active>Merimbula</active>
     4    <active>parallel</active>
    55    <project name="Merimbula">Merimbula.zpi</project>
    66    <project name="parallel">parallel.zpi</project>
  • inundation/ga/storm_surge/zeus/parallel.zpi

    r1282 r1363  
    7474    <ReleaseProjectReload>Off</ReleaseProjectReload>
    7575    <file>..\parallel\advection.py</file>
     76    <file>..\parallel\parallel_advection.py</file>
    7677    <file>..\parallel\run_advection.py</file>
     78    <file>..\parallel\run_parallel_advection.py</file>
    7779    <file>..\parallel\test_advection.py</file>
    7880    <folder name="Header Files" />
Note: See TracChangeset for help on using the changeset viewer.