1 | """Validation study of Merimbula lake using Pyvolution. |
---|
2 | Example of shallow water wave equation applied to |
---|
3 | Malpasset dam break simulation. |
---|
4 | |
---|
5 | Copyright 2004 |
---|
6 | Christopher Zoppou, Stephen Roberts |
---|
7 | Australian National University |
---|
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 | Existence of file 'Hobart_mesh.tsh' is assumed. |
---|
17 | """ |
---|
18 | |
---|
19 | ############################### |
---|
20 | # Setup Path and importing modules |
---|
21 | import sys |
---|
22 | from os import sep, path |
---|
23 | sys.path.append('..'+sep+'pyvolution') |
---|
24 | |
---|
25 | import Numeric |
---|
26 | from shallow_water import Domain, Reflective_boundary, File_boundary,\ |
---|
27 | Dirichlet_boundary, Transmissive_boundary |
---|
28 | from pmesh2domain import pmesh_to_domain_instance |
---|
29 | from util import Polygon_function, read_polygon |
---|
30 | |
---|
31 | ###################### |
---|
32 | # Domain |
---|
33 | filename = 'hobart_mesh.tsh' |
---|
34 | yieldstep = 2 |
---|
35 | finaltime = 600 |
---|
36 | |
---|
37 | print 'Creating domain from', filename |
---|
38 | domain = pmesh_to_domain_instance(filename, Domain) |
---|
39 | print "Number of triangles = ", len(domain) |
---|
40 | |
---|
41 | domain.default_order = 1 |
---|
42 | domain.smooth = True |
---|
43 | domain.visualise = True |
---|
44 | |
---|
45 | #------------------------------ |
---|
46 | # Boundary Conditions |
---|
47 | tags = {} |
---|
48 | tags['external'] = Reflective_boundary(domain) |
---|
49 | domain.set_boundary(tags) |
---|
50 | |
---|
51 | #--------------------------------------------------------- |
---|
52 | #Decide which quantities are to be stored at each timestep |
---|
53 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
54 | |
---|
55 | #----------------- |
---|
56 | #Initial condition |
---|
57 | |
---|
58 | p0 = read_polygon('Hobart_recent_source_zone.xya') |
---|
59 | domain.set_quantity('stage',Polygon_function([(p0,10.0)])) |
---|
60 | |
---|
61 | stage_vv = domain.quantities['stage'].vertex_values |
---|
62 | elevation_vv = domain.quantities['elevation'].vertex_values |
---|
63 | |
---|
64 | new_stage_vv = stage_vv + elevation_vv |
---|
65 | |
---|
66 | domain.set_quantity('stage', new_stage_vv) |
---|
67 | |
---|
68 | #------------------------------------- |
---|
69 | # Provide file name for storing output |
---|
70 | domain.store = True |
---|
71 | domain.format = 'sww' |
---|
72 | domain.filename = 'Hobart_first_order' |
---|
73 | |
---|
74 | #---------------------------- |
---|
75 | # Friction |
---|
76 | domain.set_quantity('friction', 0.033) |
---|
77 | |
---|
78 | ###################### |
---|
79 | #Evolution |
---|
80 | import time |
---|
81 | t0 = time.time() |
---|
82 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
83 | domain.write_time() |
---|
84 | |
---|
85 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
86 | |
---|
87 | |
---|