source: anuga_validation/performance_tests/run_profile.py @ 7846

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

Fixed failing validations

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