[3486] | 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 | #------------------------------------------------------------------------------ |
---|
[6889] | 10 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
[3563] | 11 | from anuga.shallow_water import Domain |
---|
| 12 | from anuga.shallow_water import Reflective_boundary |
---|
| 13 | from anuga.shallow_water import Dirichlet_boundary |
---|
| 14 | from anuga.shallow_water import Time_boundary |
---|
| 15 | from anuga.shallow_water import Transmissive_boundary |
---|
[3486] | 16 | |
---|
[6889] | 17 | from math import sin, pi, exp |
---|
[3486] | 18 | |
---|
| 19 | #------------------------------------------------------------------------------ |
---|
| 20 | # Setup computational domain |
---|
| 21 | #------------------------------------------------------------------------------ |
---|
[6227] | 22 | points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh |
---|
[3486] | 23 | |
---|
| 24 | domain = Domain(points, vertices, boundary) # Create domain |
---|
[4551] | 25 | domain.set_name('runup') # Output to file runup.sww |
---|
[3486] | 26 | domain.set_datadir('.') # Use current directory for output |
---|
| 27 | |
---|
| 28 | #------------------------------------------------------------------------------ |
---|
| 29 | # Setup initial conditions |
---|
| 30 | #------------------------------------------------------------------------------ |
---|
| 31 | def topography(x,y): |
---|
[7064] | 32 | return -x/2 # linear bed slope |
---|
[5574] | 33 | #return x*(-(2.0-x)*.5) # curved bed slope |
---|
[3486] | 34 | |
---|
| 35 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
| 36 | domain.set_quantity('friction', 0.1) # Constant friction |
---|
| 37 | domain.set_quantity('stage', -.4) # Constant negative initial stage |
---|
| 38 | |
---|
| 39 | #------------------------------------------------------------------------------ |
---|
| 40 | # Setup boundary conditions |
---|
| 41 | #------------------------------------------------------------------------------ |
---|
| 42 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
| 43 | Bt = Transmissive_boundary(domain) # Continue all values on boundary |
---|
| 44 | Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values |
---|
| 45 | Bw = Time_boundary(domain=domain, # Time dependent boundary |
---|
[5112] | 46 | f=lambda t: [(.1*sin(t*2*pi)-0.3) * exp(-t), 0.0, 0.0]) |
---|
[3486] | 47 | |
---|
| 48 | # Associate boundary tags with boundary objects |
---|
| 49 | domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br}) |
---|
| 50 | |
---|
| 51 | #------------------------------------------------------------------------------ |
---|
| 52 | # Evolve system through time |
---|
| 53 | #------------------------------------------------------------------------------ |
---|
| 54 | for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0): |
---|
[6889] | 55 | print domain.timestepping_statistics() |
---|