source: development/momentum_sink/run_friction.py @ 2417

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

Creation of looped friction to auto generate multiple friction blocks. CCS.py created as modified copy of PCS.py ( plots cross section at various times of buildings and friction blocks)

File size: 2.7 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
8fric=10
9
10# fwojhrt
11import time
12
13import project_friction
14
15from pyvolution.pmesh2domain import pmesh_to_domain_instance
16from caching import cache
17from pyvolution.shallow_water import Domain, Reflective_boundary,\
18     File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary,\
19     Set_region
20from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA
21
22
23from friction_block import create_mesh
24#from building_generator import create_mesh
25
26from pmesh.mesh import importMeshFromFile
27
28meshname = project_friction.meshname
29outputname = project_friction.outputname
30
31t0 = time.time()
32
33#meshname, triagle_count =create_mesh(100,mesh_file=meshname,triangles_in_name=True)
34
35meshname, triagle_count = cache(create_mesh,(100),
36                                {'mesh_file':meshname,
37                                 'triangles_in_name':True}
38                                ,dependencies = ['friction_block.py']
39                                #,evaluate = True     
40                                )
41#meshname = 'build.tsh'
42#outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:]
43
44print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) 
45
46
47#meshname = importMeshFromFile('build.tsh')
48
49#Setup domain
50domain = cache(pmesh_to_domain_instance, (meshname, Domain),
51               dependencies = [meshname]                   
52               ,verbose = False
53               )               
54
55
56domain.set_name(project_friction.basename + '_%d' %triagle_count)
57domain.set_datadir(project_friction.outputdir)
58domain.store = True
59domain.quantities_to_be_stored = ['stage','xmomentum','ymomentum']
60
61print 'Number of triangles = ', len(domain)
62print 'The extent is ', domain.get_extent()
63
64#Setup Initial Conditions
65domain.set_quantity('friction', 0.01)
66domain.set_quantity('stage', 0)
67domain.set_region(Set_region('mound', 'friction', fric)) #, location='unique vertices'))
68#Setup Boundary Conditions
69print domain.get_boundary_tags()
70
71domain.starttime = 0  #Obtained from MOST
72
73Br = Reflective_boundary(domain)
74Bt = Transmissive_boundary(domain)
75Bdw = Dirichlet_boundary([20,0,0])
76Bdb = Dirichlet_boundary([0,0,0])
77Bw = Time_boundary(domain=domain,
78                   f=lambda t: [(60<t<660)*4, 0, 0])
79
80domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) 
81
82#Evolve
83t0 = time.time()
84
85for t in domain.evolve(yieldstep = 10, finaltime = 500):
86    domain.write_time()     
87
88print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.