source: anuga_core/source_numpy_conversion/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py @ 5899

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

Initial NumPy? changes (again!).

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