1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | |
---|
4 | """Simple water flow example using ANUGA |
---|
5 | |
---|
6 | Water driven up a linear slope and time varying boundary, |
---|
7 | similar to a beach environment |
---|
8 | |
---|
9 | This is a very simple test of the parallel algorithm |
---|
10 | """ |
---|
11 | |
---|
12 | |
---|
13 | #------------------------------------------------------------------------------ |
---|
14 | # Import necessary modules |
---|
15 | #------------------------------------------------------------------------------ |
---|
16 | |
---|
17 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
18 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
19 | from anuga.shallow_water import Domain |
---|
20 | from anuga.shallow_water import Reflective_boundary |
---|
21 | from anuga.shallow_water import Dirichlet_boundary |
---|
22 | from anuga.shallow_water import Time_boundary |
---|
23 | from anuga.shallow_water import Transmissive_boundary |
---|
24 | |
---|
25 | from parallel_api import * |
---|
26 | |
---|
27 | |
---|
28 | #-------------------------------------------------------------------------- |
---|
29 | # Setup computational domain |
---|
30 | #-------------------------------------------------------------------------- |
---|
31 | points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh |
---|
32 | domain = Domain(points, vertices, boundary) # Create domain |
---|
33 | domain.set_name('runup') # Set sww filename |
---|
34 | |
---|
35 | |
---|
36 | #-------------------------------------------------------------------------- |
---|
37 | # Setup initial conditions |
---|
38 | #-------------------------------------------------------------------------- |
---|
39 | |
---|
40 | def topography(x,y): |
---|
41 | return -x/2 # linear bed slope |
---|
42 | |
---|
43 | domain.set_quantity('elevation', topography) # Use function for elevation |
---|
44 | domain.set_quantity('friction', 0.1) # Constant friction |
---|
45 | domain.set_quantity('stage', -.4) # Constant initial stage |
---|
46 | |
---|
47 | |
---|
48 | #-------------------------------------------------------------------------- |
---|
49 | # Create the parallel domain |
---|
50 | #-------------------------------------------------------------------------- |
---|
51 | domain = distribute(domain) |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | # TODO: Communicate all attributes of domain including boundary conditions |
---|
56 | |
---|
57 | # Name and dir, etc currently has to be set here as they are not |
---|
58 | # transferred from the original domain |
---|
59 | domain.set_name('runup') # Set sww filename |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | #------------------------------------------------------------------------------ |
---|
65 | # Setup parallel boundary conditions |
---|
66 | #------------------------------------------------------------------------------ |
---|
67 | |
---|
68 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
69 | Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values |
---|
70 | |
---|
71 | # Associate boundary tags with boundary objects |
---|
72 | domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br, |
---|
73 | 'ghost': None}) |
---|
74 | |
---|
75 | |
---|
76 | #------------------------------------------------------------------------------ |
---|
77 | # Evolve system through time |
---|
78 | #------------------------------------------------------------------------------ |
---|
79 | |
---|
80 | for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0): |
---|
81 | domain.write_time() |
---|
82 | |
---|
83 | |
---|