source: anuga_work/development/joaqium_luis/run.py @ 4925

Last change on this file since 4925 was 4925, checked in by ole, 16 years ago

Example from joaqium_luis where Field_boundary produces spurious flows as discussed on sourceforge in January 2008.
This may become a test for ticket:243

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