[2229] | 1 | """Example of shallow water wave equation analytical solution |
---|
| 2 | consists of a symmetrical converging frictionless channel. |
---|
| 3 | |
---|
| 4 | Specific methods pertaining to the 2D shallow water equation |
---|
| 5 | are imported from shallow_water |
---|
| 6 | for use with the generic finite volume framework |
---|
| 7 | |
---|
| 8 | Copyright 2005 |
---|
| 9 | Christopher Zoppou, Stephen Roberts |
---|
| 10 | ANU |
---|
| 11 | |
---|
| 12 | Specific methods pertaining to the 2D shallow water equation |
---|
| 13 | are imported from shallow_water |
---|
| 14 | for use with the generic finite volume framework |
---|
| 15 | |
---|
| 16 | Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the |
---|
| 17 | numerical vector named conserved_quantities. |
---|
| 18 | """ |
---|
| 19 | |
---|
| 20 | #--------------- |
---|
| 21 | # Module imports |
---|
| 22 | import sys |
---|
| 23 | from os import sep |
---|
| 24 | sys.path.append('..'+sep+'pyvolution') |
---|
| 25 | |
---|
| 26 | from shallow_water import Transmissive_boundary, Reflective_boundary, \ |
---|
| 27 | Dirichlet_boundary |
---|
| 28 | from shallow_water import Constant_height, Domain |
---|
| 29 | from pmesh2domain import pmesh_to_domain_instance |
---|
| 30 | |
---|
| 31 | #------- |
---|
| 32 | # Domain |
---|
| 33 | filename = 'converging_channel_30846.tsh' |
---|
| 34 | print 'Creating domain from', filename |
---|
| 35 | domain = pmesh_to_domain_instance(filename, Domain) |
---|
| 36 | print 'Number of triangles = ', len(domain) |
---|
| 37 | |
---|
| 38 | #---------------- |
---|
| 39 | # Order of scheme |
---|
| 40 | domain.default_order = 2 |
---|
| 41 | domain.smooth = True |
---|
| 42 | |
---|
| 43 | #------------------------------------- |
---|
| 44 | # Provide file name for storing output |
---|
| 45 | domain.store = True #Store for visualisation purposes |
---|
| 46 | domain.format = 'sww' #Native netcdf visualisation format |
---|
[3846] | 47 | domain.set_name('contracting_channel_second-order') |
---|
[2229] | 48 | |
---|
| 49 | #---------------------------------------------------------- |
---|
| 50 | # Decide which quantities are to be stored at each timestep |
---|
| 51 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
| 52 | |
---|
| 53 | #------------------------------------------ |
---|
| 54 | # Reduction operation for get_vertex_values |
---|
[3514] | 55 | #from anuga.pyvolution.util import mean |
---|
[2229] | 56 | #domain.reduction = mean |
---|
| 57 | |
---|
| 58 | #------------------------ |
---|
| 59 | # Set boundary Conditions |
---|
| 60 | tags = {} |
---|
| 61 | tags['upstream'] = Dirichlet_boundary([0.2, 1.2, 0.0]) |
---|
| 62 | tags['reflective'] = Reflective_boundary(domain) |
---|
| 63 | tags['transmissive'] = Transmissive_boundary(domain) |
---|
| 64 | domain.set_boundary(tags) |
---|
| 65 | |
---|
| 66 | #---------------------- |
---|
| 67 | # Set initial condition |
---|
| 68 | domain.set_quantity('elevation', 0.0) |
---|
| 69 | domain.set_quantity('stage', 0.2) |
---|
| 70 | |
---|
| 71 | #---------- |
---|
| 72 | # Evolution |
---|
| 73 | import time |
---|
| 74 | t0 = time.time() |
---|
| 75 | for t in domain.evolve(yieldstep = 0.1, finaltime = .2): |
---|
| 76 | domain.write_time() |
---|
| 77 | |
---|
| 78 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
| 79 | |
---|
| 80 | |
---|