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 time |
---|
10 | import subprocess |
---|
11 | import csv |
---|
12 | import os |
---|
13 | from anuga.utilities import system_tools, log |
---|
14 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
15 | from anuga.utilities.log_analyser import analyse_log |
---|
16 | #------------------------------------------------------------------------------ |
---|
17 | # Setup computational domain |
---|
18 | #------------------------------------------------------------------------------ |
---|
19 | home = os.getenv('INUNDATIONHOME') |
---|
20 | |
---|
21 | scenariodir = add_directories(home, ["data","mem_time_test", "parameters", |
---|
22 | "friction"]) |
---|
23 | file = 'ex1.csv' |
---|
24 | file_path = os.path.join(scenariodir, file) |
---|
25 | store ='store.txt' |
---|
26 | file_path_store = os.path.join(scenariodir, store) |
---|
27 | |
---|
28 | e = open(file_path_store,'a') |
---|
29 | e.close() |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
35 | spamWriter.writerow(['Friction', 'Time Taken', 'Memory Used']) |
---|
36 | |
---|
37 | |
---|
38 | for n in range(1,10000,100): |
---|
39 | f = open(file_path_store,'wb') |
---|
40 | f.write(str(n)) |
---|
41 | x = time.clock() |
---|
42 | subprocess.call(['python2.5', 'ex1.py']) |
---|
43 | y = time.clock() |
---|
44 | spamWriter.writerow([n ,(y-x)]) |
---|
45 | print 'Done' |
---|
46 | |
---|
47 | analyse_log(scenariodir, 'metalog.csv') |
---|