[2379] | 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 rotate_buildings import create_mesh |
---|
| 18 | #from building_generator import create_mesh |
---|
| 19 | |
---|
| 20 | from pmesh.mesh import importMeshFromFile |
---|
| 21 | |
---|
| 22 | meshname = project.meshname |
---|
| 23 | outputname = project.outputname |
---|
| 24 | |
---|
| 25 | t0 = time.time() |
---|
| 26 | |
---|
| 27 | meshname, triagle_count = cache(create_mesh,(100), |
---|
| 28 | {'mesh_file':meshname, |
---|
| 29 | 'triangles_in_name':True} |
---|
| 30 | ,dependencies = ['rotate_buildings.py'] |
---|
| 31 | #,evaluate = True |
---|
| 32 | ) |
---|
| 33 | #meshname = 'build.tsh' |
---|
| 34 | #outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:] |
---|
| 35 | |
---|
| 36 | print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | #meshname = importMeshFromFile('build.tsh') |
---|
| 40 | |
---|
| 41 | #Setup domain |
---|
| 42 | domain = cache(pmesh_to_domain_instance, (meshname, Domain), |
---|
| 43 | dependencies = [meshname] |
---|
| 44 | ,verbose = False |
---|
| 45 | ) |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | domain.set_name(project.basename + '_%d' %triagle_count) |
---|
| 49 | domain.set_datadir(project.outputdir) |
---|
| 50 | domain.store = True |
---|
| 51 | domain.quantities_to_be_stored = ['stage'] |
---|
| 52 | |
---|
| 53 | print 'Number of triangles = ', len(domain) |
---|
| 54 | print 'The extent is ', domain.get_extent() |
---|
| 55 | |
---|
| 56 | #Setup Initial Conditions |
---|
| 57 | domain.set_quantity('friction', 0.01) |
---|
| 58 | domain.set_quantity('stage', 0) |
---|
| 59 | |
---|
| 60 | #Setup Boundary Conditions |
---|
| 61 | print domain.get_boundary_tags() |
---|
| 62 | |
---|
| 63 | domain.starttime = 0 #Obtained from MOST |
---|
| 64 | |
---|
| 65 | Br = Reflective_boundary(domain) |
---|
| 66 | Bt = Transmissive_boundary(domain) |
---|
| 67 | Bd = Dirichlet_boundary([10,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': Bd, 'back': Bt, 'exterior':Bd} ) |
---|
| 72 | |
---|
| 73 | #Evolve |
---|
| 74 | t0 = time.time() |
---|
| 75 | |
---|
[2395] | 76 | for t in domain.evolve(yieldstep = 1, finaltime = 60): |
---|
[2379] | 77 | domain.write_time() |
---|
| 78 | |
---|
| 79 | print 'That took %.2f seconds' %(time.time()-t0) |
---|