source: inundation/ga/storm_surge/pyvolution/bed_w_file_boundary.py @ 599

Last change on this file since 599 was 324, checked in by ole, 20 years ago

Played with file boundary.

Added set_vertex_values w/ Duncan

File size: 1.9 KB
Line 
1"""Example of shallow water wave equation.
2
3Generate slope
4
5"""
6
7######################
8# Module imports
9#
10from mesh_factory import rectangular
11from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
12     Constant_height, Time_boundary, File_boundary
13from Numeric import array
14
15#Create basic mesh
16points, vertices, boundary = rectangular(10, 10, 100, 100)
17
18#Create shallow water domain
19domain = Domain(points, vertices, boundary)
20domain.smooth = False
21domain.visualise = True
22domain.newstyle = False #(Better in this case)
23domain.default_order=2
24
25#######################
26#Bed-slope and friction
27def x_slope(x, y):
28    return -x/3
29
30#domain.set_quantity('elevation', x_slope)
31domain.set_quantity('elevation', lambda x,y: -x/3)
32domain.set_quantity('friction', 0.1)
33
34
35######################
36# Boundary conditions
37
38
39#Write file
40import os, time
41from config import time_format
42from math import sin, pi
43
44finaltime = 100
45filename = 'bed_w_boundary.bdry'
46fid = open(filename, 'w')
47start = time.mktime(time.strptime('2000', '%Y'))
48dt = 5  #Five second intervals
49t = 0.0
50while t <= finaltime:
51    t_string = time.strftime(time_format, time.gmtime(t+start))   
52    fid.write('%s, %f %f %f\n' %(t_string, 10*sin(t*0.1*pi), 0.0, 0.0))
53   
54    t += dt
55   
56fid.close()
57
58
59
60Br = Reflective_boundary(domain)
61Bd = Dirichlet_boundary([0.2,0.,0.])
62Bw = Time_boundary(domain=domain,
63                   f=lambda t: [(10*sin(t*0.1*pi)), 0.0, 0.0])
64
65Bf = File_boundary(domain, filename)
66
67#domain.set_boundary({'left': Bw, 'right': Br, 'top': Br, 'bottom': Br})
68domain.set_boundary({'left': Bf, 'right': Br, 'top': Br, 'bottom': Br})
69
70
71######################
72#Initial condition
73h = 0.5
74h = 0.0
75domain.set_quantity('level', Constant_height(x_slope, h))
76
77domain.check_integrity()
78
79 
80######################
81#Evolution
82for t in domain.evolve(yieldstep = 1, finaltime = 100.0):
83    domain.write_time()
84
Note: See TracBrowser for help on using the repository browser.