"""Example of shallow water wave equation consisting of an asymetrical converging channel. Copyright 2005 Christopher Zoppou, Stephen Roberts ANU Specific methods pertaining to the 2D shallow water equation are imported from shallow_water for use with the generic finite volume framework Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the numerical vector named conserved_quantities. """ #------------------------------- # Set up path and import modules # import visualise2_chris as visualise # import Image, ImageGrab import sys from os import sep sys.path.append('..'+sep+'pyvolution') from shallow_water import Domain, Constant_height from shallow_water import Transmissive_boundary, Reflective_boundary,\ Dirichlet_boundary from math import sqrt, cos, sin, pi from mesh_factory import oblique #-------------- # Define domain n = 60 m = 80 leny = 30. lenx = 40. n = 50 m = 60 points, elements, boundary = oblique(m, n, lenx, leny) domain = Domain(points, elements, boundary) #---------------- # Order of scheme domain.default_order=1 #--------------------------------- # Store output format and location domain.store = True domain.format = "sww" #"sww" for NET.CDF binary format or "dat" for ASCII domain.filename = "oblique_first_order" #------------------------ # Visualization smoothing domain.smooth=True domain.visualise = True #-------------- # Set bed slope def x_slope(x, y): return 0*x domain.set_quantity('elevation', x_slope) #------------- # Set friction domain.set_quantity('friction', 0.0) #-------------------- # Boundary conditions R = Reflective_boundary(domain) T = Transmissive_boundary(domain) D = Dirichlet_boundary([1.0, 8.57, 0.0]) domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R}) #------------------ # Initial condition h = 0.5 domain.set_quantity('level', Constant_height(x_slope, h) ) #---------------------------------------------------------- # Decide which quantities are to be stored at each timestep domain.quantities_to_be_stored = ['level', 'xmomentum', 'ymomentum'] #---------- # Evolution import time t0 = time.time() for t in domain.evolve(yieldstep = 1.0, finaltime = 50): domain.write_time() print 'That took %.2f seconds' %(time.time()-t0) #----------------------------------- #Save the last frame as an EPS file #filename = 'ccube.eps' #print 'Saving last frame in EPS format in ', filemame #im = ImageGrab.grab() #im.save(filename)