[8728] | 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 | |
---|
| 14 | #------------------------------------------------------------------------------ |
---|
| 15 | # Setup computational domain |
---|
| 16 | #------------------------------------------------------------------------------ |
---|
| 17 | points, vertices, boundary = anuga.rectangular_cross(10, 5, |
---|
| 18 | len1=10.0, len2=5.0) # Mesh |
---|
| 19 | |
---|
| 20 | domain = anuga.Domain(points, vertices, boundary) # Create domain |
---|
| 21 | domain.set_name('channel1') # Output name |
---|
| 22 | |
---|
| 23 | #------------------------------------------------------------------------------ |
---|
| 24 | # Setup initial conditions |
---|
| 25 | #------------------------------------------------------------------------------ |
---|
| 26 | def topography(x, y): |
---|
| 27 | return -x/10 # linear bed slope |
---|
| 28 | |
---|
| 29 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
| 30 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
| 31 | domain.set_quantity('stage', # Dry bed |
---|
| 32 | expression='elevation') |
---|
| 33 | |
---|
| 34 | #------------------------------------------------------------------------------ |
---|
| 35 | # Setup boundary conditions |
---|
| 36 | #------------------------------------------------------------------------------ |
---|
| 37 | Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow |
---|
| 38 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
| 39 | |
---|
| 40 | domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
| 41 | |
---|
| 42 | #------------------------------------------------------------------------------ |
---|
| 43 | # Evolve system through time |
---|
| 44 | #------------------------------------------------------------------------------ |
---|
| 45 | for t in domain.evolve(yieldstep=0.2, finaltime=40.0): |
---|
| 46 | print domain.timestepping_statistics() |
---|
| 47 | |
---|