Changeset 8326 for trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/runcairns.py
- Timestamp:
- Jan 31, 2012, 10:54:12 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/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))
Note: See TracChangeset
for help on using the changeset viewer.