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

Last change on this file since 8325 was 8325, checked in by steve, 12 years ago

Uncommented the vtk visualisation code in dam_break.py

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