1 | """Example of shallow water wave equation. |
---|
2 | |
---|
3 | This is called Netherlands because it shows a dam with a gap in it and |
---|
4 | stylised housed behind it and below the water surface. |
---|
5 | |
---|
6 | """ |
---|
7 | |
---|
8 | ###################### |
---|
9 | # Module imports |
---|
10 | # |
---|
11 | from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\ |
---|
12 | Transmissive_boundary, Time_boundary, Constant_height |
---|
13 | |
---|
14 | from mesh_factory import from_polyfile |
---|
15 | from Numeric import array |
---|
16 | |
---|
17 | |
---|
18 | print 'Creating domain' |
---|
19 | points, triangles, values = from_polyfile('cornell_room_medres') |
---|
20 | |
---|
21 | #Create shallow water domain |
---|
22 | domain = Domain(points, triangles) |
---|
23 | |
---|
24 | domain.check_integrity() |
---|
25 | domain.default_order = 2 |
---|
26 | domain.smooth = True |
---|
27 | domain.reduction = min #Looks a lot better on top of steep slopes |
---|
28 | |
---|
29 | print "Number of triangles = ", len(domain) |
---|
30 | |
---|
31 | domain.visualise = False |
---|
32 | domain.checkpoint = False |
---|
33 | domain.store = True #Store for visualisation purposes |
---|
34 | domain.format = 'sww' #Native netcdf visualisation format |
---|
35 | import sys, os |
---|
36 | root, ext = os.path.splitext(sys.argv[0]) |
---|
37 | if domain.smooth is True: |
---|
38 | s = 'smooth' |
---|
39 | else: |
---|
40 | s = 'nonsmooth' |
---|
41 | domain.filename = root + '_' + s |
---|
42 | |
---|
43 | #Set bed-slope and friction |
---|
44 | manning = 0.0 |
---|
45 | |
---|
46 | print 'Field values' |
---|
47 | domain.set_quantity('elevation', values) |
---|
48 | domain.set_quantity('friction', manning) |
---|
49 | |
---|
50 | |
---|
51 | ###################### |
---|
52 | # Boundary conditions |
---|
53 | # |
---|
54 | print 'Boundaries' |
---|
55 | Br = Reflective_boundary(domain) |
---|
56 | domain.set_boundary({'exterior': Br}) |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | ###################### |
---|
61 | #Initial condition |
---|
62 | # |
---|
63 | print 'Initial condition' |
---|
64 | E = domain.quantities['elevation'].vertex_values |
---|
65 | print max(E) |
---|
66 | L = E.copy() |
---|
67 | N = len(L) |
---|
68 | L[:N/4] += 100 |
---|
69 | domain.set_quantity('level', L) |
---|
70 | |
---|
71 | #Evolve |
---|
72 | for t in domain.evolve(yieldstep = 0.01, finaltime = 1.0): |
---|
73 | domain.write_time() |
---|
74 | |
---|
75 | |
---|
76 | |
---|