source: inundation/examples/bedslope.py @ 2279

Last change on this file since 2279 was 2156, checked in by sexton, 19 years ago

Unnecessary import deleted (Constant_height) as accounted for later in example.

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