[901] | 1 | """Example of shallow water wave equation. |
---|
| 2 | |
---|
| 3 | Two levels - testing that momentum is not genearted in the upward direction |
---|
| 4 | |
---|
| 5 | """ |
---|
| 6 | |
---|
| 7 | ###################### |
---|
| 8 | # Module imports |
---|
| 9 | # |
---|
| 10 | from os import sep, path |
---|
[5439] | 11 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular |
---|
| 12 | from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary |
---|
[901] | 13 | from Numeric import array |
---|
[5439] | 14 | from anuga.utilities.polygon import Polygon_function, read_polygon |
---|
[901] | 15 | |
---|
| 16 | |
---|
| 17 | #Create basic mesh |
---|
| 18 | N = 2 |
---|
| 19 | points, vertices, boundary = rectangular(3, N, 20, 10) |
---|
| 20 | |
---|
| 21 | #Create shallow water domain |
---|
| 22 | domain = Domain(points, vertices, boundary) |
---|
| 23 | domain.store = True |
---|
| 24 | domain.set_name('two_levels') |
---|
| 25 | print "Output being written to " + domain.get_datadir() + sep + \ |
---|
[3846] | 26 | domain.get_name() + "_size%d." %len(domain) + domain.format |
---|
[901] | 27 | |
---|
| 28 | |
---|
| 29 | domain.default_order=2 |
---|
| 30 | domain.smooth = False |
---|
| 31 | |
---|
[911] | 32 | #PLAY WITH THIS [0;1]: |
---|
| 33 | # |
---|
[5439] | 34 | # To reveal the problem set |
---|
| 35 | # domain.tight_slope_limiters = False |
---|
| 36 | domain.tight_slope_limiters = False |
---|
| 37 | # To fix it set |
---|
| 38 | #domain.tight_slope_limiters = True |
---|
| 39 | domain.tight_slope_limiters = True |
---|
[911] | 40 | |
---|
[5439] | 41 | |
---|
[901] | 42 | #IC |
---|
| 43 | domain.set_quantity('friction', 0.0) |
---|
| 44 | domain.set_quantity('stage', 3.0) |
---|
| 45 | |
---|
| 46 | def twostage(x, y): |
---|
| 47 | z = 0*x |
---|
| 48 | for i in range(len(x)): |
---|
| 49 | if x[i]<10: |
---|
| 50 | z[i] = 4. |
---|
| 51 | |
---|
| 52 | return z |
---|
| 53 | #Set elevation |
---|
| 54 | domain.set_quantity('elevation', twostage) |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | ###################### |
---|
| 58 | # Boundary conditions |
---|
| 59 | Br = Reflective_boundary(domain) |
---|
| 60 | |
---|
| 61 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
| 62 | domain.check_integrity() |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | #print domain.quantities['elevation'].vertex_values |
---|
| 66 | ###################### |
---|
| 67 | #Evolution |
---|
| 68 | for t in domain.evolve(yieldstep = 0.01, finaltime = 0.05): |
---|
| 69 | domain.write_time() |
---|
| 70 | print domain.quantities['xmomentum'].edge_values |
---|
| 71 | #print domain.quantities['stage'].centroid_values |
---|
| 72 | |
---|
| 73 | #print domain.quantities['stage'].vertex_values |
---|
| 74 | #print |
---|
| 75 | #print domain.quantities['xmomentum'].vertex_values |
---|
| 76 | #print |
---|
| 77 | #print domain.quantities['ymomentum'].vertex_values |
---|
| 78 | |
---|
| 79 | print 'Done' |
---|
| 80 | |
---|