source: trunk/anuga_validation/validation_tests/dam_break/dam_break.py @ 8074

Last change on this file since 8074 was 8074, checked in by steve, 13 years ago

Changed name

File size: 3.6 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# Import necessary modules
9#------------------------------------------------------------------------------
10
11import sys
12import anuga
13
14from math import cos
15from numpy import zeros, float
16from time import localtime, strftime, gmtime
17
18
19
20#-------------------------------------------------------------------------------
21# Copy scripts to time stamped output directory and capture screen
22# output to file
23#-------------------------------------------------------------------------------
24time = strftime('%Y%m%d_%H%M%S',localtime())
25
26output_dir = 'dam_break_'+time
27output_file = 'dam_break'
28
29anuga.copy_code_files(output_dir,__file__)
30#start_screen_catcher(output_dir+'_')
31
32
33#------------------------------------------------------------------------------
34# Setup domain
35#------------------------------------------------------------------------------
36dx = 1000.
37dy = dx
38L = 100000.
39W = 10*dx
40
41# structured mesh
42points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, -W/2))
43
44domain = anuga.Domain(points, vertices, boundary) 
45
46domain.set_name(output_file)               
47domain.set_datadir(output_dir) 
48
49#------------------------------------------------------------------------------
50# Setup Algorithm
51#------------------------------------------------------------------------------
52domain.set_timestepping_method('rk2')
53domain.set_default_order(2)
54
55print domain.get_timestepping_method()
56
57domain.use_edge_limiter = True
58domain.tight_slope_limiters = True
59domain.use_centroid_velocities = False
60
61domain.CFL = 1.0
62
63domain.beta_w      = 0.6
64domain.beta_uh     = 0.6
65domain.beta_vh     = 0.6
66
67
68#------------------------------------------------------------------------------
69# Setup initial conditions
70#------------------------------------------------------------------------------
71domain.set_quantity('elevation',0.0)
72domain.set_quantity('friction', 0.0)
73
74h0 = 10.0
75h1 = 1.0
76
77def height(x,y):
78    z = zeros(len(x), float)
79    for i in range(len(x)):
80        if x[i]<=50000.0:
81            z[i] = h0
82        else:
83            z[i] = h1
84    return z
85
86
87domain.set_quantity('stage', height)
88#-----------------------------------------------------------------------------
89# Setup boundary conditions
90#------------------------------------------------------------------------------
91from math import sin, pi, exp
92Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
93Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary
94Bd = anuga.Dirichlet_boundary([1,0.,0.]) # Constant boundary values
95
96
97# Associate boundary tags with boundary objects
98domain.set_boundary({'left': Bt, 'right': Bt, 'top': Br, 'bottom': Br})
99
100
101#===============================================================================
102from anuga.visualiser import RealtimeVisualiser
103vis = RealtimeVisualiser(domain)
104vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
105vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
106vis.start()
107#===============================================================================
108
109
110#------------------------------------------------------------------------------
111# Evolve system through time
112#------------------------------------------------------------------------------
113
114for t in domain.evolve(yieldstep = 100.0, finaltime = 60*60.):
115    #print domain.timestepping_statistics(track_speeds=True)
116    print domain.timestepping_statistics()
117    vis.update()
118
119
120#test against know data
121   
122vis.evolveFinished()
123
Note: See TracBrowser for help on using the repository browser.