source: trunk/anuga_work/development/gareth/tests/runup_sinusoid/runup_sinusoid.py @ 8358

Last change on this file since 8358 was 8358, checked in by davies, 13 years ago

Minor changes

File size: 2.8 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.shallow_water_domain import Domain as Domain
12#from anuga.shallow_water_balanced2.swb2_domain import Domain as Domain
13#path.append('/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/development/gareth/balanced_basic')
14#from swb2_domain import *
15#from balanced_basic import *
16from balanced_dev import *
17#---------
18#Setup computational domain
19#---------
20points, vertices, boundary = anuga.rectangular_cross(40,40)
21
22domain=Domain(points,vertices,boundary)    # Create Domain
23domain.set_name('runup_sinusoid_v2')                         # Output to file runup.sww
24domain.set_datadir('.')                          # Use current folder
25domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
26#domain.set_store_vertices_uniquely(True)
27
28#------------------
29# Define topography
30#------------------
31scale_me=1.0
32def topography(x,y):
33        return (-x/2.0 +0.05*numpy.sin((x+y)*50.0))*scale_me
34
35def stagefun(x,y):
36    stge=-0.2*scale_me #-0.1*(x>0.5) -0.2*(x<=0.5)
37    #topo=topography(x,y)
38    return stge#*(stge>topo) + (topo)*(stge<=topo)
39
40domain.set_quantity('elevation',topography)     # Use function for elevation
41domain.get_quantity('elevation').smooth_vertex_values() 
42
43domain.set_quantity('friction',0.00)             # Constant friction
44
45#def frict_change(x,y):
46#       return 0.2*(x>0.5)+0.1*(x<=0.5)
47#
48#domain.set_quantity('friction',frict_change)
49
50domain.set_quantity('stage', stagefun)              # Constant negative initial stage
51domain.get_quantity('stage').smooth_vertex_values()
52
53# Experiment with rain.
54# rainin = anuga.shallow_water.forcing.Rainfall(domain, rate=0.001) #, center=(0.,0.), radius=1000. )
55# domain.forcing_terms.append(rainin)
56
57#--------------------------
58# Setup boundary conditions
59#--------------------------
60Br=anuga.Reflective_boundary(domain)            # Solid reflective wall
61Bt=anuga.Transmissive_boundary(domain)          # Continue all values of boundary -- not used in this example
62Bd=anuga.Dirichlet_boundary([-0.1*scale_me,0.,0.])       # Constant boundary values -- not used in this example
63#Bw=anuga.Time_boundary(domain=domain,
64#       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.
65
66#----------------------------------------------
67# Associate boundary tags with boundary objects
68#----------------------------------------------
69domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom':Br})
70
71#------------------------------
72#Evolve the system through time
73#------------------------------
74
75for t in domain.evolve(yieldstep=0.1,finaltime=20.0):
76    print domain.timestepping_statistics()
77
78print 'Finished'
Note: See TracBrowser for help on using the repository browser.