source: development/momentum_sink/run_buildings.py @ 2891

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

CCS.py still produces sudden jumps in friction values, 2nd normal test or implementation of it needs to be revised.

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