source: inundation/pyvolution/run_profile2.py @ 2598

Last change on this file since 2598 was 2380, checked in by ole, 18 years ago

Revisited profiling, cleaned up and added setter for spatial order

File size: 1.5 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#
13from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
14     Transmissive_boundary, Time_boundary,\
15     Weir_simple as Weir, Constant_height
16
17from mesh_factory import rectangular
18from Numeric import array
19   
20
21######################
22# Domain
23#
24
25N = 128
26
27print 'Creating domain'
28#Create basic mesh
29points, vertices, boundary = rectangular(N, N)
30
31#Create shallow water domain
32domain = Domain(points, vertices, boundary)
33domain.default_order = 2
34domain.set_quantities_to_be_stored(None)
35#domain.visualise = True
36
37
38print 'Field values'
39def slope(x, y):
40    return -x
41   
42domain.set_quantity('elevation', slope)
43domain.set_quantity('friction', 0.3)
44
45
46# Boundary conditions
47#
48Br = Reflective_boundary(domain)
49domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
50
51
52######################
53#Initial condition
54domain.set_quantity('stage', Constant_height(slope, 0.3))
55
56domain.check_integrity()
57 
58
59######################
60#Evolution
61
62import time
63t0 = time.time()
64
65s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
66
67
68
69import profile, pstats
70FN = 'profile.dat'
71
72profile.run(s, FN)
73   
74print 'That took %.2f seconds' %(time.time()-t0)
75
76S = pstats.Stats(FN)
77#S.sort_stats('time').print_stats(20)
78s = S.sort_stats('cumulative').print_stats(30)
79
80print s
Note: See TracBrowser for help on using the repository browser.