source: documentation/user_manual/examples/bedslope.py @ 3534

Last change on this file since 3534 was 3534, checked in by duncan, 16 years ago

fixing to work with new structure

File size: 1.6 KB
Line 
1"""Simple example of shallow water wave equation using Pyvolution
2
3Water driven by linear slope and Dirichlet boundary
4
5"""
6
7######################
8# Module imports
9#
10from anuga.pyvolution.mesh_factory import rectangular
11from anuga.pyvolution.shallow_water import Domain, Reflective_boundary,\
12     Dirichlet_boundary, Time_boundary, Transmissive_boundary
13
14#Create basic triangular mesh
15points, vertices, boundary = rectangular(2, 1)
16
17#Create shallow water domain
18domain = Domain(points, vertices, boundary)
19domain.set_name('bedslope')
20domain.set_datadir('.')                      #Use current directory for output
21domain.set_quantities_to_be_stored('stage')  #See shallow_water.py
22
23
24#######################
25# Initial conditions
26def f(x,y):
27    return -x/2
28
29domain.set_quantity('elevation', f)
30domain.set_quantity('friction', 0.1)
31
32h = 0.05  # Constant depth
33domain.set_quantity('stage', expression = 'elevation + %f' %h)
34
35
36######################
37# Boundary conditions
38from math import sin, pi
39Br = Reflective_boundary(domain)
40Bt = Transmissive_boundary(domain)
41Bd = Dirichlet_boundary([0.2,0.,0.])
42Bw = Time_boundary(domain=domain,
43                   f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
44
45
46print 'Tags are ', domain.get_boundary_tags()
47
48domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
49#domain.set_boundary({'left': Bw, 'right': Br, 'top': Br, 'bottom': Br})
50
51
52######################
53#Evolution
54domain.check_integrity()
55
56for t in domain.evolve(yieldstep = 0.1, finaltime = 0.2):
57    domain.write_time()
58
Note: See TracBrowser for help on using the repository browser.