source: anuga_core/source/anuga/examples/twolevels.py @ 4243

Last change on this file since 4243 was 4026, checked in by jack, 18 years ago

Moved the vpython visualiser to obsolete_code and cleared out things that call it from other code.

File size: 1.8 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 mesh_factory import rectangular
12from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
13     Constant_height
14from Numeric import array
15from anuga.pyvolution.util import Polygon_function, read_polygon
16
17
18#Create basic mesh
19N = 2
20points, vertices, boundary = rectangular(3, N, 20, 10)
21
22#Create shallow water domain
23domain = Domain(points, vertices, boundary)
24domain.store = True
25domain.set_name('two_levels')
26print "Output being written to " + domain.get_datadir() + sep + \
27              domain.get_name() + "_size%d." %len(domain) + domain.format
28       
29
30domain.default_order=2
31domain.smooth = False
32
33#PLAY WITH THIS [0;1]:
34#
35# beta_h == 0.0 reveals the problem
36# beta_h > 0.2 alleviates it
37domain.beta_h = 0.2   
38
39#IC
40domain.set_quantity('friction', 0.0)
41domain.set_quantity('stage', 3.0)
42
43def twostage(x, y): 
44    z = 0*x     
45    for i in range(len(x)):             
46        if x[i]<10:     
47            z[i] = 4.
48
49    return z                   
50#Set elevation 
51domain.set_quantity('elevation', twostage)
52
53
54######################
55# Boundary conditions
56Br = Reflective_boundary(domain)
57
58domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
59domain.check_integrity()
60
61
62#print domain.quantities['elevation'].vertex_values   
63######################
64#Evolution
65for t in domain.evolve(yieldstep = 0.01, finaltime = 0.05):
66    domain.write_time()
67    print domain.quantities['xmomentum'].edge_values   
68    #print domain.quantities['stage'].centroid_values   
69
70#print domain.quantities['stage'].vertex_values
71#print
72#print domain.quantities['xmomentum'].vertex_values
73#print
74#print domain.quantities['ymomentum'].vertex_values
75   
76print 'Done'   
77
Note: See TracBrowser for help on using the repository browser.