source: production/gippsland_2005/run_small_gippsland.py @ 2058

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

creating a mesh and points file.

File size: 3.9 KB
Line 
1"""
2Source data such as elevation and boundary data is assumed to be available in
3directories specified by project.py
4The output sww file is stored in project.outputdir
5
6The scenario is defined by a triangular mesh created from project.polygon,
7the elevation data and boundary data obtained from a tsunami simulation done with MOST.
8
9Duncan Gray, Ole Neilsen, GA - 2005
10"""
11
12
13import os
14import time
15
16
17from pyvolution.shallow_water import Domain, Reflective_boundary, \
18     File_boundary,\
19     Dirichlet_boundary, Time_boundary, Transmissive_boundary
20from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\
21     dem2pts, asc_csiro2sww
22#from pyvolution.pmesh2domain import pmesh_to_domain_instance
23from pyvolution.pmesh2domain import pmesh_instance_to_domain_instance
24from caching import cache
25import project
26from create_mesh import create_mesh
27
28#Data preparation
29#Convert ASC 2 DEM 2 PTS using source data and store result in source data
30demname = project.demname
31demname = project.datadir + 'lakes_100' 
32# just interested in the boundary/ mesh intereaction first off.
33#cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True},
34#      dependencies = [demname + '.asc'],
35#      verbose = True)
36#      #evaluate = True)
37
38cache(dem2pts, demname, {'verbose': True},
39      dependencies = [demname + '.dem'],     
40      verbose = True)
41
42
43# Convert CSIRO boundary
44# NOTE: This function is dependent on a lot of files, and I haven't listed
45# them, since there is so many and I don't think they will be changing.
46cache(asc_csiro2sww,
47      (project.bath_dir,
48       project.elevation_dir,
49       project.ucur_dir,
50       project.vcur_dir,
51       project.boundaryname + '.sww'),
52       {'verbose': True,
53       'minlat': -38.25,
54       'maxlat': -37.7,
55       'minlon': 147.0,
56       'maxlon': 148.25,
57       'mean_stage': project.tide,
58       'zscale': 1,                 #Enhance tsunami
59       'fail_on_NaN': False},
60       #evaluate = True,
61      verbose = True)
62
63
64#Create the mesh ..
65
66#cache this, with dependancy on create_mesh.py
67mesh, triagle_count = create_mesh(10000000)
68
69
70#meshname = project.meshname + '_%d.msh' %resolution
71#meshname = project.meshdir + 'lakes_small_100.msh'
72
73
74#Setup domain
75
76domain = cache(pmesh_instance_to_domain_instance, (mesh, Domain),
77               #dependencies = [meshname],                     
78               verbose = True)               
79
80
81domain.set_name(project.basename) # + '_%d' %resolution)
82domain.set_datadir(project.outputdir)
83domain.store = True
84#domain.smooth = False
85
86
87#domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
88domain.quantities_to_be_stored = ['stage']
89       
90print 'Number of triangles = ', len(domain)
91print 'The extent is ', domain.get_extent()
92
93
94
95#Setup Initial Conditions
96domain.set_quantity('friction', 0)
97domain.set_quantity('stage', project.tide)
98domain.set_quantity('elevation',
99                    filename = demname + '.pts',
100                    use_cache = True,
101                    verbose = True)
102
103
104
105#Setup Boundary Conditions
106print domain.get_boundary_tags()
107
108Bf = File_boundary(project.boundary_basename + '.sww', domain, verbose = True)
109#domain.starttime = 3000  #Obtained from MOST
110domain.starttime = 0  #Obtained from MOST
111
112Br = Reflective_boundary(domain)
113Bt = Transmissive_boundary(domain)
114Bd = Dirichlet_boundary([tide,0,0])
115Bw = Time_boundary(domain=domain,
116                   f=lambda t: [(60<t<660)*4, 0, 0])
117
118
119domain.set_boundary( {'back': Br,'side': Bd, 'ocean': Bf} ) #MOST tsunami
120
121#domain.set_boundary( {'back': Bd,'side': Bd, 'ocean': Bd} )  #Nothing
122
123
124#Evolve
125import time
126t0 = time.time()
127
128for t in domain.evolve(yieldstep = 60, finaltime = 40000):
129#                       skip_initial_step = True):
130    domain.write_time()
131    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')       
132
133print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.