source: development/momentum_sink/run_friction.py @ 2395

Last change on this file since 2395 was 2395, checked in by nicholas, 19 years ago

Updated compare_sww.py. Increased distance of rear boundary and changed to dirichlet

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