- Timestamp:
- Jan 31, 2012, 10:54:12 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py
r8303 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules 6 3 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 4 import anuga 9 5 import subprocess 10 import runcairns11 6 import csv 12 7 import os 13 8 import time 14 from anuga.utilities import system_tools, log15 9 from anuga.abstract_2d_finite_volumes.util import add_directories 10 from anuga.utilities.log_analyser import analyse_log 16 11 17 12 #------------------------------------------------------------------------------ 18 # Set up computational domain13 # Set up variables for the correct directories to store the output 19 14 #------------------------------------------------------------------------------ 20 a = []21 22 23 15 home = os.getenv('INUNDATIONHOME') 24 16 scenariodir = add_directories(home, ["data","mem_time_test", "triangles", 25 17 "fromregions"]) 26 log.log_filename = os.path.join(scenariodir, 'log.txt') 27 18 storea ='storea.txt' 19 file_path_storea = os.path.join(scenariodir, storea) 20 store ='store.txt' 21 file_path_store = os.path.join(scenariodir, store) 22 storen ='storen.txt' 23 file_path_storen = os.path.join(scenariodir, storen) 28 24 file = 'ex1.csv' 29 25 file_path = os.path.join(scenariodir, file) 30 26 27 #create and set up the files 31 28 spamWriter = csv.writer(open(file_path, 'wb')) 32 29 spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s']) 30 e = open(file_path_storea,'a') 31 e.close() 32 e = open(file_path_store,'a') 33 e.close() 34 e = open(file_path_storen,'a') 35 e.close() 33 36 37 #these are the main loops that determine the maximum triangle area (m) and the map side length(n) 38 for m in range(1,100,10): 39 for n in range(1,1000,100): 34 40 41 #write these values to file 42 g = open(file_path_store,'r+') 43 g.write(str(m)) 44 h = open(file_path_storen,'r+') 45 h.write(str(n)) 35 46 36 def runlist(r): 37 for n in range(1,2000,100): 38 system_tools.MemoryUpdate() 39 z = time.time() 40 h = runcairns.runex(n,r) 41 y = time.time() 42 x = system_tools.MemoryUpdate()[0] 43 spamWriter.writerow([h,r,(n*n),x ,(y-z)]) 47 z = time.time() #time it 48 subprocess.call(['python2.5', 'runcairns.py'])#run simulation 49 y = time.time() #time it 44 50 45 for m in range(1,100,10): 46 runlist(m) 51 #read the number of triangles from this text file 52 f = open(file_path_storea,'r+') 53 h = float(f.readline()) 54 f.close() 47 55 56 spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it 48 57 print 'DONE' 49 58 59 analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
Note: See TracChangeset
for help on using the changeset viewer.