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

Last change on this file since 6145 was 6145, checked in by rwilson, 15 years ago

Change Numeric imports to general form - ready to change to NumPy?.

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