source: inundation/ga/storm_surge/analytical solutions/Analytical_solution_oblique_shock.py @ 1254

Last change on this file since 1254 was 1254, checked in by chris, 20 years ago
File size: 2.4 KB
Line 
1"""Example of shallow water wave equation
2consisting of an asymetrical converging channel.
3
4   Copyright 2005
5   Christopher Zoppou, Stephen Roberts
6   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# Set up path and import modules
18# import visualise2_chris as visualise
19# import Image, ImageGrab
20import sys
21from os import sep
22sys.path.append('..'+sep+'pyvolution')
23
24from shallow_water import Domain, Constant_height
25from shallow_water import Transmissive_boundary, Reflective_boundary,\
26     Dirichlet_boundary
27from math import sqrt, cos, sin, pi
28from mesh_factory import oblique
29
30#--------------
31# Define domain
32n = 60
33m = 80
34leny = 30.
35lenx = 40.
36n = 50
37m = 60
38points, elements, boundary = oblique(m, n, lenx, leny)
39domain = Domain(points, elements, boundary) 
40
41#----------------
42# Order of scheme
43domain.default_order=1
44
45#---------------------------------
46# Store output format and location
47domain.store = True
48domain.format = "sww" #"sww" for NET.CDF binary format or "dat" for ASCII
49domain.filename = "oblique_first_order"
50
51#------------------------
52# Visualization smoothing
53domain.smooth=True
54
55#--------------
56# Set bed slope
57def x_slope(x, y):
58    return 0*x
59domain.set_quantity('elevation', x_slope)
60
61#-------------
62# Set friction
63domain.set_quantity('friction', 0.0)
64
65#--------------------
66# Boundary conditions
67R = Reflective_boundary(domain)
68T = Transmissive_boundary(domain)
69D = Dirichlet_boundary([1.0, 8.57, 0.0])
70domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R})
71
72#------------------
73# Initial condition
74h = 0.5
75domain.set_quantity('level', Constant_height(x_slope, h) )
76
77#----------------------------------------------------------
78# Decide which quantities are to be stored at each timestep
79domain.quantities_to_be_stored = ['level', 'xmomentum', 'ymomentum']
80
81
82#----------
83# Evolution
84import time
85t0 = time.time()
86for t in domain.evolve(yieldstep = 1.0, finaltime = 50):
87    domain.write_time()
88   
89print 'That took %.2f seconds' %(time.time()-t0)
90
91#-----------------------------------
92#Save the last frame as an EPS file
93#filename = 'ccube.eps'
94#print 'Saving last frame in EPS format in ', filemame
95#im = ImageGrab.grab()
96#im.save(filename)
97
98
99   
Note: See TracBrowser for help on using the repository browser.