[2229] | 1 | """Example of the use of the shallow water wave equation |
---|
| 2 | to simulate a bomb blast in an urban area. |
---|
| 3 | |
---|
| 4 | Copyright 2004 |
---|
| 5 | Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray |
---|
| 6 | Geoscience Australia |
---|
| 7 | |
---|
| 8 | """ |
---|
| 9 | |
---|
| 10 | ############################### |
---|
| 11 | # Setup Path and import modules |
---|
| 12 | import sys |
---|
| 13 | from os import sep, path |
---|
| 14 | sys.path.append('..'+sep+'pyvolution') |
---|
| 15 | |
---|
| 16 | from shallow_water import Domain, Reflective_boundary, File_boundary,\ |
---|
| 17 | Dirichlet_boundary, Transmissive_boundary |
---|
| 18 | from pmesh2domain import pmesh_to_domain_instance |
---|
| 19 | from util import Polygon_function,read_polygon |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | ###################### |
---|
| 23 | # Domain |
---|
| 24 | filename = 'sydney_ubd.tsh' |
---|
| 25 | print 'Creating domain from', filename |
---|
| 26 | domain = pmesh_to_domain_instance(filename, Domain) |
---|
| 27 | print 'Number of triangles = ', len(domain) |
---|
| 28 | |
---|
| 29 | domain.default_order = 2 |
---|
| 30 | domain.smooth = True |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | # Provide file name for storing output |
---|
| 34 | domain.store = True |
---|
| 35 | domain.format = 'sww' |
---|
| 36 | domain.filename = 'sydney_ubd_again' |
---|
| 37 | |
---|
| 38 | #Reduction operation for get_vertex_values |
---|
| 39 | from util import mean |
---|
| 40 | domain.reduction = mean |
---|
| 41 | #domain.reduction = min #Looks better near steep slopes |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | ###################### |
---|
| 45 | #Initial condition |
---|
| 46 | # |
---|
| 47 | print 'Initial condition' |
---|
| 48 | |
---|
| 49 | #Set bed-elevation and friction(None) |
---|
| 50 | def x_slope(x,y): |
---|
| 51 | n = x.shape[0] |
---|
| 52 | z = 0*x |
---|
| 53 | return z |
---|
| 54 | |
---|
| 55 | domain.set_quantity('elevation', x_slope) |
---|
| 56 | |
---|
| 57 | #Set the initial water stage |
---|
| 58 | def stage(x,y): |
---|
| 59 | z = x_slope(x,y) |
---|
| 60 | n = x.shape[0] |
---|
| 61 | h = 0*x |
---|
| 62 | return h |
---|
| 63 | |
---|
| 64 | domain.set_quantity('stage', stage) |
---|
| 65 | p0 = [[334429.024416, 6251238.11488],[334428.532417, 6251234.42489], |
---|
| 66 | [334432.468407, 6251233.93289],[334431.730409, 6251238.36088]] |
---|
| 67 | domain.set_quantity('stage',Polygon_function([(p0,10000.0)])) |
---|
| 68 | |
---|
| 69 | ############ |
---|
| 70 | #Boundary |
---|
| 71 | tags = {} |
---|
| 72 | tags['external'] = Transmissive_boundary(domain) |
---|
| 73 | tags[''] = None |
---|
| 74 | domain.set_boundary(tags) |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | ###################### |
---|
| 78 | #Evolution |
---|
| 79 | import time |
---|
| 80 | t0 = time.time() |
---|
| 81 | for t in domain.evolve(yieldstep = 0.1, finaltime = 5): |
---|
| 82 | domain.write_time() |
---|
| 83 | |
---|
| 84 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
| 85 | |
---|
| 86 | |
---|