1 | """Simple water flow example using ANUGA |
---|
2 | |
---|
3 | Water flowing down a channel |
---|
4 | """ |
---|
5 | |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | # Import necessary modules |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | |
---|
10 | # Import standard shallow water domain and standard boundaries. |
---|
11 | import anuga |
---|
12 | |
---|
13 | # Import rectangular cross mesh generator |
---|
14 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
15 | |
---|
16 | |
---|
17 | #------------------------------------------------------------------------------ |
---|
18 | # Setup computational domain |
---|
19 | #------------------------------------------------------------------------------ |
---|
20 | points, vertices, boundary = rectangular_cross(10, 5, |
---|
21 | len1=10.0, len2=5.0) # Mesh |
---|
22 | |
---|
23 | domain = anuga.Domain(points, vertices, boundary) # Create domain |
---|
24 | domain.set_name('channel1') # Output name |
---|
25 | |
---|
26 | #------------------------------------------------------------------------------ |
---|
27 | # Setup initial conditions |
---|
28 | #------------------------------------------------------------------------------ |
---|
29 | def topography(x, y): |
---|
30 | return -x/10 # linear bed slope |
---|
31 | |
---|
32 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
33 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
34 | domain.set_quantity('stage', # Dry bed |
---|
35 | expression='elevation') |
---|
36 | |
---|
37 | #------------------------------------------------------------------------------ |
---|
38 | # Setup boundary conditions |
---|
39 | #------------------------------------------------------------------------------ |
---|
40 | Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow |
---|
41 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
42 | |
---|
43 | domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
44 | |
---|
45 | #------------------------------------------------------------------------------ |
---|
46 | # Evolve system through time |
---|
47 | #------------------------------------------------------------------------------ |
---|
48 | for t in domain.evolve(yieldstep=0.2, finaltime=40.0): |
---|
49 | print domain.timestepping_statistics() |
---|