1 | """Simple example of shallow water wave equation using Pyvolution |
---|
2 | |
---|
3 | Water driven by linear slope and Dirichlet boundary |
---|
4 | |
---|
5 | """ |
---|
6 | |
---|
7 | ###################### |
---|
8 | # Module imports |
---|
9 | # |
---|
10 | from pyvolution.mesh_factory import rectangular |
---|
11 | from pyvolution.shallow_water import Domain, Reflective_boundary,\ |
---|
12 | Dirichlet_boundary, Constant_height, Time_boundary, Transmissive_boundary |
---|
13 | from Numeric import array |
---|
14 | |
---|
15 | #Create basic mesh |
---|
16 | points, vertices, boundary = rectangular(10, 10) |
---|
17 | |
---|
18 | #Create shallow water domain |
---|
19 | domain = Domain(points, vertices, boundary) |
---|
20 | domain.smooth = False |
---|
21 | domain.visualise = True |
---|
22 | domain.store = True |
---|
23 | domain.filename = 'bedslope' |
---|
24 | domain.default_order=2 |
---|
25 | |
---|
26 | ####################### |
---|
27 | #Bed-slope and friction |
---|
28 | domain.set_quantity('elevation', lambda x,y: -x/3) |
---|
29 | domain.set_quantity('friction', 0.1) |
---|
30 | |
---|
31 | |
---|
32 | ###################### |
---|
33 | # Boundary conditions |
---|
34 | from math import sin, pi |
---|
35 | Br = Reflective_boundary(domain) |
---|
36 | Bt = Transmissive_boundary(domain) |
---|
37 | Bd = Dirichlet_boundary([0.2,0.,0.]) |
---|
38 | Bw = Time_boundary(domain=domain, |
---|
39 | f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) |
---|
40 | |
---|
41 | domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
42 | |
---|
43 | |
---|
44 | ###################### |
---|
45 | #Initial condition |
---|
46 | h = 0.05 |
---|
47 | #h = 0.0 |
---|
48 | elevation = domain.quantities['elevation'].vertex_values |
---|
49 | domain.set_quantity('stage', elevation + h) |
---|
50 | |
---|
51 | domain.check_integrity() |
---|
52 | |
---|
53 | |
---|
54 | ###################### |
---|
55 | #Evolution |
---|
56 | for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0): |
---|
57 | domain.write_time() |
---|
58 | |
---|
59 | for t in domain.evolve(yieldstep = 0.01, finaltime = 4.0): |
---|
60 | domain.write_time() |
---|
61 | |
---|