1 | """Example of shallow water wave equation analytical solution of the |
---|
2 | circular hydraulic jump experimental data treated as a two-dimensional solution. |
---|
3 | |
---|
4 | Copyright 2005 |
---|
5 | Christopher Zoppou, Stephen Roberts |
---|
6 | Geoscience Australia, ANU |
---|
7 | """ |
---|
8 | |
---|
9 | #------------------------------- |
---|
10 | # Set up path and module imports |
---|
11 | import sys |
---|
12 | from os import sep |
---|
13 | sys.path.append('..'+sep+'pyvolution') |
---|
14 | |
---|
15 | from shallow_water import Domain, Dirichlet_Discharge_boundary |
---|
16 | from shallow_water import Transmissive_Momentum_Set_Stage_boundary, Dirichlet_boundary |
---|
17 | from math import pi, sqrt |
---|
18 | from mesh_factory import strang_mesh |
---|
19 | |
---|
20 | #--------- |
---|
21 | # Geometry |
---|
22 | bed = ([.519, .519, .519, .519, .5192, .5194, .5196, .520, .5207, .5215, .5233, .5233]) |
---|
23 | distance = ([.08, .10, .11, .16, .21, .26, .31, .36, .41, .46, .50, .52]) |
---|
24 | n_bed = 12 |
---|
25 | |
---|
26 | #--------- |
---|
27 | # Case A.4 |
---|
28 | Q = 9.985/1000.0 |
---|
29 | wh0 = Q/(2.0*pi*0.1) |
---|
30 | h0 = bed[2] + 0.005 |
---|
31 | wh1 = -Q/(2.0*pi*0.5) |
---|
32 | h1 = 0.562 |
---|
33 | Manning = 0.009 |
---|
34 | |
---|
35 | #------------------ |
---|
36 | # Set up the domain |
---|
37 | # Strang_domain will search through the file and test to see if there are |
---|
38 | # two or three entries. Two entries are for points and three for triangles. |
---|
39 | points, elements = strang_mesh('circular.pt') |
---|
40 | domain = Domain(points, elements) |
---|
41 | |
---|
42 | print "Number of triangles = ", len(domain) |
---|
43 | |
---|
44 | #---------------------- |
---|
45 | # Set a default tagging |
---|
46 | |
---|
47 | |
---|
48 | for id, face in domain.boundary: |
---|
49 | domain.boundary[(id,face)] = 'outer' |
---|
50 | point = domain.get_vertex_coordinate(id,(face+1)%3) |
---|
51 | radius2 = point[0]*point[0] + point[1]*point[1] |
---|
52 | typical_outer = (id,face) |
---|
53 | if radius2 < 0.1: |
---|
54 | domain.boundary[(id,face)] = 'inner' |
---|
55 | typical_inner = (id,face) |
---|
56 | |
---|
57 | |
---|
58 | #------------------------------------- |
---|
59 | # Provide file name for storing output |
---|
60 | #domain.visualise = True |
---|
61 | domain.store = True |
---|
62 | domain.format = 'sww' |
---|
63 | domain.filename = 'circular_second_order' |
---|
64 | |
---|
65 | #------------------------------------------ |
---|
66 | # Reduction operation for get_vertex_values |
---|
67 | from util import mean |
---|
68 | domain.reduction = mean |
---|
69 | #domain.reduction = min #Looks better near steep slopes |
---|
70 | |
---|
71 | #--------------------------- |
---|
72 | # Function for bed-elevation |
---|
73 | def bed_z(x,y): |
---|
74 | n = x.shape[0] |
---|
75 | z = 0*x |
---|
76 | for i in range(n): |
---|
77 | r = sqrt(x[i]*x[i]+y[i]*y[i]) |
---|
78 | for j in range(n_bed-1): |
---|
79 | if distance[j] <= r: |
---|
80 | if distance[j+1] > r: |
---|
81 | z[i] = bed[0] |
---|
82 | #bed[j] + (bed[j+1] - bed[j])/(distance[j+1] - distance[j])*(r - distance[j]) |
---|
83 | return z |
---|
84 | domain.set_quantity('elevation', bed_z) |
---|
85 | |
---|
86 | #--------- |
---|
87 | # Friction |
---|
88 | domain.set_quantity('friction', Manning) |
---|
89 | |
---|
90 | #--------------------------------- |
---|
91 | # Function for initial water depth |
---|
92 | def level(x,y): |
---|
93 | z = bed_z(x,y) |
---|
94 | n = x.shape[0] |
---|
95 | w = 0*x |
---|
96 | for i in range(n): |
---|
97 | w[i] = h0 |
---|
98 | h = w[i] - z[i] |
---|
99 | return w |
---|
100 | |
---|
101 | |
---|
102 | def outflow_height(t): |
---|
103 | return [h1, 0 , 0] |
---|
104 | |
---|
105 | |
---|
106 | domain.set_quantity('stage', level) |
---|
107 | |
---|
108 | #--------------------------- |
---|
109 | # Set up boundary conditions |
---|
110 | DD_BC_INNER = Dirichlet_Discharge_boundary(domain, h0, wh0) |
---|
111 | DD_BC_OUTER = Dirichlet_Discharge_boundary(domain, h1, wh1) |
---|
112 | |
---|
113 | domain.set_boundary({'inner': DD_BC_INNER, 'outer': DD_BC_OUTER}) |
---|
114 | |
---|
115 | #------------------ |
---|
116 | # Order of accuracy |
---|
117 | domain.default_order = 1 |
---|
118 | domain.CFL = 0.75 |
---|
119 | #domain.beta_w = 0.5 |
---|
120 | #domain.beta_h = 0.2 |
---|
121 | domain.smooth = True |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | domain.initialise_visualiser() |
---|
127 | #domain.visualiser.coloring['stage'] = True |
---|
128 | domain.visualiser.scale_z['stage'] = 2.0 |
---|
129 | domain.visualiser.scale_z['elevation'] = 0.05 |
---|
130 | |
---|
131 | |
---|
132 | from realtime_visualisation_new import Visualiser |
---|
133 | #vxmom = Visualiser(domain,title='xmomentum',scale_z=10.0) |
---|
134 | #vymom = Visualiser(domain,title='ymomentum',scale_z=10.0) |
---|
135 | |
---|
136 | |
---|
137 | #---------- |
---|
138 | # Evolution |
---|
139 | import time |
---|
140 | |
---|
141 | t0 = time.time() |
---|
142 | for t in domain.evolve(yieldstep = .01, finaltime = 10): |
---|
143 | domain.write_time() |
---|
144 | #vxmom.update_quantity('xmomentum') |
---|
145 | #vymom.update_quantity('ymomentum') |
---|
146 | print 'outer stage ',domain.quantities['stage'].get_values(location='centroids',indices=[typical_outer[0]]) |
---|
147 | print ' radial mom ',sqrt(domain.quantities['xmomentum'].get_values(location='centroids',indices=[typical_outer[0]])[0]**2 + |
---|
148 | domain.quantities['ymomentum'].get_values(location='centroids',indices=[typical_outer[0]])[0]**2) |
---|
149 | print 'inner stage ',domain.quantities['stage'].get_values(location='centroids',indices=[typical_inner[0]]) |
---|
150 | print ' radial mom ',sqrt(domain.quantities['xmomentum'].get_values(location='centroids',indices=[typical_inner[0]])[0]**2 + |
---|
151 | domain.quantities['ymomentum'].get_values(location='centroids',indices=[typical_inner[0]])[0]**2) |
---|
152 | |
---|
153 | |
---|
154 | print 'That took %.2f seconds' %(time.time()-t0) |
---|