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, Time_boundary, Transmissive_boundary |
---|
13 | |
---|
14 | #Create basic mesh |
---|
15 | points, vertices, boundary = rectangular(10, 10) |
---|
16 | |
---|
17 | #Create shallow water domain |
---|
18 | domain = Domain(points, vertices, boundary) |
---|
19 | domain.smooth = False |
---|
20 | domain.visualise = False |
---|
21 | domain.store = True |
---|
22 | domain.filename = 'bedslope' |
---|
23 | domain.default_order = 2 |
---|
24 | |
---|
25 | ####################### |
---|
26 | # Initial conditions |
---|
27 | def f(x,y): |
---|
28 | return -x/2 |
---|
29 | |
---|
30 | domain.set_quantity('elevation', f) |
---|
31 | domain.set_quantity('friction', 0.1) |
---|
32 | |
---|
33 | h = 0.05 # Constant depth |
---|
34 | domain.set_quantity('stage', expression = 'elevation + %f' %h) |
---|
35 | |
---|
36 | |
---|
37 | ###################### |
---|
38 | # Boundary conditions |
---|
39 | from math import sin, pi |
---|
40 | Br = Reflective_boundary(domain) |
---|
41 | Bt = Transmissive_boundary(domain) |
---|
42 | Bd = Dirichlet_boundary([0.2,0.,0.]) |
---|
43 | Bw = Time_boundary(domain=domain, |
---|
44 | f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) |
---|
45 | |
---|
46 | |
---|
47 | domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
48 | #domain.set_boundary({'left': Bw, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
49 | |
---|
50 | |
---|
51 | ###################### |
---|
52 | #Evolution |
---|
53 | |
---|
54 | domain.check_integrity() |
---|
55 | |
---|
56 | for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0): |
---|
57 | domain.write_time() |
---|
58 | |
---|
59 | |
---|
60 | |
---|