source: trunk/anuga_validation/convergence_study/convergence.py @ 7877

Last change on this file since 7877 was 4715, checked in by ole, 17 years ago

Work on Will's convergence problem

File size: 4.1 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 = 10.
26dy = dx
27L = 100000.
28W = 3000.
29
30# structured mesh
31#points, 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
36#domain = Domain(points, vertices, boundary)
37
38# unstructured mesh
39poly_domain = [[0,-W],[0,W],[L,W],[L,-W]]
40meshname = 'test.msh'
41from anuga.pmesh.mesh_interface import create_mesh_from_regions
42# Create mesh
43create_mesh_from_regions(poly_domain,
44                         boundary_tags={'left': [0], 'top': [1],
45                                        'right': [2], 'bottom': [3]},
46                         maximum_triangle_area = 100000,
47                         filename=meshname)
48
49# Create domain
50domain = Domain(meshname, use_cache=True, verbose = True)
51domain.set_name('myexample2')               
52domain.set_default_order(2) # Use second order spatial scheme
53domain.set_datadir('.')                     # Use current directory for output
54
55#------------------------------------------------------------------------------
56# Setup initial conditions
57#------------------------------------------------------------------------------
58#domain.set_quantity('elevation', topography) # Use function for elevation
59domain.set_quantity('elevation', -100)
60domain.set_quantity('friction', 0.00)
61domain.set_quantity('stage', 0.0)           
62
63#-----------------------------------------------------------------------------
64# Setup boundary conditions
65#------------------------------------------------------------------------------
66from math import sin, pi, exp
67Br = Reflective_boundary(domain)      # Solid reflective wall
68Bt = Transmissive_boundary(domain)    # Continue all values on boundary
69Bd = Dirichlet_boundary([1,0.,0.]) # Constant boundary values
70amplitude = 1
71Bw = Time_boundary(domain=domain,     # Time dependent boundary 
72## Sine wave
73                   f=lambda t: [(-amplitude*sin((1./300.)*t*2*pi)), 0.0, 0.0])
74## Sawtooth?
75#                   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])
76## Sharp rise, linear fall
77#                   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])
78#                   f=lambda t: [amplitude*(1.-2.*(pi*(1./720.)*(t-720.))**2)/exp((pi*(1./720.)*(t-720.))**2) , 0.0, 0.0])
79#                   f=lambda t: [(-8.0*sin((1./720.)*t*2*pi))*((t<720.)-0.5*(t<360.)), 0.0, 0.0])
80
81# Associate boundary tags with boundary objects
82domain.set_boundary({'left': Bw, 'right': Bt, 'top': Br, 'bottom': Br})
83
84#------------------------------------------------------------------------------
85# Evolve system through time
86#------------------------------------------------------------------------------
87
88for t in domain.evolve(yieldstep = 20.0, finaltime = 40*60.):
89    domain.write_time()
90   
Note: See TracBrowser for help on using the repository browser.