source: inundation/pyvolution/show_balanced_limiters.py @ 1862

Last change on this file since 1862 was 1043, checked in by ole, 19 years ago

Added diagnostics about boundary forcing

File size: 2.1 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
40domain.filename = 'test_of_pyvolution'
41domain.store = True
42domain.format = 'sww'   #Native netcdf visualisation format
43
44#Set bed-slope and friction
45inflow_stage = 0.1
46manning = 0.1
47Z = Weir(inflow_stage)
48
49print 'Field values'
50domain.set_quantity('elevation', Z)
51domain.set_quantity('friction', manning)
52
53
54######################
55# Boundary conditions
56#
57print 'Boundaries'
58Br = Reflective_boundary(domain)
59Bt = Transmissive_boundary(domain)
60
61#Constant inflow
62Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0])
63
64#Time dependent inflow
65from math import sin, pi
66Bw = Time_boundary(domain=domain,
67                   f=lambda x: [(1 + sin(x*pi/4))*\
68                                (inflow_stage*(sin(2.5*x*pi)+0.7)),0,0])
69
70#Set boundary conditions
71domain.set_boundary({'left': Bd, 'right': Br, 'bottom': Br, 'top': Br})
72
73                   
74
75######################
76#Initial condition
77#
78print 'Initial condition'
79domain.set_quantity('stage', Constant_height(Z, 0.))
80
81from Numeric import allclose
82
83#Evolve
84for t in domain.evolve(yieldstep = 0.1, finaltime = 30):
85    domain.write_time()
86    domain.boundary_stats(['stage'],'left')
87
88print 'Done'   
89   
90
Note: See TracBrowser for help on using the repository browser.