source: inundation/ga/storm_surge/analytical solutions/Analytical solution_oblique_shock.py @ 1599

Last change on this file since 1599 was 1160, checked in by steve, 20 years ago
File size: 2.3 KB
Line 
1"""
2Example of shallow water wave equation
3consisting of an asymetrical converging channel.
4
5Copyright 2004
6Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray
7Geoscience Australia, ANU
8
9Specific methods pertaining to the 2D shallow water equation
10are imported from shallow_water
11for use with the generic finite volume framework
12
13Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the
14numerical vector named conserved_quantities.
15
16"""
17
18######################
19# Module imports
20#
21
22#Were these used?
23#import visualise2_chris as visualise
24#import Image, ImageGrab
25
26import sys
27from os import sep
28sys.path.append('..'+sep+'pyvolution')
29
30
31from shallow_water import Domain, Constant_height
32from shallow_water import Transmissive_boundary, Reflective_boundary,\
33     Dirichlet_boundary
34
35from math import sqrt, cos, sin, pi
36from mesh_factory import oblique
37
38
39######################
40# Domain
41#
42n = 60
43m = 80
44leny = 30.
45lenx = 40.
46n = 50
47m = 60
48
49points, elements, boundary = oblique(m, n, lenx, leny)
50domain = Domain(points, elements, boundary)
51
52# Order of solver
53domain.default_order=2
54
55# Store output
56domain.store=True
57
58# Output format
59domain.format="sww" #NET.CDF binary format
60                    # "dat" for ASCII
61
62# Provide file name for storing output
63domain.filename="oblique"
64
65# Visualization smoothing
66domain.smooth=True
67
68#######################
69#Bed-slope and friction
70def x_slope(x, y):
71    return 0*x
72
73domain.set_quantity('elevation', x_slope)
74domain.set_quantity('friction', 0.0)
75
76######################
77# Boundary conditions
78#
79R = Reflective_boundary(domain)
80T = Transmissive_boundary(domain)
81D = Dirichlet_boundary([1.0, 8.57, 0.0])
82
83domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R})
84
85######################
86#Initial condition
87h = 0.5
88domain.set_quantity('stage', Constant_height(x_slope, h) )
89
90
91######################
92#Evolution
93import time
94t0 = time.time()
95for t in domain.evolve(yieldstep = 0.5, finaltime = 50):
96    domain.write_time()
97
98print 'That took %.2f seconds' %(time.time()-t0)
99
100#FIXME: Compute average water depth on either side of shock and compare
101#to expected values. And also Froude numbers.
102
103
104#print "saving file?"
105#im = ImageGrab.grab()
106#im.save("ccube.eps")
107
108
109
Note: See TracBrowser for help on using the repository browser.