[3112] | 1 | """ File used for looping 'friction block.py' script to create many |
---|
| 2 | friction scenarios with variations in Manning's n """ |
---|
[2927] | 3 | |
---|
| 4 | #Convention for strings representing files |
---|
| 5 | # #_file has the extention |
---|
| 6 | # #name does not have the extension |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | import time |
---|
| 10 | import string |
---|
| 11 | import project_friction |
---|
| 12 | import Numeric |
---|
| 13 | from pyvolution.pmesh2domain import pmesh_to_domain_instance |
---|
| 14 | from caching import cache |
---|
| 15 | from pyvolution.shallow_water import Domain, Reflective_boundary,\ |
---|
| 16 | File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary |
---|
| 17 | from region import Set_region |
---|
| 18 | from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA |
---|
| 19 | from friction_block import create_mesh |
---|
| 20 | from pmesh.mesh import importMeshFromFile |
---|
| 21 | |
---|
[3112] | 22 | # generation of friction value list |
---|
[2927] | 23 | Friction_large = list(Numeric.arange(1,120,1)) |
---|
| 24 | Friction = list(Numeric.arange(0.025,1,0.025)) |
---|
| 25 | Friction_log = list([200, 500, 1000, 2000, 5000, 10000]) |
---|
| 26 | Friction.extend(Friction_large) |
---|
| 27 | Friction.extend(Friction_log) |
---|
| 28 | print Friction |
---|
| 29 | |
---|
| 30 | raw_input('check friction array >>') |
---|
| 31 | |
---|
| 32 | for fric in Friction: |
---|
| 33 | meshname = project_friction.meshname |
---|
| 34 | outputname = project_friction.outputname |
---|
| 35 | print " " |
---|
| 36 | print "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_" |
---|
| 37 | print fric, "Manning friction value" |
---|
| 38 | print "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-" |
---|
| 39 | t0 = time.time() |
---|
| 40 | #meshname, triagle_count =create_mesh(100,mesh_file=meshname,triangles_in_name=True) |
---|
| 41 | meshname, triagle_count = cache(create_mesh,(100), |
---|
| 42 | {'mesh_file':meshname, |
---|
| 43 | 'triangles_in_name':True} |
---|
| 44 | ,dependencies = ['friction_block.py'] |
---|
| 45 | #,evaluate = True |
---|
| 46 | ) |
---|
| 47 | #meshname = 'build.tsh' |
---|
| 48 | #outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:] |
---|
| 49 | print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) |
---|
| 50 | #meshname = importMeshFromFile('build.tsh') |
---|
| 51 | #Setup domain |
---|
| 52 | domain = cache(pmesh_to_domain_instance, (meshname, Domain), |
---|
| 53 | dependencies = [meshname] |
---|
| 54 | ,verbose = False |
---|
| 55 | ) |
---|
| 56 | |
---|
| 57 | #fr=str(fric).strip('.') |
---|
| 58 | domain.set_name(project_friction.basename + '%s_%d' %(str(fric).strip('.'), triagle_count)) |
---|
| 59 | domain.set_datadir(project_friction.outputdir) |
---|
| 60 | domain.store = True |
---|
| 61 | domain.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] |
---|
| 62 | |
---|
| 63 | print 'Number of triangles = ', len(domain) |
---|
| 64 | print 'The extent is ', domain.get_extent() |
---|
| 65 | |
---|
| 66 | #Setup Initial Conditions |
---|
| 67 | domain.set_quantity('friction', 0.01) |
---|
| 68 | domain.set_quantity('stage', 0) |
---|
| 69 | domain.set_region(Set_region('mound', 'friction', fric)) #, location='unique vertices')) |
---|
| 70 | #Setup Boundary Conditions |
---|
| 71 | print domain.get_boundary_tags() |
---|
| 72 | |
---|
| 73 | domain.starttime = 0 #Obtained from MOST |
---|
| 74 | |
---|
| 75 | Br = Reflective_boundary(domain) |
---|
| 76 | Bt = Transmissive_boundary(domain) |
---|
| 77 | Bdw = Dirichlet_boundary([10,0,0]) |
---|
| 78 | Bdb = Dirichlet_boundary([0,0,0]) |
---|
| 79 | Bw = Time_boundary(domain=domain, |
---|
| 80 | f=lambda t: [(60<t<660)*4, 0, 0]) |
---|
| 81 | |
---|
| 82 | domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) |
---|
| 83 | |
---|
| 84 | #Evolve |
---|
| 85 | t0 = time.time() |
---|
| 86 | |
---|
| 87 | for t in domain.evolve(yieldstep = 10, finaltime = 1000): |
---|
| 88 | domain.write_time() |
---|
| 89 | |
---|
| 90 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
| 91 | |
---|