source: anuga_validation/performance_tests/run_profile.py @ 7248

Last change on this file since 7248 was 7181, checked in by ole, 16 years ago

Removed dead code

File size: 1.4 KB
RevLine 
[239]1"""Example of shallow water wave equation.
2
[2380]3This version is for profiling of timestepping
[239]4"""
5
6######################
[1629]7# Module imports
[3567]8from anuga.shallow_water import Domain, Reflective_boundary
[239]9from mesh_factory import rectangular
10
[1629]11
[239]12######################
13# Domain
14
[2380]15#N = 16   #Should take less than 0.1 s
16#N = 64  #Should take less than 3s
17N = 128  #Should take less than 20s
[239]18
[2380]19
[239]20print 'Creating domain'
21#Create basic mesh
22points, vertices, boundary = rectangular(N, N)
23
24#Create shallow water domain
25domain = Domain(points, vertices, boundary)
[2380]26domain.set_default_order(2)       
27domain.set_quantities_to_be_stored(None)
[239]28
[244]29
[2380]30print 'Setting initial conditions'
31
[239]32def slope(x, y):
33    return -x
[1629]34
[239]35domain.set_quantity('elevation', slope)
[2380]36domain.set_quantity('friction', 0.03)
37domain.set_quantity('stage', expression = 'elevation + 0.5')
[239]38
39
[2380]40
41print 'Setting boundary conditions'
[239]42Br = Reflective_boundary(domain)
43domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
44
45
[5297]46#print 'Checking integrity'
47#domain.check_integrity()
[239]48
[1629]49
[239]50######################
51#Evolution
52
53import time
54t0 = time.time()
55
56s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
57
[5847]58#for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()
[239]59
[5847]60
[239]61import profile, pstats
62FN = 'profile.dat'
63
64profile.run(s, FN)
[1629]65
[239]66print 'That took %.2f seconds' %(time.time()-t0)
67
68S = pstats.Stats(FN)
[5320]69s = S.sort_stats('cumulative').print_stats(20)
[239]70
71print s
[5320]72
73
Note: See TracBrowser for help on using the repository browser.