"""Simple example of shallow water wave equation using Pyvolution Water driven by linear slope and Dirichlet boundary """ ###################### # Module imports # from pyvolution.mesh_factory import rectangular from pyvolution.shallow_water import Domain, Reflective_boundary,\ Dirichlet_boundary, Time_boundary, Transmissive_boundary #Create basic triangular mesh points, vertices, boundary = rectangular(2, 1) #Create shallow water domain domain = Domain(points, vertices, boundary) domain.set_name('bedslope') domain.set_datadir('.') #Use current directory for output domain.set_quantities_to_be_stored('stage') #See shallow_water.py ####################### # Initial conditions def f(x,y): return -x/2 domain.set_quantity('elevation', f) domain.set_quantity('friction', 0.1) h = 0.05 # Constant depth domain.set_quantity('stage', expression = 'elevation + %f' %h) ###################### # Boundary conditions from math import sin, pi Br = Reflective_boundary(domain) Bt = Transmissive_boundary(domain) Bd = Dirichlet_boundary([0.2,0.,0.]) Bw = Time_boundary(domain=domain, f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) print 'Tags are ', domain.get_boundary_tags() domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) #domain.set_boundary({'left': Bw, 'right': Br, 'top': Br, 'bottom': Br}) ###################### #Evolution domain.check_integrity() for t in domain.evolve(yieldstep = 0.1, finaltime = 0.2): domain.write_time()