source: inundation/ga/storm_surge/analytical solutions/oblique_test_chris.py @ 615

Last change on this file since 615 was 587, checked in by steve, 20 years ago

testing sparse

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
13######################
14# Module imports
15#
16
17#Were these used?
18#import visualise2_chris as visualise
19#import Image, ImageGrab
20
21import sys
22from os import sep
23sys.path.append('..'+sep+'pyvolution')
24
25
26from shallow_water import Domain, Constant_height
27from shallow_water import Transmissive_boundary, Reflective_boundary,\
28     Dirichlet_boundary
29
30from math import sqrt, cos, sin, pi
31from mesh_factory import oblique
32
33
34######################
35# Domain
36#
37n = 60
38m = 80
39leny = 30.
40lenx = 40.
41n = 50
42m = 60
43
44points, elements, boundary = oblique(m, n, lenx, leny)
45domain = Domain(points, elements, boundary) 
46
47# Order of solver
48domain.default_order=2
49
50# Store output
51domain.store=True
52
53# Output format
54domain.format="sww" #NET.CDF binary format
55                    # "dat" for ASCII
56
57# Provide file name for storing output
58domain.filename="oblique"
59
60# Visualization smoothing
61domain.smooth=True
62
63#######################
64#Bed-slope and friction
65def x_slope(x, y):
66    return 0*x
67
68domain.set_quantity('elevation', x_slope)
69domain.set_quantity('friction', 0.0)
70
71######################
72# Boundary conditions
73#
74R = Reflective_boundary(domain)
75T = Transmissive_boundary(domain)
76D = Dirichlet_boundary([1.0, 8.57, 0.0])
77
78domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R})
79
80######################
81#Initial condition
82h = 0.5
83domain.set_quantity('level', Constant_height(x_slope, h) )
84
85
86######################
87#Evolution
88import time
89t0 = time.time()
90for t in domain.evolve(yieldstep = 0.5, finaltime = 50):
91    domain.write_time()
92   
93print 'That took %.2f seconds' %(time.time()-t0)
94
95#FIXME: Compute average water depth on either side of shock and compare
96#to expected values. And also Froude numbers.
97
98
99#print "saving file?"
100#im = ImageGrab.grab()
101#im.save("ccube.eps")
102
103
104   
Note: See TracBrowser for help on using the repository browser.