- Timestamp:
- Jan 31, 2012, 10:54:12 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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))
Note: See TracChangeset
for help on using the changeset viewer.