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

Last change on this file since 8353 was 8353, checked in by davies, 12 years ago

Updates to balanced_dev and associated tests

File size: 3.2 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
12#from 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 *
20from balanced_dev import *
21#---------
22#Setup computational domain
23#---------
24points, vertices, boundary = anuga.rectangular_cross(40,40)
25
26domain=Domain(points,vertices,boundary)    # Create Domain
27domain.set_name('runup_v2')                         # Output to file runup.sww
28domain.set_datadir('.')                          # Use current folder
29domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
30#domain.set_store_vertices_uniquely(True)
31#------------------
32# Define topography
33#------------------
34
35def topography(x,y):
36        return -x/2 #+0.05*numpy.sin((x+y)*50.0) #+0.1*(numpy.random.rand(len(x)) -0.5)       # Linear bed slope + small random perturbation
37
38def stagefun(x,y):
39    #stg=-0.2*(x<0.5) -0.1*(x>=0.5)
40    stg=-0.2 # Stage
41    #topo=topography(x,y) #Bed
42    return stg #*(stg>topo) + topo*(stg<=topo)
43
44domain.set_quantity('elevation',topography)     # Use function for elevation
45domain.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.
46
47domain.set_quantity('friction',0.00)             # Constant friction
48
49domain.set_quantity('stage', stagefun)              # Constant negative initial stage
50
51#--------------------------
52# Setup boundary conditions
53#--------------------------
54Br=anuga.Reflective_boundary(domain)            # Solid reflective wall
55Bt=anuga.Transmissive_boundary(domain)          # Continue all values of boundary -- not used in this example
56Bd=anuga.Dirichlet_boundary([-0.2,0.,0.])       # Constant boundary values -- not used in this example
57Bw=anuga.Time_boundary(domain=domain,
58        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.
59
60#----------------------------------------------
61# Associate boundary tags with boundary objects
62#----------------------------------------------
63domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom':Br})
64
65#------------------------------
66#Evolve the system through time
67#------------------------------
68
69#xwrite=open("xvel.out","wb")
70#ywrite=open("yvel.out","wb")
71## Set print options to be compatible with file writing via the 'print' statement
72#numpy.set_printoptions(threshold=numpy.nan, linewidth=numpy.nan)
73
74for t in domain.evolve(yieldstep=0.2,finaltime=30.0):
75    print domain.timestepping_statistics()
76
77
78print 'Finished'
Note: See TracBrowser for help on using the repository browser.