1 | """Simple water flow example using ANUGA |
---|
2 | |
---|
3 | Water driven up a linear slope and time varying boundary, |
---|
4 | similar to a beach environment |
---|
5 | """ |
---|
6 | |
---|
7 | |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | # Import necessary modules |
---|
10 | #------------------------------------------------------------------------------ |
---|
11 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
12 | from anuga.shallow_water import Domain |
---|
13 | from anuga.shallow_water import Reflective_boundary |
---|
14 | from anuga.shallow_water import Dirichlet_boundary |
---|
15 | from anuga.shallow_water import Time_boundary |
---|
16 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
17 | |
---|
18 | |
---|
19 | #------------------------------------------------------------------------------ |
---|
20 | # Setup computational domain |
---|
21 | #------------------------------------------------------------------------------ |
---|
22 | N=10 |
---|
23 | points, vertices, boundary = rectangular_cross(N, N) # Basic mesh |
---|
24 | |
---|
25 | domain = Domain(points, vertices, boundary) # Create domain |
---|
26 | domain.set_name('runup') # Output to bedslope.sww |
---|
27 | |
---|
28 | |
---|
29 | #------------------------------------------------------------------------------ |
---|
30 | # Setup initial conditions |
---|
31 | #------------------------------------------------------------------------------ |
---|
32 | def topography(x,y): |
---|
33 | return -x/2 # linear bed slope |
---|
34 | |
---|
35 | |
---|
36 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
37 | domain.set_quantity('friction', 0.0) # Constant friction |
---|
38 | domain.set_quantity('stage', -.4) # Constant negative initial stage |
---|
39 | |
---|
40 | |
---|
41 | #------------------------------------------------------------------------------ |
---|
42 | # Setup boundary conditions |
---|
43 | #------------------------------------------------------------------------------ |
---|
44 | from math import sin, pi, exp |
---|
45 | |
---|
46 | def waveform(t): |
---|
47 | return (0.1*sin(t*2*pi)-0.8) * exp(-2*t) |
---|
48 | |
---|
49 | Bw = Transmissive_Momentum_Set_Stage_boundary(domain, waveform) |
---|
50 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
51 | Bd = Dirichlet_boundary([-0.3,0,0]) |
---|
52 | |
---|
53 | # Associate boundary tags with boundary objects |
---|
54 | domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br}) |
---|
55 | |
---|
56 | |
---|
57 | #------------------------------------------------------------------------------ |
---|
58 | # Evolve system through time |
---|
59 | #------------------------------------------------------------------------------ |
---|
60 | for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0): |
---|
61 | domain.write_time() |
---|
62 | |
---|
63 | |
---|
64 | |
---|