source: anuga_core/source/anuga/abstract_2d_finite_volumes/run_profile2.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.6 KB
Line 
1"""Example of shallow water wave equation.
2
3This version is for profiling
4(The original)
5
6
7FIXME: This should really measure something else, such as profiling the set up of domains.
8"""
9
10######################
11# Module imports
12#
13from anuga.shallow_water import Domain, Reflective_boundary,\
14     Dirichlet_boundary,\
15     Transmissive_boundary, Time_boundary
16
17from anuga.shallow_water.shallow_water_domain\
18     import Weir_simple as Weir, Constant_height
19
20from mesh_factory import rectangular
21from Numeric import array
22   
23
24######################
25# Domain
26#
27
28N = 128
29
30print 'Creating domain'
31#Create basic mesh
32points, vertices, boundary = rectangular(N, N)
33
34#Create shallow water domain
35domain = Domain(points, vertices, boundary)
36domain.default_order = 2
37domain.set_quantities_to_be_stored(None)
38#domain.visualise = True
39
40
41print 'Field values'
42def slope(x, y):
43    return -x
44   
45domain.set_quantity('elevation', slope)
46domain.set_quantity('friction', 0.3)
47
48
49# Boundary conditions
50#
51Br = Reflective_boundary(domain)
52domain.set_boundary({'left': Br, 'right': Br, 'bottom': Br, 'top': Br})
53
54
55######################
56#Initial condition
57domain.set_quantity('stage', Constant_height(slope, 0.3))
58
59domain.check_integrity()
60 
61
62######################
63#Evolution
64
65import time
66t0 = time.time()
67
68s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()'
69
70
71
72import profile, pstats
73FN = 'profile.dat'
74
75profile.run(s, FN)
76   
77print 'That took %.2f seconds' %(time.time()-t0)
78
79S = pstats.Stats(FN)
80#S.sort_stats('time').print_stats(20)
81s = S.sort_stats('cumulative').print_stats(30)
82
83print s
Note: See TracBrowser for help on using the repository browser.