source: inundation/ga/storm_surge/pyvolution/run_profile.py @ 262

Last change on this file since 262 was 244, checked in by ole, 20 years ago
File size: 1.4 KB
Line 
1"""Example of shallow water wave equation.
2
3This version is for profiling
4
5"""
6
7######################
8# Module imports
9#
10from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
11     Transmissive_boundary, Time_boundary,\
12     Weir_simple as Weir, Constant_height
13
14from mesh_factory import rectangular
15from Numeric import array
16   
17
18######################
19# Domain
20#
21
22N = 16
23
24print 'Creating domain'
25#Create basic mesh
26points, vertices, boundary = rectangular(N, N)
27
28#Create shallow water domain
29domain = Domain(points, vertices, boundary)
30domain.default_order = 2
31#domain.visualise = True
32domain.newstyle = False  #For comparison
33
34
35print 'Field values'
36def slope(x, y):
37    return -x
38   
39domain.set_quantity('elevation', slope)
40domain.set_quantity('friction', 0.3)
41
42
43# Boundary conditions
44#
45Br = Reflective_boundary(domain)
46domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
47
48
49######################
50#Initial condition
51domain.set_quantity('level', Constant_height(slope, 0.3))
52
53domain.check_integrity()
54 
55
56######################
57#Evolution
58
59import time
60t0 = time.time()
61
62s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
63
64
65
66import profile, pstats
67FN = 'profile.dat'
68
69profile.run(s, FN)
70   
71print 'That took %.2f seconds' %(time.time()-t0)
72
73S = pstats.Stats(FN)
74#S.sort_stats('time').print_stats(20)
75s = S.sort_stats('cumulative').print_stats(30)
76
77print s
Note: See TracBrowser for help on using the repository browser.