source: inundation/examples/bedslope.py @ 1855

Last change on this file since 1855 was 1853, checked in by ole, 19 years ago

Tried non-equidistant timestepping

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 pyvolution.mesh_factory import rectangular
11from pyvolution.shallow_water import Domain, Reflective_boundary,\
12     Dirichlet_boundary, Constant_height, Time_boundary, Transmissive_boundary
13from Numeric import array
14
15#Create basic mesh
16points, vertices, boundary = rectangular(10, 10)
17
18#Create shallow water domain
19domain = Domain(points, vertices, boundary)
20domain.smooth = False
21domain.visualise = True
22domain.store = True
23domain.filename = 'bedslope'
24domain.default_order=2
25
26#######################
27#Bed-slope and friction
28domain.set_quantity('elevation', lambda x,y: -x/3)
29domain.set_quantity('friction', 0.1)
30
31
32######################
33# Boundary conditions
34from math import sin, pi
35Br = Reflective_boundary(domain)
36Bt = Transmissive_boundary(domain)
37Bd = Dirichlet_boundary([0.2,0.,0.])
38Bw = Time_boundary(domain=domain,
39                   f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
40
41domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
42
43
44######################
45#Initial condition
46h = 0.05
47#h = 0.0
48elevation = domain.quantities['elevation'].vertex_values
49domain.set_quantity('stage', elevation + h)
50
51domain.check_integrity()
52
53 
54######################
55#Evolution
56for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
57    domain.write_time()
58
59for t in domain.evolve(yieldstep = 0.01, finaltime = 4.0):
60    domain.write_time()   
61
Note: See TracBrowser for help on using the repository browser.