source: anuga_work/development/dam_test_from_brad_2007/dam_sample.py @ 6409

Last change on this file since 6409 was 5442, checked in by ole, 17 years ago

Retired h-limiter and beta_h as per ticket:194.
All unit tests and validation tests pass.

File size: 3.6 KB
Line 
1"""
2Dam break!
3"""
4
5#------------------------------------------------------------------------------
6# Import necessary modules
7#------------------------------------------------------------------------------
8
9from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
10
11from anuga.shallow_water import Domain
12from anuga.shallow_water import Reflective_boundary
13from anuga.shallow_water import Dirichlet_boundary
14
15from anuga.utilities.polygon import read_polygon, plot_polygons
16from anuga.utilities.polygon import Polygon_function
17
18#------------------------------------------------------------------------------
19# Setup computational domain
20#------------------------------------------------------------------------------
21length = 20.
22width = 10.
23dx = dy = 2           # Resolution: Length of subdivisions on both axes
24
25points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
26                                               len1=length, len2=width)
27
28domain = Domain(points, vertices, boundary)   # Create domain
29domain.set_name('dam_sample')                 # Output name
30#domain.set_store_vertices_uniquely(True)      # Look at the 'real' triangles
31domain.set_minimum_allowed_height(0.01)
32
33#------------------------------------------------------------------------------
34# Setup initial conditions
35#------------------------------------------------------------------------------
36
37# Polygons
38study = [[0,0], [20,0], [20,10], [0,10], [0,0]]
39#dam = [[0,0], [6,0], [6,10], [0,10], [0,0]]
40poly_dam = read_polygon('dam.csv')
41print poly_dam
42#plot_polygons([poly_dam])
43
44
45def dam1(x,y):
46    z = -x/10                 #initialise with slope (this is required to create the vector z?)
47    X = len(x)                  #find the number of vector elements
48    for i in range(X):
49        if 6<= x[i]<=7 or x[i]<1:    #dam wall
50                z[i] = 2
51        if 6<= x[i] <=7 and 4<= y[i] <=6: #remove unwanted wall
52                z[i] = -x[i]/10
53    return z
54
55def water(x,y):
56    z = -x/10                 #initialise with slope (this is required to create the vector z)
57    X = len(x)                #find the number of vector elements
58
59    for i in range(X):
60        if x[i]<=6:    #dam
61            z[i]= 2
62           
63    return z
64
65##manual definition
66#
67#domain.set_quantity('elevation', water)                # Use function for elevation
68#domain.set_quantity('friction', 0.01)                       # Constant friction
69#domain.set_quantity('stage', expression='elevation')        # take elevation
70#domain.set_quantity('elevation', dam1)                # Use function for elevation
71
72
73# Assign values to quantities
74domain.set_quantity('elevation', dam1)                # Use function for elevation
75domain.set_quantity('friction', 0.01)                 # Constant friction
76domain.set_quantity('stage', Polygon_function( [(study, -1),(poly_dam, 2)] )) 
77
78
79#------------------------------------------------------------------------------
80# Setup boundary conditions
81#------------------------------------------------------------------------------
82Bi = Dirichlet_boundary([1.5, 0, 0])         # Inflow
83Bo = Dirichlet_boundary([-20/10, 0, 0])      # Outflow
84Br = Reflective_boundary(domain)             # Solid reflective wall
85
86domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br})
87
88
89#------------------------------------------------------------------------------
90# Evolve system through time
91#------------------------------------------------------------------------------
92for t in domain.evolve(yieldstep = 0.2, finaltime = 20):
93    domain.write_time(track_speeds=False)
94
Note: See TracBrowser for help on using the repository browser.