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