[699] | 1 | """Validation study of Merimbula lake using Pyvolution. |
---|
| 2 | Example of shallow water wave equation applied to |
---|
| 3 | Malpasset dam break simulation. |
---|
| 4 | |
---|
| 5 | Copyright 2004 |
---|
| 6 | Christopher Zoppou, Stephen Roberts |
---|
| 7 | Australian National University |
---|
| 8 | |
---|
| 9 | Specific methods pertaining to the 2D shallow water equation |
---|
| 10 | are imported from shallow_water |
---|
| 11 | for use with the generic finite volume framework |
---|
| 12 | |
---|
| 13 | Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the |
---|
| 14 | numerical vector named conserved_quantities. |
---|
| 15 | |
---|
| 16 | Existence of file 'Hobart_mesh.tsh' is assumed. |
---|
| 17 | """ |
---|
| 18 | |
---|
| 19 | ############################### |
---|
| 20 | # Setup Path and import modules |
---|
| 21 | import sys |
---|
| 22 | from os import sep, path |
---|
| 23 | sys.path.append('..'+sep+'pyvolution') |
---|
| 24 | |
---|
| 25 | from shallow_water import Domain, Reflective_boundary, File_boundary,\ |
---|
| 26 | Dirichlet_boundary, Transmissive_boundary, Constant_height |
---|
| 27 | from pmesh2domain import pmesh_to_domain_instance |
---|
| 28 | from util import inside_polygon, read_polygon |
---|
| 29 | |
---|
| 30 | ###################### |
---|
| 31 | # Domain |
---|
| 32 | filename = 'Hobart_mesh.tsh' |
---|
| 33 | yieldstep = 1 |
---|
| 34 | finaltime = 100 |
---|
| 35 | |
---|
| 36 | print 'Creating domain from', filename |
---|
| 37 | domain = pmesh_to_domain_instance(filename, Domain) |
---|
[700] | 38 | print 'Number of triangles = ', len(domain) |
---|
| 39 | print 'Extent = ', domain.get_extent() |
---|
[699] | 40 | |
---|
[700] | 41 | |
---|
[699] | 42 | domain.default_order = 1 |
---|
| 43 | domain.smooth = True |
---|
[1290] | 44 | domain.visualise = True |
---|
[699] | 45 | |
---|
[700] | 46 | |
---|
[699] | 47 | #------------------------------ |
---|
| 48 | # Boundary Conditions |
---|
| 49 | tags = {} |
---|
| 50 | tags['external'] = Reflective_boundary(domain) |
---|
| 51 | domain.set_boundary(tags) |
---|
| 52 | |
---|
| 53 | #----------------- |
---|
| 54 | #Initial condition |
---|
| 55 | # Throughout |
---|
[774] | 56 | domain.set_quantity('stage', 0.) |
---|
[699] | 57 | |
---|
| 58 | # Within polygon region |
---|
| 59 | # Set elevation to bed plus depth |
---|
| 60 | depth = 100. |
---|
| 61 | # Read polygon boundary |
---|
| 62 | p0 = read_polygon('Hobart_recent_source_zone.xya') |
---|
| 63 | # Get all centroid coordinates |
---|
| 64 | X = domain.get_centroid_coordinates() |
---|
| 65 | # Find triangle indices which are within polygon boundary only |
---|
[700] | 66 | indices = inside_polygon(X, p0) |
---|
[699] | 67 | # Get the bed elevation at the centroid of every triangle in polygon region |
---|
| 68 | |
---|
[700] | 69 | zp = 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] | 72 | domain.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 |
---|
| 88 | domain.store = True |
---|
| 89 | domain.format = 'sww' |
---|
| 90 | domain.filename = 'Hobart_first_order' |
---|
| 91 | |
---|
| 92 | #--------------------------------------------------------- |
---|
| 93 | #Decide which quantities are to be stored at each timestep |
---|
[774] | 94 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
[699] | 95 | |
---|
| 96 | #---------------------------- |
---|
| 97 | # Friction |
---|
| 98 | domain.set_quantity('friction', 0.05) |
---|
| 99 | |
---|
| 100 | ###################### |
---|
| 101 | #Evolution |
---|
| 102 | import time |
---|
| 103 | t0 = time.time() |
---|
| 104 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
| 105 | domain.write_time() |
---|
| 106 | |
---|
| 107 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
| 108 | |
---|
| 109 | |
---|