Changeset 8326 for trunk/anuga_work/development/mem_time_tests
- Timestamp:
- Jan 31, 2012, 10:54:12 AM (13 years ago)
- Location:
- trunk/anuga_work/development/mem_time_tests
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/NCIparallel/area/main.py
r8324 r8326 22 22 # Setup computational domain 23 23 #------------------------------------------------------------------------------ 24 a = []25 24 #SpaceUsed = 0.0 26 25 #number = 0 27 26 28 27 home1 = os.getenv('INUNDATIONHOME') 29 scenariodir = add_directories(home1, ["data","mem_time_test", "triangles"," area"])28 scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","logarea"]) 30 29 file1 = 'ex1.csv' 31 30 file_path = os.path.join(scenariodir, file1) … … 39 38 file_path_storen = os.path.join(scenariodir, storen) 40 39 41 log.log_filename = os.path.join(scenariodir, 'log.txt42 40 43 41 spamWriter = csv.writer(open(file_path, 'wb')) … … 53 51 54 52 55 def rum(d): 56 f = 4 57 for l in range(400,500,100): 53 for m in range(1,2,1): 54 for l in range(700,800,100): 58 55 59 56 g = open(file_path_storel,'r+') … … 61 58 62 59 h = open(file_path_storea,'r+') 63 h.write(str( d))60 h.write(str(m)) 64 61 65 62 z = time.time() 66 subprocess.call(['mpirun','-np','8','-x','PYTHONPATH','-x','INUNDATIONHOME','python','runcairns.py'])67 #subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado','-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'ru $68 #subprocess.call(['python2.5', 'runcairns.py'])63 #subprocess.call(['mpirun','-np','8','-x','PYTHONPATH','-x','INUNDATIONHOME','python','runcairns.py']) 64 #subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado','-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'runcairns.py']) 65 subprocess.call(['python2.5', 'runcairns.py']) 69 66 y = time.time() 70 67 … … 77 74 f.close() 78 75 79 spamWriter.writerow([ i,d,(l*l),x ,(y-z)])76 spamWriter.writerow(['i,d,(l*l),x ,(y-z)']) 80 77 liststore.store = [0,0,0,0] 81 78 82 for m in range(90,100,10):83 rum(m)84 79 85 80 print 'Done' -
trunk/anuga_work/development/mem_time_tests/NCIparallel/area/runcairns.py
r8324 r8326 30 30 home2 = os.getenv('INUNDATIONHOME') 31 31 32 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", " area"])32 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "logarea"]) 33 33 34 34 h = 'CAIRNS.msh' … … 52 52 53 53 scenariodirV = add_directories(home2, ["data","mem_time_test", "triangles", 54 "area", "triangles-" + str(area) +"-"+ str(length)])54 "logarea", "triangles-" + str(area) +"-"+ str(length)]) 55 55 56 56 h = 'CAIRNS.msh' … … 60 60 log._setup = False 61 61 62 system_tools.MemoryUpdate()62 log.resource_usage_timing(prefix = 'BeforeSimulation') 63 63 #------------------------------------------------------------------------------ 64 64 # Create the triangular mesh and domain based on … … 82 82 else: 83 83 domain = None 84 84 85 log.resource_usage_timing(prefix = 'AfterMesh') 85 86 domain = distribute(domain) 86 87 … … 97 98 def topography(x,y): 98 99 return 0.0 99 100 log.resource_usage_timing(prefix='beforeinitialconditions') 100 101 tide = 100.0 101 102 friction = 0.0 … … 103 104 domain.set_quantity('friction', friction) 104 105 domain.set_quantity('elevation',topography,alpha=0.1) 105 106 log.resource_usage_timing(prefix='afterinitialconditions') 106 107 107 108 … … 120 121 'top': Br}) 121 122 122 123 log.resource_usage_timing(prefix='afterboundary') 123 124 #------------------------------------------------------------------------------ 124 125 # Evolve system through time … … 126 127 127 128 # Save every two mins leading up to wave approaching land 128 for t in domain.evolve(yieldstep=500, finaltime=2000):129 print domain.timestepping_statistics()129 #for t in domain.evolve(yieldstep=500, finaltime=2000): 130 # print domain.timestepping_statistics() 130 131 131 132 132 liststore.store[myid] = system_tools.MemoryUpdate()[0]133 a = sum(liststore.store)133 #liststore.store[myid] = system_tools.MemoryUpdate()[0] 134 #a = sum(liststore.store) 134 135 136 a = 1 135 137 v = open(file_path_store, 'r+') 136 138 v.write(str(a)) -
trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py
r8320 r8326 5 5 # Import necessary modules 6 6 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 7 import anuga 9 import random10 8 import subprocess 11 9 import csv 12 10 import os 13 11 import time 14 import liststore15 from anuga.utilities import system_tools, log16 12 from anuga.abstract_2d_finite_volumes.util import add_directories 13 from anuga.utilities.log_analyser import analyse_log 17 14 18 19 #------------------------------------------------------------------------------ 20 # Setup computational domain 21 #------------------------------------------------------------------------------ 22 a = [] 15 #-------------------------------------------------------------------------------------- 16 # Set up variables for the correct directories to store the output 17 #-------------------------------------------------------------------------------------- 23 18 host = os.getenv('HOST') 24 home 1= os.getenv('INUNDATIONHOME')25 scenariodir = add_directories(home 1, ["data","mem_time_test", "parallel","cairns"])19 home = os.getenv('INUNDATIONHOME') 20 scenariodir = add_directories(home, ["data","mem_time_test", "parallel","cairns"]) 26 21 file1 = 'ex1.csv' 27 22 file_path = os.path.join(scenariodir, file1) 28 store ='store.txt'29 file_path_store = os.path.join(scenariodir, store)30 31 log.log_filename = os.path.join(scenariodir, 'log.txt')32 23 33 24 spamWriter = csv.writer(open(file_path, 'wb')) 34 25 spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s']) 35 e = open(file_path_store,'a')36 e.close()37 26 27 28 # main loop that runs macpus - 1 times 38 29 maxcpus = 18 39 30 40 31 for n in range(1,maxcpus,1): 41 z = time.time() 42 y = time.time() 32 z = time.time() # time it 43 33 34 #the necessary ways to run this script in parallel on the different hosts we use 44 35 if (host == 'cyclone.agso.gov.au'): 45 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])36 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 46 37 if (host == 'tornado.agso.gov.au'): 47 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])38 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 48 39 if (host == 'vayu1'): 49 40 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) … … 53 44 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 54 45 55 liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] 56 f = open(file_path_store,'r+') 57 x = float(f.readline()) 58 f.close() 59 spamWriter.writerow([n,x ,(y-z)]) 60 print a 46 y = time.time()# time it 47 spamWriter.writerow([n,'x' ,(y-z)]) # write recorded results 48 print 'DONE' 61 49 50 analyse_log(scenariodir, 'metalog.csv') # interrogate log files for the memory usage information -
trunk/anuga_work/development/mem_time_tests/hardware/cairns/project.py
r8311 r8326 1 1 """ Common filenames and locations for topographic data, meshes and outputs. 2 2 This file defines the parameters of the scenario you wish to run. 3 4 Parameters differ from example to make the code run faster, and so the data is stored and found in the correct places 3 5 """ 4 6 -
trunk/anuga_work/development/mem_time_tests/hardware/cairns/runcairns.py
r8311 r8326 10 10 11 11 Geoscience Australia, 2004-present 12 13 This has remained unchanged aside from the parallelism added, the resource statistics 14 and the output directories, its also been scaled down so it runs faster 12 15 """ 13 16 … … 19 22 import time 20 23 import sys 24 import anuga 25 from anuga_parallel import distribute, myid, numprocs 26 from anuga.abstract_2d_finite_volumes.util import add_directories 27 from anuga.utilities import log 21 28 22 # Related major packages23 import anuga24 import liststore25 29 26 30 # Application specific imports 27 31 import project # Definition of file names and polygons 28 32 29 from anuga_parallel import distribute, myid, numprocs, finalize, barrier 30 from anuga.abstract_2d_finite_volumes.util import add_directories 31 from anuga.utilities import system_tools, log 33 34 # set up variables for the correct output directories 35 home = os.getenv('INUNDATIONHOME') 36 scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "cairns"]) 37 h = 'CAIRNS.msh' 38 file_pathh = os.path.join(scenariodir, h) 39 store ='store.txt' 40 file_path_store = os.path.join(scenariodir, store) 41 scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", 42 "cairns", "parrallel-" + str(numprocs) +"-"+str(myid)]) 43 log.log_filename = os.path.join(scenariodirV, "anuga.log") 44 log._setup = False 32 45 33 46 34 home2 = os.getenv('INUNDATIONHOME') 35 36 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "parallel", "cairns"]) 37 38 h = 'CAIRNS.msh' 39 file_pathh = os.path.join(scenariodir2, h) 40 store ='store.txt' 41 file_path_store = os.path.join(scenariodir2, store) 42 43 44 system_tools.MemoryUpdate() 45 47 log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics at this point 46 48 #------------------------------------------------------------------------------ 47 49 # Preparation of topographic data … … 49 51 #------------------------------------------------------------------------------ 50 52 # Create DEM from asc data 51 anuga.asc2dem(os.path.join(scenariodir 2, 'cairns.asc'), use_cache=True, verbose=True)53 anuga.asc2dem(os.path.join(scenariodir, 'cairns.asc'), use_cache=True, verbose=True) 52 54 53 55 # Create pts file for onshore DEM 54 anuga.dem2pts(os.path.join(scenariodir 2,'cairns.dem'), use_cache=True, verbose=True)56 anuga.dem2pts(os.path.join(scenariodir,'cairns.dem'), use_cache=True, verbose=True) 55 57 56 58 #------------------------------------------------------------------------------ … … 58 60 # overall clipping polygon with a tagged 59 61 # boundary and interior regions as defined in project.py 62 # (in serial, so the set up only runs once) 60 63 #------------------------------------------------------------------------------ 61 64 if myid == 0: … … 77 80 else: 78 81 domain = None 82 83 log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics at this point 79 84 85 #parallel 80 86 domain = distribute(domain) 81 87 … … 84 90 #------------------------------------------------------------------------------ 85 91 domain.set_name('cairns_' + project.scenario) # Name of sww file 86 domain.set_datadir(scenariodir 2) # Store sww output here92 domain.set_datadir(scenariodirV) # Store sww output here 87 93 domain.set_minimum_storable_height(0.01) # Store only depth > 1cm 88 94 … … 95 101 domain.set_quantity('friction', 0.0) 96 102 domain.set_quantity('elevation', 97 filename=os.path.join(scenariodir 2, 'cairns.pts'),103 filename=os.path.join(scenariodir, 'cairns.pts'), 98 104 use_cache=True, 99 105 verbose=True, 100 106 alpha=0.1) 107 log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics at this point 101 108 102 109 #------------------------------------------------------------------------------ … … 138 145 'onshore': Bd, 139 146 'top': Bd}) 140 147 log.resource_usage_timing(prefix='afterboundary') #get memory statistics at this point 141 148 #------------------------------------------------------------------------------ 142 149 # Evolve system through time … … 175 182 print domain.boundary_statistics(tags='ocean_east') 176 183 184 177 185 print 'That took %.2f seconds' %(time.time()-t0) 178 186 179 liststore.spacelist[myid] = system_tools.MemoryUpdate()[0] 180 a = sum(liststore.spacelist) 181 182 f = open(file_path_store, 'r+') 183 f.write(str(a)) 184 187 log.resource_usage_timing(prefix='aftersimulation') #get memory statistics at this point -
trunk/anuga_work/development/mem_time_tests/hardware/template/main.py
r8320 r8326 5 5 # Import necessary modules 6 6 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 7 import anuga 9 8 import random 10 9 import subprocess 11 import run_parallel12 10 import csv 13 11 import os 14 12 import time 15 import liststore16 from anuga.utilities import system_tools, log17 13 from anuga.abstract_2d_finite_volumes.util import add_directories 14 from anuga.utilities.log_analyser import analyse_log 18 15 19 20 #------------------------------------------------------------------------------ 21 # Setup computational domain 22 #------------------------------------------------------------------------------ 23 a = [] 16 #------------------------------------------------------------------------------- 17 # Set up variables for the correct directories to store the output 18 #------------------------------------------------------------------------------- 24 19 host = os.getenv('HOST') 25 20 home = os.getenv('INUNDATIONHOME') … … 27 22 file1 = 'ex1.csv' 28 23 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 24 spamWriter = csv.writer(open(file_path, 'wb')) 41 25 spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s','Total Space']) 42 e = open(file_path_store,'a')43 e.close()44 26 45 27 28 #main loop that runs maxcpus - 1 times 29 maxcpus = 40 46 30 47 for n in range(1,40,1): 48 z = time.time() 31 for n in range(1,maxcpus,1): 32 z = time.time()# time it 33 34 #the different ways each HOST requires the parallel script to be run 49 35 if (host == 'cyclone.agso.gov.au'): 50 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])36 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 51 37 if (host == 'tornado.agso.gov.au'): 52 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])38 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 53 39 if (host == 'vayu1'): 54 40 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) … … 57 43 if (host == 'xe'): 58 44 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 59 60 y = time.time() 61 f = open(file_path_store,'r+') 62 x = float(f.readline()) 63 f.close() 64 spamWriter.writerow([n,liststore.spacelist,(y-z),x]) 65 liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] 66 print a 45 67 46 47 y = time.time() #time it 48 spamWriter.writerow([n,(y-z)]) #record it 49 50 print 'Done' 51 52 analyse_log(scenariodir, 'metalog.csv') #get all the memory usage statistics -
trunk/anuga_work/development/mem_time_tests/hardware/template/runcairns.py
r8311 r8326 1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia. 1 """ 2 This experiment was based heavily on the cairns demo given in the user manual and found in 3 the anuga repository. 2 4 3 Source data such as elevation and boundary data is assumed to be available in 4 directories specified by project.py 5 The output sww file is stored in directory named after the scenario, i.e 6 slide or fixed_wave. 7 8 The scenario is defined by a triangular mesh created from project.polygon, 9 the elevation data and a tsunami wave generated by a submarine mass failure. 10 11 Geoscience Australia, 2004-present 5 However, it has been simplified so that it doesnt require all the files the cairns demo does 12 6 """ 13 7 … … 15 9 # Import necessary modules 16 10 #------------------------------------------------------------------------------ 17 # Standard modules18 11 import os 19 12 import time 20 13 import sys 14 import anuga 15 from anuga_parallel import distribute, myid, numprocs 16 from anuga.abstract_2d_finite_volumes.util import add_directories 17 from anuga.utilities import log 21 18 22 # Related major packages 23 import anuga 19 #set up variables for the correct I/O directories for data storage 20 home = os.getenv('INUNDATIONHOME') 21 scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "template"]) 22 scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", 23 "template", "template-" + str(numprocs) +"-"+ str(myid)]) 24 h = 'CAIRNS.msh' 25 file_pathh = os.path.join(scenariodirV, h) 26 log.log_filename = os.path.join(scenariodirV, "anuga.log") 27 log._setup = False 24 28 25 from anuga_parallel import distribute, myid 26 import liststore 27 from anuga.abstract_2d_finite_volumes.util import add_directories 28 from anuga.utilities import system_tools, log 29 log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics here 30 #------------------------------------------------------------------------------ 31 #Create the domain and mesh for the resource experiment on only one processor 32 #------------------------------------------------------------------------------ 29 33 30 31 home2 = os.getenv('INUNDATIONHOME')32 33 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])34 35 store ='store.txt'36 file_path_store = os.path.join(scenariodir2, store)37 h = 'cairnsmesh.msh'38 file_pathh = os.path.join(scenariodir2, h)39 40 41 system_tools.MemoryUpdate()42 #------------------------------------------------------------------------------43 # Create the triangular mesh and domain based on44 # overall clipping polygon with a tagged45 # boundary and interior regions as defined in project.py46 #------------------------------------------------------------------------------47 34 if myid == 0: 48 35 domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)], … … 52 39 'left': [3]}, 53 40 maximum_triangle_area=100.0, 54 mesh_filename=file_pathh 55 #,interior_regions=INTERIORREGIONS#, 56 #use_cache=True, 57 #verbose=True) 58 ) 59 60 # Print some stats about mesh and domain 61 #print 'Number of triangles = ', len(domain) 62 #print 'The extent is ', domain.get_extent() 63 #print domain.statistics() 41 mesh_filename=file_pathh) 64 42 else: 65 43 domain = None 66 44 45 #parallel 67 46 domain = distribute(domain) 68 69 #------------------------------------------------------------------------------70 # Setup parameters of computational domain71 #------------------------------------------------------------------------------72 47 domain.set_name('CAIRNS') # Name of sww file 73 domain.set_datadir(scenariodir2) # Store sww output here 48 domain.set_datadir(scenariodirV)# Store sww output here 49 log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics here 74 50 75 51 #------------------------------------------------------------------------------ … … 86 62 domain.set_quantity('elevation',topography,alpha=0.1) 87 63 88 64 log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here 89 65 90 66 #------------------------------------------------------------------------------ … … 94 70 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 95 71 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow 96 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary97 72 Br = anuga.Reflective_boundary(domain) 98 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) 99 domain.set_boundary({'right': Bo, 100 'bottom': Br, 101 'left': Bi, 102 'top': Br}) 73 domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) 103 74 75 log.resource_usage_timing(prefix='afterboundary') #get memory statistics here 104 76 #------------------------------------------------------------------------------ 105 77 # Evolve system through time 106 78 #------------------------------------------------------------------------------ 107 108 # Save every two mins leading up to wave approaching land109 79 for t in domain.evolve(yieldstep=120, finaltime=2000): 110 80 print domain.timestepping_statistics() 111 112 81 113 liststore.spacelist[myid] = system_tools.MemoryUpdate()[0] 114 a = sum(liststore.spacelist) 115 print liststore.spacelist 116 117 f = open(file_path_store, 'r+') 118 f.write(str(a)) 119 82 log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here -
trunk/anuga_work/development/mem_time_tests/parameters/friction/ex1.py
r8304 r8326 10 10 import os 11 11 from anuga.abstract_2d_finite_volumes.util import add_directories 12 from anuga.utilities import log 12 13 13 14 home = os.getenv('INUNDATIONHOME') … … 16 17 17 18 18 file = 'CAIRNS.sww'19 file_path = os.path.join(scenariodir, file)19 #store = 'store.txt' 20 #file_path_store = os.path.join(scenariodir, store) 20 21 21 h = 'CAIRNS.msh' 22 file_pathh = os.path.join(scenariodir, h) 22 f = open(os.path.join(scenariodir, "store.txt"),'r+') # SQRT extent this is set 23 friction = float(f.readline()) 24 f.close() 25 26 scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", 27 "friction","friction-" + str(friction)]) 28 29 log.log_filename = os.path.join(scenariodirV, "anuga.log") 30 log._setup = False 31 32 log.resource_usage_timing(prefix = 'BeforeSimulation') 33 23 34 #------------------------------------------------------------------------------ 24 35 # Setup computational domain 25 36 #------------------------------------------------------------------------------ 37 points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh 38 domain = anuga.Domain(points, vertices, boundary) # Create domain 39 domain.set_datadir(scenariodirV) 40 domain.set_name('channel1') # Output name 26 41 27 28 29 def runex(f): 30 points, vertices, boundary = anuga.rectangular_cross(10,5, 31 len1=10.0, len2=5.0) # Mesh 32 domain = anuga.Domain(points, vertices, boundary) # Create domain 33 domain.set_datadir(scenariodir) 34 domain.set_name('channel1') # Output name 35 42 log.resource_usage_timing(prefix = 'AfterMesh') 36 43 37 44 #------------------------------------------------------------------------------ 38 45 # Setup initial conditions 39 46 #------------------------------------------------------------------------------ 40 def topography(x, y): 41 return -x/10 # linear bed slope 42 domain.set_quantity('elevation', topography) # Use function for elevation 43 domain.set_quantity('friction', f) # Constant friction 44 domain.set_quantity('stage', # Dry bed 47 def topography(x, y): 48 return -x/10 # linear bed slope 49 50 log.resource_usage_timing(prefix = 'BeforeInitial') 51 domain.set_quantity('elevation', topography) # Use function for elevation 52 domain.set_quantity('friction', friction) # Constant friction 53 domain.set_quantity('stage', # Dry bed 45 54 expression='elevation') 55 log.resource_usage_timing(prefix = 'AfterInitial') 46 56 47 57 #------------------------------------------------------------------------------ 48 58 # Setup boundary conditions 49 59 #------------------------------------------------------------------------------ 50 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 51 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 52 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 60 log.resource_usage_timing(prefix = 'BeforeBoundary') 61 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 62 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 63 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 64 log.resource_usage_timing(prefix = 'AfterBoundary') 53 65 54 66 #------------------------------------------------------------------------------ 55 67 # Evolve system through time 56 68 #------------------------------------------------------------------------------ 57 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 58 print domain.timestepping_statistics() 59 return f 69 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 70 print domain.timestepping_statistics() 60 71 61 72 log.resource_usage_timing(prefix = 'AfterSimulation') -
trunk/anuga_work/development/mem_time_tests/parameters/friction/main.py
r8304 r8326 9 9 import time 10 10 import subprocess 11 import ex112 11 import csv 13 12 import os 14 13 from anuga.utilities import system_tools, log 15 14 from anuga.abstract_2d_finite_volumes.util import add_directories 15 from anuga.utilities.log_analyser import analyse_log 16 16 #------------------------------------------------------------------------------ 17 17 # Setup computational domain 18 18 #------------------------------------------------------------------------------ 19 a = []20 19 home = os.getenv('INUNDATIONHOME') 21 20 … … 24 23 file = 'ex1.csv' 25 24 file_path = os.path.join(scenariodir, file) 25 store ='store.txt' 26 file_path_store = os.path.join(scenariodir, store) 26 27 27 log.log_filename = os.path.join(scenariodir, 'log.txt') 28 e = open(file_path_store,'a') 29 e.close() 30 31 32 28 33 29 34 spamWriter = csv.writer(open(file_path, 'wb')) … … 32 37 33 38 for n in range(1,10000,100): 34 system_tools.MemoryUpdate() 39 f = open(file_path_store,'wb') 40 f.write(str(n)) 35 41 x = time.clock() 36 h = ex1.runex(n)42 subprocess.call(['python2.5', 'ex1.py']) 37 43 y = time.clock() 38 b = system_tools.MemoryUpdate()[0] 39 spamWriter.writerow([n ,(y-x),b]) 40 print a 44 spamWriter.writerow([n ,(y-x)]) 45 print 'Done' 41 46 47 analyse_log(scenariodir, 'metalog.csv') -
trunk/anuga_work/development/mem_time_tests/parameters/nothing/ex1.py
r8304 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 time 10 6 import os 11 7 from anuga.utilities import log 12 8 from anuga.abstract_2d_finite_volumes.util import add_directories 13 9 10 #set up the variables to correctly store the temporary data 14 11 home = os.getenv('INUNDATIONHOME') 15 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 16 "nothing"]) 12 scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"]) 13 store ='store.txt' 14 file_path_store = os.path.join(scenariodir, store) 17 15 16 #get the run number from the store text file 17 f = open(file_path_store,'r+') 18 n = float(f.readline()) 19 f.close() 18 20 19 file = 'CAIRNS.sww' 20 file_path = os.path.join(scenariodir, file) 21 #set up the variables to correctly store the output data and log file 22 scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", 23 "nothing","nothing"+"-"+str(n)]) 21 24 22 h = 'CAIRNS.msh' 23 file_pathh = os.path.join(scenariodir, h) 25 log.log_filename = os.path.join(scenariodirV, "anuga.log") 26 log._setup = False 24 27 28 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here 25 29 #------------------------------------------------------------------------------ 26 30 # Setup computational domain 27 31 #------------------------------------------------------------------------------ 32 points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh 33 domain = anuga.Domain(points, vertices, boundary) # Create domain 28 34 35 domain.set_name('channel1') # Output name 36 domain.set_datadir(scenariodir) 29 37 38 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here 30 39 31 def runex():32 points, vertices, boundary = anuga.rectangular_cross(10,5,33 len1=10.0, len2=5.0) # Mesh34 domain = anuga.Domain(points, vertices, boundary) # Create domain35 domain.set_name('channel1') # Output name36 domain.set_datadir(scenariodir)37 40 #------------------------------------------------------------------------------ 38 41 # Setup initial conditions 39 42 #------------------------------------------------------------------------------ 40 41 42 43 44 domain.set_quantity('stage', # Dry bed 45 expression='elevation')43 def topography(x, y): 44 return -x/10 # linear bed slope 45 domain.set_quantity('elevation', topography) # Use function for elevation 46 domain.set_quantity('friction', 0.01) # Constant friction 47 domain.set_quantity('stage',expression='elevation') 48 log.resource_usage_timing(prefix='afterinitialconditions') 46 49 47 50 #------------------------------------------------------------------------------ 48 51 # Setup boundary conditions 49 52 #------------------------------------------------------------------------------ 50 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow51 52 53 Bi = anuga.Dirichlet_boundary([400, 0, 0]) # Inflow 54 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 55 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 53 56 57 log.resource_usage_timing(prefix='afterboundary') #get memory usage here 54 58 #------------------------------------------------------------------------------ 55 59 # Evolve system through time 56 60 #------------------------------------------------------------------------------ 57 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 58 print domain.timestepping_statistics() 59 return len(domain) 61 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 62 print domain.timestepping_statistics() 60 63 61 64 log.resource_usage_timing(prefix='aftersimulation') #get memory usage here -
trunk/anuga_work/development/mem_time_tests/parameters/nothing/main.py
r8304 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 time 10 6 import random 11 7 import subprocess 12 import ex113 8 import csv 14 9 import os 15 10 from anuga.utilities import system_tools, log 16 11 from anuga.abstract_2d_finite_volumes.util import add_directories 17 #------------------------------------------------------------------------------ 18 # Setup computational domain 19 #------------------------------------------------------------------------------ 20 a = [] 12 from anuga.utilities.log_analyser import analyse_log 21 13 14 #-------------------------------------------------------------------------------------- 15 # Set up variables for the correct directories to store the output 16 #-------------------------------------------------------------------------------------- 22 17 home = os.getenv('INUNDATIONHOME') 23 24 25 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 26 "nothing"]) 18 scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"]) 27 19 file = 'ex1.csv' 28 29 log.log_filename = os.path.join(scenariodir, 'log.txt')30 31 20 file_path = os.path.join(scenariodir, file) 21 store = 'store.txt' 22 file_path_store = os.path.join(scenariodir, store) 32 23 33 24 spamWriter = csv.writer(open(file_path, 'wb')) 25 spamWriter.writerow(['Run Number' , 'Time Taken','Space Used']) 26 e = open(file_path_store,'a') #create the file 27 e.close() 34 28 35 spamWriter.writerow(['Run Number' , 'Time Taken','Space Used']) 29 #main loop, that stores the current run number so that unique folders exist for the information 30 for n in range(0,300,1): 36 31 32 e = open(file_path_store,'r+') 33 e.write(str(n)) #store the run number 34 35 x = time.clock() #time it 36 subprocess.call(['python2.5', 'ex1.py']) #run script 37 y = time.clock() #time it 37 38 38 for n in range(0,300,1): 39 system_tools.MemoryUpdate() 40 x = time.clock() 41 ex1.runex() 42 y = time.clock() 43 d = system_tools.MemoryUpdate()[0] 44 spamWriter.writerow([n ,(y-x),d]) 45 a.append((n,y-x,d)) 46 print a 39 spamWriter.writerow([n ,(y-x)]) 47 40 41 print "DONE" 42 43 analyse_log(scenariodir, 'metalog.csv') #get the memory usage from the log files -
trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/ex1.py
r8311 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 time 10 6 import random 11 7 import os 12 #------------------------------------------------------------------------------13 # Setup computational domain14 #------------------------------------------------------------------------------15 8 from anuga.abstract_2d_finite_volumes.util import add_directories 9 from anuga.utilities import log 16 10 11 #set up variables to store the temporary data 17 12 home = os.getenv('INUNDATIONHOME') 18 13 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 19 14 "timelen-over-timestep"]) 15 store ='store.txt' 16 file_path_store = os.path.join(scenariodir, store) 17 storen ='storen.txt' 18 file_path_storen = os.path.join(scenariodir, storen) 20 19 21 def runex(g,f): 22 points, vertices, boundary = anuga.rectangular_cross(10,5, 23 len1=10.0, len2=5.0) # Mesh 24 domain = anuga.Domain(points, vertices, boundary) # Create domain 25 domain.set_name('channel1') # Output name 26 domain.set_datadir(scenariodir) 20 #get the time length and time step from the text files 21 f = open(file_path_store,'r+') 22 g = float(f.readline()) 23 f.close() 24 f = open(file_path_storen,'r+') 25 h = float(f.readline()) 26 f.close() 27 28 #set up variables to store the data and the log files 29 scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", 30 "timelen-over-timestep", "TT-" + str(g) +"-"+ str(h)]) 31 log.log_filename = os.path.join(scenariodirV, "anuga.log") 32 log._setup = False 33 34 35 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here 36 37 #------------------------------------------------------------------------------ 38 #Create Domain and Mesh 39 #------------------------------------------------------------------------------ 40 points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh 41 domain = anuga.Domain(points, vertices, boundary) # Create domain 42 domain.set_name('channel1') # Output name 43 domain.set_datadir(scenariodirV) 44 45 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here 46 27 47 #------------------------------------------------------------------------------ 28 48 # Setup initial conditions 29 49 #------------------------------------------------------------------------------ 30 def topography(x, y): 31 return -x/10 # linear bed slope 32 domain.set_quantity('elevation', topography) # Use function for elevation 33 domain.set_quantity('friction', 0.01) # Constant friction 34 domain.set_quantity('stage', # Dry bed 35 expression='elevation') 50 def topography(x, y): 51 return -x/10 # linear bed slope 52 53 domain.set_quantity('elevation', topography) # Use function for elevation 54 domain.set_quantity('friction', 0.01) # Constant friction 55 domain.set_quantity('stage', expression='elevation') 56 log.resource_usage_timing(prefix='afterinitialconditions') #get memory usage here 36 57 37 58 #------------------------------------------------------------------------------ 38 59 # Setup boundary conditions 39 60 #------------------------------------------------------------------------------ 40 41 42 43 61 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 62 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 63 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 64 log.resource_usage_timing(prefix='afterboundary') #get memory usage here 44 65 #------------------------------------------------------------------------------ 45 66 # Evolve system through time 46 67 #------------------------------------------------------------------------------ 47 for t in domain.evolve(yieldstep=f, finaltime=g):48 68 for t in domain.evolve(yieldstep=h, finaltime=g): 69 print domain.timestepping_statistics() 49 70 50 71 log.resource_usage_timing(prefix='aftersimulation') #get memory usage here -
trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py
r8315 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules … … 10 7 import random 11 8 import subprocess 12 import ex113 9 import csv 14 10 import os 15 from anuga.utilities import system_tools, log16 11 from anuga.abstract_2d_finite_volumes.util import add_directories 17 #------------------------------------------------------------------------------ 18 # Setup computational domain 19 #------------------------------------------------------------------------------ 20 a = [] 21 home = os.getenv('INUNDATIONHOME') 12 from anuga.utilities.log_analyser import analyse_log 22 13 23 14 15 #------------------------------------------------------------------------------ 16 # Set up variables for the correct directories to store the output 17 #------------------------------------------------------------------------------ 18 home = os.getenv('INUNDATIONHOME') 24 19 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 25 20 "timelen-over-timestep"]) 26 21 file = 'ex1.csv' 22 file_path = os.path.join(scenariodir, file) 23 spamWriter = csv.writer(open(file_path, 'wb')) 24 spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used']) 25 store ='store.txt' 26 file_path_store = os.path.join(scenariodir, store) 27 storen ='storen.txt' 28 file_path_storen = os.path.join(scenariodir, storen) 27 29 28 log.log_filename = os.path.join(scenariodir, 'log.txt') 30 #create each file 31 e = open(file_path_store,'a') 32 e.close() 33 e = open(file_path_storen,'a') 34 e.close() 29 35 30 file_path = os.path.join(scenariodir, file)31 36 32 spamWriter = csv.writer(open(file_path, 'wb'))33 37 34 spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used']) 35 38 # main loops that give the time length (m) and the time step (n) 36 39 for m in range(1,1000,50): 37 40 38 41 for n in range(1,1000,5): 39 n = n/1000.0 40 system_tools.MemoryUpdate() 41 x = time.clock() 42 ex1.runex(float(m),n) 43 y = time.clock() 44 b = system_tools.MemoryUpdate()[0] 45 spamWriter.writerow([m,n ,(y-x),b]) 46 a.append((n,y-x,b)) 47 print a 42 n = n/1000.0 #adjust it so its small enough to see the nature of the relationship 48 43 44 #write to file 45 s = open(file_path_store,'r+') 46 s.write(str(float(m))) 47 t = open(file_path_storen,'r+') 48 t.write(str(n)) 49 50 x = time.clock()#time it 51 subprocess.call(['python2.5', 'ex1.py'])#run it 52 y = time.clock()#time it 53 spamWriter.writerow([m,n ,(y-x),'b'])#write the results 54 55 print 'Done' 56 57 analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the log files -
trunk/anuga_work/development/mem_time_tests/parameters/timelen/ex1.py
r8304 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 time 10 6 import os 11 #------------------------------------------------------------------------------12 # Setup computational domain13 #------------------------------------------------------------------------------14 7 from anuga.abstract_2d_finite_volumes.util import add_directories 8 from anuga.utilities import log 15 9 10 #set up variables for the temporary data files 16 11 home = os.getenv('INUNDATIONHOME') 17 12 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 18 13 "timelength"]) 14 store ='store.txt' 15 file_path_store = os.path.join(scenariodir, store) 19 16 20 def runex(f): 21 points, vertices, boundary = anuga.rectangular_cross(10,5, 22 len1=10.0, len2=5.0) # Mesh 23 domain = anuga.Domain(points, vertices, boundary) # Create domain 24 domain.set_name('channel1') # Output name 25 domain.set_datadir(scenariodir) 17 #get the time length from the store text file 18 s = open(file_path_store,'r+') 19 f = float(s.readline()) 20 s.close() 21 22 #set up variables to store the results and the log files of each experiment 23 scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", 24 "timelength", "timelength-" + str(f)]) 25 log.log_filename = os.path.join(scenariodirV, "anuga.log") 26 log._setup = False 27 28 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here 29 30 #------------------------------------------------------------------------------ 31 # Create the domain and the mesh of the run 32 #------------------------------------------------------------------------------ 33 points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh 34 domain = anuga.Domain(points, vertices, boundary) # Create domain 35 domain.set_name('channel1') # Output name 36 domain.set_datadir(scenariodirV) 37 38 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here 26 39 #------------------------------------------------------------------------------ 27 40 # Setup initial conditions 28 41 #------------------------------------------------------------------------------ 29 def topography(x, y): 30 return -x/10 # linear bed slope 31 domain.set_quantity('elevation', topography) # Use function for elevation 32 domain.set_quantity('friction', 0.01) # Constant friction 33 domain.set_quantity('stage', # Dry bed 34 expression='elevation') 42 def topography(x, y): 43 return -x/10 # linear bed slope 44 domain.set_quantity('elevation', topography) # Use function for elevation 45 domain.set_quantity('friction', 0.01) # Constant friction 46 domain.set_quantity('stage',expression='elevation') 47 48 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here 35 49 36 50 #------------------------------------------------------------------------------ 37 51 # Setup boundary conditions 38 52 #------------------------------------------------------------------------------ 39 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 40 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 41 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 53 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 54 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 55 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 56 57 log.resource_usage_timing(prefix='afterboundary')#get memory usage here 42 58 43 59 #------------------------------------------------------------------------------ 44 60 # Evolve system through time 45 61 #------------------------------------------------------------------------------ 46 for t in domain.evolve(yieldstep=0.2, finaltime=f): 47 print domain.timestepping_statistics() 48 return f 62 for t in domain.evolve(yieldstep=0.2, finaltime=f): 63 print domain.timestepping_statistics() 49 64 50 65 66 log.resource_usage_timing(prefix='aftersimulation') #get memory usage here 67 -
trunk/anuga_work/development/mem_time_tests/parameters/timelen/main.py
r8304 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 time 10 import random11 6 import subprocess 12 import ex113 7 import csv 14 8 import os 15 9 from anuga.utilities import system_tools, log 16 10 from anuga.abstract_2d_finite_volumes.util import add_directories 17 #------------------------------------------------------------------------------ 18 # Setup computational domain 19 #------------------------------------------------------------------------------ 20 a = [] 21 22 home = os.getenv('INUNDATIONHOME') 11 from anuga.utilities.log_analyser import analyse_log 23 12 24 13 14 #------------------------------------------------------------------------------ 15 # Set up variables for the correct directories to store the output 16 #------------------------------------------------------------------------------ 17 home = os.getenv('INUNDATIONHOME') 25 18 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 26 19 "timelength"]) 27 20 file = 'ex1.csv' 28 29 log.log_filename = os.path.join(scenariodir, 'log.txt')30 31 21 file_path = os.path.join(scenariodir, file) 22 store ='store.txt' 23 file_path_store = os.path.join(scenariodir, store) 32 24 33 25 spamWriter = csv.writer(open(file_path, 'wb')) 26 spamWriter.writerow(['Time Length(s)' , 'Time Taken(s)', 'Space Used']) 27 e = open(file_path_store,'a') 28 e.close() 34 29 35 spamWriter.writerow(['Number Of Triangles' , 'Time Taken', 'Space Used']) 30 #main loop that does the same experiment with different time lengths 31 for n in range(1,100000,100): 36 32 33 h = open(file_path_store,'r+') 34 h.write(str(n)) #store the time length 37 35 38 for n in range(1,1000,100): 39 system_tools.MemoryUpdate() 40 x = time.clock() 41 h = ex1.runex(n) 42 y = time.clock() 43 b = system_tools.MemoryUpdate()[0] 44 spamWriter.writerow([h ,(y-x),b]) 45 a.append((h,y-x,b)) 46 print a 36 x = time.clock() #time it 37 subprocess.call(['python2.5', 'ex1.py']) #run script 38 y = time.clock() #time it 39 spamWriter.writerow([n ,(y-x)]) #write results 47 40 41 print 'Done' 42 43 #get the memory usage from the log files of each run 44 analyse_log(scenariodir, 'metalog.csv') -
trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py
r8304 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules … … 10 7 import random 11 8 import os 9 from anuga.abstract_2d_finite_volumes.util import add_directories 10 from anuga.utilities import log 11 12 #set up the variables for the temporary file directories 13 home = os.getenv('INUNDATIONHOME') 14 scenariodir = add_directories(home, ["data","mem_time_test", "parameters","timestep"]) 15 16 store ='store.txt' 17 file_path_store = os.path.join(scenariodir, store) 18 19 s = open(file_path_store,'r+') # read the timestep from the text file 20 f = float(s.readline()) 21 s.close() 22 23 #set up the variables for the log files and data directories 24 scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", 25 "timestep", "timestep-" + str(f)]) 26 log.log_filename = os.path.join(scenariodirV, "anuga.log") 27 log._setup = False 28 29 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here 12 30 #------------------------------------------------------------------------------ 13 31 # Setup computational domain 14 32 #------------------------------------------------------------------------------ 15 from anuga.abstract_2d_finite_volumes.util import add_directories 33 points, vertices, boundary = anuga.rectangular_cross(10,5,len1=10.0, len2=5.0) # Mesh 34 domain = anuga.Domain(points, vertices, boundary) # Create domain 35 domain.set_name('channel1') # Output name 36 domain.set_datadir(scenariodirV) 16 37 17 home = os.getenv('INUNDATIONHOME') 18 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 19 "timestep"]) 20 21 def runex(f): 22 points, vertices, boundary = anuga.rectangular_cross(10,5, 23 len1=10.0, len2=5.0) # Mesh 24 domain = anuga.Domain(points, vertices, boundary) # Create domain 25 domain.set_name('channel1') # Output name 26 domain.set_datadir(scenariodir) 38 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here 27 39 #------------------------------------------------------------------------------ 28 40 # Setup initial conditions 29 41 #------------------------------------------------------------------------------ 30 def topography(x, y): 31 return -x/10 # linear bed slope 32 domain.set_quantity('elevation', topography) # Use function for elevation 33 domain.set_quantity('friction', 0.01) # Constant friction 34 domain.set_quantity('stage', # Dry bed 35 expression='elevation') 42 def topography(x, y): 43 return -x/10 # linear bed slope 44 domain.set_quantity('elevation', topography) # Use function for elevation 45 domain.set_quantity('friction', 0.01) # Constant friction 46 domain.set_quantity('stage', expression='elevation') 47 48 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here 36 49 37 50 #------------------------------------------------------------------------------ 38 51 # Setup boundary conditions 39 52 #------------------------------------------------------------------------------ 40 41 42 53 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 54 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 55 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 43 56 57 log.resource_usage_timing(prefix='afterboundary') #get memory usage here 44 58 #------------------------------------------------------------------------------ 45 59 # Evolve system through time 46 60 #------------------------------------------------------------------------------ 47 48 61 for t in domain.evolve(yieldstep=f, finaltime=40.0): 62 print domain.timestepping_statistics() 49 63 64 log.resource_usage_timing(prefix='aftersimulation') #get memory usage here 50 65 -
trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py
r8304 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 time 10 import random11 6 import subprocess 12 import ex113 7 import csv 14 8 import os 15 from anuga.utilities import system_tools,log9 from anuga.utilities import log 16 10 from anuga.abstract_2d_finite_volumes.util import add_directories 11 from anuga.utilities.log_analyser import analyse_log 12 17 13 #------------------------------------------------------------------------------ 18 # Set up computational domain14 # Set up variables for the correct directories to store the output 19 15 #------------------------------------------------------------------------------ 20 a = []21 16 home = os.getenv('INUNDATIONHOME') 22 23 24 17 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 25 18 "timestep"]) 26 19 file = 'ex1.csv' 27 28 log.log_filename = os.path.join(scenariodir, 'log.txt')29 30 20 file_path = os.path.join(scenariodir, file) 21 store ='store.txt' 22 file_path_store = os.path.join(scenariodir, store) 31 23 32 24 spamWriter = csv.writer(open(file_path, 'wb')) 25 spamWriter.writerow(['TimeStep' , 'Time Taken','Space Used']) 33 26 34 spamWriter.writerow(['Friction' , 'Time Taken','Space Used']) 27 e = open(file_path_store,'a') # create file 28 e.close() 35 29 30 #main loop that runs the script with different time steps (yield steps) 31 for n in range(1,10000,10): 32 n = n/100.0 # get it in the right range 36 33 37 for n in range(1,100,1): 38 n = n/100.0 39 system_tools.MemoryUpdate() 40 x = time.clock() 41 ex1.runex(n) 42 y = time.clock() 43 b = system_tools.MemoryUpdate()[0] 44 spamWriter.writerow([n ,(y-x),b]) 45 a.append((n,y-x,b)) 46 print a 34 g = open(file_path_store,'r+') 35 g.write(str(n)) #write the time step to the file 47 36 37 x = time.clock()#time it 38 subprocess.call(['python2.5', 'ex1.py']) # run it 39 y = time.clock() #time it 40 spamWriter.writerow([n ,(y-x),'b']) #record results 41 42 print 'Done' 43 44 analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files -
trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/ex1.py
r8304 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 time … … 11 7 import os 12 8 from anuga.abstract_2d_finite_volumes.util import add_directories 9 from anuga.utilities import log 13 10 11 #set up the variables for the temporary storage files 14 12 home = os.getenv('INUNDATIONHOME') 15 13 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 16 14 "channelflow"]) 15 store = 'store.txt' 16 file_path_store = os.path.join(scenariodir, store) 17 storen = 'storen.txt' 18 file_path_storen = os.path.join(scenariodir, storen) 17 19 20 #read the percentage of water coverage and the length of the boundary 21 f = open(file_path_store,'r+') 22 length = float(f.readline()) 23 f.close() 24 f = open(file_path_storen,'r+') 25 lower = float(f.readline()) 26 f.close() 27 28 #set up variables to store the experiment data and the log file 29 scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios", 30 "channelflow", "channelflow-" + str(lower) +"-"+ str(length)]) 31 log.log_filename = os.path.join(scenariodirV, "anuga.log") 32 log._setup = False 33 34 log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage 18 35 #------------------------------------------------------------------------------ 19 36 # Setup computational domain 20 37 #------------------------------------------------------------------------------ 21 def runex(lower,length): 22 points, vertices, boundary = anuga.rectangular_cross(50,50, 23 len1=length, len2=length) # Mesh 38 points, vertices, boundary = anuga.rectangular_cross(100,300,len1=length, len2=length) # Mesh 39 domain = anuga.Domain(points, vertices, boundary) # Create domain 40 domain.set_datadir(scenariodir) 41 domain.set_name('channel1.sww') # Output name 24 42 43 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage 25 44 #-------------------------------------------------------------------------- 26 # Setup Domain only on processor 045 # Setup Initial Conditions 27 46 #-------------------------------------------------------------------------- 28 domain = anuga.Domain(points, vertices, boundary) # Create domain 29 domain.set_datadir(scenariodir) 30 domain.set_name('channel1.sww') # Output name 47 def topography(x, y): 48 z = -x/10 49 N = len(x) 50 51 #makes a step 52 for i in range(N): 31 53 32 def topography(x, y): 33 z = -x/10 34 N = len(x) 35 for i in range(N): 36 if y[i] > lower: 37 z[i] += 1 54 if y[i] > lower: 55 z[i] += 1 38 56 39 57 return z 40 58 41 42 43 domain.set_quantity('stage', -1000.0)59 domain.set_quantity('elevation', topography) # Use function for elevation 60 domain.set_quantity('friction', 0.01) # Constant friction 61 domain.set_quantity('stage', -10000000000000000000000.0) 44 62 45 63 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage 46 64 #------------------------------------------------------------------------------ 47 65 # Setup boundary conditions 48 66 #------------------------------------------------------------------------------ 49 50 51 52 67 Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow 68 Bo = anuga.Dirichlet_boundary([-100,0,0]) 69 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 70 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br}) 53 71 72 log.resource_usage_timing(prefix='afterboundary')#get memory usage 54 73 #------------------------------------------------------------------------------ 55 74 # Evolve system through time 56 75 #------------------------------------------------------------------------------ 57 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 58 #if myid == 0: 59 domain.write_time() 76 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 77 domain.write_time() 60 78 61 #domain.sww_merge() 62 #finalize() 63 79 log.resource_usage_timing(prefix='aftersimulation') #get memory usage -
trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/main.py
r8320 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 random 10 6 import subprocess 11 import ex112 7 import csv 13 8 import os 14 9 import time 15 from anuga.utilities import system_tools, log16 10 from anuga.abstract_2d_finite_volumes.util import add_directories 11 from anuga.utilities.log_analyser import analyse_log 17 12 18 13 #------------------------------------------------------------------------------ 19 # Set up computational domain14 # Set up variables for the correct directories to store the output 20 15 #------------------------------------------------------------------------------ 21 a = []22 23 24 16 home = os.getenv('INUNDATIONHOME') 25 17 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 26 18 "channelflow"]) 27 28 log.log_filename = os.path.join(scenariodir, 'log.txt') 29 19 store ='store.txt' 20 file_path_store = os.path.join(scenariodir, store) 21 storen ='storen.txt' 22 file_path_storen = os.path.join(scenariodir, storen) 30 23 file = 'ex1.csv' 31 24 file_path = os.path.join(scenariodir, file) 32 25 26 #set up the output files 33 27 spamWriter = csv.writer(open(file_path, 'wb')) 34 28 spamWriter.writerow(['Length','Stage','Time','Space']) 29 e = open(file_path_store,'a') 30 e.close() 31 e = open(file_path_storen,'a') 32 e.close() 35 33 34 #the main loops that give the length of the inflow boundary (i) and the place to begin the step (n) 36 35 for i in range(100,100000,10000): 36 for n in range(1,i/10,i/100): 37 38 #adjust 39 i = i /100.0 40 n = n/10.0 37 41 38 for n in range(1,i/10,i/100): 39 i = i /100.0 40 n = n/float(i) 41 system_tools.MemoryUpdate() 42 z = time.time() 43 ex1.runex(n,i) 44 b = system_tools.MemoryUpdate()[0] 45 y = time.time() 46 spamWriter.writerow([i,(n/float(i)) ,(y-z), b]) 47 print a 42 #write these values to files 43 g = open(file_path_store,'r+') 44 g.write(str(i)) 45 h = open(file_path_storen,'r+') 46 h.write(str(n)) 48 47 48 z = time.time() #time it 49 subprocess.call(['python2.5', 'ex1.py'])#run the script 50 y = time.time() #time it 51 52 spamWriter.writerow([i,n,(y-z), 'b'])#record it 53 print 'DONE' 54 55 analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the various log files -
trunk/anuga_work/development/mem_time_tests/scenarios/stage/ex1.py
r8304 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 time … … 11 7 import os 12 8 from anuga.abstract_2d_finite_volumes.util import add_directories 9 from anuga.utilities import log 13 10 11 #set up the variables for the temporary data storage 14 12 home = os.getenv('INUNDATIONHOME') 15 13 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 16 14 "stage"]) 15 store = 'store.txt' 16 file_path_store = os.path.join(scenariodir, store) 17 storen = 'storen.txt' 18 file_path_storen = os.path.join(scenariodir, storen) 17 19 20 #read the values from the text files 21 f = open(file_path_store,'r+') 22 l = float(f.readline()) 23 f.close() 24 f = open(file_path_storen,'r+') 25 tide = float(f.readline()) 26 f.close() 18 27 28 #set up variables to store the output of the simulation and the log files 29 scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios", 30 "stage", "stage-" + str(tide) +"-"+ str(l)]) 31 log.log_filename = os.path.join(scenariodirV, "anuga.log") 32 log._setup = False 19 33 34 log.resource_usage_timing(prefix = 'BeforeSimulation')# get memory usage 20 35 #------------------------------------------------------------------------------ 21 36 # Setup computational domain 22 37 #------------------------------------------------------------------------------ 23 def runex(l,tide): 38 points, vertices, boundary = anuga.rectangular_cross(100,300, 39 len1=l, len2=(l/2)) # Mesh 40 domain = anuga.Domain(points, vertices, boundary) # Create domain 41 domain.set_datadir(scenariodirV) 42 domain.set_name('channel1') # Output name 24 43 25 points, vertices, boundary = anuga.rectangular_cross(50,50, 26 len1=l, len2=(l/2)) # Mesh 27 44 log.resource_usage_timing(prefix = 'AfterMesh')# get memory usage 28 45 29 46 #-------------------------------------------------------------------------- 30 # Setup Domain only on processor 047 # Setup initial conditions 31 48 #-------------------------------------------------------------------------- 49 def topography(x, y): 50 return 0 #flat land 51 domain.set_quantity('elevation', topography) # Use function for elevation 52 domain.set_quantity('friction', 0.01) # Constant friction 53 domain.set_quantity('stage', tide) 32 54 33 domain = anuga.Domain(points, vertices, boundary) # Create domain 34 domain.set_datadir(scenariodir) 35 domain.set_name('channel1') # Output name 36 37 def topography(x, y): 38 return 0 #-x/10 linear bed slope 39 domain.set_quantity('elevation', topography) # Use function for elevation 40 domain.set_quantity('friction', 0.01) # Constant friction 41 domain.set_quantity('stage', tide) 42 55 log.resource_usage_timing(prefix='afterinitialconditions') # get memory usage 43 56 44 57 #------------------------------------------------------------------------------ 45 58 # Setup boundary conditions 46 59 #------------------------------------------------------------------------------ 47 #Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 48 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 49 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 60 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 61 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 62 63 log.resource_usage_timing(prefix='afterboundary')# get memory usage 50 64 51 65 #------------------------------------------------------------------------------ 52 66 # Evolve system through time 53 67 #------------------------------------------------------------------------------ 54 55 68 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 69 domain.write_time() 56 70 57 #domain.sww_merge() 58 #finalize() 59 71 log.resource_usage_timing(prefix='aftersimulation')# get memory usage -
trunk/anuga_work/development/mem_time_tests/scenarios/stage/main.py
r8304 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 random 10 6 import subprocess 11 import ex112 7 import csv 13 8 import os 14 9 import time 15 from anuga.utilities import system_tools, log16 10 from anuga.abstract_2d_finite_volumes.util import add_directories 17 11 from anuga.utilities.log_analyser import analyse_log 18 12 19 13 #------------------------------------------------------------------------------ 20 # Set up computational domain14 # Set up variables for the correct directories to store the output 21 15 #------------------------------------------------------------------------------ 22 a = []23 24 16 home = os.getenv('INUNDATIONHOME') 25 17 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 26 18 "stage"]) 27 28 log.log_filename = os.path.join(scenariodir, 'log.txt')29 19 file = 'ex1.csv' 30 20 file_path = os.path.join(scenariodir, file) 21 store ='store.txt' 22 file_path_store = os.path.join(scenariodir, store) 23 storen ='storen.txt' 24 file_path_storen = os.path.join(scenariodir, storen) 31 25 26 #create files 32 27 spamWriter = csv.writer(open(file_path, 'wb')) 33 28 spamWriter.writerow(['Stage','Extent','Time','Space']) 29 e = open(file_path_store,'a') 30 e.close() 31 e = open(file_path_storen,'a') 32 e.close() 34 33 34 #these are the main loops that determine the side length of the bounding square(m) 35 #and the depth of the initial water (n) 36 for m in range(100,1000,100): 37 for n in range(1,100,10): 38 39 # thsese values are written to the files 40 g = open(file_path_store,'r+') 41 g.write(str(m)) 42 h = open(file_path_storen,'r+') 43 h.write(str(n)) 35 44 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 z = time.time() #time it 46 subprocess.call(['python2.5', 'ex1.py']) # run the simulation script 47 y = time.time() #time it 48 spamWriter.writerow([n ,((m**2)/2),(y-z),'a']) #record it 49 print 'DONE' 45 50 46 for m in range(100,1000,100): 47 onevar(m) 48 51 analyse_log(scenariodir, 'metalog.csv') #get the memory usage information from the log files -
trunk/anuga_work/development/mem_time_tests/scenarios/vel2/ex1.py
r8304 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 time … … 11 7 import os 12 8 from anuga.abstract_2d_finite_volumes.util import add_directories 9 from anuga.utilities import log 13 10 11 # set up the variables for the temporary files 14 12 home = os.getenv('INUNDATIONHOME') 15 scenariodir = add_directories(home, ["data","mem_time_test", "triangles", 16 "serial"]) 13 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 14 "velocity"]) 15 store ='store.txt' 16 file_path_store = os.path.join(scenariodir, store) 17 storen = 'storen.txt' 18 file_path_storen = os.path.join(scenariodir, storen) 19 storea = 'storea.txt' 20 file_path_storea = os.path.join(scenariodir, storea) 17 21 22 # read the velocity and the map side length from the text files 23 f = open(file_path_store,'r+') 24 k = float(f.readline()) 25 f.close() 26 f = open(file_path_storen,'r+') 27 l = float(f.readline()) 28 f.close() 29 30 #set up variables for the simulation output and the log files 31 scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios", 32 "velocity", "velocity-" + str(k) +"-"+ str(l)]) 33 log.log_filename = os.path.join(scenariodirV, "anuga.log") 34 log._setup = False 35 36 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage 18 37 #------------------------------------------------------------------------------ 19 38 # Setup computational domain 20 39 #------------------------------------------------------------------------------ 21 def runex(k,l): 40 points, vertices, boundary = anuga.rectangular_cross(100,300, len1=1000, len2=500) # Mesh 41 domain = anuga.Domain(points, vertices, boundary) # Create domain 42 domain.set_name('channel1') # Output name 43 domain.set_datadir(scenariodirV) 22 44 23 points, vertices, boundary = anuga.rectangular_cross(100,100, 24 len1=l, len2=l) # Mesh 45 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage 46 47 #get the number of triangles 48 number = len(domain) 25 49 26 50 #-------------------------------------------------------------------------- 27 # Setup Domain only on processor 051 # Setup initial conditions 28 52 #-------------------------------------------------------------------------- 29 domain = anuga.Domain(points, vertices, boundary) # Create domain 30 domain.set_name('channel1') # Output name31 domain.set_datadir(scenariodir) 32 33 number = len(domain)53 def topography(x, y): 54 return 0.0 55 domain.set_quantity('elevation', topography) # Use function for elevation 56 domain.set_quantity('friction', 0.01) # Constant friction 57 domain.set_quantity('stage', -1000.0) 34 58 35 def topography(x, y): 36 return 0.0 37 38 domain.set_quantity('elevation', topography) # Use function for elevation 39 domain.set_quantity('friction', 0.01) # Constant friction 40 domain.set_quantity('stage', -1000.0) 59 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage 41 60 42 61 #------------------------------------------------------------------------------ 43 62 # Setup boundary conditions 44 63 #------------------------------------------------------------------------------ 45 Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow 46 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 47 Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow 48 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br}) 64 Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow 65 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 66 Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow 67 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br}) 68 69 log.resource_usage_timing(prefix='afterboundary')#get memory usage 49 70 50 71 #------------------------------------------------------------------------------ 51 72 # Evolve system through time 52 73 #------------------------------------------------------------------------------ 53 54 74 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 75 domain.write_time() 55 76 56 return number 77 log.resource_usage_timing(prefix='aftersimulation') #get memory usage 57 78 79 #write the number of triangles to the file 80 c = open(file_path_storea,'r+') 81 c.write(str(number)) -
trunk/anuga_work/development/mem_time_tests/scenarios/vel2/main.py
r8320 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 random 10 6 import subprocess 11 import ex112 7 import csv 13 8 import os 14 9 import time 15 from anuga.utilities import log16 from anuga.utilities import system_tools17 10 from anuga.abstract_2d_finite_volumes.util import add_directories 11 from anuga.utilities.log_analyser import analyse_log 18 12 19 13 #------------------------------------------------------------------------------ 20 # Set up computational domain14 # Set up variables for the correct directories to store the output 21 15 #------------------------------------------------------------------------------ 22 a = []23 24 16 home = os.getenv('INUNDATIONHOME') 25 17 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 26 18 "velocity"]) 27 28 19 file = 'ex1.csv' 29 20 file_path = os.path.join(scenariodir, file) 21 storea ='storea.txt' 22 file_path_storea = os.path.join(scenariodir, storea) 23 store ='store.txt' 24 file_path_store = os.path.join(scenariodir, store) 25 storen ='storen.txt' 26 file_path_storen = os.path.join(scenariodir, storen) 30 27 31 log.log_filename = os.path.join(scenariodir, 'log.txt') 32 28 #create and set up the files 33 29 spamWriter = csv.writer(open(file_path, 'wb')) 34 30 spamWriter.writerow(['Velocity','Number Of Triangles','Extent','Time','Space']) 35 system_tools.MemoryUpdate() 31 e = open(file_path_storea,'a') 32 e.close() 33 e = open(file_path_store,'a') 34 e.close() 35 e = open(file_path_storen,'a') 36 e.close() 36 37 38 # these are the main loops that give the velocity of inflow (m) and the map side length(n) 39 for m in range(0,250,10): 40 for n in range(1,2000,300): 41 #write these values to the temporary 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)) 37 46 38 for m in range(0,250,10): 39 for i in range(1,2000,100): 40 system_tools.MemoryUpdate()[0] 41 z = time.time() 42 h = ex1.runex(k,i) 43 b = system_tools.MemoryUpdate()[0] 44 y = time.time() 45 spamWriter.writerow([k,h,(i*i),(y-z), b]) 47 z = time.time() #time it 48 subprocess.call(['python2.5', 'ex1.py'])#run simulation script 49 y = time.time() #time it 46 50 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() 55 56 spamWriter.writerow([m,h,(n*n),(y-z), 'b'])# record it 47 57 print 'DONE' 58 59 analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files -
trunk/anuga_work/development/mem_time_tests/triangles/area/main.py
r8320 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 … … 12 8 import time 13 9 import liststore 14 from anuga.utilities import system_tools, log15 10 from anuga.abstract_2d_finite_volumes.util import add_directories 16 11 from anuga.utilities.log_analyser import analyse_log 17 12 18 13 #------------------------------------------------------------------------------ 19 # Set up computational domain14 # Set up variables for the correct directories to store the output 20 15 #------------------------------------------------------------------------------ 21 a = [] 22 #SpaceUsed = 0.0 23 #number = 0 24 25 home1 = os.getenv('INUNDATIONHOME') 16 home = os.getenv('INUNDATIONHOME') 26 17 host = os.getenv('HOST') 27 scenariodir = add_directories(home 1, ["data","mem_time_test", "triangles","area"])18 scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"]) 28 19 file1 = 'ex1.csv' 29 20 file_path = os.path.join(scenariodir, file1) … … 32 23 storea ='storea.txt' 33 24 file_path_storea = os.path.join(scenariodir, storea) 34 store ='store.txt'35 file_path_store = os.path.join(scenariodir, store)36 25 storen ='storen.txt' 37 26 file_path_storen = os.path.join(scenariodir, storen) 38 27 39 log.log_filename = os.path.join(scenariodir, 'log.txt') 40 28 #create and set up the files 41 29 spamWriter = csv.writer(open(file_path, 'wb')) 42 30 spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s']) 43 e = open(file_path_store,'a')44 e.close()45 31 e = open(file_path_storea,'a') 46 32 e.close() … … 50 36 e.close() 51 37 38 # this is the main loops that assigns the maximum triangle area (m) and the map side length(l) 52 39 40 n = 4 #number of processors to use 53 41 for m in range(90,100,10): 54 n = 4 #number of processors to use55 42 for l in range(100,2000,100): 56 43 44 #write these values to file 57 45 g = open(file_path_storel,'r+') 58 46 g.write(str(l)) 47 h = open(file_path_storea,'r+') 48 h.write(str(m)) 49 50 z = time.time()# time it 59 51 60 h = open(file_path_storea,'r+') 61 h.write(str(d)) 62 63 z = time.time() 52 #the different ways each host calls MPI properly 64 53 if (host == 'cyclone.agso.gov.au'): 65 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])54 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 66 55 if (host == 'tornado.agso.gov.au'): 67 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])56 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 68 57 if (host == 'vayu1'): 69 58 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) … … 73 62 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 74 63 75 y = time.time() 64 y = time.time()# time it 76 65 77 f = open(file_path_store,'r+') 78 x = float(f.readline()) 79 f.close() 80 66 # read the number of triangles from this file 81 67 f = open(file_path_storen,'r+') 82 68 i = float(f.readline()) 83 69 f.close() 84 70 85 spamWriter.writerow([i,d,(l*l),x ,(y-z)]) 86 liststore.store = [0,0,0,0] 87 71 spamWriter.writerow([i,d,(l*l),'x' ,(y-z)])# record it 88 72 89 73 print 'Done' 90 74 75 analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files 76 -
trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py
r8314 r8326 1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.2 3 Source data such as elevation and boundary data is assumed to be available in4 directories specified by project.py5 The output sww file is stored in directory named after the scenario, i.e6 slide or fixed_wave.7 8 The scenario is defined by a triangular mesh created from project.polygon,9 the elevation data and a tsunami wave generated by a submarine mass failure.10 11 Geoscience Australia, 2004-present12 """13 14 1 #------------------------------------------------------------------------------ 15 2 # Import necessary modules 16 3 #------------------------------------------------------------------------------ 17 # Standard modules18 4 import os 19 5 import time 20 6 import sys 21 7 import liststore 22 23 # Related major packages24 8 import anuga 25 9 from anuga_parallel import distribute, myid 26 10 from anuga.abstract_2d_finite_volumes.util import add_directories 27 from anuga.utilities import system_tools,log11 from anuga.utilities import log 28 12 13 #set up the variables for the temporary data files 14 home = os.getenv('INUNDATIONHOME') 15 scenariodir = add_directories(home, ["data", "mem_time_test", "triangles", "area"]) 16 storen ='storen.txt' 17 file_path_storen = os.path.join(scenariodir, storen) 18 storel = 'storel.txt' 19 file_path_storel = os.path.join(scenariodir, storel) 20 storea = 'storea.txt' 21 file_path_storea = os.path.join(scenariodir, storea) 29 22 30 home2 = os.getenv('INUNDATIONHOME') 31 32 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"]) 33 34 h = 'CAIRNS.msh' 35 file_pathh = os.path.join(scenariodir2, h) 36 store ='store.txt' 37 file_path_store = os.path.join(scenariodir2, store) 38 storen ='storen.txt' 39 file_path_storen = os.path.join(scenariodir2, storen) 40 storel = 'storel.txt' 41 file_path_storel = os.path.join(scenariodir2, storel) 42 storea = 'storea.txt' 43 file_path_storea = os.path.join(scenariodir2, storea) 44 45 f = open(file_path_storel,'r+') # SQRT extent this is set 23 #read the maximum triangle area and the map side length from the files 24 f = open(file_path_storel,'r+') 46 25 length = float(f.readline()) 47 26 f.close() 48 49 f = open(file_path_storea,'r+') #maxarea this is set 27 f = open(file_path_storea,'r+') 50 28 area = float(f.readline()) 51 29 f.close() 52 30 53 system_tools.MemoryUpdate() 31 #set up the variables for the output data and the log files 32 scenariodirV = add_directories(home, ["data","mem_time_test", "triangles", 33 "area", "triangles-" + str(area) +"-"+ str(length)]) 34 h = 'CAIRNS.msh' 35 file_pathh = os.path.join(scenariodirV, h) 36 log.log_filename = os.path.join(scenariodirV, "anuga.log") 37 log._setup = False 38 39 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage 54 40 #------------------------------------------------------------------------------ 55 # Create the triangular mesh and domain based on 56 # overall clipping polygon with a tagged 57 # boundary and interior regions as defined in project.py 41 # Create the triangular mesh and domain on one processor 58 42 #------------------------------------------------------------------------------ 59 43 if myid == 0: … … 65 49 maximum_triangle_area=area, 66 50 mesh_filename=file_pathh 67 #,interior_regions=INTERIORREGIONS#,68 #use_cache=True,69 #verbose=True)70 51 ) 52 #get the number of triangles 53 n = len(domain) 71 54 72 n = len(domain)73 55 else: 74 56 domain = None 75 76 domain = distribute(domain) 77 78 #------------------------------------------------------------------------------ 79 # Setup parameters of computational domain 80 #------------------------------------------------------------------------------ 57 58 #parallel 59 domain = distribute(domain) 60 81 61 domain.set_name('CAIRNS.sww') # Name of sww file 82 domain.set_datadir(scenariodir 2)# Store sww output here62 domain.set_datadir(scenariodirV)# Store sww output here 83 63 64 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage 84 65 #------------------------------------------------------------------------------ 85 66 # Setup initial conditions … … 95 76 domain.set_quantity('elevation',topography,alpha=0.1) 96 77 97 78 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage 98 79 99 80 #------------------------------------------------------------------------------ … … 102 83 103 84 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 104 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow 105 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary 85 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow 106 86 Br = anuga.Reflective_boundary(domain) 107 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) 108 domain.set_boundary({'right': Bo, 109 'bottom': Br, 110 'left': Bi, 111 'top': Br}) 87 domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) 112 88 113 89 log.resource_usage_timing(prefix='afterboundary')#get memory usage 114 90 #------------------------------------------------------------------------------ 115 91 # Evolve system through time 116 92 #------------------------------------------------------------------------------ 117 118 # Save every two mins leading up to wave approaching land119 93 for t in domain.evolve(yieldstep=120, finaltime=2000): 120 94 print domain.timestepping_statistics() 121 122 95 123 liststore.store[myid] = system_tools.MemoryUpdate()[0] 124 a = sum(liststore.store) 96 log.resource_usage_timing(prefix='aftersimulation') #get memory usage 125 97 126 v = open(file_path_store, 'r+') 127 v.write(str(a)) 128 98 #write the number of triangles to file 129 99 i = open(file_path_storen, 'r+') 130 100 i.write(str(n)) -
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 -
trunk/anuga_work/development/mem_time_tests/triangles/fromregions/runcairns.py
r8303 r8326 1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.2 3 Source data such as elevation and boundary data is assumed to be available in4 directories specified by project.py5 The output sww file is stored in directory named after the scenario, i.e6 slide or fixed_wave.7 8 The scenario is defined by a triangular mesh created from project.polygon,9 the elevation data and a tsunami wave generated by a submarine mass failure.10 11 Geoscience Australia, 2004-present12 """13 14 15 16 1 #------------------------------------------------------------------------------ 17 2 # Import necessary modules 18 3 #------------------------------------------------------------------------------ 19 # Standard modules20 4 import os 21 5 import time 22 6 import sys 23 7 import random 24 25 # Related major packages26 27 8 import anuga 28 9 from anuga.abstract_2d_finite_volumes.util import add_directories 10 from anuga.utilities import log 29 11 30 12 # set up the variables for the temporary files 31 13 home = os.getenv('INUNDATIONHOME') 32 14 scenariodir = add_directories(home, ["data","mem_time_test", "triangles", 33 15 "fromregions"]) 16 store ='store.txt' 17 file_path_store = os.path.join(scenariodir, store) 18 storen ='storen.txt' 19 file_path_storen = os.path.join(scenariodir, storen) 20 storea = 'storea.txt' 21 file_path_storea = os.path.join(scenariodir, storea) 34 22 23 #read the maximum triangle area and map side length from the text files 24 f = open(file_path_store,'r+') 25 a = float(f.readline()) 26 f.close() 27 f = open(file_path_storen,'r+') 28 l = float(f.readline()) 29 f.close() 35 30 36 file = 'CAIRNS.sww' 37 file_path = os.path.join(scenariodir, file) 31 #set up the variables for the simulation output and the log files 32 scenariodirV = add_directories(home, ["data","mem_time_test", "triangles", 33 "fromregions", "triangles-" + str(a) +"-"+ str(l)]) 34 h = 'CAIRNS.msh' 35 file_pathh = os.path.join(scenariodirV, h) 36 log.log_filename = os.path.join(scenariodirV, "anuga.log") 37 log._setup = False 38 38 39 h = 'CAIRNS.msh' 40 file_pathh = os.path.join(scenariodir, h) 41 42 def runex(l,a): 43 39 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage 44 40 #------------------------------------------------------------------------------ 45 # Create the triangular mesh and domain based on 46 # overall clipping polygon with a tagged 47 # boundary and interior regions as defined in project.py 41 # Create the triangular mesh and domain 48 42 #------------------------------------------------------------------------------ 49 43 domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)], 50 44 boundary_tags={'top': [0], 51 45 'right': [1], … … 54 48 maximum_triangle_area=a, 55 49 mesh_filename=file_pathh 56 #,interior_regions=INTERIORREGIONS#, 57 #use_cache=True, 58 #verbose=True) 59 ) 60 61 number=len(domain) 62 63 64 #------------------------------------------------------------------------------ 65 # Setup parameters of computational domain 66 #------------------------------------------------------------------------------ 67 domain.set_name('CAIRNS.sww') # Name of sww file 68 domain.set_datadir(scenariodir) # Store sww output here 69 50 ) 51 domain.set_name('CAIRNS.sww') # Name of sww file 52 domain.set_datadir(scenariodirV)# Store sww output here 53 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage 70 54 #------------------------------------------------------------------------------ 71 55 # Setup initial conditions 72 56 #------------------------------------------------------------------------------ 73 57 74 def topography(x,y): 75 return 0.0 58 #get the number of triangles 59 number=len(domain) 76 60 77 tide = 100.0 78 friction = 0.0 79 domain.set_quantity('stage', tide) 80 domain.set_quantity('friction', friction) 81 domain.set_quantity('elevation',topography,alpha=0.1) 61 def topography(x,y): 62 return 0.0 82 63 64 tide = 100.0 65 friction = 0.0 66 domain.set_quantity('stage', tide) 67 domain.set_quantity('friction', friction) 68 domain.set_quantity('elevation',topography,alpha=0.1) 83 69 70 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage 84 71 85 72 #------------------------------------------------------------------------------ 86 73 # Setup boundary conditions 87 74 #------------------------------------------------------------------------------ 75 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 76 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow 77 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary 78 Br = anuga.Reflective_boundary(domain) 79 domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) 88 80 89 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 90 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow 91 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary 92 Br = anuga.Reflective_boundary(domain) 93 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) 94 domain.set_boundary({'right': Bo, 95 'bottom': Br, 96 'left': Bi, 97 'top': Br}) 98 81 log.resource_usage_timing(prefix='afterboundary')#get memory usage 99 82 #------------------------------------------------------------------------------ 100 83 # Evolve system through time 101 84 #------------------------------------------------------------------------------ 102 103 # Save every two mins leading up to wave approaching land 104 for t in domain.evolve(yieldstep=120, finaltime=2000):105 print domain.timestepping_statistics() 106 107 108 return number 109 85 for t in domain.evolve(yieldstep=120, finaltime=2000): 86 print domain.timestepping_statistics() 87 88 log.resource_usage_timing(prefix='aftersimulation')#get memory usage 89 90 #write the number of triangles to file 91 i = open(file_path_storea, 'r+') 92 i.write(str(number)) -
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 -
trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/runcairns.py
r8303 r8326 1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.2 3 Source data such as elevation and boundary data is assumed to be available in4 directories specified by project.py5 The output sww file is stored in directory named after the scenario, i.e6 slide or fixed_wave.7 8 The scenario is defined by a triangular mesh created from project.polygon,9 the elevation data and a tsunami wave generated by a submarine mass failure.10 11 Geoscience Australia, 2004-present12 """13 14 15 16 1 #------------------------------------------------------------------------------ 17 2 # Import necessary modules 18 3 #------------------------------------------------------------------------------ 19 # Standard modules20 4 import os 21 5 import time 22 6 import sys 23 import random24 25 # Related major packages26 7 import anuga 27 8 from anuga.abstract_2d_finite_volumes.util import add_directories 9 from anuga.utilities import log 28 10 11 #set up the variables for the temporary data files 29 12 home = os.getenv('INUNDATIONHOME') 30 13 scenariodir = add_directories(home, ["data","mem_time_test", "triangles", 31 14 "rectanglecross"]) 15 store ='store.txt' 16 file_path_store = os.path.join(scenariodir, store) 17 storen ='storen.txt' 18 file_path_storen = os.path.join(scenariodir, storen) 19 storea = 'storea.txt' 20 file_path_storea = os.path.join(scenariodir, storea) 32 21 22 #read the matrix size(number of triangles) and the map size from these files 23 f = open(file_path_store,'r+') 24 a = int(f.readline()) 25 f.close() 26 f = open(file_path_storen,'r+') 27 l = float(f.readline()) 28 f.close() 33 29 34 file = 'CAIRNS.sww' 35 file_path = os.path.join(scenariodir, file) 30 #set up the variables for the simulation out put and log files 31 scenariodirV = add_directories(home, ["data","mem_time_test", "triangles", 32 "rectanglecross", "triangles-" + str(a) +"-"+ str(l)]) 33 log.log_filename = os.path.join(scenariodirV, "anuga.log") 34 log._setup = False 36 35 37 h = 'CAIRNS.msh' 38 file_pathh = os.path.join(scenariodir, h) 39 40 41 def runex(l,a): 42 43 36 log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage 44 37 #------------------------------------------------------------------------------ 45 # Create the triangular mesh and domain based on 46 # overall clipping polygon with a tagged 47 # boundary and interior regions as defined in project.py 38 # Create the triangular mesh and domain 48 39 #------------------------------------------------------------------------------ 49 50 points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh 51 domain = anuga.Domain(points, vertices, boundary) # Create domain 52 53 number=len(domain) 54 55 56 #------------------------------------------------------------------------------ 57 # Setup parameters of computational domain 58 #------------------------------------------------------------------------------ 59 domain.set_name('CAIRNS.sww') # Name of sww file 60 domain.set_datadir(scenariodir) # Store sww output here 61 40 points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh 41 domain = anuga.Domain(points, vertices, boundary) # Create 42 domain.set_name('CAIRNS.sww') # Name of sww file 43 domain.set_datadir(scenariodirV)# Store sww output here 44 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage 62 45 #------------------------------------------------------------------------------ 63 46 # Setup initial conditions 64 47 #------------------------------------------------------------------------------ 65 48 66 def topography(x,y): 67 return 0.0 49 #get the number of triangles 50 number=len(domain) 68 51 69 tide = 100.0 70 friction = 0.0 71 domain.set_quantity('stage', tide) 72 domain.set_quantity('friction', friction) 73 domain.set_quantity('elevation',topography,alpha=0.1) 52 def topography(x,y): 53 return 0.0 74 54 55 tide = 100.0 56 friction = 0.0 57 domain.set_quantity('stage', tide) 58 domain.set_quantity('friction', friction) 59 domain.set_quantity('elevation',topography,alpha=0.1) 75 60 76 61 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage 77 62 #------------------------------------------------------------------------------ 78 63 # Setup boundary conditions 79 64 #------------------------------------------------------------------------------ 65 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 66 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow 67 Br = anuga.Reflective_boundary(domain) 68 domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) 80 69 81 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 82 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow 83 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary 84 Br = anuga.Reflective_boundary(domain) 85 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) 86 domain.set_boundary({'right': Bo, 87 'bottom': Br, 88 'left': Bi, 89 'top': Br}) 90 70 log.resource_usage_timing(prefix='afterboundary')#get memory usage 91 71 #------------------------------------------------------------------------------ 92 72 # Evolve system through time 93 73 #------------------------------------------------------------------------------ 74 for t in domain.evolve(yieldstep=120, finaltime=2000): 75 print domain.timestepping_statistics() 94 76 95 # Save every two mins leading up to wave approaching land 96 for t in domain.evolve(yieldstep=120, finaltime=2000): 97 print domain.timestepping_statistics() 98 99 100 return number 101 77 log.resource_usage_timing(prefix='aftersimulation')#get memory usage 78 79 #write the number of triangles to the text file 80 v = open(file_path_storea, 'r+') 81 v.write(str(number)) -
trunk/anuga_work/development/mem_time_tests/triangles/serial/main.py
r8320 r8326 13 13 import os 14 14 import time 15 from anuga.utilities import system_tools, log 15 from anuga.utilities import system_tools, log, log_analyser 16 16 from anuga.abstract_2d_finite_volumes.util import add_directories 17 import logAnalyser 17 18 18 #------------------------------------------------------------------------------ 19 19 # Setup computational domain … … 28 28 "serial"]) 29 29 file = 'ex1.csv' 30 31 #log.log_filename = os.path.join(scenariodir, 'anuga.log')32 33 30 file_path = os.path.join(scenariodir, file) 34 #print "file_path",file_path35 31 36 32 spamWriter = csv.writer(open(file_path, 'wb')) … … 40 36 41 37 42 def runlist(r): 43 n = 1 #20 44 while (n > 0): 45 c = 2 #random.random() * 2000 + 1 38 for m in range(40000,50000,10000): 39 40 for n in range(9,10,1): 46 41 z = time.time() 47 h = runcairns.runex( c,r)42 h = runcairns.runex(n,m) 48 43 y = time.time() 49 44 n = n -1 50 #subprocess.call(['python','timingScript.py',scenariodir,outputresource])51 logAnalyser.AnalyseLog()52 45 spamWriter.writerow([h,r,(c*c),'x' ,(y-z)]) 53 54 while (m > 0):55 m = m -156 d = 101 #random.random() * 100 +157 58 runlist(d)59 60 46 print 'DONE' 61 47
Note: See TracChangeset
for help on using the changeset viewer.