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

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

Refactored limit2007 to tight_slope_limiters (using eclipse)

File size: 3.7 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.beta_h = 0.0
32domain.tight_slope_limiters = 1
33domain.set_minimum_allowed_height(0.01)
34
35#------------------------------------------------------------------------------
36# Setup initial conditions
37#------------------------------------------------------------------------------
38
39# Polygons
40study = [[0,0], [20,0], [20,10], [0,10], [0,0]]
41#dam = [[0,0], [6,0], [6,10], [0,10], [0,0]]
42poly_dam = read_polygon('dam.csv')
43print poly_dam
44#plot_polygons([poly_dam])
45
46
47def dam1(x,y):
48    z = -x/10                 #initialise with slope (this is required to create the vector z?)
49    X = len(x)                  #find the number of vector elements
50    for i in range(X):
51        if 6<= x[i]<=7 or x[i]<1:    #dam wall
52                z[i] = 2
53        if 6<= x[i] <=7 and 4<= y[i] <=6: #remove unwanted wall
54                z[i] = -x[i]/10
55    return z
56
57def water(x,y):
58    z = -x/10                 #initialise with slope (this is required to create the vector z)
59    X = len(x)                #find the number of vector elements
60
61    for i in range(X):
62        if x[i]<=6:    #dam
63            z[i]= 2
64           
65    return z
66
67##manual definition
68#
69#domain.set_quantity('elevation', water)                # Use function for elevation
70#domain.set_quantity('friction', 0.01)                       # Constant friction
71#domain.set_quantity('stage', expression='elevation')        # take elevation
72#domain.set_quantity('elevation', dam1)                # Use function for elevation
73
74
75# Assign values to quantities
76domain.set_quantity('elevation', dam1)                # Use function for elevation
77domain.set_quantity('friction', 0.01)                 # Constant friction
78domain.set_quantity('stage', Polygon_function( [(study, -1),(poly_dam, 2)] )) 
79
80
81#------------------------------------------------------------------------------
82# Setup boundary conditions
83#------------------------------------------------------------------------------
84Bi = Dirichlet_boundary([1.5, 0, 0])         # Inflow
85Bo = Dirichlet_boundary([-20/10, 0, 0])      # Outflow
86Br = Reflective_boundary(domain)             # Solid reflective wall
87
88domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br})
89
90
91#------------------------------------------------------------------------------
92# Evolve system through time
93#------------------------------------------------------------------------------
94for t in domain.evolve(yieldstep = 0.2, finaltime = 20):
95    domain.write_time(track_speeds=False)
96
Note: See TracBrowser for help on using the repository browser.