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 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
13 | |
---|
14 | home = os.getenv('INUNDATIONHOME') |
---|
15 | scenariodir = add_directories(home, ["data","mem_time_test", "parameters", |
---|
16 | "nothing"]) |
---|
17 | |
---|
18 | |
---|
19 | file = 'CAIRNS.sww' |
---|
20 | file_path = os.path.join(scenariodir, file) |
---|
21 | |
---|
22 | h = 'CAIRNS.msh' |
---|
23 | file_pathh = os.path.join(scenariodir, h) |
---|
24 | |
---|
25 | #------------------------------------------------------------------------------ |
---|
26 | # Setup computational domain |
---|
27 | #------------------------------------------------------------------------------ |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | def runex(): |
---|
32 | points, vertices, boundary = anuga.rectangular_cross(10,5, |
---|
33 | len1=10.0, len2=5.0) # Mesh |
---|
34 | domain = anuga.Domain(points, vertices, boundary) # Create domain |
---|
35 | domain.set_name('channel1') # Output name |
---|
36 | domain.set_datadir(scenariodir) |
---|
37 | #------------------------------------------------------------------------------ |
---|
38 | # Setup initial conditions |
---|
39 | #------------------------------------------------------------------------------ |
---|
40 | def topography(x, y): |
---|
41 | return -x/10 # linear bed slope |
---|
42 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
43 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
44 | domain.set_quantity('stage', # Dry bed |
---|
45 | expression='elevation') |
---|
46 | |
---|
47 | #------------------------------------------------------------------------------ |
---|
48 | # Setup boundary conditions |
---|
49 | #------------------------------------------------------------------------------ |
---|
50 | Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow |
---|
51 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
52 | domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
53 | |
---|
54 | #------------------------------------------------------------------------------ |
---|
55 | # Evolve system through time |
---|
56 | #------------------------------------------------------------------------------ |
---|
57 | for t in domain.evolve(yieldstep=0.2, finaltime=40.0): |
---|
58 | print domain.timestepping_statistics() |
---|
59 | return len(domain) |
---|
60 | |
---|
61 | |
---|