[3508] | 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 | #------------------------------------------------------------------------------ |
---|
| 9 | # Import necessary modules |
---|
| 10 | #------------------------------------------------------------------------------ |
---|
[3560] | 11 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
[3563] | 12 | from anuga.shallow_water import Domain |
---|
| 13 | from anuga.shallow_water import Reflective_boundary |
---|
| 14 | from anuga.shallow_water import Dirichlet_boundary |
---|
| 15 | from anuga.shallow_water import Time_boundary |
---|
[3689] | 16 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
[3508] | 17 | |
---|
| 18 | |
---|
| 19 | #------------------------------------------------------------------------------ |
---|
| 20 | # Setup computational domain |
---|
| 21 | #------------------------------------------------------------------------------ |
---|
[3689] | 22 | N=10 |
---|
| 23 | points, vertices, boundary = rectangular_cross(N, N) # Basic mesh |
---|
[3508] | 24 | |
---|
| 25 | domain = Domain(points, vertices, boundary) # Create domain |
---|
| 26 | domain.set_name('runup') # Output to bedslope.sww |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | #------------------------------------------------------------------------------ |
---|
| 30 | # Setup initial conditions |
---|
| 31 | #------------------------------------------------------------------------------ |
---|
| 32 | def topography(x,y): |
---|
| 33 | return -x/2 # linear bed slope |
---|
[3689] | 34 | |
---|
[3508] | 35 | |
---|
| 36 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
[3689] | 37 | domain.set_quantity('friction', 0.0) # Constant friction |
---|
[3508] | 38 | domain.set_quantity('stage', -.4) # Constant negative initial stage |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | #------------------------------------------------------------------------------ |
---|
| 42 | # Setup boundary conditions |
---|
| 43 | #------------------------------------------------------------------------------ |
---|
[3689] | 44 | from math import sin, pi, exp |
---|
[3508] | 45 | |
---|
[3689] | 46 | def waveform(t): |
---|
| 47 | return (0.1*sin(t*2*pi)-0.8) * exp(-2*t) |
---|
| 48 | |
---|
| 49 | Bw = Transmissive_Momentum_Set_Stage_boundary(domain, waveform) |
---|
[3508] | 50 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
[3689] | 51 | Bd = Dirichlet_boundary([-0.3,0,0]) |
---|
[3508] | 52 | |
---|
| 53 | # Associate boundary tags with boundary objects |
---|
| 54 | domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br}) |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | #------------------------------------------------------------------------------ |
---|
| 58 | # Evolve system through time |
---|
| 59 | #------------------------------------------------------------------------------ |
---|
[3689] | 60 | for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0): |
---|
[3508] | 61 | domain.write_time() |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|