"""Script for running a dam break simulation of UQ's dam break tank. The simulation is based on the simulation Matt has presented and will form part of the ANUGA validation paper. i want to compare the stage at .4m and the velocity at .45m. Ole Nielsen and Duncan Gray, GA - 2006 """ #---------------------------------------------------------------------------- # Import necessary modules #---------------------------------------------------------------------------- # Standard modules import time import sys from shutil import copy from os import path # Related major packages from anuga.shallow_water import Domain, Reflective_boundary, \ Dirichlet_boundary, Time_boundary, File_boundary from anuga.abstract_2d_finite_volumes.region import Set_region from anuga.fit_interpolate.interpolate import interpolate_sww2csv from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \ copy_code_files import create_mesh import project # Application specific imports def main(): slope= 0 friction = 0.01 inital_depth = 0.2 gate_position = 0.75 return scenario(slope, friction, inital_depth, gate_position) def scenario(slope, friction, inital_depth, gate_position): #------------------------------------------------------------------------- # Create the triangular mesh #------------------------------------------------------------------------- create_mesh.generate(project.mesh_filename, gate_position, #is_course=True) # this creates the mesh is_course=False) # this creates the mesh head,tail = path.split(project.mesh_filename) #------------------------------------------------------------------------- # Setup computational domain #------------------------------------------------------------------------- domain = Domain(project.mesh_filename, use_cache = False, verbose = True) print 'Number of triangles = ', len(domain) print 'The extent is ', domain.get_extent() print domain.statistics() domain.set_name(project.basename) domain.set_datadir('.') domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) domain.set_minimum_storable_height(0.001) domain.set_store_vertices_uniquely(True) # for writting to sww #------------------------------------------------------------------------- # Setup initial conditions #------------------------------------------------------------------------- def elevation_tilt(x, y): return x*slope domain.set_quantity('stage', elevation_tilt) domain.set_quantity('friction', friction) domain.set_quantity('elevation',elevation_tilt) print 'Available boundary tags', domain.get_boundary_tags() domain.set_region('dam','stage',inital_depth, location = 'unique vertices') Br = Reflective_boundary(domain) Bd = Dirichlet_boundary([0,0,0]) # to drain the water out. domain.set_boundary( {'wall': Br, 'edge': Bd} ) #------------------------------------------------------------------------- # Evolve system through time #------------------------------------------------------------------------- t0 = time.time() for t in domain.evolve(yieldstep = 0.1, finaltime = 10): #enter timestep and final time domain.write_time() print 'That took %.2f seconds' %(time.time()-t0) print 'finished' points = [[0.4,0.2], [0.45,0.2]] #------------------------------------------------------------------------- # Calculate gauge info #------------------------------------------------------------------------- print "name",project.basename +".sww" interpolate_sww2csv( project.basename +".sww", points, project.depth_filename , project.velocity_x_filename, project.velocity_y_filename ) #------------------------------------------------------------- if __name__ == "__main__": main()