source: trunk/anuga_work/development/gareth/tests/dam_break/dam_break.py @ 9358

Last change on this file since 9358 was 9292, checked in by davies, 11 years ago

Adding local extrapolation and flux updating

File size: 3.9 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
12#from anuga import Domain as Domain
13from math import cos
14from numpy import zeros, float
15from time import localtime, strftime, gmtime
16#from bal_and import *
17#from anuga_tsunami import *
18
19
20#-------------------------------------------------------------------------------
21# Copy scripts to time stamped output directory and capture screen
22# output to file
23#-------------------------------------------------------------------------------
24time = strftime('%Y%m%d_%H%M%S',localtime())
25
26output_dir = 'dam_break_'+time
27output_file = 'dam_break'
28
29#anuga.copy_code_files(output_dir,__file__)
30#start_screen_catcher(output_dir+'_')
31
32
33#------------------------------------------------------------------------------
34# Setup domain
35#------------------------------------------------------------------------------
36dx = 1000.
37dy = dx
38L = 100000.
39W = 10*dx
40
41# structured mesh
42points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, -W/2))
43
44domain = anuga.Domain(points, vertices, boundary) 
45#domain = Domain(points, vertices, boundary)
46
47domain.set_name(output_file)               
48domain.set_datadir(output_dir) 
49
50#------------------------------------------------------------------------------
51# Setup Algorithm
52#------------------------------------------------------------------------------
53#domain.set_timestepping_method('rk2')
54#domain.set_default_order(2)
55
56print domain.get_timestepping_method()
57
58domain.set_flow_algorithm('DE0')
59#domain.set_local_extrapolation_and_flux_updating(nlevels=8)
60#domain.use_edge_limiter = True
61#domain.use_edge_limiter = False
62#domain.tight_slope_limiters = True
63#domain.use_centroid_velocities = False
64
65#domain.CFL = 1.0
66
67#domain.beta_w      = 0.6
68#domain.beta_uh     = 0.6
69#domain.beta_vh     = 0.6
70
71
72#------------------------------------------------------------------------------
73# Setup initial conditions
74#------------------------------------------------------------------------------
75domain.set_quantity('elevation',0.0)
76domain.set_quantity('friction', 0.0)
77
78h0 = 10000.0
79h1 = 1.0
80
81def height(x,y):
82    z = zeros(len(x), float)
83    for i in range(len(x)):
84        if x[i]<=50000.0:
85            z[i] = h0
86        else:
87            z[i] = h1
88    return z
89domain.set_quantity('stage', height)
90
91#-----------------------------------------------------------------------------
92# Setup boundary conditions
93#------------------------------------------------------------------------------
94from math import sin, pi, exp
95Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
96Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary
97Bd = anuga.Dirichlet_boundary([1,0.,0.]) # Constant boundary values
98
99# Associate boundary tags with boundary objects
100domain.set_boundary({'left': Bt, 'right': Bt, 'top': Br, 'bottom': Br})
101
102
103#===============================================================================
104##from anuga.visualiser import RealtimeVisualiser
105##vis = RealtimeVisualiser(domain)
106##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
107##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
108##vis.start()
109#===============================================================================
110
111
112#------------------------------------------------------------------------------
113# Evolve system through time
114#------------------------------------------------------------------------------
115for t in domain.evolve(yieldstep = 1.0, finaltime = 10*10.):
116    #print domain.timestepping_statistics(track_speeds=True)
117    print domain.timestepping_statistics()
118    #vis.update()
119
120
121#test against know data
122   
123#vis.evolveFinished()
124
Note: See TracBrowser for help on using the repository browser.