source: anuga_validation/performance_tests/run_profile.py @ 7276

Last change on this file since 7276 was 7276, checked in by ole, 15 years ago

Merged numpy branch back into the trunk.

In ~/sandpit/anuga/anuga_core/source
svn merge -r 6246:HEAD ../../branches/numpy .

In ~/sandpit/anuga/anuga_validation
svn merge -r 6417:HEAD ../branches/numpy_anuga_validation .

In ~/sandpit/anuga/misc
svn merge -r 6809:HEAD ../branches/numpy_misc .

For all merges, I used numpy version where conflicts existed

The suites test_all.py (in source/anuga) and validate_all.py passed using Python2.5 with numpy on my Ubuntu Linux box.

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