source: trunk/anuga_work/development/gareth/tests/runup/runup.py @ 9624

Last change on this file since 9624 was 9104, checked in by davies, 11 years ago

Initial structure for levees

File size: 3.5 KB
Line 
1"""Runup example from the manual, slightly modified
2"""
3#---------
4#Import Modules
5#--------
6import anuga
7
8import numpy
9
10from math import sin, pi, exp
11#from anuga.shallow_water_balanced2.swb2_domain import Domain as Domain
12from anuga.shallow_water.shallow_water_domain import Domain as Domain
13#from shallow_water_balanced_steve.swb_domain import *
14#import shallow_water_balanced_steve.swb_domain
15#from shallow_water_balanced_steve.swb_domain import Domain as Domain
16#path.append('/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/shallow_water_balanced_steve')
17#from swb_domain import *
18#path.append('/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/development/gareth/balanced_basic')
19#from balanced_basic import *
20#from bal_and import *
21#from anuga_tsunami import *
22#---------
23#Setup computational domain
24#---------
25points, vertices, boundary = anuga.rectangular_cross(40,40)
26
27domain=Domain(points,vertices,boundary)    # Create Domain
28domain.set_name('runup_v2')                         # Output to file runup.sww
29domain.set_datadir('.')                          # Use current folder
30#domain.set_store_centroids(True)
31domain.set_flow_algorithm('DE1')
32#domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
33#domain.set_store_vertices_uniquely(True)
34#------------------
35# Define topography
36#------------------
37
38scale_me=1.0
39
40def topography(x,y):
41        return -x/2*scale_me #+0.05*numpy.sin((x+y)*50.0) #+0.1*(numpy.random.rand(len(x)) -0.5)       # Linear bed slope + small random perturbation
42
43def stagefun(x,y):
44    #stg=(-0.2*(x<0.5) -0.1*(x>=0.5))*scale_me
45    stg=-0.2*scale_me # Stage
46    #topo=topography(x,y) #Bed
47    return stg #*(stg>topo) + topo*(stg<=topo)
48
49domain.set_quantity('elevation',topography)     # Use function for elevation
50domain.get_quantity('elevation').smooth_vertex_values() # Steve's fix -- without this, substantial artificial velcities are generated everywhere in the domain. With this fix, there are artificial velocities near the coast, but not elsewhere.
51
52domain.set_quantity('friction',0.03)             # Constant friction
53
54domain.set_quantity('stage', stagefun)              # Constant negative initial stage
55
56#--------------------------
57# Setup boundary conditions
58#--------------------------
59Br=anuga.Reflective_boundary(domain)            # Solid reflective wall
60Bt=anuga.Transmissive_boundary(domain)          # Continue all values of boundary -- not used in this example
61Bd=anuga.Dirichlet_boundary([-0.1*scale_me,0.,0.])       # Constant boundary values -- not used in this example
62#Bw=anuga.Time_boundary(domain=domain,
63#       f=lambda t: [(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1,0.0,0.0]) # Time varying boundary -- get rid of the 0.0 to do a runup.
64
65#----------------------------------------------
66# Associate boundary tags with boundary objects
67#----------------------------------------------
68domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom':Br})
69
70#------------------------------
71#Evolve the system through time
72#------------------------------
73
74for t in domain.evolve(yieldstep=0.2,finaltime=30.0):
75    print domain.timestepping_statistics()
76    uh=domain.quantities['xmomentum'].centroid_values
77    vh=domain.quantities['ymomentum'].centroid_values
78    depth=domain.quantities['height'].centroid_values#domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values
79    depth=depth*(depth>1.0e-06) + 1.0e-06
80    vel=((uh/depth)**2 + (vh/depth)**2)**0.5
81    print 'peak speed is', vel.max()
82
83print 'Finished'
Note: See TracBrowser for help on using the repository browser.