source: trunk/anuga_core/demos/runup.py @ 8969

Last change on this file since 8969 was 8728, checked in by steve, 12 years ago

Adding in usermanual and demos

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