1 | """ |
---|
2 | This experiment was based heavily on the cairns demo given in the user manual and found in |
---|
3 | the anuga repository. |
---|
4 | |
---|
5 | However, it has been simplified so that it doesnt require all the files the cairns demo does |
---|
6 | """ |
---|
7 | |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | # Import necessary modules |
---|
10 | #------------------------------------------------------------------------------ |
---|
11 | import os |
---|
12 | import time |
---|
13 | import sys |
---|
14 | import anuga |
---|
15 | from anuga_parallel import distribute, myid, numprocs |
---|
16 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
17 | from anuga.utilities import log |
---|
18 | |
---|
19 | #set up variables for the correct I/O directories for data storage |
---|
20 | home = os.getenv('INUNDATIONHOME') |
---|
21 | scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", |
---|
22 | "template", "template-" + str(numprocs) +"-"+ str(myid)]) |
---|
23 | h = 'CAIRNS.msh' |
---|
24 | file_pathh = os.path.join(scenariodirV, h) |
---|
25 | log.log_filename = os.path.join(scenariodirV, "anuga.log") |
---|
26 | log._setup = False |
---|
27 | |
---|
28 | log.timingInfo(msg=('numberofcpus,'+str(numprocs))) #write the variable to be measured to file |
---|
29 | log.timingInfo(msg=('myid,'+str(myid))) #write the variable to be measured to file |
---|
30 | |
---|
31 | log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
32 | |
---|
33 | log.resource_usage_timing(prefix = 'beforesimulation')#get memory statistics here |
---|
34 | #------------------------------------------------------------------------------ |
---|
35 | #Create the domain and mesh for the resource experiment on only one processor |
---|
36 | #------------------------------------------------------------------------------ |
---|
37 | |
---|
38 | if myid == 0: |
---|
39 | domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)], |
---|
40 | boundary_tags={'top': [0], |
---|
41 | 'right': [1], |
---|
42 | 'bottom': [2], |
---|
43 | 'left': [3]}, |
---|
44 | maximum_triangle_area=100.0, |
---|
45 | mesh_filename=file_pathh) |
---|
46 | else: |
---|
47 | domain = None |
---|
48 | |
---|
49 | #parallel |
---|
50 | domain = distribute(domain) |
---|
51 | domain.set_name('CAIRNS') # Name of sww file |
---|
52 | domain.set_datadir(scenariodirV)# Store sww output here |
---|
53 | |
---|
54 | log.resource_usage_timing(prefix = 'aftermesh')#get memory statistics here |
---|
55 | log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
56 | |
---|
57 | #------------------------------------------------------------------------------ |
---|
58 | # Setup initial conditions |
---|
59 | #------------------------------------------------------------------------------ |
---|
60 | |
---|
61 | def topography(x,y): |
---|
62 | return 0.0 |
---|
63 | |
---|
64 | tide = 100.0 |
---|
65 | friction = 0.0 |
---|
66 | domain.set_quantity('stage', tide) |
---|
67 | domain.set_quantity('friction', friction) |
---|
68 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
69 | |
---|
70 | log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here |
---|
71 | |
---|
72 | #------------------------------------------------------------------------------ |
---|
73 | # Setup boundary conditions |
---|
74 | #------------------------------------------------------------------------------ |
---|
75 | |
---|
76 | Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow |
---|
77 | Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow |
---|
78 | Br = anuga.Reflective_boundary(domain) |
---|
79 | domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) |
---|
80 | |
---|
81 | log.resource_usage_timing(prefix='afterboundary') #get memory statistics here |
---|
82 | #------------------------------------------------------------------------------ |
---|
83 | # Evolve system through time |
---|
84 | #------------------------------------------------------------------------------ |
---|
85 | for t in domain.evolve(yieldstep=2000, finaltime=2000): |
---|
86 | print domain.timestepping_statistics() |
---|
87 | |
---|
88 | log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here |
---|
89 | log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation |
---|
90 | |
---|