1 | """Parabolic channel oscilation example |
---|
2 | """ |
---|
3 | #--------- |
---|
4 | #Import Modules |
---|
5 | #-------- |
---|
6 | import anuga |
---|
7 | #from anuga.shallow_water.shallow_water_domain import Domain as Domain |
---|
8 | import numpy |
---|
9 | |
---|
10 | from balanced_dev import * |
---|
11 | #from balanced_basic import * |
---|
12 | #from anuga.shallow_water_balanced2.swb2_domain import Domain as Domain |
---|
13 | #from anuga.shallow_water.shallow_water_domain import Domain as Domain |
---|
14 | #--------- |
---|
15 | #Setup computational domain |
---|
16 | #--------- |
---|
17 | points, vertices, boundary = anuga.rectangular_cross(200,10, len1=40.0,len2=2.0) |
---|
18 | |
---|
19 | domain=Domain(points,vertices,boundary) # Create Domain |
---|
20 | domain.set_name('parabola_v2') # Output to file runup.sww |
---|
21 | domain.set_datadir('.') # Use current folder |
---|
22 | domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1}) |
---|
23 | domain.set_minimum_allowed_height(0.01) |
---|
24 | # Time stepping |
---|
25 | #domain.set_timestepping_method('euler') # Default |
---|
26 | #domain.set_timestepping_method('rk2') # |
---|
27 | #domain.beta_w= 1. #0.2 |
---|
28 | #domain.beta_uh= 1. #0.2 |
---|
29 | #domain.beta_vh= 1. #0.2 |
---|
30 | #domain.beta_w_dry= 0.2 #0. |
---|
31 | #domain.beta_uh_dry= 0.2 #0. |
---|
32 | #domain.beta_vh_dry= 0.2 #0. |
---|
33 | #domain.alpha=100. |
---|
34 | |
---|
35 | #------------------ |
---|
36 | # Define topography |
---|
37 | #------------------ |
---|
38 | |
---|
39 | # Parameters for analytical solution |
---|
40 | D0=4.0 |
---|
41 | L=10.0 |
---|
42 | A = 2.0 |
---|
43 | |
---|
44 | def topography(x,y): |
---|
45 | return (D0/(L**2.))*(x-20.0)**2. |
---|
46 | |
---|
47 | def stage_init(x,y): |
---|
48 | wat= ( D0 + (2.0*A*D0/L**2.)*((x-20.0)-A/2.0) ) # Water elevation inside the parabola |
---|
49 | top=topography(x,y) # Bed elevation |
---|
50 | # Return the maximum of the water elevation and the bed elvation |
---|
51 | return wat*(wat>top) + top*(wat<=top) |
---|
52 | |
---|
53 | |
---|
54 | domain.set_quantity('elevation',topography) # Use function for elevation |
---|
55 | |
---|
56 | domain.set_quantity('friction',0.00) # No friction |
---|
57 | |
---|
58 | domain.set_quantity('stage', stage_init) # Constant negative initial stage |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | #-------------------------- |
---|
63 | # Setup boundary conditions |
---|
64 | #-------------------------- |
---|
65 | Br=anuga.Reflective_boundary(domain) # Solid reflective wall |
---|
66 | #Bt=anuga.Transmissive_boundary(domain) # Continue all values of boundary -- not used in this example |
---|
67 | #Bd=anuga.Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values -- not used in this example |
---|
68 | #Bw=anuga.Time_boundary(domain=domain, |
---|
69 | # f=lambda t: [(0.0*sin(t*2*pi)-0.1)*exp(-t)-0.1,0.0,0.0]) # Time varying boundary -- get rid of the 0.0 to do a runup. |
---|
70 | |
---|
71 | #---------------------------------------------- |
---|
72 | # Associate boundary tags with boundary objects |
---|
73 | #---------------------------------------------- |
---|
74 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom':Br}) |
---|
75 | |
---|
76 | #------------------------------ |
---|
77 | #Evolve the system through time |
---|
78 | #------------------------------ |
---|
79 | for t in domain.evolve(yieldstep=0.1,finaltime=90.0): |
---|
80 | print domain.timestepping_statistics() |
---|
81 | |
---|
82 | print 'Finished' |
---|