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

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

There is an error in test_mem_time_equation. Should be fixed by pittj
Removed print statement from test_polygon.py

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