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 ex1 |
---|
12 | import csv |
---|
13 | import os |
---|
14 | from anuga.utilities import system_tools, log |
---|
15 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
16 | #------------------------------------------------------------------------------ |
---|
17 | # Setup computational domain |
---|
18 | #------------------------------------------------------------------------------ |
---|
19 | a = [] |
---|
20 | home = os.getenv('INUNDATIONHOME') |
---|
21 | |
---|
22 | scenariodir = add_directories(home, ["data","mem_time_test", "parameters", |
---|
23 | "friction"]) |
---|
24 | file = 'ex1.csv' |
---|
25 | file_path = os.path.join(scenariodir, file) |
---|
26 | |
---|
27 | log.log_filename = os.path.join(scenariodir, 'log.txt') |
---|
28 | |
---|
29 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
30 | spamWriter.writerow(['Friction', 'Time Taken', 'Memory Used']) |
---|
31 | |
---|
32 | |
---|
33 | for n in range(1,10000,100): |
---|
34 | system_tools.MemoryUpdate() |
---|
35 | x = time.clock() |
---|
36 | h = ex1.runex(n) |
---|
37 | y = time.clock() |
---|
38 | b = system_tools.MemoryUpdate()[0] |
---|
39 | spamWriter.writerow([n ,(y-x),b]) |
---|
40 | print a |
---|
41 | |
---|