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