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 subprocess |
---|
10 | import csv |
---|
11 | import os |
---|
12 | import time |
---|
13 | import liststore |
---|
14 | from anuga.utilities import system_tools, log |
---|
15 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
16 | |
---|
17 | |
---|
18 | #------------------------------------------------------------------------------ |
---|
19 | # Setup computational domain |
---|
20 | #------------------------------------------------------------------------------ |
---|
21 | a = [] |
---|
22 | #SpaceUsed = 0.0 |
---|
23 | #number = 0 |
---|
24 | |
---|
25 | home1 = os.getenv('INUNDATIONHOME') |
---|
26 | scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","area"]) |
---|
27 | file1 = 'ex1.csv' |
---|
28 | file_path = os.path.join(scenariodir, file1) |
---|
29 | storel ='storel.txt' |
---|
30 | file_path_storel = os.path.join(scenariodir, storel) |
---|
31 | storea ='storea.txt' |
---|
32 | file_path_storea = os.path.join(scenariodir, storea) |
---|
33 | store ='store.txt' |
---|
34 | file_path_store = os.path.join(scenariodir, store) |
---|
35 | storen ='storen.txt' |
---|
36 | file_path_storen = os.path.join(scenariodir, storen) |
---|
37 | |
---|
38 | log.log_filename = os.path.join(scenariodir, 'log.txt') |
---|
39 | |
---|
40 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
41 | spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s']) |
---|
42 | e = open(file_path_store,'a') |
---|
43 | e.close() |
---|
44 | e = open(file_path_storea,'a') |
---|
45 | e.close() |
---|
46 | e = open(file_path_storel,'a') |
---|
47 | e.close() |
---|
48 | e = open(file_path_storen,'a') |
---|
49 | e.close() |
---|
50 | |
---|
51 | |
---|
52 | def rum(d): |
---|
53 | f = 4 |
---|
54 | for l in range(400,500,100): |
---|
55 | |
---|
56 | g = open(file_path_storel,'r+') |
---|
57 | g.write(str(l)) |
---|
58 | |
---|
59 | h = open(file_path_storea,'r+') |
---|
60 | h.write(str(d)) |
---|
61 | |
---|
62 | z = time.time() |
---|
63 | subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'runcairns.py']) |
---|
64 | #subprocess.call(['python2.5', 'runcairns.py']) |
---|
65 | y = time.time() |
---|
66 | |
---|
67 | f = open(file_path_store,'r+') |
---|
68 | x = float(f.readline()) |
---|
69 | f.close() |
---|
70 | |
---|
71 | f = open(file_path_storen,'r+') |
---|
72 | i = float(f.readline()) |
---|
73 | f.close() |
---|
74 | |
---|
75 | spamWriter.writerow([i,d,(l*l),x ,(y-z)]) |
---|
76 | liststore.store = [0,0,0,0] |
---|
77 | |
---|
78 | for m in range(90,100,10): |
---|
79 | rum(m) |
---|
80 | |
---|
81 | print 'Done' |
---|
82 | |
---|