source: inundation/examples/bedslope.py @ 2619

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

Cleaned up island example

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
9from pyvolution.mesh_factory import rectangular
10from pyvolution.shallow_water import Domain, Reflective_boundary,\
11     Dirichlet_boundary, Time_boundary, Transmissive_boundary
12
13#Create basic triangular mesh
14points, vertices, boundary = rectangular(2, 1)
15
16#Create shallow water domain
17domain = Domain(points, vertices, boundary)
18domain.set_name('bedslope')
19domain.set_datadir('.')                      #Use current directory for output
20domain.set_quantities_to_be_stored('stage')  #See shallow_water.py
21
22print domain.statistics()
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.