source: anuga_core/source/anuga/examples/runup.py @ 3556

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

Modified runup to work with restructure

File size: 2.5 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#------------------------------------------------------------------------------
11
12from anuga.pyvolution.mesh_factory import rectangular_cross
13from anuga.pyvolution.shallow_water import Domain
14from anuga.pyvolution.shallow_water import Reflective_boundary
15from anuga.pyvolution.shallow_water import Dirichlet_boundary
16from anuga.pyvolution.shallow_water import Time_boundary
17from anuga.pyvolution.shallow_water import Transmissive_boundary
18
19
20#------------------------------------------------------------------------------
21# Setup computational domain
22#------------------------------------------------------------------------------
23
24points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
25
26domain = Domain(points, vertices, boundary) # Create domain
27domain.set_name('runup')                    # Output to bedslope.sww
28
29
30#------------------------------------------------------------------------------
31# Setup initial conditions
32#------------------------------------------------------------------------------
33
34def topography(x,y):
35    return -x/2                             # linear bed slope
36    #return x*(-(2.0-x)*.5)                  # curved bed slope
37
38domain.set_quantity('elevation', topography) # Use function for elevation
39domain.set_quantity('friction', 0.1)         # Constant friction
40domain.set_quantity('stage', -.4)            # Constant negative initial stage
41
42
43#------------------------------------------------------------------------------
44# Setup boundary conditions
45#------------------------------------------------------------------------------
46
47from math import sin, pi, exp
48Br = Reflective_boundary(domain)      # Solid reflective wall
49Bt = Transmissive_boundary(domain)    # Continue all values on boundary
50Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
51Bw = Time_boundary(domain=domain,     # Time dependent boundary 
52                   f=lambda t: [(.1*sin(t*2*pi)-0.3) * exp(-2*t), 0.0, 0.0])
53
54# Associate boundary tags with boundary objects
55domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br})
56
57
58#------------------------------------------------------------------------------
59# Evolve system through time
60#------------------------------------------------------------------------------
61
62for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0):
63    domain.write_time()
64   
65
66
Note: See TracBrowser for help on using the repository browser.