source: inundation/examples/bedslope.py @ 2544

Last change on this file since 2544 was 2438, checked in by ole, 19 years ago

Extreme simplification for user guide

File size: 1.5 KB
RevLine 
[777]1"""Simple example of shallow water wave equation using Pyvolution
2
3Water driven by linear slope and Dirichlet boundary
4
5"""
6
7######################
8# Module imports
9#
[1853]10from pyvolution.mesh_factory import rectangular
11from pyvolution.shallow_water import Domain, Reflective_boundary,\
[2156]12     Dirichlet_boundary, Time_boundary, Transmissive_boundary
[777]13
[2288]14#Create basic triangular mesh
[2438]15points, vertices, boundary = rectangular(2, 1)
[777]16
17#Create shallow water domain
18domain = Domain(points, vertices, boundary)
[2288]19domain.set_name('bedslope')
[2320]20domain.set_datadir('.')                      #Use current directory for output
21domain.set_quantities_to_be_stored('stage')  #See shallow_water.py
[777]22
[2288]23
[777]24#######################
[2155]25# Initial conditions
[2156]26def f(x,y):
27    return -x/2
28
29domain.set_quantity('elevation', f)
[777]30domain.set_quantity('friction', 0.1)
31
[2155]32h = 0.05  # Constant depth
33domain.set_quantity('stage', expression = 'elevation + %f' %h)
[777]34
[2155]35
[777]36######################
37# Boundary conditions
38from math import sin, pi
39Br = Reflective_boundary(domain)
40Bt = Transmissive_boundary(domain)
41Bd = Dirichlet_boundary([0.2,0.,0.])
42Bw = Time_boundary(domain=domain,
43                   f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
44
[2155]45
[2320]46print 'Tags are ', domain.get_boundary_tags()
47
[777]48domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
[2155]49#domain.set_boundary({'left': Bw, 'right': Br, 'top': Br, 'bottom': Br})
[777]50
51
52######################
[2155]53#Evolution
[777]54domain.check_integrity()
55
[2438]56for t in domain.evolve(yieldstep = 0.1, finaltime = 0.2):
[777]57    domain.write_time()
58
Note: See TracBrowser for help on using the repository browser.