source: anuga_work/development/demos/island.py @ 5442

Last change on this file since 5442 was 5442, checked in by ole, 16 years ago

Retired h-limiter and beta_h as per ticket:194.
All unit tests and validation tests pass.

File size: 4.0 KB
Line 
1"""Example of shallow water wave equation.
2
3Island surrounded by water.
4This example investigates onshore 'creep'
5
6Creep is defined as water moving uphill over many timesteps.
7The initial adjustment at time = 0 is not 'creep'
8
9"""
10
11
12#------------------------------------------------------------------------------
13# Import necessary modules
14#------------------------------------------------------------------------------
15
16# Standard modules
17from math import exp
18
19# Application specific imports
20from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
21from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
22from anuga.pmesh.mesh_interface import create_mesh_from_regions
23from anuga.utilities.polygon import Polygon_function, read_polygon
24
25from anuga.abstract_2d_finite_volumes.quantity import Quantity
26from Numeric import allclose
27
28#------------------------------------------------------------------------------
29# Setup computational domain
30#------------------------------------------------------------------------------
31name = 'island'
32mesh_filename =  name + '.tsh'
33if True:
34    #Create basic mesh
35    create_mesh_from_regions( [[0,0], [100,0], [100,100], [0,100]],
36                              boundary_tags = {'bottom': [0],
37                                               'right': [1],
38                                               'top': [2],
39                                               'left': [3]},
40                              maximum_triangle_area = 2,
41                              filename =  mesh_filename,
42                              interior_regions=[ ([[50,25], [70,25], [70,75], [50,75]], 10.0)]
43                              #interior_holes=[[[50,25], [70,25], [70,75], [50,75]]],
44                              )
45
46
47
48
49
50# Select precomputed meshes here. In changeset:4725 there is a huge difference
51# in timestepping characteristics depending on the mesh used.
52# The mesh generated on windows takes 10 times as many timesteps.
53
54#Create shallow water domain
55domain = Domain(mesh_filename = mesh_filename)
56domain.smooth = False #True
57domain.set_name(name)
58#domain.set_name('island_not_unique')
59domain.default_order = 2
60
61print domain.statistics()
62
63
64#---------------------------
65# Combinations with less creep
66#---------------------------
67
68domain.maximum_allowed_speed = 0 
69domain.tight_slope_limiters = True
70
71
72
73#------------------------------------------------------------------------------
74# Setup initial conditions
75#------------------------------------------------------------------------------
76
77def island(x, y):
78    z = 0*x
79    for i in range(len(x)):
80        z[i] = 20*exp( -((x[i]-50)**2 + (y[i]-50)**2)/100 )
81
82        #z[i] += 0.5*exp( -((x[i]-10)**2 + (y[i]-10)**2)/50 )
83
84    return z
85
86def slump(x, y):
87    z = 0*x
88    for i in range(len(x)):
89        z[i] -= 0.7*exp( -((x[i]-10)**2 + (y[i]-10)**2)/200 )
90
91    return z
92
93stage_value = 10.0
94#domain.set_quantity('friction', 0.1)  #Honky dory
95domain.set_quantity('friction', 0.01)     #Creep
96domain.set_quantity('elevation', island)
97domain.set_quantity('stage', stage_value)
98domain.max_timestep = 0.01
99
100
101
102#------------------------------------------------------------------------------
103# Setup boundary conditions (all reflective)
104#------------------------------------------------------------------------------
105
106Br = Reflective_boundary(domain)
107Bd = Dirichlet_boundary([stage_value, 0, 0])
108
109domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd, 'exterior': Br})
110domain.check_integrity()
111
112#------------------------------------------------------------------------------
113# Evolve system through time
114#------------------------------------------------------------------------------
115
116import time
117for t in domain.evolve(yieldstep = 1, finaltime = 25):
118    domain.write_time()
119    #if allclose(t, 100):
120    #    Q = domain.get_quantity('stage')
121    #    Q_s = Quantity(domain)
122    #    Q_s.set_values(slump)
123    #    domain.set_quantity('stage', Q + Q_s)
124    #print '    Volume: ', domain.get_quantity('stage').get_integral()
125
126print 'Done'
Note: See TracBrowser for help on using the repository browser.