1 | #------------------------------------------------------------------------------ |
---|
2 | # Import necessary modules |
---|
3 | #------------------------------------------------------------------------------ |
---|
4 | import anuga |
---|
5 | import time |
---|
6 | import os |
---|
7 | import sys |
---|
8 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
9 | from anuga.utilities import log |
---|
10 | |
---|
11 | #set up variables to store the results and the log files of each experiment |
---|
12 | f = sys.argv[1] |
---|
13 | g = float(f)/100.0 |
---|
14 | home = os.getenv('INUNDATIONHOME') |
---|
15 | scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", |
---|
16 | "timelength", "timelength-" + str(f)]) |
---|
17 | log.log_filename = os.path.join(scenariodirV, "anuga.log") |
---|
18 | log._setup = False |
---|
19 | |
---|
20 | log.timingInfo(msg=('timelength,'+str(f))) #write the variable to be measured to file |
---|
21 | log.timingInfo(msg=('timestep,'+str(g))) #write the variable to be measured to file |
---|
22 | log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
23 | log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage here |
---|
24 | |
---|
25 | #------------------------------------------------------------------------------ |
---|
26 | # Create the domain and the mesh of the run |
---|
27 | #------------------------------------------------------------------------------ |
---|
28 | points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh |
---|
29 | domain = anuga.Domain(points, vertices, boundary) # Create domain |
---|
30 | domain.set_name('channel1') # Output name |
---|
31 | domain.set_datadir(scenariodirV) |
---|
32 | |
---|
33 | log.resource_usage_timing(prefix = 'aftermesh') #get memory usage here |
---|
34 | log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
35 | #------------------------------------------------------------------------------ |
---|
36 | # Setup initial conditions |
---|
37 | #------------------------------------------------------------------------------ |
---|
38 | def topography(x, y): |
---|
39 | return 0 # linear bed slope |
---|
40 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
41 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
42 | domain.set_quantity('stage', 10) |
---|
43 | |
---|
44 | log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here |
---|
45 | |
---|
46 | #------------------------------------------------------------------------------ |
---|
47 | # Setup boundary conditions |
---|
48 | #------------------------------------------------------------------------------ |
---|
49 | Br = anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
50 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
51 | |
---|
52 | log.resource_usage_timing(prefix='afterboundary')#get memory usage here |
---|
53 | |
---|
54 | #------------------------------------------------------------------------------ |
---|
55 | # Evolve system through time |
---|
56 | #------------------------------------------------------------------------------ |
---|
57 | for t in domain.evolve(yieldstep=g, finaltime=f): |
---|
58 | print domain.timestepping_statistics() |
---|
59 | |
---|
60 | |
---|
61 | log.resource_usage_timing(prefix='aftersimulation') #get memory usage here |
---|
62 | log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation |
---|