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 random |
---|
11 | import os |
---|
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", "scenarios", |
---|
16 | "channelflow"]) |
---|
17 | |
---|
18 | #------------------------------------------------------------------------------ |
---|
19 | # Setup computational domain |
---|
20 | #------------------------------------------------------------------------------ |
---|
21 | def runex(lower,length): |
---|
22 | points, vertices, boundary = anuga.rectangular_cross(50,50, |
---|
23 | len1=length, len2=length) # Mesh |
---|
24 | |
---|
25 | #-------------------------------------------------------------------------- |
---|
26 | # Setup Domain only on processor 0 |
---|
27 | #-------------------------------------------------------------------------- |
---|
28 | domain = anuga.Domain(points, vertices, boundary) # Create domain |
---|
29 | domain.set_datadir(scenariodir) |
---|
30 | domain.set_name('channel1.sww') # Output name |
---|
31 | |
---|
32 | def topography(x, y): |
---|
33 | z = -x/10 |
---|
34 | N = len(x) |
---|
35 | for i in range(N): |
---|
36 | if y[i] > lower: |
---|
37 | z[i] += 1 |
---|
38 | |
---|
39 | return z |
---|
40 | |
---|
41 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
42 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
43 | domain.set_quantity('stage', -1000.0) |
---|
44 | |
---|
45 | |
---|
46 | #------------------------------------------------------------------------------ |
---|
47 | # Setup boundary conditions |
---|
48 | #------------------------------------------------------------------------------ |
---|
49 | Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow |
---|
50 | Bo = anuga.Dirichlet_boundary([-100,0,0]) |
---|
51 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
52 | domain.set_boundary({'left': Bi, 'right': Bo, '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 | #if myid == 0: |
---|
59 | domain.write_time() |
---|
60 | |
---|
61 | #domain.sww_merge() |
---|
62 | #finalize() |
---|
63 | |
---|