source: anuga_validation/automated_validation_tests/pixel_registration/run_pixel_registration.py @ 4810

Last change on this file since 4810 was 4810, checked in by ole, 17 years ago

Moved files from joaquim_luis into the autovalidation suite to check problems with pixel registration of ESRI ASCII data.
Currently, this test will fail.

File size: 5.8 KB
Line 
1"""Script for running a tsunami inundation scenario for Boca do Rio.
2Adopted from cairns files
3
4Joaquim Luis, 2007
5"""
6
7#------------------------------------------------------------------------------
8# Import necessary modules
9#------------------------------------------------------------------------------
10
11# Standard modules
12import os
13import time
14import sys
15
16# Related major packages
17from anuga.shallow_water import Domain
18from anuga.shallow_water import Transmissive_boundary
19from anuga.shallow_water import Reflective_boundary
20from anuga.shallow_water import Dirichlet_boundary
21from anuga.shallow_water import Time_boundary
22from anuga.shallow_water import File_boundary
23from anuga.shallow_water import Field_boundary
24
25from anuga.pmesh.mesh_interface import create_mesh_from_regions
26from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf
27from anuga.shallow_water.data_manager import dem2pts
28from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary
29from anuga.abstract_2d_finite_volumes.util import file_function
30
31
32#------------------------------------------------------------------------------
33# Define scenario as either ...
34#------------------------------------------------------------------------------
35scenario = 'br'
36basename = scenario + 'source'
37
38#------------------------------------------------------------------------------
39# Preparation of topographic data
40# Convert ASC 2 DEM 2 PTS using source data and store result in source data
41#------------------------------------------------------------------------------
42
43# Filenames
44dem_name = 'sub_region_bat' 
45meshname = 'sub_region.msh'
46
47# Create DEM from asc data
48convert_dem_from_ascii2netcdf(dem_name, use_cache=False, verbose=True)
49
50# Create pts file for onshore DEM
51dem2pts(dem_name, use_cache=False, verbose=True)
52
53from anuga.utilities.polygon import read_polygon, plot_polygons, \
54                                    polygon_area, is_inside_polygon
55
56###############################
57# Domain definitions
58###############################
59
60# bounding polygon for study area
61bounding_polygon = read_polygon('out_rect.csv')
62
63print 'Area of bounding polygon in km?', polygon_area(bounding_polygon)/1000000.0
64
65###############################
66# Interior region definitions
67###############################
68
69# interior polygons
70poly_shallow = read_polygon('shallow.csv')
71
72#------------------------------------------------------------------------------
73# Create the triangular mesh based on overall clipping polygon with a tagged
74# boundary and interior regions defined in project.py along with
75# resolutions (maximal area of per triangle) for each polygon
76#------------------------------------------------------------------------------
77
78remainder_res = 2500
79shallow_res = 250
80interior_regions = [[bounding_polygon, remainder_res], [poly_shallow, shallow_res]]
81
82create_mesh_from_regions(bounding_polygon, 
83                         boundary_tags={'west': [0],
84                                        'south': [1],
85                                        'east': [2],
86                                        'north': [3]},
87                         maximum_triangle_area=remainder_res,
88                         filename=meshname,
89                         interior_regions=interior_regions,
90                         use_cache=False,
91                         verbose=True)
92
93#------------------------------------------------------------------------------
94# Setup computational domain
95#------------------------------------------------------------------------------
96
97domain = Domain(meshname, use_cache=False, verbose=True)
98
99print 'Number of triangles = ', len(domain)
100print 'The extent is ', domain.get_extent()
101print domain.statistics()
102
103domain.set_name(basename) 
104domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
105domain.set_minimum_storable_height(0.01)
106
107#------------------------------------------------------------------------------
108# Setup initial conditions
109#------------------------------------------------------------------------------
110
111tide = 0.0
112domain.set_quantity('stage', tide)
113domain.set_quantity('friction', 0.025) 
114domain.set_quantity('elevation', 
115                    filename=dem_name + '.pts',
116                    use_cache=False,
117                    verbose=True,
118                    alpha=0.1)
119
120#------------------------------------------------------------------------------
121# Setup boundary conditions
122#------------------------------------------------------------------------------
123
124# Create boundary function from timeseries provided in file
125#function1 = file_function('mareg.tms', domain, verbose=True)
126
127# Create and assign boundary objects
128#Bts1 = Transmissive_Momentum_Set_Stage_boundary(domain, function1)
129
130print 'Available boundary tags', domain.get_boundary_tags()
131#Bt = Transmissive_boundary(domain)    # Continue all values on boundary
132Br = Reflective_boundary(domain)
133Bd = Dirichlet_boundary([tide,0,0])
134Bf = Field_boundary('br_swan.sww',
135                    domain, time_thinning=1, mean_stage=tide, 
136                    use_cache=False, verbose=True)
137   
138#Boundary condition for sww feed at the east boundary
139domain.set_boundary({'west': Br,'south':Bf,'east': Br,'north': Br})
140   
141#------------------------------------------------------------------------------
142# Evolve system through time
143#------------------------------------------------------------------------------
144
145import time
146t0 = time.time()
147
148from Numeric import allclose
149from anuga.abstract_2d_finite_volumes.quantity import Quantity
150
151
152    # save every 1sec leading up to wave approaching land
153for t in domain.evolve(yieldstep = 1, finaltime = 960): 
154        domain.write_time()
155        domain.write_boundary_statistics(tags = 'east')
156           
157print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.