source: trunk/anuga_core/examples/channel3.py @ 9680

Last change on this file since 9680 was 9309, checked in by steve, 11 years ago

small changes plot_utils

File size: 2.6 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water flowing down a channel with more complex topography
4"""
5
6#------------------------------------------------------------------------------
7# Import necessary modules
8#------------------------------------------------------------------------------
9import anuga
10
11#------------------------------------------------------------------------------
12# Setup computational domain
13#------------------------------------------------------------------------------
14length = 40.
15width = 5.
16dx = dy = .1           # Resolution: Length of subdivisions on both axes
17
18points, vertices, boundary = anuga.rectangular_cross(int(length/dx),
19                                         int(width/dy), len1=length, len2=width)
20domain = anuga.Domain(points, vertices, boundary)
21domain.set_name('channel3')                  # Output name
22domain.set_flow_algorithm('DE0')
23print domain.statistics()
24
25#------------------------------------------------------------------------------
26# Setup initial conditions
27#------------------------------------------------------------------------------
28def topography(x,y):
29    """Complex topography defined by a function of vectors x and y."""
30
31    z = -x/10
32
33    N = len(x)
34    for i in range(N):
35        # Step
36        if 10 < x[i] < 12:
37            z[i] += 0.4 - 0.05*y[i]
38
39        # Constriction
40        if 27 < x[i] < 29 and y[i] > 3:
41            z[i] += 2
42
43        # Pole
44        if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
45            z[i] += 2
46
47    return z
48
49domain.set_quantity('elevation', topography)           # elevation is a function
50domain.set_quantity('friction', 0.01)                  # Constant friction
51domain.set_quantity('stage', expression='elevation')   # Dry initial condition
52
53#------------------------------------------------------------------------------
54# Setup boundary conditions
55#------------------------------------------------------------------------------
56Bi = anuga.Dirichlet_boundary([0.4, 0, 0])          # Inflow
57Br = anuga.Reflective_boundary(domain)              # Solid reflective wall
58Bo = anuga.Dirichlet_boundary([-5, 0, 0])           # Outflow
59
60domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
61
62#------------------------------------------------------------------------------
63# Evolve system through time
64#------------------------------------------------------------------------------
65for t in domain.evolve(yieldstep=0.1, finaltime=16.0):
66    print domain.timestepping_statistics()
67
68    if domain.get_quantity('stage').\
69           get_values(interpolation_points=[[10, 2.5]]) > 0:
70        print 'Stage > 0: Changing to outflow boundary'
71        domain.set_boundary({'right': Bo})
72       
Note: See TracBrowser for help on using the repository browser.