source: trunk/anuga_core/demos/channel3_parallel.py @ 9309

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

small changes plot_utils

File size: 3.2 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#import anuga_parallel
12
13
14#------------------------------------------------------------------------------
15# Setup some initial info
16#------------------------------------------------------------------------------
17def topography(x,y):
18    """Complex topography defined by a function of vectors x and y."""
19
20    z = -x/10
21
22    N = len(x)
23    for i in range(N):
24        # Step
25        if 10 < x[i] < 12:
26            z[i] += 0.4 - 0.05*y[i]
27
28        # Constriction
29        if 27 < x[i] < 29 and y[i] > 3:
30            z[i] += 2
31
32        # Pole
33        if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
34            z[i] += 2
35
36    return z
37
38
39
40#------------------------------------------------------------------------------
41# Setup computational domain on one processor
42#------------------------------------------------------------------------------
43length = 40.
44width = 5.
45dx = dy = .1           # Resolution: Length of subdivisions on both axes
46
47
48if anuga.myid == 0:
49    points, vertices, boundary = anuga.rectangular_cross(int(length/dx),
50                                         int(width/dy), len1=length, len2=width)
51    domain = anuga.Domain(points, vertices, boundary)
52    domain.set_name('channel3')                  # Output name
53    domain.set_flow_algorithm('DE0')
54    print domain.statistics()
55
56
57   
58    domain.set_quantity('elevation', topography)           # elevation is a function
59    domain.set_quantity('friction', 0.01)                  # Constant friction
60    domain.set_quantity('stage', expression='elevation')   # Dry initial condition
61else:
62    domain = None
63
64#------------------------------------------------------------------------------
65# Distribute domain on processor 0 to to other processors
66#------------------------------------------------------------------------------
67#parameters = dict(ghost_layer_width=3)
68domain = anuga.distribute(domain, verbose= True)
69
70
71#------------------------------------------------------------------------------
72# Setup boundary conditions
73#------------------------------------------------------------------------------
74Bi = anuga.Dirichlet_boundary([0.4, 0, 0])          # Inflow
75Br = anuga.Reflective_boundary(domain)              # Solid reflective wall
76Bo = anuga.Dirichlet_boundary([-5, 0, 0])           # Outflow
77
78domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
79
80#------------------------------------------------------------------------------
81# Evolve system through time
82#------------------------------------------------------------------------------
83for t in domain.evolve(yieldstep=0.1, finaltime=16.0):
84    if anuga.myid == 0:
85        print domain.timestepping_statistics()
86
87
88    ## if domain.get_quantity('stage').\
89    ##        get_values(interpolation_points=[[10, 2.5]]) > 0:
90    ##     print 'Stage > 0: Changing to outflow boundary'
91    ##     domain.set_boundary({'right': Bo})
92
93
94domain.sww_merge(verbose=True)
95
96anuga.finalize()
97       
Note: See TracBrowser for help on using the repository browser.