[453] | 1 | """Example of shallow water wave equation. |
---|
| 2 | |
---|
[483] | 3 | Generate slope |
---|
[453] | 4 | |
---|
| 5 | """ |
---|
| 6 | |
---|
| 7 | ###################### |
---|
| 8 | # Module imports |
---|
| 9 | # |
---|
| 10 | from mesh_factory import rectangular |
---|
| 11 | from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\ |
---|
[483] | 12 | Constant_height |
---|
[453] | 13 | from Numeric import array |
---|
| 14 | |
---|
| 15 | #Create basic mesh |
---|
[483] | 16 | N = 8 |
---|
[453] | 17 | points, vertices, boundary = rectangular(N, N) |
---|
| 18 | |
---|
| 19 | #Create shallow water domain |
---|
| 20 | domain = Domain(points, vertices, boundary) |
---|
| 21 | domain.smooth = False |
---|
[483] | 22 | domain.visualise = True |
---|
| 23 | domain.default_order=2 |
---|
[453] | 24 | |
---|
| 25 | |
---|
| 26 | ###################### |
---|
| 27 | # Boundary conditions |
---|
| 28 | Br = Reflective_boundary(domain) |
---|
| 29 | Bd = Dirichlet_boundary([0.2,0.,0.]) |
---|
| 30 | |
---|
[483] | 31 | domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
| 32 | |
---|
| 33 | |
---|
[453] | 34 | domain.check_integrity() |
---|
| 35 | |
---|
| 36 | ###################### |
---|
| 37 | #Evolution |
---|
[483] | 38 | #for t in domain.evolve(yieldstep = 0.05, finaltime = 1.): |
---|
| 39 | # domain.write_time() |
---|
[458] | 40 | |
---|
| 41 | |
---|
[483] | 42 | #import sys; sys.exit() |
---|
[458] | 43 | |
---|
[483] | 44 | ###################### |
---|
| 45 | #Evolution |
---|
| 46 | for t in domain.evolve(yieldstep = 0.01, finaltime = 0.03): |
---|
| 47 | domain.write_time() |
---|
[458] | 48 | |
---|
[483] | 49 | print domain.quantities['level'].centroid_values[:4] |
---|
| 50 | print domain.quantities['xmomentum'].centroid_values[:4] |
---|
| 51 | print domain.quantities['ymomentum'].centroid_values[:4] |
---|
| 52 | domain.distribute_to_vertices_and_edges() |
---|
| 53 | print |
---|
| 54 | print domain.quantities['level'].vertex_values[:4,0] |
---|
| 55 | print domain.quantities['xmomentum'].vertex_values[:4,0] |
---|
| 56 | print domain.quantities['ymomentum'].vertex_values[:4,0] |
---|