source: anuga_work/development/demos/twolevels.py @ 6671

Last change on this file since 6671 was 5439, checked in by ole, 17 years ago

Updated 'two_levels' example to show that tight_slope_limiters take care of upwards momentum or 'creep'. This used to be treated with the h-limiter with beta_h > 0 but this is no longer needed.

File size: 1.9 KB
Line 
1"""Example of shallow water wave equation.
2
3Two levels - testing that momentum is not genearted in the upward direction
4
5"""
6
7######################
8# Module imports
9#
10from os import sep, path
11from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
12from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
13from Numeric import array
14from anuga.utilities.polygon import Polygon_function, read_polygon
15
16
17#Create basic mesh
18N = 2
19points, vertices, boundary = rectangular(3, N, 20, 10)
20
21#Create shallow water domain
22domain = Domain(points, vertices, boundary)
23domain.store = True
24domain.set_name('two_levels')
25print "Output being written to " + domain.get_datadir() + sep + \
26              domain.get_name() + "_size%d." %len(domain) + domain.format
27       
28
29domain.default_order=2
30domain.smooth = False
31
32#PLAY WITH THIS [0;1]:
33#
34# To reveal the problem set
35# domain.tight_slope_limiters = False
36domain.tight_slope_limiters = False
37# To fix it set
38#domain.tight_slope_limiters = True
39domain.tight_slope_limiters = True
40
41
42#IC
43domain.set_quantity('friction', 0.0)
44domain.set_quantity('stage', 3.0)
45
46def twostage(x, y): 
47    z = 0*x     
48    for i in range(len(x)):             
49        if x[i]<10:     
50            z[i] = 4.
51
52    return z                   
53#Set elevation 
54domain.set_quantity('elevation', twostage)
55
56
57######################
58# Boundary conditions
59Br = Reflective_boundary(domain)
60
61domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
62domain.check_integrity()
63
64
65#print domain.quantities['elevation'].vertex_values   
66######################
67#Evolution
68for t in domain.evolve(yieldstep = 0.01, finaltime = 0.05):
69    domain.write_time()
70    print domain.quantities['xmomentum'].edge_values   
71    #print domain.quantities['stage'].centroid_values   
72
73#print domain.quantities['stage'].vertex_values
74#print
75#print domain.quantities['xmomentum'].vertex_values
76#print
77#print domain.quantities['ymomentum'].vertex_values
78   
79print 'Done'   
80
Note: See TracBrowser for help on using the repository browser.