source: anuga_work/production/dampier_2006/run_dampier_parallel.py @ 4072

Last change on this file since 4072 was 3829, checked in by ole, 18 years ago

Retired modify_boundary (now rolled into set_boundary).
Got okushiri_parallel to run correctly and timed the speedup (6.5 on 8 procs)

File size: 7.0 KB
Line 
1"""Script for running tsunami inundation scenario for Karratha, WA, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.outputtimedir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated submarine landslide.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
11"""
12
13# FIXME - parallel library not yet ready (16/10/2006)
14
15
16
17#------------------------------------------------------------------------------
18# Import necessary modules
19#------------------------------------------------------------------------------
20
21# Standard modules
22from os import sep
23from os.path import dirname, basename
24from os import mkdir, access, F_OK
25from shutil import copy
26import time
27import sys
28
29
30# Related major packages
31from anuga.shallow_water import Domain
32from anuga.shallow_water import Dirichlet_boundary
33from anuga.shallow_water import File_boundary
34from anuga.shallow_water import Reflective_boundary
35
36from anuga.pmesh.mesh_interface import create_mesh_from_regions
37
38from anuga.geospatial_data.geospatial_data import *
39
40# Application specific imports
41import project                 # Definition of file names and polygons
42
43from anuga_parallel.parallel_api import distribute, myid, numprocs
44
45#------------------------------------------------------------------------------
46# Copy scripts to time stamped output directory and capture screen
47# output to file
48#------------------------------------------------------------------------------
49
50# filenames
51meshname = project.meshname+'.msh'
52source_dir = project.boundarydir
53
54if myid == 0:
55    # creates copy of code in output dir if dir doesn't exist
56    if access(project.outputtimedir,F_OK) == 0:
57        mkdir (project.outputtimedir)
58    copy (dirname(project.__file__) +sep+ project.__name__+'.py',
59          project.outputtimedir + project.__name__+'.py')
60    copy (__file__, project.outputtimedir + basename(__file__))
61    print 'project.outputtimedir',project.outputtimedir
62
63
64    #--------------------------------------------------------------------------
65    # Create the triangular mesh based on overall clipping polygon with a
66    # tagged
67    # boundary and interior regions defined in project.py along with
68    # resolutions (maximal area of per triangle) for each polygon
69    #--------------------------------------------------------------------------
70
71
72    print 'start create mesh from regions'
73    from caching import cache
74    meshname = project.meshname + '_%d.msh' %myid
75    _ = cache(create_mesh_from_regions,
76              project.bounding_polygon,
77              {'boundary_tags': {'back': [7, 8], 'side': [0, 6],
78                                 'ocean': [1, 2, 3, 4, 5]},
79               'maximum_triangle_area': 200000,
80               'filename': meshname},
81              verbose = True,
82              evaluate = False)
83
84    #-------------------------------------------------------------------------
85    # Setup computational domain
86    #-------------------------------------------------------------------------
87    domain = Domain(meshname, use_cache = True, verbose = True)
88    print domain.statistics()
89    domain.set_name(project.basename)
90    domain.set_datadir(project.outputtimedir)
91
92
93    #-------------------------------------------------------------------------
94    # Setup initial conditions
95    #-------------------------------------------------------------------------
96    tide = 0.
97    domain.set_quantity('stage', tide)
98    domain.set_quantity('friction', 0.0) 
99    domain.set_quantity('elevation', 
100                        filename = project.datadir + project.basename + '.pts',
101                        use_cache = False,
102                        verbose = True,
103                        alpha = 0.1)
104   
105    #-------------------------------------------------------------------------
106    # Setup boundary conditions
107    #-------------------------------------------------------------------------
108
109    print 'Available boundary tags', domain.get_boundary_tags()
110    #Bf = File_boundary(source_dir + project.boundary_basename + '.sww',
111    #                   domain, verbose = True)
112    Br = Reflective_boundary(domain)
113    Bd = Dirichlet_boundary([tide,0,0])
114    domain.set_boundary({'back': Br,
115                         'side': Bd,
116                         'ocean': None}) # Bind this one later
117else:
118    domain = None
119
120
121#--------------------------------------------------------------------------
122# Create the parallel domain
123#--------------------------------------------------------------------------
124if numprocs > 1:
125    domain = distribute(domain, verbose=True)
126
127# Set those boundaries that can't be communicated automatically
128# FIXME: There is a problem with the parallel domain.
129# It seems that boundaries are outside coverage.
130#
131# We get
132#
133#------------------------------------------------
134#Interpolation_function (spatio-temporal) statistics:
135#  Extent:
136#    x in [-60494.651593, 149593.652382], len(x) == 56
137#    y in [-74198.017534, 184623.446077], len(y) == 56
138#    t in [0.000000, 28610.000000], len(t) == 145
139#  Quantities:
140#    stage in [-1.797799, 1.644574]
141#    xmomentum in [-33.219473, 21.571094]
142#    ymomentum in [-32.775090, 73.761256]
143#  Interpolation points (xi, eta): number of points == 411
144#    xi in [-420467.297166, -368252.119852]
145#    eta in [-7652664.149808, -7605199.504709]
146#  Interpolated quantities (over all timesteps):
147#    stage at interpolation points in [inf, inf]
148#    xmomentum at interpolation points in [inf, inf]
149#    ymomentum at interpolation points in [inf, inf]
150#------------------------------------------------
151#
152#Instead of
153#
154#------------------------------------------------
155#Interpolation_function (spatio-temporal) statistics:
156#  Extent:
157#    x in [-60494.651593, 149593.652382], len(x) == 56
158#    y in [-74198.017534, 184623.446077], len(y) == 56
159#    t in [0.000000, 28610.000000], len(t) == 145
160#  Quantities:
161#    stage in [-1.797799, 1.644574]
162#    xmomentum in [-33.219473, 21.571094]
163#    ymomentum in [-32.775090, 73.761256]
164#  Interpolation points (xi, eta): number of points == 503
165#    xi in [4747.280215, 96909.729282]
166#    eta in [9240.613414, 83183.465791]
167#  Interpolated quantities (over all timesteps):
168#    stage at interpolation points in [-0.909515, 1.331521]
169#    xmomentum at interpolation points in [-17.054914, 17.110528]
170#    ymomentum at interpolation points in [-24.691402, 16.625063]
171#------------------------------------------------
172
173
174Bf = File_boundary(source_dir + project.boundary_basename + '.sww',
175                   domain, verbose = True)
176domain.set_boundary({'ocean': Bf})
177
178
179#----------------------------------------------------------------------------
180# Evolve system through time
181#----------------------------------------------------------------------------
182import time
183t0 = time.time()
184
185for t in domain.evolve(yieldstep = 60, finaltime = 28600):
186    domain.write_time()
187    domain.write_boundary_statistics(tags = 'ocean')     
188   
189print 'That took %.2f seconds' %(time.time()-t0)
190
Note: See TracBrowser for help on using the repository browser.