source: inundation/ga/storm_surge/analytical solutions/Hobart.py @ 1353

Last change on this file since 1353 was 1290, checked in by steve, 20 years ago

visualisation stuff

File size: 3.1 KB
RevLine 
[699]1"""Validation study of Merimbula lake using Pyvolution.
2Example of shallow water wave equation applied to
3Malpasset dam break simulation.
4
5   Copyright 2004
6   Christopher Zoppou, Stephen Roberts
7   Australian National University
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
16Existence of file 'Hobart_mesh.tsh' is assumed.
17"""
18
19###############################
20# Setup Path and import modules
21import sys
22from os import sep, path
23sys.path.append('..'+sep+'pyvolution')
24
25from shallow_water import Domain, Reflective_boundary, File_boundary,\
26     Dirichlet_boundary, Transmissive_boundary, Constant_height
27from pmesh2domain import pmesh_to_domain_instance
28from util import inside_polygon, read_polygon
29
30######################
31# Domain
32filename = 'Hobart_mesh.tsh'
33yieldstep = 1
34finaltime = 100
35   
36print 'Creating domain from', filename
37domain = pmesh_to_domain_instance(filename, Domain)
[700]38print 'Number of triangles = ', len(domain)
39print 'Extent = ', domain.get_extent()
[699]40
[700]41
[699]42domain.default_order = 1
43domain.smooth = True
[1290]44domain.visualise = True
[699]45
[700]46
[699]47#------------------------------
48# Boundary Conditions
49tags = {}
50tags['external'] = Reflective_boundary(domain) 
51domain.set_boundary(tags)
52
53#-----------------
54#Initial condition
55#   Throughout
[774]56domain.set_quantity('stage', 0.)
[699]57
58#    Within polygon region
59#        Set elevation to bed plus depth
60depth = 100.
61#        Read polygon boundary
62p0 = read_polygon('Hobart_recent_source_zone.xya')
63#        Get all centroid coordinates
64X = domain.get_centroid_coordinates()
65#        Find triangle indices which are within polygon boundary only
[700]66indices = inside_polygon(X, p0)
[699]67#        Get the bed elevation at the centroid of every triangle in polygon region
68
[700]69zp = domain.get_quantity('elevation', location='centroids', indexes=indices)
[774]70#        Set the stage to bed elevation plus depth for all triangle vertices in the polygon region
[700]71
[774]72domain.set_quantity('stage', zp+depth, location='centroids', indexes=indices) 
[700]73
74
75#Alternative way which also works (I used it for testing - OMN)
76#
77
78#z = domain.get_quantity('elevation')
79#from copy import copy
80#w = copy(z)
81#for i in indices:
82#    w[i, :] = z[i, :] + depth
[774]83#domain.set_quantity('stage', w)
[700]84
85
[699]86#-------------------------------------
87# Provide file name for storing output
88domain.store = True
89domain.format = 'sww'
90domain.filename = 'Hobart_first_order'
91
92#---------------------------------------------------------
93#Decide which quantities are to be stored at each timestep
[774]94domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
[699]95
96#----------------------------
97# Friction
98domain.set_quantity('friction', 0.05)
99         
100######################
101#Evolution
102import time
103t0 = time.time()
104for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
105    domain.write_time()
106   
107print 'That took %.2f seconds' %(time.time()-t0)
108
109   
Note: See TracBrowser for help on using the repository browser.