1 | """Example of shallow water wave equation. |
---|
2 | |
---|
3 | Island surrounded by water. |
---|
4 | This example investigates onshore 'creep' |
---|
5 | |
---|
6 | """ |
---|
7 | |
---|
8 | |
---|
9 | #------------------------------------------------------------------------------- |
---|
10 | # Import necessary modules |
---|
11 | #------------------------------------------------------------------------------- |
---|
12 | |
---|
13 | # Standard modules |
---|
14 | from math import exp |
---|
15 | |
---|
16 | # Application specific imports |
---|
17 | from pyvolution.mesh_factory import rectangular |
---|
18 | from pyvolution.shallow_water import Domain, Reflective_boundary |
---|
19 | from pmesh.mesh_interface import create_mesh_from_regions |
---|
20 | from utilities.polygon import Polygon_function, read_polygon |
---|
21 | |
---|
22 | |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | # Setup computational domain |
---|
25 | #------------------------------------------------------------------------------- |
---|
26 | |
---|
27 | #Create basic mesh |
---|
28 | N = 40 |
---|
29 | points, vertices, boundary = rectangular(N, N, 100, 100) |
---|
30 | |
---|
31 | |
---|
32 | create_mesh_from_regions( [[0,0], [100,0], [100,100], [0,100]], |
---|
33 | boundary_tags = {'bottom': [0], |
---|
34 | 'right': [1], |
---|
35 | 'top': [2], |
---|
36 | 'left': [3]}, |
---|
37 | maximum_triangle_area = 25, |
---|
38 | filename = 'island.msh', |
---|
39 | interior_regions=[ ([[55,25], [75,25], |
---|
40 | [75,75], [55,75]], 3)] |
---|
41 | ) |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | #Create shallow water domain |
---|
48 | #domain = Domain(points, vertices, boundary) |
---|
49 | domain = Domain(mesh_filename = 'island.msh') |
---|
50 | domain.smooth = False |
---|
51 | domain.set_name('island') |
---|
52 | domain.set_default_order(2) |
---|
53 | |
---|
54 | |
---|
55 | #I tried to introduce this parameter top control the h-limiter, |
---|
56 | #but it doesn't remove the 'lapping water' |
---|
57 | #NEW (ON): I think it has been fixed (or at least reduced significantly) now |
---|
58 | # |
---|
59 | # beta_h == 1.0 means that the largest gradients (on h) are allowed |
---|
60 | # beta_h == 0.0 means that constant (1st order) gradients are introduced |
---|
61 | # on h. This is equivalent to the constant depth used previously. |
---|
62 | domain.beta_h = 0.9 |
---|
63 | |
---|
64 | |
---|
65 | #------------------------------------------------------------------------------- |
---|
66 | # Setup initial conditions |
---|
67 | #------------------------------------------------------------------------------- |
---|
68 | |
---|
69 | def island(x, y): |
---|
70 | z = 0*x |
---|
71 | for i in range(len(x)): |
---|
72 | z[i] = 8*exp( -((x[i]-50)**2 + (y[i]-50)**2)/100 ) |
---|
73 | return z |
---|
74 | |
---|
75 | domain.set_quantity('friction', 0.0) |
---|
76 | domain.set_quantity('elevation', island) |
---|
77 | domain.set_quantity('stage', 1) |
---|
78 | |
---|
79 | |
---|
80 | #------------------------------------------------------------------------------- |
---|
81 | # Setup boundary conditions (all reflective) |
---|
82 | #------------------------------------------------------------------------------- |
---|
83 | |
---|
84 | Br = Reflective_boundary(domain) |
---|
85 | |
---|
86 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
87 | domain.check_integrity() |
---|
88 | |
---|
89 | |
---|
90 | #------------------------------------------------------------------------------- |
---|
91 | # Evolve system through time |
---|
92 | #------------------------------------------------------------------------------- |
---|
93 | |
---|
94 | import time |
---|
95 | for t in domain.evolve(yieldstep = 0.5, finaltime = 100): |
---|
96 | domain.write_time() |
---|
97 | |
---|
98 | print 'Done' |
---|