1 | #------------------------------------------------------------------------------ |
---|
2 | # Import necessary modules |
---|
3 | #------------------------------------------------------------------------------ |
---|
4 | import os |
---|
5 | import time |
---|
6 | import sys |
---|
7 | import anuga |
---|
8 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
9 | from anuga.utilities import log |
---|
10 | |
---|
11 | #set up the variables for the simulation out put and log files |
---|
12 | a = int(sys.argv[1]) |
---|
13 | l = float(sys.argv[2]) |
---|
14 | |
---|
15 | home = os.getenv('INUNDATIONHOME') |
---|
16 | scenariodirV = add_directories(home, ["data","mem_time_test", "triangles", |
---|
17 | "rectanglecross", "triangles-" + str(a) +"-"+ str(l)]) |
---|
18 | log.log_filename = os.path.join(scenariodirV, "anuga.log") |
---|
19 | log._setup = False |
---|
20 | |
---|
21 | log.timingInfo(msg=('matrixsize,'+str(a))) #write the variable to be measured to file |
---|
22 | log.timingInfo(msg=('extent,'+str(l**2))) #write the variable to be measured to file |
---|
23 | log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
24 | |
---|
25 | log.resource_usage_timing(prefix = 'beforesimulation')#get memory usage |
---|
26 | #------------------------------------------------------------------------------ |
---|
27 | # Create the triangular mesh and domain |
---|
28 | #------------------------------------------------------------------------------ |
---|
29 | points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh |
---|
30 | domain = anuga.Domain(points, vertices, boundary) # Create |
---|
31 | domain.set_name('CAIRNS.sww') # Name of sww file |
---|
32 | domain.set_datadir(scenariodirV)# Store sww output here |
---|
33 | log.resource_usage_timing(prefix = 'aftermesh') #get memory usage |
---|
34 | log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
35 | #------------------------------------------------------------------------------ |
---|
36 | # Setup initial conditions |
---|
37 | #------------------------------------------------------------------------------ |
---|
38 | |
---|
39 | #get the number of triangles |
---|
40 | number=len(domain) |
---|
41 | log.timingInfo(msg=('numberoftriangles,'+str(number))) #write the variable to be measured to file |
---|
42 | |
---|
43 | def topography(x,y): |
---|
44 | return 0.0 |
---|
45 | |
---|
46 | tide = 100.0 |
---|
47 | friction = 0.0 |
---|
48 | domain.set_quantity('stage', tide) |
---|
49 | domain.set_quantity('friction', friction) |
---|
50 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
51 | |
---|
52 | log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage |
---|
53 | #------------------------------------------------------------------------------ |
---|
54 | # Setup boundary conditions |
---|
55 | #------------------------------------------------------------------------------ |
---|
56 | Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow |
---|
57 | Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow |
---|
58 | Br = anuga.Reflective_boundary(domain) |
---|
59 | domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) |
---|
60 | |
---|
61 | log.resource_usage_timing(prefix='afterboundary')#get memory usage |
---|
62 | #------------------------------------------------------------------------------ |
---|
63 | # Evolve system through time |
---|
64 | #------------------------------------------------------------------------------ |
---|
65 | for t in domain.evolve(yieldstep=120, finaltime=2000): |
---|
66 | print domain.timestepping_statistics() |
---|
67 | |
---|
68 | log.resource_usage_timing(prefix='aftersimulation')#get memory usage |
---|
69 | log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation |
---|