1 | |
---|
2 | from os import sep, environ, getenv, getcwd |
---|
3 | import os |
---|
4 | |
---|
5 | #import project |
---|
6 | #from Numeric import allclose |
---|
7 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
8 | from anuga.shallow_water import Domain |
---|
9 | from anuga.shallow_water import File_boundary |
---|
10 | from time import localtime, strftime, gmtime |
---|
11 | |
---|
12 | home = getenv('INUNDATIONHOME') #Sandpit's parent dir |
---|
13 | #user = get_user_name() |
---|
14 | data = 'data' |
---|
15 | state = 'western_australia' |
---|
16 | scenario_name = 'dampier' |
---|
17 | scenario = 'test_dampier' |
---|
18 | an = 'anuga' |
---|
19 | bo = 'boundaries' |
---|
20 | topo = 'topographies' |
---|
21 | out = 'outputs' |
---|
22 | urs = 'urs' |
---|
23 | gridded = '1_10000' |
---|
24 | #best_boundary_sww_file = 'o_test_8500_12000.sww' |
---|
25 | best_boundary_sww_file = 'o_8500_12000_no_zone.sww' |
---|
26 | |
---|
27 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
28 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
29 | run_time = time+'_run' |
---|
30 | print 'gtime: ', gtime |
---|
31 | print 'time: ', time |
---|
32 | |
---|
33 | |
---|
34 | mesh_filename = 'small.tsh' # this will be local |
---|
35 | best_boundary_sww = os.path.join(home,data,state,scenario,an,bo,best_boundary_sww_file) |
---|
36 | #J:\inundation\data\western_australia\dampier_tsunami_scenario_2006\anuga\topographies |
---|
37 | |
---|
38 | elevation_file = 'dampier_combined_elevation_smallest.txt' |
---|
39 | smallest_elevation= os.path.join(home,data,state,scenario,an,topo,elevation_file) |
---|
40 | |
---|
41 | output= os.path.join(home,data,state,scenario,an,out,run_time) |
---|
42 | |
---|
43 | #pro_instance = project.Project([data,state,scenario_name], |
---|
44 | # outputdir_name=outputdir_name) |
---|
45 | |
---|
46 | #poly_all = [[250000,7660000],[280000,7660000], [280000,7630000]] |
---|
47 | poly_all = [[469000,7760000],[470000,7758000],[468000,7758000]] |
---|
48 | |
---|
49 | print 'create mesh' |
---|
50 | create_mesh_from_regions(poly_all, |
---|
51 | boundary_tags={'back': [0,1,2]}, |
---|
52 | maximum_triangle_area=100000000000000000000, |
---|
53 | filename=mesh_filename, |
---|
54 | use_cache=False, |
---|
55 | verbose=True) |
---|
56 | domain = Domain( mesh_filename, verbose=True) |
---|
57 | print domain.statistics() |
---|
58 | |
---|
59 | domain.set_quantity('stage', 2.4) |
---|
60 | domain.set_quantity('friction', 0.01) |
---|
61 | domain.set_name(scenario_name) |
---|
62 | domain.set_datadir(output) |
---|
63 | |
---|
64 | print 'set elevation',smallest_elevation |
---|
65 | |
---|
66 | domain.set_quantity('elevation', |
---|
67 | filename = smallest_elevation, |
---|
68 | use_cache = True, |
---|
69 | verbose = True, |
---|
70 | alpha = 0.1) |
---|
71 | |
---|
72 | |
---|
73 | print 'best_boundary_sww',best_boundary_sww |
---|
74 | |
---|
75 | print 'get file boundary' |
---|
76 | Bf = File_boundary(best_boundary_sww, |
---|
77 | domain, time_thinning=24, use_cache=False, verbose=True) |
---|
78 | |
---|
79 | domain.set_boundary({'back': Bf}) |
---|
80 | |
---|
81 | |
---|
82 | #t0 = time.time() |
---|
83 | |
---|
84 | print 'evolve' |
---|
85 | for t in domain.evolve(yieldstep = 120, finaltime = 3400): |
---|
86 | domain.write_time() |
---|
87 | domain.write_boundary_statistics(tags = 'back') |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|