source: anuga_validation/performance_tests/run_profile.py @ 7256

Last change on this file since 7256 was 7181, checked in by ole, 15 years ago

Removed dead code

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