source: production/gippsland_2005/run_crash.py @ 2353

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

hunting down a bug, the 432000sec crash

File size: 5.1 KB
Line 
1
2#Convention for strings representing files
3# #_file has the extention
4#           #name does not have the extension
5
6import time
7
8from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\
9     dem2pts, asc_csiro2sww
10from pyvolution.pmesh2domain import pmesh_to_domain_instance
11from caching import cache
12from create_mesh import create_mesh
13from pyvolution.shallow_water import Domain, Reflective_boundary,\
14     File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary
15from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA
16
17# Import this last!  It stuffs up the loading of c extensions otherwise.
18import project
19
20#Data preparation
21#Convert ASC 2 DEM 2 PTS using source data and store result in source data
22# just interested in the boundary/ mesh intereaction first off.
23#cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True},
24#      dependencies = [demname + '.asc'],
25#      verbose = True)
26#      #evaluate = True)
27
28cache(dem2pts, project.demname[:-4], {'verbose': True},
29      dependencies = [project.demname]     
30      ,verbose = False
31      )
32
33
34# Convert CSIRO boundary
35# NOTE: This function is dependent on a lot of files, and I haven't listed
36# them, since there is so many and I don't think they will be changing.
37cache(asc_csiro2sww,
38      (project.bath_dir,
39       project.elevation_dir,
40       project.ucur_dir,
41       project.vcur_dir,
42       project.boundaryname),
43       {'verbose': True,
44       'minlat': -38.25,
45       'maxlat': -37.7,
46       'minlon': 147.0,
47       'maxlon': 148.25,
48       'mean_stage': project.tide,
49       'zscale': 1,                 #Enhance storm surge
50       'fail_on_NaN': False}
51      #,evaluate = True                 
52      ,verbose = False
53      )
54
55meshname = project.meshname
56pointname = project.pointname
57mesh_elevname = project.mesh_elevname
58outputname = project.outputname
59
60t0 = time.time()
61#Create the mesh without elevation data
62# 100000 very course - 16,827 triangle mesh
63
64#meshname, triagle_count = cache(create_mesh,(100000000000000),
65#                                {'factor':60000000,
66#                                 'mesh_file':meshname,
67#                                 'triangles_in_name':True}
68#                                ,dependencies = ['create_mesh2.py']
69#                                #,evaluate = True     
70#                                )
71
72meshname, triagle_count = cache(create_mesh,(100000000000),
73                                {'mesh_file':meshname,
74                                 'triangles_in_name':True}
75                                ,dependencies = ['create_mesh.py']
76                                ,evaluate = True     
77                                )
78
79mesh_elevname = mesh_elevname[:-9] + '_' + str(triagle_count) +  \
80                mesh_elevname[-9:]
81outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:]
82
83
84#Add elevation data to the mesh
85#fit_to_mesh_file(mesh_file, point_file, mesh_output_file, DEFAULT_ALPHA,
86#                 verbose=True, expand_search=True, precrop=True)     
87cache(fit_to_mesh_file,(meshname,
88                 pointname,
89                 mesh_elevname,
90                 10),
91      {'verbose': True,
92       'expand_search': True,
93       'precrop': True}
94      ,dependencies = [meshname, pointname]
95      #,evaluate = True     
96      ,verbose = False
97      )
98 
99print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) 
100
101#Setup domain
102domain = cache(pmesh_to_domain_instance, (mesh_elevname, Domain),
103               dependencies = [mesh_elevname]                   
104               ,verbose = False
105               )               
106
107
108domain.set_name(project.basename + '_%d' %triagle_count)
109domain.set_datadir(project.outputdir)
110domain.store = True
111domain.smooth = False
112domain.quantities_to_be_stored = ['stage']
113
114print 'Number of triangles = ', len(domain)
115print 'The extent is ', domain.get_extent()
116
117#Setup Initial Conditions
118domain.set_quantity('friction', 0)
119domain.set_quantity('stage', project.tide)
120
121
122#Setup Boundary Conditions
123print domain.get_boundary_tags()
124
125print "****** run  ****"
126print "project.boundaryname",project.boundaryname
127print "**********"
128
129Bf = File_boundary(project.boundaryname, domain, verbose = True)
130#domain.starttime = 54000  #Obtained from MOST
131domain.starttime = 0 
132
133Br = Reflective_boundary(domain)
134Bt = Transmissive_boundary(domain)
135Bd = Dirichlet_boundary([project.tide,0,0])
136Bw = Time_boundary(domain=domain,
137                   f=lambda t: [(60<t<660)*4, 0, 0])
138
139#domain.set_boundary( {'back': Br,'side': Br, 'ocean': Bw} ) #Time boundary
140
141domain.set_boundary( {'back': Br,'side': Br, 'ocean': Bf} ) #CSIRO storm surge
142
143#domain.set_boundary( {'back': Br,'side': Br, 'ocean': Br} ) #NO storm surge
144
145#Evolve
146t0 = time.time()
147
148for t in domain.evolve(yieldstep = 6000, finaltime = 600000):
149#for t in domain.evolve(yieldstep = 10, finaltime = 30):
150#                       skip_initial_step = True):
151    domain.write_time()
152    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')       
153
154print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.