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 ex1 |
---|
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 | |
---|
18 | |
---|
19 | #------------------------------------------------------------------------------ |
---|
20 | # Setup computational domain |
---|
21 | #------------------------------------------------------------------------------ |
---|
22 | a = [] |
---|
23 | |
---|
24 | home = os.getenv('INUNDATIONHOME') |
---|
25 | scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", |
---|
26 | "stage"]) |
---|
27 | |
---|
28 | log.log_filename = os.path.join(scenariodir, 'log.txt') |
---|
29 | file = 'ex1.csv' |
---|
30 | file_path = os.path.join(scenariodir, file) |
---|
31 | |
---|
32 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
33 | spamWriter.writerow(['Stage','Extent','Time','Space']) |
---|
34 | |
---|
35 | |
---|
36 | def onevar(b): |
---|
37 | for n in range(1,100,10): |
---|
38 | system_tools.MemoryUpdate() |
---|
39 | z = time.time() |
---|
40 | ex1.runex(b,n) |
---|
41 | y = time.time() |
---|
42 | a = system_tools.MemoryUpdate()[0] |
---|
43 | spamWriter.writerow([n ,((b**2)/2),(y-z),a]) |
---|
44 | print a |
---|
45 | |
---|
46 | for m in range(100,1000,100): |
---|
47 | onevar(m) |
---|
48 | |
---|