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