[2927] | 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 |
---|
| 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 | from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | from create_buildings import create_mesh |
---|
| 18 | #from building_generator import create_mesh |
---|
| 19 | |
---|
| 20 | from pmesh.mesh import importMeshFromFile |
---|
| 21 | |
---|
| 22 | depth = 3.5 # depth of building side to oncoming wave |
---|
| 23 | breadth = 3.5 # breadth of building, width of building to oncoming wave |
---|
| 24 | #from loop_buildings import depth |
---|
| 25 | |
---|
| 26 | meshname = project.meshname |
---|
| 27 | outputname = project.outputname |
---|
| 28 | |
---|
| 29 | t0 = time.time() |
---|
| 30 | |
---|
| 31 | meshname, triagle_count = cache(create_mesh,(1000,depth), |
---|
| 32 | {'mesh_file':meshname, |
---|
| 33 | 'triangles_in_name':True} |
---|
| 34 | ,dependencies = ['create_buildings.py'] |
---|
| 35 | #,evaluate = True |
---|
| 36 | ) |
---|
| 37 | #meshname = 'test.tsh' |
---|
| 38 | #outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:] |
---|
| 39 | |
---|
| 40 | print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | #meshname = importMeshFromFile('build.tsh') |
---|
| 44 | |
---|
| 45 | #Setup domain |
---|
| 46 | domain = cache(pmesh_to_domain_instance, (meshname, Domain), |
---|
| 47 | dependencies = [meshname] |
---|
| 48 | ,verbose = False |
---|
| 49 | ,evaluate = True |
---|
| 50 | |
---|
| 51 | ) |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | domain.set_name(project.basename + '_Very_small_BR=%d_%d_%d' %(5, 15, triagle_count)) |
---|
| 55 | domain.set_datadir(project.outputdir) |
---|
| 56 | domain.store = True |
---|
| 57 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
| 58 | |
---|
| 59 | print 'Number of triangles = ', len(domain) |
---|
| 60 | print 'The extent is ', domain.get_extent() |
---|
| 61 | |
---|
| 62 | #Setup Initial Conditions |
---|
| 63 | domain.set_quantity('friction', 0.01) |
---|
| 64 | domain.set_quantity('stage', 0) |
---|
| 65 | |
---|
| 66 | #Setup Boundary Conditions |
---|
| 67 | print domain.get_boundary_tags() |
---|
| 68 | |
---|
| 69 | domain.starttime = 0 #Obtained from MOST |
---|
| 70 | |
---|
| 71 | Br = Reflective_boundary(domain) |
---|
| 72 | Bt = Transmissive_boundary(domain) |
---|
| 73 | Bdw = Dirichlet_boundary([20,0,0]) |
---|
| 74 | Bdb = Dirichlet_boundary([0,0,0]) |
---|
| 75 | Bw = Time_boundary(domain=domain, |
---|
| 76 | f=lambda t: [(60<t<660)*4, 0, 0]) |
---|
| 77 | |
---|
| 78 | domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) |
---|
| 79 | |
---|
| 80 | #Evolve |
---|
| 81 | t0 = time.time() |
---|
| 82 | |
---|
| 83 | for t in domain.evolve(yieldstep = 10, finaltime = 1000): |
---|
| 84 | domain.write_time() |
---|
| 85 | |
---|
| 86 | print 'That took %.2f seconds' %(time.time()-t0) |
---|