source: anuga_core/source/anuga/abstract_2d_finite_volumes/run_profile.py @ 3567

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

More heavy handed restructuring towards the agreed formats.

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
8from anuga.shallow_water import Domain, Reflective_boundary
9from mesh_factory import rectangular
10from Numeric import array
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
47print 'Checking integrity'
48domain.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
60import profile, pstats
61FN = 'profile.dat'
62
63profile.run(s, FN)
64
65print 'That took %.2f seconds' %(time.time()-t0)
66
67S = pstats.Stats(FN)
68#S.sort_stats('time').print_stats(20)
69s = S.sort_stats('cumulative').print_stats(30)
70
71print s
Note: See TracBrowser for help on using the repository browser.