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