[2229] | 1 | """ |
---|
| 2 | Example of shallow water wave equation |
---|
| 3 | consisting of an asymetrical converging channel. |
---|
| 4 | |
---|
| 5 | Copyright 2004 |
---|
| 6 | Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray |
---|
| 7 | Geoscience Australia, ANU |
---|
| 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 | """ |
---|
| 17 | |
---|
| 18 | ###################### |
---|
| 19 | # Module imports |
---|
| 20 | # |
---|
| 21 | |
---|
| 22 | #Were these used? |
---|
| 23 | #import visualise2_chris as visualise |
---|
| 24 | #import Image, ImageGrab |
---|
| 25 | |
---|
| 26 | import sys |
---|
| 27 | from os import sep |
---|
| 28 | sys.path.append('..'+sep+'pyvolution') |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | from shallow_water import Domain, Constant_height |
---|
| 32 | from shallow_water import Transmissive_boundary, Reflective_boundary,\ |
---|
| 33 | Dirichlet_boundary |
---|
| 34 | |
---|
| 35 | from math import sqrt, cos, sin, pi |
---|
| 36 | from mesh_factory import oblique |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | ###################### |
---|
| 40 | # Domain |
---|
| 41 | # |
---|
| 42 | n = 60 |
---|
| 43 | m = 80 |
---|
| 44 | leny = 30. |
---|
| 45 | lenx = 40. |
---|
| 46 | n = 50 |
---|
| 47 | m = 60 |
---|
| 48 | |
---|
| 49 | points, elements, boundary = oblique(m, n, lenx, leny) |
---|
| 50 | domain = Domain(points, elements, boundary) |
---|
| 51 | |
---|
| 52 | # Order of solver |
---|
| 53 | domain.default_order=2 |
---|
| 54 | |
---|
| 55 | # Store output |
---|
| 56 | domain.store=True |
---|
| 57 | |
---|
| 58 | # Output format |
---|
| 59 | domain.format="sww" #NET.CDF binary format |
---|
| 60 | # "dat" for ASCII |
---|
| 61 | |
---|
| 62 | # Provide file name for storing output |
---|
| 63 | domain.filename="oblique" |
---|
| 64 | |
---|
| 65 | # Visualization smoothing |
---|
| 66 | domain.smooth=True |
---|
| 67 | domain.visualise=True |
---|
| 68 | |
---|
| 69 | ####################### |
---|
| 70 | #Bed-slope and friction |
---|
| 71 | def x_slope(x, y): |
---|
| 72 | return 0*x |
---|
| 73 | |
---|
| 74 | domain.set_quantity('elevation', x_slope) |
---|
| 75 | domain.set_quantity('friction', 0.0) |
---|
| 76 | |
---|
| 77 | ###################### |
---|
| 78 | # Boundary conditions |
---|
| 79 | # |
---|
| 80 | R = Reflective_boundary(domain) |
---|
| 81 | T = Transmissive_boundary(domain) |
---|
| 82 | D = Dirichlet_boundary([1.0, 8.57, 0.0]) |
---|
| 83 | |
---|
| 84 | domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R}) |
---|
| 85 | |
---|
| 86 | ###################### |
---|
| 87 | #Initial condition |
---|
| 88 | h = 0.5 |
---|
| 89 | domain.set_quantity('stage', Constant_height(x_slope, h) ) |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | ###################### |
---|
| 93 | #Evolution |
---|
| 94 | import time |
---|
| 95 | t0 = time.time() |
---|
| 96 | for t in domain.evolve(yieldstep = 0.5, finaltime = 50): |
---|
| 97 | domain.write_time() |
---|
| 98 | |
---|
| 99 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
| 100 | |
---|
| 101 | #FIXME: Compute average water depth on either side of shock and compare |
---|
| 102 | #to expected values. And also Froude numbers. |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | #print "saving file?" |
---|
| 106 | #im = ImageGrab.grab() |
---|
| 107 | #im.save("ccube.eps") |
---|
| 108 | |
---|
| 109 | |
---|