source: trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py

Last change on this file was 8427, checked in by davies, 13 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 3.2 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import subprocess
6import csv
7import os
8import time
9from anuga.abstract_2d_finite_volumes.util import add_directories
10from anuga.utilities.log_analyser import analyse_log
11
12#------------------------------------------------------------------------------
13# Set up variables for the correct directories to store the output
14#------------------------------------------------------------------------------
15home = os.getenv('INUNDATIONHOME')
16scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
17                                     "fromregions"])
18meta = 'metalog.csv'
19meta_path = os.path.join(scenariodir, meta)
20final = 'final.csv'
21final_path = os.path.join(scenariodir, final)
22
23#these are the main loops that determine the maximum triangle area (m) and the map side length(n)
24for m in range(20,1000,50):
25    for n in range(1,100000,10000):
26        subprocess.call(['python2.5', 'runcairns.py',str(m),str(n)])#run simulation
27print 'DONE'
28
29#get the important data for the experiments from the anuga experiments
30analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 
31
32#open files to read from and write to
33metalog = csv.reader(open(meta_path,'rb'))
34final = csv.writer(open(final_path,'wb'))
35
36#list stores the index of the values requird
37indexlist = []
38
39#read in the first row
40firstrow = metalog.next()
41
42#get the indices of the values we want, so that the data can be condensed
43indexlist.append(firstrow.index("beforetime"))
44indexlist.append(firstrow.index("aftertime"))
45indexlist.append(firstrow.index("aftermeshtime"))
46indexlist.append(firstrow.index("beforesimulationmemory"))
47indexlist.append(firstrow.index("aftermeshmemory"))
48indexlist.append(firstrow.index("afterinitialconditionsmemory"))
49indexlist.append(firstrow.index("afterboundarymemory"))
50indexlist.append(firstrow.index("aftersimulationmemory"))
51indexlist.append(firstrow.index("trianglearea"))
52indexlist.append(firstrow.index("extent"))
53indexlist.append(firstrow.index("numberoftriangles"))
54
55
56#write the header for the final csv
57final.writerow(["TimeTaken(s)","MeshTime(s)",
58                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
59                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
60                firstrow[(indexlist[7])],firstrow[(indexlist[8])],
61                firstrow[(indexlist[9])],firstrow[(indexlist[10])]])
62
63#write the data for each column in the final csv
64for row in metalog:
65
66    #manipulate the beginning and end time to get the time taken
67    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
68    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
69    mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S')
70    taken = time.mktime(end) - time.mktime(begin)
71    meshtime = time.mktime(mesh) - time.mktime(begin)
72
73    #write to file
74    final.writerow([str(taken),str(meshtime),
75                    row[(indexlist[3])],row[(indexlist[4])],
76                    row[(indexlist[5])],row[(indexlist[6])],
77                    row[(indexlist[7])],row[(indexlist[8])],
78                    row[(indexlist[9])],row[(indexlist[10])]])
Note: See TracBrowser for help on using the repository browser.