[8728] | 1 | """Simple water flow example using ANUGA |
---|
| 2 | |
---|
| 3 | Water driven up a linear slope and time varying boundary, |
---|
| 4 | similar to a beach environment |
---|
| 5 | """ |
---|
| 6 | |
---|
| 7 | #------------------------------------------------------------------------------ |
---|
| 8 | # Import necessary modules |
---|
| 9 | #------------------------------------------------------------------------------ |
---|
| 10 | import anuga |
---|
| 11 | |
---|
| 12 | from math import sin, pi, exp |
---|
| 13 | |
---|
| 14 | #------------------------------------------------------------------------------ |
---|
| 15 | # Setup computational domain |
---|
| 16 | #------------------------------------------------------------------------------ |
---|
| 17 | points, vertices, boundary = anuga.rectangular_cross(10, 10) # Basic mesh |
---|
| 18 | |
---|
| 19 | domain = anuga.Domain(points, vertices, boundary) # Create domain |
---|
| 20 | domain.set_name('runup') # Output to file runup.sww |
---|
| 21 | domain.set_datadir('.') # Use current folder |
---|
| 22 | |
---|
| 23 | #------------------------------------------------------------------------------ |
---|
| 24 | # Setup initial conditions |
---|
| 25 | #------------------------------------------------------------------------------ |
---|
| 26 | def topography(x, y): |
---|
| 27 | return -x/2 # linear bed slope |
---|
| 28 | #return x*(-(2.0-x)*.5) # curved bed slope |
---|
| 29 | |
---|
| 30 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
| 31 | domain.set_quantity('friction', 0.1) # Constant friction |
---|
| 32 | domain.set_quantity('stage', -0.4) # Constant negative initial stage |
---|
| 33 | |
---|
| 34 | #------------------------------------------------------------------------------ |
---|
| 35 | # Setup boundary conditions |
---|
| 36 | #------------------------------------------------------------------------------ |
---|
| 37 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
| 38 | Bt = anuga.Transmissive_boundary(domain) # Continue all values on boundary |
---|
| 39 | Bd = anuga.Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values |
---|
| 40 | Bw = anuga.Time_boundary(domain=domain, # Time dependent boundary |
---|
| 41 | f=lambda t: [(0.1*sin(t*2*pi)-0.3)*exp(-t), 0.0, 0.0]) |
---|
| 42 | |
---|
| 43 | # Associate boundary tags with boundary objects |
---|
| 44 | domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br}) |
---|
| 45 | |
---|
| 46 | #------------------------------------------------------------------------------ |
---|
| 47 | # Evolve system through time |
---|
| 48 | #------------------------------------------------------------------------------ |
---|
| 49 | for t in domain.evolve(yieldstep=0.1, finaltime=10.0): |
---|
| 50 | print domain.timestepping_statistics() |
---|