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 output and the log files |
---|
12 | a = 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 | "fromregions", "triangles-" + str(a) +"-"+ str(l)]) |
---|
18 | h = 'CAIRNS.msh' |
---|
19 | file_pathh = os.path.join(scenariodirV, h) |
---|
20 | log._setup = False |
---|
21 | log.log_filename = os.path.join(scenariodirV, "anuga.log") |
---|
22 | |
---|
23 | log.timingInfo(msg=('trianglearea,'+str(a))) #write the variable to be measured to file |
---|
24 | log.timingInfo(msg=('extent,'+str(l**2))) #write the variable to be measured to file |
---|
25 | |
---|
26 | log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
27 | |
---|
28 | log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage |
---|
29 | #------------------------------------------------------------------------------ |
---|
30 | # Create the triangular mesh and domain |
---|
31 | #------------------------------------------------------------------------------ |
---|
32 | domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)], |
---|
33 | boundary_tags={'top': [0], |
---|
34 | 'right': [1], |
---|
35 | 'bottom': [2], |
---|
36 | 'left': [3]}, |
---|
37 | maximum_triangle_area=a, |
---|
38 | mesh_filename=file_pathh |
---|
39 | ) |
---|
40 | domain.set_name('CAIRNS.sww') # Name of sww file |
---|
41 | domain.set_datadir(scenariodirV)# Store sww output here |
---|
42 | log.resource_usage_timing(prefix = 'aftermesh') #get memory usage |
---|
43 | log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
44 | #------------------------------------------------------------------------------ |
---|
45 | # Setup initial conditions |
---|
46 | #------------------------------------------------------------------------------ |
---|
47 | |
---|
48 | #get the number of triangles |
---|
49 | number=len(domain) |
---|
50 | log.timingInfo(msg=('numberoftriangles,'+str(number))) #write the variable to be measured to file |
---|
51 | |
---|
52 | def topography(x,y): |
---|
53 | return 0.0 |
---|
54 | |
---|
55 | tide = 100.0 |
---|
56 | friction = 0.0 |
---|
57 | domain.set_quantity('stage', tide) |
---|
58 | domain.set_quantity('friction', friction) |
---|
59 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
60 | |
---|
61 | log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage |
---|
62 | |
---|
63 | #------------------------------------------------------------------------------ |
---|
64 | # Setup boundary conditions |
---|
65 | #------------------------------------------------------------------------------ |
---|
66 | Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow |
---|
67 | Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow |
---|
68 | Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary |
---|
69 | Br = anuga.Reflective_boundary(domain) |
---|
70 | domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) |
---|
71 | |
---|
72 | log.resource_usage_timing(prefix='afterboundary')#get memory usage |
---|
73 | #------------------------------------------------------------------------------ |
---|
74 | # Evolve system through time |
---|
75 | #------------------------------------------------------------------------------ |
---|
76 | for t in domain.evolve(yieldstep=120, finaltime=2000): |
---|
77 | print domain.timestepping_statistics() |
---|
78 | |
---|
79 | log.resource_usage_timing(prefix='aftersimulation')#get memory usage |
---|
80 | log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation |
---|