source: development/dam_2006/run_dam.py @ 3171

Last change on this file since 3171 was 3145, checked in by duncan, 19 years ago

minor streamlining

File size: 3.7 KB
Line 
1"""Script for running a tsunami inundation scenario for Onslow, WA, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.outputtimedir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated submarine landslide.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006
11"""
12
13
14#-------------------------------------------------------------------------------# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
18import time
19import sys
20from shutil import copy
21from os import mkdir, access, F_OK
22
23# Related major packages
24from pyvolution.shallow_water import Domain, Reflective_boundary, \
25                            Dirichlet_boundary, Time_boundary, File_boundary
26from pyvolution.util import Screen_Catcher
27from pyvolution.region import Set_region
28
29# Application specific imports
30import project                 # Definition of file names and polygons
31import create_mesh
32
33
34#-------------------------------------------------------------------------------                                 
35# Setup archiving of simulations
36#-------------------------------------------------------------------------------   
37
38copy (project.codedirname, project.outputtimedir + 'project.py')
39copy (project.codedir + 'run_dam.py', project.outputtimedir + 'run_dam.py')
40copy (project.codedir + 'create_mesh.py', project.outputtimedir + 'create_mesh.py')
41print'output dir', project.outputtimedir
42
43#normal screen output is stored in
44screen_output_name = project.outputtimedir + "screen_output.txt"
45screen_error_name = project.outputtimedir + "screen_error.txt"
46
47#-------------------------------------------------------------------------------                                 
48# Create the triangular mesh
49#-------------------------------------------------------------------------------
50
51create_mesh.generate() # this creates the mesh
52
53#-------------------------------------------------------------------------------                                 
54# Setup computational domain
55#-------------------------------------------------------------------------------                                 
56domain = Domain(project.mesh_filename, use_cache = False, verbose = True)
57   
58
59print 'Number of triangles = ', len(domain)
60print 'The extent is ', domain.get_extent()
61print domain.statistics()
62
63domain.set_name(project.basename)
64domain.set_datadir(project.outputtimedir)
65domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
66
67#-------------------------------------------------------------------------------                                 
68# Setup initial conditions
69#-------------------------------------------------------------------------------
70
71tide = 0.0
72
73def elevation_tilt(x, y):
74    return -x*0.15
75       
76domain.set_quantity('stage', elevation_tilt)
77domain.set_quantity('friction', 0.03) 
78domain.set_quantity('elevation',elevation_tilt)
79
80print 'Available boundary tags', domain.get_boundary_tags()
81
82domain.set_region(Set_region('dam','stage',0.4,location = 'unique vertices'))
83
84Br = Reflective_boundary(domain)
85Bd = Dirichlet_boundary([tide,0,0])
86
87#domain.set_boundary( {'wall': Br, 'wave': Bw} )
88domain.set_boundary( {'wall': Br, 'wave': Br} )
89
90#-------------------------------------------------------------------------------                                 
91# Evolve system through time
92#-------------------------------------------------------------------------------
93import time
94t0 = time.time()
95
96for t in domain.evolve(yieldstep = 0.1, finaltime = 5):
97    domain.write_time()
98   
99print 'That took %.2f seconds' %(time.time()-t0)
100
101print 'finished'
Note: See TracBrowser for help on using the repository browser.