source: inundation/examples/island.py @ 2621

Last change on this file since 2621 was 2621, checked in by ole, 18 years ago

Comments

File size: 3.2 KB
Line 
1"""Example of shallow water wave equation.
2
3Island surrounded by water.
4This example investigates onshore 'creep'
5
6"""
7
8
9#-------------------------------------------------------------------------------
10# Import necessary modules
11#-------------------------------------------------------------------------------
12
13# Standard modules
14from math import exp
15
16# Application specific imports
17from pyvolution.mesh_factory import rectangular
18from pyvolution.shallow_water import Domain, Reflective_boundary
19from pmesh.mesh_interface import create_mesh_from_regions
20from utilities.polygon import Polygon_function, read_polygon
21
22
23#-------------------------------------------------------------------------------   
24# Setup computational domain
25#-------------------------------------------------------------------------------
26
27#Create basic mesh
28N = 40
29points, vertices, boundary = rectangular(N, N, 100, 100)
30
31
32create_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)
49domain = Domain(mesh_filename = 'island.msh')
50domain.smooth = False
51domain.set_name('island')
52domain.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.
62domain.beta_h = 0.9
63
64
65#-------------------------------------------------------------------------------
66# Setup initial conditions
67#-------------------------------------------------------------------------------
68
69def 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
75domain.set_quantity('friction', 0.0)
76domain.set_quantity('elevation', island)
77domain.set_quantity('stage', 1)
78
79
80#-------------------------------------------------------------------------------
81# Setup boundary conditions (all reflective)
82#-------------------------------------------------------------------------------
83
84Br = Reflective_boundary(domain)
85
86domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
87domain.check_integrity()
88
89
90#-------------------------------------------------------------------------------
91# Evolve system through time
92#-------------------------------------------------------------------------------
93
94import time
95for t in domain.evolve(yieldstep = 0.5, finaltime = 100):
96    domain.write_time()
97
98print 'Done'
Note: See TracBrowser for help on using the repository browser.