source: anuga_core/source/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py @ 5521

Last change on this file since 5521 was 4204, checked in by ole, 17 years ago

Added histogram and percentiles to speed report

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 anuga.shallow_water import Domain,\
15     Reflective_boundary, Dirichlet_boundary,\
16     Transmissive_boundary, Time_boundary
17from anuga.shallow_water.shallow_water_domain import Weir_simple as Weir
18
19from mesh_factory import rectangular
20from Numeric import array
21   
22
23######################
24# Domain
25#
26
27N = 12
28
29print 'Creating domain'
30#Create basic mesh
31points, vertices, boundary = rectangular(N, N/2, len1=1.2,len2=0.6,
32                                         origin=(-0.07, 0))
33
34print 'Number of elements', len(vertices)
35#Create shallow water domain
36domain = Domain(points, vertices, boundary)
37domain.smooth = False
38domain.default_order = 2
39domain.set_name('show_balanced_limiters')
40domain.store = True
41domain.format = 'sww'   #Native netcdf visualisation format
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('stage', Z)
79
80from Numeric import allclose
81
82#Evolve
83for t in domain.evolve(yieldstep = 0.1, finaltime = 30):
84    domain.write_time(track_speeds=True)
85    domain.write_boundary_statistics(['stage'],'left')
86
87print 'Done'   
88   
89
Note: See TracBrowser for help on using the repository browser.