1 | """Simple water flow example using ANUGA |
---|
2 | |
---|
3 | Water driven up a linear slope and time varying boundary, |
---|
4 | similar to a beach environment |
---|
5 | """ |
---|
6 | |
---|
7 | |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | # Import necessary modules |
---|
10 | #------------------------------------------------------------------------------ |
---|
11 | |
---|
12 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular |
---|
13 | from anuga.shallow_water import Domain |
---|
14 | from anuga.shallow_water import Reflective_boundary |
---|
15 | from anuga.shallow_water import Dirichlet_boundary |
---|
16 | from anuga.shallow_water import Time_boundary |
---|
17 | from anuga.shallow_water import Transmissive_boundary |
---|
18 | |
---|
19 | |
---|
20 | #------------------------------------------------------------------------------ |
---|
21 | # Setup computational domain |
---|
22 | #------------------------------------------------------------------------------ |
---|
23 | |
---|
24 | points, vertices, boundary = rectangular(4, 1, len1=4, len2=1) |
---|
25 | domain = Domain(points, vertices, boundary) |
---|
26 | domain.set_name('limiter_test') |
---|
27 | domain.set_store_vertices_uniquely(True) |
---|
28 | domain.set_default_order(2) |
---|
29 | domain.limit2007 = 1 |
---|
30 | |
---|
31 | #------------------------------------------------------------------------------ |
---|
32 | # Setup initial conditions |
---|
33 | #------------------------------------------------------------------------------ |
---|
34 | |
---|
35 | def topography(x,y): |
---|
36 | from Numeric import zeros, size, Float |
---|
37 | |
---|
38 | z = zeros(size(x), Float) |
---|
39 | for i in range(len(x)): |
---|
40 | if x[i] < 2: |
---|
41 | z[i] = 1.0 |
---|
42 | else: |
---|
43 | z[i] = 0.0 |
---|
44 | return z |
---|
45 | |
---|
46 | |
---|
47 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
48 | domain.set_quantity('stage', 0.5) # Constant initial stage |
---|
49 | |
---|
50 | |
---|
51 | #------------------------------------------------------------------------------ |
---|
52 | # Setup boundary conditions |
---|
53 | #------------------------------------------------------------------------------ |
---|
54 | |
---|
55 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
56 | domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
57 | |
---|
58 | #------------------------------------------------------------------------------ |
---|
59 | # Evolve system through time |
---|
60 | #------------------------------------------------------------------------------ |
---|
61 | |
---|
62 | for t in domain.evolve(yieldstep = 0.1, finaltime = 50.0): |
---|
63 | domain.write_time() |
---|
64 | |
---|
65 | print 'done' |
---|
66 | |
---|
67 | |
---|
68 | |
---|