source: storm_surge/pyvolution/cornell_room.py @ 522

Last change on this file since 522 was 1, checked in by duncan, 20 years ago

initial import

File size: 2.3 KB
RevLine 
[1]1"""Example of shallow water wave equation.
2
3This is called Netherlands because it shows a dam with a gap in it and
4stylised housed behind it and below the water surface.
5
6"""
7
8######################
9# Module imports
10#
11from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
12     Transmissive_boundary, Time_boundary, Constant_height
13
14from mesh_factory import from_polyfile
15from Numeric import array
16   
17
18print 'Creating domain'
19#points, triangles, values = from_polyfile('cornell_room_medres')
20points, triangles, values = from_polyfile('hires2')
21
22
23#Create shallow water domain
24domain = Domain(points, triangles)
25   
26domain.check_integrity()
27domain.default_order = 2
28domain.smooth = True
29domain.reduction = min  #Looks a lot better on top of steep slopes
30
31print "Number of triangles = ", len(domain)
32
33domain.visualise = False
34domain.checkpoint = False
35domain.store = True    #Store for visualisation purposes
36domain.format = 'sww'   #Native netcdf visualisation format
37import sys, os
38root, ext = os.path.splitext(sys.argv[0])
39if domain.smooth is True:
40    s = 'smooth'
41else:
42    s = 'nonsmooth'       
43domain.filename = root + '_' + s
44
45#Set bed-slope and friction
46manning = 0.0
47
48print 'Field values'
49domain.set_quantity('elevation', values)
50domain.set_quantity('friction', manning)
51
52
53######################
54# Boundary conditions
55#
56print 'Boundaries'
57Br = Reflective_boundary(domain)
58domain.set_boundary({'exterior': Br})
59
60                 
61
62######################
63#Initial condition
64#
65print 'Initial condition'
66
67#Define water height as a lump in one corner
68def height(x, y):
69    from Numeric import zeros, Float
70   
71    N = len(x)
72    assert N == len(y)   
73
74    xmin = min(x); xmax = max(x)
75    ymin = min(y); ymax = max(y)
76
77    xrange = xmax - xmin
78    yrange = ymax - ymin   
79
80    z = zeros(N, Float)
81    for i in range(N):
82        if x[i] <= xmin + 0.25*xrange and y[i] <= ymin + 0.25*yrange:
83            z[i] = 300
84
85    return z
86
87domain.set_quantity('level', height)
88
89E = domain.quantities['elevation'].vertex_values
90L = domain.quantities['level'].vertex_values
91domain.set_quantity('level', E+L)
92
93#Evolve
94for t in domain.evolve(yieldstep = 0.05, finaltime = 5.0):
95    domain.write_time()
96   
97
98   
Note: See TracBrowser for help on using the repository browser.