source: anuga_core/source/anuga/examples/island.py @ 4445

Last change on this file since 4445 was 4445, checked in by duncan, 17 years ago

changed to run faster

File size: 4.0 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 anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
18from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
19from anuga.pmesh.mesh_interface import create_mesh_from_regions
20from anuga.utilities.polygon import Polygon_function, read_polygon
21
22from anuga.abstract_2d_finite_volumes.quantity import Quantity
23from Numeric import allclose
24
25#------------------------------------------------------------------------------
26# Setup computational domain
27#------------------------------------------------------------------------------
28
29#Create basic mesh
30create_mesh_from_regions( [[0,0], [100,0], [100,100], [0,100]],
31                          boundary_tags = {'bottom': [0],
32                                           'right': [1],
33                                           'top': [2],
34                                           'left': [3]},
35                          maximum_triangle_area = 5,
36                          filename = 'island.msh' ,
37                          interior_regions=[ ([[50,25], [70,25], [70,75], [50,75]], 10.0)]
38                          #interior_holes=[[[50,25], [70,25], [70,75], [50,75]]],
39                          )
40
41
42
43#Create shallow water domain
44domain = Domain(mesh_filename = 'island.msh')
45domain.smooth = False #True
46domain.set_name('island_unique')
47#domain.set_name('island_not_unique')
48domain.default_order = 2
49
50
51#I tried to introduce this parameter top control the h-limiter,
52#but it doesn't remove the 'lapping water'
53#NEW (ON): I think it has been fixed (or at least reduced significantly) now
54#
55# beta_h == 1.0 means that the largest gradients (on h) are allowed
56# beta_h == 0.0 means that constant (1st order) gradients are introduced
57# on h. This is equivalent to the constant depth used previously.
58#domain.beta_h     = 0.5
59#domain.beta_w_dry = 0.0
60#domain.alpha_balance = 10.0
61#domain.minimum_allowed_height = 1.0e-4
62#domain.maximum_allowed_speed = 100.0
63#domain.minimum_storable_height = 1.0e-4
64
65domain.beta_h     = 0.0
66domain.limit2007 = 1
67
68#------------------------------------------------------------------------------
69# Setup initial conditions
70#------------------------------------------------------------------------------
71
72def island(x, y):
73    z = 0*x
74    for i in range(len(x)):
75        z[i] = 20*exp( -((x[i]-50)**2 + (y[i]-50)**2)/100 )
76
77        #z[i] += 0.5*exp( -((x[i]-10)**2 + (y[i]-10)**2)/50 )
78
79    return z
80
81def slump(x, y):
82    z = 0*x
83    for i in range(len(x)):
84        z[i] -= 0.7*exp( -((x[i]-10)**2 + (y[i]-10)**2)/200 )
85
86    return z
87
88stage_value = 15.0
89#domain.set_quantity('friction', 0.1)  #Honky dory
90domain.set_quantity('friction', 0.01)     #Creep
91domain.set_quantity('elevation', island)
92domain.set_quantity('stage', stage_value)
93domain.max_timestep = 0.01
94
95
96
97#------------------------------------------------------------------------------
98# Setup boundary conditions (all reflective)
99#------------------------------------------------------------------------------
100
101Br = Reflective_boundary(domain)
102Bd = Dirichlet_boundary([stage_value, 0, 0])
103
104domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd, 'exterior': Br})
105domain.check_integrity()
106
107#------------------------------------------------------------------------------
108# Evolve system through time
109#------------------------------------------------------------------------------
110
111import time
112for t in domain.evolve(yieldstep = 1, finaltime = 5):
113    domain.write_time()
114    #if allclose(t, 100):
115    #    Q = domain.get_quantity('stage')
116    #    Q_s = Quantity(domain)
117    #    Q_s.set_values(slump)
118    #    domain.set_quantity('stage', Q + Q_s)
119    #print '    Volume: ', domain.get_quantity('stage').get_integral()
120
121print 'Done'
Note: See TracBrowser for help on using the repository browser.