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