Changeset 9329
- Timestamp:
- Sep 9, 2014, 3:38:02 PM (11 years ago)
- Location:
- trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts/project.py
r9328 r9329 14 14 from anuga_parallel import myid, barrier, send, receive, numprocs 15 15 # We need the boundary tags info to correctly cache the mesh 16 from setup_boundary_conditions import BoundaryInfo16 from setup_boundary_conditions import boundary_info 17 17 18 18 … … 78 78 # List of filenames (can be .shp and/or .csv) 79 79 # 80 #break Line_files=glob.glob('../../GIS/Mesh/BreakLines/*.shp')81 break Line_files=[]80 #breakline_files=glob.glob('../../GIS/Mesh/BreakLines/*.shp') 81 breakline_files=[] 82 82 83 83 ## Riverwalls … … 86 86 # header describing the riverwallPar 87 87 # 88 # riverwall_csv Files=glob.glob('../../GIS/Mesh/RiverWalls/*.csv')89 riverwall_csv Files = []88 # riverwall_csv_files=glob.glob('../../GIS/Mesh/RiverWalls/*.csv') 89 riverwall_csv_files = [] 90 90 91 91 # If breaklines/riverwalls intersect with < this distance between the intersection and an … … 94 94 breakLine_intersection_point_movement_threshold=10. 95 95 96 # Get mesh resolutions = RegionPtAreas [alternative to interior_polygons + res]96 # Get mesh resolutions = region_point_areas [alternative to interior_polygons + res] 97 97 #ptAreas='../../GIS/Mesh/RegionResolutions/RegionResolutions.shp' 98 98 ptAreas=None … … 189 189 190 190 bounding_polygon=su.read_polygon(bounding_polygon_file) 191 break Lines=su.readListOfBreakLines(breakLine_files)192 river Walls, riverWall_Par=su.readListOfRiverWalls(riverwall_csvFiles) #{} # Dictionary191 breaklines=su.readListOfBreakLines(breakline_files) 192 riverwalls, riverwall_par=su.readListOfRiverWalls(riverwall_csv_files) #{} # Dictionary 193 193 194 194 if ptAreas is not None: 195 RegionPtAreas=su.readRegionPtAreas(ptAreas, convert_length_to_area=True)195 region_point_areas=su.readregion_point_areas(ptAreas, convert_length_to_area=True) 196 196 else: 197 RegionPtAreas = None197 region_point_areas = None 198 198 # Hack to override resolution 199 # RegionPtAreas=[ RegionPtAreas[i][0:2]+[150*150*0.5] for i in range(len(RegionPtAreas))]199 # region_point_areas=[ region_point_areas[i][0:2]+[150*150*0.5] for i in range(len(region_point_areas))] 200 200 201 201 # Redefine interior_regions to contain the polygon data + resolutions … … 209 209 210 210 # Deal with intersections in the bounding polygon / breaklines / riverwalls 211 bounding_polygon, break Lines, riverWalls =\212 su.add_intersections_to_domain_features(bounding_polygon, break Lines, riverWalls,\211 bounding_polygon, breaklines, riverwalls =\ 212 su.add_intersections_to_domain_features(bounding_polygon, breaklines, riverwalls,\ 213 213 point_movement_threshold=breakLine_intersection_point_movement_threshold, 214 214 verbose=True) … … 216 216 # Here we make a unique ID based on the all the mesh geometry inputs 217 217 # This tells us if we need to regenerate partitions, or use old ones 218 mesh_ ID_hash=hashlib.md5(json.dumps(\219 [bounding_polygon, interior_regions, river Walls, \220 break Lines, RegionPtAreas, default_res, BoundaryInfo]) ).hexdigest()218 mesh_id_hash=hashlib.md5(json.dumps(\ 219 [bounding_polygon, interior_regions, riverwalls, \ 220 breaklines, region_point_areas, default_res, boundary_info]) ).hexdigest() 221 221 222 222 # Fix the output tif bounding polygon … … 240 240 # Set up directories etc 241 241 if(myid==0): 242 run Time = time.strftime('%Y%m%d_%H%M%S', time.localtime())242 runtime = time.strftime('%Y%m%d_%H%M%S', time.localtime()) 243 243 for i in range(1,numprocs): 244 send(run Time,i)244 send(runtime,i) 245 245 else: 246 run Time=receive(0)246 runtime=receive(0) 247 247 barrier() 248 248 249 output_dir = output_basedir+'RUN_'+str(run Time)+'_'+scenario249 output_dir = output_basedir+'RUN_'+str(runtime)+'_'+scenario 250 250 partition_basedir='PARTITIONS/' 251 partition_dir= partition_basedir+'Mesh_'+str(mesh_ ID_hash)251 partition_dir= partition_basedir+'Mesh_'+str(mesh_id_hash) 252 252 meshname=output_dir+'/mesh.tsh' 253 253 … … 297 297 for i in range(len(interior_regions)): 298 298 savLines(interior_regions[i][0], filename=spatial_txt_outputDir+'interior_region_'+str(i)+'.txt') 299 if break Lines is not {}:300 for i in range(len(break Lines)):301 savLines(break Lines.values()[i], filename=spatial_txt_outputDir+'breakLine_'+str(i)+'.txt')302 if river Walls is not {}:303 for i in range(len(river Walls)):304 savLines(river Walls.values()[i], filename=spatial_txt_outputDir+'riverWall_'+str(i)+'.txt')299 if breaklines is not {}: 300 for i in range(len(breaklines)): 301 savLines(breaklines.values()[i], filename=spatial_txt_outputDir+'breakline_'+str(i)+'.txt') 302 if riverwalls is not {}: 303 for i in range(len(riverwalls)): 304 savLines(riverwalls.values()[i], filename=spatial_txt_outputDir+'riverwall_'+str(i)+'.txt') 305 305 306 306 savLines(bounding_polygon,filename=spatial_txt_outputDir+'boundingPoly.txt') 307 307 308 if RegionPtAreas is not None:309 savLines( RegionPtAreas, filename=spatial_txt_outputDir+'regionPtAreas.txt')308 if region_point_areas is not None: 309 savLines(region_point_areas, filename=spatial_txt_outputDir+'regionPtAreas.txt') 310 310 311 311 # Copy all the txt representations of these files to the output directory -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts/run_model.py
r9328 r9329 81 81 # 82 82 #################################################################################### 83 maxQuantities=collect_max_quantities_operator(83 MaxQuantities=collect_max_quantities_operator( 84 84 domain, 85 85 update_frequency=project.max_quantity_update_frequency, -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts/setup_boundary_conditions.py
r9322 r9329 3 3 THE USER MUST EDIT THIS FILE TO SET THE BOUNDARY CONDITIONS 4 4 5 Both the BoundaryInfo list and the function 'setup_boundary_conditions'5 Both the boundary_info list and the function 'setup_boundary_conditions' 6 6 require adjustment 7 7 … … 29 29 # These points define the 'ocean_boundary': 1 point per edge on the bounding polygon 30 30 # 31 ocean_boundary_points File='../anuga/boundaries/ocean_boundary_points/ocean_boundary_points.shp'32 ocean_boundary_points=su.read_points(ocean_boundary_points File)31 ocean_boundary_points_file='../anuga/boundaries/ocean_boundary_points/ocean_boundary_points.shp' 32 ocean_boundary_points=su.read_points(ocean_boundary_points_file) 33 33 34 34 … … 39 39 # assigned to the 'Default' boundary 40 40 # 41 BoundaryInfo=[41 boundary_info=[ 42 42 ['ocean_waterlevel_boundary', ocean_boundary_points], 43 43 ['vertices_without_tagpoints', 'Default'] … … 53 53 54 54 2) Next make sure the 'boundary_tags_and_conditions' dictionary 55 associates the correct 'tags' (defined in BoundaryInfo) to the55 associates the correct 'tags' (defined in boundary_info) to the 56 56 correct boundary condition type 57 57 """ … … 63 63 64 64 # Example: 65 # Transmissive with stage being set by a function 'stage F'66 def stage F(t):65 # Transmissive with stage being set by a function 'stage_function' 66 def stage_function(t): 67 67 return min( max( t-120., 0.)/360., 1.) 68 B_t_stage F = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, stageF)68 B_t_stage_function = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, stage_function) 69 69 70 ## Here we associate each tag in BoundaryInfo with its boundary condition defined above70 ## Here we associate each tag in boundary_info with its boundary condition defined above 71 71 boundary_tags_and_conditions={ 72 'ocean_waterlevel_boundary': B_t_stage F,72 'ocean_waterlevel_boundary': B_t_stage_function, 73 73 'vertices_without_tagpoints':Br 74 74 } … … 78 78 #@@@@@@@@@@@@@@@@@# 79 79 80 ## Check that all tags in BoundaryInfo have been set81 for i in range(len( BoundaryInfo)):82 tag= BoundaryInfo[i][0]80 ## Check that all tags in boundary_info have been set 81 for i in range(len(boundary_info)): 82 tag=boundary_info[i][0] 83 83 if not boundary_tags_and_conditions.has_key(tag): 84 84 msg = 'Need to set boundary_tags_and_conditions for tag = ' + tag -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts/setup_initial_conditions.py
r9328 r9329 108 108 109 109 # Set_quantity data 110 elevation_ Data=[110 elevation_data=[ 111 111 ['../anuga/polygons/patong_10m.txt', elevation_patong_10m], 112 112 ['../anuga/polygons/saddle_10m.txt', elevation_saddle_10m], … … 130 130 default_friction=0.025 131 131 # Set_quantity data 132 friction_ Data =[132 friction_data =[ 133 133 ['All', default_friction] 134 134 ] … … 146 146 147 147 # Set_quantity data 148 stage_ Data = [148 stage_data = [ 149 149 ['All', project.tide] 150 150 ] … … 163 163 164 164 # Set_quantity data 165 xmomentum_ Data = [165 xmomentum_data = [ 166 166 ['All', 0.] 167 167 ] … … 173 173 174 174 # Set_quantity data 175 ymomentum_ Data = [175 ymomentum_data = [ 176 176 ['All', 0.] 177 177 ] … … 195 195 # location='centroids' 196 196 197 elev Fun=qs.composite_quantity_setting_function(elevation_Data, domain)198 domain.set_quantity('elevation', elev Fun, location='vertices')199 elev AddFun=qs.composite_quantity_setting_function(elevation_additions, domain)200 domain.add_quantity('elevation', elev AddFun)201 202 friction Fun=qs.composite_quantity_setting_function(friction_Data, domain)203 domain.set_quantity('friction', friction Fun, location='centroids')204 friction AddFun=qs.composite_quantity_setting_function(friction_additions, domain)205 domain.add_quantity('friction', friction AddFun)206 207 stage Fun=qs.composite_quantity_setting_function(stage_Data, domain)208 domain.set_quantity('stage', stage Fun, location='centroids')209 stage AddFun=qs.composite_quantity_setting_function(stage_additions, domain)210 domain.add_quantity('stage', stage AddFun)211 212 xmomentum Fun=qs.composite_quantity_setting_function(xmomentum_Data, domain)213 domain.set_quantity('xmomentum', xmomentum Fun, location='centroids')214 xmomentum AddFun=qs.composite_quantity_setting_function(xmomentum_additions, domain)215 domain.add_quantity('xmomentum', xmomentum AddFun)216 217 ymomentum Fun=qs.composite_quantity_setting_function(ymomentum_Data, domain)218 domain.set_quantity('ymomentum', ymomentum Fun, location='centroids')219 ymomentum AddFun=qs.composite_quantity_setting_function(ymomentum_additions, domain)220 domain.add_quantity('ymomentum', ymomentum AddFun)197 elevation_function=qs.composite_quantity_setting_function(elevation_data, domain) 198 domain.set_quantity('elevation', elevation_function, location='vertices') 199 elevation_addition_function=qs.composite_quantity_setting_function(elevation_additions, domain) 200 domain.add_quantity('elevation', elevation_addition_function) 201 202 friction_function=qs.composite_quantity_setting_function(friction_data, domain) 203 domain.set_quantity('friction', friction_function, location='centroids') 204 friction_addition_function=qs.composite_quantity_setting_function(friction_additions, domain) 205 domain.add_quantity('friction', friction_addition_function) 206 207 stage_function=qs.composite_quantity_setting_function(stage_data, domain) 208 domain.set_quantity('stage', stage_function, location='centroids') 209 stage_addition_function=qs.composite_quantity_setting_function(stage_additions, domain) 210 domain.add_quantity('stage', stage_addition_function) 211 212 xmomentum_function=qs.composite_quantity_setting_function(xmomentum_data, domain) 213 domain.set_quantity('xmomentum', xmomentum_function, location='centroids') 214 xmomentum_addition_function=qs.composite_quantity_setting_function(xmomentum_additions, domain) 215 domain.add_quantity('xmomentum', xmomentum_addition_function) 216 217 ymomentum_function=qs.composite_quantity_setting_function(ymomentum_data, domain) 218 domain.set_quantity('ymomentum', ymomentum_function, location='centroids') 219 ymomentum_addition_function=qs.composite_quantity_setting_function(ymomentum_additions, domain) 220 domain.add_quantity('ymomentum', ymomentum_addition_function) 221 221 222 222 ################################################################################ … … 226 226 ################################################################################ 227 227 228 if not project.river Walls=={}:229 domain.riverwallData.create_riverwalls(project.river Walls, project.riverWall_Par)228 if not project.riverwalls=={}: 229 domain.riverwallData.create_riverwalls(project.riverwalls, project.riverwall_par) 230 230 domain.riverwallData.export_riverwalls_to_text(output_dir=project.output_dir+'/'+project.spatial_txt_outputDir) 231 231 -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts/setup_mesh.py
r9320 r9329 55 55 56 56 # Information on the tags 57 BoundaryInfo=setup_boundary_conditions.BoundaryInfo 58 59 for i in range(len(BoundaryInfo)): 60 BI=BoundaryInfo[i] 61 tag_i=BI[0] 62 PTS_i=BI[1] 57 boundary_info=setup_boundary_conditions.boundary_info 58 59 for i in range(len(boundary_info)): 60 bi=boundary_info[i] 61 # Shorthand for i'th boundary tag 62 tag_i=bi[0] 63 # Shorthand for i'th set of boundary points 64 PTS_i=bi[1] 63 65 64 66 # Add the boundary tag to the list 65 67 boundary_tags[tag_i]=[] 66 68 67 if(PTS_i=='Default' or i==(len( BoundaryInfo)-1)):69 if(PTS_i=='Default' or i==(len(boundary_info)-1)): 68 70 # Assign default boundaries 69 assert (i==(len( BoundaryInfo)-1) and PTS_i=='Default'),\70 'Default boundary condition must be at the end of the BoundaryInfo list'71 assert (i==(len(boundary_info)-1) and PTS_i=='Default'),\ 72 'Default boundary condition must be at the end of the boundary_info list' 71 73 boundary_tags[tag_i]=default_tags 72 74 else: 73 75 # Loop over all points in the boundary condition 74 76 for j in range(len(PTS_i)): 75 new Ind=su.find_nearest_segment(PTS_i[j], bounding_polygon_closed)[1]76 boundary_tags[tag_i]=boundary_tags[tag_i]+[new Ind]77 default_tags.remove(new Ind)77 new_index=su.find_nearest_segment(PTS_i[j], bounding_polygon_closed)[1] 78 boundary_tags[tag_i]=boundary_tags[tag_i]+[new_index] 79 default_tags.remove(new_index) 78 80 79 81 return boundary_tags … … 89 91 90 92 # Create the boundary tags 91 boundary_ Tags=make_boundary_tags(project.bounding_polygon, setup_boundary_conditions)92 93 # Ensure mesh_break Lines include riverwalls and breakLines94 mesh_break Lines=su.combine_breakLines_and_riverWalls_for_mesh(project.breakLines, project.riverWalls)93 boundary_tags=make_boundary_tags(project.bounding_polygon, setup_boundary_conditions) 94 95 # Ensure mesh_breaklines include riverwalls and breaklines 96 mesh_breaklines=su.combine_breakLines_and_riverWalls_for_mesh(project.breaklines, project.riverwalls) 95 97 96 98 ## Make the mesh 97 99 anuga.create_mesh_from_regions(project.bounding_polygon, 98 boundary_tags=boundary_ Tags,100 boundary_tags=boundary_tags, 99 101 maximum_triangle_area=project.default_res, 100 102 filename=project.meshname, … … 102 104 use_cache=False, 103 105 verbose=verbose, 104 breaklines=mesh_break Lines,105 regionPtArea=project. RegionPtAreas)106 breaklines=mesh_breaklines, 107 regionPtArea=project.region_point_areas) 106 108 107 109 # Make the domain using the mesh … … 145 147 146 148 # Copy code files to output dir. This should be 'nearly the first' thing we do 147 model Files=glob.glob('*.py')+glob.glob('*.sh')148 for model File in modelFiles:149 anuga.copy_code_files(project.output_dir,model File)149 model_files=glob.glob('*.py')+glob.glob('*.sh') 150 for model_file in model_files: 151 anuga.copy_code_files(project.output_dir,model_file) 150 152 151 153 -
trunk/anuga_work/development/gareth/template_scenarios/tsunami/tsunami1/scripts/user_functions.py
r9320 r9329 16 16 17 17 18 def print_velocity_statistics(domain, maxQuantities):18 def print_velocity_statistics(domain, MaxQuantities): 19 19 """ 20 20 Utility for printing velocity stats in the evolve loop … … 32 32 print ' Processor ', myid 33 33 print ' @ Peak velocity is: ', vv.max(), vv.argmax() 34 print ' &- MaxSpeedHistory: ', maxQuantities.max_speed.max()34 print ' &- MaxSpeedHistory: ', MaxQuantities.max_speed.max() 35 35 print ' %- FUF: ', domain.flux_update_frequency.mean() 36 36 else:
Note: See TracChangeset
for help on using the changeset viewer.