source: anuga_validation/performance_tests/run_profile2.py @ 7846

Last change on this file since 7846 was 7846, checked in by hudson, 14 years ago

Fixed failing validations

File size: 1.3 KB
Line 
1"""Example of shallow water wave equation.
2
3This version is for profiling
4(The original)
5
6
7FIXME: This should really measure something else, such as profiling the set up of domains.
8"""
9
10######################
11# Module imports
12#
13import anuga
14from numpy import array
15   
16
17######################
18# Domain
19#
20
21N = 128
22
23print 'Creating domain'
24#Create basic mesh
25points, vertices, boundary = anuga.rectangular(N, N)
26
27#Create shallow water domain
28domain = anuga.Domain(points, vertices, boundary)
29domain.default_order = 2
30domain.set_quantities_to_be_stored(None)
31#domain.visualise = True
32
33
34print 'Field values'
35def slope(x, y):
36    return -x
37   
38domain.set_quantity('elevation', slope)
39domain.set_quantity('friction', 0.3)
40
41
42# Boundary conditions
43#
44Br = anuga.Reflective_boundary(domain)
45domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
46
47
48######################
49#Initial condition
50domain.set_quantity('stage', expression='elevation + 0.3')
51
52domain.check_integrity()
53 
54
55######################
56#Evolution
57
58import time
59t0 = time.time()
60
61s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
62
63
64
65import profile, pstats
66FN = 'profile.dat'
67
68profile.run(s, FN)
69   
70print 'That took %.2f seconds' %(time.time()-t0)
71
72S = pstats.Stats(FN)
73#S.sort_stats('time').print_stats(20)
74s = S.sort_stats('cumulative').print_stats(30)
75
76print s
Note: See TracBrowser for help on using the repository browser.