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