source: trunk/anuga_validation/performance_tests/run_profile.py @ 8051

Last change on this file since 8051 was 7877, checked in by James Hudson, 15 years ago

Moved all development files into trunk.

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
8import anuga
9
10######################
11# Domain
12
13#N = 16   #Should take less than 0.1 s
14#N = 64  #Should take less than 3s
15N = 128  #Should take less than 20s
16
17
18print 'Creating domain'
19#Create basic mesh
20points, vertices, boundary = anuga.rectangular(N, N)
21
22#Create shallow water domain
23domain = anuga.Domain(points, vertices, boundary)
24domain.set_default_order(2)       
25domain.set_quantities_to_be_stored(None)
26
27
28print 'Setting initial conditions'
29
30def slope(x, y):
31    return -x
32
33domain.set_quantity('elevation', slope)
34domain.set_quantity('friction', 0.03)
35domain.set_quantity('stage', expression = 'elevation + 0.5')
36
37
38
39print 'Setting boundary conditions'
40Br = anuga.Reflective_boundary(domain)
41domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
42
43
44#print 'Checking integrity'
45#domain.check_integrity()
46
47
48######################
49#Evolution
50
51import time
52t0 = time.time()
53
54s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
55
56#for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()
57
58
59import profile, pstats
60FN = 'profile.dat'
61
62profile.run(s, FN)
63
64print 'That took %.2f seconds' %(time.time()-t0)
65
66S = pstats.Stats(FN)
67s = S.sort_stats('cumulative').print_stats(20)
68
69print s
70
71
Note: See TracBrowser for help on using the repository browser.