[3740] | 1 | """Simple water flow example using ANUGA |
---|
| 2 | |
---|
[3753] | 3 | Water flowing down a channel with changing boundary conditions |
---|
[3740] | 4 | """ |
---|
| 5 | |
---|
| 6 | #------------------------------------------------------------------------------ |
---|
| 7 | # Import necessary modules |
---|
| 8 | #------------------------------------------------------------------------------ |
---|
[7806] | 9 | import anuga |
---|
[3740] | 10 | |
---|
| 11 | #------------------------------------------------------------------------------ |
---|
| 12 | # Setup computational domain |
---|
| 13 | #------------------------------------------------------------------------------ |
---|
| 14 | length = 10. |
---|
| 15 | width = 5. |
---|
| 16 | dx = dy = 1 # Resolution: Length of subdivisions on both axes |
---|
| 17 | |
---|
[7806] | 18 | points, vertices, boundary = anuga.rectangular_cross(int(length/dx), |
---|
| 19 | int(width/dy), len1=length, len2=width) |
---|
| 20 | |
---|
| 21 | domain = anuga.Domain(points, vertices, boundary) |
---|
[3863] | 22 | domain.set_name('channel2') # Output name |
---|
[3740] | 23 | |
---|
| 24 | #------------------------------------------------------------------------------ |
---|
| 25 | # Setup initial conditions |
---|
| 26 | #------------------------------------------------------------------------------ |
---|
| 27 | def topography(x,y): |
---|
| 28 | return -x/10 # linear bed slope |
---|
| 29 | |
---|
[3753] | 30 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
| 31 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
| 32 | domain.set_quantity('stage', |
---|
| 33 | expression='elevation') # Dry initial condition |
---|
[3740] | 34 | |
---|
| 35 | #------------------------------------------------------------------------------ |
---|
| 36 | # Setup boundary conditions |
---|
| 37 | #------------------------------------------------------------------------------ |
---|
[7806] | 38 | Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow |
---|
| 39 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
| 40 | Bo = anuga.Dirichlet_boundary([-5, 0, 0]) # Outflow |
---|
[3740] | 41 | |
---|
| 42 | domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
| 43 | |
---|
| 44 | #------------------------------------------------------------------------------ |
---|
| 45 | # Evolve system through time |
---|
| 46 | #------------------------------------------------------------------------------ |
---|
[7064] | 47 | for t in domain.evolve(yieldstep=0.2, finaltime=40.0): |
---|
[6889] | 48 | print domain.timestepping_statistics() |
---|
[3740] | 49 | |
---|
[3753] | 50 | if domain.get_quantity('stage').\ |
---|
| 51 | get_values(interpolation_points=[[10, 2.5]]) > 0: |
---|
| 52 | print 'Stage > 0: Changing to outflow boundary' |
---|
[3829] | 53 | domain.set_boundary({'right': Bo}) |
---|
[7806] | 54 | |
---|