Changeset 4100
- Timestamp:
- Dec 19, 2006, 6:20:47 PM (18 years ago)
- Location:
- anuga_core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/demos/cairns/project.py
r4063 r4100 15 15 16 16 # bounding polygon for study area 17 polyAll= read_polygon('extent.csv')17 bounding_polygon = read_polygon('extent.csv') 18 18 19 print 'Area of bounding polygon', polygon_area( polyAll)/1000000.019 print 'Area of bounding polygon', polygon_area(bounding_polygon)/1000000.0 20 20 21 21 ############################### … … 31 31 poly_shallow = read_polygon('shallow.csv') 32 32 33 #plot_polygons([ polyAll,poly_cairns,poly_island0,poly_island1,\33 #plot_polygons([bounding_polygon,poly_cairns,poly_island0,poly_island1,\ 34 34 # poly_island2,poly_island3,poly_shallow],\ 35 35 # 'boundingpoly',verbose=False) -
anuga_core/documentation/user_manual/demos/cairns/runcairns.py
r4087 r4100 9 9 the elevation data and a tsunami wave generated by a submarine mass failure. 10 10 11 Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton and Nick Bartzis, GA - 2006 11 Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton and 12 Nick Bartzis, GA - 2006 12 13 """ 13 14 14 #------------------------------------------------------------------------------ -15 #------------------------------------------------------------------------------ 15 16 # Import necessary modules 16 #------------------------------------------------------------------------------ -17 #------------------------------------------------------------------------------ 17 18 18 19 # Standard modules 19 20 import os 20 21 import time 21 from shutil import copy22 from os import mkdir, access, F_OK23 22 import sys 24 23 25 24 # Related major packages 26 from anuga.shallow_water import Domain, Reflective_boundary, \ 27 Dirichlet_boundary, Time_boundary, File_boundary 28 from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts 29 from anuga.abstract_2d_finite_volumes.combine_pts import combine_rectangular_points_files 30 from anuga.geospatial_data.geospatial_data import * 25 from anuga.shallow_water import Domain 26 from anuga.shallow_water import Reflective_boundary 27 from anuga.shallow_water import Dirichlet_boundary 28 from anuga.shallow_water import Time_boundary 29 from anuga.shallow_water import File_boundary 30 from anuga.pmesh.mesh_interface import create_mesh_from_regions 31 from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf 32 from anuga.shallow_water.data_manager import dem2pts 31 33 32 34 # Application specific imports 33 35 import project # Definition of file names and polygons 34 36 35 #------------------------------------------------------------------------------- 37 38 #------------------------------------------------------------------------------ 36 39 # Define scenario as either slide or fixed_wave. 37 #------------------------------------------------------------------------------ -40 #------------------------------------------------------------------------------ 38 41 scenario = 'slide' 39 42 #scenario = 'fixed_wave' 40 if access(scenario,F_OK) == 0: 41 mkdir (scenario) 43 44 if os.access(scenario, os.F_OK) == 0: 45 os.mkdir(scenario) 42 46 basename = scenario + 'source' 43 47 44 #------------------------------------------------------------------------------- 48 49 #------------------------------------------------------------------------------ 45 50 # Preparation of topographic data 46 #47 51 # Convert ASC 2 DEM 2 PTS using source data and store result in source data 48 #------------------------------------------------------------------------------ -49 50 # filenames52 #------------------------------------------------------------------------------ 53 54 # Filenames 51 55 dem_name = 'cairns' 52 56 meshname = 'cairns.msh' 53 57 54 # createsDEM from asc data58 # Create DEM from asc data 55 59 convert_dem_from_ascii2netcdf(dem_name, use_cache=True, verbose=True) 56 60 57 # createspts file for onshore DEM61 # Create pts file for onshore DEM 58 62 dem2pts(dem_name, use_cache=True, verbose=True) 59 63 60 #---------------------------------------------------------------------------- 64 65 #------------------------------------------------------------------------------ 61 66 # Create the triangular mesh based on overall clipping polygon with a tagged 62 67 # boundary and interior regions defined in project.py along with 63 68 # resolutions (maximal area of per triangle) for each polygon 64 #------------------------------------------------------------------------------- 65 66 from anuga.pmesh.mesh_interface import create_mesh_from_regions 69 #------------------------------------------------------------------------------ 70 67 71 remainder_res = 10000000 68 72 islands_res = 100000 … … 76 80 [project.poly_shallow, shallow_res]] 77 81 78 from caching import cache 79 _ = cache(create_mesh_from_regions, 80 project.polyAll, 81 {'boundary_tags': {'top': [0], 'ocean_east': [1], 82 'bottom': [2], 'onshore': [3]}, 83 'maximum_triangle_area': remainder_res, 84 'filename': meshname, 85 'interior_regions': interior_regions}, 86 verbose = True, evaluate=False) 87 print 'created mesh' 88 89 #------------------------------------------------------------------------------- 82 create_mesh_from_regions(project.bounding_polygon, 83 boundary_tags={'top': [0], 84 'ocean_east': [1], 85 'bottom': [2], 86 'onshore': [3]}, 87 maximum_triangle_area=remainder_res, 88 filename=meshname, 89 interior_regions=interior_regions, 90 use_cache=True, 91 verbose=True) 92 93 94 #------------------------------------------------------------------------------ 90 95 # Setup computational domain 91 #------------------------------------------------------------------------------ -92 93 domain = Domain(meshname, use_cache = True, verbose =True)96 #------------------------------------------------------------------------------ 97 98 domain = Domain(meshname, use_cache=True, verbose=True) 94 99 95 100 print 'Number of triangles = ', len(domain) … … 102 107 domain.set_minimum_storable_height(0.01) 103 108 104 #------------------------------------------------------------------------------- 109 110 #------------------------------------------------------------------------------ 105 111 # Setup initial conditions 106 #------------------------------------------------------------------------------ -112 #------------------------------------------------------------------------------ 107 113 108 114 tide = 0.0 … … 110 116 domain.set_quantity('friction', 0.0) 111 117 domain.set_quantity('elevation', 112 filename = dem_name + '.pts', 113 use_cache = True, 114 verbose = True, 115 alpha = 0.1 116 ) 117 118 #------------------------------------------------------------------------------- 118 filename=dem_name + '.pts', 119 use_cache=True, 120 verbose=True, 121 alpha=0.1) 122 123 124 125 #------------------------------------------------------------------------------ 119 126 # Setup information for slide scenario (to be applied 1 min into simulation 120 #------------------------------------------------------------------------------ -127 #------------------------------------------------------------------------------ 121 128 122 129 if scenario == 'slide': 123 from anuga.shallow_water.smf import slide_tsunami # Function for submarine slide 130 # Function for submarine slide 131 from anuga.shallow_water.smf import slide_tsunami 124 132 tsunami_source = slide_tsunami(length=35000.0, 125 133 depth=project.slide_depth, … … 133 141 134 142 135 #------------------------------------------------------------------------------ -143 #------------------------------------------------------------------------------ 136 144 # Setup boundary conditions 137 #------------------------------------------------------------------------------ -145 #------------------------------------------------------------------------------ 138 146 139 147 print 'Available boundary tags', domain.get_boundary_tags() … … 146 154 Bw = Time_boundary(domain = domain, 147 155 f=lambda t: [(60<t<3660)*50, 0, 0]) 148 domain.set_boundary( {'ocean_east': Bw, 'bottom': Bd, 'onshore': Bd, 149 'top': Bd} ) 156 domain.set_boundary({'ocean_east': Bw, 157 'bottom': Bd, 158 'onshore': Bd, 159 'top': Bd}) 150 160 151 161 # boundary conditions for slide scenario 152 162 if scenario == 'slide': 153 domain.set_boundary( {'ocean_east': Bd, 'bottom': Bd, 'onshore': Bd, 154 'top': Bd} ) 155 156 157 #------------------------------------------------------------------------------- 163 domain.set_boundary({'ocean_east': Bd, 164 'bottom': Bd, 165 'onshore': Bd, 166 'top': Bd}) 167 168 169 #------------------------------------------------------------------------------ 158 170 # Evolve system through time 159 #------------------------------------------------------------------------------ -171 #------------------------------------------------------------------------------ 160 172 161 173 import time -
anuga_core/source/anuga/pmesh/mesh_interface.py
r3943 r4100 76 76 77 77 kwargs = {'maximum_triangle_area': maximum_triangle_area, 78 'filename': filename, 78 79 'interior_regions': interior_regions, 79 80 'interior_holes': interior_holes, … … 103 104 args, kwargs) 104 105 105 106 # Decide whether to store this mesh or return it 107 if filename is None: 108 return m 109 else: 110 if verbose: print 'Generating mesh to file "%s"' %filename 111 m.generate_mesh(minimum_triangle_angle=minimum_triangle_angle, 112 verbose=verbose) 113 m.export_mesh_file(filename) 106 return m 114 107 115 108 … … 118 111 boundary_tags, 119 112 maximum_triangle_area=None, 113 filename=None, 120 114 interior_regions=None, 121 115 interior_holes=None, … … 263 257 geo_reference=poly_geo_reference) 264 258 265 266 return m 267 259 260 261 262 # NOTE (Ole): This was moved here as it is annoying if mesh is always 263 # stored irrespective of whether the computation 264 # was cached or not. This caused Domain to 265 # recompute as it has meshfile as a dependency 266 267 # Decide whether to store this mesh or return it 268 if filename is None: 269 return m 270 else: 271 if verbose: print 'Generating mesh to file "%s"' %filename 272 m.generate_mesh(minimum_triangle_angle=minimum_triangle_angle, 273 verbose=verbose) 274 m.export_mesh_file(filename) 275 276
Note: See TracChangeset
for help on using the changeset viewer.