source: trunk/anuga_validation/validation_tests/circular_dam_break.py @ 8538

Last change on this file since 8538 was 8212, checked in by steve, 14 years ago

Committing Sudi's changes

File size: 3.3 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water driven up a linear slope and time varying boundary,
4similar to a beach environment
5"""
6
7#------------------------------------------------------------------------------
8# Import necessary modules
9#------------------------------------------------------------------------------
10import sys
11import anuga
12from math import cos
13from numpy import zeros, float
14from time import localtime, strftime, gmtime
15
16
17
18#-------------------------------------------------------------------------------
19# Copy scripts to time stamped output directory and capture screen
20# output to file
21#-------------------------------------------------------------------------------
22time = strftime('%Y%m%d_%H%M%S',localtime())
23
24output_dir = 'circular_dam_break_'+time
25output_file = 'circular_dam_break'
26
27#anuga.copy_code_files(output_dir,__file__)
28#start_screen_catcher(output_dir+'_')
29
30
31#------------------------------------------------------------------------------
32# Setup domain
33#------------------------------------------------------------------------------
34dx = 1.
35dy = dx
36L = 100.
37W = L
38
39# structured mesh
40points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (-L/2.0, -W/2.0))
41
42domain = anuga.Domain(points, vertices, boundary) 
43
44domain.set_name(output_file)               
45domain.set_datadir(output_dir) 
46
47#------------------------------------------------------------------------------
48# Setup Algorithm
49#------------------------------------------------------------------------------
50domain.set_timestepping_method('rk2')
51domain.set_default_order(2)
52
53print domain.get_timestepping_method()
54
55#------------------------------------------------------------------------------
56# Setup initial conditions
57#------------------------------------------------------------------------------
58domain.set_quantity('elevation',0.0)
59domain.set_quantity('friction', 0.0)
60
61h0 = 10.0
62h1 = 1.0
63radius = 10.0
64
65def height(x,y):
66    z = zeros(len(x), float)
67    r2 = radius**2
68    for i in range(len(x)):
69        rad2 = x[i]**2 + y[i]**2
70
71        if rad2 <= r2:
72            z[i] = h0
73        else:
74            z[i] = h1
75    return z
76
77domain.set_quantity('stage', height)
78
79#-----------------------------------------------------------------------------
80# Setup boundary conditions
81#------------------------------------------------------------------------------
82Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
83
84
85
86# Associate boundary tags with boundary objects
87domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
88
89
90#===============================================================================
91##from anuga.visualiser import RealtimeVisualiser
92##vis = RealtimeVisualiser(domain)
93##vis.render_quantity_height("stage", zScale =h0, dynamic=True)
94##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
95##vis.start()
96#===============================================================================
97print "Evolving...."
98
99#------------------------------------------------------------------------------
100# Evolve system through time
101#------------------------------------------------------------------------------
102
103for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0):
104    #print domain.timestepping_statistics(track_speeds=True)
105    print domain.timestepping_statistics()
106##    vis.update()
107
108
109#test against know data
110   
111##vis.evolveFinished()
112
Note: See TracBrowser for help on using the repository browser.