source: anuga_validation/convergence_study/convergence_structured.py @ 4838

Last change on this file since 4838 was 4838, checked in by steve, 16 years ago

Changed exception in fit_interpolation from ToFewPointsError? to
TooFewPointsError?

File size: 4.7 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#------------------------------------------------------------------------------
10
11import sys
12from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
13from anuga.shallow_water import Domain
14from anuga.shallow_water import Reflective_boundary
15from anuga.shallow_water import Dirichlet_boundary
16from anuga.shallow_water import Time_boundary
17from anuga.shallow_water import Transmissive_boundary
18from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary
19from anuga.geospatial_data.geospatial_data import *
20from math import cos
21
22#------------------------------------------------------------------------------
23# Setup computational domain
24#------------------------------------------------------------------------------
25dx = 100.
26dy = dx
27L = 100000.
28W = dx
29
30# structured mesh
31points, vertices, boundary = rectangular_cross(int(L/dx), int(W/dy),
32                                               L, W, (0.0, -W/2)) # Basic mesh
33#points, vertices, boundary = rectangular_cross(666, 3, 100000, 3000, (0.0, -0.0)) # Basic mesh
34#points, vertices, boundary = rectangular_cross(530, 10, 5300, 100, (-5000.0, -50.0)) # Basic mesh
35#points, vertices, boundary = rectangular_cross(1000, 100, 20, 3) # Basic mesh
36domain = Domain(points, vertices, boundary) 
37
38
39## # unstructured mesh
40## poly_domain = [[0,-W],[0,W],[L,W],[L,-W]]
41## meshname = 'test.msh'
42## from anuga.pmesh.mesh_interface import create_mesh_from_regions
43## # Create mesh
44## create_mesh_from_regions(poly_domain,
45##                          boundary_tags={'left': [0], 'top': [1],
46##                                         'right': [2], 'bottom': [3]},
47##                          maximum_triangle_area = 1000,
48##                          filename=meshname)
49
50## # Create domain
51## domain = Domain(meshname, use_cache=True, verbose = True)
52
53domain.set_timestepping_method('euler')
54domain.set_default_order(2)
55domain.set_name('myexample9')               
56domain.set_datadir('.')                     # Use current directory for output
57
58domain.beta_w      = 100.0
59domain.beta_w_dry  = 0.2
60domain.beta_uh     = 100.0
61domain.beta_uh_dry = 0.2
62domain.beta_vh     = 100.0
63domain.beta_vh_dry = 0.2
64domain.beta_h      = 100.0
65
66#------------------------------------------------------------------------------
67# Setup initial conditions
68#------------------------------------------------------------------------------
69#domain.set_quantity('elevation', topography) # Use function for elevation
70domain.set_quantity('elevation',-100)
71domain.set_quantity('friction', 0.00)
72domain.set_quantity('stage', 0.0)           
73
74#-----------------------------------------------------------------------------
75# Setup boundary conditions
76#------------------------------------------------------------------------------
77from math import sin, pi, exp
78Br = Reflective_boundary(domain)      # Solid reflective wall
79Bt = Transmissive_boundary(domain)    # Continue all values on boundary
80Bd = Dirichlet_boundary([1,0.,0.]) # Constant boundary values
81amplitude = 1
82#Bw = Transmissive_Momentum_Set_Stage_boundary(domain=domain,
83Bw = Time_boundary(domain=domain,     # Time dependent boundary 
84## Sine wave
85                   f=lambda t: [(-amplitude*sin((1./300.)*t*2*pi)), 0.0, 0.0])
86## Sawtooth?
87#                   f=lambda t: [(-8.0*(sin((1./180.)*t*2*pi))+(1./2.)*sin((2./180.)*t*2*pi)+(1./3.)*sin((3./180.)*t*2*pi)), 0.0, 0.0])
88## Sharp rise, linear fall
89#                   f=lambda t: [(5.0*(-((t-0.)/300.)*(t<300.)-cos((t-300.)*2.*pi*(1./240.))*(t>=300. and t<420.)+(1.-(t-420.)/300.)*(t>=420. and t <720.))), 0.0, 0.0])
90#                   f=lambda t: [amplitude*(1.-2.*(pi*(1./720.)*(t-720.))**2)/exp((pi*(1./720.)*(t-720.))**2) , 0.0, 0.0])
91#                   f=lambda t: [(-8.0*sin((1./720.)*t*2*pi))*((t<720.)-0.5*(t<360.)), 0.0, 0.0])
92
93# Associate boundary tags with boundary objects
94domain.set_boundary({'left': Bw, 'right': Bt, 'top': Br, 'bottom': Br})
95
96## from anuga.visualiser import RealtimeVisualiser
97## vis = RealtimeVisualiser(domain)
98## vis.render_quantity_height("elevation", dynamic=False)
99## vis.render_quantity_height("stage", dynamic=True, zScale=100.0)
100## #vis.colour_height_quantity('stage', (0.0, 0.0, 0.8))
101## vis.colour_height_quantity('stage', (lambda q:q['stage'], -1, 1))
102## vis.start()
103
104#------------------------------------------------------------------------------
105# Evolve system through time
106#------------------------------------------------------------------------------
107
108for t in domain.evolve(yieldstep = 20.0, finaltime = 40*60.):
109    domain.write_time()
110    #vis.update()
111   
112#vis.evolveFinished()
113#vis.join()
Note: See TracBrowser for help on using the repository browser.