source: anuga_validation/analytical solutions/Analytical solution_oblique_shock.py @ 3846

Last change on this file since 3846 was 3846, checked in by ole, 16 years ago

Refactored references to domain.filename away.
Use

domain.set_name()
domain.get_name()

instead.

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