source: development/momentum_sink/scripts/loop_friction.py @ 2927

Last change on this file since 2927 was 2927, checked in by nicholas, 18 years ago

final update of all relavent data

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