1 | |
---|
2 | #Convention for strings representing files |
---|
3 | # #_file has the extention |
---|
4 | # #name does not have the extension |
---|
5 | |
---|
6 | import time |
---|
7 | |
---|
8 | import project_friction |
---|
9 | |
---|
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 | Set_region |
---|
15 | from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA |
---|
16 | |
---|
17 | |
---|
18 | from friction_block import create_mesh |
---|
19 | #from building_generator import create_mesh |
---|
20 | |
---|
21 | from pmesh.mesh import importMeshFromFile |
---|
22 | |
---|
23 | meshname = project_friction.meshname |
---|
24 | outputname = project_friction.outputname |
---|
25 | |
---|
26 | t0 = time.time() |
---|
27 | |
---|
28 | #meshname, triagle_count =create_mesh(100,mesh_file=meshname,triangles_in_name=True) |
---|
29 | |
---|
30 | meshname, triagle_count = cache(create_mesh,(100), |
---|
31 | {'mesh_file':meshname, |
---|
32 | 'triangles_in_name':True} |
---|
33 | ,dependencies = ['friction_block.py'] |
---|
34 | #,evaluate = True |
---|
35 | ) |
---|
36 | #meshname = 'build.tsh' |
---|
37 | #outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:] |
---|
38 | |
---|
39 | print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) |
---|
40 | |
---|
41 | |
---|
42 | #meshname = importMeshFromFile('build.tsh') |
---|
43 | |
---|
44 | #Setup domain |
---|
45 | domain = cache(pmesh_to_domain_instance, (meshname, Domain), |
---|
46 | dependencies = [meshname] |
---|
47 | ,verbose = False |
---|
48 | ) |
---|
49 | |
---|
50 | |
---|
51 | domain.set_name(project_friction.basename + '_%d' %triagle_count) |
---|
52 | domain.set_datadir(project_friction.outputdir) |
---|
53 | domain.store = True |
---|
54 | domain.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] |
---|
55 | |
---|
56 | print 'Number of triangles = ', len(domain) |
---|
57 | print 'The extent is ', domain.get_extent() |
---|
58 | |
---|
59 | #Setup Initial Conditions |
---|
60 | domain.set_quantity('friction', 0.01) |
---|
61 | domain.set_quantity('stage', 0) |
---|
62 | domain.set_region(Set_region('mound', 'friction', 3)) #, location='unique vertices')) |
---|
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 | Bdw = Dirichlet_boundary([36,0,0]) |
---|
71 | Bdb = Dirichlet_boundary([0,0,0]) |
---|
72 | Bw = Time_boundary(domain=domain, |
---|
73 | f=lambda t: [(60<t<660)*4, 0, 0]) |
---|
74 | |
---|
75 | domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) |
---|
76 | |
---|
77 | #Evolve |
---|
78 | t0 = time.time() |
---|
79 | |
---|
80 | for t in domain.evolve(yieldstep = 4, finaltime = 400): |
---|
81 | domain.write_time() |
---|
82 | |
---|
83 | print 'That took %.2f seconds' %(time.time()-t0) |
---|