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

Last change on this file since 5574 was 5574, checked in by ole, 16 years ago

Reverted changeset:5571 which inadvertently added a bunch of non-versioned
files.
The command used to revert this changeset was:

svn merge -r 5571:5570 .

in the anuga root directory.

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