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