source: development/dam_2006/run_dam.py @ 3543

Last change on this file since 3543 was 3543, checked in by duncan, 18 years ago

moving swollen

File size: 4.7 KB
Line 
1"""Script for running a dam break simulation of UQ's dam break tank.
2
3
4Ole Nielsen and Duncan Gray, GA - 2006
5"""
6
7
8#----------------------------------------------------------------------------
9# Import necessary modules
10#----------------------------------------------------------------------------
11
12# Standard modules
13import time
14import sys
15from shutil import copy
16from os import path
17
18# Related major packages
19from anuga.pyvolution.shallow_water import Domain, Reflective_boundary, \
20                            Dirichlet_boundary, Time_boundary, File_boundary
21from anuga.pyvolution.util import Screen_Catcher
22from anuga.pyvolution.region import Set_region
23from anuga.fit_interpolate.interpolate import interpolate_sww2csv
24import create_mesh
25
26# Application specific imports
27import project                 # Definition of file names and polygons
28
29
30def main():
31    #-------------------------------------------------------------------------
32    # Setup archiving of simulations
33    #-------------------------------------------------------------------------
34
35    copy (project.codedirname, project.outputtimedir + 'project.py')
36    copy (project.codedir + 'run_dam.py', project.outputtimedir + 'run_dam.py')
37    copy (project.codedir + 'create_mesh.py',
38          project.outputtimedir + 'create_mesh.py')
39    print'output dir', project.outputtimedir
40
41    #FIXME this isn't working
42    #normal screen output is stored in
43    screen_output_name = project.outputtimedir + "screen_output.txt"
44    screen_error_name = project.outputtimedir + "screen_error.txt"
45
46    #-------------------------------------------------------------------------
47    # Create the triangular mesh
48    #-------------------------------------------------------------------------
49
50    gate_position = 0.85
51    create_mesh.generate(project.mesh_filename,
52                         gate_position,
53                         #is_course=True) # this creates the mesh
54                         is_course=False) # this creates the mesh
55
56    head,tail = path.split(project.mesh_filename)
57    copy (project.mesh_filename,
58          project.outputtimedir + tail )
59    #-------------------------------------------------------------------------
60    # Setup computational domain
61    #-------------------------------------------------------------------------
62    domain = Domain(project.mesh_filename, use_cache = False, verbose = True)
63   
64
65    print 'Number of triangles = ', len(domain)
66    print 'The extent is ', domain.get_extent()
67    print domain.statistics()
68
69   
70    domain.set_name(project.basename)
71    domain.set_datadir(project.outputtimedir)
72    domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
73    domain.set_minimum_sww_depth(0.01)
74    domain.set_store_vertices_uniquely(True)  # for writting to sww
75
76    #-------------------------------------------------------------------------
77    # Setup initial conditions
78    #-------------------------------------------------------------------------
79
80    slope = 0.05
81
82    def elevation_tilt(x, y):
83        return x*slope
84       
85    domain.set_quantity('stage', elevation_tilt)
86    domain.set_quantity('friction', 0.03) 
87    domain.set_quantity('elevation',elevation_tilt)
88
89    print 'Available boundary tags', domain.get_boundary_tags()
90    domain.set_region('dam','stage',0.2,
91                                 location = 'unique vertices') 
92    #domain.set_region(Set_region('dam','stage',0.2,
93    #                             location = 'unique vertices'))
94
95    Br = Reflective_boundary(domain)
96    Bd = Dirichlet_boundary([0,0,0])  # to drain the water out.
97    domain.set_boundary( {'wall': Br, 'edge': Bd} )
98
99    #-------------------------------------------------------------------------
100    # Evolve system through time
101    #-------------------------------------------------------------------------
102    t0 = time.time()
103
104    for t in domain.evolve(yieldstep = 0.1, finaltime = 25):
105        domain.write_time()
106   
107        print 'That took %.2f seconds' %(time.time()-t0)
108        print 'finished'
109
110    points = [[gate_position - 0.65,0.2],
111              [gate_position - 0.55,0.2],
112              [gate_position - 0.45,0.2],
113              [gate_position - 0.35,0.2],
114              [gate_position - 0.25,0.2],
115              [0.55,0.2]
116              ]
117
118    #-------------------------------------------------------------------------
119    # Calculate gauge info
120    #-------------------------------------------------------------------------
121    interpolate_sww2csv(project.outputtimedir + project.basename +".sww",
122                        points,
123                        project.depth_filename,
124                        project.velocity_x_filename,
125                        project.velocity_y_filename)
126
127#-------------------------------------------------------------
128if __name__ == "__main__":
129    main()
130   
Note: See TracBrowser for help on using the repository browser.