source: inundation/pyvolution/run_tsh_weir.py @ 1740

Last change on this file since 1740 was 773, checked in by ole, 19 years ago

Changed quantity name 'level' to 'stage'

File size: 2.4 KB
Line 
1"""Example of shallow water wave equation.
2
3Specific methods pertaining to the 2D shallow water equation
4are imported from shallow_water
5for use with the generic finite volume framework
6
7Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the
8numerical vector named conserved_quantities.
9"""
10
11######################
12# Module imports
13#
14from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
15     Transmissive_boundary, Time_boundary, Constant_height, Weir
16
17from mesh_factory import rectangular
18from pmesh2domain import pmesh_to_domain
19
20from Numeric import array
21
22######################
23# Domain
24
25import sys
26if len(sys.argv) > 1: 
27    filename = sys.argv[1]
28else:
29    filename = 'weir_domain_refined.tsh'
30
31print 'Creating domain from', filename
32domain_list = pmesh_to_domain(filename)
33vertex_coordinates = domain_list[0]
34volumes = domain_list[1]
35marker_dict = domain_list[2]
36vertex_quantity_dict = domain_list[3]
37
38domain = Domain(vertex_coordinates, volumes, marker_dict)
39print "Number of triangles = ", len(domain)
40
41domain.store = False #True
42domain.format = 'sww'
43domain.filename = 'weir'
44domain.checkpoint = False #True
45domain.visualise = True #False
46domain.default_order = 2
47
48#Set bed-slope and friction
49inflow_stage = 0.15
50manning = 0.07
51W = Weir(inflow_stage)
52
53print 'Field values'
54
55domain.set_quantity('elevation', W)
56domain.set_quantity('friction', manning)
57
58
59
60######################
61# Boundary conditions
62#
63print 'Boundaries'
64Br = Reflective_boundary(domain)
65Bt = Transmissive_boundary(domain)
66
67#Constant inflow
68Bd = Dirichlet_boundary(array([inflow_stage, 0.0, 0.0]))
69
70#Time dependent inflow
71from math import sin, pi
72Bw = Time_boundary(domain=domain,
73                   f=lambda x: array([(1 + sin(x*pi/4))*\
74                                      (inflow_stage*(sin(2.5*x*pi)+0.7)),0,0]))
75
76
77print 'Available boundary tags are', domain.get_boundary_tags()
78
79#Set boundary conditions
80domain.set_boundary({'left': Bw, '0': Br, '1':Bw, 'external':Br})
81
82
83#print domain.quantities['elevation'].vertex_values
84#print domain.quantities['stage'].vertex_values
85         
86######################
87#Initial condition
88print 'Initial condition'
89domain.set_quantity('stage', Constant_height(W, 0.))
90domain.check_integrity()
91
92######################
93#Evolution
94for t in domain.evolve(yieldstep = 0.01, finaltime = 5):
95    domain.write_time()
96   
97print 'Done'
98
99   
Note: See TracBrowser for help on using the repository browser.