source: documentation/user_manual/examples/bedslopephysical.py @ 2574

Last change on this file since 2574 was 2574, checked in by ole, 18 years ago

From meeting with Howard

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