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