- 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/rectanglecross/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 9 from anuga.abstract_2d_finite_volumes.util import add_directories 10 from anuga.utilities.log_analyser import analyse_log 14 11 15 from anuga.utilities import system_tools, log 16 from anuga.abstract_2d_finite_volumes.util import add_directories 17 12 #------------------------------------------------------------------------------ 13 # Set up variables for the correct directories to store the output 14 #------------------------------------------------------------------------------ 18 15 home = os.getenv('INUNDATIONHOME') 19 16 scenariodir = add_directories(home, ["data","mem_time_test", "triangles", 20 17 "rectanglecross"]) 21 22 log.log_filename = os.path.join(scenariodir, 'log.txt') 23 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) 24 24 file = 'ex1.csv' 25 25 file_path = os.path.join(scenariodir, file) 26 26 27 #------------------------------------------------------------------------------ 28 # Setup computational domain 29 #------------------------------------------------------------------------------ 30 a = [] 27 #create and set up the output files 31 28 spamWriter = csv.writer(open(file_path, 'wb')) 32 29 spamWriter.writerow(['Number Of Triangles' ,'MxM Rectangular Mesh', '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 main loops assign the matrix size[number of triangles] (m) and the map side length(n) 38 for m in range(1,500,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 the 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 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 60
Note: See TracChangeset
for help on using the changeset viewer.