source: anuga_work/development/demos/runup.py @ 5175

Last change on this file since 5175 was 4539, checked in by ole, 18 years ago

Moved files from examples to anuga_work

File size: 2.3 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water driven up a linear slope and time varying boundary,
4similar to a beach environment
5"""
6
7
8#------------------------------------------------------------------------------
9# Import necessary modules
10#------------------------------------------------------------------------------
11from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
12from anuga.shallow_water import Domain
13from anuga.shallow_water import Reflective_boundary
14from anuga.shallow_water import Dirichlet_boundary
15from anuga.shallow_water import Time_boundary
16from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary
17
18
19#------------------------------------------------------------------------------
20# Setup computational domain
21#------------------------------------------------------------------------------
22N=10
23points, vertices, boundary = rectangular_cross(N, N) # Basic mesh
24
25domain = Domain(points, vertices, boundary) # Create domain
26domain.set_name('runup')                    # Output to bedslope.sww
27
28
29#------------------------------------------------------------------------------
30# Setup initial conditions
31#------------------------------------------------------------------------------
32def topography(x,y):
33    return -x/2                             # linear bed slope
34   
35
36domain.set_quantity('elevation', topography) # Use function for elevation
37domain.set_quantity('friction', 0.0)         # Constant friction
38domain.set_quantity('stage', -.4)            # Constant negative initial stage
39
40
41#------------------------------------------------------------------------------
42# Setup boundary conditions
43#------------------------------------------------------------------------------
44from math import sin, pi, exp
45
46def waveform(t): 
47    return (0.1*sin(t*2*pi)-0.8) * exp(-2*t)
48
49Bw = Transmissive_Momentum_Set_Stage_boundary(domain, waveform)
50Br = Reflective_boundary(domain)      # Solid reflective wall
51Bd = Dirichlet_boundary([-0.3,0,0])
52
53# Associate boundary tags with boundary objects
54domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br})
55
56
57#------------------------------------------------------------------------------
58# Evolve system through time
59#------------------------------------------------------------------------------
60for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0):
61    domain.write_time()
62   
63
64
Note: See TracBrowser for help on using the repository browser.