source: inundation/ga/storm_surge/pyvolution/show_balanced_limiters.py @ 303

Last change on this file since 303 was 287, checked in by ole, 21 years ago

Cleanup

File size: 2.0 KB
Line 
1"""Example of shallow water wave equation.
2
3Specific methods pertaining to the 2D shallow water equation
4are imported from shallow_water
5for use with the generic finite volume framework
6
7Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the
8numerical vector named conserved_quantities.
9"""
10
11######################
12# Module imports
13#
14from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
15     Transmissive_boundary, Time_boundary,\
16     Weir_simple as Weir, Constant_height
17
18from mesh_factory import rectangular
19from Numeric import array
20   
21
22######################
23# Domain
24#
25
26N = 12
27
28print 'Creating domain'
29#Create basic mesh
30points, vertices, boundary = rectangular(N, N/2, len1=1.2,len2=0.6,
31                                         origin=(-0.07, 0))
32
33print 'Number of elements', len(vertices)
34#Create shallow water domain
35domain = Domain(points, vertices, boundary)
36domain.smooth = False
37domain.visualise = False
38domain.visualise = True
39domain.default_order = 2
40
41#domain.store = True
42
43#Set bed-slope and friction
44inflow_stage = 0.1
45manning = 0.1
46Z = Weir(inflow_stage)
47
48print 'Field values'
49domain.set_quantity('elevation', Z)
50domain.set_quantity('friction', manning)
51
52
53######################
54# Boundary conditions
55#
56print 'Boundaries'
57Br = Reflective_boundary(domain)
58Bt = Transmissive_boundary(domain)
59
60#Constant inflow
61Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0])
62
63#Time dependent inflow
64from math import sin, pi
65Bw = Time_boundary(domain=domain,
66                   f=lambda x: [(1 + sin(x*pi/4))*\
67                                (inflow_stage*(sin(2.5*x*pi)+0.7)),0,0])
68
69#Set boundary conditions
70domain.set_boundary({'left': Bd, 'right': Br, 'bottom': Br, 'top': Br})
71
72                   
73
74######################
75#Initial condition
76#
77print 'Initial condition'
78domain.set_quantity('level', Constant_height(Z, 0.))
79
80from Numeric import allclose
81
82#Evolve
83for t in domain.evolve(yieldstep = 0.1, finaltime = 30):
84    domain.write_time()
85
86print 'Done'   
87   
88
Note: See TracBrowser for help on using the repository browser.