source: inundation/ga/storm_surge/pyvolution/run_tsh.py @ 333

Last change on this file since 333 was 309, checked in by duncan, 20 years ago

added basic smoothing function to least squares

File size: 2.2 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
32points, vertices, boundary = pmesh_to_domain(filename)
33domain = Domain(points, vertices, boundary)
34print "Number of triangles = ", len(domain)
35
36domain.store = False #True
37domain.format = 'sww'
38domain.filename = 'weir'
39domain.checkpoint = False #True
40domain.visualise = True #False
41domain.default_order = 2
42
43#Set bed-slope and friction
44inflow_stage = 0.15
45manning = 0.07
46W = Weir(inflow_stage)
47
48print 'Field values'
49
50domain.set_quantity('elevation', W)
51domain.set_quantity('friction', manning)
52
53
54
55######################
56# Boundary conditions
57#
58print 'Boundaries'
59Br = Reflective_boundary(domain)
60Bt = Transmissive_boundary(domain)
61
62#Constant inflow
63Bd = Dirichlet_boundary(array([inflow_stage, 0.0, 0.0]))
64
65#Time dependent inflow
66from math import sin, pi
67Bw = Time_boundary(domain=domain,
68                   f=lambda x: array([(1 + sin(x*pi/4))*\
69                                      (inflow_stage*(sin(2.5*x*pi)+0.7)),0,0]))
70
71
72print 'Available boundary tags are', domain.get_boundary_tags()
73
74#Set boundary conditions
75domain.set_boundary({'left': Bw, '0': Br})
76
77######################
78#Initial condition
79print 'Initial condition'
80domain.set_quantity('level', Constant_height(W, 0.))
81domain.check_integrity()
82
83######################
84#Evolution
85for t in domain.evolve(yieldstep = 0.01, finaltime = 5):
86    domain.write_time()
87   
88print 'Done'
89
90   
Note: See TracBrowser for help on using the repository browser.