Changeset 550


Ignore:
Timestamp:
Nov 16, 2004, 11:06:07 AM (20 years ago)
Author:
ole
Message:

Got wave run-up to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/analytical solutions/Analytical solution_wave_runup.py

    r547 r550  
    1616######################
    1717# Module imports
    18 #
    19 
    2018import sys
    2119from os import sep
    2220sys.path.append('..'+sep+'pyvolution')
    2321
    24 from shallow_water import Transmissive_boundary, Reflective_boundary,\
    25      Dirichlet_boundary
    26 from shallow_water import Constant_height
    27 from shallow_water import Time_boundary
    28 from domain import Domain, Volume
    29 from Numeric import array
     22from shallow_water import Domain, Reflective_boundary, Time_boundary
    3023from math import sqrt, cos, sin, pi
     24from mesh_factory import strang_mesh
    3125
    32 import visualise2 as visualise
    33 
     26#Convenience functions
    3427def imag(a):
    3528    return a.imag
     
    4033
    4134######################
    42 # Boundary conditions
    43 # Not required for this problem
    44 
    45 from domain import Strang_domain, Volume
    46 
    47 ######################
    4835# Domain
    4936# Strang_domain will search through the file and test to see if there are
    5037# two or three entries. Two entries are for points and three for triangles.
    5138
    52 domain = Strang_domain('run-up.pt')
     39points, elements = strang_mesh('run-up.pt')
     40domain = Domain(points, elements)
    5341
    5442domain.default_order = 2
     
    6553
    6654# Provide file name for storing output
    67 domain.filename="run-up_second_order"
     55domain.store = True
     56domain.format = 'sww'
     57domain.filename = 'run-up_second_order'
    6858
    69 print "Number of triangles = ", len(Volume.instances)
    70 
    71 domain.visualise = False
    72 domain.checkpoint = False #
    73 domain.store = True       #Store for visualisation purposes
    74 domain.format = 'sww'     #Native netcdf visualisation format
     59print "Number of triangles = ", len(domain)
    7560
    7661#Reduction operation for get_vertex_values             
    77 from pytools.stats import mean
     62from util import mean
    7863domain.reduction = mean
    7964#domain.reduction = min  #Looks better near steep slopes
     
    130115    return [stage, uh, vh]
    131116
    132 def boundary_height(t):
     117def boundary_level(t):
    133118    x = -200
    134119    return stage_setup(x,t)
     
    137122######################
    138123#Initial condition
    139 #
    140124print 'Initial condition'
    141125t_star1 = 0.0
     
    150134    return z
    151135
    152 domain.set_field_values(x_slope, None)
     136domain.set_quantity('elevation', x_slope)
    153137
    154138#Set the water depth
    155 def height(x,y):
     139def level(x,y):
    156140    z = x_slope(x,y)
    157141    n = x.shape[0]
     
    165149    return w   
    166150
    167 domain.set_conserved_quantities(height, None, None)
     151domain.set_quantity('level', level)
     152
    168153
    169154#####################
    170155#Set up boundary conditions
    171 Br = Reflective_boundary()
    172 Bw = Time_boundary(domain, boundary_height)
     156Br = Reflective_boundary(domain)
     157Bw = Time_boundary(domain, boundary_level)
    173158domain.set_boundary({'left': Bw, 'external': Br})
    174159
    175160
    176    
    177 ######################
    178 #Visualisation
    179 if domain.visualise:
    180     visualise.create_surface(domain)
    181 
    182  
    183161######################
    184162#Evolution
    185 
    186163import time
    187164t0 = time.time()
    188 for t in domain.evolve(max_timestep = 1.0, yieldstep = 1., finaltime = 100):
     165for t in domain.evolve(yieldstep = 1., finaltime = 100):
    189166    domain.write_time()
    190     print boundary_height(domain.time)
    191 
    192 # Remove the following if Visual Python not required       
    193     if domain.visualise: 
    194         visualise.update(domain, index=0, smooth=True)
     167    print boundary_level(domain.time)
    195168   
    196169print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracChangeset for help on using the changeset viewer.