source: inundation/ga/storm_surge/analytical solutions/Analytical solution_oblique_shock.py @ 669

Last change on this file since 669 was 634, checked in by chris, 20 years ago
File size: 2.2 KB
Line 
1"""Example of shallow water wave equation
2consisting of an asymetrical converging channel.
3
4   Copyright 2004
5   Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray
6   Geoscience Australia, ANU
7   
8Specific methods pertaining to the 2D shallow water equation
9are imported from shallow_water
10for use with the generic finite volume framework
11
12Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the
13numerical vector named conserved_quantities.
14
15
16"""
17
18######################
19# Module imports
20#
21
22#Were these used?
23#import visualise2_chris as visualise
24#import Image, ImageGrab
25
26import sys
27from os import sep
28sys.path.append('..'+s
29
30ep+'pyvolution')
31
32
33from shallow_water import Domain, Constant_height
34from shallow_water import Transmissive_boundary, Reflective_boundary,\
35     Dirichlet_boundary
36
37from math import sqrt, cos, sin, pi
38from mesh_factory import oblique
39
40
41######################
42# Domain
43#
44n = 60
45m = 80
46leny = 30.
47lenx = 40.
48n = 50
49m = 60
50
51points, elements, boundary = oblique(m, n, lenx, leny)
52domain = Domain(points, elements, boundary) 
53
54# Order of solver
55domain.default_order=2
56
57# Store output
58domain.store=True
59
60# Output format
61domain.format="sww" #NET.CDF binary format
62                    # "dat" for ASCII
63
64# Provide file name for storing output
65domain.filename="oblique"
66
67# Visualization smoothing
68domain.smooth=True
69
70#######################
71#Bed-slope and friction
72def x_slope(x, y):
73    return 0*x
74
75domain.set_quantity('elevation', x_slope)
76domain.set_quantity('friction', 0.0)
77
78######################
79# Boundary conditions
80#
81R = Reflective_boundary(domain)
82T = Transmissive_boundary(domain)
83D = Dirichlet_boundary([1.0, 8.57, 0.0])
84
85domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R})
86
87######################
88#Initial condition
89h = 0.5
90domain.set_quantity('level', Constant_height(x_slope, h) )
91
92
93######################
94#Evolution
95import time
96t0 = time.time()
97for t in domain.evolve(yieldstep = 0.5, finaltime = 50):
98    domain.write_time()
99   
100print 'That took %.2f seconds' %(time.time()-t0)
101
102#FIXME: Compute average water depth on either side of shock and compare
103#to expected values. And also Froude numbers.
104
105
106#print "saving file?"
107#im = ImageGrab.grab()
108#im.save("ccube.eps")
109
110
111   
Note: See TracBrowser for help on using the repository browser.