source: anuga_work/production/gold_coast_2007/run_goldcoast.py @ 4294

Last change on this file since 4294 was 4294, checked in by sexton, 18 years ago

slide report updates and gold coast hypothetical

File size: 5.3 KB
Line 
1"""Script for running a hypothetical inundation scenario for Gold Coast,
2QLD, Australia.
3
4Source data such as elevation and boundary data is assumed to be available in
5directories specified by project.py
6The output sww file is stored in project.outputtimedir
7
8The scenario is defined by a triangular mesh created from project.polygon,
9the elevation data and a tsunami wave generated by s submarine mass failure.
10
11Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006
12"""
13
14#-------------------------------------------------------------------------------
15# Import necessary modules
16#-------------------------------------------------------------------------------
17
18# Standard modules
19import os
20import time
21from shutil import copy
22from os.path import dirname, basename
23from os import mkdir, access, F_OK, sep
24import sys
25
26# Related major packages
27from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary, Time_boundary
28from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
29from anuga.geospatial_data.geospatial_data import *
30from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
31
32# Application specific imports
33import project              # Definition of file names and polygons
34
35#-------------------------------------------------------------------------------
36# Copy scripts to time stamped output directory and capture screen
37# output to file
38#-------------------------------------------------------------------------------
39
40# creates copy of code in output dir
41copy_code_files(project.outputtimedir,__file__,dirname(project.__file__)+sep+ project.__name__+'.py' )
42myid = 0
43numprocs = 1
44start_screen_catcher(project.outputtimedir, myid, numprocs)
45
46print 'USER:    ', project.user
47
48#-------------------------------------------------------------------------------
49# Preparation of topographic data
50#
51# Convert ASC 2 DEM 2 PTS using source data and store result in source data
52#-------------------------------------------------------------------------------
53
54# filenames
55gc_dem_name = project.gc_dem_name
56meshname = project.meshname+'.msh'
57
58# creates DEM from asc data
59convert_dem_from_ascii2netcdf(gc_dem_name, use_cache=True, verbose=True)
60
61#creates pts file for onshore DEM
62dem2pts(gc_dem_name, use_cache=True, verbose=True)
63
64G = Geospatial_data(file_name = project.gc_dem_name + '.pts')
65
66G.export_points_file(project.combined_dem_name + '.pts')
67
68
69#----------------------------------------------------------------------------
70# Create the triangular mesh based on overall clipping polygon with a tagged
71# boundary and interior regions defined in project.py along with
72# resolutions (maximal area of per triangle) for each polygon
73#-------------------------------------------------------------------------------
74
75from anuga.pmesh.mesh_interface import create_mesh_from_regions
76remainder_res = 150000.
77int_res = 1000.
78interior_regions = [[project.poly_int, int_res]]
79
80from caching import cache
81_ = cache(create_mesh_from_regions,
82          project.polyAll,
83           {'boundary_tags': {'e0': [0], 'e1': [1], 'e2': [2], 'e3': [3]},
84           'maximum_triangle_area': remainder_res,
85           'filename': meshname,
86           'interior_regions': interior_regions},
87          verbose = True, evaluate=False)
88
89#-------------------------------------------------------------------------------                                 
90# Setup computational domain
91#-------------------------------------------------------------------------------                                 
92domain = Domain(meshname, use_cache = True, verbose = True)
93
94print 'Number of triangles = ', len(domain)
95print 'The extent is ', domain.get_extent()
96print domain.statistics()
97
98domain.set_name(project.basename)
99domain.set_datadir(project.outputtimedir)
100domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
101domain.set_minimum_storable_height(0.01)
102
103#-------------------------------------------------------------------------------                                 
104# Setup initial conditions
105#-------------------------------------------------------------------------------
106
107tide = 0.0
108domain.set_quantity('stage', tide)
109domain.set_quantity('friction', 0.0) 
110domain.set_quantity('elevation', 
111                    filename = project.combined_dem_name + '.pts',
112                    use_cache = True,
113                    verbose = True,
114                    alpha = 0.1
115                    )
116
117#-------------------------------------------------------------------------------                                 
118# Setup boundary conditions
119#-------------------------------------------------------------------------------
120print 'Available boundary tags', domain.get_boundary_tags()
121
122Br = Reflective_boundary(domain)
123Bd = Dirichlet_boundary([tide,0,0])
124Bw = Time_boundary(domain=domain, # Time dependent boundary
125                   f=lambda t: [(60<t<660)*6., 0, 0])
126
127domain.set_boundary( {'e0': Bw,  'e1': Bd, 'e2': Bd, 'e3': Bd} )
128
129
130#-------------------------------------------------------------------------------                                 
131# Evolve system through time
132#-------------------------------------------------------------------------------
133import time
134
135t0 = time.time()
136
137for t in domain.evolve(yieldstep = 10, finaltime = 5000): 
138    domain.write_time()
139    domain.write_boundary_statistics(tags = 'e0')
140   
141print 'That took %.2f seconds' %(time.time()-t0)
142
143print 'finished'
Note: See TracBrowser for help on using the repository browser.