source: anuga_work/development/demos/run_tsh_weir.py @ 5685

Last change on this file since 5685 was 4713, checked in by steve, 18 years ago

Implemented 2nd and 3rd order timestepping via the domain.set_timestepping_method method

File size: 2.3 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 anuga.pyvolution.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.set_name('weir')
44domain.checkpoint = False #True
45domain.default_order = 2
46
47#Set bed-slope and friction
48inflow_stage = 0.15
49manning = 0.07
50W = Weir(inflow_stage)
51
52print 'Field values'
53
54domain.set_quantity('elevation', W)
55domain.set_quantity('friction', manning)
56
57
58
59######################
60# Boundary conditions
61#
62print 'Boundaries'
63Br = Reflective_boundary(domain)
64Bt = Transmissive_boundary(domain)
65
66#Constant inflow
67Bd = Dirichlet_boundary(array([inflow_stage, 0.0, 0.0]))
68
69#Time dependent inflow
70from math import sin, pi
71Bw = Time_boundary(domain=domain,
72                   f=lambda x: array([(1 + sin(x*pi/4))*\
73                                      (inflow_stage*(sin(2.5*x*pi)+0.7)),0,0]))
74
75
76print 'Available boundary tags are', domain.get_boundary_tags()
77
78#Set boundary conditions
79domain.set_boundary({'left': Bw, '0': Br, '1':Bw, 'external':Br})
80
81
82#print domain.quantities['elevation'].vertex_values
83#print domain.quantities['stage'].vertex_values
84         
85######################
86#Initial condition
87print 'Initial condition'
88domain.set_quantity('stage', Constant_height(W, 0.))
89domain.check_integrity()
90
91######################
92#Evolution
93for t in domain.evolve(yieldstep = 0.01, finaltime = 5):
94    domain.write_time()
95   
96print 'Done'
97
98   
Note: See TracBrowser for help on using the repository browser.