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

Last change on this file since 240 was 239, checked in by ole, 21 years ago

Added profiler

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
33#Create shallow water domain
34domain = Domain(points, vertices, boundary)
35domain.smooth = False
36domain.visualise = False
37domain.visualise = True
38domain.default_order = 2
39domain.newstyle = True  #True is better
40
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('level', Constant_height(Z, 0.))
78
79from Numeric import allclose
80
81#Evolve
82for t in domain.evolve(yieldstep = 0.1, finaltime = 20):
83    domain.write_time()
84    #print domain.quantities['level'].centroid_values[:6]
85print 'Done'   
86   
Note: See TracBrowser for help on using the repository browser.