"""Script for running tsunami inundation scenario for Dampier, WA, Australia. Source data such as elevation and boundary data is assumed to be available in directories specified by project.py The output sww file is stored in project.output_run_time_dir The scenario is defined by a triangular mesh created from project.polygon, the elevation data and a simulated submarine landslide. Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006 """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ # Standard modules from os import sep from os.path import dirname, basename from os import mkdir, access, F_OK from shutil import copy import time import sys # Related major packages from anuga.shallow_water import Domain from anuga.shallow_water import Dirichlet_boundary from anuga.shallow_water import File_boundary from anuga.shallow_water import Reflective_boundary from anuga.pmesh.mesh_interface import create_mesh_from_regions from anuga.geospatial_data.geospatial_data import * from anuga.abstract_2d_finite_volumes.util import Screen_Catcher from anuga_parallel.parallel_api import distribute, numprocs, myid # Application specific imports import project # Definition of file names and polygons #------------------------------------------------------------------------------ # Copy scripts to time stamped output directory and capture screen # output to file #------------------------------------------------------------------------------ # filenames build_time = '20061025_113524_build' boundaries_name = project.boundaries_name meshes_dir_name = project.meshes_dir_name+'.msh' #source_dir = project.boundarydir boundaries_time_dir_name = project.boundaries_dir + build_time + sep + boundaries_name #------------------------------------------------------------------------- # Setup computational domain #------------------------------------------------------------------------- print 'Setup computational domain' domain = Domain(meshes_dir_name, use_cache=True, verbose=True) print domain.statistics() #------------------------------------------------------------------------- # Setup initial conditions #------------------------------------------------------------------------- tide = project.tide domain.set_quantity('stage', tide) domain.set_quantity('friction', 0.0) #combined_time_dir_name = project.topographies_dir+build_time+project.combined_name domain.set_quantity('elevation', filename = project.topographies_dir + build_time + sep + project.combined_name + '.pts', use_cache = True, verbose = True, alpha = 0.1) #------------------------------------------------------ # Distribute domain to implement parallelism !!! #------------------------------------------------------ if numprocs > 1: domain=distribute(domain) #------------------------------------------------------ # Set domain parameters #------------------------------------------------------ domain.set_name(project.scenario_name) domain.set_datadir(project.output_run_time_dir) domain.set_default_order(2) #associate to the spatial order of the triangle domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm #------------------------------------------------------------------------- # Setup boundary conditions #------------------------------------------------------------------------- print 'Available boundary tags', domain.get_boundary_tags() Bf = File_boundary(boundaries_time_dir_name + '.sww', domain, verbose = True) Br = Reflective_boundary(domain) Bd = Dirichlet_boundary([tide,0,0]) domain.set_boundary({'back': Br, 'side': Bd, 'ocean': Bf}) #---------------------------------------------------------------------------- # Evolve system through time #---------------------------------------------------------------------------- import time t0 = time.time() for t in domain.evolve(yieldstep = 120, finaltime = 28800): domain.write_time() domain.write_boundary_statistics(tags = 'ocean') print 'That took %.2f seconds' %(time.time()-t0)