Changeset 1295


Ignore:
Timestamp:
May 8, 2005, 11:50:32 PM (20 years ago)
Author:
steve
Message:

Playing with coloured surfaces

Location:
inundation/ga/storm_surge
Files:
6 edited

Legend:

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

    r1292 r1295  
    44   Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray
    55   Geoscience Australia, ANU
    6    
     6
    77Specific methods pertaining to the 2D shallow water equation
    88are imported from shallow_water
     
    2525from pmesh2domain import pmesh_to_domain_instance
    2626from util import file_function, Polygon_function, read_polygon
    27 from Numeric import zeros, Float 
     27from Numeric import zeros, Float
    2828
    2929#-------
     
    3636
    3737#------------------------------------------
    38 # Reduction operation for get_vertex_values             
     38# Reduction operation for get_vertex_values
    3939from util import mean
    40 domain.reduction = mean 
     40domain.reduction = mean
    4141
    4242#-----------------
     
    176176# Initial water surface elevation
    177177domain.set_quantity('stage', 0.0)
    178    
     178
    179179#----------------------------------------------------------
    180180# Decide which quantities are to be stored at each timestep
     
    191191domain.default_order = 1
    192192domain.visualise = True
     193domain.visualise_color_stage = True
     194domain.visualise_stage_range = 1.0
    193195domain.smooth = True
    194          
     196
    195197#---------
    196198#Evolution
     
    199201for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    200202    domain.write_time()
    201    
     203
    202204print 'Done'
    203205
    204    
     206
  • inundation/ga/storm_surge/pyvolution/netherlands.py

    r1290 r1295  
    6363                z[i] = -x[i]/20+0.4
    6464
     65            if (x[i] - 0.72)**2 + (y[i] - 0.4)**2 < 0.05**2:# or\
     66                   #x[i] > 0.75 and x[i] < 0.9 and y[i] > 0.35 and y[i] < 0.45:
     67                z[i] = -x[i]/20+0.4
     68
    6569            #Wall
    6670            if x[i] > 0.995:
     
    7983N = 130 #size = 33800
    8084N = 600 #Size = 720000
    81 N = 30
     85N = 40
    8286
    8387#N = 15
     
    100104print "Number of triangles = ", len(domain)
    101105
     106#Set bed-slope and friction
     107inflow_stage = 0.4
     108manning = 0.02
     109Z = Weir(inflow_stage)
    102110
    103111if N > 150:
     
    112120else:
    113121    domain.visualise = True
     122    domain.visualise_color_stage = True
     123    domain.visualise_timer = True
    114124    domain.checkpoint = False
    115125    domain.store = False
    116126
    117 
    118 #Set bed-slope and friction
    119 inflow_stage = 0.1
    120 manning = 0.02
    121 Z = Weir(inflow_stage)
    122127
    123128print 'Field values'
     
    134139
    135140#Constant inflow
    136 Bd = Dirichlet_boundary([2*inflow_stage, 0.0, 0.0])
     141Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0])
    137142
    138143
     
    151156t0 = time.time()
    152157
    153 for t in domain.evolve(yieldstep = 0.2, finaltime = 10.0):
     158for t in domain.evolve(yieldstep = 0.05, finaltime = 10.0):
    154159    domain.write_time()
    155160
  • inundation/ga/storm_surge/pyvolution/realtime_visualisation.py

    r773 r1295  
    1111        #n = vector(0,0,0)
    1212
    13     return n   
     13    return n
    1414
    1515
     
    2020
    2121        #Outward normal
    22        
     22
    2323        self.normal=normal(v1-v0, v2-v0)
    2424
    2525        self.panel = faces(frame = frame)
    26         self.backpanel = faces(frame = frame)       
     26        self.backpanel = faces(frame = frame)
    2727        for v in (v0,v1,v2):
    2828            self.panel.append(pos=v, normal = self.normal, color=color)
    2929
    3030        for v in (v2,v1,v0):
    31             self.backpanel.append(pos=v, normal = -self.normal, color=color)           
    32 
    33            
     31            self.backpanel.append(pos=v, normal = -self.normal, color=color)
     32
     33
    3434    def move(self,v):
    3535        """Move panel in direction given by vector v
     
    3737
    3838        for vertex in self.panel.pos:
    39             vertex += v           
     39            vertex += v
    4040
    4141    def update_height(self,d,fix_baseline=False):
     
    4747        v0 = self.panel.pos[0]
    4848        v1 = self.panel.pos[1]
    49         v2 = self.panel.pos[2]       
    50        
     49        v2 = self.panel.pos[2]
     50
    5151        n = normal(v1-v0, self.normal)
    5252
     
    5454            self.panel.pos[2] -= d*n
    5555        else:
    56             self.panel.pos[:2] += d*n       
     56            self.panel.pos[:2] += d*n
    5757
    5858    def update_color(self, c):
     
    6161
    6262        self.panel.color = c
    63        
     63
    6464
    6565    def set_vertexheights(self, heights, floor_heights = None):
     
    7070            floor_heights = zeros(heights.shape, Float)
    7171
    72         all_vertices_below_threshold = True   
     72        all_vertices_below_threshold = True
    7373        for k in range(3):
    7474            w = heights[k]
     
    7777            if w-z >= hmin:
    7878                all_vertices_below_threshold = False
    79            
     79
    8080            vertex = self.panel.pos[k]
    8181            vertex[2] = w
     
    8585
    8686
    87         #Update color to visualise dry areas 
    88         if all_vertices_below_threshold: 
     87        #Update color to visualise dry areas
     88        if all_vertices_below_threshold:
    8989            self.panel.color = self.bottom_color
    90             self.backpanel.color = self.bottom_color               
     90            self.backpanel.color = self.bottom_color
    9191        else:
    9292            self.panel.color = self.top_color
     
    9494
    9595
    96         #update normal   
     96        #update normal
    9797        v0 = self.panel.pos[0]
    9898        v1 = self.panel.pos[1]
     
    104104        self.backpanel.normal=-n
    105105
    106        
     106
    107107
    108108
     
    120120    except:
    121121        bed = False
    122        
     122
    123123    N = Q.vertex_values.shape[0]
    124124
     
    128128        z0 = Q.vertex_values[i, 0]
    129129        z1 = Q.vertex_values[i, 1]
    130         z2 = Q.vertex_values[i, 2]       
     130        z2 = Q.vertex_values[i, 2]
    131131
    132132        x0, y0 = domain.get_vertex_coordinate(i,0)
    133133        x1, y1 = domain.get_vertex_coordinate(i,1)
    134         x2, y2 = domain.get_vertex_coordinate(i,2)       
    135        
     134        x2, y2 = domain.get_vertex_coordinate(i,2)
     135
    136136        V0 = vector(x0, y0, z0)
    137137        V1 = vector(x1, y1, z1)
     
    149149
    150150        col = (c0,c1,c2)
    151            
     151
    152152        visual_top = Triangle(V0,V1,V2,color=col,frame=fr)
    153153        visual_top.top_color = col
    154154
    155    
     155
    156156        #Bottom surface
    157157        #v0, v1, v2 = volume.vertices
     
    168168        V0 = vector(x0, y0, z0)
    169169        V1 = vector(x1, y1, z1)
    170         V2 = vector(x2, y2, z2)       
     170        V2 = vector(x2, y2, z2)
    171171
    172172        c0 = 0.3
     
    176176            c2 = 0.4*c2   #To show triangles in slightly different shades
    177177
    178         col = (c0,c1,c2)   
     178        col = (c0,c1,c2)
    179179        visual_bottom = Triangle(V0, V1, V2, color=col,frame=fr)
    180180        visual_top.bottom_color=col
    181        
     181
    182182        domain.visuals.append( (visual_top, visual_bottom) )
    183        
     183
    184184    update(domain)
    185     #print 'Scale', scene.scale   
    186 
    187 
    188 def update(domain):   
     185    #print 'Scale', scene.scale
     186
     187
     188def update(domain):
    189189    """Update vertex heights.
    190     The argument index refers to which conserved quantity to visualise.   
     190    The argument index refers to which conserved quantity to visualise.
    191191    If domain.smooth is set True, vertex values will be averaged
    192192    yielding a smoother surface.
     
    198198    Q = domain.quantities['stage']
    199199    N = Q.vertex_values.shape[0]
    200    
     200
    201201    #print scene.forward
    202202    #FIXME: Use smoother from pyvolution instead
     
    218218
    219219
    220     for k in range(N):   
     220    for k in range(N):
    221221        if domain.smooth:
    222222            #The averages
    223223            x = zeros(3, Float)
    224             for i in range(3):           
     224            for i in range(3):
    225225                vertex = domain.triangles[k, i]
    226226                A = array(vertex_heights[vertex])
    227227                x[i] = sum(A)/len(A)
    228         else:       
     228        else:
    229229            #The true values
    230230            x = [Q.vertex_values[k, 0],
     
    232232                 Q.vertex_values[k, 2]]
    233233
    234            
     234
    235235        #Do it
    236236        floor_heights = array([pos[2] for pos in domain.visuals[k][1].panel.pos])
    237        
     237
    238238        domain.visuals[k][0].set_vertexheights(x, floor_heights)
    239239
     
    246246#Original
    247247scene.center = (0.5,0.5,0)
    248 scene.forward = vector(-0.1, 0.5, -0.5)
     248scene.forward = vector(0.0, 0.5, -0.5)
    249249
    250250#Temporary (for bedslope)
    251 #scene.forward = vector(0.0006, 0.7, -0.03)   
     251#scene.forward = vector(0.0006, 0.7, -0.03)
    252252
    253253
     
    258258#Temporary for hackett - end
    259259
    260    
     260
    261261scene.ambient = 0.4
    262262scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4), (-0.1, 0.1, -0.4),
     
    266266
    267267
    268 
  • inundation/ga/storm_surge/pyvolution/realtime_visualisation_new.py

    r1290 r1295  
    5959        self.border_model = curve(frame = self.frame,
    6060                                  pos=[(0,0),(0,1),(1,1),(1,0),(0,0)])
    61         self.timer=label(pos=(0.75,0.5,0.5),text='Time=%10.5e'%self.domain.time)
     61        self.timer=label(pos=(0.75,0.75,0.5),text='Time=%10.5e'%self.domain.time)
    6262
    6363        #scene.autoscale=0
     
    135135
    136136
    137         try:
    138             self.update_arrays_color(self.domain.quantities[qname].vertex_values, qcolor)
     137        #try:
     138        self.update_arrays_color(self.domain.quantities[qname].vertex_values, qcolor)
    139139
    140140            #print 'update bed image'
    141             self.z_models[qname].pos    = self.pos
    142             self.z_models[qname].color  = self.colour
    143             self.z_models[qname].normal = self.normals
    144         except:
    145             print 'Visualisation: Could not update quantity '+qname
    146             pass
     141        self.z_models[qname].pos    = self.pos
     142        self.z_models[qname].color  = self.colour
     143        self.z_models[qname].normal = self.normals
     144        #except:
     145        #    print 'Visualisation: Could not update quantity '+qname
     146        #    pass
    147147
    148148
     
    189189        colour   = self.colour
    190190
    191         try:
    192             update_arrays_color_weave(vertices,quantity,col,pos,normals,colour,N,
     191        #try:
     192        update_arrays_color_python(vertices,quantity,col,pos,normals,colour,N,
    193193                                min_x,min_y,range_xy,range_z,scale_z)
    194         except:
    195             update_arrays_color_python(vertices,quantity,col,pos,normals,colour,N,
    196                                  min_x,min_y,range_xy,range_z,scale_z)
     194        #except:
     195        #    update_arrays_color_python(vertices,quantity,col,pos,normals,colour,N,
     196        #                         min_x,min_y,range_xy,range_z,scale_z)
    197197
    198198
     
    359359        pos[6*i+5,:] = v[1,:]
    360360
    361         s = abs(v(2,j))
    362 
    363         colour[6*i  ,:] = s*col
    364         colour[6*i+1,:] = s*col
    365         colour[6*i+2,:] = s*col
    366         colour[6*i+3,:] = s*col
    367         colour[6*i+4,:] = s*col
    368         colour[6*i+5,:] = s*col
     361        q0 = quantity[i,0]/0.4
     362        q1 = quantity[i,1]/0.4
     363        q2 = quantity[i,2]/0.4
     364
     365        q0r = min(q0,0.0)
     366        q1r = min(q1,0.0)
     367        q2r = min(q2,0.0)
     368        q0b = max(q0,0.0)
     369        q1b = max(q1,0.0)
     370        q2b = max(q2,0.0)
     371
     372
     373        colour[6*i  ,:] = s*array([0.3 - q0r, 0.3 - q0, 0.3 + q0b])
     374        colour[6*i+1,:] = s*array([0.3 - q1r, 0.3 - q1, 0.3 + q1b])
     375        colour[6*i+2,:] = s*array([0.3 - q2r, 0.3 - q2, 0.3 + q2b])
     376        colour[6*i+3,:] = s*array([0.3 - q0r, 0.3 - q0, 0.3 + q0b])
     377        colour[6*i+4,:] = s*array([0.3 - q2r, 0.3 - q2, 0.3 + q2b])
     378        colour[6*i+5,:] = s*array([0.3 - q1r, 0.3 - q1, 0.3 + q1b])
    369379
    370380        s =  15.0/8.0 - s
     
    417427            normal(2) = normal(2)/norm;
    418428
    419             s = 0.2+fabs((v(0,2)+v(1,2)+v(2,2))/3.0);
     429
    420430
    421431            for (int j=0; j<3; j++) {
     
    427437                pos(6*i+5,j) = v(1,j);
    428438
    429 
    430 
    431 
    432                 colour(6*i  ,j) = s*col(j);
    433                 colour(6*i+1,j) = s*col(j);
    434                 colour(6*i+2,j) = s*col(j);
    435                 colour(6*i+3,j) = s*col(j);
    436                 colour(6*i+4,j) = s*col(j);
    437                 colour(6*i+5,j) = s*col(j);
    438 
    439439                normals(6*i  ,j) = normal(j);
    440440                normals(6*i+1,j) = normal(j);
     
    445445                }
    446446
     447            s = 0.2+fabs((v(0,2)+v(1,2)+v(2,2))/3.0);
     448            for (int j=0; j<3; j++) {
     449                colour(6*i  ,j) = s*col(j);
     450                colour(6*i+1,j) = s*col(j);
     451                colour(6*i+2,j) = s*col(j);
     452                colour(6*i+3,j) = s*col(j);
     453                colour(6*i+4,j) = s*col(j);
     454                colour(6*i+5,j) = s*col(j);
     455                }
    447456            s =  15.0/8.0 - s;
    448457        }
     
    459468#Original
    460469scene.center = (0.5,0.5,0.0)
    461 scene.forward = vector(-0.1, 0.5, -0.5)
     470scene.forward = vector(-0.0, 0.5, -0.8)
    462471
    463472#Temporary (for bedslope)
     
    492501
    493502    surface = domain.surface
    494     surface.update_quantity('stage')
    495     surface.update_timer()
     503    if domain.visualise_color_stage:
     504        surface.update_quantity_color('stage')
     505    else:
     506        surface.update_quantity('stage')
     507
     508    if domain.visualise_timer:
     509        surface.update_timer()
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r1265 r1295  
    8080        #Realtime visualisation
    8181        self.visualise = False
     82        self.visualise_color_stage = False
     83        self.visualise_stage_range = 1.0
     84        self.visualise_timer = False
    8285
    8386        #Stored output
Note: See TracChangeset for help on using the changeset viewer.