source: trunk/anuga_work/development/gareth/tests/dam_break/dam_break.py @ 8547

Last change on this file since 8547 was 8547, checked in by davies, 13 years ago

Major experimental changes to balanced_dev

File size: 3.8 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#------------------------------------------------------------------------------
10import sys
11import anuga
12from anuga import Domain as Domain
13from math import cos
14from numpy import zeros, float
15from time import localtime, strftime, gmtime
16from balanced_dev import *
17#from anuga_tsunami import *
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
29#anuga.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
44#domain = anuga.Domain(points, vertices, boundary)
45domain = Domain(points, vertices, boundary) 
46
47domain.set_name(output_file)               
48domain.set_datadir(output_dir) 
49
50#------------------------------------------------------------------------------
51# Setup Algorithm
52#------------------------------------------------------------------------------
53domain.set_timestepping_method('rk2')
54domain.set_default_order(2)
55
56print domain.get_timestepping_method()
57
58domain.use_edge_limiter = True
59#domain.use_edge_limiter = False
60domain.tight_slope_limiters = True
61domain.use_centroid_velocities = False
62
63domain.CFL = 1.0
64
65#domain.beta_w      = 0.6
66#domain.beta_uh     = 0.6
67#domain.beta_vh     = 0.6
68
69
70#------------------------------------------------------------------------------
71# Setup initial conditions
72#------------------------------------------------------------------------------
73domain.set_quantity('elevation',0.0)
74domain.set_quantity('friction', 0.0)
75
76h0 = 10000.0
77h1 = 1.0
78
79def height(x,y):
80    z = zeros(len(x), float)
81    for i in range(len(x)):
82        if x[i]<=50000.0:
83            z[i] = h0
84        else:
85            z[i] = h1
86    return z
87domain.set_quantity('stage', height)
88
89#-----------------------------------------------------------------------------
90# Setup boundary conditions
91#------------------------------------------------------------------------------
92from math import sin, pi, exp
93Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
94Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary
95Bd = anuga.Dirichlet_boundary([1,0.,0.]) # Constant boundary values
96
97# Associate boundary tags with boundary objects
98domain.set_boundary({'left': Bt, 'right': Bt, 'top': Br, 'bottom': Br})
99
100
101#===============================================================================
102##from anuga.visualiser import RealtimeVisualiser
103##vis = RealtimeVisualiser(domain)
104##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
105##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
106##vis.start()
107#===============================================================================
108
109
110#------------------------------------------------------------------------------
111# Evolve system through time
112#------------------------------------------------------------------------------
113for t in domain.evolve(yieldstep = 1.0, finaltime = 10*10.):
114    #print domain.timestepping_statistics(track_speeds=True)
115    print domain.timestepping_statistics()
116    #vis.update()
117
118
119#test against know data
120   
121#vis.evolveFinished()
122
Note: See TracBrowser for help on using the repository browser.