1 | """Simple water flow example using ANUGA |
---|
2 | Water flowing down a channel |
---|
3 | """ |
---|
4 | #------------------------------------------------------------------------------ |
---|
5 | # Import necessary modules |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | # Import standard shallow water domain and standard boundaries. |
---|
8 | import anuga |
---|
9 | import random |
---|
10 | import subprocess |
---|
11 | import runcairns |
---|
12 | import csv |
---|
13 | import os |
---|
14 | import time |
---|
15 | from anuga.utilities import system_tools, log |
---|
16 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
17 | import logAnalyser |
---|
18 | #------------------------------------------------------------------------------ |
---|
19 | # Setup computational domain |
---|
20 | #------------------------------------------------------------------------------ |
---|
21 | a = [] |
---|
22 | m = 20 |
---|
23 | |
---|
24 | home = os.getenv('INUNDATIONHOME') |
---|
25 | |
---|
26 | |
---|
27 | scenariodir = add_directories(home, ["data","mem_time_test", "triangles", |
---|
28 | "serial"]) |
---|
29 | file = 'ex1.csv' |
---|
30 | |
---|
31 | #log.log_filename = os.path.join(scenariodir, 'anuga.log') |
---|
32 | |
---|
33 | file_path = os.path.join(scenariodir, file) |
---|
34 | #print "file_path",file_path |
---|
35 | |
---|
36 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
37 | spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s']) |
---|
38 | outputresource = os.path.join(scenariodir,'test.csv') |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | def runlist(r): |
---|
43 | n = 1 #20 |
---|
44 | while (n > 0): |
---|
45 | c = 2 #random.random() * 2000 + 1 |
---|
46 | z = time.time() |
---|
47 | h = runcairns.runex(c,r) |
---|
48 | y = time.time() |
---|
49 | n = n -1 |
---|
50 | #subprocess.call(['python','timingScript.py',scenariodir,outputresource]) |
---|
51 | logAnalyser.AnalyseLog() |
---|
52 | spamWriter.writerow([h,r,(c*c),'x' ,(y-z)]) |
---|
53 | |
---|
54 | while (m > 0): |
---|
55 | m = m -1 |
---|
56 | d = 101 #random.random() * 100 +1 |
---|
57 | |
---|
58 | runlist(d) |
---|
59 | |
---|
60 | print 'DONE' |
---|
61 | |
---|