source: anuga_core/documentation/user_manual/demos/runup.py @ 7064

Last change on this file since 7064 was 7064, checked in by rwilson, 15 years ago

Fiddling with layout of user guide.

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