1 | """ File used for looping create_buildings script to create many |
---|
2 | building scenarios with variations in building width """ |
---|
3 | |
---|
4 | |
---|
5 | #Convention for strings representing files |
---|
6 | # #_file has the extention |
---|
7 | # #name does not have the extension |
---|
8 | |
---|
9 | import time |
---|
10 | from pyvolution.pmesh2domain import pmesh_to_domain_instance |
---|
11 | from caching import cache |
---|
12 | from pyvolution.shallow_water import Domain, Reflective_boundary,\ |
---|
13 | File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary |
---|
14 | from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA |
---|
15 | import project |
---|
16 | from create_buildings import create_mesh |
---|
17 | from pmesh.mesh import importMeshFromFile |
---|
18 | import Numeric |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | #from building_generator import create_mesh |
---|
23 | |
---|
24 | |
---|
25 | # creates buildign scenarios from widths A to B in steps of n >> |
---|
26 | # >> list(Numeric.arange(A,B,n)) |
---|
27 | DR = list(Numeric.arange(3,7,1)) |
---|
28 | #DR = [4,5] #[3,5,7,9,11,13,15,17,19,21,23] |
---|
29 | for depth in DR: |
---|
30 | |
---|
31 | meshname = project.meshname |
---|
32 | outputname = project.outputname |
---|
33 | t0 = time.time() |
---|
34 | meshname, triagle_count = cache(create_mesh,(1000,depth), |
---|
35 | {'mesh_file':meshname, |
---|
36 | 'triangles_in_name':True} |
---|
37 | ,dependencies = ['create_buildings.py'] |
---|
38 | ,evaluate = True |
---|
39 | ) |
---|
40 | |
---|
41 | print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) |
---|
42 | |
---|
43 | #Setup domain |
---|
44 | domain = cache(pmesh_to_domain_instance, (meshname, Domain), |
---|
45 | dependencies = [meshname] |
---|
46 | ,verbose = False |
---|
47 | ) |
---|
48 | |
---|
49 | # Building scenario name with width and traingle count added. |
---|
50 | domain.set_name(project.basename + '_Rot(45)_5_D_%s_%d' %(str(depth), triagle_count)) |
---|
51 | domain.set_datadir(project.outputdir) |
---|
52 | domain.store = True |
---|
53 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
54 | |
---|
55 | print 'Number of triangles = ', len(domain) |
---|
56 | print 'The extent is ', domain.get_extent() |
---|
57 | print 'current building depth = ', depth |
---|
58 | |
---|
59 | #Setup Initial Conditions |
---|
60 | domain.set_quantity('friction', 0.01) |
---|
61 | domain.set_quantity('stage', 0) |
---|
62 | |
---|
63 | #Setup Boundary Conditions |
---|
64 | print domain.get_boundary_tags() |
---|
65 | |
---|
66 | domain.starttime = 0 #Obtained from MOST |
---|
67 | |
---|
68 | Br = Reflective_boundary(domain) |
---|
69 | Bt = Transmissive_boundary(domain) |
---|
70 | # <<<<<<<<< CHANGE WAVE DEPTH HERE >>>>>>>>>>>> |
---|
71 | Bdw = Dirichlet_boundary([5,0,0]) # inundating wave height |
---|
72 | Bdb = Dirichlet_boundary([0,0,0]) # rear boundary, keep at zero. |
---|
73 | Bw = Time_boundary(domain=domain, |
---|
74 | f=lambda t: [(60<t<660)*4, 0, 0]) |
---|
75 | |
---|
76 | domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) |
---|
77 | |
---|
78 | #Evolve |
---|
79 | t0 = time.time() |
---|
80 | |
---|
81 | for t in domain.evolve(yieldstep = 10, finaltime = 1000): |
---|
82 | domain.write_time() |
---|
83 | |
---|
84 | print 'That took %.2f seconds' %(time.time()-t0) |
---|